summaryrefslogtreecommitdiffstats
path: root/contrib/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gdb')
-rw-r--r--contrib/gdb/bfd/acconfig.h19
-rw-r--r--contrib/gdb/bfd/aix386-core.c285
-rw-r--r--contrib/gdb/bfd/aout-adobe.c528
-rw-r--r--contrib/gdb/bfd/aout-arm.c548
-rw-r--r--contrib/gdb/bfd/aout-encap.c236
-rw-r--r--contrib/gdb/bfd/aout-ns32k.c399
-rw-r--r--contrib/gdb/bfd/aout0.c32
-rw-r--r--contrib/gdb/bfd/aout64.c31
-rw-r--r--contrib/gdb/bfd/aoutf1.h788
-rw-r--r--contrib/gdb/bfd/bfd-in2.h2479
-rw-r--r--contrib/gdb/bfd/bout.c1471
-rw-r--r--contrib/gdb/bfd/cf-i386lynx.c31
-rw-r--r--contrib/gdb/bfd/cf-m68klynx.c223
-rw-r--r--contrib/gdb/bfd/cf-sparclynx.c28
-rw-r--r--contrib/gdb/bfd/cisco-core.c313
-rw-r--r--contrib/gdb/bfd/coff-a29k.c641
-rw-r--r--contrib/gdb/bfd/coff-alpha.c2390
-rw-r--r--contrib/gdb/bfd/coff-apollo.c162
-rw-r--r--contrib/gdb/bfd/coff-arm.c537
-rw-r--r--contrib/gdb/bfd/coff-aux.c332
-rw-r--r--contrib/gdb/bfd/coff-go32.c25
-rw-r--r--contrib/gdb/bfd/coff-h8300.c650
-rw-r--r--contrib/gdb/bfd/coff-h8500.c355
-rw-r--r--contrib/gdb/bfd/coff-i860.c423
-rw-r--r--contrib/gdb/bfd/coff-i960.c683
-rw-r--r--contrib/gdb/bfd/coff-m68k.c203
-rw-r--r--contrib/gdb/bfd/coff-m88k.c311
-rw-r--r--contrib/gdb/bfd/coff-mips.c2596
-rw-r--r--contrib/gdb/bfd/coff-pmac.c27
-rw-r--r--contrib/gdb/bfd/coff-ppc.c3255
-rw-r--r--contrib/gdb/bfd/coff-rs6000.c1403
-rw-r--r--contrib/gdb/bfd/coff-sh.c1525
-rw-r--r--contrib/gdb/bfd/coff-sparc.c278
-rw-r--r--contrib/gdb/bfd/coff-u68k.c35
-rw-r--r--contrib/gdb/bfd/coff-w65.c446
-rw-r--r--contrib/gdb/bfd/coff-we32k.c110
-rw-r--r--contrib/gdb/bfd/coff-z8k.c281
-rw-r--r--contrib/gdb/bfd/cofflink.c2327
-rw-r--r--contrib/gdb/bfd/configure.bat18
-rw-r--r--contrib/gdb/bfd/cpu-a29k.c39
-rw-r--r--contrib/gdb/bfd/cpu-alpha.c38
-rw-r--r--contrib/gdb/bfd/cpu-arm.c39
-rw-r--r--contrib/gdb/bfd/cpu-h8300.c246
-rw-r--r--contrib/gdb/bfd/cpu-h8500.c199
-rw-r--r--contrib/gdb/bfd/cpu-hppa.c54
-rw-r--r--contrib/gdb/bfd/cpu-i860.c40
-rw-r--r--contrib/gdb/bfd/cpu-i960.c162
-rw-r--r--contrib/gdb/bfd/cpu-m68k.c42
-rw-r--r--contrib/gdb/bfd/cpu-m88k.c42
-rw-r--r--contrib/gdb/bfd/cpu-mips.c85
-rw-r--r--contrib/gdb/bfd/cpu-ns32k.c868
-rw-r--r--contrib/gdb/bfd/cpu-powerpc.c124
-rw-r--r--contrib/gdb/bfd/cpu-rs6000.c70
-rw-r--r--contrib/gdb/bfd/cpu-sh.c68
-rw-r--r--contrib/gdb/bfd/cpu-sparc.c111
-rw-r--r--contrib/gdb/bfd/cpu-vax.c39
-rw-r--r--contrib/gdb/bfd/cpu-w65.c54
-rw-r--r--contrib/gdb/bfd/cpu-we32k.c39
-rw-r--r--contrib/gdb/bfd/cpu-z8k.c198
-rw-r--r--contrib/gdb/bfd/demo64.c24
-rw-r--r--contrib/gdb/bfd/ecoffswap.h853
-rw-r--r--contrib/gdb/bfd/elf32-gen.c37
-rw-r--r--contrib/gdb/bfd/elf32-hppa.c2984
-rw-r--r--contrib/gdb/bfd/elf32-hppa.h152
-rw-r--r--contrib/gdb/bfd/elf32-i386.c1546
-rw-r--r--contrib/gdb/bfd/elf32-i860.c33
-rw-r--r--contrib/gdb/bfd/elf32-m68k.c1600
-rw-r--r--contrib/gdb/bfd/elf32-m88k.c35
-rw-r--r--contrib/gdb/bfd/elf32-mips.c5867
-rw-r--r--contrib/gdb/bfd/elf32-ppc.c2554
-rw-r--r--contrib/gdb/bfd/elf32-sparc.c1795
-rw-r--r--contrib/gdb/bfd/elf32.c23
-rw-r--r--contrib/gdb/bfd/elf64-gen.c37
-rw-r--r--contrib/gdb/bfd/elf64-sparc.c421
-rw-r--r--contrib/gdb/bfd/elf64.c22
-rw-r--r--contrib/gdb/bfd/elfcode.h1406
-rw-r--r--contrib/gdb/bfd/elfcore.h475
-rw-r--r--contrib/gdb/bfd/elflink.c372
-rw-r--r--contrib/gdb/bfd/elflink.h3424
-rw-r--r--contrib/gdb/bfd/elfxx-target.h450
-rw-r--r--contrib/gdb/bfd/filemode.c193
-rw-r--r--contrib/gdb/bfd/freebsd.h22
-rw-r--r--contrib/gdb/bfd/gen-aout.c101
-rw-r--r--contrib/gdb/bfd/host-aout.c83
-rw-r--r--contrib/gdb/bfd/hp300bsd.c38
-rw-r--r--contrib/gdb/bfd/hp300hpux.c865
-rw-r--r--contrib/gdb/bfd/hppa_stubs.h23
-rw-r--r--contrib/gdb/bfd/hppabsd-core.c305
-rw-r--r--contrib/gdb/bfd/hpux-core.c270
-rw-r--r--contrib/gdb/bfd/i386dynix.c80
-rw-r--r--contrib/gdb/bfd/i386linux.c762
-rw-r--r--contrib/gdb/bfd/i386lynx.c563
-rw-r--r--contrib/gdb/bfd/i386mach3.c65
-rw-r--r--contrib/gdb/bfd/i386msdos.c243
-rw-r--r--contrib/gdb/bfd/i386netbsd.c33
-rw-r--r--contrib/gdb/bfd/i386os9k.c370
-rw-r--r--contrib/gdb/bfd/ieee.c3738
-rw-r--r--contrib/gdb/bfd/irix-core.c263
-rw-r--r--contrib/gdb/bfd/libbfd-in.h503
-rw-r--r--contrib/gdb/bfd/libcoff-in.h482
-rw-r--r--contrib/gdb/bfd/libhppa.h549
-rw-r--r--contrib/gdb/bfd/libieee.h135
-rw-r--r--contrib/gdb/bfd/libnlm.h264
-rw-r--r--contrib/gdb/bfd/liboasys.h83
-rw-r--r--contrib/gdb/bfd/lynx-core.c233
-rw-r--r--contrib/gdb/bfd/m68k4knetbsd.c35
-rw-r--r--contrib/gdb/bfd/m68klinux.c767
-rw-r--r--contrib/gdb/bfd/m68klynx.c54
-rw-r--r--contrib/gdb/bfd/m68knetbsd.c35
-rw-r--r--contrib/gdb/bfd/m88kmach3.c38
-rw-r--r--contrib/gdb/bfd/makefile.dos49
-rw-r--r--contrib/gdb/bfd/mipsbsd.c467
-rw-r--r--contrib/gdb/bfd/mpw-config.in73
-rw-r--r--contrib/gdb/bfd/mpw-make.sed70
-rw-r--r--contrib/gdb/bfd/netbsd-core.c310
-rw-r--r--contrib/gdb/bfd/netbsd.h108
-rw-r--r--contrib/gdb/bfd/newsos3.c40
-rw-r--r--contrib/gdb/bfd/nlm-target.h228
-rw-r--r--contrib/gdb/bfd/nlm.c55
-rw-r--r--contrib/gdb/bfd/nlm32-alpha.c892
-rw-r--r--contrib/gdb/bfd/nlm32-i386.c451
-rw-r--r--contrib/gdb/bfd/nlm32-ppc.c1045
-rw-r--r--contrib/gdb/bfd/nlm32-sparc.c440
-rw-r--r--contrib/gdb/bfd/nlm32.c21
-rw-r--r--contrib/gdb/bfd/nlm64.c21
-rw-r--r--contrib/gdb/bfd/nlmcode.h2057
-rw-r--r--contrib/gdb/bfd/nlmswap.h157
-rw-r--r--contrib/gdb/bfd/ns32knetbsd.c53
-rw-r--r--contrib/gdb/bfd/oasys.c1533
-rw-r--r--contrib/gdb/bfd/osf-core.c256
-rw-r--r--contrib/gdb/bfd/pc532-mach.c121
-rw-r--r--contrib/gdb/bfd/pe-arm.c32
-rw-r--r--contrib/gdb/bfd/pe-i386.c30
-rw-r--r--contrib/gdb/bfd/pe-ppc.c39
-rw-r--r--contrib/gdb/bfd/pei-arm.c33
-rw-r--r--contrib/gdb/bfd/pei-i386.c33
-rw-r--r--contrib/gdb/bfd/pei-ppc.c44
-rw-r--r--contrib/gdb/bfd/peicode.h1861
-rw-r--r--contrib/gdb/bfd/ptrace-core.c233
-rw-r--r--contrib/gdb/bfd/reloc16.c289
-rw-r--r--contrib/gdb/bfd/riscix.c644
-rw-r--r--contrib/gdb/bfd/rs6000-core.c396
-rw-r--r--contrib/gdb/bfd/som.c5999
-rw-r--r--contrib/gdb/bfd/som.h224
-rw-r--r--contrib/gdb/bfd/sparclynx.c265
-rw-r--r--contrib/gdb/bfd/sparcnetbsd.c33
-rw-r--r--contrib/gdb/bfd/sunos.c2767
-rw-r--r--contrib/gdb/bfd/trad-core.c1
-rw-r--r--contrib/gdb/bfd/versados.c906
-rw-r--r--contrib/gdb/bfd/xcofflink.c5798
-rw-r--r--contrib/gdb/gdb/ChangeLog-937597
-rw-r--r--contrib/gdb/gdb/ChangeLog-945705
-rw-r--r--contrib/gdb/gdb/ChangeLog-954915
-rw-r--r--contrib/gdb/gdb/acconfig.h95
-rw-r--r--contrib/gdb/gdb/alpha-nat.c297
-rw-r--r--contrib/gdb/gdb/alpha-tdep.c1410
-rw-r--r--contrib/gdb/gdb/arm-convert.s16
-rw-r--r--contrib/gdb/gdb/arm-tdep.c1626
-rw-r--r--contrib/gdb/gdb/arm-xdep.c559
-rw-r--r--contrib/gdb/gdb/c-exp.tab.c2796
-rw-r--r--contrib/gdb/gdb/callback.c7
-rw-r--r--contrib/gdb/gdb/coff-solib.c134
-rw-r--r--contrib/gdb/gdb/coff-solib.h190
-rw-r--r--contrib/gdb/gdb/config/nm-empty.h2
-rw-r--r--contrib/gdb/gdb/config/nm-gnu.h46
-rw-r--r--contrib/gdb/gdb/config/nm-lynx.h83
-rw-r--r--contrib/gdb/gdb/config/nm-m3.h123
-rw-r--r--contrib/gdb/gdb/config/nm-nbsd.h86
-rw-r--r--contrib/gdb/gdb/config/nm-sysv4.h34
-rw-r--r--contrib/gdb/gdb/config/tm-lynx.h34
-rw-r--r--contrib/gdb/gdb/config/tm-nbsd.h19
-rw-r--r--contrib/gdb/gdb/config/tm-sunos.h31
-rw-r--r--contrib/gdb/gdb/config/tm-sysv4.h45
-rw-r--r--contrib/gdb/gdb/config/xm-aix4.h96
-rw-r--r--contrib/gdb/gdb/config/xm-lynx.h22
-rw-r--r--contrib/gdb/gdb/config/xm-mpw.h81
-rw-r--r--contrib/gdb/gdb/config/xm-nbsd.h37
-rw-r--r--contrib/gdb/gdb/config/xm-sysv4.h36
-rw-r--r--contrib/gdb/gdb/core-aout.c57
-rw-r--r--contrib/gdb/gdb/core-regset.c10
-rw-r--r--contrib/gdb/gdb/core-sol2.c133
-rw-r--r--contrib/gdb/gdb/cpu32bug-rom.c167
-rw-r--r--contrib/gdb/gdb/cxux-nat.c523
-rw-r--r--contrib/gdb/gdb/doc/gdb.texinfo2652
-rw-r--r--contrib/gdb/gdb/doc/refcard.dvibin21732 -> 0 bytes
-rw-r--r--contrib/gdb/gdb/doc/stabs.texinfo123
-rw-r--r--contrib/gdb/gdb/exec.c294
-rw-r--r--contrib/gdb/gdb/f-exp.tab.c2086
-rw-r--r--contrib/gdb/gdb/gdbserver/gdbreplay.c8
-rw-r--r--contrib/gdb/gdb/gdbserver/utils.c8
-rw-r--r--contrib/gdb/gdb/gnu-nat.c3201
-rw-r--r--contrib/gdb/gdb/gnu-nat.h93
-rw-r--r--contrib/gdb/gdb/go32-xdep.c35
-rw-r--r--contrib/gdb/gdb/i386-stub.c927
-rw-r--r--contrib/gdb/gdb/i386aix-nat.c362
-rw-r--r--contrib/gdb/gdb/i386b-nat.c98
-rw-r--r--contrib/gdb/gdb/i386gnu-nat.c357
-rw-r--r--contrib/gdb/gdb/i386ly-tdep.c43
-rw-r--r--contrib/gdb/gdb/i386m3-nat.c421
-rw-r--r--contrib/gdb/gdb/i386mach-nat.c163
-rw-r--r--contrib/gdb/gdb/i386v-nat.c392
-rw-r--r--contrib/gdb/gdb/i386v4-nat.c172
-rw-r--r--contrib/gdb/gdb/infptrace.c241
-rw-r--r--contrib/gdb/gdb/irix4-nat.c195
-rw-r--r--contrib/gdb/gdb/irix5-nat.c1349
-rw-r--r--contrib/gdb/gdb/isi-xdep.c20
-rw-r--r--contrib/gdb/gdb/kdb-start.c35
-rw-r--r--contrib/gdb/gdb/lynx-nat.c837
-rw-r--r--contrib/gdb/gdb/m2-exp.tab.c2089
-rw-r--r--contrib/gdb/gdb/m3-nat.c4646
-rw-r--r--contrib/gdb/gdb/m68k-stub.c1014
-rw-r--r--contrib/gdb/gdb/m68k-tdep.c516
-rw-r--r--contrib/gdb/gdb/m68knbsd-nat.c86
-rw-r--r--contrib/gdb/gdb/m88k-nat.c285
-rw-r--r--contrib/gdb/gdb/m88k-tdep.c629
-rw-r--r--contrib/gdb/gdb/minimon.h562
-rw-r--r--contrib/gdb/gdb/mon960-rom.c264
-rw-r--r--contrib/gdb/gdb/monitor.c2296
-rw-r--r--contrib/gdb/gdb/monitor.h247
-rw-r--r--contrib/gdb/gdb/mpw-config.in81
-rw-r--r--contrib/gdb/gdb/mpw-make.sed178
-rw-r--r--contrib/gdb/gdb/news-xdep.c65
-rw-r--r--contrib/gdb/gdb/nindy-tdep.c74
-rw-r--r--contrib/gdb/gdb/ns32k-tdep.c122
-rw-r--r--contrib/gdb/gdb/ns32km3-nat.c183
-rw-r--r--contrib/gdb/gdb/objfiles.c249
-rw-r--r--contrib/gdb/gdb/op50-rom.c142
-rw-r--r--contrib/gdb/gdb/osfsolib.c980
-rw-r--r--contrib/gdb/gdb/ppcbug-rom.c230
-rw-r--r--contrib/gdb/gdb/procfs.c5764
-rw-r--r--contrib/gdb/gdb/ptx4-nat.c209
-rw-r--r--contrib/gdb/gdb/pyr-tdep.c452
-rw-r--r--contrib/gdb/gdb/pyr-xdep.c370
-rw-r--r--contrib/gdb/gdb/remote-adapt.c1443
-rw-r--r--contrib/gdb/gdb/remote-array.c1497
-rw-r--r--contrib/gdb/gdb/remote-bug.c1099
-rw-r--r--contrib/gdb/gdb/remote-e7000.c2258
-rw-r--r--contrib/gdb/gdb/remote-eb.c1056
-rw-r--r--contrib/gdb/gdb/remote-es.c2202
-rw-r--r--contrib/gdb/gdb/remote-est.c171
-rw-r--r--contrib/gdb/gdb/remote-hms.c1500
-rw-r--r--contrib/gdb/gdb/remote-mips.c3655
-rw-r--r--contrib/gdb/gdb/remote-mm.c1673
-rw-r--r--contrib/gdb/gdb/remote-nindy.c852
-rw-r--r--contrib/gdb/gdb/remote-nrom.c360
-rw-r--r--contrib/gdb/gdb/remote-os9k.c1264
-rw-r--r--contrib/gdb/gdb/remote-pa.c1540
-rw-r--r--contrib/gdb/gdb/remote-rdp.c1512
-rw-r--r--contrib/gdb/gdb/remote-sim.c1003
-rw-r--r--contrib/gdb/gdb/remote-st.c879
-rw-r--r--contrib/gdb/gdb/remote-udi.c1694
-rw-r--r--contrib/gdb/gdb/remote-vx.c1467
-rw-r--r--contrib/gdb/gdb/remote-vx29k.c188
-rw-r--r--contrib/gdb/gdb/remote-vx68.c158
-rw-r--r--contrib/gdb/gdb/remote-vx960.c163
-rw-r--r--contrib/gdb/gdb/remote-vxmips.c201
-rw-r--r--contrib/gdb/gdb/remote-vxsparc.c196
-rw-r--r--contrib/gdb/gdb/remote.c2451
-rw-r--r--contrib/gdb/gdb/ser-e7kpc.c470
-rw-r--r--contrib/gdb/gdb/ser-go32.c958
-rw-r--r--contrib/gdb/gdb/ser-mac.c362
-rw-r--r--contrib/gdb/gdb/ser-unix.c88
-rw-r--r--contrib/gdb/gdb/solib.c572
-rw-r--r--contrib/gdb/gdb/somread.c803
-rw-r--r--contrib/gdb/gdb/somsolib.c1640
-rw-r--r--contrib/gdb/gdb/somsolib.h177
-rw-r--r--contrib/gdb/gdb/srec.h36
-rw-r--r--contrib/gdb/gdb/standalone.c593
-rw-r--r--contrib/gdb/gdb/stop-gdb.c110
-rw-r--r--contrib/gdb/gdb/stuff.c174
-rw-r--r--contrib/gdb/gdb/symfile.c1504
-rw-r--r--contrib/gdb/gdb/symm-nat.c846
-rw-r--r--contrib/gdb/gdb/symm-tdep.c93
-rw-r--r--contrib/gdb/gdb/target.c983
-rw-r--r--contrib/gdb/gdb/target.h542
-rw-r--r--contrib/gdb/gdb/umax-xdep.c133
-rw-r--r--contrib/gdb/gdb/xcoffread.c2811
-rw-r--r--contrib/gdb/gdb/xcoffsolib.c220
-rw-r--r--contrib/gdb/gdb/xmodem.c284
-rw-r--r--contrib/gdb/gdb/xmodem.h29
-rw-r--r--contrib/gdb/readline/doc/ChangeLog12
-rw-r--r--contrib/gdb/readline/doc/Makefile.in94
-rw-r--r--contrib/gdb/readline/doc/configure.in8
-rw-r--r--contrib/gdb/readline/doc/hist.texinfo106
-rw-r--r--contrib/gdb/readline/doc/hstech.texinfo311
-rw-r--r--contrib/gdb/readline/doc/hsuser.texinfo153
-rw-r--r--contrib/gdb/readline/doc/inc-hist.texi159
-rw-r--r--contrib/gdb/readline/doc/rlman.texinfo103
-rw-r--r--contrib/gdb/readline/doc/rltech.texinfo1012
-rw-r--r--contrib/gdb/readline/doc/rluser.texinfo566
290 files changed, 2336 insertions, 199315 deletions
diff --git a/contrib/gdb/bfd/acconfig.h b/contrib/gdb/bfd/acconfig.h
deleted file mode 100644
index 647798c..0000000
--- a/contrib/gdb/bfd/acconfig.h
+++ /dev/null
@@ -1,19 +0,0 @@
-
-/* Whether malloc must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_MALLOC
-
-/* Whether free must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_FREE
-@TOP@
-
-/* Do we need to use the b modifier when opening binary files? */
-#undef USE_BINARY_FOPEN
-
-/* Name of host specific header file to include in trad-core.c. */
-#undef TRAD_HEADER
-
-/* Define only if <sys/procfs.h> is available *and* it defines prstatus_t. */
-#undef HAVE_SYS_PROCFS_H
-
-/* Do we really want to use mmap if it's available? */
-#undef USE_MMAP
diff --git a/contrib/gdb/bfd/aix386-core.c b/contrib/gdb/bfd/aix386-core.c
deleted file mode 100644
index 21ec9a6..0000000
--- a/contrib/gdb/bfd/aix386-core.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/* BFD back-end for AIX on PS/2 core files.
- This was based on trad-core.c, which was written by John Gilmore of
- Cygnus Support.
- Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
- Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "coff/i386.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#include <stdio.h>
-#include <stddef.h>
-#include <signal.h>
-
-#include <errno.h>
-
-#if defined (_AIX) && defined (_I386)
-#define NOCHECKS /* this is for coredump.h */
-#define _h_USER /* avoid including user.h from coredump.h */
-#include <uinfo.h>
-#include <sys/i386/coredump.h>
-#endif /* _AIX && _I386 */
-
-/* maybe this could work on some other i386 but I have not tried it
- * mtranle@paris - Tue Sep 24 12:49:35 1991
- */
-
-#ifndef COR_MAGIC
-# define COR_MAGIC "core"
-#endif
-
-/* need this cast because ptr is really void * */
-#define core_hdr(bfd) \
- (((bfd->tdata.trad_core_data))->hdr)
-#define core_section(bfd,n) \
- (((bfd)->tdata.trad_core_data)->sections[n])
-#define core_regsec(bfd) \
- (((bfd)->tdata.trad_core_data)->reg_section)
-#define core_reg2sec(bfd) \
- (((bfd)->tdata.trad_core_data)->reg2_section)
-
-/* These are stored in the bfd's tdata */
-struct trad_core_struct {
- struct corehdr *hdr; /* core file header */
- asection *reg_section;
- asection *reg2_section;
- asection *sections[MAX_CORE_SEGS];
-};
-
-static const bfd_target *
-aix386_core_file_p (abfd)
- bfd *abfd;
-{
- int i,n;
- unsigned char longbuf[4]; /* Raw bytes of various header fields */
- int core_size = sizeof (struct corehdr);
- struct corehdr *core;
- struct mergem {
- struct trad_core_struct coredata;
- struct corehdr internal_core;
- } *mergem;
-
- if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf))
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- if (strncmp(longbuf,COR_MAGIC,4)) return 0;
-
- if (bfd_seek (abfd, 0L, false) < 0) return 0;
-
- mergem = (struct mergem *)bfd_zalloc (abfd, sizeof (struct mergem));
- if (mergem == NULL)
- return 0;
-
- core = &mergem->internal_core;
-
- if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- bfd_release (abfd, (char *)mergem);
- return 0;
- }
-
- set_tdata (abfd, &mergem->coredata);
- core_hdr (abfd) = core;
-
- /* create the sections. This is raunchy, but bfd_close wants to reclaim
- them */
- core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_regsec (abfd) == NULL)
- {
- loser:
- bfd_release (abfd, (char *)mergem);
- return 0;
- }
- core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_reg2sec (abfd) == NULL)
- {
- loser1:
- bfd_release (abfd, core_regsec (abfd));
- goto loser;
- }
-
- for (i=0, n=0 ; (i < MAX_CORE_SEGS) && (core->cd_segs[i].cs_type) ; i++)
- {
- if (core->cd_segs[i].cs_offset == 0)
- continue;
- core_section (abfd,n) =
- (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_section (abfd,n) == NULL)
- {
- int j;
- if (n > 0)
- {
- for (j=0; j < n; j++)
- bfd_release (abfd, core_section(abfd, j));
- }
- bfd_release (abfd, (char *)mergem);
- goto loser1;
- }
-
- switch (core->cd_segs[i].cs_type)
- {
- case COR_TYPE_DATA:
- core_section (abfd, n)->name = ".data";
- core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
- SEC_HAS_CONTENTS);
- break;
- case COR_TYPE_STACK:
- core_section (abfd, n)->name = ".stack";
- core_section (abfd, n)->flags = (SEC_ALLOC + SEC_LOAD +
- SEC_HAS_CONTENTS);
- break;
- case COR_TYPE_LIBDATA:
- core_section (abfd, n)->name = ".libdata";
- core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
- break;
- case COR_TYPE_WRITE:
- core_section (abfd, n)->name = ".writeable";
- core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
- break;
- case COR_TYPE_MSC:
- core_section (abfd, n)->name = ".misc";
- core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
- break;
- default:
- core_section (abfd, n)->name = ".unknown";
- core_section (abfd, n)->flags = (SEC_ALLOC + SEC_HAS_CONTENTS);
- break;
- }
- core_section (abfd, n)->_raw_size = core->cd_segs[i].cs_len;
- core_section (abfd, n)->vma = core->cd_segs[i].cs_address;
- core_section (abfd, n)->filepos = core->cd_segs[i].cs_offset;
- core_section (abfd, n)->alignment_power = 2;
- core_section (abfd, n)->next = NULL;
- if (n > 0)
- core_section (abfd, (n-1))->next = core_section (abfd, n);
-
- abfd->section_count = ++n;
- }
-
- core_regsec (abfd)->name = ".reg";
- core_reg2sec (abfd)->name = ".reg2";
-
- core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
- core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
-
- core_regsec (abfd)->_raw_size = sizeof(core->cd_regs);
- core_reg2sec (abfd)->_raw_size = sizeof(core->cd_fpregs);
-
- core_regsec (abfd)->vma = -1;
- core_reg2sec (abfd)->vma = -1;
-
- /* We'll access the regs afresh in the core file, like any section: */
- core_regsec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,cd_regs[0]);
- core_reg2sec (abfd)->filepos = (file_ptr)offsetof(struct corehdr,
- cd_fpregs);
-
- /* add the 2 reg fake sections to abfd */
- abfd->section_count += 2;
- abfd->sections = core_regsec (abfd);
- core_regsec (abfd)->next = core_reg2sec (abfd);
- core_reg2sec (abfd)->next = core_section (abfd, 0);
-
- return abfd->xvec;
-}
-
-static char *
-aix386_core_file_failing_command (abfd)
- bfd *abfd;
-{
- return core_hdr (abfd)->cd_comm;
-}
-
-static int
-aix386_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return core_hdr (abfd)->cd_cursig;
-}
-
-static boolean
-aix386_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd;
- bfd *exec_bfd;
-{
- return true; /* FIXME, We have no way of telling at this
- point */
-}
-
-/* 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, (*), ( const bfd_byte *))) swap_abort )
-#define NO_GETS ((PROTO(bfd_signed_vma, (*), (const bfd_byte *))) swap_abort )
-#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort )
-
-const bfd_target aix386_core_vec =
- {
- "aix386-core",
- bfd_target_unknown_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIANG_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- NO_GET, NO_GETS, NO_PUT,
- NO_GET, NO_GETS, NO_PUT,
- NO_GET, NO_GETS, NO_PUT, /* data */
- NO_GET, NO_GETS, NO_PUT,
- NO_GET, NO_GETS, NO_PUT,
- NO_GET, NO_GETS, NO_PUT, /* hdrs */
-
- {_bfd_dummy_target, _bfd_dummy_target,
- _bfd_dummy_target, aix386_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},
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (aix386),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/aout-adobe.c b/contrib/gdb/bfd/aout-adobe.c
deleted file mode 100644
index 36d230d..0000000
--- a/contrib/gdb/bfd/aout-adobe.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/* BFD back-end for a.out.adobe binaries.
- Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by Cygnus Support. Based on bout.c.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#include "aout/adobe.h"
-
-#include "aout/stab_gnu.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-extern const bfd_target a_out_adobe_vec; /* Forward decl */
-
-static const bfd_target *aout_adobe_callback PARAMS ((bfd *));
-
-extern boolean aout_32_slurp_symbol_table PARAMS ((bfd *abfd));
-extern boolean aout_32_write_syms PARAMS ((bfd *));
-static void aout_adobe_write_section PARAMS ((bfd *abfd, sec_ptr sect));
-
-/* Swaps the information in an executable header taken from a raw byte
- stream memory image, into the internal exec_header structure. */
-
-void aout_adobe_swap_exec_header_in
- PARAMS ((bfd *abfd, struct external_exec *raw_bytes,
- struct internal_exec *execp));
-
-void
-aout_adobe_swap_exec_header_in (abfd, raw_bytes, execp)
- bfd *abfd;
- struct external_exec *raw_bytes;
- 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);
-}
-
-/* Swaps the information in an internal exec header structure into the
- supplied buffer ready for writing to disk. */
-
-PROTO(void, aout_adobe_swap_exec_header_out,
- (bfd *abfd,
- struct internal_exec *execp,
- struct external_exec *raw_bytes));
-void
-aout_adobe_swap_exec_header_out (abfd, execp, raw_bytes)
- bfd *abfd;
- struct internal_exec *execp;
- 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);
-}
-
-
-static const bfd_target *
-aout_adobe_object_p (abfd)
- bfd *abfd;
-{
- struct internal_exec anexec;
- struct external_exec exec_bytes;
- char *targ;
-
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
-
- /* Normally we just compare for the magic number.
- However, a bunch of Adobe tools aren't fixed up yet; they generate
- files using ZMAGIC(!).
- If the environment variable GNUTARGET is set to "a.out.adobe", we will
- take just about any a.out file as an Adobe a.out file. FIXME! */
-
- if (N_BADMAG (anexec)) {
- extern char *getenv ();
-
- targ = getenv ("GNUTARGET");
- if (targ && !strcmp (targ, a_out_adobe_vec.name))
- ; /* Just continue anyway, if specifically set to this format */
- else
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- }
-
- aout_adobe_swap_exec_header_in (abfd, &exec_bytes, &anexec);
- return aout_32_some_aout_object_p (abfd, &anexec, aout_adobe_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 const bfd_target *
-aout_adobe_callback (abfd)
- bfd *abfd;
-{
- struct internal_exec *execp = exec_hdr (abfd);
- asection *sect;
- struct external_segdesc ext[1];
- char *section_name;
- char try_again[30]; /* name and number */
- char *newname;
- int trynum;
- flagword flags;
-
- /* Architecture and machine type -- unknown in this format. */
- bfd_set_arch_mach(abfd, bfd_arch_unknown, 0);
-
- /* The positions of the string table and symbol table. */
- obj_str_filepos (abfd) = N_STROFF (*execp);
- obj_sym_filepos (abfd) = N_SYMOFF (*execp);
-
- /* Suck up the section information from the file, one section at a time. */
-
- for (;;) {
- if (bfd_read ((PTR) ext, 1, sizeof (*ext), abfd) != sizeof (*ext)) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- switch (ext->e_type[0]) {
- case N_TEXT:
- section_name = ".text";
- flags = SEC_CODE | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
- break;
-
- case N_DATA:
- section_name = ".data";
- flags = SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
- break;
-
- case N_BSS:
- section_name = ".bss";
- flags = SEC_DATA | SEC_HAS_CONTENTS;
- break;
-
- case 0:
- goto no_more_sections;
-
- default:
- (*_bfd_error_handler)
- ("%s: Unknown section type in a.out.adobe file: %x\n",
- bfd_get_filename (abfd), ext->e_type[0]);
- goto no_more_sections;
- }
-
- /* First one is called ".text" or whatever; subsequent ones are
- ".text1", ".text2", ... */
-
- bfd_set_error (bfd_error_no_error);
- sect = bfd_make_section (abfd, section_name);
- trynum = 0;
- while (!sect) {
- if (bfd_get_error () != bfd_error_no_error)
- return 0; /* Some other error -- slide into the sunset */
- sprintf (try_again, "%s%d", section_name, ++trynum);
- sect = bfd_make_section (abfd, try_again);
- }
-
- /* Fix the name, if it is a sprintf'd name. */
- if (sect->name == try_again) {
- newname = (char *) bfd_zalloc(abfd, strlen (sect->name));
- if (newname == NULL)
- return 0;
- strcpy (newname, sect->name);
- sect->name = newname;
- }
-
- /* Now set the section's attributes. */
- bfd_set_section_flags (abfd, sect, flags);
- sect->_raw_size = ((ext->e_size[0] << 8) /* Assumed big-endian */
- | ext->e_size[1] << 8)
- | ext->e_size[2];
- sect->_cooked_size = sect->_raw_size;
- sect->vma = bfd_h_get_32 (abfd, ext->e_virtbase);
- sect->filepos = bfd_h_get_32 (abfd, ext->e_filebase);
- /* FIXME XXX alignment? */
-
- /* Set relocation information for first section of each type. */
- if (trynum == 0) switch (ext->e_type[0]) {
- case N_TEXT:
- sect->rel_filepos = N_TRELOFF (*execp);
- sect->reloc_count = execp->a_trsize;
- break;
-
- case N_DATA:
- sect->rel_filepos = N_DRELOFF (*execp);
- sect->reloc_count = execp->a_drsize;
- break;
- }
- }
-no_more_sections:
-
- adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
- adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
- adata(abfd).page_size = 1; /* Not applicable. */
- adata(abfd).segment_size = 1; /* Not applicable. */
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-
- return abfd->xvec;
-}
-
-struct bout_data_struct {
- struct aoutdata a;
- struct internal_exec e;
-};
-
-static boolean
-aout_adobe_mkobject (abfd)
- bfd *abfd;
-{
- struct bout_data_struct *rawptr;
-
- rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
- if (rawptr == NULL)
- return false;
-
- abfd->tdata.bout_data = rawptr;
- exec_hdr (abfd) = &rawptr->e;
-
- adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external);
- adata(abfd).symbol_entry_size = sizeof (struct external_nlist);
- adata(abfd).page_size = 1; /* Not applicable. */
- adata(abfd).segment_size = 1; /* Not applicable. */
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-
- return true;
-}
-
-
-static boolean
-aout_adobe_write_object_contents (abfd)
- bfd *abfd;
-{
- struct external_exec swapped_hdr;
- static struct external_segdesc sentinel[1]; /* Initialized to zero */
- asection *sect;
-
- exec_hdr (abfd)->a_info = ZMAGIC;
-
- /* Calculate text size as total of text sections, etc. */
-
- exec_hdr (abfd)->a_text = 0;
- exec_hdr (abfd)->a_data = 0;
- exec_hdr (abfd)->a_bss = 0;
- exec_hdr (abfd)->a_trsize = 0;
- exec_hdr (abfd)->a_drsize = 0;
-
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (sect->flags & SEC_CODE) {
- exec_hdr (abfd)->a_text += sect->_raw_size;
- exec_hdr (abfd)->a_trsize += sect->reloc_count *
- sizeof (struct reloc_std_external);
- } else if (sect->flags & SEC_DATA) {
- exec_hdr (abfd)->a_data += sect->_raw_size;
- exec_hdr (abfd)->a_drsize += sect->reloc_count *
- sizeof (struct reloc_std_external);
- } else if (sect->flags & SEC_ALLOC && !(sect->flags & SEC_LOAD)) {
- exec_hdr (abfd)->a_bss += sect->_raw_size;
- }
- }
-
- exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd)
- * sizeof (struct external_nlist);
- exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd);
-
- aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE))
- return false;
-
- /* Now write out the section information. Text first, data next, rest
- afterward. */
-
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (sect->flags & SEC_CODE) {
- aout_adobe_write_section (abfd, sect);
- }
- }
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (sect->flags & SEC_DATA) {
- aout_adobe_write_section (abfd, sect);
- }
- }
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (!(sect->flags & (SEC_CODE|SEC_DATA))) {
- aout_adobe_write_section (abfd, sect);
- }
- }
-
- /* Write final `sentinel` section header (with type of 0). */
- if (bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd)
- != sizeof (*sentinel))
- return false;
-
- /* Now write out reloc info, followed by syms and strings */
- if (bfd_get_symcount (abfd) != 0)
- {
- if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
- != 0)
- return false;
-
- if (! aout_32_write_syms (abfd))
- return false;
-
- if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET)
- != 0)
- return false;
-
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (sect->flags & SEC_CODE) {
- if (!aout_32_squirt_out_relocs (abfd, sect))
- return false;
- }
- }
-
- if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET)
- != 0)
- return false;
-
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (sect->flags & SEC_DATA) {
- if (!aout_32_squirt_out_relocs (abfd, sect))
- return false;
- }
- }
- }
- return true;
-}
-
-static void
-aout_adobe_write_section (abfd, sect)
- bfd *abfd;
- sec_ptr sect;
-{
- /* FIXME XXX */
-}
-
-static boolean
-aout_adobe_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- file_ptr section_start;
- sec_ptr sect;
-
- if (abfd->output_has_begun == false) { /* set by bfd.c handler */
-
- /* Assign file offsets to sections. Text sections are first, and
- are contiguous. Then data sections. Everything else at the end. */
-
- section_start = N_TXTOFF (ignore<-->me);
-
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (sect->flags & SEC_CODE) {
- sect->filepos = section_start;
- /* FIXME: Round to alignment */
- section_start += sect->_raw_size;
- }
- }
-
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (sect->flags & SEC_DATA) {
- sect->filepos = section_start;
- /* FIXME: Round to alignment */
- section_start += sect->_raw_size;
- }
- }
-
- for (sect = abfd->sections; sect; sect = sect->next) {
- if (sect->flags & SEC_HAS_CONTENTS &&
- !(sect->flags & (SEC_CODE|SEC_DATA))) {
- sect->filepos = section_start;
- /* FIXME: Round to alignment */
- section_start += sect->_raw_size;
- }
- }
- }
-
- /* regardless, once we know what we're doing, we might as well get going */
- if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
- return false;
-
- if (count != 0) {
- return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
- }
- return true;
-}
-
-static boolean
-aout_adobe_set_arch_mach (abfd, arch, machine)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- if (! bfd_default_set_arch_mach (abfd, arch, machine))
- return false;
-
- if (arch == bfd_arch_unknown
- || arch == bfd_arch_m68k)
- return true;
-
- return false;
-}
-
-static int
-aout_adobe_sizeof_headers (ignore_abfd, ignore)
- bfd *ignore_abfd;
- boolean ignore;
-{
- return sizeof(struct internal_exec);
-}
-
-
-
-
-/* Build the transfer vector for Adobe A.Out files. */
-
-#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
-
-#define aout_32_bfd_make_debug_symbol \
- ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
-
-#define aout_32_bfd_reloc_type_lookup \
- ((reloc_howto_type *(*) \
- PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
-
-#define aout_32_set_arch_mach aout_adobe_set_arch_mach
-#define aout_32_set_section_contents aout_adobe_set_section_contents
-
-#define aout_32_sizeof_headers aout_adobe_sizeof_headers
-#define aout_32_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
-#define aout_32_bfd_relax_section bfd_generic_relax_section
-#define aout_32_bfd_link_hash_table_create \
- _bfd_generic_link_hash_table_create
-#define aout_32_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define aout_32_bfd_final_link _bfd_generic_final_link
-#define aout_32_bfd_link_split_section _bfd_generic_link_split_section
-
-const bfd_target a_out_adobe_vec =
-{
- "a.out.adobe", /* name */
- bfd_target_aout_flavour,
- BFD_ENDIAN_BIG, /* data byte order is unknown (big assumed) */
- BFD_ENDIAN_BIG, /* hdr byte order is big */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT ),
- /* section flags */
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_DATA | SEC_RELOC),
- '_', /* symbol leading char */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
-
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
- {_bfd_dummy_target, aout_adobe_object_p, /* bfd_check_format */
- bfd_generic_archive_p, _bfd_dummy_target},
- {bfd_false, aout_adobe_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, aout_adobe_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (aout_32),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
- BFD_JUMP_TABLE_SYMBOLS (aout_32),
- BFD_JUMP_TABLE_RELOCS (aout_32),
- BFD_JUMP_TABLE_WRITE (aout_32),
- BFD_JUMP_TABLE_LINK (aout_32),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/aout-arm.c b/contrib/gdb/bfd/aout-arm.c
deleted file mode 100644
index 978664a..0000000
--- a/contrib/gdb/bfd/aout-arm.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/* BFD back-end for raw ARM a.out binaries.
- Copyright (C) 1994, 1995 Free Software Foundation, Inc.
- Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#define N_TXTADDR(x) \
- ((N_MAGIC(x) == NMAGIC) ? 0x8000 : \
- (N_MAGIC(x) != ZMAGIC) ? 0 : \
- (N_SHARED_LIB(x)) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) : \
- TEXT_START_ADDR)
-
-#define TEXT_START_ADDR 0x8000
-#define TARGET_PAGE_SIZE 0x8000
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define DEFAULT_ARCH bfd_arch_arm
-
-#define MY(OP) CAT(aoutarm_,OP)
-#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
- (((x).a_info & ~006000) != OMAGIC) && \
- ((x).a_info != NMAGIC))
-#define N_MAGIC(x) ((x).a_info & ~07200)
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "assert.h"
-
-#define MYARM(OP) CAT(aoutarm_,OP)
-reloc_howto_type *MYARM(bfd_reloc_type_lookup)
- PARAMS((bfd *, bfd_reloc_code_real_type));
-static boolean MYARM(write_object_contents) PARAMS((bfd *));
-
-/* Avoid multiple defininitions from aoutx if supporting standarad a.out
- as well as our own. */
-#define NAME(x,y) CAT3(aoutarm,_32_,y)
-
-#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
-
-#include "libaout.h"
-#include "aout/aout64.h"
-
-static bfd_reloc_status_type
-MY(fix_pcrel_26_done) PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-
-static bfd_reloc_status_type
-MY(fix_pcrel_26) PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-static void MY(swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
- arelent *, asymbol **,
- bfd_size_type));
-void MY(swap_std_reloc_out) PARAMS ((bfd *, arelent *,
- struct reloc_std_external *));
-
-reloc_howto_type MY(howto_table)[] =
-{
- /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask
- pcdone */
- HOWTO (0, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true,
- 0x000000ff, 0x000000ff, false),
- HOWTO (1, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true,
- 0x0000ffff, 0x0000ffff, false),
- HOWTO (2, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true,
- 0xffffffff, 0xffffffff, false),
- HOWTO (3, 2, 2, 26, true, 0, complain_overflow_signed, MY(fix_pcrel_26),
- "ARM26", true, 0x00ffffff, 0x00ffffff, true),
- HOWTO (4, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true,
- 0x000000ff, 0x000000ff, true),
- HOWTO (5, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true,
- 0x0000ffff, 0x0000ffff, true),
- HOWTO (6, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true,
- 0xffffffff, 0xffffffff, true),
- HOWTO (7, 2, 2, 26, false, 0, complain_overflow_signed,
- MY(fix_pcrel_26_done), "ARM26D", true, 0x0, 0x0,
- false),
- {-1},
- HOWTO (9, 0, -1, 16, false, 0, complain_overflow_bitfield, 0, "NEG16", true,
- 0x0000ffff, 0x0000ffff, false),
- HOWTO (10, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "NEG32", true,
- 0xffffffff, 0xffffffff, false)
-};
-
-#define RELOC_ARM_BITS_NEG_BIG ((unsigned int) 0x08)
-#define RELOC_ARM_BITS_NEG_LITTLE ((unsigned int) 0x10)
-
-reloc_howto_type *
-MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
- bfd *abfd;
- struct reloc_std_external *rel;
- int *r_index;
- int *r_extern;
- int *r_pcrel;
-{
- unsigned int r_length;
- unsigned int r_pcrel_done;
- unsigned int r_neg;
- int index;
-
- *r_pcrel = 0;
- if (bfd_header_big_endian (abfd))
- {
- *r_index = ((rel->r_index[0] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[2]);
- *r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
- r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
- r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_BIG));
- r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_BIG)
- >> RELOC_STD_BITS_LENGTH_SH_BIG);
- }
- else
- {
- *r_index = ((rel->r_index[2] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[0]);
- *r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
- r_pcrel_done = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
- r_neg = (0 != (rel->r_type[0] & RELOC_ARM_BITS_NEG_LITTLE));
- r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
- >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
- }
- index = r_length + 4 * r_pcrel_done + 8 * r_neg;
- if (index == 3)
- *r_pcrel = 1;
-
- return MY(howto_table) + index;
-}
-
-#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
- MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
-
-void
-MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
- bfd *abfd;
- int r_extern;
- int r_index;
- long value;
- reloc_howto_type *howto;
- struct reloc_std_external *reloc;
-{
- unsigned int r_length;
- int r_pcrel;
- int r_neg;
-
- PUT_WORD (abfd, value, reloc->r_address);
- r_length = howto->size ; /* Size as a power of two */
-
- /* Special case for branch relocations. */
- if (howto->type == 3 || howto->type == 7)
- r_length = 3;
-
- r_pcrel = howto->type & 4; /* PC Relative done? */
- r_neg = howto->type & 8; /* Negative relocation */
- if (bfd_header_big_endian (abfd))
- {
- reloc->r_index[0] = r_index >> 16;
- reloc->r_index[1] = r_index >> 8;
- reloc->r_index[2] = r_index;
- reloc->r_type[0] =
- ((r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
- | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
- | (r_neg ? RELOC_ARM_BITS_NEG_BIG : 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG));
- }
- else
- {
- reloc->r_index[2] = r_index >> 16;
- reloc->r_index[1] = r_index >> 8;
- reloc->r_index[0] = r_index;
- reloc->r_type[0] =
- ((r_extern ? RELOC_STD_BITS_EXTERN_LITTLE : 0)
- | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE : 0)
- | (r_neg ? RELOC_ARM_BITS_NEG_LITTLE : 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
- }
-}
-
-#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
- MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
-
-void
-MY(relocatable_reloc)(howto, abfd, reloc, amount, r_addr)
- reloc_howto_type *howto;
- bfd *abfd;
- struct reloc_std_external *reloc;
- bfd_vma *amount;
- bfd_vma r_addr;
-{
- if (howto->type == 3)
- {
- if (reloc->r_type[0]
- & (bfd_header_big_endian (abfd)
- ? RELOC_STD_BITS_EXTERN_BIG : RELOC_STD_BITS_EXTERN_LITTLE))
- {
- /* The reloc is still external, so don't modify anything. */
- *amount = 0;
- }
- else
- {
- *amount -= r_addr;
- /* Change the r_pcrel value -- on the ARM, this bit is set once the
- relocation is done. */
- if (bfd_header_big_endian (abfd))
- reloc->r_type[0] |= RELOC_STD_BITS_PCREL_BIG;
- else
- reloc->r_type[0] |= RELOC_STD_BITS_PCREL_LITTLE;
- }
- }
- else if (howto->type == 7)
- *amount = 0;
-}
-
-#define MY_relocatable_reloc(HOW, BFD, REL, AMOUNT, ADDR) \
- MY(relocatable_reloc)(HOW, BFD, REL, &(AMOUNT), ADDR)
-
-static bfd_reloc_status_type
-MY(fix_pcrel_26_done) (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- /* This is dead simple at present. */
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_type
-MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_vma relocation;
- bfd_size_type addr = reloc_entry->address;
- long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
- bfd_reloc_status_type flag = bfd_reloc_ok;
-
- /* If this is an undefined symbol, return error */
- if (symbol->section == &bfd_und_section
- && (symbol->flags & BSF_WEAK) == 0)
- return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
-
- /* If the sections are different, and we are doing a partial relocation,
- just ignore it for now. */
- if (symbol->section->name != input_section->name
- && output_bfd != (bfd *)NULL)
- return bfd_reloc_ok;
-
- relocation = (target & 0x00ffffff) << 2;
- relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
- relocation += symbol->value;
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
- relocation -= input_section->output_section->vma;
- relocation -= input_section->output_offset;
- relocation -= addr;
- if (relocation & 3)
- return bfd_reloc_overflow;
-
- /* Check for overflow */
- if (relocation & 0x02000000)
- {
- if ((relocation & ~0x03ffffff) != ~0x03ffffff)
- flag = bfd_reloc_overflow;
- }
- else if (relocation & ~0x03ffffff)
- flag = bfd_reloc_overflow;
-
- target &= ~0x00ffffff;
- target |= (relocation >> 2) & 0x00ffffff;
- bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
-
- /* Now the ARM magic... Change the reloc type so that it is marked as done.
- Strictly this is only necessary if we are doing a partial relocation. */
- reloc_entry->howto = &MY(howto_table)[7];
-
- return flag;
-}
-
-reloc_howto_type *
-MY(bfd_reloc_type_lookup)(abfd,code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
-#define ASTD(i,j) case i: return &MY(howto_table)[j]
- if (code == BFD_RELOC_CTOR)
- switch (bfd_get_arch_info (abfd)->bits_per_address)
- {
- case 32:
- code = BFD_RELOC_32;
- break;
- default: return (CONST struct reloc_howto_struct *) 0;
- }
-
- switch (code)
- {
- ASTD (BFD_RELOC_16, 1);
- ASTD (BFD_RELOC_32, 2);
- ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
- ASTD (BFD_RELOC_8_PCREL, 4);
- ASTD (BFD_RELOC_16_PCREL, 5);
- ASTD (BFD_RELOC_32_PCREL, 6);
- default: return (CONST struct reloc_howto_struct *) 0;
- }
-}
-
-#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
-#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
-#define MY_get_section_contents _bfd_generic_get_section_contents
-/* #define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create */
-/* #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols */
-/* #define MY_bfd_final_link _bfd_generic_final_link */
-
-#include "aoutx.h"
-
-static void
-MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
- bfd *abfd;
- struct reloc_std_external *bytes;
- arelent *cache_ptr;
- asymbol **symbols;
- bfd_size_type symcount;
-{
- int r_index;
- int r_extern;
- unsigned int r_length;
- int r_pcrel;
- struct aoutdata *su = &(abfd->tdata.aout_data->a);
-
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
-
- cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel);
-
- MOVE_ADDRESS (0);
-}
-
-void
-MY_swap_std_reloc_out (abfd, g, natptr)
- bfd *abfd;
- arelent *g;
- struct reloc_std_external *natptr;
-{
- int r_index;
- asymbol *sym = *(g->sym_ptr_ptr);
- int r_extern;
- int r_length;
- int r_pcrel;
- int r_neg = 0; /* Negative relocs use the BASEREL bit. */
- asection *output_section = sym->section->output_section;
-
- PUT_WORD(abfd, g->address, natptr->r_address);
-
- r_length = g->howto->size ; /* Size as a power of two */
- if (r_length < 0)
- {
- r_length = -r_length;
- r_neg = 1;
- }
-
- r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
-
- /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
- relocation has been done already (Only for the 26-bit one I think)???!!!
- */
-
- if (g->howto->type == 3)
- {
- r_length = 3;
- r_pcrel = 0;
- }
- else if (g->howto->type == 7)
- {
- r_length = 3;
- r_pcrel = 1;
- }
-
-
-#if 0
- /* For a standard reloc, the addend is in the object file. */
- r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
-#endif
-
- /* name was clobbered by aout_write_syms to be symbol index */
-
- /* If this relocation is relative to a symbol then set the
- r_index to the symbols index, and the r_extern bit.
-
- Absolute symbols can come in in two ways, either as an offset
- from the abs section, or as a symbol which has an abs value.
- check for that here
- */
-
- if (bfd_is_com_section (output_section)
- || output_section == &bfd_abs_section
- || output_section == &bfd_und_section)
- {
- if (bfd_abs_section.symbol == sym)
- {
- /* Whoops, looked like an abs symbol, but is really an offset
- from the abs section */
- r_index = 0;
- r_extern = 0;
- }
- else
- {
- /* Fill in symbol */
- r_extern = 1;
- r_index = (*(g->sym_ptr_ptr))->KEEPIT;
- }
- }
- else
- {
- /* Just an ordinary section */
- r_extern = 0;
- r_index = output_section->target_index;
- }
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd))
- {
- 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_neg ? RELOC_ARM_BITS_NEG_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_neg ? RELOC_ARM_BITS_NEG_LITTLE: 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
- }
-}
-
-#define MY_BFD_TARGET
-
-#include "aout-target.h"
-
-const bfd_target aout_arm_little_vec =
-{
- "a.out-arm-little", /* name */
- bfd_target_aout_flavour,
- BFD_ENDIAN_LITTLE, /* target byte order (little) */
- BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
- (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 */
- MY_symbol_leading_char,
- AR_PAD_CHAR, /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
- {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
- bfd_generic_archive_p, MY_core_file_p},
- {bfd_false, MY_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, MY_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (MY),
- BFD_JUMP_TABLE_COPY (MY),
- BFD_JUMP_TABLE_CORE (MY),
- BFD_JUMP_TABLE_ARCHIVE (MY),
- BFD_JUMP_TABLE_SYMBOLS (MY),
- BFD_JUMP_TABLE_RELOCS (MY),
- BFD_JUMP_TABLE_WRITE (MY),
- BFD_JUMP_TABLE_LINK (MY),
- BFD_JUMP_TABLE_DYNAMIC (MY),
-
- (PTR) MY_backend_data,
-};
-
-const bfd_target aout_arm_big_vec =
-{
- "a.out-arm-big", /* name */
- bfd_target_aout_flavour,
- BFD_ENDIAN_BIG, /* target byte order (big) */
- BFD_ENDIAN_BIG, /* target headers byte order (big) */
- (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 */
- MY_symbol_leading_char,
- AR_PAD_CHAR, /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
- {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
- bfd_generic_archive_p, MY_core_file_p},
- {bfd_false, MY_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, MY_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (MY),
- BFD_JUMP_TABLE_COPY (MY),
- BFD_JUMP_TABLE_CORE (MY),
- BFD_JUMP_TABLE_ARCHIVE (MY),
- BFD_JUMP_TABLE_SYMBOLS (MY),
- BFD_JUMP_TABLE_RELOCS (MY),
- BFD_JUMP_TABLE_WRITE (MY),
- BFD_JUMP_TABLE_LINK (MY),
- BFD_JUMP_TABLE_DYNAMIC (MY),
-
- (PTR) MY_backend_data,
-};
diff --git a/contrib/gdb/bfd/aout-encap.c b/contrib/gdb/bfd/aout-encap.c
deleted file mode 100644
index c25f903..0000000
--- a/contrib/gdb/bfd/aout-encap.c
+++ /dev/null
@@ -1,236 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* THIS MODULE IS NOT FINISHED. IT PROBABLY DOESN'T EVEN COMPILE. */
-
-#if 0
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define TEXT_START_ADDR 0
-#define BYTES_IN_WORD 4
-#endif
-
-#include "bfd.h"
-#include <sysdep.h>
-#include "libbfd.h"
-#include <aout/aout64.h>
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-const bfd_target *encap_real_callback ();
-
-const bfd_target *
-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;
-
- if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
- sizeof (magicbuf))
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- 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) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (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_realcallback);
-}
-
-/* Finish up the reading of a encapsulated-coff a.out file header */
-const bfd_target *
-encap_real_callback (abfd)
- bfd *abfd;
-{
- struct internal_exec *execp = exec_hdr (abfd);
-
- MY(callback)(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
-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, aout_backend_info (abfd)->exec_hdr_flags);
- 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;
-}
-
-#define MY_write_object_content encap_write_object_contents
-#define MY_object_p encap_object_p
-#define MY_exec_hdr_flags N_FLAGS_COFF_ENCAPSULATE
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/aout-ns32k.c b/contrib/gdb/bfd/aout-ns32k.c
deleted file mode 100644
index 269e053..0000000
--- a/contrib/gdb/bfd/aout-ns32k.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/* BFD back-end for ns32k a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
- Contributed by Ian Dall (idall@eleceng.adelaide.edu.au).
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-
-#include "bfd.h"
-#include "aout/aout64.h"
-
-#define MYNS(OP) CAT(ns32kaout_,OP)
-reloc_howto_type *
-MYNS(bfd_reloc_type_lookup)
- PARAMS((bfd *abfd AND
- bfd_reloc_code_real_type code));
-
-boolean
-MYNS(write_object_contents)
- PARAMS((bfd *abfd));
-
-/* Avoid multiple definitions from aoutx if supporting standard a.out format(s)
- * as well as this one
- */
-#define NAME(x,y) CAT3(ns32kaout,_32_,y)
-
-void bfd_ns32k_arch PARAMS ((void));
-long ns32k_get_displacement PARAMS ((bfd_byte *buffer, long offset, long size));
-int ns32k_put_displacement PARAMS ((long value, bfd_byte *buffer, long offset, long size));
-long ns32k_get_immediate PARAMS ((bfd_byte *buffer, long offset, long size));
-int ns32k_put_immediate PARAMS ((long value, bfd_byte *buffer, long offset, long size));
-bfd_reloc_status_type
- ns32k_reloc_disp PARAMS ((bfd *abfd, arelent *reloc_entry,
- struct symbol_cache_entry *symbol,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-bfd_reloc_status_type
- ns32k_reloc_imm PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- struct symbol_cache_entry *symbol,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-bfd_reloc_status_type
- ns32k_final_link_relocate PARAMS ((reloc_howto_type *howto,
- bfd *input_bfd,
- asection *input_section,
- bfd_byte *contents,
- bfd_vma address,
- bfd_vma value,
- bfd_vma addend ));
-bfd_reloc_status_type
- ns32k_relocate_contents PARAMS ((reloc_howto_type *howto,
- bfd *input_bfd,
- bfd_vma relocation,
- bfd_byte *location));
-
-#include "libaout.h"
-
-#define MY(OP) MYNS(OP)
-
-#define MY_swap_std_reloc_in MY(swap_std_reloc_in)
-#define MY_swap_std_reloc_out MY(swap_std_reloc_out)
-
-static void
-MY_swap_std_reloc_in PARAMS ((bfd *abfd, struct reloc_std_external *bytes,
- arelent *cache_ptr, asymbol **symbols,
- bfd_size_type symcount));
-
-static void
-MY_swap_std_reloc_out PARAMS ((bfd *abfd, arelent *g,
- struct reloc_std_external *natptr));
-
-/* The ns32k series is ah, unusual, when it comes to relocation.
- * There are three storage methods for relocateable objects. There
- * are displacements, immediate operands and ordinary twos complement
- * data. Of these, only the last fits into the standard relocation
- * scheme. Immediate operands are stored huffman encoded and
- * immediate operands are stored big endian (where as the natural byte
- * order is little endian for this achitecture).
-
- * Note that the ns32k displacement storage method is orthogonal to
- * whether the relocation is pc relative or not. The "displacement"
- * storage scheme is used for essentially all address constants. The
- * displacement can be relative to zero (absolute displacement),
- * relative to the pc (pc relative), the stack pointer, the frame
- * pointer, the static base register and general purpose register etc.
-
- * For example:
- *
- * sym1: .long . # pc relative 2's complement
- * sym1: .long foo # 2's complement not pc relative
- *
- * self: movd @self, r0 # pc relative displacement
- * movd foo, r0 # non pc relative displacement
- *
- * self: movd self, r0 # pc relative immediate
- * movd foo, r0 # non pc relative immediate
- *
- * In addition, for historical reasons the encoding of the relocation types
- * in the a.out format relocation entries is such that even the relocation
- * methods which are standard are not encoded the standard way.
- *
- */
-
-reloc_howto_type MY(howto_table)[] =
-{
-/* ns32k immediate operands */
-HOWTO(BFD_RELOC_NS32K_IMM_8, 0, 0, 8, false, 0, true,
- ns32k_reloc_imm, "NS32K_IMM_8",
- true, 0x000000ff,0x000000ff, false),
-HOWTO(BFD_RELOC_NS32K_IMM_16, 0, 1, 16, false, 0, true,
- ns32k_reloc_imm, "NS32K_IMM_16",
- true, 0x0000ffff,0x0000ffff, false),
-HOWTO(BFD_RELOC_NS32K_IMM_32, 0, 2, 32, false, 0, true,
- ns32k_reloc_imm, "NS32K_IMM_32",
- true, 0xffffffff,0xffffffff, false),
-HOWTO(BFD_RELOC_NS32K_IMM_8_PCREL, 0, 0, 8, true, 0, false,
- ns32k_reloc_imm, "PCREL_NS32K_IMM_8",
- true, 0x000000ff, 0x000000ff, false),
-HOWTO(BFD_RELOC_NS32K_IMM_16_PCREL, 0, 1, 16, true, 0, false,
- ns32k_reloc_imm, "PCREL_NS32K_IMM_16",
- true, 0x0000ffff,0x0000ffff, false),
-HOWTO(BFD_RELOC_NS32K_IMM_32_PCREL, 0, 2, 32, true, 0, false,
- ns32k_reloc_imm, "PCREL_NS32K_IMM_32",
- true, 0xffffffff,0xffffffff, false),
-
-/* ns32k displacements */
-HOWTO(BFD_RELOC_NS32K_DISP_8, 0, 0, 8, false, 0, true,
- ns32k_reloc_disp, "NS32K_DISP_8",
- true, 0x000000ff,0x000000ff, false),
-HOWTO(BFD_RELOC_NS32K_DISP_16, 0, 1, 16, false, 0, true,
- ns32k_reloc_disp, "NS32K_DISP_16",
- true, 0x0000ffff, 0x0000ffff, false),
-HOWTO(BFD_RELOC_NS32K_DISP_32, 0, 2, 32, false, 0, true,
- ns32k_reloc_disp, "NS32K_DISP_32",
- true, 0xffffffff, 0xffffffff, false),
-HOWTO(BFD_RELOC_NS32K_DISP_8_PCREL, 0, 0, 8, true, 0, false,
- ns32k_reloc_disp, "PCREL_NS32K_DISP_8",
- true, 0x000000ff,0x000000ff, false),
-HOWTO(BFD_RELOC_NS32K_DISP_16_PCREL, 0, 1, 16, true, 0, false,
- ns32k_reloc_disp, "PCREL_NS32K_DISP_16",
- true, 0x0000ffff,0x0000ffff, false),
-HOWTO(BFD_RELOC_NS32K_DISP_32_PCREL, 0, 2, 32, true, 0, false,
- ns32k_reloc_disp, "PCREL_NS32K_DISP_32",
- true, 0xffffffff,0xffffffff, false),
-
-/* Normal 2's complement */
-HOWTO(BFD_RELOC_8, 0, 0, 8, false, 0, complain_overflow_bitfield,0,
- "8", true, 0x000000ff,0x000000ff, false),
-HOWTO(BFD_RELOC_16, 0, 1, 16, false, 0, complain_overflow_bitfield,0,
- "16", true, 0x0000ffff,0x0000ffff, false),
-HOWTO(BFD_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,
- "32", true, 0xffffffff,0xffffffff, false),
-HOWTO(BFD_RELOC_8_PCREL, 0, 0, 8, true, 0, complain_overflow_signed, 0,
- "PCREL_8", true, 0x000000ff,0x000000ff, false),
-HOWTO(BFD_RELOC_16_PCREL, 0, 1, 16, true, 0, complain_overflow_signed, 0,
- "PCREL_16", true, 0x0000ffff,0x0000ffff, false),
-HOWTO(BFD_RELOC_32_PCREL, 0, 2, 32, true, 0, complain_overflow_signed, 0,
- "PCREL_32", true, 0xffffffff,0xffffffff, false),
-};
-
-
-#define CTOR_TABLE_RELOC_HOWTO(BFD) (MY(howto_table) + 14)
-
-#define RELOC_STD_BITS_NS32K_TYPE_BIG 0x06
-#define RELOC_STD_BITS_NS32K_TYPE_LITTLE 0x60
-#define RELOC_STD_BITS_NS32K_TYPE_SH_BIG 1
-#define RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE 5
-
-reloc_howto_type *
-MY(reloc_howto)(abfd, rel, r_index, r_extern, r_pcrel)
- bfd *abfd;
- struct reloc_std_external *rel;
- int *r_index;
- int *r_extern;
- int *r_pcrel;
-{
- unsigned int r_length;
- int r_ns32k_type;
-/* BFD_ASSERT(bfd_header_little_endian (abfd)); */
- *r_index = ((rel->r_index[2] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[0] );
- *r_extern = (0 != (rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
- *r_pcrel = (0 != (rel->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
- r_length = ((rel->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE)
- >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
- r_ns32k_type = ((rel->r_type[0] & RELOC_STD_BITS_NS32K_TYPE_LITTLE)
- >> RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
- return (MY(howto_table) + r_length + 3 * (*r_pcrel) + 6 * r_ns32k_type);
-}
-
-#define MY_reloc_howto(BFD,REL,IN,EX,PC) MY(reloc_howto)(BFD, REL, &IN, &EX, &PC)
-
-void
-MY(put_reloc)(abfd, r_extern, r_index, value, howto, reloc)
- bfd *abfd;
- int r_extern;
- int r_index;
- long value;
- reloc_howto_type *howto;
- struct reloc_std_external *reloc;
-{
- unsigned int r_length;
- int r_pcrel;
- int r_ns32k_type;
- PUT_WORD (abfd, value, reloc->r_address);
- r_length = howto->size ; /* Size as a power of two */
- r_pcrel = (int) howto->pc_relative; /* Relative to PC? */
- r_ns32k_type = (howto - MY(howto_table) )/6;
-/* BFD_ASSERT (bfd_header_little_endian (abfd)); */
- reloc->r_index[2] = r_index >> 16;
- reloc->r_index[1] = r_index >> 8;
- reloc->r_index[0] = r_index;
- reloc->r_type[0] =
- (r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0)
- | (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)
- | (r_ns32k_type << RELOC_STD_BITS_NS32K_TYPE_SH_LITTLE);
-}
-
-#define MY_put_reloc(BFD, EXT, IDX, VAL, HOWTO, RELOC) \
- MY(put_reloc)(BFD, EXT, IDX, VAL, HOWTO, RELOC)
-
-#define STAT_FOR_EXEC
-
-#define MY_final_link_relocate ns32k_final_link_relocate
-#define MY_relocate_contents ns32k_relocate_contents
-
-#include <aoutx.h>
-
-reloc_howto_type *
- MY(bfd_reloc_type_lookup)(abfd,code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
-
-#define ENTRY(i,j) case i: return &MY(howto_table)[j]
-
- int ext = obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE;
-
- BFD_ASSERT(ext == 0);
- if (code == BFD_RELOC_CTOR)
- switch (bfd_get_arch_info (abfd)->bits_per_address)
- {
- case 32:
- code = BFD_RELOC_32;
- break;
- }
- switch (code)
- {
- ENTRY(BFD_RELOC_NS32K_IMM_8, 0);
- ENTRY(BFD_RELOC_NS32K_IMM_16, 1);
- ENTRY(BFD_RELOC_NS32K_IMM_32, 2);
- ENTRY(BFD_RELOC_NS32K_IMM_8_PCREL, 3);
- ENTRY(BFD_RELOC_NS32K_IMM_16_PCREL, 4);
- ENTRY(BFD_RELOC_NS32K_IMM_32_PCREL, 5);
- ENTRY(BFD_RELOC_NS32K_DISP_8, 6);
- ENTRY(BFD_RELOC_NS32K_DISP_16, 7);
- ENTRY(BFD_RELOC_NS32K_DISP_32, 8);
- ENTRY(BFD_RELOC_NS32K_DISP_8_PCREL, 9);
- ENTRY(BFD_RELOC_NS32K_DISP_16_PCREL, 10);
- ENTRY(BFD_RELOC_NS32K_DISP_32_PCREL, 11);
- ENTRY(BFD_RELOC_8, 12);
- ENTRY(BFD_RELOC_16, 13);
- ENTRY(BFD_RELOC_32, 14);
- ENTRY(BFD_RELOC_8_PCREL, 15);
- ENTRY(BFD_RELOC_16_PCREL, 16);
- ENTRY(BFD_RELOC_32_PCREL, 17);
- default: return (reloc_howto_type *) NULL;
- }
-#undef ENTRY
-}
-
-
-static void
-MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount)
- bfd *abfd;
- struct reloc_std_external *bytes;
- arelent *cache_ptr;
- asymbol **symbols;
- bfd_size_type symcount;
-{
- int r_index;
- int r_extern;
- int r_pcrel;
- struct aoutdata *su = &(abfd->tdata.aout_data->a);
-
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
-
- /* now the fun stuff */
-
- cache_ptr->howto = MY_reloc_howto(abfd, bytes, r_index, r_extern, r_pcrel);
-
- MOVE_ADDRESS(0);
-}
-
-static void
-MY_swap_std_reloc_out (abfd, g, natptr)
- bfd *abfd;
- arelent *g;
- struct reloc_std_external *natptr;
-{
- int r_index;
- asymbol *sym = *(g->sym_ptr_ptr);
- int r_extern;
- unsigned int r_addend;
- asection *output_section = sym->section->output_section;
-
- r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
-
- /* name was clobbered by aout_write_syms to be symbol index */
-
- /* If this relocation is relative to a symbol then set the
- r_index to the symbols index, and the r_extern bit.
-
- Absolute symbols can come in in two ways, either as an offset
- from the abs section, or as a symbol which has an abs value.
- Check for that here. */
-
- if (bfd_is_com_section (output_section)
- || output_section == &bfd_abs_section
- || output_section == &bfd_und_section)
- {
- if (bfd_abs_section.symbol == sym)
- {
- /* Whoops, looked like an abs symbol, but is really an offset
- from the abs section */
- r_index = 0;
- r_extern = 0;
- }
- else
- {
- /* Fill in symbol */
- r_extern = 1;
-#undef KEEPIT
-#define KEEPIT udata.i
- r_index = (*(g->sym_ptr_ptr))->KEEPIT;
-#undef KEEPIT
- }
- }
- else
- {
- /* Just an ordinary section */
- r_extern = 0;
- r_index = output_section->target_index;
- }
-
- MY_put_reloc (abfd, r_extern, r_index, g->address, g->howto, natptr);
-}
-
-bfd_reloc_status_type
-ns32k_relocate_contents (howto, input_bfd, relocation, location)
- reloc_howto_type *howto;
- bfd *input_bfd;
- bfd_vma relocation;
- bfd_byte *location;
-{
- int r_ns32k_type = (howto - MY(howto_table)) / 6;
- long (*get_data)();
- int (*put_data)();
-
- switch (r_ns32k_type)
- {
- case 0:
- get_data = ns32k_get_immediate;
- put_data = ns32k_put_immediate;
- break;
- case 1:
- get_data = ns32k_get_displacement;
- put_data = ns32k_put_displacement;
- break;
- case 2:
- return _bfd_relocate_contents (howto, input_bfd, relocation,
- location);
- /* NOT REACHED */
- break;
- }
- return do_ns32k_reloc_contents (howto, input_bfd, relocation,
- location, get_data, put_data);
-}
diff --git a/contrib/gdb/bfd/aout0.c b/contrib/gdb/bfd/aout0.c
deleted file mode 100644
index 5bc7ae0..0000000
--- a/contrib/gdb/bfd/aout0.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* BFD backend for SunOS style a.out with flags set to 0
- Copyright (C) 1990, 91, 92, 93, 1994 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGETNAME "a.out-zero-big"
-#define MY(OP) CAT(aout0_big_,OP)
-
-#include "bfd.h"
-
-#define MY_exec_hdr_flags 0
-
-#define MACHTYPE_OK(mtype) \
- ((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020)
-
-/* Include the usual a.out support. */
-#include "aoutf1.h"
diff --git a/contrib/gdb/bfd/aout64.c b/contrib/gdb/bfd/aout64.c
deleted file mode 100644
index 84036c8..0000000
--- a/contrib/gdb/bfd/aout64.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* BFD back-end for 64-bit a.out files.
- Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define ARCH_SIZE 64
-
-/* aoutx.h requires definitions for BMAGIC and QMAGIC. */
-#ifndef BMAGIC
-#define BMAGIC 0
-#endif
-#ifndef QMAGIC
-#define QMAGIC 0
-#endif
-
-#include "aoutx.h"
diff --git a/contrib/gdb/bfd/aoutf1.h b/contrib/gdb/bfd/aoutf1.h
deleted file mode 100644
index 690d528..0000000
--- a/contrib/gdb/bfd/aoutf1.h
+++ /dev/null
@@ -1,788 +0,0 @@
-/* A.out "format 1" file handling code for BFD.
- Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#include "aout/sun4.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-
-/* This is needed to reject a NewsOS file, e.g. in
- gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
- I needed to add M_UNKNOWN to recognize a 68000 object, so this will
- probably no longer reject a NewsOS object. <ian@cygnus.com>. */
-#ifndef MACHTYPE_OK
-#define MACHTYPE_OK(mtype) \
- (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
- || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
- && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))
-#endif
-
-/*
-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{BFD_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
-
-*/
-
-/*SUPPRESS558*/
-/*SUPPRESS529*/
-
-static void
-#if ARCH_SIZE == 64
-sunos_64_set_arch_mach
-#else
-sunos_32_set_arch_mach
-#endif
- (abfd, machtype)
- bfd *abfd;
- int machtype;
-{
- /* Determine the architecture and machine type of the object file. */
- enum bfd_architecture arch;
- long machine;
- switch (machtype)
- {
-
- case M_UNKNOWN:
- /* Some Sun3s make magic numbers without cpu types in them, so
- we'll default to the 68000. */
- arch = bfd_arch_m68k;
- machine = 68000;
- 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:
- case M_386_DYNIX:
- 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);
-}
-
-#define SET_ARCH_MACH(ABFD, EXEC) \
- NAME(sunos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
- choose_reloc_size(ABFD);
-
-/* Determine the size of a relocation entry, based on the architecture */
-static void
-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;
- }
-}
-
-/* Write an object file in SunOS format.
- Section contents have already been written. We write the
- file header, symbols, and relocation. */
-
-static boolean
-#if ARCH_SIZE == 64
-aout_64_sunos4_write_object_contents
-#else
-aout_32_sunos4_write_object_contents
-#endif
- (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
- /* Magic number, maestro, please! */
- switch (bfd_get_arch (abfd))
- {
- case bfd_arch_m68k:
- switch (bfd_get_mach (abfd))
- {
- case 68000:
- N_SET_MACHTYPE (*execp, M_UNKNOWN);
- break;
- 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_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
-
- N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);
-
- 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.) */
- };
-
-/* Core files generated by the BCP (the part of Solaris which allows
- it to run SunOS4 a.out files). */
-struct external_solaris_bcp_core
- {
- int c_magic; /* Corefile magic number */
- int c_len; /* Sizeof (struct core) */
-#define SOLARIS_BCP_CORE_LEN 456
- int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */
- int c_exdata_vp; /* exdata structure */
- int c_exdata_tsize;
- int c_exdata_dsize;
- int c_exdata_bsize;
- int c_exdata_lsize;
- int c_exdata_nshlibs;
- short c_exdata_mach;
- short c_exdata_mag;
- int c_exdata_toffset;
- int c_exdata_doffset;
- int c_exdata_loffset;
- int c_exdata_txtorg;
- int c_exdata_datorg;
- int c_exdata_entloc;
- 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) */
- bfd_vma c_data_addr; /* Data start (address) */
- int c_ssize; /* Stack size (bytes) */
- bfd_vma 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
-swapcore_sun3 (abfd, ext, intcore)
- bfd *abfd;
- char *ext;
- 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);
-#if ARCH_SIZE == 64
- aout_64_swap_exec_header_in
-#else
- aout_32_swap_exec_header_in
-#endif
- (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_data_addr = N_DATADDR (intcore->c_aouthdr);
- intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
- memcpy (intcore->c_cmdname, extcore->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
-swapcore_sparc (abfd, ext, intcore)
- bfd *abfd;
- char *ext;
- 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);
-#if ARCH_SIZE == 64
- aout_64_swap_exec_header_in
-#else
- aout_32_swap_exec_header_in
-#endif
- (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_data_addr = N_DATADDR (intcore->c_aouthdr);
- intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
- memcpy (intcore->c_cmdname, extcore->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. */
- /* Now sun has provided us with another challenge. The value is different
- for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
- the other based on the current value of the stack pointer. This
- loses (a) if the stack pointer has been clobbered, or (b) if the stack
- is larger than 128 megabytes.
-
- It's times like these you're glad they're switching to ELF.
-
- Note that using include files or nlist on /vmunix would be wrong,
- because we want the value for this core file, no matter what kind of
- machine we were compiled on or are running on. */
-#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
-#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
- {
- bfd_vma sp = bfd_h_get_32
- (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
- if (sp < SPARC_USRSTACK_SPARC10)
- intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
- else
- intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
- }
-}
-
-/* byte-swap in the Solaris BCP core structure */
-static void
-swapcore_solaris_bcp (abfd, ext, intcore)
- bfd *abfd;
- char *ext;
- struct internal_sunos_core *intcore;
-{
- struct external_solaris_bcp_core *extcore =
- (struct external_solaris_bcp_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_solaris_bcp_core *) 0)->c_regs);
- intcore->c_regs_size = sizeof (extcore->c_regs);
-
- /* The Solaris BCP exdata structure does not contain an a_syms field,
- so we are unable to synthesize an internal exec header.
- Luckily we are able to figure out the start address of the data section,
- which is the only thing needed from the internal exec header,
- from the exdata structure.
-
- As of Solaris 2.3, BCP core files for statically linked executables
- are buggy. The exdata structure is not properly filled in, and
- the data section is written from address zero instead of the data
- start address. */
- memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
- intcore->c_data_addr =
- bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
- 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);
- memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
- intcore->fp_stuff_pos =
- (long) (((struct external_solaris_bcp_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_solaris_bcp_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. */
- /* Now sun has provided us with another challenge. The value is different
- for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or
- the other based on the current value of the stack pointer. This
- loses (a) if the stack pointer has been clobbered, or (b) if the stack
- is larger than 128 megabytes.
-
- It's times like these you're glad they're switching to ELF.
-
- Note that using include files or nlist on /vmunix would be wrong,
- because we want the value for this core file, no matter what kind of
- machine we were compiled on or are running on. */
-#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
-#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
- {
- bfd_vma sp = bfd_h_get_32
- (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
- if (sp < SPARC_USRSTACK_SPARC10)
- intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
- else
- intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
- }
-}
-
-/* need this cast because ptr is really void * */
-#define core_hdr(bfd) ((bfd)->tdata.sun_core_data)
-#define core_datasec(bfd) (core_hdr(bfd)->data_section)
-#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
-#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
-#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)
-
-/* These are stored in the bfd's tdata */
-struct sun_core_struct
-{
- struct internal_sunos_core *hdr; /* core file header */
- asection *data_section;
- asection *stack_section;
- asection *reg_section;
- asection *reg2_section;
-};
-
-static const bfd_target *
-sunos4_core_file_p (abfd)
- bfd *abfd;
-{
- unsigned char longbuf[4]; /* Raw bytes of various header fields */
- bfd_size_type core_size;
- unsigned long core_mag;
- struct internal_sunos_core *core;
- char *extcore;
- struct mergem
- {
- struct sun_core_struct suncoredata;
- struct internal_sunos_core internal_sunos_core;
- char external_core[1];
- }
- *mergem;
-
- 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, (file_ptr) 0, SEEK_SET) < 0)
- return 0;
-
- mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
- if (mergem == NULL)
- return 0;
-
- extcore = mergem->external_core;
-
- if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
- {
- 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;
- case SOLARIS_BCP_CORE_LEN:
- swapcore_solaris_bcp (abfd, extcore, core);
- break;
- default:
- bfd_set_error (bfd_error_system_call); /* FIXME */
- bfd_release (abfd, (char *) mergem);
- return 0;
- }
-
- abfd->tdata.sun_core_data = &mergem->suncoredata;
- abfd->tdata.sun_core_data->hdr = 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_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_HAS_CONTENTS;
- core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
-
- core_stacksec (abfd)->_raw_size = core->c_ssize;
- core_datasec (abfd)->_raw_size = core->c_dsize;
- core_regsec (abfd)->_raw_size = core->c_regs_size;
- core_reg2sec (abfd)->_raw_size = core->fp_stuff_size;
-
- core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
- core_datasec (abfd)->vma = core->c_data_addr;
- 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)->hdr->c_cmdname;
-}
-
-static int
-sunos4_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return core_hdr (abfd)->hdr->c_signo;
-}
-
-static boolean
-sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd;
- bfd *exec_bfd;
-{
- if (core_bfd->xvec != exec_bfd->xvec)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
-
- /* Solaris core files do not include an aouthdr. */
- if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
- return true;
-
- return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
- (char *) exec_hdr (exec_bfd),
- sizeof (struct internal_exec)) == 0) ? true : false;
-}
-
-#define MY_set_sizes sunos4_set_sizes
-static boolean
-sunos4_set_sizes (abfd)
- bfd *abfd;
-{
- switch (bfd_get_arch (abfd))
- {
- default:
- return false;
- case bfd_arch_sparc:
- adata (abfd).page_size = 0x2000;
- adata (abfd).segment_size = 0x2000;
- adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
- return true;
- case bfd_arch_m68k:
- adata (abfd).page_size = 0x2000;
- adata (abfd).segment_size = 0x20000;
- adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
- return true;
- }
-}
-
-/* We default to setting the toolversion field to 1, as is required by
- SunOS. */
-#ifndef MY_exec_hdr_flags
-#define MY_exec_hdr_flags 1
-#endif
-
-#ifndef MY_add_dynamic_symbols
-#define MY_add_dynamic_symbols 0
-#endif
-#ifndef MY_add_one_symbol
-#define MY_add_one_symbol 0
-#endif
-#ifndef MY_link_dynamic_object
-#define MY_link_dynamic_object 0
-#endif
-#ifndef MY_write_dynamic_symbol
-#define MY_write_dynamic_symbol 0
-#endif
-#ifndef MY_check_dynamic_reloc
-#define MY_check_dynamic_reloc 0
-#endif
-#ifndef MY_finish_dynamic_link
-#define MY_finish_dynamic_link 0
-#endif
-
-static CONST struct aout_backend_data sunos4_aout_backend =
-{
- 0, /* zmagic files are not contiguous */
- 1, /* text includes header */
- MY_exec_hdr_flags,
- 0, /* default text vma */
- sunos4_set_sizes,
- 0, /* header is counted in zmagic text */
- MY_add_dynamic_symbols,
- MY_add_one_symbol,
- MY_link_dynamic_object,
- MY_write_dynamic_symbol,
- MY_check_dynamic_reloc,
- MY_finish_dynamic_link
-};
-
-#define MY_core_file_failing_command sunos4_core_file_failing_command
-#define MY_core_file_failing_signal sunos4_core_file_failing_signal
-#define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p
-
-#define MY_bfd_debug_info_start bfd_void
-#define MY_bfd_debug_info_end bfd_void
-#define MY_bfd_debug_info_accumulate \
- (void (*) PARAMS ((bfd *, struct sec *))) bfd_void
-#define MY_core_file_p sunos4_core_file_p
-#define MY_write_object_contents NAME(aout,sunos4_write_object_contents)
-#define MY_backend_data &sunos4_aout_backend
-
-#define TARGET_IS_BIG_ENDIAN_P
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/bfd-in2.h b/contrib/gdb/bfd/bfd-in2.h
deleted file mode 100644
index d238d5a..0000000
--- a/contrib/gdb/bfd/bfd-in2.h
+++ /dev/null
@@ -1,2479 +0,0 @@
-/* Main header file for the bfd library -- portable access to object files.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
-
-** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them;
-** instead, change bfd-in.h or the other BFD source files processed to
-** generate these files.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* bfd.h -- The only header file required by users of the bfd library
-
-The bfd.h file is generated from bfd-in.h and various .c files; if you
-change it, your changes will probably 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__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "ansidecl.h"
-#include "obstack.h"
-
-/* These two lines get substitutions done by commands in Makefile.in. */
-#define BFD_VERSION "@VERSION@"
-#define BFD_ARCH_SIZE @WORDSIZE@
-#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
-
-#if BFD_ARCH_SIZE >= 64
-#define BFD64
-#endif
-
-#ifndef INLINE
-#if __GNUC__ >= 2
-#define INLINE __inline__
-#else
-#define INLINE
-#endif
-#endif
-
-/* forward declaration */
-typedef struct _bfd bfd;
-
-/* To squelch erroneous compiler warnings ("illegal pointer
- combination") from the SVR3 compiler, we would like to typedef
- boolean to int (it doesn't like functions which return boolean.
- Making sure they are never implicitly declared to return int
- doesn't seem to help). But this file is not configured based on
- the host. */
-/* 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 <sys/types.h> -fnf */
-/* It gets worse if the host also defines a true/false enum... -sts */
-/* And even worse if your compiler has built-in boolean types... -law */
-#if defined (__GNUG__) && (__GNUC_MINOR__ > 5)
-#define TRUE_FALSE_ALREADY_DEFINED
-#endif
-#ifdef MPW
-/* Pre-emptive strike - get the file with the enum. */
-#include <Types.h>
-#define TRUE_FALSE_ALREADY_DEFINED
-#endif /* MPW */
-#ifndef TRUE_FALSE_ALREADY_DEFINED
-typedef enum bfd_boolean {false, true} boolean;
-#define BFD_TRUE_FALSE
-#else
-/* Use enum names that will appear nowhere else. */
-typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
-#endif
-
-/* A pointer to a position in a file. */
-/* FIXME: This should be using off_t from <sys/types.h>.
- For now, try to avoid breaking stuff by not including <sys/types.h> here.
- This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
- Probably the best long-term answer is to avoid using file_ptr AND off_t
- in this header file, and to handle this in the BFD implementation
- rather than in its interface. */
-/* typedef off_t file_ptr; */
-typedef long int file_ptr;
-
-/* Support for different sizes of target format ints and addresses.
- If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
- set to 1 above. Otherwise, if gcc is being used, this code will
- use gcc's "long long" type. Otherwise, the compilation will fail
- if 64-bit targets are requested. */
-
-#ifdef BFD64
-
-#ifndef BFD_HOST_64_BIT
-#if BFD_HOST_64BIT_LONG
-#define BFD_HOST_64_BIT long
-#else
-#ifdef __GNUC__
-#define BFD_HOST_64_BIT long long
-#endif /* defined (__GNUC__) */
-#endif /* ! BFD_HOST_64BIT_LONG */
-#endif /* ! defined (BFD_HOST_64_BIT) */
-
-typedef unsigned BFD_HOST_64_BIT bfd_vma;
-typedef BFD_HOST_64_BIT bfd_signed_vma;
-typedef unsigned BFD_HOST_64_BIT bfd_size_type;
-typedef unsigned BFD_HOST_64_BIT symvalue;
-
-#ifndef fprintf_vma
-#if BFD_HOST_64BIT_LONG
-#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
-#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
-#else
-#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
-#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
-#define fprintf_vma(s,x) \
- fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
-#define sprintf_vma(s,x) \
- sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
-#endif
-#endif
-
-#else /* not BFD64 */
-
-/* Represent a target address. Also used as a generic unsigned type
- which is guaranteed to be big enough to hold any arithmetic types
- we need to deal with. */
-typedef unsigned long bfd_vma;
-
-/* A generic signed type which is guaranteed to be big enough to hold any
- arithmetic types we need to deal with. Can be assumed to be compatible
- with bfd_vma in the same way that signed and unsigned ints are compatible
- (as parameters, in assignment, etc). */
-typedef long bfd_signed_vma;
-
-typedef unsigned long symvalue;
-typedef unsigned long bfd_size_type;
-
-/* Print a bfd_vma x on stream s. */
-#define fprintf_vma(s,x) fprintf(s, "%08lx", x)
-#define sprintf_vma(s,x) sprintf(s, "%08lx", x)
-#endif /* not BFD64 */
-#define printf_vma(x) fprintf_vma(stdout,x)
-
-typedef unsigned int flagword; /* 32 bits of flags */
-typedef unsigned char bfd_byte;
-
-/** 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;
-
-/* Values that may appear in the flags field of a BFD. These also
- appear in the object_flags field of the bfd_target structure, where
- they indicate the set of flags used by that backend (not all flags
- are meaningful for all object file formats) (FIXME: at the moment,
- the object_flags values have mostly just been copied from backend
- to another, and are not necessarily correct). */
-
-/* No flags. */
-#define NO_FLAGS 0x00
-
-/* BFD contains relocation entries. */
-#define HAS_RELOC 0x01
-
-/* BFD is directly executable. */
-#define EXEC_P 0x02
-
-/* BFD has line number information (basically used for F_LNNO in a
- COFF header). */
-#define HAS_LINENO 0x04
-
-/* BFD has debugging information. */
-#define HAS_DEBUG 0x08
-
-/* BFD has symbols. */
-#define HAS_SYMS 0x10
-
-/* BFD has local symbols (basically used for F_LSYMS in a COFF
- header). */
-#define HAS_LOCALS 0x20
-
-/* BFD is a dynamic object. */
-#define DYNAMIC 0x40
-
-/* Text section is write protected (if D_PAGED is not set, this is
- like an a.out NMAGIC file) (the linker sets this by default, but
- clears it for -r or -N). */
-#define WP_TEXT 0x80
-
-/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
- linker sets this by default, but clears it for -r or -n or -N). */
-#define D_PAGED 0x100
-
-/* BFD is relaxable (this means that bfd_relax_section may be able to
- do something) (sometimes bfd_relax_section can do something even if
- this is not set). */
-#define BFD_IS_RELAXABLE 0x200
-
-/* This may be set before writing out a BFD to request using a
- traditional format. For example, this is used to request that when
- writing out an a.out object the symbols not be hashed to eliminate
- duplicates. */
-#define BFD_TRADITIONAL_FORMAT 0x400
-
-/* This flag indicates that the BFD contents are actually cached in
- memory. If this is set, iostream points to a bfd_in_memory struct. */
-#define BFD_IN_MEMORY 0x800
-
-/* symbols and relocation */
-
-/* A count of carsyms (canonical archive symbols). */
-typedef unsigned long symindex;
-
-/* How to perform a relocation. */
-typedef const struct reloc_howto_struct reloc_howto_type;
-
-#define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
-
-/* General purpose part of a symbol X;
- target specific parts are in libcoff.h, libaout.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->vma)
-#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
-#define bfd_asymbol_name(x) ((x)->name)
-/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
-#define bfd_asymbol_bfd(x) ((x)->the_bfd)
-#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
-
-/* A canonical archive symbol. */
-/* 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 (archive tables of contents).
- 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_get_section_name(bfd, ptr) ((ptr)->name + 0)
-#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
-#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
-#define bfd_section_name(bfd, ptr) ((ptr)->name)
-#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
-#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 + 0)
-#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
-
-#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
-
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true)
-#define bfd_set_section_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;
-
-typedef enum bfd_print_symbol
-{
- bfd_print_symbol_name,
- bfd_print_symbol_more,
- bfd_print_symbol_all
-} bfd_print_symbol_type;
-
-/* Information about a symbol that nm needs. */
-
-typedef struct _symbol_info
-{
- symvalue value;
- char type;
- CONST char *name; /* Symbol name. */
- unsigned char stab_type; /* Stab type. */
- char stab_other; /* Stab other. */
- short stab_desc; /* Stab desc. */
- CONST char *stab_name; /* String for stab type. */
-} symbol_info;
-
-/* Get the name of a stabs type code. */
-
-extern const char *bfd_get_stab_name PARAMS ((int));
-
-/* Hash table routines. There is no way to free up a hash table. */
-
-/* An element in the hash table. Most uses will actually use a larger
- structure, and an instance of this will be the first field. */
-
-struct bfd_hash_entry
-{
- /* Next entry for this hash code. */
- struct bfd_hash_entry *next;
- /* String being hashed. */
- const char *string;
- /* Hash code. This is the full hash code, not the index into the
- table. */
- unsigned long hash;
-};
-
-/* A hash table. */
-
-struct bfd_hash_table
-{
- /* The hash array. */
- struct bfd_hash_entry **table;
- /* The number of slots in the hash table. */
- unsigned int size;
- /* A function used to create new elements in the hash table. The
- first entry is itself a pointer to an element. When this
- function is first invoked, this pointer will be NULL. However,
- having the pointer permits a hierarchy of method functions to be
- built each of which calls the function in the superclass. Thus
- each function should be written to allocate a new block of memory
- only if the argument is NULL. */
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
- /* An obstack for this hash table. */
- struct obstack memory;
-};
-
-/* Initialize a hash table. */
-extern boolean bfd_hash_table_init
- PARAMS ((struct bfd_hash_table *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-/* Initialize a hash table specifying a size. */
-extern boolean bfd_hash_table_init_n
- PARAMS ((struct bfd_hash_table *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *),
- unsigned int size));
-
-/* Free up a hash table. */
-extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *));
-
-/* Look up a string in a hash table. If CREATE is true, a new entry
- will be created for this string if one does not already exist. The
- COPY argument must be true if this routine should copy the string
- into newly allocated memory when adding an entry. */
-extern struct bfd_hash_entry *bfd_hash_lookup
- PARAMS ((struct bfd_hash_table *, const char *, boolean create,
- boolean copy));
-
-/* Replace an entry in a hash table. */
-extern void bfd_hash_replace
- PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old,
- struct bfd_hash_entry *nw));
-
-/* Base method for creating a hash table entry. */
-extern struct bfd_hash_entry *bfd_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
- const char *));
-
-/* Grab some space for a hash table entry. */
-extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *,
- unsigned int));
-
-/* Traverse a hash table in a random order, calling a function on each
- element. If the function returns false, the traversal stops. The
- INFO argument is passed to the function. */
-extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *,
- boolean (*) (struct bfd_hash_entry *,
- PTR),
- PTR info));
-
-/* Semi-portable string concatenation in cpp.
- The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
- The problem is, "32_" is not a valid preprocessing token, and we don't
- want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the
- inner CAT macros to be evaluated first, producing still-valid pp-tokens.
- Then the final concatenation can be done. (Sigh.) */
-#ifndef CAT
-#ifdef SABER
-#define CAT(a,b) a##b
-#define CAT3(a,b,c) a##b##c
-#define CAT4(a,b,c,d) a##b##c##d
-#else
-#if defined(__STDC__) || defined(ALMOST_STDC)
-#define CAT(a,b) a##b
-#define CAT3(a,b,c) a##b##c
-#define XCAT2(a,b) CAT(a,b)
-#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
-#else
-#define CAT(a,b) a/**/b
-#define CAT3(a,b,c) a/**/b/**/c
-#define CAT4(a,b,c,d) a/**/b/**/c/**/d
-#endif
-#endif
-#endif
-
-#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table
-
-/* User program access to BFD facilities */
-
-/* Direct I/O routines, for programs which know more about the object
- file than BFD does. Use higher level routines if possible. */
-
-extern bfd_size_type bfd_read
- PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern bfd_size_type bfd_write
- PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
-extern long bfd_tell PARAMS ((bfd *abfd));
-extern int bfd_flush PARAMS ((bfd *abfd));
-extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
-
-
-/* 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_cacheable(abfd) ((abfd)->cacheable)
-#define bfd_get_format(abfd) ((abfd)->format)
-#define bfd_get_target(abfd) ((abfd)->xvec->name)
-#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
-#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
-#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
-#define bfd_header_big_endian(abfd) \
- ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
-#define bfd_header_little_endian(abfd) \
- ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
-#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_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_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
-
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean)(bool)), true)
-
-extern boolean bfd_record_phdr
- PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma,
- boolean, boolean, unsigned int, struct sec **));
-
-/* Byte swapping routines. */
-
-bfd_vma bfd_getb64 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl64 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *));
-bfd_vma bfd_getb32 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl32 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *));
-bfd_vma bfd_getb16 PARAMS ((const unsigned char *));
-bfd_vma bfd_getl16 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *));
-bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *));
-void bfd_putb64 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl64 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
-void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
-
-/* Externally visible ECOFF routines. */
-
-#if defined(__STDC__) || defined(ALMOST_STDC)
-struct ecoff_debug_info;
-struct ecoff_debug_swap;
-struct ecoff_extr;
-struct symbol_cache_entry;
-struct bfd_link_info;
-struct bfd_link_hash_entry;
-#endif
-extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd));
-extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value));
-extern boolean bfd_ecoff_set_regmasks
- PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask,
- unsigned long *cprmask));
-extern PTR bfd_ecoff_debug_init
- PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- struct bfd_link_info *));
-extern void bfd_ecoff_debug_free
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_accumulate
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap,
- bfd *input_bfd, struct ecoff_debug_info *input_debug,
- const struct ecoff_debug_swap *input_swap,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_accumulate_other
- PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug,
- const struct ecoff_debug_swap *output_swap, bfd *input_bfd,
- struct bfd_link_info *));
-extern boolean bfd_ecoff_debug_externals
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- boolean relocateable,
- boolean (*get_extr) (struct symbol_cache_entry *,
- struct ecoff_extr *),
- void (*set_index) (struct symbol_cache_entry *,
- bfd_size_type)));
-extern boolean bfd_ecoff_debug_one_external
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- const char *name, struct ecoff_extr *esym));
-extern bfd_size_type bfd_ecoff_debug_size
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap));
-extern boolean bfd_ecoff_write_debug
- PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap, file_ptr where));
-extern boolean bfd_ecoff_write_accumulated_debug
- PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug,
- const struct ecoff_debug_swap *swap,
- struct bfd_link_info *info, file_ptr where));
-extern boolean bfd_mips_ecoff_create_embedded_relocs
- PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *,
- char **));
-
-/* Externally visible ELF routines. */
-
-struct bfd_link_needed_list
-{
- struct bfd_link_needed_list *next;
- bfd *by;
- const char *name;
-};
-
-extern boolean bfd_elf32_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
-extern boolean bfd_elf64_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean));
-extern struct bfd_link_needed_list *bfd_elf_get_needed_list
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_elf32_size_dynamic_sections
- PARAMS ((bfd *, const char *, const char *, boolean,
- struct bfd_link_info *, struct sec **));
-extern boolean bfd_elf64_size_dynamic_sections
- PARAMS ((bfd *, const char *, const char *, boolean,
- struct bfd_link_info *, struct sec **));
-extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *));
-extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *));
-
-/* SunOS shared library support routines for the linker. */
-
-extern struct bfd_link_needed_list *bfd_sunos_get_needed_list
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_sunos_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_sunos_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **,
- struct sec **));
-
-/* Linux shared library support routines for the linker. */
-
-extern boolean bfd_i386linux_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean bfd_m68klinux_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* mmap hacks */
-
-struct _bfd_window_internal;
-typedef struct _bfd_window_internal bfd_window_internal;
-
-typedef struct _bfd_window {
- /* What the user asked for. */
- PTR data;
- bfd_size_type size;
- /* The actual window used by BFD. Small user-requested read-only
- regions sharing a page may share a single window into the object
- file. Read-write versions shouldn't until I've fixed things to
- keep track of which portions have been claimed by the
- application; don't want to give the same region back when the
- application wants two writable copies! */
- struct _bfd_window_internal *i;
-} bfd_window;
-
-extern void bfd_init_window PARAMS ((bfd_window *));
-extern void bfd_free_window PARAMS ((bfd_window *));
-extern boolean bfd_get_file_window
- PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, boolean));
-
-/* XCOFF support routines for the linker. */
-
-extern boolean bfd_xcoff_link_record_set
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- bfd_size_type));
-extern boolean bfd_xcoff_import_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- bfd_vma, const char *, const char *, const char *));
-extern boolean bfd_xcoff_export_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *,
- boolean));
-extern boolean bfd_xcoff_link_count_reloc
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_xcoff_record_link_assignment
- PARAMS ((bfd *, struct bfd_link_info *, const char *));
-extern boolean bfd_xcoff_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
- unsigned long, unsigned long, unsigned long, boolean,
- int, boolean, boolean, struct sec **));
-
-/* And more from the source. */
-void
-bfd_init PARAMS ((void));
-
-bfd *
-bfd_openr PARAMS ((CONST char *filename, CONST char *target));
-
-bfd *
-bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd));
-
-bfd *
-bfd_openstreamr PARAMS (());
-
-bfd *
-bfd_openw PARAMS ((CONST char *filename, CONST char *target));
-
-boolean
-bfd_close PARAMS ((bfd *abfd));
-
-boolean
-bfd_close_all_done PARAMS ((bfd *));
-
-bfd_size_type
-bfd_alloc_size PARAMS ((bfd *abfd));
-
-bfd *
-bfd_create PARAMS ((CONST char *filename, bfd *templ));
-
-
- /* Byte swapping macros for user section data. */
-
-#define bfd_put_8(abfd, val, ptr) \
- (*((unsigned char *)(ptr)) = (unsigned char)(val))
-#define bfd_put_signed_8 \
- bfd_put_8
-#define bfd_get_8(abfd, ptr) \
- (*(unsigned char *)(ptr))
-#define bfd_get_signed_8(abfd, ptr) \
- ((*(unsigned char *)(ptr) ^ 0x80) - 0x80)
-
-#define bfd_put_16(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
-#define bfd_put_signed_16 \
- bfd_put_16
-#define bfd_get_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx16, (ptr))
-#define bfd_get_signed_16(abfd, ptr) \
- BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
-
-#define bfd_put_32(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
-#define bfd_put_signed_32 \
- bfd_put_32
-#define bfd_get_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx32, (ptr))
-#define bfd_get_signed_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
-
-#define bfd_put_64(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
-#define bfd_put_signed_64 \
- bfd_put_64
-#define bfd_get_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx64, (ptr))
-#define bfd_get_signed_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
-
-
- /* Byte swapping macros for file header data. */
-
-#define bfd_h_put_8(abfd, val, ptr) \
- bfd_put_8 (abfd, val, ptr)
-#define bfd_h_put_signed_8(abfd, val, ptr) \
- bfd_put_8 (abfd, val, ptr)
-#define bfd_h_get_8(abfd, ptr) \
- bfd_get_8 (abfd, ptr)
-#define bfd_h_get_signed_8(abfd, ptr) \
- bfd_get_signed_8 (abfd, ptr)
-
-#define bfd_h_put_16(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
-#define bfd_h_put_signed_16 \
- bfd_h_put_16
-#define bfd_h_get_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx16,(ptr))
-#define bfd_h_get_signed_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
-
-#define bfd_h_put_32(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
-#define bfd_h_put_signed_32 \
- bfd_h_put_32
-#define bfd_h_get_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx32,(ptr))
-#define bfd_h_get_signed_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
-
-#define bfd_h_put_64(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
-#define bfd_h_put_signed_64 \
- bfd_h_put_64
-#define bfd_h_get_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx64,(ptr))
-#define bfd_h_get_signed_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
-
-typedef struct sec
-{
- /* The name of the section; the name isn't a copy, the pointer is
- the same as that passed to bfd_make_section. */
-
- CONST char *name;
-
- /* Which section is it; 0..nth. */
-
- int index;
-
- /* The next section in the list belonging to the BFD, or NULL. */
-
- struct sec *next;
-
- /* The field flags contains attributes of the section. Some
- flags are read in from the object file, and some are
- synthesized from other information. */
-
- flagword flags;
-
-#define SEC_NO_FLAGS 0x000
-
- /* Tells the OS to allocate space for this section when loading.
- This is clear for a section containing debug information
- only. */
-#define SEC_ALLOC 0x001
-
- /* Tells the OS to load the section from the file when loading.
- This is clear for a .bss section. */
-#define SEC_LOAD 0x002
-
- /* The section contains data still to be relocated, so there is
- some relocation information too. */
-#define SEC_RELOC 0x004
-
-#if 0 /* Obsolete ? */
-#define SEC_BALIGN 0x008
-#endif
-
- /* A signal to the OS that the section contains read only
- data. */
-#define SEC_READONLY 0x010
-
- /* The section contains code only. */
-#define SEC_CODE 0x020
-
- /* The section contains data only. */
-#define SEC_DATA 0x040
-
- /* The section will reside in ROM. */
-#define SEC_ROM 0x080
-
- /* The section contains constructor information. This section
- type is used by the linker to create lists of constructors and
- destructors used by <<g++>>. When a back end sees a symbol
- which should be used in a constructor list, it creates a new
- section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
- the symbol to it, and builds a relocation. To build the lists
- of constructors, all the linker has to do is catenate all the
- sections called <<__CTOR_LIST__>> and relocate the data
- contained within - exactly the operations it would peform on
- standard data. */
-#define SEC_CONSTRUCTOR 0x100
-
- /* The section is a constuctor, and should be placed at the
- end of the text, data, or bss section(?). */
-#define SEC_CONSTRUCTOR_TEXT 0x1100
-#define SEC_CONSTRUCTOR_DATA 0x2100
-#define SEC_CONSTRUCTOR_BSS 0x3100
-
- /* The section has contents - a data section could be
- <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
- <<SEC_HAS_CONTENTS>> */
-#define SEC_HAS_CONTENTS 0x200
-
- /* An instruction to the linker to not output the section
- even if it has information which would normally be written. */
-#define SEC_NEVER_LOAD 0x400
-
- /* The section is a COFF shared library section. This flag is
- only for the linker. If this type of section appears in
- the input file, the linker must copy it to the output file
- without changing the vma or size. FIXME: Although this
- was originally intended to be general, it really is COFF
- specific (and the flag was renamed to indicate this). It
- might be cleaner to have some more general mechanism to
- allow the back end to control what the linker does with
- sections. */
-#define SEC_COFF_SHARED_LIBRARY 0x800
-
- /* The section is a common section (symbols may be defined
- multiple times, the value of a symbol is the amount of
- space it requires, and the largest symbol value is the one
- used). Most targets have exactly one of these (which we
- translate to bfd_com_section_ptr), but ECOFF has two. */
-#define SEC_IS_COMMON 0x8000
-
- /* The section contains only debugging information. For
- example, this is set for ELF .debug and .stab sections.
- strip tests this flag to see if a section can be
- discarded. */
-#define SEC_DEBUGGING 0x10000
-
- /* The contents of this section are held in memory pointed to
- by the contents field. This is checked by
- bfd_get_section_contents, and the data is retrieved from
- memory if appropriate. */
-#define SEC_IN_MEMORY 0x20000
-
- /* The contents of this section are to be excluded by the
- linker for executable and shared objects unless those
- objects are to be further relocated. */
-#define SEC_EXCLUDE 0x40000
-
- /* The contents of this section are to be sorted by the
- based on the address specified in the associated symbol
- table. */
-#define SEC_SORT_ENTRIES 0x80000
-
- /* End of section flags. */
-
- /* The virtual memory address of the section - where it will be
- at run time. The symbols are relocated against this. The
- user_set_vma flag is maintained by bfd; if it's not set, the
- backend can assign addresses (for example, in <<a.out>>, where
- the default address for <<.data>> is dependent on the specific
- target and various flags). */
-
- bfd_vma vma;
- boolean user_set_vma;
-
- /* The load address of the section - where it would be in a
- rom image; really only used for writing section header
- information. */
-
- bfd_vma lma;
-
- /* The size of the section in bytes, as it will be output.
- contains a value even if the section has no contents (e.g., the
- size of <<.bss>>). This will be filled in after relocation */
-
- bfd_size_type _cooked_size;
-
- /* The original size on disk of the section, in bytes. Normally this
- value is the same as the size, but if some relaxing has
- been done, then this value will be bigger. */
-
- bfd_size_type _raw_size;
-
- /* If this section is going to be output, then this value is the
- offset into the output section of the first byte in the input
- section. E.g., if this was going to start at the 100th byte in
- the output section, this value would be 100. */
-
- bfd_vma output_offset;
-
- /* The output section through which to map on output. */
-
- struct sec *output_section;
-
- /* The alignment requirement of the section, as an exponent of 2 -
- e.g., 3 aligns to 2^3 (or 8). */
-
- unsigned int alignment_power;
-
- /* If an input section, a pointer to a vector of relocation
- records for the data in this section. */
-
- struct reloc_cache_entry *relocation;
-
- /* If an output section, a pointer to a vector of pointers to
- relocation records for the data in this section. */
-
- struct reloc_cache_entry **orelocation;
-
- /* The number of relocation records in one of the above */
-
- unsigned reloc_count;
-
- /* Information below is back end specific - and not always used
- or updated. */
-
- /* File position of section data */
-
- file_ptr filepos;
-
- /* File position of relocation info */
-
- file_ptr rel_filepos;
-
- /* File position of line data */
-
- file_ptr line_filepos;
-
- /* Pointer to data for applications */
-
- PTR userdata;
-
- /* If the SEC_IN_MEMORY flag is set, this points to the actual
- contents. */
- unsigned char *contents;
-
- /* Attached line number information */
-
- alent *lineno;
-
- /* Number of line number records */
-
- unsigned int lineno_count;
-
- /* When a section is being output, this value changes as more
- linenumbers are written out */
-
- file_ptr moving_line_filepos;
-
- /* What the section number is in the target world */
-
- int target_index;
-
- PTR used_by_bfd;
-
- /* If this is a constructor section then here is a list of the
- relocations created to relocate items within it. */
-
- struct relent_chain *constructor_chain;
-
- /* The BFD which owns the section. */
-
- bfd *owner;
-
- boolean reloc_done;
- /* A symbol which points at this section only */
- struct symbol_cache_entry *symbol;
- struct symbol_cache_entry **symbol_ptr_ptr;
-
- struct bfd_link_order *link_order_head;
- struct bfd_link_order *link_order_tail;
-} asection ;
-
- /* These sections are global, and are managed by BFD. The application
- and target back end are not permitted to change the values in
- these sections. New code should use the section_ptr macros rather
- than referring directly to the const sections. The const sections
- may eventually vanish. */
-#define BFD_ABS_SECTION_NAME "*ABS*"
-#define BFD_UND_SECTION_NAME "*UND*"
-#define BFD_COM_SECTION_NAME "*COM*"
-#define BFD_IND_SECTION_NAME "*IND*"
-
- /* the absolute section */
-extern const asection bfd_abs_section;
-#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
-#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
- /* Pointer to the undefined section */
-extern const asection bfd_und_section;
-#define bfd_und_section_ptr ((asection *) &bfd_und_section)
-#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
- /* Pointer to the common section */
-extern const asection bfd_com_section;
-#define bfd_com_section_ptr ((asection *) &bfd_com_section)
- /* Pointer to the indirect section */
-extern const asection bfd_ind_section;
-#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
-#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
-
-extern const struct symbol_cache_entry * const bfd_abs_symbol;
-extern const struct symbol_cache_entry * const bfd_com_symbol;
-extern const struct symbol_cache_entry * const bfd_und_symbol;
-extern const struct symbol_cache_entry * const bfd_ind_symbol;
-#define bfd_get_section_size_before_reloc(section) \
- (section->reloc_done ? (abort(),1): (section)->_raw_size)
-#define bfd_get_section_size_after_reloc(section) \
- ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
-asection *
-bfd_get_section_by_name PARAMS ((bfd *abfd, CONST char *name));
-
-asection *
-bfd_make_section_old_way PARAMS ((bfd *abfd, CONST char *name));
-
-asection *
-bfd_make_section_anyway PARAMS ((bfd *abfd, CONST char *name));
-
-asection *
-bfd_make_section PARAMS ((bfd *, CONST char *name));
-
-boolean
-bfd_set_section_flags PARAMS ((bfd *abfd, asection *sec, flagword flags));
-
-void
-bfd_map_over_sections PARAMS ((bfd *abfd,
- void (*func)(bfd *abfd,
- asection *sect,
- PTR obj),
- PTR obj));
-
-boolean
-bfd_set_section_size PARAMS ((bfd *abfd, asection *sec, bfd_size_type val));
-
-boolean
-bfd_set_section_contents
- PARAMS ((bfd *abfd,
- asection *section,
- PTR data,
- file_ptr offset,
- bfd_size_type count));
-
-boolean
-bfd_get_section_contents
- PARAMS ((bfd *abfd, asection *section, PTR location,
- file_ptr offset, bfd_size_type count));
-
-boolean
-bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, asection *osec));
-
-#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
- BFD_SEND (ibfd, _bfd_copy_private_section_data, \
- (ibfd, isection, obfd, osection))
-enum bfd_architecture
-{
- bfd_arch_unknown, /* File arch not known */
- bfd_arch_obscure, /* Arch known, not one of these */
- bfd_arch_m68k, /* Motorola 68xxx */
- bfd_arch_vax, /* DEC Vax */
- bfd_arch_i960, /* Intel 960 */
- /* The order of the following is important.
- lower number indicates a machine type that
- only accepts a subset of the instructions
- available to machines with higher numbers.
- The exception is the "ca", which is
- incompatible with all other machines except
- "core". */
-
-#define bfd_mach_i960_core 1
-#define bfd_mach_i960_ka_sa 2
-#define bfd_mach_i960_kb_sb 3
-#define bfd_mach_i960_mc 4
-#define bfd_mach_i960_xa 5
-#define bfd_mach_i960_ca 6
-#define bfd_mach_i960_jx 7
-#define bfd_mach_i960_hx 8
-
- bfd_arch_a29k, /* AMD 29000 */
- bfd_arch_sparc, /* SPARC */
-#define bfd_mach_sparc 1
- /* The difference between v8plus and v9 is that v9 is a true 64 bit env. */
-#define bfd_mach_sparc_v8plus 2
-#define bfd_mach_sparc_v8plusa 3 /* with ultrasparc add'ns */
-#define bfd_mach_sparc_v9 4
-#define bfd_mach_sparc_v9a 5 /* with ultrasparc add'ns */
- /* Nonzero if MACH has the v9 instruction set. */
-#define bfd_mach_sparc_v9_p(mach) ((mach) != bfd_mach_sparc)
- bfd_arch_mips, /* MIPS Rxxxx */
- bfd_arch_i386, /* Intel 386 */
- bfd_arch_we32k, /* AT&T WE32xxx */
- bfd_arch_tahoe, /* CCI/Harris Tahoe */
- bfd_arch_i860, /* Intel 860 */
- bfd_arch_romp, /* IBM ROMP PC/RT */
- bfd_arch_alliant, /* Alliant */
- bfd_arch_convex, /* Convex */
- bfd_arch_m88k, /* Motorola 88xxx */
- bfd_arch_pyramid, /* Pyramid Technology */
- bfd_arch_h8300, /* Hitachi H8/300 */
-#define bfd_mach_h8300 1
-#define bfd_mach_h8300h 2
- bfd_arch_powerpc, /* PowerPC */
- bfd_arch_rs6000, /* IBM RS/6000 */
- bfd_arch_hppa, /* HP PA RISC */
- bfd_arch_z8k, /* Zilog Z8000 */
-#define bfd_mach_z8001 1
-#define bfd_mach_z8002 2
- bfd_arch_h8500, /* Hitachi H8/500 */
- bfd_arch_sh, /* Hitachi SH */
- bfd_arch_alpha, /* Dec Alpha */
- bfd_arch_arm, /* Advanced Risc Machines ARM */
- bfd_arch_ns32k, /* National Semiconductors ns32000 */
- bfd_arch_w65, /* WDC 65816 */
- bfd_arch_last
- };
-
-typedef struct bfd_arch_info
-{
- int bits_per_word;
- int bits_per_address;
- int bits_per_byte;
- enum bfd_architecture arch;
- unsigned long mach;
- const char *arch_name;
- const char *printable_name;
- unsigned int section_align_power;
- /* true if this is the default machine for the architecture */
- boolean the_default;
- const struct bfd_arch_info * (*compatible)
- PARAMS ((const struct bfd_arch_info *a,
- const struct bfd_arch_info *b));
-
- boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *));
-
- const struct bfd_arch_info *next;
-} bfd_arch_info_type;
-const char *
-bfd_printable_name PARAMS ((bfd *abfd));
-
-const bfd_arch_info_type *
-bfd_scan_arch PARAMS ((const char *string));
-
-const bfd_arch_info_type *
-bfd_arch_get_compatible PARAMS ((
- const bfd *abfd,
- const bfd *bbfd));
-
-void
-bfd_set_arch_info PARAMS ((bfd *abfd, const bfd_arch_info_type *arg));
-
-enum bfd_architecture
-bfd_get_arch PARAMS ((bfd *abfd));
-
-unsigned long
-bfd_get_mach PARAMS ((bfd *abfd));
-
-unsigned int
-bfd_arch_bits_per_byte PARAMS ((bfd *abfd));
-
-unsigned int
-bfd_arch_bits_per_address PARAMS ((bfd *abfd));
-
-const bfd_arch_info_type *
-bfd_get_arch_info PARAMS ((bfd *abfd));
-
-const bfd_arch_info_type *
-bfd_lookup_arch
- PARAMS ((enum bfd_architecture
- arch,
- unsigned long machine));
-
-const char *
-bfd_printable_arch_mach
- PARAMS ((enum bfd_architecture arch, unsigned long machine));
-
-typedef enum bfd_reloc_status
-{
- /* No errors detected */
- bfd_reloc_ok,
-
- /* The relocation was performed, but there was an overflow. */
- bfd_reloc_overflow,
-
- /* The address to relocate was not within the section supplied. */
- bfd_reloc_outofrange,
-
- /* Used by special functions */
- bfd_reloc_continue,
-
- /* Unsupported relocation size requested. */
- bfd_reloc_notsupported,
-
- /* Unused */
- bfd_reloc_other,
-
- /* The symbol to relocate against was undefined. */
- bfd_reloc_undefined,
-
- /* The relocation was performed, but may not be ok - presently
- generated only when linking i960 coff files with i960 b.out
- symbols. If this type is returned, the error_message argument
- to bfd_perform_relocation will be set. */
- bfd_reloc_dangerous
- }
- bfd_reloc_status_type;
-
-
-typedef struct reloc_cache_entry
-{
- /* A pointer into the canonical table of pointers */
- struct symbol_cache_entry **sym_ptr_ptr;
-
- /* offset in section */
- bfd_size_type address;
-
- /* addend for relocation value */
- bfd_vma addend;
-
- /* Pointer to how to perform the required relocation */
- reloc_howto_type *howto;
-
-} arelent;
-enum complain_overflow
-{
- /* Do not complain on overflow. */
- complain_overflow_dont,
-
- /* Complain if the bitfield overflows, whether it is considered
- as signed or unsigned. */
- complain_overflow_bitfield,
-
- /* Complain if the value overflows when considered as signed
- number. */
- complain_overflow_signed,
-
- /* Complain if the value overflows when considered as an
- unsigned number. */
- complain_overflow_unsigned
-};
-
-struct reloc_howto_struct
-{
- /* The type field has mainly a documetary use - the back end can
- do what it wants with it, though normally the back end's
- external idea of what a reloc number is stored
- in this field. For example, a PC relative word relocation
- in a coff environment has the type 023 - because that's
- what the outside world calls a R_PCRWORD reloc. */
- unsigned int type;
-
- /* The value the final relocation is shifted right by. This drops
- unwanted data from the relocation. */
- unsigned int rightshift;
-
- /* The size of the item to be relocated. This is *not* a
- power-of-two measure. To get the number of bytes operated
- on by a type of relocation, use bfd_get_reloc_size. */
- int size;
-
- /* The number of bits in the item to be relocated. This is used
- when doing overflow checking. */
- unsigned int bitsize;
-
- /* Notes that the relocation is relative to the location in the
- data section of the addend. The relocation function will
- subtract from the relocation value the address of the location
- being relocated. */
- boolean pc_relative;
-
- /* The bit position of the reloc value in the destination.
- The relocated value is left shifted by this amount. */
- unsigned int bitpos;
-
- /* What type of overflow error should be checked for when
- relocating. */
- enum complain_overflow complain_on_overflow;
-
- /* If this field is non null, then the supplied function is
- called rather than the normal function. This allows really
- strange relocation methods to be accomodated (e.g., i960 callj
- instructions). */
- bfd_reloc_status_type (*special_function)
- PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- struct symbol_cache_entry *symbol,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-
- /* The textual name of the relocation type. */
- char *name;
-
- /* When performing a partial link, some formats must modify the
- relocations rather than the data - this flag signals this.*/
- boolean partial_inplace;
-
- /* The src_mask selects which parts of the read in data
- are to be used in the relocation sum. E.g., if this was an 8 bit
- bit of data which we read and relocated, this would be
- 0x000000ff. When we have relocs which have an addend, such as
- sun4 extended relocs, the value in the offset part of a
- relocating field is garbage so we never use it. In this case
- the mask would be 0x00000000. */
- bfd_vma src_mask;
-
- /* The dst_mask selects which parts of the instruction are replaced
- into the instruction. In most cases src_mask == dst_mask,
- except in the above special case, where dst_mask would be
- 0x000000ff, and src_mask would be 0x00000000. */
- bfd_vma dst_mask;
-
- /* When some formats create PC relative instructions, they leave
- the value of the pc of the place being relocated in the offset
- slot of the instruction, so that a PC relative relocation can
- be made just by adding in an ordinary offset (e.g., sun3 a.out).
- Some formats leave the displacement part of an instruction
- empty (e.g., m88k bcs); this flag signals the fact.*/
- boolean pcrel_offset;
-
-};
-#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
- {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
-#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
-
-#define HOWTO_PREPARE(relocation, symbol) \
- { \
- if (symbol != (asymbol *)NULL) { \
- if (bfd_is_com_section (symbol->section)) { \
- relocation = 0; \
- } \
- else { \
- relocation = symbol->value; \
- } \
- } \
-}
-int
-bfd_get_reloc_size PARAMS ((reloc_howto_type *));
-
-typedef struct relent_chain {
- arelent relent;
- struct relent_chain *next;
-} arelent_chain;
-bfd_reloc_status_type
-
-bfd_perform_relocation
- PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-
-bfd_reloc_status_type
-
-bfd_install_relocation
- PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- PTR data, bfd_vma data_start,
- asection *input_section,
- char **error_message));
-
-enum bfd_reloc_code_real {
- _dummy_first_bfd_reloc_code_real,
-
-
-/* Basic absolute relocations of N bits. */
- BFD_RELOC_64,
- BFD_RELOC_32,
- BFD_RELOC_26,
- BFD_RELOC_16,
- BFD_RELOC_14,
- BFD_RELOC_8,
-
-/* PC-relative relocations. Sometimes these are relative to the address
-of the relocation itself; sometimes they are relative to the start of
-the section containing the relocation. It depends on the specific target.
-
-The 24-bit relocation is used in some Intel 960 configurations. */
- BFD_RELOC_64_PCREL,
- BFD_RELOC_32_PCREL,
- BFD_RELOC_24_PCREL,
- BFD_RELOC_16_PCREL,
- BFD_RELOC_12_PCREL,
- BFD_RELOC_8_PCREL,
-
-/* For ELF. */
- BFD_RELOC_32_GOT_PCREL,
- BFD_RELOC_16_GOT_PCREL,
- BFD_RELOC_8_GOT_PCREL,
- BFD_RELOC_32_GOTOFF,
- BFD_RELOC_16_GOTOFF,
- BFD_RELOC_LO16_GOTOFF,
- BFD_RELOC_HI16_GOTOFF,
- BFD_RELOC_HI16_S_GOTOFF,
- BFD_RELOC_8_GOTOFF,
- BFD_RELOC_32_PLT_PCREL,
- BFD_RELOC_24_PLT_PCREL,
- BFD_RELOC_16_PLT_PCREL,
- BFD_RELOC_8_PLT_PCREL,
- BFD_RELOC_32_PLTOFF,
- BFD_RELOC_16_PLTOFF,
- BFD_RELOC_LO16_PLTOFF,
- BFD_RELOC_HI16_PLTOFF,
- BFD_RELOC_HI16_S_PLTOFF,
- BFD_RELOC_8_PLTOFF,
-
-/* Relocations used by 68K ELF. */
- BFD_RELOC_68K_GLOB_DAT,
- BFD_RELOC_68K_JMP_SLOT,
- BFD_RELOC_68K_RELATIVE,
-
-/* Linkage-table relative. */
- BFD_RELOC_32_BASEREL,
- BFD_RELOC_16_BASEREL,
- BFD_RELOC_LO16_BASEREL,
- BFD_RELOC_HI16_BASEREL,
- BFD_RELOC_HI16_S_BASEREL,
- BFD_RELOC_8_BASEREL,
- BFD_RELOC_RVA,
-
-/* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */
- BFD_RELOC_8_FFnn,
-
-/* These PC-relative relocations are stored as word displacements --
-i.e., byte displacements shifted right two bits. The 30-bit word
-displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
-SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The
-signed 16-bit displacement is used on the MIPS, and the 23-bit
-displacement is used on the Alpha. */
- BFD_RELOC_32_PCREL_S2,
- BFD_RELOC_16_PCREL_S2,
- BFD_RELOC_23_PCREL_S2,
-
-/* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
-the target word. These are used on the SPARC. */
- BFD_RELOC_HI22,
- BFD_RELOC_LO10,
-
-/* For systems that allocate a Global Pointer register, these are
-displacements off that register. These relocation types are
-handled specially, because the value the register will have is
-decided relatively late. */
- BFD_RELOC_GPREL16,
- BFD_RELOC_GPREL32,
-
-/* Reloc types used for i960/b.out. */
- BFD_RELOC_I960_CALLJ,
-
-/* SPARC ELF relocations. There is probably some overlap with other
-relocation types already defined. */
- BFD_RELOC_NONE,
- BFD_RELOC_SPARC_WDISP22,
- BFD_RELOC_SPARC22,
- BFD_RELOC_SPARC13,
- BFD_RELOC_SPARC_GOT10,
- BFD_RELOC_SPARC_GOT13,
- BFD_RELOC_SPARC_GOT22,
- BFD_RELOC_SPARC_PC10,
- BFD_RELOC_SPARC_PC22,
- BFD_RELOC_SPARC_WPLT30,
- BFD_RELOC_SPARC_COPY,
- BFD_RELOC_SPARC_GLOB_DAT,
- BFD_RELOC_SPARC_JMP_SLOT,
- BFD_RELOC_SPARC_RELATIVE,
- BFD_RELOC_SPARC_UA32,
-
-/* I think these are specific to SPARC a.out (e.g., Sun 4). */
- BFD_RELOC_SPARC_BASE13,
- BFD_RELOC_SPARC_BASE22,
-
-/* Some relocations we're using for SPARC V9 -- subject to change. */
-#define BFD_RELOC_SPARC_64 BFD_RELOC_64
- BFD_RELOC_SPARC_10,
- BFD_RELOC_SPARC_11,
- BFD_RELOC_SPARC_OLO10,
- BFD_RELOC_SPARC_HH22,
- BFD_RELOC_SPARC_HM10,
- BFD_RELOC_SPARC_LM22,
- BFD_RELOC_SPARC_PC_HH22,
- BFD_RELOC_SPARC_PC_HM10,
- BFD_RELOC_SPARC_PC_LM22,
- BFD_RELOC_SPARC_WDISP16,
- BFD_RELOC_SPARC_WDISP19,
- BFD_RELOC_SPARC_GLOB_JMP,
- BFD_RELOC_SPARC_7,
- BFD_RELOC_SPARC_6,
- BFD_RELOC_SPARC_5,
-
-/* Alpha ECOFF relocations. Some of these treat the symbol or "addend"
-in some special way.
-For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
-writing; when reading, it will be the absolute section symbol. The
-addend is the displacement in bytes of the "lda" instruction from
-the "ldah" instruction (which is at the address of this reloc). */
- BFD_RELOC_ALPHA_GPDISP_HI16,
-
-/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
-with GPDISP_HI16 relocs. The addend is ignored when writing the
-relocations out, and is filled in with the file's GP value on
-reading, for convenience. */
- BFD_RELOC_ALPHA_GPDISP_LO16,
-
-/* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
-the assembler turns it into a LDQ instruction to load the address of
-the symbol, and then fills in a register in the real instruction.
-
-The LITERAL reloc, at the LDQ instruction, refers to the .lita
-section symbol. The addend is ignored when writing, but is filled
-in with the file's GP value on reading, for convenience, as with the
-GPDISP_LO16 reloc.
-
-The LITUSE reloc, on the instruction using the loaded address, gives
-information to the linker that it might be able to use to optimize
-away some literal section references. The symbol is ignored (read
-as the absolute section symbol), and the "addend" indicates the type
-of instruction using the register:
-1 - "memory" fmt insn
-2 - byte-manipulation (byte offset reg)
-3 - jsr (target of branch)
-
-The GNU linker currently doesn't do any of this optimizing. */
- BFD_RELOC_ALPHA_LITERAL,
- BFD_RELOC_ALPHA_LITUSE,
-
-/* The HINT relocation indicates a value that should be filled into the
-"hint" field of a jmp/jsr/ret instruction, for possible branch-
-prediction logic which may be provided on some processors. */
- BFD_RELOC_ALPHA_HINT,
-
-/* Bits 27..2 of the relocation address shifted right 2 bits;
-simple reloc otherwise. */
- BFD_RELOC_MIPS_JMP,
-
-/* High 16 bits of 32-bit value; simple reloc. */
- BFD_RELOC_HI16,
-
-/* High 16 bits of 32-bit value but the low 16 bits will be sign
-extended and added to form the final result. If the low 16
-bits form a negative number, we need to add one to the high value
-to compensate for the borrow when the low bits are added. */
- BFD_RELOC_HI16_S,
-
-/* Low 16 bits. */
- BFD_RELOC_LO16,
-
-/* Like BFD_RELOC_HI16_S, but PC relative. */
- BFD_RELOC_PCREL_HI16_S,
-
-/* Like BFD_RELOC_LO16, but PC relative. */
- BFD_RELOC_PCREL_LO16,
-
-/* Relocation relative to the global pointer. */
-#define BFD_RELOC_MIPS_GPREL BFD_RELOC_GPREL16
-
-/* Relocation against a MIPS literal section. */
- BFD_RELOC_MIPS_LITERAL,
-
-/* MIPS ELF relocations. */
- BFD_RELOC_MIPS_GOT16,
- BFD_RELOC_MIPS_CALL16,
-#define BFD_RELOC_MIPS_GPREL32 BFD_RELOC_GPREL32
- BFD_RELOC_MIPS_GOT_HI16,
- BFD_RELOC_MIPS_GOT_LO16,
- BFD_RELOC_MIPS_CALL_HI16,
- BFD_RELOC_MIPS_CALL_LO16,
-
-/* i386/elf relocations */
- BFD_RELOC_386_GOT32,
- BFD_RELOC_386_PLT32,
- BFD_RELOC_386_COPY,
- BFD_RELOC_386_GLOB_DAT,
- BFD_RELOC_386_JUMP_SLOT,
- BFD_RELOC_386_RELATIVE,
- BFD_RELOC_386_GOTOFF,
- BFD_RELOC_386_GOTPC,
-
-/* ns32k relocations */
- BFD_RELOC_NS32K_IMM_8,
- BFD_RELOC_NS32K_IMM_16,
- BFD_RELOC_NS32K_IMM_32,
- BFD_RELOC_NS32K_IMM_8_PCREL,
- BFD_RELOC_NS32K_IMM_16_PCREL,
- BFD_RELOC_NS32K_IMM_32_PCREL,
- BFD_RELOC_NS32K_DISP_8,
- BFD_RELOC_NS32K_DISP_16,
- BFD_RELOC_NS32K_DISP_32,
- BFD_RELOC_NS32K_DISP_8_PCREL,
- BFD_RELOC_NS32K_DISP_16_PCREL,
- BFD_RELOC_NS32K_DISP_32_PCREL,
-
-/* Power(rs6000) and PowerPC relocations. */
- BFD_RELOC_PPC_B26,
- BFD_RELOC_PPC_BA26,
- BFD_RELOC_PPC_TOC16,
- BFD_RELOC_PPC_B16,
- BFD_RELOC_PPC_B16_BRTAKEN,
- BFD_RELOC_PPC_B16_BRNTAKEN,
- BFD_RELOC_PPC_BA16,
- BFD_RELOC_PPC_BA16_BRTAKEN,
- BFD_RELOC_PPC_BA16_BRNTAKEN,
- BFD_RELOC_PPC_COPY,
- BFD_RELOC_PPC_GLOB_DAT,
- BFD_RELOC_PPC_JMP_SLOT,
- BFD_RELOC_PPC_RELATIVE,
- BFD_RELOC_PPC_LOCAL24PC,
- BFD_RELOC_PPC_EMB_NADDR32,
- BFD_RELOC_PPC_EMB_NADDR16,
- BFD_RELOC_PPC_EMB_NADDR16_LO,
- BFD_RELOC_PPC_EMB_NADDR16_HI,
- BFD_RELOC_PPC_EMB_NADDR16_HA,
- BFD_RELOC_PPC_EMB_SDAI16,
- BFD_RELOC_PPC_EMB_SDA2I16,
- BFD_RELOC_PPC_EMB_SDA2REL,
- BFD_RELOC_PPC_EMB_SDA21,
- BFD_RELOC_PPC_EMB_MRKREF,
- BFD_RELOC_PPC_EMB_RELSEC16,
- BFD_RELOC_PPC_EMB_RELST_LO,
- BFD_RELOC_PPC_EMB_RELST_HI,
- BFD_RELOC_PPC_EMB_RELST_HA,
- BFD_RELOC_PPC_EMB_BIT_FLD,
- BFD_RELOC_PPC_EMB_RELSDA,
-
-/* The type of reloc used to build a contructor table - at the moment
-probably a 32 bit wide absolute relocation, but the target can choose.
-It generally does map to one of the other relocation types. */
- BFD_RELOC_CTOR,
-
-/* ARM 26 bit pc-relative branch. The lowest two bits must be zero and are
-not stored in the instruction. */
- BFD_RELOC_ARM_PCREL_BRANCH,
-
-/* These relocs are only used within the ARM assembler. They are not
-(at present) written to any object files. */
- BFD_RELOC_ARM_IMMEDIATE,
- BFD_RELOC_ARM_OFFSET_IMM,
- BFD_RELOC_ARM_SHIFT_IMM,
- BFD_RELOC_ARM_SWI,
- BFD_RELOC_ARM_MULTI,
- BFD_RELOC_ARM_CP_OFF_IMM,
- BFD_RELOC_ARM_ADR_IMM,
- BFD_RELOC_ARM_LDR_IMM,
- BFD_RELOC_ARM_LITERAL,
- BFD_RELOC_ARM_IN_POOL,
- BFD_RELOC_UNUSED };
-typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
-reloc_howto_type *
-
-bfd_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-
-const char *
-bfd_get_reloc_code_name PARAMS ((bfd_reloc_code_real_type code));
-
-
-typedef struct symbol_cache_entry
-{
- /* A pointer to the BFD which owns the symbol. This information
- is necessary so that a back end can work out what additional
- information (invisible to the application writer) is carried
- with the symbol.
-
- This field is *almost* redundant, since you can use section->owner
- instead, except that some symbols point to the global sections
- bfd_{abs,com,und}_section. This could be fixed by making
- these globals be per-bfd (or per-target-flavor). FIXME. */
-
- struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */
-
- /* The text of the symbol. The name is left alone, and not copied; the
- application may not alter it. */
- CONST char *name;
-
- /* The value of the symbol. This really should be a union of a
- numeric value with a pointer, since some flags indicate that
- a pointer to another symbol is stored here. */
- symvalue value;
-
- /* Attributes of a symbol: */
-
-#define BSF_NO_FLAGS 0x00
-
- /* The symbol has local scope; <<static>> in <<C>>. The value
- is the offset into the section of the data. */
-#define BSF_LOCAL 0x01
-
- /* The symbol has global scope; initialized data in <<C>>. The
- value is the offset into the section of the data. */
-#define BSF_GLOBAL 0x02
-
- /* The symbol has global scope and is exported. The value is
- the offset into the section of the data. */
-#define BSF_EXPORT BSF_GLOBAL /* no real difference */
-
- /* A normal C symbol would be one of:
- <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or
- <<BSF_GLOBAL>> */
-
- /* The symbol is a debugging record. The value has an arbitary
- meaning. */
-#define BSF_DEBUGGING 0x08
-
- /* The symbol denotes a function entry point. Used in ELF,
- perhaps others someday. */
-#define BSF_FUNCTION 0x10
-
- /* Used by the linker. */
-#define BSF_KEEP 0x20
-#define BSF_KEEP_G 0x40
-
- /* A weak global symbol, overridable without warnings by
- a regular global symbol of the same name. */
-#define BSF_WEAK 0x80
-
- /* This symbol was created to point to a section, e.g. ELF's
- STT_SECTION symbols. */
-#define BSF_SECTION_SYM 0x100
-
- /* The symbol used to be a common symbol, but now it is
- allocated. */
-#define BSF_OLD_COMMON 0x200
-
- /* The default value for common data. */
-#define BFD_FORT_COMM_DEFAULT_VALUE 0
-
- /* In some files the type of a symbol sometimes alters its
- location in an output file - ie in coff a <<ISFCN>> symbol
- which is also <<C_EXT>> symbol appears where it was
- declared and not at the end of a section. This bit is set
- by the target BFD part to convey this information. */
-
-#define BSF_NOT_AT_END 0x400
-
- /* Signal that the symbol is the label of constructor section. */
-#define BSF_CONSTRUCTOR 0x800
-
- /* Signal that the symbol is a warning symbol. The name is a
- warning. The name of the next symbol is the one to warn about;
- if a reference is made to a symbol with the same name as the next
- symbol, a warning is issued by the linker. */
-#define BSF_WARNING 0x1000
-
- /* Signal that the symbol is indirect. This symbol is an indirect
- pointer to the symbol with the same name as the next symbol. */
-#define BSF_INDIRECT 0x2000
-
- /* BSF_FILE marks symbols that contain a file name. This is used
- for ELF STT_FILE symbols. */
-#define BSF_FILE 0x4000
-
- /* Symbol is from dynamic linking information. */
-#define BSF_DYNAMIC 0x8000
-
- /* The symbol denotes a data object. Used in ELF, and perhaps
- others someday. */
-#define BSF_OBJECT 0x10000
-
- flagword flags;
-
- /* A pointer to the section to which this symbol is
- relative. This will always be non NULL, there are special
- sections for undefined and absolute symbols. */
- struct sec *section;
-
- /* Back end special data. */
- union
- {
- PTR p;
- bfd_vma i;
- } udata;
-
-} asymbol;
-#define bfd_get_symtab_upper_bound(abfd) \
- BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
-boolean
-bfd_is_local_label PARAMS ((bfd *abfd, asymbol *sym));
-
-#define bfd_is_local_label(abfd, sym) \
- BFD_SEND (abfd, _bfd_is_local_label,(abfd, sym))
-#define bfd_canonicalize_symtab(abfd, location) \
- BFD_SEND (abfd, _bfd_canonicalize_symtab,\
- (abfd, location))
-boolean
-bfd_set_symtab PARAMS ((bfd *abfd, asymbol **location, unsigned int count));
-
-void
-bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol));
-
-#define bfd_make_empty_symbol(abfd) \
- BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
-#define bfd_make_debug_symbol(abfd,ptr,size) \
- BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
-int
-bfd_decode_symclass PARAMS ((asymbol *symbol));
-
-void
-bfd_symbol_info PARAMS ((asymbol *symbol, symbol_info *ret));
-
-boolean
-bfd_copy_private_symbol_data PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym));
-
-#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \
- BFD_SEND (ibfd, _bfd_copy_private_symbol_data, \
- (ibfd, isymbol, obfd, osymbol))
-struct _bfd
-{
- /* The filename the application opened the BFD with. */
- CONST char *filename;
-
- /* A pointer to the target jump table. */
- const struct bfd_target *xvec;
-
- /* To avoid dragging too many header files into every file that
- includes `<<bfd.h>>', IOSTREAM has been declared as a "char
- *", and MTIME as a "long". Their correct types, to which they
- are cast when used, are "FILE *" and "time_t". The iostream
- is the result of an fopen on the filename. However, if the
- BFD_IN_MEMORY flag is set, then iostream is actually a pointer
- to a bfd_in_memory struct. */
- PTR iostream;
-
- /* Is the file descriptor being cached? That is, can it be closed as
- needed, and re-opened when accessed later? */
-
- boolean cacheable;
-
- /* Marks whether there was a default target specified when the
- BFD was opened. This is used to select which matching algorithm
- to use to choose the back end. */
-
- boolean target_defaulted;
-
- /* The caching routines use these to maintain a
- least-recently-used list of BFDs */
-
- struct _bfd *lru_prev, *lru_next;
-
- /* When a file is closed by the caching routines, BFD retains
- state information on the file here: */
-
- file_ptr where;
-
- /* and here: (``once'' means at least once) */
-
- boolean opened_once;
-
- /* Set if we have a locally maintained mtime value, rather than
- getting it from the file each time: */
-
- boolean mtime_set;
-
- /* File modified time, if mtime_set is true: */
-
- long mtime;
-
- /* Reserved for an unimplemented file locking extension.*/
-
- int ifd;
-
- /* The format which belongs to the BFD. (object, core, etc.) */
-
- bfd_format format;
-
- /* The direction the BFD was opened with*/
-
- enum bfd_direction {no_direction = 0,
- read_direction = 1,
- write_direction = 2,
- both_direction = 3} direction;
-
- /* Format_specific flags*/
-
- flagword flags;
-
- /* Currently my_archive is tested before adding origin to
- anything. I believe that this can become always an add of
- origin, with origin set to 0 for non archive files. */
-
- file_ptr origin;
-
- /* Remember when output has begun, to stop strange things
- from happening. */
- boolean output_has_begun;
-
- /* Pointer to linked list of sections*/
- struct sec *sections;
-
- /* The number of sections */
- unsigned int section_count;
-
- /* Stuff only useful for object files:
- The start address. */
- bfd_vma start_address;
-
- /* Used for input and output*/
- unsigned int symcount;
-
- /* Symbol table for output BFD (with symcount entries) */
- struct symbol_cache_entry **outsymbols;
-
- /* Pointer to structure which contains architecture information*/
- const struct bfd_arch_info *arch_info;
-
- /* Stuff only useful for archives:*/
- PTR arelt_data;
- struct _bfd *my_archive; /* The containing archive BFD. */
- struct _bfd *next; /* The next BFD in the archive. */
- struct _bfd *archive_head; /* The first BFD in the archive. */
- boolean has_armap;
-
- /* A chain of BFD structures involved in a link. */
- struct _bfd *link_next;
-
- /* A field used by _bfd_generic_link_add_archive_symbols. This will
- be used only for archive elements. */
- int archive_pass;
-
- /* Used by the back end to hold private data. */
-
- union
- {
- struct aout_data_struct *aout_data;
- struct artdata *aout_ar_data;
- struct _oasys_data *oasys_obj_data;
- struct _oasys_ar_data *oasys_ar_data;
- struct coff_tdata *coff_obj_data;
- struct pe_tdata *pe_obj_data;
- struct xcoff_tdata *xcoff_obj_data;
- struct ecoff_tdata *ecoff_obj_data;
- struct ieee_data_struct *ieee_data;
- struct ieee_ar_data_struct *ieee_ar_data;
- struct srec_data_struct *srec_data;
- struct ihex_data_struct *ihex_data;
- struct tekhex_data_struct *tekhex_data;
- struct elf_obj_tdata *elf_obj_data;
- struct nlm_obj_tdata *nlm_obj_data;
- struct bout_data_struct *bout_data;
- struct sun_core_struct *sun_core_data;
- struct trad_core_struct *trad_core_data;
- struct som_data_struct *som_data;
- struct hpux_core_struct *hpux_core_data;
- struct hppabsd_core_struct *hppabsd_core_data;
- struct sgi_core_struct *sgi_core_data;
- struct lynx_core_struct *lynx_core_data;
- struct osf_core_struct *osf_core_data;
- struct cisco_core_struct *cisco_core_data;
- struct versados_data_struct *versados_data;
- struct netbsd_core_struct *netbsd_core_data;
- PTR any;
- } tdata;
-
- /* Used by the application to hold private data*/
- PTR usrdata;
-
- /* Where all the allocated stuff under this BFD goes */
- struct obstack memory;
-};
-
-typedef enum bfd_error
-{
- bfd_error_no_error = 0,
- bfd_error_system_call,
- bfd_error_invalid_target,
- bfd_error_wrong_format,
- bfd_error_invalid_operation,
- bfd_error_no_memory,
- bfd_error_no_symbols,
- bfd_error_no_armap,
- bfd_error_no_more_archived_files,
- bfd_error_malformed_archive,
- bfd_error_file_not_recognized,
- bfd_error_file_ambiguously_recognized,
- bfd_error_no_contents,
- bfd_error_nonrepresentable_section,
- bfd_error_no_debug_section,
- bfd_error_bad_value,
- bfd_error_file_truncated,
- bfd_error_file_too_big,
- bfd_error_invalid_error_code
-} bfd_error_type;
-
-bfd_error_type
-bfd_get_error PARAMS ((void));
-
-void
-bfd_set_error PARAMS ((bfd_error_type error_tag));
-
-CONST char *
-bfd_errmsg PARAMS ((bfd_error_type error_tag));
-
-void
-bfd_perror PARAMS ((CONST char *message));
-
-typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...));
-
-bfd_error_handler_type
-bfd_set_error_handler PARAMS ((bfd_error_handler_type));
-
-void
-bfd_set_error_program_name PARAMS ((const char *));
-
-long
-bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect));
-
-long
-bfd_canonicalize_reloc
- PARAMS ((bfd *abfd,
- asection *sec,
- arelent **loc,
- asymbol **syms));
-
-void
-bfd_set_reloc
- PARAMS ((bfd *abfd, asection *sec, arelent **rel, unsigned int count)
-
- );
-
-boolean
-bfd_set_file_flags PARAMS ((bfd *abfd, flagword flags));
-
-boolean
-bfd_set_start_address PARAMS ((bfd *abfd, bfd_vma vma));
-
-long
-bfd_get_mtime PARAMS ((bfd *abfd));
-
-long
-bfd_get_size PARAMS ((bfd *abfd));
-
-int
-bfd_get_gp_size PARAMS ((bfd *abfd));
-
-void
-bfd_set_gp_size PARAMS ((bfd *abfd, int i));
-
-bfd_vma
-bfd_scan_vma PARAMS ((CONST char *string, CONST char **end, int base));
-
-boolean
-bfd_copy_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
-
-#define bfd_copy_private_bfd_data(ibfd, obfd) \
- BFD_SEND (ibfd, _bfd_copy_private_bfd_data, \
- (ibfd, obfd))
-boolean
-bfd_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd));
-
-#define bfd_merge_private_bfd_data(ibfd, obfd) \
- BFD_SEND (ibfd, _bfd_merge_private_bfd_data, \
- (ibfd, obfd))
-boolean
-bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags));
-
-#define bfd_set_private_flags(abfd, flags) \
- BFD_SEND (abfd, _bfd_set_private_flags, \
- (abfd, flags))
-#define bfd_sizeof_headers(abfd, reloc) \
- BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
-
-#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
- BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
-
- /* Do these three do anything useful at all, for any back end? */
-#define bfd_debug_info_start(abfd) \
- BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
-
-#define bfd_debug_info_end(abfd) \
- BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
-
-#define bfd_debug_info_accumulate(abfd, section) \
- BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
-
-
-#define bfd_stat_arch_elt(abfd, stat) \
- BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
-
-#define bfd_update_armap_timestamp(abfd) \
- BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
-
-#define bfd_set_arch_mach(abfd, arch, mach)\
- BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
-
-#define bfd_relax_section(abfd, section, link_info, again) \
- BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
-
-#define bfd_link_hash_table_create(abfd) \
- BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
-
-#define bfd_link_add_symbols(abfd, info) \
- BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
-
-#define bfd_final_link(abfd, info) \
- BFD_SEND (abfd, _bfd_final_link, (abfd, info))
-
-#define bfd_free_cached_info(abfd) \
- BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
-
-#define bfd_get_dynamic_symtab_upper_bound(abfd) \
- BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
-
-#define bfd_print_private_bfd_data(abfd, file)\
- BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
-
-#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
- BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
-
-#define bfd_get_dynamic_reloc_upper_bound(abfd) \
- BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
-
-#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
- BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
-
-extern bfd_byte *bfd_get_relocated_section_contents
- PARAMS ((bfd *, struct bfd_link_info *,
- struct bfd_link_order *, bfd_byte *,
- boolean, asymbol **));
-
-symindex
-bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym));
-
-boolean
-bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head));
-
-bfd *
-bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous));
-
-CONST char *
-bfd_core_file_failing_command PARAMS ((bfd *abfd));
-
-int
-bfd_core_file_failing_signal PARAMS ((bfd *abfd));
-
-boolean
-core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
-
-#define BFD_SEND(bfd, message, arglist) \
- ((*((bfd)->xvec->message)) arglist)
-
-#ifdef DEBUG_BFD_SEND
-#undef BFD_SEND
-#define BFD_SEND(bfd, message, arglist) \
- (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
- ((*((bfd)->xvec->message)) arglist) : \
- (bfd_assert (__FILE__,__LINE__), NULL))
-#endif
-#define BFD_SEND_FMT(bfd, message, arglist) \
- (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
-
-#ifdef DEBUG_BFD_SEND
-#undef BFD_SEND_FMT
-#define BFD_SEND_FMT(bfd, message, arglist) \
- (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
- (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \
- (bfd_assert (__FILE__,__LINE__), NULL))
-#endif
-enum bfd_flavour {
- bfd_target_unknown_flavour,
- bfd_target_aout_flavour,
- bfd_target_coff_flavour,
- bfd_target_ecoff_flavour,
- bfd_target_elf_flavour,
- bfd_target_ieee_flavour,
- bfd_target_nlm_flavour,
- bfd_target_oasys_flavour,
- bfd_target_tekhex_flavour,
- bfd_target_srec_flavour,
- bfd_target_ihex_flavour,
- bfd_target_som_flavour,
- bfd_target_os9k_flavour,
- bfd_target_versados_flavour,
- bfd_target_msdos_flavour
-};
-
-enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
-
- /* Forward declaration. */
-typedef struct bfd_link_info _bfd_link_info;
-
-typedef struct bfd_target
-{
- char *name;
- enum bfd_flavour flavour;
- enum bfd_endian byteorder;
- enum bfd_endian header_byteorder;
- flagword object_flags;
- flagword section_flags;
- char symbol_leading_char;
- char ar_pad_char;
- unsigned short ar_max_namelen;
- bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
- void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
- void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
- void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
- bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
- const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
- boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
- boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
-
- /* Generic entry points. */
-#define BFD_JUMP_TABLE_GENERIC(NAME)\
-CAT(NAME,_close_and_cleanup),\
-CAT(NAME,_bfd_free_cached_info),\
-CAT(NAME,_new_section_hook),\
-CAT(NAME,_get_section_contents),\
-CAT(NAME,_get_section_contents_in_window)
-
- /* Called when the BFD is being closed to do any necessary cleanup. */
- boolean (*_close_and_cleanup) PARAMS ((bfd *));
- /* Ask the BFD to free all cached information. */
- boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
- /* Called when a new section is created. */
- boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
- /* Read the contents of a section. */
- boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr, bfd_size_type));
- boolean (*_bfd_get_section_contents_in_window)
- PARAMS ((bfd *, sec_ptr, bfd_window *,
- file_ptr, bfd_size_type));
-
- /* Entry points to copy private data. */
-#define BFD_JUMP_TABLE_COPY(NAME)\
-CAT(NAME,_bfd_copy_private_bfd_data),\
-CAT(NAME,_bfd_merge_private_bfd_data),\
-CAT(NAME,_bfd_copy_private_section_data),\
-CAT(NAME,_bfd_copy_private_symbol_data),\
-CAT(NAME,_bfd_set_private_flags),\
-CAT(NAME,_bfd_print_private_bfd_data)\
- /* Called to copy BFD general private data from one object file
- to another. */
- boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
- /* Called to merge BFD general private data from one object file
- to a common output file when linking. */
- boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
- /* Called to copy BFD private section data from one object file
- to another. */
- boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
- bfd *, sec_ptr));
- /* Called to copy BFD private symbol data from one symbol
- to another. */
- boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
- bfd *, asymbol *));
- /* Called to set private backend flags */
- boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
-
- /* Called to print private BFD data */
- boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
-
- /* Core file entry points. */
-#define BFD_JUMP_TABLE_CORE(NAME)\
-CAT(NAME,_core_file_failing_command),\
-CAT(NAME,_core_file_failing_signal),\
-CAT(NAME,_core_file_matches_executable_p)
- char * (*_core_file_failing_command) PARAMS ((bfd *));
- int (*_core_file_failing_signal) PARAMS ((bfd *));
- boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *));
-
- /* Archive entry points. */
-#define BFD_JUMP_TABLE_ARCHIVE(NAME)\
-CAT(NAME,_slurp_armap),\
-CAT(NAME,_slurp_extended_name_table),\
-CAT(NAME,_construct_extended_name_table),\
-CAT(NAME,_truncate_arname),\
-CAT(NAME,_write_armap),\
-CAT(NAME,_read_ar_hdr),\
-CAT(NAME,_openr_next_archived_file),\
-CAT(NAME,_get_elt_at_index),\
-CAT(NAME,_generic_stat_arch_elt),\
-CAT(NAME,_update_armap_timestamp)
- boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
- boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
- boolean (*_bfd_construct_extended_name_table)
- PARAMS ((bfd *, char **, bfd_size_type *, const char **));
- void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
- boolean (*write_armap) PARAMS ((bfd *arch,
- unsigned int elength,
- struct orl *map,
- unsigned int orl_count,
- int stridx));
- PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
- bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
-#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
- bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
- int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
- boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *));
-
- /* Entry points used for symbols. */
-#define BFD_JUMP_TABLE_SYMBOLS(NAME)\
-CAT(NAME,_get_symtab_upper_bound),\
-CAT(NAME,_get_symtab),\
-CAT(NAME,_make_empty_symbol),\
-CAT(NAME,_print_symbol),\
-CAT(NAME,_get_symbol_info),\
-CAT(NAME,_bfd_is_local_label),\
-CAT(NAME,_get_lineno),\
-CAT(NAME,_find_nearest_line),\
-CAT(NAME,_bfd_make_debug_symbol),\
-CAT(NAME,_read_minisymbols),\
-CAT(NAME,_minisymbol_to_symbol)
- long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
- long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
- struct symbol_cache_entry **));
- struct symbol_cache_entry *
- (*_bfd_make_empty_symbol) PARAMS ((bfd *));
- void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
- struct symbol_cache_entry *,
- bfd_print_symbol_type));
-#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
- void (*_bfd_get_symbol_info) PARAMS ((bfd *,
- struct symbol_cache_entry *,
- symbol_info *));
-#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
- boolean (*_bfd_is_local_label) PARAMS ((bfd *, asymbol *));
-
- alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
- boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
- struct sec *section, struct symbol_cache_entry **symbols,
- bfd_vma offset, CONST char **file, CONST char **func,
- unsigned int *line));
- /* Back-door to allow format-aware applications to create debug symbols
- while using BFD for everything else. Currently used by the assembler
- when creating COFF files. */
- asymbol * (*_bfd_make_debug_symbol) PARAMS ((
- bfd *abfd,
- void *ptr,
- unsigned long size));
-#define bfd_read_minisymbols(b, d, m, s) \
- BFD_SEND (b, _read_minisymbols, (b, d, m, s))
- long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
- unsigned int *));
-#define bfd_minisymbol_to_symbol(b, d, m, f) \
- BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
- asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
- asymbol *));
-
- /* Routines for relocs. */
-#define BFD_JUMP_TABLE_RELOCS(NAME)\
-CAT(NAME,_get_reloc_upper_bound),\
-CAT(NAME,_canonicalize_reloc),\
-CAT(NAME,_bfd_reloc_type_lookup)
- long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
- long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
- struct symbol_cache_entry **));
- /* See documentation on reloc types. */
- reloc_howto_type *
- (*reloc_type_lookup) PARAMS ((bfd *abfd,
- bfd_reloc_code_real_type code));
-
- /* Routines used when writing an object file. */
-#define BFD_JUMP_TABLE_WRITE(NAME)\
-CAT(NAME,_set_arch_mach),\
-CAT(NAME,_set_section_contents)
- boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
- unsigned long));
- boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr, bfd_size_type));
-
- /* Routines used by the linker. */
-#define BFD_JUMP_TABLE_LINK(NAME)\
-CAT(NAME,_sizeof_headers),\
-CAT(NAME,_bfd_get_relocated_section_contents),\
-CAT(NAME,_bfd_relax_section),\
-CAT(NAME,_bfd_link_hash_table_create),\
-CAT(NAME,_bfd_link_add_symbols),\
-CAT(NAME,_bfd_final_link),\
-CAT(NAME,_bfd_link_split_section)
- int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
- bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
- struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *data, boolean relocateable,
- struct symbol_cache_entry **));
-
- boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
- struct bfd_link_info *, boolean *again));
-
- /* Create a hash table for the linker. Different backends store
- different information in this table. */
- struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
-
- /* Add symbols from this object file into the hash table. */
- boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
-
- /* Do a link based on the link_order structures attached to each
- section of the BFD. */
- boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
-
- /* Should this section be split up into smaller pieces during linking. */
- boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
-
- /* Routines to handle dynamic symbols and relocs. */
-#define BFD_JUMP_TABLE_DYNAMIC(NAME)\
-CAT(NAME,_get_dynamic_symtab_upper_bound),\
-CAT(NAME,_canonicalize_dynamic_symtab),\
-CAT(NAME,_get_dynamic_reloc_upper_bound),\
-CAT(NAME,_canonicalize_dynamic_reloc)
- /* Get the amount of memory required to hold the dynamic symbols. */
- long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
- /* Read in the dynamic symbols. */
- long (*_bfd_canonicalize_dynamic_symtab)
- PARAMS ((bfd *, struct symbol_cache_entry **));
- /* Get the amount of memory required to hold the dynamic relocs. */
- long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
- /* Read in the dynamic relocs. */
- long (*_bfd_canonicalize_dynamic_reloc)
- PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
-
- PTR backend_data;
-} bfd_target;
-const bfd_target *
-bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd));
-
-const char **
-bfd_target_list PARAMS ((void));
-
-boolean
-bfd_check_format PARAMS ((bfd *abfd, bfd_format format));
-
-boolean
-bfd_check_format_matches PARAMS ((bfd *abfd, bfd_format format, char ***matching));
-
-boolean
-bfd_set_format PARAMS ((bfd *abfd, bfd_format format));
-
-CONST char *
-bfd_format_string PARAMS ((bfd_format format));
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/contrib/gdb/bfd/bout.c b/contrib/gdb/bfd/bout.c
deleted file mode 100644
index 9da4b82..0000000
--- a/contrib/gdb/bfd/bout.c
+++ /dev/null
@@ -1,1471 +0,0 @@
-/* BFD back-end for Intel 960 b.out binaries.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "genlink.h"
-#include "bout.h"
-
-#include "aout/stab_gnu.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-
-static int aligncode PARAMS ((bfd *abfd, asection *input_section,
- arelent *r, unsigned int shrink));
-static void perform_slip PARAMS ((bfd *abfd, unsigned int slip,
- asection *input_section, bfd_vma value));
-static boolean b_out_squirt_out_relocs PARAMS ((bfd *abfd, asection *section));
-static const bfd_target *b_out_callback PARAMS ((bfd *));
-static bfd_reloc_status_type calljx_callback
- PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR src, PTR dst,
- asection *));
-static bfd_reloc_status_type callj_callback
- PARAMS ((bfd *, struct bfd_link_info *, arelent *, PTR data,
- unsigned int srcidx, unsigned int dstidx, asection *, boolean));
-static bfd_vma get_value PARAMS ((arelent *, struct bfd_link_info *,
- asection *));
-static int abs32code PARAMS ((bfd *, asection *, arelent *,
- unsigned int, struct bfd_link_info *));
-static boolean b_out_bfd_relax_section PARAMS ((bfd *, asection *,
- struct bfd_link_info *,
- boolean *));
-static bfd_byte *b_out_bfd_get_relocated_section_contents
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *, boolean, asymbol **));
-
-/* Swaps the information in an executable header taken from a raw byte
- stream memory image, into the internal exec_header structure. */
-
-void
-bout_swap_exec_header_in (abfd, raw_bytes, execp)
- bfd *abfd;
- struct external_exec *raw_bytes;
- 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];
- execp->a_relaxable = bytes->e_relaxable[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
-bout_swap_exec_header_out (abfd, execp, raw_bytes)
- bfd *abfd;
- struct internal_exec *execp;
- 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_relaxable[0] = execp->a_relaxable;
-}
-
-
-static const 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) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
-
- if (N_BADMAG (anexec)) {
- bfd_set_error (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 const 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;
-
- /* And reload the sizes, since the aout module zaps them */
- obj_textsec (abfd)->_raw_size = execp->a_text;
-
- bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */
- obj_bsssec (abfd)->vma = align_power (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);
-
- adata(abfd).page_size = 1; /* Not applicable. */
- adata(abfd).segment_size = 1; /* Not applicable. */
- adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
-
- if (execp->a_relaxable)
- abfd->flags |= BFD_IS_RELAXABLE;
- return abfd->xvec;
-}
-
-struct bout_data_struct {
- struct aoutdata a;
- struct internal_exec e;
-};
-
-static boolean
-b_out_mkobject (abfd)
- bfd *abfd;
-{
- struct bout_data_struct *rawptr;
-
- rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
- if (rawptr == NULL)
- return false;
-
- abfd->tdata.bout_data = rawptr;
- exec_hdr (abfd) = &rawptr->e;
-
- obj_textsec (abfd) = (asection *)NULL;
- obj_datasec (abfd) = (asection *)NULL;
- obj_bsssec (abfd) = (asection *)NULL;
-
- return true;
-}
-
-static boolean
-b_out_write_object_contents (abfd)
- bfd *abfd;
-{
- struct external_exec swapped_hdr;
-
- if (! aout_32_make_sections (abfd))
- return false;
-
- exec_hdr (abfd)->a_info = BMAGIC;
-
- exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
- exec_hdr (abfd)->a_data = obj_datasec (abfd)->_raw_size;
- exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_raw_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);
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE))
- return false;
-
- /* Now write out reloc info, followed by syms and strings */
- if (bfd_get_symcount (abfd) != 0)
- {
- if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
- != 0)
- return false;
-
- if (! aout_32_write_syms (abfd))
- return false;
-
- if (bfd_seek (abfd, (file_ptr)(N_TROFF(*exec_hdr(abfd))), SEEK_SET) != 0)
- return false;
-
- if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) return false;
- if (bfd_seek (abfd, (file_ptr)(N_DROFF(*exec_hdr(abfd))), SEEK_SET)
- != 0)
- return false;
-
- 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 BALX 0x85000000 /* Template for 'balx' instruction */
-#define BAL_MASK 0x00ffffff
-#define CALL 0x09000000
-#define PCREL13_MASK 0x1fff
-
-
-#define output_addr(sec) ((sec)->output_offset+(sec)->output_section->vma)
-
-/* Magic to turn callx into calljx */
-static bfd_reloc_status_type
-calljx_callback (abfd, link_info, reloc_entry, src, dst, input_section)
- bfd *abfd;
- struct bfd_link_info *link_info;
- arelent *reloc_entry;
- PTR src;
- PTR dst;
- asection *input_section;
-{
- int word = bfd_get_32 (abfd, src);
- asymbol *symbol_in = *(reloc_entry->sym_ptr_ptr);
- aout_symbol_type *symbol = aout_symbol (symbol_in);
- bfd_vma value;
-
- value = get_value (reloc_entry, link_info, input_section);
-
- if (IS_CALLNAME (symbol->other))
- {
- aout_symbol_type *balsym = symbol+1;
- int inst = bfd_get_32 (abfd, (bfd_byte *) src-4);
- /* The next symbol should be an N_BALNAME */
- BFD_ASSERT (IS_BALNAME (balsym->other));
- inst &= BAL_MASK;
- inst |= BALX;
- bfd_put_32 (abfd, inst, (bfd_byte *) dst-4);
- symbol = balsym;
- value = (symbol->symbol.value
- + output_addr (symbol->symbol.section));
- }
-
- word += value + reloc_entry->addend;
-
- bfd_put_32(abfd, word, dst);
- return bfd_reloc_ok;
-}
-
-
-/* Magic to turn call into callj */
-static bfd_reloc_status_type
-callj_callback (abfd, link_info, reloc_entry, data, srcidx, dstidx,
- input_section, shrinking)
- bfd *abfd;
- struct bfd_link_info *link_info;
- arelent *reloc_entry;
- PTR data;
- unsigned int srcidx;
- unsigned int dstidx;
- asection *input_section;
- boolean shrinking;
-{
- int word = bfd_get_32 (abfd, (bfd_byte *) data + srcidx);
- asymbol *symbol_in = *(reloc_entry->sym_ptr_ptr);
- aout_symbol_type *symbol = aout_symbol (symbol_in);
- bfd_vma value;
-
- value = get_value (reloc_entry, link_info, input_section);
-
- if (IS_OTHER(symbol->other))
- {
- /* Call to a system procedure - replace code with system
- procedure number. */
- word = CALLS | (symbol->other - 1);
- }
- else 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
- + output_addr (balsym->symbol.section)
- + balsym->symbol.value + reloc_entry->addend
- - dstidx
- - output_addr (input_section))
- & BAL_MASK);
- }
- else if ((symbol->symbol.flags & BSF_SECTION_SYM) != 0)
- {
- /* A callj against a symbol in the same section is a fully
- resolved relative call. We don't need to do anything here.
- If the symbol is not in the same section, I'm not sure what
- to do; fortunately, this case will probably never arise. */
- BFD_ASSERT (! shrinking);
- BFD_ASSERT (symbol->symbol.section == input_section);
- }
- else
- {
- word = CALL | (((word & BAL_MASK)
- + value
- + reloc_entry->addend
- - (shrinking ? dstidx : 0)
- - output_addr (input_section))
- & BAL_MASK);
- }
- bfd_put_32(abfd, word, (bfd_byte *) data + dstidx);
- return bfd_reloc_ok;
-}
-
-/* type rshift size bitsize pcrel bitpos absolute overflow check*/
-
-#define ABS32CODE 0
-#define ABS32CODE_SHRUNK 1
-#define PCREL24 2
-#define CALLJ 3
-#define ABS32 4
-#define PCREL13 5
-#define ABS32_MAYBE_RELAXABLE 1
-#define ABS32_WAS_RELAXABLE 2
-
-#define ALIGNER 10
-#define ALIGNDONE 11
-static reloc_howto_type howto_reloc_callj =
-HOWTO(CALLJ, 0, 2, 24, true, 0, complain_overflow_signed, 0,"callj", true, 0x00ffffff, 0x00ffffff,false);
-static reloc_howto_type howto_reloc_abs32 =
-HOWTO(ABS32, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"abs32", true, 0xffffffff,0xffffffff,false);
-static reloc_howto_type howto_reloc_pcrel24 =
-HOWTO(PCREL24, 0, 2, 24, true, 0, complain_overflow_signed,0,"pcrel24", true, 0x00ffffff,0x00ffffff,false);
-
-static reloc_howto_type howto_reloc_pcrel13 =
-HOWTO(PCREL13, 0, 2, 13, true, 0, complain_overflow_signed,0,"pcrel13", true, 0x00001fff,0x00001fff,false);
-
-
-static reloc_howto_type howto_reloc_abs32codeshrunk =
-HOWTO(ABS32CODE_SHRUNK, 0, 2, 24, true, 0, complain_overflow_signed, 0,"callx->callj", true, 0x00ffffff, 0x00ffffff,false);
-
-static reloc_howto_type howto_reloc_abs32code =
-HOWTO(ABS32CODE, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"callx", true, 0xffffffff,0xffffffff,false);
-
-static reloc_howto_type howto_align_table[] = {
- HOWTO (ALIGNER, 0, 0x1, 0, false, 0, complain_overflow_dont, 0, "align16", false, 0, 0, false),
- HOWTO (ALIGNER, 0, 0x3, 0, false, 0, complain_overflow_dont, 0, "align32", false, 0, 0, false),
- HOWTO (ALIGNER, 0, 0x7, 0, false, 0, complain_overflow_dont, 0, "align64", false, 0, 0, false),
- HOWTO (ALIGNER, 0, 0xf, 0, false, 0, complain_overflow_dont, 0, "align128", false, 0, 0, false),
-};
-
-static reloc_howto_type howto_done_align_table[] = {
- HOWTO (ALIGNDONE, 0x1, 0x1, 0, false, 0, complain_overflow_dont, 0, "donealign16", false, 0, 0, false),
- HOWTO (ALIGNDONE, 0x3, 0x3, 0, false, 0, complain_overflow_dont, 0, "donealign32", false, 0, 0, false),
- HOWTO (ALIGNDONE, 0x7, 0x7, 0, false, 0, complain_overflow_dont, 0, "donealign64", false, 0, 0, false),
- HOWTO (ALIGNDONE, 0xf, 0xf, 0, false, 0, complain_overflow_dont, 0, "donealign128", false, 0, 0, false),
-};
-
-static reloc_howto_type *
-b_out_bfd_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- default:
- return 0;
- case BFD_RELOC_I960_CALLJ:
- return &howto_reloc_callj;
- case BFD_RELOC_32:
- case BFD_RELOC_CTOR:
- return &howto_reloc_abs32;
- case BFD_RELOC_24_PCREL:
- return &howto_reloc_pcrel24;
- }
-}
-
-/* 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;
-{
- register struct relocation_info *rptr;
- unsigned int counter ;
- arelent *cache_ptr ;
- int extern_mask, pcrel_mask, callj_mask, length_shift;
- int incode_mask;
- int size_mask;
- bfd_vma prev_addr = 0;
- 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;
- }
-
- if (asect == obj_bsssec (abfd)) {
- reloc_size = 0;
- goto doit;
- }
-
- bfd_set_error (bfd_error_invalid_operation);
- return false;
-
- doit:
- if (bfd_seek (abfd, (file_ptr)(asect->rel_filepos), SEEK_SET) != 0)
- return false;
- count = reloc_size / sizeof (struct relocation_info);
-
- relocs = (struct relocation_info *) bfd_malloc (reloc_size);
- if (!relocs && reloc_size != 0)
- return false;
- reloc_cache = (arelent *) bfd_malloc ((count+1) * sizeof (arelent));
- if (!reloc_cache) {
- if (relocs != NULL)
- free ((char*)relocs);
- return false;
- }
-
- if (bfd_read ((PTR) relocs, 1, reloc_size, abfd) != reloc_size) {
- free (reloc_cache);
- if (relocs != NULL)
- free (relocs);
- return false;
- }
-
-
-
- if (bfd_header_big_endian (abfd)) {
- /* big-endian bit field allocation order */
- pcrel_mask = 0x80;
- extern_mask = 0x10;
- incode_mask = 0x08;
- callj_mask = 0x02;
- size_mask = 0x20;
- length_shift = 5;
- } else {
- /* little-endian bit field allocation order */
- pcrel_mask = 0x01;
- extern_mask = 0x08;
- incode_mask = 0x10;
- callj_mask = 0x40;
- size_mask = 0x02;
- length_shift = 1;
- }
-
- for (rptr = relocs, cache_ptr = reloc_cache, counter = 0;
- 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);
- cache_ptr->howto = 0;
- if (bfd_header_big_endian (abfd))
- {
- 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;
- } 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 */
- int s;
- {
- /* sign-extend symnum from 24 bits to whatever host uses */
- s = symnum;
- if (s & (1 << 23))
- s |= (~0) << 24;
- }
- cache_ptr->sym_ptr_ptr = (asymbol **)NULL;
- switch (s)
- {
- case N_TEXT:
- case N_TEXT | N_EXT:
- cache_ptr->sym_ptr_ptr = obj_textsec(abfd)->symbol_ptr_ptr;
- cache_ptr->addend = - obj_textsec(abfd)->vma;
- break;
- case N_DATA:
- case N_DATA | N_EXT:
- cache_ptr->sym_ptr_ptr = obj_datasec(abfd)->symbol_ptr_ptr;
- cache_ptr->addend = - obj_datasec(abfd)->vma;
- break;
- case N_BSS:
- case N_BSS | N_EXT:
- cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr;
- cache_ptr->addend = - obj_bsssec(abfd)->vma;
- break;
- case N_ABS:
- case N_ABS | N_EXT:
- cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr;
- cache_ptr->addend = 0;
- break;
- case -2: /* .align */
- if (raw[7] & pcrel_mask)
- {
- cache_ptr->howto = &howto_align_table[(raw[7] >> length_shift) & 3];
- cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- }
- else
- {
- /* .org? */
- abort ();
- }
- cache_ptr->addend = 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 (cache_ptr->howto != 0)
- ;
- else if (raw[7] & callj_mask)
- {
- cache_ptr->howto = &howto_reloc_callj;
- }
- else if ( raw[7] & pcrel_mask)
- {
- if (raw[7] & size_mask)
- cache_ptr->howto = &howto_reloc_pcrel13;
- else
- cache_ptr->howto = &howto_reloc_pcrel24;
- }
- else
- {
- if (raw[7] & incode_mask)
- {
- cache_ptr->howto = &howto_reloc_abs32code;
- }
- else
- {
- cache_ptr->howto = &howto_reloc_abs32;
- }
- }
- if (cache_ptr->address < prev_addr)
- {
- /* Ouch! this reloc is out of order, insert into the right place
- */
- arelent tmp;
- arelent *cursor = cache_ptr-1;
- bfd_vma stop = cache_ptr->address;
- tmp = *cache_ptr;
- while (cursor->address > stop && cursor >= reloc_cache)
- {
- cursor[1] = cursor[0];
- cursor--;
- }
- cursor[1] = tmp;
- }
- else
- {
- prev_addr = cache_ptr->address;
- }
- }
-
-
- if (relocs != NULL)
- 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;
- int r_extern = 0;
- int r_idx;
- int incode_mask;
- int len_1;
- 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 *) bfd_malloc (natsize));
- if (!native && natsize != 0)
- return false;
-
- if (bfd_header_big_endian (abfd))
- {
- /* Big-endian bit field allocation order */
- pcrel_mask = 0x80;
- extern_mask = 0x10;
- len_2 = 0x40;
- len_1 = 0x20;
- callj_mask = 0x02;
- incode_mask = 0x08;
- }
- else
- {
- /* Little-endian bit field allocation order */
- pcrel_mask = 0x01;
- extern_mask = 0x08;
- len_2 = 0x04;
- len_1 = 0x02;
- callj_mask = 0x40;
- incode_mask = 0x10;
- }
-
- for (natptr = native; count > 0; --count, ++natptr, ++generic)
- {
- arelent *g = *generic;
- unsigned char *raw = (unsigned char *)natptr;
- asymbol *sym = *(g->sym_ptr_ptr);
-
- asection *output_section = sym->section->output_section;
-
- 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!!
- */
- r_idx = 0;
- /* 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 if (g->howto == &howto_reloc_pcrel13)
- {
- raw[7] = pcrel_mask + len_1;
- }
- else if (g->howto == &howto_reloc_abs32code)
- {
- raw[7] = len_2 + incode_mask;
- }
- else if (g->howto >= howto_align_table
- && g->howto <= (howto_align_table
- + sizeof (howto_align_table) / sizeof (howto_align_table[0])
- - 1))
- {
- /* symnum == -2; extern_mask not set, pcrel_mask set */
- r_idx = -2;
- r_extern = 0;
- raw[7] = (pcrel_mask
- | ((g->howto - howto_align_table) << 1));
- }
- else {
- raw[7] = len_2;
- }
-
- if (r_idx != 0)
- /* already mucked with r_extern, r_idx */;
- else if (bfd_is_com_section (output_section)
- || bfd_is_abs_section (output_section)
- || bfd_is_und_section (output_section))
- {
-
- if (bfd_abs_section_ptr->symbol == sym)
- {
- /* Whoops, looked like an abs symbol, but is really an offset
- from the abs section */
- r_idx = 0;
- r_extern = 0;
- }
- else
- {
- /* Fill in symbol */
-
- r_extern = 1;
- r_idx = (*g->sym_ptr_ptr)->udata.i;
- }
- }
- else
- {
- /* Just an ordinary section */
- r_extern = 0;
- r_idx = output_section->target_index;
- }
-
- if (bfd_header_big_endian (abfd)) {
- raw[4] = (unsigned char) (r_idx >> 16);
- raw[5] = (unsigned char) (r_idx >> 8);
- raw[6] = (unsigned char) (r_idx );
- } else {
- raw[6] = (unsigned char) (r_idx >> 16);
- raw[5] = (unsigned char) (r_idx>> 8);
- raw[4] = (unsigned char) (r_idx );
- }
- if (r_extern)
- raw[7] |= extern_mask;
- }
-
- 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 long
-b_out_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr;
- unsigned int count;
-
- if ((section->flags & SEC_CONSTRUCTOR) != 0)
- {
- arelent_chain *chain = section->constructor_chain;
- for (count = 0; count < section->reloc_count; count++)
- {
- *relptr++ = &chain->relent;
- chain = chain->next;
- }
- }
- else
- {
- if (section->relocation == NULL
- && ! b_out_slurp_reloc_table (abfd, section, symbols))
- return -1;
-
- tblptr = section->relocation;
- for (count = 0; count++ < section->reloc_count;)
- *relptr++ = tblptr++;
- }
-
- *relptr = NULL;
-
- return section->reloc_count;
-}
-
-static long
-b_out_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- if (bfd_get_format (abfd) != bfd_object) {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- 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 / sizeof (struct relocation_info))
- +1));
-
- if (asect == obj_textsec (abfd))
- return (sizeof (arelent *) *
- ((exec_hdr(abfd)->a_trsize / sizeof (struct relocation_info))
- +1));
-
- if (asect == obj_bsssec (abfd))
- return 0;
-
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
-}
-
-static boolean
-b_out_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
-
- if (abfd->output_has_begun == false) { /* set by bfd.c handler */
- if (! aout_32_make_sections (abfd))
- return false;
-
- obj_textsec (abfd)->filepos = sizeof(struct internal_exec);
- obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos
- + obj_textsec (abfd)->_raw_size;
-
- }
- /* regardless, once we know what we're doing, we might as well get going */
- if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
- return false;
-
- if (count != 0) {
- return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
- }
- return true;
-}
-
-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 bfd_mach_i960_jx:
- case bfd_mach_i960_hx:
- case 0:
- return true;
- default:
- return false;
- }
-
- return false;
-}
-
-static int
-b_out_sizeof_headers (ignore_abfd, ignore)
- bfd *ignore_abfd;
- boolean ignore;
-{
- return sizeof(struct internal_exec);
-}
-
-
-
-/************************************************************************/
-static bfd_vma
-get_value (reloc, link_info, input_section)
- arelent *reloc;
- struct bfd_link_info *link_info;
- asection *input_section;
-{
- bfd_vma value;
- asymbol *symbol = *(reloc->sym_ptr_ptr);
-
- /* A symbol holds a pointer to a section, and an offset from the
- base of the section. To relocate, we find where the section will
- live in the output and add that in */
-
- if (bfd_is_und_section (symbol->section))
- {
- struct bfd_link_hash_entry *h;
-
- /* The symbol is undefined in this BFD. Look it up in the
- global linker hash table. FIXME: This should be changed when
- we convert b.out to use a specific final_link function and
- change the interface to bfd_relax_section to not require the
- generic symbols. */
- h = bfd_wrapped_link_hash_lookup (input_section->owner, link_info,
- bfd_asymbol_name (symbol),
- false, false, true);
- if (h != (struct bfd_link_hash_entry *) NULL
- && (h->type == bfd_link_hash_defined
- || h->type == bfd_link_hash_defweak))
- value = h->u.def.value + output_addr (h->u.def.section);
- else if (h != (struct bfd_link_hash_entry *) NULL
- && h->type == bfd_link_hash_common)
- value = h->u.c.size;
- else
- {
- if (! ((*link_info->callbacks->undefined_symbol)
- (link_info, bfd_asymbol_name (symbol),
- input_section->owner, input_section, reloc->address)))
- abort ();
- value = 0;
- }
- }
- else
- {
- value = symbol->value + output_addr (symbol->section);
- }
-
- /* Add the value contained in the relocation */
- value += reloc->addend;
-
- return value;
-}
-
-static void
-perform_slip (abfd, slip, input_section, value)
- bfd *abfd;
- unsigned int slip;
- asection *input_section;
- bfd_vma value;
-{
- asymbol **s;
-
- s = _bfd_generic_link_get_symbols (abfd);
- BFD_ASSERT (s != (asymbol **) NULL);
-
- /* Find all symbols past this point, and make them know
- what's happened */
- while (*s)
- {
- asymbol *p = *s;
- if (p->section == input_section)
- {
- /* This was pointing into this section, so mangle it */
- if (p->value > value)
- {
- p->value -=slip;
- if (p->udata.p != NULL)
- {
- struct generic_link_hash_entry *h;
-
- h = (struct generic_link_hash_entry *) p->udata.p;
- BFD_ASSERT (h->root.type == bfd_link_hash_defined);
- h->root.u.def.value -= slip;
- BFD_ASSERT (h->root.u.def.value == p->value);
- }
- }
- }
- s++;
-
- }
-}
-
-/* This routine works out if the thing we want to get to can be
- reached with a 24bit offset instead of a 32 bit one.
- If it can, then it changes the amode */
-
-static int
-abs32code (abfd, input_section, r, shrink, link_info)
- bfd *abfd;
- asection *input_section;
- arelent *r;
- unsigned int shrink;
- struct bfd_link_info *link_info;
-{
- bfd_vma value = get_value (r, link_info, input_section);
- bfd_vma dot = output_addr (input_section) + r->address;
- bfd_vma gap;
-
- /* See if the address we're looking at within 2^23 bytes of where
- we are, if so then we can use a small branch rather than the
- jump we were going to */
-
- gap = value - (dot - shrink);
-
-
- if (-1<<23 < (long)gap && (long)gap < 1<<23 )
- {
- /* Change the reloc type from 32bitcode possible 24, to 24bit
- possible 32 */
-
- r->howto = &howto_reloc_abs32codeshrunk;
- /* The place to relc moves back by four bytes */
- r->address -=4;
-
- /* This will be four bytes smaller in the long run */
- shrink += 4 ;
- perform_slip (abfd, 4, input_section, r->address-shrink + 4);
- }
- return shrink;
-}
-
-static int
-aligncode (abfd, input_section, r, shrink)
- bfd *abfd;
- asection *input_section;
- arelent *r;
- unsigned int shrink;
-{
- bfd_vma dot = output_addr (input_section) + r->address;
- bfd_vma gap;
- bfd_vma old_end;
- bfd_vma new_end;
- int shrink_delta;
- int size = r->howto->size;
-
- /* Reduce the size of the alignment so that it's still aligned but
- smaller - the current size is already the same size as or bigger
- than the alignment required. */
-
- /* calculate the first byte following the padding before we optimize */
- old_end = ((dot + size ) & ~size) + size+1;
- /* work out where the new end will be - remember that we're smaller
- than we used to be */
- new_end = ((dot - shrink + size) & ~size);
-
- /* This is the new end */
- gap = old_end - ((dot + size) & ~size);
-
- shrink_delta = (old_end - new_end) - shrink;
-
- if (shrink_delta)
- {
- /* Change the reloc so that it knows how far to align to */
- r->howto = howto_done_align_table + (r->howto - howto_align_table);
-
- /* Encode the stuff into the addend - for future use we need to
- know how big the reloc used to be */
- r->addend = old_end - dot + r->address;
-
- /* This will be N bytes smaller in the long run, adjust all the symbols */
- perform_slip (abfd, shrink_delta, input_section, r->address - shrink);
- shrink += shrink_delta;
- }
- return shrink;
-}
-
-static boolean
-b_out_bfd_relax_section (abfd, i, link_info, again)
- bfd *abfd;
- asection *i;
- struct bfd_link_info *link_info;
- boolean *again;
-{
- /* Get enough memory to hold the stuff */
- bfd *input_bfd = i->owner;
- asection *input_section = i;
- int shrink = 0 ;
- arelent **reloc_vector = NULL;
- long reloc_size = bfd_get_reloc_upper_bound(input_bfd,
- input_section);
-
- if (reloc_size < 0)
- return false;
-
- /* We only run this relaxation once. It might work to run it
- multiple times, but it hasn't been tested. */
- *again = false;
-
- if (reloc_size)
- {
- long reloc_count;
-
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
- if (reloc_vector == NULL && reloc_size != 0)
- goto error_return;
-
- /* Get the relocs and think about them */
- reloc_count =
- bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector,
- _bfd_generic_link_get_symbols (input_bfd));
- if (reloc_count < 0)
- goto error_return;
- if (reloc_count > 0)
- {
- arelent **parent;
- for (parent = reloc_vector; *parent; parent++)
- {
- arelent *r = *parent;
- switch (r->howto->type)
- {
- case ALIGNER:
- /* An alignment reloc */
- shrink = aligncode (abfd, input_section, r, shrink);
- break;
- case ABS32CODE:
- /* A 32bit reloc in an addressing mode */
- shrink = abs32code (input_bfd, input_section, r, shrink,
- link_info);
- break;
- case ABS32CODE_SHRUNK:
- shrink+=4;
- break;
- }
- }
- }
- }
- input_section->_cooked_size = input_section->_raw_size - shrink;
-
- if (reloc_vector != NULL)
- free (reloc_vector);
- return true;
- error_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
- return false;
-}
-
-static bfd_byte *
-b_out_bfd_get_relocated_section_contents (in_abfd, link_info, link_order,
- data, relocateable, symbols)
- bfd *in_abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- bfd_byte *data;
- boolean relocateable;
- asymbol **symbols;
-{
- /* Get enough memory to hold the stuff */
- bfd *input_bfd = link_order->u.indirect.section->owner;
- asection *input_section = link_order->u.indirect.section;
- long reloc_size = bfd_get_reloc_upper_bound(input_bfd,
- input_section);
- arelent **reloc_vector = NULL;
- long reloc_count;
-
- if (reloc_size < 0)
- goto error_return;
-
- /* If producing relocateable output, don't bother to relax. */
- if (relocateable)
- return bfd_generic_get_relocated_section_contents (in_abfd, link_info,
- link_order,
- data, relocateable,
- symbols);
-
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
- if (reloc_vector == NULL && reloc_size != 0)
- goto error_return;
-
- input_section->reloc_done = 1;
-
- /* read in the section */
- BFD_ASSERT (true == bfd_get_section_contents(input_bfd,
- input_section,
- data,
- 0,
- input_section->_raw_size));
-
- reloc_count = bfd_canonicalize_reloc (input_bfd,
- input_section,
- reloc_vector,
- symbols);
- if (reloc_count < 0)
- goto error_return;
- if (reloc_count > 0)
- {
- arelent **parent = reloc_vector;
- arelent *reloc ;
-
- unsigned int dst_address = 0;
- unsigned int src_address = 0;
- unsigned int run;
- unsigned int idx;
-
- /* Find how long a run we can do */
- while (dst_address < link_order->size)
- {
- reloc = *parent;
- if (reloc)
- {
- /* Note that the relaxing didn't tie up the addresses in the
- relocation, so we use the original address to work out the
- run of non-relocated data */
- BFD_ASSERT (reloc->address >= src_address);
- run = reloc->address - src_address;
- parent++;
- }
- else
- {
- run = link_order->size - dst_address;
- }
- /* Copy the bytes */
- for (idx = 0; idx < run; idx++)
- {
- data[dst_address++] = data[src_address++];
- }
-
- /* Now do the relocation */
-
- if (reloc)
- {
- switch (reloc->howto->type)
- {
- case ABS32CODE:
- calljx_callback (in_abfd, link_info, reloc,
- src_address + data, dst_address + data,
- input_section);
- src_address+=4;
- dst_address+=4;
- break;
- case ABS32:
- bfd_put_32(in_abfd,
- (bfd_get_32 (in_abfd, data+src_address)
- + get_value (reloc, link_info, input_section)),
- data+dst_address);
- src_address+=4;
- dst_address+=4;
- break;
- case CALLJ:
- callj_callback (in_abfd, link_info, reloc, data, src_address,
- dst_address, input_section, false);
- src_address+=4;
- dst_address+=4;
- break;
- case ALIGNDONE:
- BFD_ASSERT (reloc->addend >= src_address);
- BFD_ASSERT (reloc->addend <= input_section->_raw_size);
- src_address = reloc->addend;
- dst_address = ((dst_address + reloc->howto->size)
- & ~reloc->howto->size);
- break;
- case ABS32CODE_SHRUNK:
- /* This used to be a callx, but we've found out that a
- callj will reach, so do the right thing. */
- callj_callback (in_abfd, link_info, reloc, data,
- src_address + 4, dst_address, input_section,
- true);
- dst_address+=4;
- src_address+=8;
- break;
- case PCREL24:
- {
- long int word = bfd_get_32(in_abfd, data+src_address);
- bfd_vma value;
-
- value = get_value (reloc, link_info, input_section);
- word = ((word & ~BAL_MASK)
- | (((word & BAL_MASK)
- + value
- - output_addr (input_section)
- + reloc->addend)
- & BAL_MASK));
-
- bfd_put_32(in_abfd,word, data+dst_address);
- dst_address+=4;
- src_address+=4;
-
- }
- break;
-
- case PCREL13:
- {
- long int word = bfd_get_32(in_abfd, data+src_address);
- bfd_vma value;
-
- value = get_value (reloc, link_info, input_section);
- word = ((word & ~PCREL13_MASK)
- | (((word & PCREL13_MASK)
- + value
- + reloc->addend
- - output_addr (input_section))
- & PCREL13_MASK));
-
- bfd_put_32(in_abfd,word, data+dst_address);
- dst_address+=4;
- src_address+=4;
-
- }
- break;
-
- default:
- abort();
- }
- }
- }
- }
- if (reloc_vector != NULL)
- free (reloc_vector);
- return data;
- error_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
- return NULL;
-}
-/***********************************************************************/
-
-/* Build the transfer vectors for Big and Little-Endian B.OUT files. */
-
-#define aout_32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
-
-#define b_out_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define b_out_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define b_out_bfd_final_link _bfd_generic_final_link
-#define b_out_bfd_link_split_section _bfd_generic_link_split_section
-
-#define aout_32_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-const bfd_target b_out_vec_big_host =
-{
- "b.out.big", /* name */
- bfd_target_aout_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_BIG, /* hdr byte order is big */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* symbol leading char */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
-
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
- {_bfd_dummy_target, 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},
-
- BFD_JUMP_TABLE_GENERIC (aout_32),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
- BFD_JUMP_TABLE_SYMBOLS (aout_32),
- BFD_JUMP_TABLE_RELOCS (b_out),
- BFD_JUMP_TABLE_WRITE (b_out),
- BFD_JUMP_TABLE_LINK (b_out),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0,
-};
-
-
-const bfd_target b_out_vec_little_host =
-{
- "b.out.little", /* name */
- bfd_target_aout_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* symbol leading char */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (aout_32),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
- BFD_JUMP_TABLE_SYMBOLS (aout_32),
- BFD_JUMP_TABLE_RELOCS (b_out),
- BFD_JUMP_TABLE_WRITE (b_out),
- BFD_JUMP_TABLE_LINK (b_out),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/cf-i386lynx.c b/contrib/gdb/bfd/cf-i386lynx.c
deleted file mode 100644
index 2a14bde..0000000
--- a/contrib/gdb/bfd/cf-i386lynx.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* BFD back-end for Intel 386 COFF LynxOS files.
- Copyright 1993, 1994 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#define TARGET_SYM i386lynx_coff_vec
-#define TARGET_NAME "coff-i386-lynx"
-
-#define LYNXOS
-
-#define COFF_LONG_FILENAMES
-
-#include "coff-i386.c"
diff --git a/contrib/gdb/bfd/cf-m68klynx.c b/contrib/gdb/bfd/cf-m68klynx.c
deleted file mode 100644
index 8149dc6..0000000
--- a/contrib/gdb/bfd/cf-m68klynx.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/* BFD back-end for Motorola M68K COFF LynxOS files.
- Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_SYM m68klynx_coff_vec
-#define TARGET_NAME "coff-m68k-lynx"
-
-#define LYNXOS
-
-#define COFF_LONG_FILENAMES
-
-#define _bfd_m68kcoff_howto_table _bfd_m68klynx_howto_table
-#define _bfd_m68kcoff_rtype2howto _bfd_m68klynx_rtype2howto
-#define _bfd_m68kcoff_howto2rtype _bfd_m68klynx_howto2rtype
-#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68klynx_reloc_type_lookup
-
-#define LYNX_SPECIAL_FN _bfd_m68klynx_special_fn
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#ifdef ANSI_PROTOTYPES
-struct internal_reloc;
-struct coff_link_hash_entry;
-struct internal_syment;
-#endif
-
-static bfd_reloc_status_type _bfd_m68klynx_special_fn
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type *coff_m68k_lynx_rtype_to_howto
- PARAMS ((bfd *, asection *, struct internal_reloc *,
- struct coff_link_hash_entry *, struct internal_syment *,
- bfd_vma *));
-
-/* For some reason when using m68k COFF the value stored in the .text
- section for a reference to a common symbol is the value itself plus
- any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
- for I386 COFF). */
-
-/* If we are producing relocateable output, we need to do some
- adjustments to the object file that are not done by the
- bfd_perform_relocation function. This function is called by every
- reloc type to make any required adjustments. */
-
-static bfd_reloc_status_type
-_bfd_m68klynx_special_fn (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- symvalue diff;
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- if (bfd_is_com_section (symbol->section))
- {
- /* We are relocating a common symbol. The current value in the
- object file is ORIG + OFFSET, where ORIG is the value of the
- common symbol as seen by the object file when it was compiled
- (this may be zero if the symbol was undefined) and OFFSET is
- the offset into the common symbol (normally zero, but may be
- non-zero when referring to a field in a common structure).
- ORIG is the negative of reloc_entry->addend, which is set by
- the CALC_ADDEND macro below. We want to replace the value in
- the object file with NEW + OFFSET, where NEW is the value of
- the common symbol which we are going to put in the final
- object file. NEW is symbol->value. */
- diff = symbol->value + reloc_entry->addend;
- }
- else
- {
- /* For some reason bfd_perform_relocation always effectively
- ignores the addend for a COFF target when producing
- relocateable output. This seems to be always wrong for 386
- COFF, so we handle the addend here instead. */
- diff = reloc_entry->addend;
- }
-
-#define DOIT(x) \
- x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
-
- if (diff != 0)
- {
- reloc_howto_type *howto = reloc_entry->howto;
- unsigned char *addr = (unsigned char *) data + reloc_entry->address;
-
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, addr);
- DOIT (x);
- bfd_put_8 (abfd, x, addr);
- }
- break;
-
- case 1:
- {
- short x = bfd_get_16 (abfd, addr);
- DOIT (x);
- bfd_put_16 (abfd, x, addr);
- }
- break;
-
- case 2:
- {
- long x = bfd_get_32 (abfd, addr);
- DOIT (x);
- bfd_put_32 (abfd, x, addr);
- }
- break;
-
- default:
- abort ();
- }
- }
-
- /* Now let bfd_perform_relocation finish everything up. */
- return bfd_reloc_continue;
-}
-/* Compute the addend of a reloc. If the reloc is to a common symbol,
- the object file contains the value of the common symbol. By the
- time this is called, the linker may be using a different symbol
- from a different object file with a different value. Therefore, we
- hack wildly to locate the original symbol from this file so that we
- can make the correct adjustment. This macro sets coffsym to the
- symbol from the original file, and uses it to set the addend value
- correctly. If this is not a common symbol, the usual addend
- calculation is done, except that an additional tweak is needed for
- PC relative relocs.
- FIXME: This macro refers to symbols and asect; these are from the
- calling function, not the macro arguments. */
-
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
- { \
- coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
- if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
- coffsym = (obj_symbols (abfd) \
- + (cache_ptr->sym_ptr_ptr - symbols)); \
- else if (ptr) \
- coffsym = coff_symbol_from (abfd, ptr); \
- if (coffsym != (coff_symbol_type *) NULL \
- && coffsym->native->u.syment.n_scnum == 0) \
- cache_ptr->addend = - coffsym->native->u.syment.n_value; \
- else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
- && ptr->section != (asection *) NULL) \
- cache_ptr->addend = - (ptr->section->vma + ptr->value); \
- else \
- cache_ptr->addend = 0; \
- if (ptr && (reloc.r_type == R_PCRBYTE \
- || reloc.r_type == R_PCRWORD \
- || reloc.r_type == R_PCRLONG)) \
- cache_ptr->addend += asect->vma; \
- }
-
-#define coff_rtype_to_howto coff_m68k_lynx_rtype_to_howto
-
-#include "coff-m68k.c"
-
-/* coff-m68k.c uses the special COFF backend linker. We need to
- adjust common symbols.
-
- We can't define this function until after we have included
- coff-m68k.c, because it uses RTYPE2HOWTO. */
-
-/*ARGSUSED*/
-static reloc_howto_type *
-coff_m68k_lynx_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
- bfd *abfd;
- asection *sec;
- struct internal_reloc *rel;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma *addendp;
-{
- arelent relent;
- reloc_howto_type *howto;
-
- RTYPE2HOWTO (&relent, rel);
-
- howto = relent.howto;
-
- if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
- {
- /* This is a common symbol. The section contents include the
- size (sym->n_value) as an addend. The relocate_section
- function will be adding in the final value of the symbol. We
- need to subtract out the current size in order to get the
- correct result. */
- BFD_ASSERT (h != NULL);
- *addendp -= sym->n_value;
- }
-
- /* If the output symbol is common (in which case this must be a
- relocateable link), we need to add in the final size of the
- common symbol. */
- if (h != NULL && h->root.type == bfd_link_hash_common)
- *addendp += h->root.u.c.size;
-
- return howto;
-}
diff --git a/contrib/gdb/bfd/cf-sparclynx.c b/contrib/gdb/bfd/cf-sparclynx.c
deleted file mode 100644
index 774a099..0000000
--- a/contrib/gdb/bfd/cf-sparclynx.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* BFD back-end for Sparc COFF LynxOS files.
- Copyright 1993 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_SYM sparclynx_coff_vec
-#define TARGET_NAME "coff-sparc-lynx"
-
-#define LYNXOS
-
-#define COFF_LONG_FILENAMES
-
-#include "coff-sparc.c"
diff --git a/contrib/gdb/bfd/cisco-core.c b/contrib/gdb/bfd/cisco-core.c
deleted file mode 100644
index a25115c..0000000
--- a/contrib/gdb/bfd/cisco-core.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/* BFD back-end for CISCO crash dumps.
-
-Copyright 1994 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-/* core_file_failing_signal returns a host signal (this probably should
- be fixed). */
-#include <signal.h>
-
-#define CRASH_INFO (0xffc)
-#define CRASH_MAGIC 0xdead1234
-
-typedef enum {
- CRASH_REASON_NOTCRASHED = 0,
- CRASH_REASON_EXCEPTION = 1,
- CRASH_REASON_CORRUPT = 2,
- } crashreason;
-
-struct crashinfo_external
-{
- char magic[4]; /* Magic number */
- char version[4]; /* Version number */
- char reason[4]; /* Crash reason */
- char cpu_vector[4]; /* CPU vector for exceptions */
- char registers[4]; /* Pointer to saved registers */
- char rambase[4]; /* Base of RAM (not in V1 crash info) */
-};
-
-struct cisco_core_struct
-{
- int sig;
-};
-
-static const bfd_target *
-cisco_core_file_p (abfd)
- bfd *abfd;
-{
- char buf[4];
- unsigned int crashinfo_offset;
- struct crashinfo_external crashinfo;
- int nread;
- unsigned int rambase;
- sec_ptr asect;
- struct stat statbuf;
-
- if (bfd_seek (abfd, CRASH_INFO, SEEK_SET) != 0)
- return NULL;
-
- nread = bfd_read (buf, 1, 4, abfd);
- if (nread != 4)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
- crashinfo_offset = bfd_get_32 (abfd, buf);
-
- if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0)
- return NULL;
-
- nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd);
- if (nread != sizeof (crashinfo))
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (bfd_stat (abfd, &statbuf) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return NULL;
- }
-
- if (bfd_get_32 (abfd, crashinfo.magic) != CRASH_MAGIC)
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- switch (bfd_get_32 (abfd, crashinfo.version))
- {
- case 0:
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- case 1:
- rambase = 0;
- break;
- default:
- case 2:
- rambase = bfd_get_32 (abfd, crashinfo.rambase);
- break;
- }
-
- /* OK, we believe you. You're a core file. */
-
- abfd->tdata.cisco_core_data =
- ((struct cisco_core_struct *)
- bfd_zmalloc (sizeof (struct cisco_core_struct)));
- if (abfd->tdata.cisco_core_data == NULL)
- return NULL;
-
- switch ((crashreason) bfd_get_32 (abfd, crashinfo.reason))
- {
- case CRASH_REASON_NOTCRASHED:
- /* Crash file probably came from write core. */
- abfd->tdata.cisco_core_data->sig = 0;
- break;
- case CRASH_REASON_CORRUPT:
- /* The crash context area was corrupt -- proceed with caution.
- We have no way of passing this information back to the caller. */
- abfd->tdata.cisco_core_data->sig = 0;
- break;
- case CRASH_REASON_EXCEPTION:
- /* Crash occured due to CPU exception. */
-
- /* This is 68k-specific; for MIPS we'll need to interpret
- cpu_vector differently based on the target configuration
- (since CISCO core files don't seem to have the processor
- encoded in them). */
-
- switch (bfd_get_32 (abfd, crashinfo.cpu_vector))
- {
- /* bus error */
- case 2 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
- /* address error */
- case 3 : abfd->tdata.cisco_core_data->sig = SIGBUS; break;
- /* illegal instruction */
- case 4 : abfd->tdata.cisco_core_data->sig = SIGILL; break;
- /* zero divide */
- case 5 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* chk instruction */
- case 6 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* trapv instruction */
- case 7 : abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* privilege violation */
- case 8 : abfd->tdata.cisco_core_data->sig = SIGSEGV; break;
- /* trace trap */
- case 9 : abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
- /* line 1010 emulator */
- case 10: abfd->tdata.cisco_core_data->sig = SIGILL; break;
- /* line 1111 emulator */
- case 11: abfd->tdata.cisco_core_data->sig = SIGILL; break;
-
- /* Coprocessor protocol violation. Using a standard MMU or FPU
- this cannot be triggered by software. Call it a SIGBUS. */
- case 13: abfd->tdata.cisco_core_data->sig = SIGBUS; break;
-
- /* interrupt */
- case 31: abfd->tdata.cisco_core_data->sig = SIGINT; break;
- /* breakpoint */
- case 33: abfd->tdata.cisco_core_data->sig = SIGTRAP; break;
-
- /* floating point err */
- case 48: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* floating point err */
- case 49: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* zero divide */
- case 50: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* underflow */
- case 51: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* operand error */
- case 52: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* overflow */
- case 53: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- /* NAN */
- case 54: abfd->tdata.cisco_core_data->sig = SIGFPE; break;
- default:
- /* "software generated"*/
- abfd->tdata.cisco_core_data->sig = SIGEMT;
- }
- break;
- default:
- /* Unknown crash reason. */
- abfd->tdata.cisco_core_data->sig = 0;
- break;
- }
-
- abfd->sections = NULL;
- abfd->section_count = 0;
-
- asect = (asection *) bfd_zmalloc (sizeof (asection));
- if (asect == NULL)
- goto error_return;
- asect->name = ".reg";
- asect->flags = SEC_HAS_CONTENTS;
- /* This can be bigger than the real size. Set it to the size of the whole
- core file. */
- asect->_raw_size = statbuf.st_size;
- asect->vma = 0;
- asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase;
- asect->next = abfd->sections;
- abfd->sections = asect;
- ++abfd->section_count;
-
- /* There is only one section containing data from the target system's RAM.
- We call it .data. */
- asect = (asection *) bfd_zmalloc (sizeof (asection));
- if (asect == NULL)
- goto error_return;
- asect->name = ".data";
- asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
- /* The size of memory is the size of the core file itself. */
- asect->_raw_size = statbuf.st_size;
- asect->vma = rambase;
- asect->filepos = 0;
- asect->next = abfd->sections;
- abfd->sections = asect;
- ++abfd->section_count;
-
- return abfd->xvec;
-
- error_return:
- {
- sec_ptr nextsect;
- for (asect = abfd->sections; asect != NULL;)
- {
- nextsect = asect->next;
- free (asect);
- asect = nextsect;
- }
- free (abfd->tdata.cisco_core_data);
- return NULL;
- }
-}
-
-char *
-cisco_core_file_failing_command (abfd)
- bfd *abfd;
-{
- return NULL;
-}
-
-int
-cisco_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return abfd->tdata.cisco_core_data->sig;
-}
-
-boolean
-cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd;
- bfd *exec_bfd;
-{
- return true;
-}
-
-const bfd_target cisco_core_vec =
- {
- "trad-core",
- bfd_target_unknown_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIAN_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* symbol prefix */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- { /* bfd_check_format */
- _bfd_dummy_target, /* unknown format */
- _bfd_dummy_target, /* object file */
- _bfd_dummy_target, /* archive */
- cisco_core_file_p /* a core file */
- },
- { /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
- { /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (cisco),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0 /* backend_data */
-};
diff --git a/contrib/gdb/bfd/coff-a29k.c b/contrib/gdb/bfd/coff-a29k.c
deleted file mode 100644
index 3ceabfb..0000000
--- a/contrib/gdb/bfd/coff-a29k.c
+++ /dev/null
@@ -1,641 +0,0 @@
-/* BFD back-end for AMD 29000 COFF binaries.
- Copyright 1990, 1991, 1992, 1993, 1994 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define A29K 1
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "coff/a29k.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-static long get_symbol_value PARAMS ((asymbol *));
-static bfd_reloc_status_type a29k_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static boolean coff_a29k_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- struct internal_reloc *, struct internal_syment *, asection **));
-static boolean coff_a29k_adjust_symndx
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
- struct internal_reloc *, boolean *));
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
-
-#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)|(~0xffffL) : (HWORD))
-
-/* Provided the symbol, returns the value reffed */
-static long
-get_symbol_value (symbol)
- asymbol *symbol;
-{
- long relocation = 0;
-
- if (bfd_is_com_section (symbol->section))
- {
- relocation = 0;
- }
- else
- {
- relocation = symbol->value +
- symbol->section->output_section->vma +
- symbol->section->output_offset;
- }
-
- return(relocation);
-}
-
-/* this function is in charge of performing all the 29k relocations */
-
-static bfd_reloc_status_type
-a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol_in;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- /* 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;
-
- unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
- bfd_byte *hit_data =addr + (bfd_byte *)(data);
-
- r_type = reloc_entry->howto->type;
-
- if (output_bfd) {
- /* Partial linking - do nothing */
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
-
- }
-
- if (symbol_in != NULL
- && bfd_is_und_section (symbol_in->section))
- {
- /* 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))
- {
- part1_consth_active = false;
- *error_message = (char *) "Missing IHCONST";
- return(bfd_reloc_dangerous);
- }
-
-
- sym_value = get_symbol_value(symbol_in);
-
- switch (r_type)
- {
- case R_IREL:
- insn = bfd_get_32(abfd, hit_data);
- /* Take the value in the field and sign extend it */
- signed_value = EXTRACT_HWORD(insn);
- signed_value = SIGN_EXTEND_HWORD(signed_value);
- signed_value <<= 2;
-
- /* See the note on the R_IREL reloc in coff_a29k_relocate_section. */
- if (signed_value == - (long) reloc_entry->address)
- signed_value = 0;
-
- 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 */
- }
- 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_overflow);
- }
- signed_value >>= 2;
- insn = INSERT_HWORD(insn, signed_value);
- bfd_put_32(abfd, insn ,hit_data);
- break;
- case R_ILOHALF:
- insn = bfd_get_32(abfd, hit_data);
- unsigned_value = EXTRACT_HWORD(insn);
- unsigned_value += sym_value + reloc_entry->addend;
- insn = INSERT_HWORD(insn, unsigned_value);
- bfd_put_32(abfd, insn, hit_data);
- break;
- case R_IHIHALF:
- insn = bfd_get_32(abfd, hit_data);
- /* 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 */
- break;
- case R_IHCONST:
- insn = bfd_get_32(abfd, hit_data);
- /* consth, part 2
- Now relocate the reference */
- if (part1_consth_active == false) {
- *error_message = (char *) "Missing IHIHALF";
- 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;
- bfd_put_32(abfd, insn, hit_data);
- break;
- case R_BYTE:
- insn = bfd_get_8(abfd, hit_data);
- unsigned_value = insn + sym_value + reloc_entry->addend;
- if (unsigned_value & 0xffffff00)
- return(bfd_reloc_overflow);
- bfd_put_8(abfd, unsigned_value, hit_data);
- break;
- case R_HWORD:
- insn = bfd_get_16(abfd, hit_data);
- unsigned_value = insn + sym_value + reloc_entry->addend;
- if (unsigned_value & 0xffff0000)
- return(bfd_reloc_overflow);
- bfd_put_16(abfd, insn, hit_data);
- break;
- case R_WORD:
- insn = bfd_get_32(abfd, hit_data);
- insn += sym_value + reloc_entry->addend;
- bfd_put_32(abfd, insn, hit_data);
- break;
- default:
- *error_message = "Unrecognized reloc";
- return (bfd_reloc_dangerous);
- }
-
-
- 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 */
-static reloc_howto_type howto_table[] =
-{
- {R_ABS, 0, 3, 32, false, 0, complain_overflow_bitfield,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, 32, true, 0, complain_overflow_signed,a29k_reloc,"IREL", true, 0xffffffff,0xffffffff, false},
- {R_IABS, 0, 3, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"IABS", true, 0xffffffff,0xffffffff, false},
- {R_ILOHALF, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"ILOHALF", true, 0x0000ffff,0x0000ffff, false},
- {R_IHIHALF, 0, 3, 16, true, 16, complain_overflow_signed, a29k_reloc,"IHIHALF", true, 0xffff0000,0xffff0000, false},
- {R_IHCONST, 0, 3, 16, true, 0, complain_overflow_signed, a29k_reloc,"IHCONST", true, 0xffff0000,0xffff0000, false},
- {R_BYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, a29k_reloc,"BYTE", true, 0x000000ff,0x000000ff, false},
- {R_HWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, a29k_reloc,"HWORD", true, 0x0000ffff,0x0000ffff, false},
- {R_WORD, 0, 2, 32, false, 0, complain_overflow_bitfield, a29k_reloc,"WORD", true, 0xffffffff,0xffffffff, false},
-};
-
-#define BADMAG(x) A29KBADMAG(x)
-
-#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
- reloc_processing(relent, reloc, symbols, abfd, section)
-
-static void
-reloc_processing (relent,reloc, symbols, abfd, section)
- arelent *relent;
- struct internal_reloc *reloc;
- asymbol **symbols;
- bfd *abfd;
- asection *section;
-{
- static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
-
- relent->address = reloc->r_vaddr;
- relent->howto = howto_table + reloc->r_type;
- if (reloc->r_type == R_IHCONST)
- {
- /* The address of an R_IHCONST should always be the address of
- the immediately preceding R_IHIHALF. relocs generated by gas
- are correct, but relocs generated by High C are different (I
- can't figure out what the address means for High C). We can
- handle both gas and High C by ignoring the address here, and
- simply reusing the address saved for R_IHIHALF. */
- if (ihihalf_vaddr == (bfd_vma) -1)
- abort ();
- relent->address = ihihalf_vaddr;
- ihihalf_vaddr = (bfd_vma) -1;
- relent->addend = reloc->r_symndx;
- relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
- }
- else
- {
- asymbol *ptr;
- relent->sym_ptr_ptr = symbols + obj_convert(abfd)[reloc->r_symndx];
-
- ptr = *(relent->sym_ptr_ptr);
-
- if (ptr
- && bfd_asymbol_bfd(ptr) == abfd
-
- && ((ptr->flags & BSF_OLD_COMMON)== 0))
- {
- relent->addend = 0;
- }
- else
- {
- relent->addend = 0;
- }
- relent->address-= section->vma;
- if (reloc->r_type == R_IHIHALF)
- ihihalf_vaddr = relent->address;
- else if (ihihalf_vaddr != (bfd_vma) -1)
- abort ();
- }
-}
-
-/* The reloc processing routine for the optimized COFF linker. */
-
-static boolean
-coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, syms, sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- struct internal_reloc *relocs;
- struct internal_syment *syms;
- asection **sections;
-{
- struct internal_reloc *rel;
- struct internal_reloc *relend;
- boolean hihalf;
- bfd_vma hihalf_val;
-
- /* If we are performing a relocateable link, we don't need to do a
- thing. The caller will take care of adjusting the reloc
- addresses and symbol indices. */
- if (info->relocateable)
- return true;
-
- hihalf = false;
- hihalf_val = 0;
-
- rel = relocs;
- relend = rel + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- long symndx;
- bfd_byte *loc;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- asection *sec;
- bfd_vma val;
- boolean overflow;
- unsigned long insn;
- long signed_value;
- unsigned long unsigned_value;
- bfd_reloc_status_type rstat;
-
- symndx = rel->r_symndx;
- loc = contents + rel->r_vaddr - input_section->vma;
-
- if (symndx == -1)
- h = NULL;
- else
- h = obj_coff_sym_hashes (input_bfd)[symndx];
-
- sym = NULL;
- sec = NULL;
- val = 0;
-
- /* An R_IHCONST reloc does not have a symbol. Instead, the
- symbol index is an addend. R_IHCONST is always used in
- conjunction with R_IHHALF. */
- if (rel->r_type != R_IHCONST)
- {
- if (h == NULL)
- {
- if (symndx == -1)
- sec = bfd_abs_section_ptr;
- else
- {
- sym = syms + symndx;
- sec = sections[symndx];
- val = (sec->output_section->vma
- + sec->output_offset
- + sym->n_value
- - sec->vma);
- }
- }
- else
- {
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- val = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
-
- if (hihalf)
- {
- if (! ((*info->callbacks->reloc_dangerous)
- (info, "missing IHCONST reloc", input_bfd,
- input_section, rel->r_vaddr - input_section->vma)))
- return false;
- hihalf = false;
- }
- }
-
- overflow = false;
-
- switch (rel->r_type)
- {
- default:
- bfd_set_error (bfd_error_bad_value);
- return false;
-
- case R_IREL:
- insn = bfd_get_32 (input_bfd, loc);
-
- /* Extract the addend. */
- signed_value = EXTRACT_HWORD (insn);
- signed_value = SIGN_EXTEND_HWORD (signed_value);
- signed_value <<= 2;
-
- /* Unfortunately, there are two different versions of COFF
- a29k. In the original AMD version, the value stored in
- the field for the R_IREL reloc is a simple addend. In
- the GNU version, the value is the negative of the address
- of the reloc within section. We try to cope here by
- assuming the AMD version, unless the addend is exactly
- the negative of the address; in the latter case we assume
- the GNU version. This means that something like
- .text
- nop
- jmp i-4
- will fail, because the addend of -4 will happen to equal
- the negative of the address within the section. The
- compiler will never generate code like this.
-
- At some point in the future we may want to take out this
- check. */
-
- if (signed_value == - (long) (rel->r_vaddr - input_section->vma))
- signed_value = 0;
-
- /* Determine the destination of the jump. */
- signed_value += val;
-
- if ((signed_value & ~0x3ffff) == 0)
- {
- /* We can use an absolute jump. */
- insn |= (1 << 24);
- }
- else
- {
- /* Make the destination PC relative. */
- signed_value -= (input_section->output_section->vma
- + input_section->output_offset
- + (rel->r_vaddr - input_section->vma));
- if (signed_value > 0x1ffff || signed_value < - 0x20000)
- {
- overflow = true;
- signed_value = 0;
- }
- }
-
- /* Put the adjusted value back into the instruction. */
- signed_value >>= 2;
- insn = INSERT_HWORD (insn, signed_value);
-
- bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
-
- break;
-
- case R_ILOHALF:
- insn = bfd_get_32 (input_bfd, loc);
- unsigned_value = EXTRACT_HWORD (insn);
- unsigned_value += val;
- insn = INSERT_HWORD (insn, unsigned_value);
- bfd_put_32 (input_bfd, insn, loc);
- break;
-
- case R_IHIHALF:
- /* Save the value for the R_IHCONST reloc. */
- hihalf = true;
- hihalf_val = val;
- break;
-
- case R_IHCONST:
- if (! hihalf)
- {
- if (! ((*info->callbacks->reloc_dangerous)
- (info, "missing IHIHALF reloc", input_bfd,
- input_section, rel->r_vaddr - input_section->vma)))
- return false;
- hihalf_val = 0;
- }
-
- insn = bfd_get_32 (input_bfd, loc);
- unsigned_value = rel->r_symndx + hihalf_val;
- unsigned_value >>= 16;
- insn = INSERT_HWORD (insn, unsigned_value);
- bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
-
- hihalf = false;
-
- break;
-
- case R_BYTE:
- case R_HWORD:
- case R_WORD:
- rstat = _bfd_relocate_contents (howto_table + rel->r_type,
- input_bfd, val, loc);
- if (rstat == bfd_reloc_overflow)
- overflow = true;
- else if (rstat != bfd_reloc_ok)
- abort ();
- break;
- }
-
- if (overflow)
- {
- const char *name;
- char buf[SYMNMLEN + 1];
-
- if (symndx == -1)
- name = "*ABS*";
- else if (h != NULL)
- name = h->root.root.string;
- else if (sym == NULL)
- name = "*unknown*";
- else if (sym->_n._n_n._n_zeroes == 0
- && sym->_n._n_n._n_offset != 0)
- name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
- else
- {
- strncpy (buf, sym->_n._n_name, SYMNMLEN);
- buf[SYMNMLEN] = '\0';
- name = buf;
- }
-
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto_table[rel->r_type].name, (bfd_vma) 0,
- input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
-
- return true;
-}
-
-#define coff_relocate_section coff_a29k_relocate_section
-
-/* We don't want to change the symndx of a R_IHCONST reloc, since it
- is actually an addend, not a symbol index at all. */
-
-/*ARGSUSED*/
-static boolean
-coff_a29k_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
- bfd *obfd;
- struct bfd_link_info *info;
- bfd *ibfd;
- asection *sec;
- struct internal_reloc *irel;
- boolean *adjustedp;
-{
- if (irel->r_type == R_IHCONST)
- *adjustedp = true;
- else
- *adjustedp = false;
- return true;
-}
-
-#define coff_adjust_symndx coff_a29k_adjust_symndx
-
-#include "coffcode.h"
-
-const bfd_target a29kcoff_big_vec =
-{
- "coff-a29k-big", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC /* section flags */
- | SEC_LOAD | SEC_RELOC
- | SEC_READONLY ),
- '_', /* leading underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
- /* hdrs */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_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
- },
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE
- };
diff --git a/contrib/gdb/bfd/coff-alpha.c b/contrib/gdb/bfd/coff-alpha.c
deleted file mode 100644
index b14f3ef..0000000
--- a/contrib/gdb/bfd/coff-alpha.c
+++ /dev/null
@@ -1,2390 +0,0 @@
-/* BFD back-end for ALPHA Extended-Coff files.
- Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
- Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
- Ian Lance Taylor <ian@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "coff/internal.h"
-#include "coff/sym.h"
-#include "coff/symconst.h"
-#include "coff/ecoff.h"
-#include "coff/alpha.h"
-#include "aout/ar.h"
-#include "libcoff.h"
-#include "libecoff.h"
-
-/* Prototypes for static functions. */
-
-static const bfd_target *alpha_ecoff_object_p PARAMS ((bfd *));
-static boolean alpha_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr));
-static PTR alpha_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
-static void alpha_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
- struct internal_reloc *));
-static void alpha_ecoff_swap_reloc_out PARAMS ((bfd *,
- const struct internal_reloc *,
- PTR));
-static void alpha_adjust_reloc_in PARAMS ((bfd *,
- const struct internal_reloc *,
- arelent *));
-static void alpha_adjust_reloc_out PARAMS ((bfd *, const arelent *,
- struct internal_reloc *));
-static bfd_byte *alpha_ecoff_get_relocated_section_contents
- PARAMS ((bfd *abfd, struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *data, boolean relocateable, asymbol **symbols));
-static bfd_vma alpha_convert_external_reloc
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, struct external_reloc *,
- struct ecoff_link_hash_entry *));
-static boolean alpha_relocate_section PARAMS ((bfd *, struct bfd_link_info *,
- bfd *, asection *,
- bfd_byte *, PTR));
-static boolean alpha_adjust_headers
- PARAMS ((bfd *, struct internal_filehdr *, struct internal_aouthdr *));
-static PTR alpha_ecoff_read_ar_hdr PARAMS ((bfd *));
-static bfd *alpha_ecoff_get_elt_at_filepos PARAMS ((bfd *, file_ptr));
-static bfd *alpha_ecoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
-static bfd *alpha_ecoff_get_elt_at_index PARAMS ((bfd *, symindex));
-
-/* ECOFF has COFF sections, but the debugging information is stored in
- a completely different format. ECOFF targets use some of the
- swapping routines from coffswap.h, and some of the generic COFF
- routines in coffgen.c, but, unlike the real COFF targets, do not
- use coffcode.h itself.
-
- Get the generic COFF swapping routines, except for the reloc,
- symbol, and lineno ones. Give them ecoff names. Define some
- accessor macros for the large sizes used for Alpha ECOFF. */
-
-#define GET_FILEHDR_SYMPTR bfd_h_get_64
-#define PUT_FILEHDR_SYMPTR bfd_h_put_64
-#define GET_AOUTHDR_TSIZE bfd_h_get_64
-#define PUT_AOUTHDR_TSIZE bfd_h_put_64
-#define GET_AOUTHDR_DSIZE bfd_h_get_64
-#define PUT_AOUTHDR_DSIZE bfd_h_put_64
-#define GET_AOUTHDR_BSIZE bfd_h_get_64
-#define PUT_AOUTHDR_BSIZE bfd_h_put_64
-#define GET_AOUTHDR_ENTRY bfd_h_get_64
-#define PUT_AOUTHDR_ENTRY bfd_h_put_64
-#define GET_AOUTHDR_TEXT_START bfd_h_get_64
-#define PUT_AOUTHDR_TEXT_START bfd_h_put_64
-#define GET_AOUTHDR_DATA_START bfd_h_get_64
-#define PUT_AOUTHDR_DATA_START bfd_h_put_64
-#define GET_SCNHDR_PADDR bfd_h_get_64
-#define PUT_SCNHDR_PADDR bfd_h_put_64
-#define GET_SCNHDR_VADDR bfd_h_get_64
-#define PUT_SCNHDR_VADDR bfd_h_put_64
-#define GET_SCNHDR_SIZE bfd_h_get_64
-#define PUT_SCNHDR_SIZE bfd_h_put_64
-#define GET_SCNHDR_SCNPTR bfd_h_get_64
-#define PUT_SCNHDR_SCNPTR bfd_h_put_64
-#define GET_SCNHDR_RELPTR bfd_h_get_64
-#define PUT_SCNHDR_RELPTR bfd_h_put_64
-#define GET_SCNHDR_LNNOPTR bfd_h_get_64
-#define PUT_SCNHDR_LNNOPTR bfd_h_put_64
-
-#define ALPHAECOFF
-
-#define NO_COFF_RELOCS
-#define NO_COFF_SYMBOLS
-#define NO_COFF_LINENOS
-#define coff_swap_filehdr_in alpha_ecoff_swap_filehdr_in
-#define coff_swap_filehdr_out alpha_ecoff_swap_filehdr_out
-#define coff_swap_aouthdr_in alpha_ecoff_swap_aouthdr_in
-#define coff_swap_aouthdr_out alpha_ecoff_swap_aouthdr_out
-#define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
-#define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
-#include "coffswap.h"
-
-/* Get the ECOFF swapping routines. */
-#define ECOFF_64
-#include "ecoffswap.h"
-
-/* How to process the various reloc types. */
-
-static bfd_reloc_status_type
-reloc_nil PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-
-static bfd_reloc_status_type
-reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message)
- bfd *abfd;
- arelent *reloc;
- asymbol *sym;
- PTR data;
- asection *sec;
- bfd *output_bfd;
- char **error_message;
-{
- return bfd_reloc_ok;
-}
-
-/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
- from smaller values. Start with zero, widen, *then* decrement. */
-#define MINUS_ONE (((bfd_vma)0) - 1)
-
-static reloc_howto_type alpha_howto_table[] =
-{
- /* Reloc type 0 is ignored by itself. However, it appears after a
- GPDISP reloc to identify the location where the low order 16 bits
- of the gp register are loaded. */
- HOWTO (ALPHA_R_IGNORE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- reloc_nil, /* special_function */
- "IGNORE", /* name */
- true, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- true), /* pcrel_offset */
-
- /* A 32 bit reference to a symbol. */
- HOWTO (ALPHA_R_REFLONG, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "REFLONG", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 64 bit reference to a symbol. */
- HOWTO (ALPHA_R_REFQUAD, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "REFQUAD", /* name */
- true, /* partial_inplace */
- MINUS_ONE, /* src_mask */
- MINUS_ONE, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 32 bit GP relative offset. This is just like REFLONG except
- that when the value is used the value of the gp register will be
- added in. */
- HOWTO (ALPHA_R_GPREL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "GPREL32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Used for an instruction that refers to memory off the GP
- register. The offset is 16 bits of the 32 bit instruction. This
- reloc always seems to be against the .lita section. */
- HOWTO (ALPHA_R_LITERAL, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "LITERAL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* This reloc only appears immediately following a LITERAL reloc.
- It identifies a use of the literal. It seems that the linker can
- use this to eliminate a portion of the .lita section. The symbol
- index is special: 1 means the literal address is in the base
- register of a memory format instruction; 2 means the literal
- address is in the byte offset register of a byte-manipulation
- instruction; 3 means the literal address is in the target
- register of a jsr instruction. This does not actually do any
- relocation. */
- HOWTO (ALPHA_R_LITUSE, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- reloc_nil, /* special_function */
- "LITUSE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Load the gp register. This is always used for a ldah instruction
- which loads the upper 16 bits of the gp register. The next reloc
- will be an IGNORE reloc which identifies the location of the lda
- instruction which loads the lower 16 bits. The symbol index of
- the GPDISP instruction appears to actually be the number of bytes
- between the ldah and lda instructions. This gives two different
- ways to determine where the lda instruction is; I don't know why
- both are used. The value to use for the relocation is the
- difference between the GP value and the current location; the
- load will always be done against a register holding the current
- address. */
- HOWTO (ALPHA_R_GPDISP, /* type */
- 16, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- reloc_nil, /* special_function */
- "GPDISP", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* A 21 bit branch. The native assembler generates these for
- branches within the text segment, and also fills in the PC
- relative offset in the instruction. */
- HOWTO (ALPHA_R_BRADDR, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 21, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "BRADDR", /* name */
- true, /* partial_inplace */
- 0x1fffff, /* src_mask */
- 0x1fffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A hint for a jump to a register. */
- HOWTO (ALPHA_R_HINT, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 14, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "HINT", /* name */
- true, /* partial_inplace */
- 0x3fff, /* src_mask */
- 0x3fff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "SREL16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "SREL32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 64 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL64, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "SREL64", /* name */
- true, /* partial_inplace */
- MINUS_ONE, /* src_mask */
- MINUS_ONE, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Push a value on the reloc evaluation stack. */
- HOWTO (ALPHA_R_OP_PUSH, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "OP_PUSH", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Store the value from the stack at the given address. Store it in
- a bitfield of size r_size starting at bit position r_offset. */
- HOWTO (ALPHA_R_OP_STORE, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "OP_STORE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- MINUS_ONE, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Subtract the reloc address from the value on the top of the
- relocation stack. */
- HOWTO (ALPHA_R_OP_PSUB, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "OP_PSUB", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Shift the value on the top of the relocation stack right by the
- given value. */
- HOWTO (ALPHA_R_OP_PRSHIFT, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "OP_PRSHIFT", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Adjust the GP value for a new range in the object file. */
- HOWTO (ALPHA_R_GPVALUE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "GPVALUE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false) /* pcrel_offset */
-};
-
-/* Recognize an Alpha ECOFF file. */
-
-static const bfd_target *
-alpha_ecoff_object_p (abfd)
- bfd *abfd;
-{
- static const bfd_target *ret;
-
- ret = coff_object_p (abfd);
-
- if (ret != NULL)
- {
- asection *sec;
-
- /* Alpha ECOFF has a .pdata section. The lnnoptr field of the
- .pdata section is the number of entries it contains. Each
- entry takes up 8 bytes. The number of entries is required
- since the section is aligned to a 16 byte boundary. When we
- link .pdata sections together, we do not want to include the
- alignment bytes. We handle this on input by faking the size
- of the .pdata section to remove the unwanted alignment bytes.
- On output we will set the lnnoptr field and force the
- alignment. */
- sec = bfd_get_section_by_name (abfd, _PDATA);
- if (sec != (asection *) NULL)
- {
- bfd_size_type size;
-
- size = sec->line_filepos * 8;
- BFD_ASSERT (size == bfd_section_size (abfd, sec)
- || size + 8 == bfd_section_size (abfd, sec));
- if (! bfd_set_section_size (abfd, sec, size))
- return NULL;
- }
- }
-
- return ret;
-}
-
-/* See whether the magic number matches. */
-
-static boolean
-alpha_ecoff_bad_format_hook (abfd, filehdr)
- bfd *abfd;
- PTR filehdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
-
- if (ALPHA_ECOFF_BADMAG (*internal_f))
- return false;
-
- return true;
-}
-
-/* This is a hook called by coff_real_object_p to create any backend
- specific information. */
-
-static PTR
-alpha_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
- bfd *abfd;
- PTR filehdr;
- PTR aouthdr;
-{
- PTR ecoff;
-
- ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr);
-
- if (ecoff != NULL)
- {
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
-
- /* Set additional BFD flags according to the object type from the
- machine specific file header flags. */
- switch (internal_f->f_flags & F_ALPHA_OBJECT_TYPE_MASK)
- {
- case F_ALPHA_SHARABLE:
- abfd->flags |= DYNAMIC;
- break;
- case F_ALPHA_CALL_SHARED:
- /* Always executable if using shared libraries as the run time
- loader might resolve undefined references. */
- abfd->flags |= (DYNAMIC | EXEC_P);
- break;
- }
- }
- return ecoff;
-}
-
-/* Reloc handling. */
-
-/* Swap a reloc in. */
-
-static void
-alpha_ecoff_swap_reloc_in (abfd, ext_ptr, intern)
- bfd *abfd;
- PTR ext_ptr;
- struct internal_reloc *intern;
-{
- const RELOC *ext = (RELOC *) ext_ptr;
-
- intern->r_vaddr = bfd_h_get_64 (abfd, (bfd_byte *) ext->r_vaddr);
- intern->r_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext->r_symndx);
-
- BFD_ASSERT (bfd_header_little_endian (abfd));
-
- intern->r_type = ((ext->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
- >> RELOC_BITS0_TYPE_SH_LITTLE);
- intern->r_extern = (ext->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
- intern->r_offset = ((ext->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
- >> RELOC_BITS1_OFFSET_SH_LITTLE);
- /* Ignored the reserved bits. */
- intern->r_size = ((ext->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
- >> RELOC_BITS3_SIZE_SH_LITTLE);
-
- if (intern->r_type == ALPHA_R_LITUSE
- || intern->r_type == ALPHA_R_GPDISP)
- {
- /* Handle the LITUSE and GPDISP relocs specially. Its symndx
- value is not actually a symbol index, but is instead a
- special code. We put the code in the r_size field, and
- clobber the symndx. */
- if (intern->r_size != 0)
- abort ();
- intern->r_size = intern->r_symndx;
- intern->r_symndx = RELOC_SECTION_NONE;
- }
- else if (intern->r_type == ALPHA_R_IGNORE)
- {
- /* The IGNORE reloc generally follows a GPDISP reloc, and is
- against the .lita section. The section is irrelevant. */
- if (! intern->r_extern &&
- intern->r_symndx == RELOC_SECTION_ABS)
- abort ();
- if (! intern->r_extern && intern->r_symndx == RELOC_SECTION_LITA)
- intern->r_symndx = RELOC_SECTION_ABS;
- }
-}
-
-/* Swap a reloc out. */
-
-static void
-alpha_ecoff_swap_reloc_out (abfd, intern, dst)
- bfd *abfd;
- const struct internal_reloc *intern;
- PTR dst;
-{
- RELOC *ext = (RELOC *) dst;
- long symndx;
- unsigned char size;
-
- /* Undo the hackery done in swap_reloc_in. */
- if (intern->r_type == ALPHA_R_LITUSE
- || intern->r_type == ALPHA_R_GPDISP)
- {
- symndx = intern->r_size;
- size = 0;
- }
- else if (intern->r_type == ALPHA_R_IGNORE
- && ! intern->r_extern
- && intern->r_symndx == RELOC_SECTION_ABS)
- {
- symndx = RELOC_SECTION_LITA;
- size = intern->r_size;
- }
- else
- {
- symndx = intern->r_symndx;
- size = intern->r_size;
- }
-
- BFD_ASSERT (intern->r_extern
- || (intern->r_symndx >= 0 && intern->r_symndx <= 14));
-
- bfd_h_put_64 (abfd, intern->r_vaddr, (bfd_byte *) ext->r_vaddr);
- bfd_h_put_32 (abfd, symndx, (bfd_byte *) ext->r_symndx);
-
- BFD_ASSERT (bfd_header_little_endian (abfd));
-
- ext->r_bits[0] = ((intern->r_type << RELOC_BITS0_TYPE_SH_LITTLE)
- & RELOC_BITS0_TYPE_LITTLE);
- ext->r_bits[1] = ((intern->r_extern ? RELOC_BITS1_EXTERN_LITTLE : 0)
- | ((intern->r_offset << RELOC_BITS1_OFFSET_SH_LITTLE)
- & RELOC_BITS1_OFFSET_LITTLE));
- ext->r_bits[2] = 0;
- ext->r_bits[3] = ((size << RELOC_BITS3_SIZE_SH_LITTLE)
- & RELOC_BITS3_SIZE_LITTLE);
-}
-
-/* Finish canonicalizing a reloc. Part of this is generic to all
- ECOFF targets, and that part is in ecoff.c. The rest is done in
- this backend routine. It must fill in the howto field. */
-
-static void
-alpha_adjust_reloc_in (abfd, intern, rptr)
- bfd *abfd;
- const struct internal_reloc *intern;
- arelent *rptr;
-{
- if (intern->r_type > ALPHA_R_GPVALUE)
- abort ();
-
- switch (intern->r_type)
- {
- case ALPHA_R_BRADDR:
- case ALPHA_R_SREL16:
- case ALPHA_R_SREL32:
- case ALPHA_R_SREL64:
- /* The PC relative relocs do not seem to use the section VMA as
- a negative addend. */
- rptr->addend = 0;
- break;
-
- case ALPHA_R_GPREL32:
- case ALPHA_R_LITERAL:
- /* Copy the gp value for this object file into the addend, to
- ensure that we are not confused by the linker. */
- if (! intern->r_extern)
- rptr->addend += ecoff_data (abfd)->gp;
- break;
-
- case ALPHA_R_LITUSE:
- case ALPHA_R_GPDISP:
- /* The LITUSE and GPDISP relocs do not use a symbol, or an
- addend, but they do use a special code. Put this code in the
- addend field. */
- rptr->addend = intern->r_size;
- break;
-
- case ALPHA_R_OP_STORE:
- /* The STORE reloc needs the size and offset fields. We store
- them in the addend. */
- BFD_ASSERT (intern->r_offset <= 256 && intern->r_size <= 256);
- rptr->addend = (intern->r_offset << 8) + intern->r_size;
- break;
-
- case ALPHA_R_OP_PUSH:
- case ALPHA_R_OP_PSUB:
- case ALPHA_R_OP_PRSHIFT:
- /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
- address. I believe that the address supplied is really an
- addend. */
- rptr->addend = intern->r_vaddr;
- break;
-
- case ALPHA_R_GPVALUE:
- /* Set the addend field to the new GP value. */
- rptr->addend = intern->r_symndx + ecoff_data (abfd)->gp;
- break;
-
- case ALPHA_R_IGNORE:
- /* If the type is ALPHA_R_IGNORE, make sure this is a reference
- to the absolute section so that the reloc is ignored. For
- some reason the address of this reloc type is not adjusted by
- the section vma. We record the gp value for this object file
- here, for convenience when doing the GPDISP relocation. */
- rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rptr->address = intern->r_vaddr;
- rptr->addend = ecoff_data (abfd)->gp;
- break;
-
- default:
- break;
- }
-
- rptr->howto = &alpha_howto_table[intern->r_type];
-}
-
-/* When writing out a reloc we need to pull some values back out of
- the addend field into the reloc. This is roughly the reverse of
- alpha_adjust_reloc_in, except that there are several changes we do
- not need to undo. */
-
-static void
-alpha_adjust_reloc_out (abfd, rel, intern)
- bfd *abfd;
- const arelent *rel;
- struct internal_reloc *intern;
-{
- switch (intern->r_type)
- {
- case ALPHA_R_LITUSE:
- case ALPHA_R_GPDISP:
- intern->r_size = rel->addend;
- break;
-
- case ALPHA_R_OP_STORE:
- intern->r_size = rel->addend & 0xff;
- intern->r_offset = (rel->addend >> 8) & 0xff;
- break;
-
- case ALPHA_R_OP_PUSH:
- case ALPHA_R_OP_PSUB:
- case ALPHA_R_OP_PRSHIFT:
- intern->r_vaddr = rel->addend;
- break;
-
- case ALPHA_R_IGNORE:
- intern->r_vaddr = rel->address;
- break;
-
- default:
- break;
- }
-}
-
-/* The size of the stack for the relocation evaluator. */
-#define RELOC_STACKSIZE (10)
-
-/* Alpha ECOFF relocs have a built in expression evaluator as well as
- other interdependencies. Rather than use a bunch of special
- functions and global variables, we use a single routine to do all
- the relocation for a section. I haven't yet worked out how the
- assembler is going to handle this. */
-
-static bfd_byte *
-alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
- data, relocateable, symbols)
- bfd *abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- bfd_byte *data;
- boolean relocateable;
- asymbol **symbols;
-{
- bfd *input_bfd = link_order->u.indirect.section->owner;
- asection *input_section = link_order->u.indirect.section;
- long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
- arelent **reloc_vector = NULL;
- long reloc_count;
- bfd *output_bfd = relocateable ? abfd : (bfd *) NULL;
- bfd_vma gp;
- boolean gp_undefined;
- bfd_vma stack[RELOC_STACKSIZE];
- int tos = 0;
-
- if (reloc_size < 0)
- goto error_return;
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
- if (reloc_vector == NULL && reloc_size != 0)
- goto error_return;
-
- if (! bfd_get_section_contents (input_bfd, input_section, data,
- (file_ptr) 0, input_section->_raw_size))
- goto error_return;
-
- /* The section size is not going to change. */
- input_section->_cooked_size = input_section->_raw_size;
- input_section->reloc_done = true;
-
- reloc_count = bfd_canonicalize_reloc (input_bfd, input_section,
- reloc_vector, symbols);
- if (reloc_count < 0)
- goto error_return;
- if (reloc_count == 0)
- goto successful_return;
-
- /* Get the GP value for the output BFD. */
- gp_undefined = false;
- gp = _bfd_get_gp_value (abfd);
- if (gp == 0)
- {
- if (relocateable != false)
- {
- asection *sec;
- bfd_vma lo;
-
- /* Make up a value. */
- lo = (bfd_vma) -1;
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
- {
- if (sec->vma < lo
- && (strcmp (sec->name, ".sbss") == 0
- || strcmp (sec->name, ".sdata") == 0
- || strcmp (sec->name, ".lit4") == 0
- || strcmp (sec->name, ".lit8") == 0
- || strcmp (sec->name, ".lita") == 0))
- lo = sec->vma;
- }
- gp = lo + 0x8000;
- _bfd_set_gp_value (abfd, gp);
- }
- else
- {
- struct bfd_link_hash_entry *h;
-
- h = bfd_link_hash_lookup (link_info->hash, "_gp", false, false,
- true);
- if (h == (struct bfd_link_hash_entry *) NULL
- || h->type != bfd_link_hash_defined)
- gp_undefined = true;
- else
- {
- gp = (h->u.def.value
- + h->u.def.section->output_section->vma
- + h->u.def.section->output_offset);
- _bfd_set_gp_value (abfd, gp);
- }
- }
- }
-
- for (; *reloc_vector != (arelent *) NULL; reloc_vector++)
- {
- arelent *rel;
- bfd_reloc_status_type r;
- char *err;
-
- rel = *reloc_vector;
- r = bfd_reloc_ok;
- switch (rel->howto->type)
- {
- case ALPHA_R_IGNORE:
- rel->address += input_section->output_offset;
- break;
-
- case ALPHA_R_REFLONG:
- case ALPHA_R_REFQUAD:
- case ALPHA_R_BRADDR:
- case ALPHA_R_HINT:
- case ALPHA_R_SREL16:
- case ALPHA_R_SREL32:
- case ALPHA_R_SREL64:
- if (relocateable
- && ((*rel->sym_ptr_ptr)->flags & BSF_SECTION_SYM) == 0)
- {
- rel->address += input_section->output_offset;
- break;
- }
- r = bfd_perform_relocation (input_bfd, rel, data, input_section,
- output_bfd, &err);
- break;
-
- case ALPHA_R_GPREL32:
- /* This relocation is used in a switch table. It is a 32
- bit offset from the current GP value. We must adjust it
- by the different between the original GP value and the
- current GP value. The original GP value is stored in the
- addend. We adjust the addend and let
- bfd_perform_relocation finish the job. */
- rel->addend -= gp;
- r = bfd_perform_relocation (input_bfd, rel, data, input_section,
- output_bfd, &err);
- if (r == bfd_reloc_ok && gp_undefined)
- {
- r = bfd_reloc_dangerous;
- err = (char *) "GP relative relocation used when GP not defined";
- }
- break;
-
- case ALPHA_R_LITERAL:
- /* This is a reference to a literal value, generally
- (always?) in the .lita section. This is a 16 bit GP
- relative relocation. Sometimes the subsequent reloc is a
- LITUSE reloc, which indicates how this reloc is used.
- This sometimes permits rewriting the two instructions
- referred to by the LITERAL and the LITUSE into different
- instructions which do not refer to .lita. This can save
- a memory reference, and permits removing a value from
- .lita thus saving GP relative space.
-
- We do not these optimizations. To do them we would need
- to arrange to link the .lita section first, so that by
- the time we got here we would know the final values to
- use. This would not be particularly difficult, but it is
- not currently implemented. */
-
- {
- unsigned long insn;
-
- /* I believe that the LITERAL reloc will only apply to a
- ldq or ldl instruction, so check my assumption. */
- insn = bfd_get_32 (input_bfd, data + rel->address);
- BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
- || ((insn >> 26) & 0x3f) == 0x28);
-
- rel->addend -= gp;
- r = bfd_perform_relocation (input_bfd, rel, data, input_section,
- output_bfd, &err);
- if (r == bfd_reloc_ok && gp_undefined)
- {
- r = bfd_reloc_dangerous;
- err =
- (char *) "GP relative relocation used when GP not defined";
- }
- }
- break;
-
- case ALPHA_R_LITUSE:
- /* See ALPHA_R_LITERAL above for the uses of this reloc. It
- does not cause anything to happen, itself. */
- rel->address += input_section->output_offset;
- break;
-
- case ALPHA_R_GPDISP:
- /* This marks the ldah of an ldah/lda pair which loads the
- gp register with the difference of the gp value and the
- current location. The second of the pair is r_size bytes
- ahead; it used to be marked with an ALPHA_R_IGNORE reloc,
- but that no longer happens in OSF/1 3.2. */
- {
- unsigned long insn1, insn2;
- bfd_vma addend;
-
- /* Get the two instructions. */
- insn1 = bfd_get_32 (input_bfd, data + rel->address);
- insn2 = bfd_get_32 (input_bfd, data + rel->address + rel->addend);
-
- BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
- BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
-
- /* Get the existing addend. We must account for the sign
- extension done by lda and ldah. */
- addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff);
- if (insn1 & 0x8000)
- {
- addend -= 0x80000000;
- addend -= 0x80000000;
- }
- if (insn2 & 0x8000)
- addend -= 0x10000;
-
- /* The existing addend includes the different between the
- gp of the input BFD and the address in the input BFD.
- Subtract this out. */
- addend -= (ecoff_data (input_bfd)->gp
- - (input_section->vma + rel->address));
-
- /* Now add in the final gp value, and subtract out the
- final address. */
- addend += (gp
- - (input_section->output_section->vma
- + input_section->output_offset
- + rel->address));
-
- /* Change the instructions, accounting for the sign
- extension, and write them out. */
- if (addend & 0x8000)
- addend += 0x10000;
- insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff);
- insn2 = (insn2 & 0xffff0000) | (addend & 0xffff);
-
- bfd_put_32 (input_bfd, (bfd_vma) insn1, data + rel->address);
- bfd_put_32 (input_bfd, (bfd_vma) insn2,
- data + rel->address + rel->addend);
-
- rel->address += input_section->output_offset;
- }
- break;
-
- case ALPHA_R_OP_PUSH:
- /* Push a value on the reloc evaluation stack. */
- {
- asymbol *symbol;
- bfd_vma relocation;
-
- if (relocateable)
- {
- rel->address += input_section->output_offset;
- break;
- }
-
- /* Figure out the relocation of this symbol. */
- symbol = *rel->sym_ptr_ptr;
-
- if (bfd_is_und_section (symbol->section))
- r = bfd_reloc_undefined;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += rel->addend;
-
- if (tos >= RELOC_STACKSIZE)
- abort ();
-
- stack[tos++] = relocation;
- }
- break;
-
- case ALPHA_R_OP_STORE:
- /* Store a value from the reloc stack into a bitfield. */
- {
- bfd_vma val;
- int offset, size;
-
- if (relocateable)
- {
- rel->address += input_section->output_offset;
- break;
- }
-
- if (tos == 0)
- abort ();
-
- /* The offset and size for this reloc are encoded into the
- addend field by alpha_adjust_reloc_in. */
- offset = (rel->addend >> 8) & 0xff;
- size = rel->addend & 0xff;
-
- val = bfd_get_64 (abfd, data + rel->address);
- val &=~ (((1 << size) - 1) << offset);
- val |= (stack[--tos] & ((1 << size) - 1)) << offset;
- bfd_put_64 (abfd, val, data + rel->address);
- }
- break;
-
- case ALPHA_R_OP_PSUB:
- /* Subtract a value from the top of the stack. */
- {
- asymbol *symbol;
- bfd_vma relocation;
-
- if (relocateable)
- {
- rel->address += input_section->output_offset;
- break;
- }
-
- /* Figure out the relocation of this symbol. */
- symbol = *rel->sym_ptr_ptr;
-
- if (bfd_is_und_section (symbol->section))
- r = bfd_reloc_undefined;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += rel->addend;
-
- if (tos == 0)
- abort ();
-
- stack[tos - 1] -= relocation;
- }
- break;
-
- case ALPHA_R_OP_PRSHIFT:
- /* Shift the value on the top of the stack. */
- {
- asymbol *symbol;
- bfd_vma relocation;
-
- if (relocateable)
- {
- rel->address += input_section->output_offset;
- break;
- }
-
- /* Figure out the relocation of this symbol. */
- symbol = *rel->sym_ptr_ptr;
-
- if (bfd_is_und_section (symbol->section))
- r = bfd_reloc_undefined;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += rel->addend;
-
- if (tos == 0)
- abort ();
-
- stack[tos - 1] >>= relocation;
- }
- break;
-
- case ALPHA_R_GPVALUE:
- /* I really don't know if this does the right thing. */
- gp = rel->addend;
- gp_undefined = false;
- break;
-
- default:
- abort ();
- }
-
- if (relocateable)
- {
- asection *os = input_section->output_section;
-
- /* A partial link, so keep the relocs. */
- os->orelocation[os->reloc_count] = rel;
- os->reloc_count++;
- }
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- case bfd_reloc_undefined:
- if (! ((*link_info->callbacks->undefined_symbol)
- (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
- input_bfd, input_section, rel->address)))
- goto error_return;
- break;
- case bfd_reloc_dangerous:
- if (! ((*link_info->callbacks->reloc_dangerous)
- (link_info, err, input_bfd, input_section,
- rel->address)))
- goto error_return;
- break;
- case bfd_reloc_overflow:
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
- rel->howto->name, rel->addend, input_bfd,
- input_section, rel->address)))
- goto error_return;
- break;
- case bfd_reloc_outofrange:
- default:
- abort ();
- break;
- }
- }
- }
-
- if (tos != 0)
- abort ();
-
- successful_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
- return data;
-
- error_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
- return NULL;
-}
-
-/* Get the howto structure for a generic reloc type. */
-
-static reloc_howto_type *
-alpha_bfd_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- int alpha_type;
-
- switch (code)
- {
- case BFD_RELOC_32:
- alpha_type = ALPHA_R_REFLONG;
- break;
- case BFD_RELOC_64:
- case BFD_RELOC_CTOR:
- alpha_type = ALPHA_R_REFQUAD;
- break;
- case BFD_RELOC_GPREL32:
- alpha_type = ALPHA_R_GPREL32;
- break;
- case BFD_RELOC_ALPHA_LITERAL:
- alpha_type = ALPHA_R_LITERAL;
- break;
- case BFD_RELOC_ALPHA_LITUSE:
- alpha_type = ALPHA_R_LITUSE;
- break;
- case BFD_RELOC_ALPHA_GPDISP_HI16:
- alpha_type = ALPHA_R_GPDISP;
- break;
- case BFD_RELOC_ALPHA_GPDISP_LO16:
- alpha_type = ALPHA_R_IGNORE;
- break;
- case BFD_RELOC_23_PCREL_S2:
- alpha_type = ALPHA_R_BRADDR;
- break;
- case BFD_RELOC_ALPHA_HINT:
- alpha_type = ALPHA_R_HINT;
- break;
- case BFD_RELOC_16_PCREL:
- alpha_type = ALPHA_R_SREL16;
- break;
- case BFD_RELOC_32_PCREL:
- alpha_type = ALPHA_R_SREL32;
- break;
- case BFD_RELOC_64_PCREL:
- alpha_type = ALPHA_R_SREL64;
- break;
-#if 0
- case ???:
- alpha_type = ALPHA_R_OP_PUSH;
- break;
- case ???:
- alpha_type = ALPHA_R_OP_STORE;
- break;
- case ???:
- alpha_type = ALPHA_R_OP_PSUB;
- break;
- case ???:
- alpha_type = ALPHA_R_OP_PRSHIFT;
- break;
- case ???:
- alpha_type = ALPHA_R_GPVALUE;
- break;
-#endif
- default:
- return (reloc_howto_type *) NULL;
- }
-
- return &alpha_howto_table[alpha_type];
-}
-
-/* A helper routine for alpha_relocate_section which converts an
- external reloc when generating relocateable output. Returns the
- relocation amount. */
-
-static bfd_vma
-alpha_convert_external_reloc (output_bfd, info, input_bfd, ext_rel, h)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- struct external_reloc *ext_rel;
- struct ecoff_link_hash_entry *h;
-{
- unsigned long r_symndx;
- bfd_vma relocation;
-
- BFD_ASSERT (info->relocateable);
-
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *hsec;
- const char *name;
-
- /* This symbol is defined in the output. Convert the reloc from
- being against the symbol to being against the section. */
-
- /* Clear the r_extern bit. */
- ext_rel->r_bits[1] &=~ RELOC_BITS1_EXTERN_LITTLE;
-
- /* Compute a new r_symndx value. */
- hsec = h->root.u.def.section;
- name = bfd_get_section_name (output_bfd, hsec->output_section);
-
- r_symndx = -1;
- switch (name[1])
- {
- case 'A':
- if (strcmp (name, "*ABS*") == 0)
- r_symndx = RELOC_SECTION_ABS;
- break;
- case 'b':
- if (strcmp (name, ".bss") == 0)
- r_symndx = RELOC_SECTION_BSS;
- break;
- case 'd':
- if (strcmp (name, ".data") == 0)
- r_symndx = RELOC_SECTION_DATA;
- break;
- case 'f':
- if (strcmp (name, ".fini") == 0)
- r_symndx = RELOC_SECTION_FINI;
- break;
- case 'i':
- if (strcmp (name, ".init") == 0)
- r_symndx = RELOC_SECTION_INIT;
- break;
- case 'l':
- if (strcmp (name, ".lita") == 0)
- r_symndx = RELOC_SECTION_LITA;
- else if (strcmp (name, ".lit8") == 0)
- r_symndx = RELOC_SECTION_LIT8;
- else if (strcmp (name, ".lit4") == 0)
- r_symndx = RELOC_SECTION_LIT4;
- break;
- case 'p':
- if (strcmp (name, ".pdata") == 0)
- r_symndx = RELOC_SECTION_PDATA;
- break;
- case 'r':
- if (strcmp (name, ".rdata") == 0)
- r_symndx = RELOC_SECTION_RDATA;
- else if (strcmp (name, ".rconst") == 0)
- r_symndx = RELOC_SECTION_RCONST;
- break;
- case 's':
- if (strcmp (name, ".sdata") == 0)
- r_symndx = RELOC_SECTION_SDATA;
- else if (strcmp (name, ".sbss") == 0)
- r_symndx = RELOC_SECTION_SBSS;
- break;
- case 't':
- if (strcmp (name, ".text") == 0)
- r_symndx = RELOC_SECTION_TEXT;
- break;
- case 'x':
- if (strcmp (name, ".xdata") == 0)
- r_symndx = RELOC_SECTION_XDATA;
- break;
- }
-
- if (r_symndx == -1)
- abort ();
-
- /* Add the section VMA and the symbol value. */
- relocation = (h->root.u.def.value
- + hsec->output_section->vma
- + hsec->output_offset);
- }
- else
- {
- /* Change the symndx value to the right one for
- the output BFD. */
- r_symndx = h->indx;
- if (r_symndx == -1)
- {
- /* Caller must give an error. */
- r_symndx = 0;
- }
- relocation = 0;
- }
-
- /* Write out the new r_symndx value. */
- bfd_h_put_32 (input_bfd, (bfd_vma) r_symndx,
- (bfd_byte *) ext_rel->r_symndx);
-
- return relocation;
-}
-
-/* Relocate a section while linking an Alpha ECOFF file. This is
- quite similar to get_relocated_section_contents. Perhaps they
- could be combined somehow. */
-
-static boolean
-alpha_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, external_relocs)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- PTR external_relocs;
-{
- asection **symndx_to_section, *lita_sec;
- struct ecoff_link_hash_entry **sym_hashes;
- bfd_vma gp;
- boolean gp_undefined;
- bfd_vma stack[RELOC_STACKSIZE];
- int tos = 0;
- struct external_reloc *ext_rel;
- struct external_reloc *ext_rel_end;
-
- /* We keep a table mapping the symndx found in an internal reloc to
- the appropriate section. This is faster than looking up the
- section by name each time. */
- symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
- if (symndx_to_section == (asection **) NULL)
- {
- symndx_to_section = ((asection **)
- bfd_alloc (input_bfd,
- (NUM_RELOC_SECTIONS
- * sizeof (asection *))));
- if (!symndx_to_section)
- return false;
-
- symndx_to_section[RELOC_SECTION_NONE] = NULL;
- symndx_to_section[RELOC_SECTION_TEXT] =
- bfd_get_section_by_name (input_bfd, ".text");
- symndx_to_section[RELOC_SECTION_RDATA] =
- bfd_get_section_by_name (input_bfd, ".rdata");
- symndx_to_section[RELOC_SECTION_DATA] =
- bfd_get_section_by_name (input_bfd, ".data");
- symndx_to_section[RELOC_SECTION_SDATA] =
- bfd_get_section_by_name (input_bfd, ".sdata");
- symndx_to_section[RELOC_SECTION_SBSS] =
- bfd_get_section_by_name (input_bfd, ".sbss");
- symndx_to_section[RELOC_SECTION_BSS] =
- bfd_get_section_by_name (input_bfd, ".bss");
- symndx_to_section[RELOC_SECTION_INIT] =
- bfd_get_section_by_name (input_bfd, ".init");
- symndx_to_section[RELOC_SECTION_LIT8] =
- bfd_get_section_by_name (input_bfd, ".lit8");
- symndx_to_section[RELOC_SECTION_LIT4] =
- bfd_get_section_by_name (input_bfd, ".lit4");
- symndx_to_section[RELOC_SECTION_XDATA] =
- bfd_get_section_by_name (input_bfd, ".xdata");
- symndx_to_section[RELOC_SECTION_PDATA] =
- bfd_get_section_by_name (input_bfd, ".pdata");
- symndx_to_section[RELOC_SECTION_FINI] =
- bfd_get_section_by_name (input_bfd, ".fini");
- symndx_to_section[RELOC_SECTION_LITA] =
- bfd_get_section_by_name (input_bfd, ".lita");
- symndx_to_section[RELOC_SECTION_ABS] = bfd_abs_section_ptr;
- symndx_to_section[RELOC_SECTION_RCONST] =
- bfd_get_section_by_name (input_bfd, ".rconst");
-
- ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
- }
-
- sym_hashes = ecoff_data (input_bfd)->sym_hashes;
-
- /* On the Alpha, the .lita section must be addressable by the global
- pointer. To support large programs, we need to allow multiple
- global pointers. This works as long as each input .lita section
- is <64KB big. This implies that when producing relocatable
- output, the .lita section is limited to 64KB. . */
-
- lita_sec = symndx_to_section[RELOC_SECTION_LITA];
- gp = _bfd_get_gp_value (output_bfd);
- if (! info->relocateable && lita_sec != NULL)
- {
- struct ecoff_section_tdata *lita_sec_data;
-
- /* Make sure we have a section data structure to which we can
- hang on to the gp value we pick for the section. */
- lita_sec_data = ecoff_section_data (input_bfd, lita_sec);
- if (lita_sec_data == NULL)
- {
- lita_sec_data = ((struct ecoff_section_tdata *)
- bfd_zalloc (input_bfd,
- sizeof (struct ecoff_section_tdata)));
- ecoff_section_data (input_bfd, lita_sec) = lita_sec_data;
- }
-
- if (lita_sec_data->gp != 0)
- {
- /* If we already assigned a gp to this section, we better
- stick with that value. */
- gp = lita_sec_data->gp;
- }
- else
- {
- bfd_vma lita_vma;
- bfd_size_type lita_size;
-
- lita_vma = lita_sec->output_offset + lita_sec->output_section->vma;
- lita_size = lita_sec->_cooked_size;
- if (lita_size == 0)
- lita_size = lita_sec->_raw_size;
-
- if (gp == 0
- || lita_vma < gp - 0x8000
- || lita_vma + lita_size >= gp + 0x8000)
- {
- /* Either gp hasn't been set at all or the current gp
- cannot address this .lita section. In both cases we
- reset the gp to point into the "middle" of the
- current input .lita section. */
- if (gp && !ecoff_data (output_bfd)->issued_multiple_gp_warning)
- {
- (*info->callbacks->warning) (info,
- "using multiple gp values",
- (char *) NULL, output_bfd,
- (asection *) NULL, (bfd_vma) 0);
- ecoff_data (output_bfd)->issued_multiple_gp_warning = true;
- }
- if (lita_vma < gp - 0x8000)
- gp = lita_vma + lita_size - 0x8000;
- else
- gp = lita_vma + 0x8000;
-
- }
-
- lita_sec_data->gp = gp;
- }
-
- _bfd_set_gp_value (output_bfd, gp);
- }
-
- gp_undefined = (gp == 0);
-
- BFD_ASSERT (bfd_header_little_endian (output_bfd));
- BFD_ASSERT (bfd_header_little_endian (input_bfd));
-
- ext_rel = (struct external_reloc *) external_relocs;
- ext_rel_end = ext_rel + input_section->reloc_count;
- for (; ext_rel < ext_rel_end; ext_rel++)
- {
- bfd_vma r_vaddr;
- unsigned long r_symndx;
- int r_type;
- int r_extern;
- int r_offset;
- int r_size;
- boolean relocatep;
- boolean adjust_addrp;
- boolean gp_usedp;
- bfd_vma addend;
-
- r_vaddr = bfd_h_get_64 (input_bfd, (bfd_byte *) ext_rel->r_vaddr);
- r_symndx = bfd_h_get_32 (input_bfd, (bfd_byte *) ext_rel->r_symndx);
-
- r_type = ((ext_rel->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
- >> RELOC_BITS0_TYPE_SH_LITTLE);
- r_extern = (ext_rel->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
- r_offset = ((ext_rel->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
- >> RELOC_BITS1_OFFSET_SH_LITTLE);
- /* Ignored the reserved bits. */
- r_size = ((ext_rel->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
- >> RELOC_BITS3_SIZE_SH_LITTLE);
-
- relocatep = false;
- adjust_addrp = true;
- gp_usedp = false;
- addend = 0;
-
- switch (r_type)
- {
- default:
- abort ();
-
- case ALPHA_R_IGNORE:
- /* This reloc appears after a GPDISP reloc. On earlier
- versions of OSF/1, It marked the position of the second
- instruction to be altered by the GPDISP reloc, but it is
- not otherwise used for anything. For some reason, the
- address of the relocation does not appear to include the
- section VMA, unlike the other relocation types. */
- if (info->relocateable)
- bfd_h_put_64 (input_bfd,
- input_section->output_offset + r_vaddr,
- (bfd_byte *) ext_rel->r_vaddr);
- adjust_addrp = false;
- break;
-
- case ALPHA_R_REFLONG:
- case ALPHA_R_REFQUAD:
- case ALPHA_R_BRADDR:
- case ALPHA_R_HINT:
- case ALPHA_R_SREL16:
- case ALPHA_R_SREL32:
- case ALPHA_R_SREL64:
- relocatep = true;
- break;
-
- case ALPHA_R_GPREL32:
- /* This relocation is used in a switch table. It is a 32
- bit offset from the current GP value. We must adjust it
- by the different between the original GP value and the
- current GP value. */
- relocatep = true;
- addend = ecoff_data (input_bfd)->gp - gp;
- gp_usedp = true;
- break;
-
- case ALPHA_R_LITERAL:
- /* This is a reference to a literal value, generally
- (always?) in the .lita section. This is a 16 bit GP
- relative relocation. Sometimes the subsequent reloc is a
- LITUSE reloc, which indicates how this reloc is used.
- This sometimes permits rewriting the two instructions
- referred to by the LITERAL and the LITUSE into different
- instructions which do not refer to .lita. This can save
- a memory reference, and permits removing a value from
- .lita thus saving GP relative space.
-
- We do not these optimizations. To do them we would need
- to arrange to link the .lita section first, so that by
- the time we got here we would know the final values to
- use. This would not be particularly difficult, but it is
- not currently implemented. */
-
- /* I believe that the LITERAL reloc will only apply to a ldq
- or ldl instruction, so check my assumption. */
- {
- unsigned long insn;
-
- insn = bfd_get_32 (input_bfd,
- contents + r_vaddr - input_section->vma);
- BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
- || ((insn >> 26) & 0x3f) == 0x28);
- }
-
- relocatep = true;
- addend = ecoff_data (input_bfd)->gp - gp;
- gp_usedp = true;
- break;
-
- case ALPHA_R_LITUSE:
- /* See ALPHA_R_LITERAL above for the uses of this reloc. It
- does not cause anything to happen, itself. */
- break;
-
- case ALPHA_R_GPDISP:
- /* This marks the ldah of an ldah/lda pair which loads the
- gp register with the difference of the gp value and the
- current location. The second of the pair is r_symndx
- bytes ahead. It used to be marked with an ALPHA_R_IGNORE
- reloc, but OSF/1 3.2 no longer does that. */
- {
- unsigned long insn1, insn2;
-
- /* Get the two instructions. */
- insn1 = bfd_get_32 (input_bfd,
- contents + r_vaddr - input_section->vma);
- insn2 = bfd_get_32 (input_bfd,
- (contents
- + r_vaddr
- - input_section->vma
- + r_symndx));
-
- BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
- BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
-
- /* Get the existing addend. We must account for the sign
- extension done by lda and ldah. */
- addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff);
- if (insn1 & 0x8000)
- {
- /* This is addend -= 0x100000000 without causing an
- integer overflow on a 32 bit host. */
- addend -= 0x80000000;
- addend -= 0x80000000;
- }
- if (insn2 & 0x8000)
- addend -= 0x10000;
-
- /* The existing addend includes the difference between the
- gp of the input BFD and the address in the input BFD.
- We want to change this to the difference between the
- final GP and the final address. */
- addend += (gp
- - ecoff_data (input_bfd)->gp
- + input_section->vma
- - (input_section->output_section->vma
- + input_section->output_offset));
-
- /* Change the instructions, accounting for the sign
- extension, and write them out. */
- if (addend & 0x8000)
- addend += 0x10000;
- insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff);
- insn2 = (insn2 & 0xffff0000) | (addend & 0xffff);
-
- bfd_put_32 (input_bfd, (bfd_vma) insn1,
- contents + r_vaddr - input_section->vma);
- bfd_put_32 (input_bfd, (bfd_vma) insn2,
- contents + r_vaddr - input_section->vma + r_symndx);
-
- gp_usedp = true;
- }
- break;
-
- case ALPHA_R_OP_PUSH:
- case ALPHA_R_OP_PSUB:
- case ALPHA_R_OP_PRSHIFT:
- /* Manipulate values on the reloc evaluation stack. The
- r_vaddr field is not an address in input_section, it is
- the current value (including any addend) of the object
- being used. */
- if (! r_extern)
- {
- asection *s;
-
- s = symndx_to_section[r_symndx];
- if (s == (asection *) NULL)
- abort ();
- addend = s->output_section->vma + s->output_offset - s->vma;
- }
- else
- {
- struct ecoff_link_hash_entry *h;
-
- h = sym_hashes[r_symndx];
- if (h == (struct ecoff_link_hash_entry *) NULL)
- abort ();
-
- if (! info->relocateable)
- {
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- addend = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- else
- {
- /* Note that we pass the address as 0, since we
- do not have a meaningful number for the
- location within the section that is being
- relocated. */
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, (bfd_vma) 0)))
- return false;
- addend = 0;
- }
- }
- else
- {
- if (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak
- && h->indx == -1)
- {
- /* This symbol is not being written out. Pass
- the address as 0, as with undefined_symbol,
- above. */
- if (! ((*info->callbacks->unattached_reloc)
- (info, h->root.root.string, input_bfd,
- input_section, (bfd_vma) 0)))
- return false;
- }
-
- addend = alpha_convert_external_reloc (output_bfd, info,
- input_bfd,
- ext_rel, h);
- }
- }
-
- addend += r_vaddr;
-
- if (info->relocateable)
- {
- /* Adjust r_vaddr by the addend. */
- bfd_h_put_64 (input_bfd, addend,
- (bfd_byte *) ext_rel->r_vaddr);
- }
- else
- {
- switch (r_type)
- {
- case ALPHA_R_OP_PUSH:
- if (tos >= RELOC_STACKSIZE)
- abort ();
- stack[tos++] = addend;
- break;
-
- case ALPHA_R_OP_PSUB:
- if (tos == 0)
- abort ();
- stack[tos - 1] -= addend;
- break;
-
- case ALPHA_R_OP_PRSHIFT:
- if (tos == 0)
- abort ();
- stack[tos - 1] >>= addend;
- break;
- }
- }
-
- adjust_addrp = false;
- break;
-
- case ALPHA_R_OP_STORE:
- /* Store a value from the reloc stack into a bitfield. If
- we are generating relocateable output, all we do is
- adjust the address of the reloc. */
- if (! info->relocateable)
- {
- bfd_vma mask;
- bfd_vma val;
-
- if (tos == 0)
- abort ();
-
- /* Get the relocation mask. The separate steps and the
- casts to bfd_vma are attempts to avoid a bug in the
- Alpha OSF 1.3 C compiler. See reloc.c for more
- details. */
- mask = 1;
- mask <<= (bfd_vma) r_size;
- mask -= 1;
-
- /* FIXME: I don't know what kind of overflow checking,
- if any, should be done here. */
- val = bfd_get_64 (input_bfd,
- contents + r_vaddr - input_section->vma);
- val &=~ mask << (bfd_vma) r_offset;
- val |= (stack[--tos] & mask) << (bfd_vma) r_offset;
- bfd_put_64 (input_bfd, val,
- contents + r_vaddr - input_section->vma);
- }
- break;
-
- case ALPHA_R_GPVALUE:
- /* I really don't know if this does the right thing. */
- gp = ecoff_data (input_bfd)->gp + r_symndx;
- gp_undefined = false;
- break;
- }
-
- if (relocatep)
- {
- reloc_howto_type *howto;
- struct ecoff_link_hash_entry *h = NULL;
- asection *s = NULL;
- bfd_vma relocation;
- bfd_reloc_status_type r;
-
- /* Perform a relocation. */
-
- howto = &alpha_howto_table[r_type];
-
- if (r_extern)
- {
- h = sym_hashes[r_symndx];
- /* If h is NULL, that means that there is a reloc
- against an external symbol which we thought was just
- a debugging symbol. This should not happen. */
- if (h == (struct ecoff_link_hash_entry *) NULL)
- abort ();
- }
- else
- {
- if (r_symndx >= NUM_RELOC_SECTIONS)
- s = NULL;
- else
- s = symndx_to_section[r_symndx];
-
- if (s == (asection *) NULL)
- abort ();
- }
-
- if (info->relocateable)
- {
- /* We are generating relocateable output, and must
- convert the existing reloc. */
- if (r_extern)
- {
- if (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak
- && h->indx == -1)
- {
- /* This symbol is not being written out. */
- if (! ((*info->callbacks->unattached_reloc)
- (info, h->root.root.string, input_bfd,
- input_section, r_vaddr - input_section->vma)))
- return false;
- }
-
- relocation = alpha_convert_external_reloc (output_bfd,
- info,
- input_bfd,
- ext_rel,
- h);
- }
- else
- {
- /* This is a relocation against a section. Adjust
- the value by the amount the section moved. */
- relocation = (s->output_section->vma
- + s->output_offset
- - s->vma);
- }
-
- /* If this is PC relative, the existing object file
- appears to already have the reloc worked out. We
- must subtract out the old value and add in the new
- one. */
- if (howto->pc_relative)
- relocation -= (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma);
-
- /* Put in any addend. */
- relocation += addend;
-
- /* Adjust the contents. */
- r = _bfd_relocate_contents (howto, input_bfd, relocation,
- (contents
- + r_vaddr
- - input_section->vma));
- }
- else
- {
- /* We are producing a final executable. */
- if (r_extern)
- {
- /* This is a reloc against a symbol. */
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *hsec;
-
- hsec = h->root.u.def.section;
- relocation = (h->root.u.def.value
- + hsec->output_section->vma
- + hsec->output_offset);
- }
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section,
- r_vaddr - input_section->vma)))
- return false;
- relocation = 0;
- }
- }
- else
- {
- /* This is a reloc against a section. */
- relocation = (s->output_section->vma
- + s->output_offset
- - s->vma);
-
- /* Adjust a PC relative relocation by removing the
- reference to the original source section. */
- if (howto->pc_relative)
- relocation += input_section->vma;
- }
-
- r = _bfd_final_link_relocate (howto,
- input_bfd,
- input_section,
- contents,
- r_vaddr - input_section->vma,
- relocation,
- addend);
- }
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (r_extern)
- name = sym_hashes[r_symndx]->root.root.string;
- else
- name = bfd_section_name (input_bfd,
- symndx_to_section[r_symndx]);
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, alpha_howto_table[r_type].name,
- (bfd_vma) 0, input_bfd, input_section,
- r_vaddr - input_section->vma)))
- return false;
- }
- break;
- }
- }
- }
-
- if (info->relocateable && adjust_addrp)
- {
- /* Change the address of the relocation. */
- bfd_h_put_64 (input_bfd,
- (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma
- + r_vaddr),
- (bfd_byte *) ext_rel->r_vaddr);
- }
-
- if (gp_usedp && gp_undefined)
- {
- if (! ((*info->callbacks->reloc_dangerous)
- (info, "GP relative relocation when GP not defined",
- input_bfd, input_section, r_vaddr - input_section->vma)))
- return false;
- /* Only give the error once per link. */
- gp = 4;
- _bfd_set_gp_value (output_bfd, gp);
- gp_undefined = false;
- }
- }
-
- if (tos != 0)
- abort ();
-
- return true;
-}
-
-/* Do final adjustments to the filehdr and the aouthdr. This routine
- sets the dynamic bits in the file header. */
-
-/*ARGSUSED*/
-static boolean
-alpha_adjust_headers (abfd, fhdr, ahdr)
- bfd *abfd;
- struct internal_filehdr *fhdr;
- struct internal_aouthdr *ahdr;
-{
- if ((abfd->flags & (DYNAMIC | EXEC_P)) == (DYNAMIC | EXEC_P))
- fhdr->f_flags |= F_ALPHA_CALL_SHARED;
- else if ((abfd->flags & DYNAMIC) != 0)
- fhdr->f_flags |= F_ALPHA_SHARABLE;
- return true;
-}
-
-/* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital
- introduced archive packing, in which the elements in an archive are
- optionally compressed using a simple dictionary scheme. We know
- how to read such archives, but we don't write them. */
-
-#define alpha_ecoff_slurp_armap _bfd_ecoff_slurp_armap
-#define alpha_ecoff_slurp_extended_name_table \
- _bfd_ecoff_slurp_extended_name_table
-#define alpha_ecoff_construct_extended_name_table \
- _bfd_ecoff_construct_extended_name_table
-#define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
-#define alpha_ecoff_write_armap _bfd_ecoff_write_armap
-#define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
-#define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
-
-/* A compressed file uses this instead of ARFMAG. */
-
-#define ARFZMAG "Z\012"
-
-/* Read an archive header. This is like the standard routine, but it
- also accepts ARFZMAG. */
-
-static PTR
-alpha_ecoff_read_ar_hdr (abfd)
- bfd *abfd;
-{
- struct areltdata *ret;
- struct ar_hdr *h;
-
- ret = (struct areltdata *) _bfd_generic_read_ar_hdr_mag (abfd, ARFZMAG);
- if (ret == NULL)
- return NULL;
-
- h = (struct ar_hdr *) ret->arch_header;
- if (strncmp (h->ar_fmag, ARFZMAG, 2) == 0)
- {
- bfd_byte ab[8];
-
- /* This is a compressed file. We must set the size correctly.
- The size is the eight bytes after the dummy file header. */
- if (bfd_seek (abfd, FILHSZ, SEEK_CUR) != 0
- || bfd_read (ab, 1, 8, abfd) != 8
- || bfd_seek (abfd, - (FILHSZ + 8), SEEK_CUR) != 0)
- return NULL;
-
- ret->parsed_size = bfd_h_get_64 (abfd, ab);
- }
-
- return (PTR) ret;
-}
-
-/* Get an archive element at a specified file position. This is where
- we uncompress the archive element if necessary. */
-
-static bfd *
-alpha_ecoff_get_elt_at_filepos (archive, filepos)
- bfd *archive;
- file_ptr filepos;
-{
- bfd *nbfd = NULL;
- struct areltdata *tdata;
- struct ar_hdr *hdr;
- bfd_byte ab[8];
- bfd_size_type size;
- bfd_byte *buf, *p;
- struct bfd_in_memory *bim;
-
- nbfd = _bfd_get_elt_at_filepos (archive, filepos);
- if (nbfd == NULL)
- goto error_return;
-
- if ((nbfd->flags & BFD_IN_MEMORY) != 0)
- {
- /* We have already expanded this BFD. */
- return nbfd;
- }
-
- tdata = (struct areltdata *) nbfd->arelt_data;
- hdr = (struct ar_hdr *) tdata->arch_header;
- if (strncmp (hdr->ar_fmag, ARFZMAG, 2) != 0)
- return nbfd;
-
- /* We must uncompress this element. We do this by copying it into a
- memory buffer, and making bfd_read and bfd_seek use that buffer.
- This can use a lot of memory, but it's simpler than getting a
- temporary file, making that work with the file descriptor caching
- code, and making sure that it is deleted at all appropriate
- times. It can be changed if it ever becomes important. */
-
- /* The compressed file starts with a dummy ECOFF file header. */
- if (bfd_seek (nbfd, FILHSZ, SEEK_SET) != 0)
- goto error_return;
-
- /* The next eight bytes are the real file size. */
- if (bfd_read (ab, 1, 8, nbfd) != 8)
- goto error_return;
- size = bfd_h_get_64 (nbfd, ab);
-
- if (size == 0)
- buf = NULL;
- else
- {
- bfd_size_type left;
- bfd_byte dict[4096];
- unsigned int h;
- bfd_byte b;
-
- buf = (bfd_byte *) bfd_alloc (nbfd, size);
- if (buf == NULL)
- goto error_return;
- p = buf;
-
- left = size;
-
- /* I don't know what the next eight bytes are for. */
- if (bfd_read (ab, 1, 8, nbfd) != 8)
- goto error_return;
-
- /* This is the uncompression algorithm. It's a simple
- dictionary based scheme in which each character is predicted
- by a hash of the previous three characters. A control byte
- indicates whether the character is predicted or whether it
- appears in the input stream; each control byte manages the
- next eight bytes in the output stream. */
- memset (dict, 0, sizeof dict);
- h = 0;
- while (bfd_read (&b, 1, 1, nbfd) == 1)
- {
- unsigned int i;
-
- for (i = 0; i < 8; i++, b >>= 1)
- {
- bfd_byte n;
-
- if ((b & 1) == 0)
- n = dict[h];
- else
- {
- if (! bfd_read (&n, 1, 1, nbfd))
- goto error_return;
- dict[h] = n;
- }
-
- *p++ = n;
-
- --left;
- if (left == 0)
- break;
-
- h <<= 4;
- h ^= n;
- h &= sizeof dict - 1;
- }
-
- if (left == 0)
- break;
- }
- }
-
- /* Now the uncompressed file contents are in buf. */
- bim = ((struct bfd_in_memory *)
- bfd_alloc (nbfd, sizeof (struct bfd_in_memory)));
- if (bim == NULL)
- goto error_return;
- bim->size = size;
- bim->buffer = buf;
-
- nbfd->mtime_set = true;
- nbfd->mtime = strtol (hdr->ar_date, (char **) NULL, 10);
-
- nbfd->flags |= BFD_IN_MEMORY;
- nbfd->iostream = (PTR) bim;
- BFD_ASSERT (! nbfd->cacheable);
-
- return nbfd;
-
- error_return:
- if (nbfd != NULL)
- bfd_close (nbfd);
- return NULL;
-}
-
-/* Open the next archived file. */
-
-static bfd *
-alpha_ecoff_openr_next_archived_file (archive, last_file)
- bfd *archive;
- bfd *last_file;
-{
- file_ptr filestart;
-
- if (last_file == NULL)
- filestart = bfd_ardata (archive)->first_file_filepos;
- else
- {
- struct areltdata *t;
- struct ar_hdr *h;
- bfd_size_type size;
-
- /* We can't use arelt_size here, because that uses parsed_size,
- which is the uncompressed size. We need the compressed size. */
- t = (struct areltdata *) last_file->arelt_data;
- h = (struct ar_hdr *) t->arch_header;
- size = strtol (h->ar_size, (char **) NULL, 10);
-
- /* Pad to an even boundary...
- Note that last_file->origin can be odd in the case of
- BSD-4.4-style element with a long odd size. */
- filestart = last_file->origin + size;
- filestart += filestart % 2;
- }
-
- return alpha_ecoff_get_elt_at_filepos (archive, filestart);
-}
-
-/* Open the archive file given an index into the armap. */
-
-static bfd *
-alpha_ecoff_get_elt_at_index (abfd, index)
- bfd *abfd;
- symindex index;
-{
- carsym *entry;
-
- entry = bfd_ardata (abfd)->symdefs + index;
- return alpha_ecoff_get_elt_at_filepos (abfd, entry->file_offset);
-}
-
-/* This is the ECOFF backend structure. The backend field of the
- target vector points to this. */
-
-static const struct ecoff_backend_data alpha_ecoff_backend_data =
-{
- /* COFF backend structure. */
- {
- (void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
- (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
- (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
- (unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
- (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
- (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
- (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
- alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out,
- alpha_ecoff_swap_scnhdr_out,
- FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true,
- alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in,
- alpha_ecoff_swap_scnhdr_in, NULL,
- alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
- alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
- _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
- },
- /* Supported architecture. */
- bfd_arch_alpha,
- /* Initial portion of armap string. */
- "________64",
- /* The page boundary used to align sections in a demand-paged
- executable file. E.g., 0x1000. */
- 0x2000,
- /* True if the .rdata section is part of the text segment, as on the
- Alpha. False if .rdata is part of the data segment, as on the
- MIPS. */
- true,
- /* Bitsize of constructor entries. */
- 64,
- /* Reloc to use for constructor entries. */
- &alpha_howto_table[ALPHA_R_REFQUAD],
- {
- /* Symbol table magic number. */
- magicSym2,
- /* Alignment of debugging information. E.g., 4. */
- 8,
- /* Sizes of external symbolic information. */
- sizeof (struct hdr_ext),
- sizeof (struct dnr_ext),
- sizeof (struct pdr_ext),
- sizeof (struct sym_ext),
- sizeof (struct opt_ext),
- sizeof (struct fdr_ext),
- sizeof (struct rfd_ext),
- sizeof (struct ext_ext),
- /* Functions to swap in external symbolic data. */
- ecoff_swap_hdr_in,
- ecoff_swap_dnr_in,
- ecoff_swap_pdr_in,
- ecoff_swap_sym_in,
- ecoff_swap_opt_in,
- ecoff_swap_fdr_in,
- ecoff_swap_rfd_in,
- ecoff_swap_ext_in,
- _bfd_ecoff_swap_tir_in,
- _bfd_ecoff_swap_rndx_in,
- /* Functions to swap out external symbolic data. */
- ecoff_swap_hdr_out,
- ecoff_swap_dnr_out,
- ecoff_swap_pdr_out,
- ecoff_swap_sym_out,
- ecoff_swap_opt_out,
- ecoff_swap_fdr_out,
- ecoff_swap_rfd_out,
- ecoff_swap_ext_out,
- _bfd_ecoff_swap_tir_out,
- _bfd_ecoff_swap_rndx_out,
- /* Function to read in symbolic data. */
- _bfd_ecoff_slurp_symbolic_info
- },
- /* External reloc size. */
- RELSZ,
- /* Reloc swapping functions. */
- alpha_ecoff_swap_reloc_in,
- alpha_ecoff_swap_reloc_out,
- /* Backend reloc tweaking. */
- alpha_adjust_reloc_in,
- alpha_adjust_reloc_out,
- /* Relocate section contents while linking. */
- alpha_relocate_section,
- /* Do final adjustments to filehdr and aouthdr. */
- alpha_adjust_headers,
- /* Read an element from an archive at a given file position. */
- alpha_ecoff_get_elt_at_filepos
-};
-
-/* Looking up a reloc type is Alpha specific. */
-#define _bfd_ecoff_bfd_reloc_type_lookup alpha_bfd_reloc_type_lookup
-
-/* So is getting relocated section contents. */
-#define _bfd_ecoff_bfd_get_relocated_section_contents \
- alpha_ecoff_get_relocated_section_contents
-
-/* Handling file windows is generic. */
-#define _bfd_ecoff_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-/* Relaxing sections is generic. */
-#define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
-
-const bfd_target ecoffalpha_little_vec =
-{
- "ecoff-littlealpha", /* name */
- bfd_target_ecoff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
-
- (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 | SEC_CODE | SEC_DATA),
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
-
- {_bfd_dummy_target, alpha_ecoff_object_p, /* bfd_check_format */
- _bfd_ecoff_archive_p, _bfd_dummy_target},
- {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
- BFD_JUMP_TABLE_COPY (_bfd_ecoff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff),
- BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
- BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
- BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
- BFD_JUMP_TABLE_LINK (_bfd_ecoff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) &alpha_ecoff_backend_data
-};
diff --git a/contrib/gdb/bfd/coff-apollo.c b/contrib/gdb/bfd/coff-apollo.c
deleted file mode 100644
index 561b1c7..0000000
--- a/contrib/gdb/bfd/coff-apollo.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* BFD back-end for Apollo 68000 COFF binaries.
- Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- By Troy Rollo (troy@cbme.unsw.edu.au)
- Based on m68k standard COFF version Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "coff/apollo.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-
-#ifdef ONLY_DECLARE_RELOCS
-extern reloc_howto_type apollocoff_howto_table[];
-#else
-reloc_howto_type apollocoff_howto_table[] =
-{
- HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
- HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
- HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
- HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
- HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
- HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
- HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "-32", true, 0xffffffff,0xffffffff, false),
-};
-#endif /* not ONLY_DECLARE_RELOCS */
-
-#ifndef BADMAG
-#define BADMAG(x) M68KBADMAG(x)
-#endif
-#define APOLLO_M68 1 /* Customize coffcode.h */
-
-/* Turn a howto into a reloc number */
-
-#ifdef ONLY_DECLARE_RELOCS
-extern void apollo_rtype2howto PARAMS ((arelent *internal, int relocentry));
-extern int apollo_howto2rtype PARAMS ((reloc_howto_type *));
-#else
-void
-apollo_rtype2howto(internal, relocentry)
- arelent *internal;
- int relocentry;
-{
- switch (relocentry)
- {
- case R_RELBYTE: internal->howto = apollocoff_howto_table + 0; break;
- case R_RELWORD: internal->howto = apollocoff_howto_table + 1; break;
- case R_RELLONG: internal->howto = apollocoff_howto_table + 2; break;
- case R_PCRBYTE: internal->howto = apollocoff_howto_table + 3; break;
- case R_PCRWORD: internal->howto = apollocoff_howto_table + 4; break;
- case R_PCRLONG: internal->howto = apollocoff_howto_table + 5; break;
- case R_RELLONG_NEG: internal->howto = apollocoff_howto_table + 6; break;
- }
-}
-
-int
-apollo_howto2rtype (internal)
- reloc_howto_type *internal;
-{
- if (internal->pc_relative)
- {
- switch (internal->bitsize)
- {
- case 32: return R_PCRLONG;
- case 16: return R_PCRWORD;
- case 8: return R_PCRBYTE;
- }
- }
- else
- {
- switch (internal->bitsize)
- {
- case 32: return R_RELLONG;
- case 16: return R_RELWORD;
- case 8: return R_RELBYTE;
- }
- }
- return R_RELLONG;
-}
-#endif /* not ONLY_DECLARE_RELOCS */
-
-#define RTYPE2HOWTO(internal, relocentry) \
- apollo_rtype2howto(internal, (relocentry)->r_type)
-
-#define SELECT_RELOC(external, internal) \
- external.r_type = apollo_howto2rtype(internal);
-
-#include "coffcode.h"
-
-const bfd_target
-#ifdef TARGET_SYM
- TARGET_SYM =
-#else
- apollocoff_vec =
-#endif
-{
-#ifdef TARGET_NAME
- TARGET_NAME,
-#else
- "apollo-m68k", /* name */
-#endif
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-#ifdef NAMES_HAVE_UNDERSCORE
- '_',
-#else
- 0, /* leading underscore */
-#endif
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE
- };
diff --git a/contrib/gdb/bfd/coff-arm.c b/contrib/gdb/bfd/coff-arm.c
deleted file mode 100644
index bb16b04..0000000
--- a/contrib/gdb/bfd/coff-arm.c
+++ /dev/null
@@ -1,537 +0,0 @@
-/* BFD back-end for ARM COFF files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-
-#include "coff/arm.h"
-
-#include "coff/internal.h"
-
-#ifdef COFF_WITH_PE
-#include "coff/pe.h"
-#endif
-
-#include "libcoff.h"
-
-static bfd_reloc_status_type
-aoutarm_fix_pcrel_26_done PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-
-static bfd_reloc_status_type
-aoutarm_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-
-
-static bfd_reloc_status_type coff_arm_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-
-
-/* Used by the assembler. */
-static bfd_reloc_status_type
-coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- symvalue diff;
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- diff = reloc_entry->addend;
-
-#define DOIT(x) \
- x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
-
- if (diff != 0)
- {
- reloc_howto_type *howto = reloc_entry->howto;
- unsigned char *addr = (unsigned char *) data + reloc_entry->address;
-
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, addr);
- DOIT (x);
- bfd_put_8 (abfd, x, addr);
- }
- break;
-
- case 1:
- {
- short x = bfd_get_16 (abfd, addr);
- DOIT (x);
- bfd_put_16 (abfd, x, addr);
- }
- break;
-
- case 2:
- {
- long x = bfd_get_32 (abfd, addr);
- DOIT (x);
- bfd_put_32 (abfd, x, addr);
- }
- break;
-
- default:
- abort ();
- }
- }
-
- /* Now let bfd_perform_relocation finish everything up. */
- return bfd_reloc_continue;
-}
-
-#ifndef PCRELOFFSET
-#define PCRELOFFSET true
-#endif
-
-static reloc_howto_type aoutarm_std_reloc_howto[] =
-{
- /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
- HOWTO(0, /* type */
- 0, /* rs */
- 0, /* size */
- 8, /* bsz */
- false, /* pcrel */
- 0, /* bitpos */
- complain_overflow_bitfield, /* ovf */
- coff_arm_reloc, /* sf */
- "8", /*name */
- true, /* partial */
- 0x000000ff, /*read mask */
- 0x000000ff, /* setmask */
- PCRELOFFSET /* pcdone */),
- HOWTO(1,
- 0,
- 1,
- 16,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "16",
- true,
- 0x0000ffff,
- 0x0000ffff,
- PCRELOFFSET),
- HOWTO( 2,
- 0,
- 2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "32",
- true,
- 0xffffffff,
- 0xffffffff,
- PCRELOFFSET),
- HOWTO( 3,
- 2,
- 2,
- 26,
- true,
- 0,
- complain_overflow_signed,
- aoutarm_fix_pcrel_26 ,
- "ARM26",
- false,
- 0x00ffffff,
- 0x00ffffff,
- PCRELOFFSET),
- HOWTO( 4,
- 0,
- 0,
- 8,
- true,
- 0,
- complain_overflow_signed,
- coff_arm_reloc,
- "DISP8",
- true,
- 0x000000ff,
- 0x000000ff,
- true),
- HOWTO( 5,
- 0,
- 1,
- 16,
- true,
- 0,
- complain_overflow_signed,
- coff_arm_reloc,
- "DISP16",
- true,
- 0x0000ffff,
- 0x0000ffff,
- true),
- HOWTO( 6,
- 0,
- 2,
- 32,
- true,
- 0,
- complain_overflow_signed,
- coff_arm_reloc,
- "DISP32",
- true,
- 0xffffffff,
- 0xffffffff,
- true),
- HOWTO( 7,
- 2,
- 2,
- 26,
- false,
- 0,
- complain_overflow_signed,
- aoutarm_fix_pcrel_26_done,
- "ARM26D",
- true,
- 0x00ffffff,
- 0x00ffffff,
- false),
- {-1},
- HOWTO( 9,
- 0,
- -1,
- 16,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "NEG16",
- true,
- 0x0000ffff,
- 0x0000ffff,
- false),
- HOWTO( 10,
- 0,
- -2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "NEG32",
- true,
- 0xffffffff,
- 0xffffffff,
- false),
- HOWTO( 11,
- 0,
- 2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- coff_arm_reloc,
- "rva32",
- true,
- 0xffffffff,
- 0xffffffff,
- PCRELOFFSET),
-};
-#ifdef COFF_WITH_PE
-/* Return true if this relocation should
- appear in the output .reloc section. */
-
-static boolean in_reloc_p (abfd, howto)
- bfd * abfd;
- reloc_howto_type *howto;
-{
- return !howto->pc_relative && howto->type != 11;
-}
-#endif
-
-
-#define RTYPE2HOWTO(cache_ptr, dst) \
- (cache_ptr)->howto = aoutarm_std_reloc_howto + (dst)->r_type;
-
-#define coff_rtype_to_howto coff_arm_rtype_to_howto
-
-static reloc_howto_type *
-coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
- bfd *abfd;
- asection *sec;
- struct internal_reloc *rel;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma *addendp;
-{
- reloc_howto_type *howto;
-
- howto = aoutarm_std_reloc_howto + rel->r_type;
-
- if (rel->r_type == 11)
- {
- *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
- }
- return howto;
-
-}
-/* Used by the assembler. */
-
-static bfd_reloc_status_type
-aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- /* This is dead simple at present. */
- return bfd_reloc_ok;
-}
-
-/* Used by the assembler. */
-
-static bfd_reloc_status_type
-aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_vma relocation;
- bfd_size_type addr = reloc_entry->address;
- long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
- bfd_reloc_status_type flag = bfd_reloc_ok;
-
- /* If this is an undefined symbol, return error */
- if (symbol->section == &bfd_und_section
- && (symbol->flags & BSF_WEAK) == 0)
- return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
-
- /* If the sections are different, and we are doing a partial relocation,
- just ignore it for now. */
- if (symbol->section->name != input_section->name
- && output_bfd != (bfd *)NULL)
- return bfd_reloc_continue;
-
- relocation = (target & 0x00ffffff) << 2;
- relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
- relocation += symbol->value;
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
- relocation -= input_section->output_section->vma;
- relocation -= input_section->output_offset;
- relocation -= addr;
- if (relocation & 3)
- return bfd_reloc_overflow;
-
- /* Check for overflow */
- if (relocation & 0x02000000)
- {
- if ((relocation & ~0x03ffffff) != ~0x03ffffff)
- flag = bfd_reloc_overflow;
- }
- else if (relocation & ~0x03ffffff)
- flag = bfd_reloc_overflow;
-
- target &= ~0x00ffffff;
- target |= (relocation >> 2) & 0x00ffffff;
- bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
-
- /* Now the ARM magic... Change the reloc type so that it is marked as done.
- Strictly this is only necessary if we are doing a partial relocation. */
- reloc_entry->howto = &aoutarm_std_reloc_howto[7];
-
- return flag;
-}
-
-
-static CONST struct reloc_howto_struct *
-arm_reloc_type_lookup(abfd,code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
-#define ASTD(i,j) case i: return &aoutarm_std_reloc_howto[j]
- if (code == BFD_RELOC_CTOR)
- switch (bfd_get_arch_info (abfd)->bits_per_address)
- {
- case 32:
- code = BFD_RELOC_32;
- break;
- default: return (CONST struct reloc_howto_struct *) 0;
- }
-
- switch (code)
- {
- ASTD (BFD_RELOC_16, 1);
- ASTD (BFD_RELOC_32, 2);
- ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
- ASTD (BFD_RELOC_8_PCREL, 4);
- ASTD (BFD_RELOC_16_PCREL, 5);
- ASTD (BFD_RELOC_32_PCREL, 6);
- ASTD (BFD_RELOC_RVA, 11);
- default: return (CONST struct reloc_howto_struct *) 0;
- }
-}
-
-
-#define coff_bfd_reloc_type_lookup arm_reloc_type_lookup
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
-#define COFF_PAGE_SIZE 0x1000
-/* Turn a howto into a reloc nunmber */
-
-#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
-#define BADMAG(x) ARMBADMAG(x)
-#define ARM 1 /* Customize coffcode.h */
-
-
-/* We use the special COFF backend linker. */
-#define coff_relocate_section _bfd_coff_generic_relocate_section
-
-
-#include "coffcode.h"
-
-const bfd_target
-#ifdef TARGET_LITTLE_SYM
-TARGET_LITTLE_SYM =
-#else
-armcoff_little_vec =
-#endif
-{
-#ifdef TARGET_LITTLE_NAME
- TARGET_LITTLE_NAME,
-#else
- "coff-arm-little",
-#endif
- bfd_target_coff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-#ifdef TARGET_UNDERSCORE
- TARGET_UNDERSCORE, /* leading underscore */
-#else
- 0, /* leading underscore */
-#endif
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
-
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
-
-/* Note that we allow an object file to be treated as a core file as well. */
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_generic_archive_p, coff_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
-
-const bfd_target
-#ifdef TARGET_BIG_SYM
-TARGET_BIG_SYM =
-#else
-armcoff_big_vec =
-#endif
-{
-#ifdef TARGET_BIG_NAME
- TARGET_BIG_NAME,
-#else
- "coff-arm-big",
-#endif
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-#ifdef TARGET_UNDERSCORE
- TARGET_UNDERSCORE, /* leading underscore */
-#else
- 0, /* leading underscore */
-#endif
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
-
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
-/* Note that we allow an object file to be treated as a core file as well. */
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_generic_archive_p, coff_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-aux.c b/contrib/gdb/bfd/coff-aux.c
deleted file mode 100644
index 1dba9d5..0000000
--- a/contrib/gdb/bfd/coff-aux.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/* BFD back-end for Apple M68K COFF A/UX 3.x files.
- Copyright 1996 Free Software Foundation, Inc.
- Portions written by Richard Henderson <rth@tamu.edu>,
- COMMON symbol munging cribbed from cf-m68klynx.c which was
- written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_SYM m68kaux_coff_vec
-#define TARGET_NAME "coff-m68k-aux"
-
-#ifndef TARG_AUX
-#define TARG_AUX
-#endif
-
-#define COFF_LONG_FILENAMES
-
-/* 4k pages */
-#define COFF_PAGE_SIZE 0x1000
-
-/* On AUX, a STYP_NOLOAD|STYP_BSS section is part of a shared library. */
-#define BSS_NOLOAD_IS_SHARED_LIBRARY
-
-#define _bfd_m68kcoff_howto_table _bfd_m68kaux_howto_table
-#define _bfd_m68kcoff_rtype2howto _bfd_m68kaux_rtype2howto
-#define _bfd_m68kcoff_howto2rtype _bfd_m68kaux_howto2rtype
-#define _bfd_m68kcoff_reloc_type_lookup _bfd_m68kaux_reloc_type_lookup
-
-/* Rather than change names lots of places, reuse the same hack */
-#define LYNX_SPECIAL_FN _bfd_m68kaux_special_fn
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#ifdef ANSI_PROTOTYPES
-struct internal_reloc;
-struct coff_link_hash_entry;
-struct internal_syment;
-#endif
-
-
-static bfd_reloc_status_type _bfd_m68kaux_special_fn
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type *coff_m68k_aux_rtype_to_howto
- PARAMS ((bfd *, asection *, struct internal_reloc *,
- struct coff_link_hash_entry *, struct internal_syment *,
- bfd_vma *));
-static boolean coff_m68k_aux_link_add_one_symbol
- PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
- asection *, bfd_vma, const char *, boolean, boolean,
- struct bfd_link_hash_entry **));
-
-
-#define coff_rtype_to_howto coff_m68k_aux_rtype_to_howto
-#define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
-
-
-/* Compute the addend of a reloc. If the reloc is to a common symbol,
- the object file contains the value of the common symbol. By the
- time this is called, the linker may be using a different symbol
- from a different object file with a different value. Therefore, we
- hack wildly to locate the original symbol from this file so that we
- can make the correct adjustment. This macro sets coffsym to the
- symbol from the original file, and uses it to set the addend value
- correctly. If this is not a common symbol, the usual addend
- calculation is done, except that an additional tweak is needed for
- PC relative relocs.
- FIXME: This macro refers to symbols and asect; these are from the
- calling function, not the macro arguments. */
-
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
- { \
- coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
- if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
- coffsym = (obj_symbols (abfd) \
- + (cache_ptr->sym_ptr_ptr - symbols)); \
- else if (ptr) \
- coffsym = coff_symbol_from (abfd, ptr); \
- if (coffsym != (coff_symbol_type *) NULL \
- && coffsym->native->u.syment.n_scnum == 0) \
- cache_ptr->addend = - coffsym->native->u.syment.n_value; \
- else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
- && ptr->section != (asection *) NULL) \
- cache_ptr->addend = - (ptr->section->vma + ptr->value); \
- else \
- cache_ptr->addend = 0; \
- if (ptr && (reloc.r_type == R_PCRBYTE \
- || reloc.r_type == R_PCRWORD \
- || reloc.r_type == R_PCRLONG)) \
- cache_ptr->addend += asect->vma; \
- }
-
-
-
-#include "coff/aux-coff.h" /* override coff/internal.h and coff/m68k.h */
-#include "coff-m68k.c"
-
-
-
-/* For some reason when using m68k COFF the value stored in the .text
- section for a reference to a common symbol is the value itself plus
- any desired offset. (taken from work done by Ian Taylor, Cygnus Support,
- for I386 COFF). */
-
-/* If we are producing relocateable output, we need to do some
- adjustments to the object file that are not done by the
- bfd_perform_relocation function. This function is called by every
- reloc type to make any required adjustments. */
-
-static bfd_reloc_status_type
-_bfd_m68kaux_special_fn (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- symvalue diff;
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- if (bfd_is_com_section (symbol->section))
- {
- /* We are relocating a common symbol. The current value in the
- object file is ORIG + OFFSET, where ORIG is the value of the
- common symbol as seen by the object file when it was compiled
- (this may be zero if the symbol was undefined) and OFFSET is
- the offset into the common symbol (normally zero, but may be
- non-zero when referring to a field in a common structure).
- ORIG is the negative of reloc_entry->addend, which is set by
- the CALC_ADDEND macro below. We want to replace the value in
- the object file with NEW + OFFSET, where NEW is the value of
- the common symbol which we are going to put in the final
- object file. NEW is symbol->value. */
- diff = symbol->value + reloc_entry->addend;
- }
- else
- {
- /* For some reason bfd_perform_relocation always effectively
- ignores the addend for a COFF target when producing
- relocateable output. This seems to be always wrong for 386
- COFF, so we handle the addend here instead. */
- diff = reloc_entry->addend;
- }
-
-#define DOIT(x) \
- x = ((x & ~howto->dst_mask) | \
- (((x & howto->src_mask) + diff) & howto->dst_mask))
-
- if (diff != 0)
- {
- reloc_howto_type *howto = reloc_entry->howto;
- unsigned char *addr = (unsigned char *) data + reloc_entry->address;
-
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, addr);
- DOIT (x);
- bfd_put_8 (abfd, x, addr);
- }
- break;
-
- case 1:
- {
- short x = bfd_get_16 (abfd, addr);
- DOIT (x);
- bfd_put_16 (abfd, x, addr);
- }
- break;
-
- case 2:
- {
- long x = bfd_get_32 (abfd, addr);
- DOIT (x);
- bfd_put_32 (abfd, x, addr);
- }
- break;
-
- default:
- abort ();
- }
- }
-
- /* Now let bfd_perform_relocation finish everything up. */
- return bfd_reloc_continue;
-}
-
-
-/* coff-m68k.c uses the special COFF backend linker. We need to
- adjust common symbols. */
-
-/*ARGSUSED*/
-static reloc_howto_type *
-coff_m68k_aux_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
- bfd *abfd;
- asection *sec;
- struct internal_reloc *rel;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma *addendp;
-{
- arelent relent;
- reloc_howto_type *howto;
-
- RTYPE2HOWTO (&relent, rel);
-
- howto = relent.howto;
-
- if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
- {
- /* This is a common symbol. The section contents include the
- size (sym->n_value) as an addend. The relocate_section
- function will be adding in the final value of the symbol. We
- need to subtract out the current size in order to get the
- correct result. */
- BFD_ASSERT (h != NULL);
- *addendp -= sym->n_value;
- }
-
- /* If the output symbol is common (in which case this must be a
- relocateable link), we need to add in the final size of the
- common symbol. */
- if (h != NULL && h->root.type == bfd_link_hash_common)
- *addendp += h->root.u.c.size;
-
- return howto;
-}
-
-
-/* We need non-absolute symbols to override absolute symbols. This
- mirrors Apple's "solution" to let a static library symbol override
- a shared library symbol. On the whole not a good thing, given how
- shared libraries work here, but can work if you are careful with
- what you include in the shared object. */
-
-boolean
-coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value,
- string, copy, collect, hashp)
- struct bfd_link_info *info;
- bfd *abfd;
- const char *name;
- flagword flags;
- asection *section;
- bfd_vma value;
- const char *string;
- boolean copy;
- boolean collect;
- struct bfd_link_hash_entry **hashp;
-{
- struct bfd_link_hash_entry *h;
-
- if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 &&
- !bfd_is_und_section (section) &&
- !bfd_is_com_section (section))
- {
- /* The new symbol is a definition or an indirect definition */
-
- /* This bit copied from linker.c */
- if (hashp != NULL && *hashp != NULL)
- {
- h = *hashp;
- BFD_ASSERT (strcmp (h->root.string, name) == 0);
- }
- else
- {
- h = bfd_link_hash_lookup (info->hash, name, true, copy, false);
- if (h == NULL)
- {
- if (hashp != NULL)
- *hashp = NULL;
- return false;
- }
- }
-
- if (info->notice_hash != (struct bfd_hash_table *) NULL
- && (bfd_hash_lookup (info->notice_hash, name, false, false)
- != (struct bfd_hash_entry *) NULL))
- {
- if (! (*info->callbacks->notice) (info, name, abfd, section, value))
- return false;
- }
-
- if (hashp != (struct bfd_link_hash_entry **) NULL)
- *hashp = h;
- /* end duplication from linker.c */
-
- if (h->type == bfd_link_hash_defined
- || h->type == bfd_link_hash_indirect)
- {
- asection *msec;
-
- if (h->type == bfd_link_hash_defined)
- msec = h->u.def.section;
- else
- msec = bfd_ind_section_ptr;
-
- if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section))
- {
- h->u.def.section = section;
- h->u.def.value = value;
- return true;
- }
- else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec))
- return true;
- }
- }
-
- /* If we didn't exit early, finish processing in the generic routine */
- return _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
- value, string, copy, collect,
- hashp);
-}
diff --git a/contrib/gdb/bfd/coff-go32.c b/contrib/gdb/bfd/coff-go32.c
deleted file mode 100644
index be4adb2..0000000
--- a/contrib/gdb/bfd/coff-go32.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* BFD back-end for Intel 386 COFF files (go32 variant).
- Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by DJ Delorie.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_SYM go32coff_vec
-#define TARGET_NAME "coff-go32"
-#define TARGET_UNDERSCORE '_'
-
-#include "coff-i386.c"
diff --git a/contrib/gdb/bfd/coff-h8300.c b/contrib/gdb/bfd/coff-h8300.c
deleted file mode 100644
index 48d0d5a..0000000
--- a/contrib/gdb/bfd/coff-h8300.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/* BFD back-end for Hitachi H8/300 COFF binaries.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
- Written by Steve Chamberlain, <sac@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "obstack.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "genlink.h"
-#include "coff/h8300.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
-
-
-/* special handling for H8/300 relocs.
- We only come here for pcrel stuff and return normally if not an -r link.
- When doing -r, we can't do any arithmetic for the pcrel stuff, because
- the code in reloc.c assumes that we can manipulate the targets of
- the pcrel branches. This isn't so, since the H8/300 can do relaxing,
- which means that the gap after the instruction may not be enough to
- contain the offset required for the branch, so we have to use the only
- the addend until the final link */
-
-static bfd_reloc_status_type
-special (abfd, reloc_entry, symbol, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- return bfd_reloc_ok;
-}
-
-static reloc_howto_type howto_table[] =
-{
- HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false),
- HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false),
- HOWTO (R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, special, "DISP8", false, 0x000000ff, 0x000000ff, true),
- HOWTO (R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, special, "DISP16", false, 0x0000ffff, 0x0000ffff, true),
- HOWTO (R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, special, "DISP32", false, 0xffffffff, 0xffffffff, true),
- HOWTO (R_MOVB1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/8", false, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_MOVB2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "8/16", false, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_JMP1, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16/pcrel", false, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_JMP2, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pcrecl/16", false, 0x000000ff, 0x000000ff, false),
-
-
- HOWTO (R_JMPL1, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "24/pcrell", false, 0x00ffffff, 0x00ffffff, false),
- HOWTO (R_JMPL_B8, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "pc8/24", false, 0x000000ff, 0x000000ff, false),
-
- HOWTO (R_MOVLB1, 0, 1, 16, false, 0, complain_overflow_bitfield,special, "24/8", false, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_MOVLB2, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "8/24", false, 0x0000ffff, 0x0000ffff, false),
-
- /* An indirect reference to a function. This causes the function's address
- to be added to the function vector in lo-mem and puts the address of
- the function vector's entry in the jsr instruction. */
- HOWTO (R_MEM_INDIRECT, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8/indirect", false, 0x000000ff, 0x000000ff, false),
-
-};
-
-
-/* Turn a howto into a reloc number */
-
-#define SELECT_RELOC(x,howto) \
- { x.r_type = select_reloc(howto); }
-
-#define BADMAG(x) (H8300BADMAG(x)&& H8300HBADMAG(x))
-#define H8300 1 /* Customize coffcode.h */
-#define __A_MAGIC_SET__
-
-
-
-/* Code to swap in the reloc */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
-#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
- dst->r_stuff[0] = 'S'; \
- dst->r_stuff[1] = 'C';
-
-
-static int
-select_reloc (howto)
- reloc_howto_type *howto;
-{
- return howto->type;
-}
-
-/* Code to turn a r_type into a howto ptr, uses the above howto table
- */
-
-static void
-rtype2howto (internal, dst)
- arelent *internal;
- struct internal_reloc *dst;
-{
- switch (dst->r_type)
- {
- case R_RELBYTE:
- internal->howto = howto_table + 0;
- break;
- case R_RELWORD:
- internal->howto = howto_table + 1;
- break;
- case R_RELLONG:
- internal->howto = howto_table + 2;
- break;
- case R_PCRBYTE:
- internal->howto = howto_table + 3;
- break;
- case R_PCRWORD:
- internal->howto = howto_table + 4;
- break;
- case R_PCRLONG:
- internal->howto = howto_table + 5;
- break;
- case R_MOVB1:
- internal->howto = howto_table + 6;
- break;
- case R_MOVB2:
- internal->howto = howto_table + 7;
- break;
- case R_JMP1:
- internal->howto = howto_table + 8;
- break;
- case R_JMP2:
- internal->howto = howto_table + 9;
- break;
- case R_JMPL1:
- internal->howto = howto_table + 10;
- break;
- case R_JMPL_B8:
- internal->howto = howto_table + 11;
- break;
- case R_MOVLB1:
- internal->howto = howto_table + 12;
- break;
- case R_MOVLB2:
- internal->howto = howto_table + 13;
- break;
- case R_MEM_INDIRECT:
- internal->howto = howto_table + 14;
- break;
- default:
- abort ();
- break;
- }
-}
-
-#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
-
-
-/* Perform any necessaru magic to the addend in a reloc entry */
-
-
-#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
- cache_ptr->addend = ext_reloc.r_offset;
-
-
-#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
- reloc_processing(relent, reloc, symbols, abfd, section)
-
-static void
-reloc_processing (relent, reloc, symbols, abfd, section)
- arelent * relent;
- struct internal_reloc *reloc;
- asymbol ** symbols;
- bfd * abfd;
- asection * section;
-{
- relent->address = reloc->r_vaddr;
- rtype2howto (relent, reloc);
-
- if (((int) reloc->r_symndx) > 0)
- {
- relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
- }
- else
- {
- relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- }
-
-
-
- relent->addend = reloc->r_offset;
-
- relent->address -= section->vma;
- /* relent->section = 0;*/
-}
-
-
-static int
-h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
- bfd *abfd;
- asection *input_section;
- arelent *reloc;
- unsigned int shrink;
- struct bfd_link_info *link_info;
-{
- bfd_vma value;
- bfd_vma dot;
- bfd_vma gap;
-
- /* The address of the thing to be relocated will have moved back by
- the size of the shrink - but we don't change reloc->address here,
- since we need it to know where the relocation lives in the source
- uncooked section */
-
- /* reloc->address -= shrink; conceptual */
-
- bfd_vma address = reloc->address - shrink;
-
-
- switch (reloc->howto->type)
- {
- case R_MOVB2:
- case R_JMP2:
- shrink+=2;
- break;
-
- /* Thing is a move one byte */
- case R_MOVB1:
- value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
-
- if (value >= 0xff00)
- {
-
- /* Change the reloc type from 16bit, possible 8 to 8bit
- possible 16 */
- reloc->howto = reloc->howto + 1;
- /* The place to relc moves back by one */
- /* This will be two bytes smaller in the long run */
- shrink +=2 ;
- bfd_perform_slip(abfd, 2, input_section, address);
- }
-
- break;
- /* This is the 24 bit branch which could become an 8 bitter,
- the relocation points to the first byte of the insn, not the
- actual data */
-
- case R_JMPL1:
- value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
-
- dot = input_section->output_section->vma +
- input_section->output_offset + address;
-
- /* See if the address we're looking at within 127 bytes of where
- we are, if so then we can use a small branch rather than the
- jump we were going to */
-
- gap = value - dot ;
-
- if (-120 < (long)gap && (long)gap < 120 )
- {
-
- /* Change the reloc type from 24bit, possible 8 to 8bit
- possible 32 */
- reloc->howto = reloc->howto + 1;
- /* This will be two bytes smaller in the long run */
- shrink +=2 ;
- bfd_perform_slip(abfd, 2, input_section, address);
- }
- break;
-
- case R_JMP1:
-
- value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
-
- dot = input_section->output_section->vma +
- input_section->output_offset + address;
-
- /* See if the address we're looking at within 127 bytes of where
- we are, if so then we can use a small branch rather than the
- jump we were going to */
-
- gap = value - (dot - shrink);
-
-
- if (-120 < (long)gap && (long)gap < 120 )
- {
-
- /* Change the reloc type from 16bit, possible 8 to 8bit
- possible 16 */
- reloc->howto = reloc->howto + 1;
- /* The place to relc moves back by one */
-
- /* This will be two bytes smaller in the long run */
- shrink +=2 ;
- bfd_perform_slip(abfd, 2, input_section, address);
- }
- break;
- }
-
-
- return shrink;
-}
-
-
-/* First phase of a relaxing link */
-
-/* Reloc types
- large small
- R_MOVB1 R_MOVB2 mov.b with 16bit or 8 bit address
- R_JMP1 R_JMP2 jmp or pcrel branch
- R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
- R_MOVLB1 R_MOVLB2 24 or 8 bit reloc for mov.b
-
-*/
-
-static void
-h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
- dst_ptr)
- bfd *abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- arelent *reloc;
- bfd_byte *data;
- unsigned int *src_ptr;
- unsigned int *dst_ptr;
-{
- unsigned int src_address = *src_ptr;
- unsigned int dst_address = *dst_ptr;
- asection *input_section = link_order->u.indirect.section;
-
- switch (reloc->howto->type)
- {
- /* A 24 bit branch which could be a 8 bit pcrel, really pointing to
- the byte before the 24bit hole, so we can treat it as a 32bit pointer */
- case R_PCRBYTE:
- {
- bfd_vma dot = link_order->offset
- + dst_address
- + link_order->u.indirect.section->output_section->vma;
- int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
- - dot);
- if (gap > 127 || gap < -128)
- {
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
- reloc->howto->name, reloc->addend, input_section->owner,
- input_section, reloc->address)))
- abort ();
- }
- gap &= ~1;
- bfd_put_8 (abfd, gap, data + dst_address);
- dst_address++;
- src_address++;
-
- break;
- }
- case R_PCRWORD:
- {
- bfd_vma dot = link_order->offset
- + dst_address
- + link_order->u.indirect.section->output_section->vma;
- int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
- - dot) - 1;
- if (gap > 32767 || gap < -32768)
- {
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
- reloc->howto->name, reloc->addend, input_section->owner,
- input_section, reloc->address)))
- abort ();
- }
-
- bfd_put_16 (abfd, gap, data + dst_address);
- dst_address+=2;
- src_address+=2;
-
- break;
- }
-
- case R_MEM_INDIRECT: /* Temporary */
- case R_RELBYTE:
- {
- unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- if (gap < 0xff
- || (gap >= 0x0000ff00
- && gap <= 0x0000ffff)
- || ( gap >= 0x00ffff00
- && gap <= 0x00ffffff)
- || ( gap >= 0xffffff00
- && gap <= 0xffffffff))
- {
- bfd_put_8 (abfd, gap, data + dst_address);
- dst_address += 1;
- src_address += 1;
- }
- else
- {
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
- reloc->howto->name, reloc->addend, input_section->owner,
- input_section, reloc->address)))
- abort ();
- }
- }
- break;
- case R_JMP1:
- /* A relword which would have like to have been a pcrel */
- case R_MOVB1:
- /* A relword which would like to have been modified but
- didn't make it */
- case R_RELWORD:
- bfd_put_16 (abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- data + dst_address);
- dst_address += 2;
- src_address += 2;
- break;
- case R_RELLONG:
- bfd_put_32 (abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- data + dst_address);
- dst_address += 4;
- src_address += 4;
- break;
-
- case R_MOVB2:
- /* Special relaxed type, there will be a gap between where we
- get stuff from and where we put stuff to now
-
- for a mov.b @aa:16 -> mov.b @aa:8
- opcode 0x6a 0x0y offset
- -> 0x2y off
- */
- if (data[dst_address - 1] != 0x6a)
- abort ();
- switch (data[src_address] & 0xf0)
- {
- case 0x00:
- /* Src is memory */
- data[dst_address - 1] = (data[src_address] & 0xf) | 0x20;
- break;
- case 0x80:
- /* Src is reg */
- data[dst_address - 1] = (data[src_address] & 0xf) | 0x30;
- break;
- default:
- abort ();
- }
-
- /* the offset must fit ! after all, what was all the relaxing
- about ? */
-
- bfd_put_8 (abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- data + dst_address);
-
- /* Note the magic - src goes up by two bytes, but dst by only
- one */
- dst_address += 1;
- src_address += 3;
-
- break;
-
- case R_JMP2:
-
- /* Speciial relaxed type */
- {
- bfd_vma dot = link_order->offset
- + dst_address
- + link_order->u.indirect.section->output_section->vma;
-
- int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
- - dot - 1);
-
- if ((gap & ~0xff) != 0 && ((gap & 0xff00) != 0xff00))
- abort ();
-
- bfd_put_8 (abfd, gap, data + dst_address);
-
- switch (data[dst_address - 1])
- {
- case 0x5e:
- /* jsr -> bsr */
- bfd_put_8 (abfd, 0x55, data + dst_address - 1);
- break;
- case 0x5a:
- /* jmp ->bra */
- bfd_put_8 (abfd, 0x40, data + dst_address - 1);
- break;
-
- default:
- abort ();
- }
- dst_address++;
- src_address += 3;
-
- break;
- }
- break;
-
- case R_JMPL_B8: /* 24 bit branch which is now 8 bits */
-
- /* Speciial relaxed type */
- {
- bfd_vma dot = link_order->offset
- + dst_address
- + link_order->u.indirect.section->output_section->vma;
-
- int gap = (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
- - dot - 2);
-
- if ((gap & ~0xff) != 0 && ((gap & 0xff00) != 0xff00))
- abort ();
-
- switch (data[src_address])
- {
- case 0x5e:
- /* jsr -> bsr */
- bfd_put_8 (abfd, 0x55, data + dst_address);
- break;
- case 0x5a:
- /* jmp ->bra */
- bfd_put_8 (abfd, 0x40, data + dst_address);
- break;
-
- default:
- bfd_put_8 (abfd, 0xde, data + dst_address);
- break;
- }
-
- bfd_put_8 (abfd, gap, data + dst_address + 1);
- dst_address += 2;
- src_address += 4;
-
- break;
- }
-
- case R_JMPL1:
- {
- int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
- int o = bfd_get_32 (abfd, data + src_address);
- v = (v & 0x00ffffff) | (o & 0xff000000);
- bfd_put_32 (abfd, v, data + dst_address);
- dst_address += 4;
- src_address += 4;
- }
-
- break;
-
-
- /* A 24 bit mov which could be an 8 bit move, really pointing to
- the byte before the 24bit hole, so we can treat it as a 32bit pointer */
- case R_MOVLB1:
- {
- int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
- int o = bfd_get_32 (abfd, data + dst_address);
- v = (v & 0x00ffffff) | (o & 0xff000000);
- bfd_put_32 (abfd, v, data + dst_address);
- dst_address += 4;
- src_address += 4;
- }
-
- break;
- default:
-
- abort ();
- break;
-
- }
- *src_ptr = src_address;
- *dst_ptr = dst_address;
-
-}
-
-#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
-#define coff_reloc16_estimate h8300_reloc16_estimate
-
-#define COFF_LONG_FILENAMES
-#include "coffcode.h"
-
-
-#undef coff_bfd_get_relocated_section_contents
-#undef coff_bfd_relax_section
-#define coff_bfd_get_relocated_section_contents \
- bfd_coff_reloc16_get_relocated_section_contents
-#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
-
-
-
-const bfd_target h8300coff_vec =
-{
- "coff-h8300", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading char */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-h8500.c b/contrib/gdb/bfd/coff-h8500.c
deleted file mode 100644
index f416f8f..0000000
--- a/contrib/gdb/bfd/coff-h8500.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/* BFD back-end for Hitachi H8/500 COFF binaries.
- Copyright 1993, 1994 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
- Written by Steve Chamberlain, <sac@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "obstack.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "coff/h8500.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
-
-static reloc_howto_type r_imm8 =
-HOWTO (R_H8500_IMM8, 0, 1, 8, false, 0,
- complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff, false);
-
-static reloc_howto_type r_imm16 =
-HOWTO (R_H8500_IMM16, 0, 1, 16, false, 0,
- complain_overflow_bitfield, 0, "r_imm16", true, 0x0000ffff, 0x0000ffff, false);
-
-static reloc_howto_type r_imm24 =
-HOWTO (R_H8500_IMM24, 0, 1, 24, false, 0,
- complain_overflow_bitfield, 0, "r_imm24", true, 0x00ffffff, 0x00ffffff, false);
-
-static reloc_howto_type r_imm32 =
-HOWTO (R_H8500_IMM32, 0, 1, 32, false, 0,
- complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff, 0xffffffff, false);
-
-
-static reloc_howto_type r_high8 =
-HOWTO (R_H8500_HIGH8, 0, 1, 8, false, 0,
- complain_overflow_dont, 0, "r_high8", true, 0x000000ff, 0x000000ff, false);
-
-static reloc_howto_type r_low16 =
-HOWTO (R_H8500_LOW16, 0, 1, 16, false, 0,
- complain_overflow_dont, 0, "r_low16", true, 0x0000ffff, 0x0000ffff, false);
-
-static reloc_howto_type r_pcrel8 =
-HOWTO (R_H8500_PCREL8, 0, 1, 8, true, 0, complain_overflow_signed, 0, "r_pcrel8", true, 0, 0, true);
-
-
-static reloc_howto_type r_pcrel16 =
-HOWTO (R_H8500_PCREL16, 0, 1, 16, true, 0, complain_overflow_signed, 0, "r_pcrel16", true, 0, 0, true);
-
-static reloc_howto_type r_high16 =
-HOWTO (R_H8500_HIGH16, 0, 1, 8, false, 0,
- complain_overflow_dont, 0, "r_high16", true, 0x000ffff, 0x0000ffff, false);
-
-
-/* Turn a howto into a reloc number */
-
-static int
-coff_h8500_select_reloc (howto)
- reloc_howto_type *howto;
-{
- return howto->type;
-}
-
-#define SELECT_RELOC(x,howto) x.r_type = coff_h8500_select_reloc(howto)
-
-
-#define BADMAG(x) H8500BADMAG(x)
-#define H8500 1 /* Customize coffcode.h */
-
-#define __A_MAGIC_SET__
-
-/* Code to swap in the reloc */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
-#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
- dst->r_stuff[0] = 'S'; \
- dst->r_stuff[1] = 'C';
-
-/* Code to turn a r_type into a howto ptr, uses the above howto table
- */
-
-static void
-rtype2howto(internal, dst)
- arelent * internal;
- struct internal_reloc *dst;
-{
- switch (dst->r_type)
- {
- default:
- abort ();
- break;
- case R_H8500_IMM8:
- internal->howto = &r_imm8;
- break;
- case R_H8500_IMM16:
- internal->howto = &r_imm16;
- break;
- case R_H8500_IMM24:
- internal->howto = &r_imm24;
- break;
- case R_H8500_IMM32:
- internal->howto = &r_imm32;
- break;
- case R_H8500_PCREL8:
- internal->howto = &r_pcrel8;
- break;
- case R_H8500_PCREL16:
- internal->howto = &r_pcrel16;
- break;
- case R_H8500_HIGH8:
- internal->howto = &r_high8;
- break;
- case R_H8500_HIGH16:
- internal->howto = &r_high16;
- break;
- case R_H8500_LOW16:
- internal->howto = &r_low16;
- break;
- }
-}
-
-#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
-
-
-/* Perform any necessaru magic to the addend in a reloc entry */
-
-
-#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
- cache_ptr->addend = ext_reloc.r_offset;
-
-
-#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
- reloc_processing(relent, reloc, symbols, abfd, section)
-
-static void reloc_processing (relent, reloc, symbols, abfd, section)
- arelent * relent;
- struct internal_reloc *reloc;
- asymbol ** symbols;
- bfd * abfd;
- asection * section;
-{
- relent->address = reloc->r_vaddr;
- rtype2howto (relent, reloc);
-
- if (reloc->r_symndx > 0)
- {
- relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
- }
- else
- {
- relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- }
-
-
- relent->addend = reloc->r_offset;
- relent->address -= section->vma;
-}
-
-static void
-extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
- bfd *in_abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- arelent *reloc;
- bfd_byte *data;
- unsigned int *src_ptr;
- unsigned int *dst_ptr;
-{
- bfd_byte *d = data+*dst_ptr;
- asection *input_section = link_order->u.indirect.section;
- switch (reloc->howto->type)
- {
- case R_H8500_IMM8:
- bfd_put_8 (in_abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- d);
- (*dst_ptr) += 1;
- (*src_ptr) += 1;
- break;
-
- case R_H8500_HIGH8:
- bfd_put_8 (in_abfd,
- (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
- >> 16),
- d );
- (*dst_ptr) += 1;
- (*src_ptr) += 1;
- break;
-
- case R_H8500_IMM16:
- bfd_put_16 (in_abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- d );
- (*dst_ptr) += 2;
- (*src_ptr) += 2;
- break;
-
- case R_H8500_LOW16:
- bfd_put_16 (in_abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- d);
-
- (*dst_ptr) += 2;
- (*src_ptr) += 2;
- break;
-
- case R_H8500_HIGH16:
- bfd_put_16 (in_abfd,
- (bfd_coff_reloc16_get_value (reloc, link_info, input_section)
- >>16),
- d);
-
- (*dst_ptr) += 2;
- (*src_ptr) += 2;
- break;
-
- case R_H8500_IMM24:
- {
- int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
- int o = bfd_get_32(in_abfd, data+ *dst_ptr -1);
- v = (v & 0x00ffffff) | (o & 0xff00000);
- bfd_put_32 (in_abfd, v, data + *dst_ptr -1);
- (*dst_ptr) +=3;
- (*src_ptr)+=3;;
- }
- break;
- case R_H8500_IMM32:
- {
- int v = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
- bfd_put_32 (in_abfd, v, data + *dst_ptr);
- (*dst_ptr) +=4;
- (*src_ptr)+=4;;
- }
- break;
-
-
- case R_H8500_PCREL8:
- {
- bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- bfd_vma dot = link_order->offset
- + *dst_ptr
- + link_order->u.indirect.section->output_section->vma;
- int gap = dst - dot - 1; /* -1 since were in the odd byte of the
- word and the pc's been incremented */
-
- if (gap > 128 || gap < -128)
- {
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
- reloc->howto->name, reloc->addend, input_section->owner,
- input_section, reloc->address)))
- abort ();
- }
- bfd_put_8 (in_abfd, gap, data + *dst_ptr);
- (*dst_ptr)++;
- (*src_ptr)++;
- break;
- }
- case R_H8500_PCREL16:
- {
- bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- bfd_vma dot = link_order->offset
- + *dst_ptr
- + link_order->u.indirect.section->output_section->vma;
- int gap = dst - dot - 1; /* -1 since were in the odd byte of the
- word and the pc's been incremented */
-
- if (gap > 32767 || gap < -32768)
- {
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
- reloc->howto->name, reloc->addend, input_section->owner,
- input_section, reloc->address)))
- abort ();
- }
- bfd_put_16 (in_abfd, gap, data + *dst_ptr);
- (*dst_ptr)+=2;
- (*src_ptr)+=2;
- break;
- }
-
- default:
- abort ();
- }
-}
-
-#define coff_reloc16_extra_cases extra_case
-
-#include "coffcode.h"
-
-
-#undef coff_bfd_get_relocated_section_contents
-#undef coff_bfd_relax_section
-#define coff_bfd_get_relocated_section_contents \
- bfd_coff_reloc16_get_relocated_section_contents
-#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
-
-const bfd_target h8500coff_vec =
-{
- "coff-h8500", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading symbol underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-i860.c b/contrib/gdb/bfd/coff-i860.c
deleted file mode 100644
index 9605cdf..0000000
--- a/contrib/gdb/bfd/coff-i860.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/* BFD back-end for Intel 860 COFF files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
- Created mostly by substituting "860" for "386" in coff-i386.c
- Harry Dolan <dolan@ssd.intel.com>, October 1995
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-
-#include "coff/i860.h"
-
-#include "coff/internal.h"
-
-#include "libcoff.h"
-
-static bfd_reloc_status_type coff_i860_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type *coff_i860_rtype_to_howto
- PARAMS ((bfd *, asection *, struct internal_reloc *,
- struct coff_link_hash_entry *, struct internal_syment *,
- bfd_vma *));
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
-/* The page size is a guess based on ELF. */
-
-#define COFF_PAGE_SIZE 0x1000
-
-/* For some reason when using i860 COFF the value stored in the .text
- section for a reference to a common symbol is the value itself plus
- any desired offset. Ian Taylor, Cygnus Support. */
-
-/* If we are producing relocateable output, we need to do some
- adjustments to the object file that are not done by the
- bfd_perform_relocation function. This function is called by every
- reloc type to make any required adjustments. */
-
-static bfd_reloc_status_type
-coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- symvalue diff;
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
-
- if (bfd_is_com_section (symbol->section))
- {
- /* We are relocating a common symbol. The current value in the
- object file is ORIG + OFFSET, where ORIG is the value of the
- common symbol as seen by the object file when it was compiled
- (this may be zero if the symbol was undefined) and OFFSET is
- the offset into the common symbol (normally zero, but may be
- non-zero when referring to a field in a common structure).
- ORIG is the negative of reloc_entry->addend, which is set by
- the CALC_ADDEND macro below. We want to replace the value in
- the object file with NEW + OFFSET, where NEW is the value of
- the common symbol which we are going to put in the final
- object file. NEW is symbol->value. */
- diff = symbol->value + reloc_entry->addend;
- }
- else
- {
- /* For some reason bfd_perform_relocation always effectively
- ignores the addend for a COFF target when producing
- relocateable output. This seems to be always wrong for 860
- COFF, so we handle the addend here instead. */
- diff = reloc_entry->addend;
- }
-
-
-#define DOIT(x) \
- x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
-
- if (diff != 0)
- {
- reloc_howto_type *howto = reloc_entry->howto;
- unsigned char *addr = (unsigned char *) data + reloc_entry->address;
-
- switch (howto->size)
- {
- case 0:
- {
- char x = bfd_get_8 (abfd, addr);
- DOIT (x);
- bfd_put_8 (abfd, x, addr);
- }
- break;
-
- case 1:
- {
- short x = bfd_get_16 (abfd, addr);
- DOIT (x);
- bfd_put_16 (abfd, x, addr);
- }
- break;
-
- case 2:
- {
- long x = bfd_get_32 (abfd, addr);
- DOIT (x);
- bfd_put_32 (abfd, x, addr);
- }
- break;
-
- default:
- abort ();
- }
- }
-
- /* Now let bfd_perform_relocation finish everything up. */
- return bfd_reloc_continue;
-}
-
-#ifndef PCRELOFFSET
-#define PCRELOFFSET false
-#endif
-
-static reloc_howto_type howto_table[] =
-{
- {0},
- {1},
- {2},
- {3},
- {4},
- {5},
- HOWTO (R_DIR32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i860_reloc, /* special_function */
- "dir32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- true), /* pcrel_offset */
- /* {7}, */
- HOWTO (R_IMAGEBASE, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i860_reloc, /* special_function */
- "rva32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
- {010},
- {011},
- {012},
- {013},
- {014},
- {015},
- {016},
- HOWTO (R_RELBYTE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i860_reloc, /* special_function */
- "8", /* name */
- true, /* partial_inplace */
- 0x000000ff, /* src_mask */
- 0x000000ff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_RELWORD, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i860_reloc, /* special_function */
- "16", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_RELLONG, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- coff_i860_reloc, /* special_function */
- "32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_PCRBYTE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- coff_i860_reloc, /* special_function */
- "DISP8", /* name */
- true, /* partial_inplace */
- 0x000000ff, /* src_mask */
- 0x000000ff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_PCRWORD, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- coff_i860_reloc, /* special_function */
- "DISP16", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- PCRELOFFSET), /* pcrel_offset */
- HOWTO (R_PCRLONG, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- coff_i860_reloc, /* special_function */
- "DISP32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- PCRELOFFSET) /* pcrel_offset */
-};
-
-/* Turn a howto into a reloc nunmber */
-
-#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
-#define BADMAG(x) I860BADMAG(x)
-#define I860 1 /* Customize coffcode.h */
-
-#define RTYPE2HOWTO(cache_ptr, dst) \
- (cache_ptr)->howto = howto_table + (dst)->r_type;
-
-/* For 860 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared
- library. On some other COFF targets STYP_BSS is normally
- STYP_NOLOAD. */
-#define BSS_NOLOAD_IS_SHARED_LIBRARY
-
-/* Compute the addend of a reloc. If the reloc is to a common symbol,
- the object file contains the value of the common symbol. By the
- time this is called, the linker may be using a different symbol
- from a different object file with a different value. Therefore, we
- hack wildly to locate the original symbol from this file so that we
- can make the correct adjustment. This macro sets coffsym to the
- symbol from the original file, and uses it to set the addend value
- correctly. If this is not a common symbol, the usual addend
- calculation is done, except that an additional tweak is needed for
- PC relative relocs.
- FIXME: This macro refers to symbols and asect; these are from the
- calling function, not the macro arguments. */
-
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
- { \
- coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
- if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
- coffsym = (obj_symbols (abfd) \
- + (cache_ptr->sym_ptr_ptr - symbols)); \
- else if (ptr) \
- coffsym = coff_symbol_from (abfd, ptr); \
- if (coffsym != (coff_symbol_type *) NULL \
- && coffsym->native->u.syment.n_scnum == 0) \
- cache_ptr->addend = - coffsym->native->u.syment.n_value; \
- else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
- && ptr->section != (asection *) NULL) \
- cache_ptr->addend = - (ptr->section->vma + ptr->value); \
- else \
- cache_ptr->addend = 0; \
- if (ptr && howto_table[reloc.r_type].pc_relative) \
- cache_ptr->addend += asect->vma; \
- }
-
-/* We use the special COFF backend linker. */
-#define coff_relocate_section _bfd_coff_generic_relocate_section
-
-static reloc_howto_type *
-coff_i860_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
- bfd *abfd;
- asection *sec;
- struct internal_reloc *rel;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma *addendp;
-{
-
- reloc_howto_type *howto;
-
- howto = howto_table + rel->r_type;
-
- if (howto->pc_relative)
- *addendp += sec->vma;
-
- if (sym != NULL && sym->n_scnum == 0 && sym->n_value != 0)
- {
- /* This is a common symbol. The section contents include the
- size (sym->n_value) as an addend. The relocate_section
- function will be adding in the final value of the symbol. We
- need to subtract out the current size in order to get the
- correct result. */
-
- BFD_ASSERT (h != NULL);
-
-
- /* I think we *do* want to bypass this. If we don't, I have seen some data
- parameters get the wrong relcation address. If I link two versions
- with and without this section bypassed and then do a binary comparison,
- the addresses which are different can be looked up in the map. The
- case in which this section has been bypassed has addresses which correspond
- to values I can find in the map */
- *addendp -= sym->n_value;
- }
-
- /* If the output symbol is common (in which case this must be a
- relocateable link), we need to add in the final size of the
- common symbol. */
- if (h != NULL && h->root.type == bfd_link_hash_common)
- *addendp += h->root.u.c.size;
-
- return howto;
-}
-
-#define coff_rtype_to_howto coff_i860_rtype_to_howto
-
-#include "coffcode.h"
-
-static const bfd_target *
-i3coff_object_p(a)
- bfd *a;
-{
- return coff_object_p(a);
-}
-
-const bfd_target
-#ifdef TARGET_SYM
- TARGET_SYM =
-#else
- i860coff_vec =
-#endif
-{
-#ifdef TARGET_NAME
- TARGET_NAME,
-#else
- "coff-i860", /* name */
-#endif
- bfd_target_coff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
-
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-i960.c b/contrib/gdb/bfd/coff-i960.c
deleted file mode 100644
index ed30125..0000000
--- a/contrib/gdb/bfd/coff-i960.c
+++ /dev/null
@@ -1,683 +0,0 @@
-/* BFD back-end for Intel 960 COFF files.
- Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define I960 1
-#define BADMAG(x) I960BADMAG(x)
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "coff/i960.h"
-#include "coff/internal.h"
-#include "libcoff.h" /* to allow easier abstraction-breaking */
-
-static bfd_reloc_status_type optcall_callback
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_reloc_status_type coff_i960_relocate
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type *coff_i960_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-static boolean coff_i960_start_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean coff_i960_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- struct internal_reloc *, struct internal_syment *, asection **));
-static boolean coff_i960_adjust_symndx
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
- struct internal_reloc *, boolean *));
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-
-/* The i960 does not support an MMU, so COFF_PAGE_SIZE can be
- arbitrarily small. */
-#define COFF_PAGE_SIZE 1
-
-#define COFF_LONG_FILENAMES
-
-/* This is just like the usual CALC_ADDEND, but it includes the
- section VMA for PC relative relocs. */
-#ifndef CALC_ADDEND
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
- { \
- coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
- if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
- coffsym = (obj_symbols (abfd) \
- + (cache_ptr->sym_ptr_ptr - symbols)); \
- else if (ptr) \
- coffsym = coff_symbol_from (abfd, ptr); \
- if (coffsym != (coff_symbol_type *) NULL \
- && coffsym->native->u.syment.n_scnum == 0) \
- cache_ptr->addend = 0; \
- else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
- && ptr->section != (asection *) NULL) \
- cache_ptr->addend = - (ptr->section->vma + ptr->value); \
- else \
- cache_ptr->addend = 0; \
- if (ptr && (reloc.r_type == 25 || reloc.r_type == 27)) \
- cache_ptr->addend += asect->vma; \
- }
-#endif
-
-#define CALLS 0x66003800 /* Template for 'calls' instruction */
-#define BAL 0x0b000000 /* Template for 'bal' instruction */
-#define BAL_MASK 0x00ffffff
-
-static bfd_reloc_status_type
-optcall_callback (abfd, reloc_entry, symbol_in, data,
- input_section, ignore_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol_in;
- PTR data;
- asection *input_section;
- bfd *ignore_bfd;
- char **error_message;
-{
- /* 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_type result;
- coff_symbol_type *cs = coffsymbol(symbol_in);
-
- /* Don't do anything with symbols which aren't tied up yet,
- except move the reloc. */
- if (bfd_is_und_section (cs->symbol.section)) {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* So the target symbol has to be of coff type, and the symbol
- has to have the correct native information within it */
- if ((bfd_asymbol_flavour(&cs->symbol) != bfd_target_coff_flavour)
- || (cs->native == (combined_entry_type *)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. */
- *error_message =
- (char *) "uncertain calling convention for non-COFF symbol";
- result = bfd_reloc_dangerous;
- }
- else
- {
- switch (cs->native->u.syment.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 = &((cs->native+2)->u.auxent);
- int word = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
- int olf = (aux->x_bal.x_balntry - cs->native->u.syment.n_value);
- BFD_ASSERT(cs->native->u.syment.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, (bfd_byte *) 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);
- result = bfd_reloc_ok;
- break;
- default:
- result = bfd_reloc_ok;
- break;
- }
- }
- return result;
-}
-
-/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
- appear to correctly handle a reloc against a symbol defined in the
- same object file. It appears to simply discard such relocs, rather
- than adding their values into the object file. We handle this here
- by converting all relocs against defined symbols into relocs
- against the section symbol, when generating a relocateable output
- file.
-
- Note that this function is only called if we are not using the COFF
- specific backend linker. It only does something when doing a
- relocateable link, which will almost certainly fail when not
- generating COFF i960 output, so this function is actually no longer
- useful. It was used before this target was converted to use the
- COFF specific backend linker. */
-
-static bfd_reloc_status_type
-coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- asection *osec;
-
- if (output_bfd == NULL)
- {
- /* Not generating relocateable output file. */
- return bfd_reloc_continue;
- }
-
- if (bfd_is_und_section (bfd_get_section (symbol)))
- {
- /* Symbol is not defined, so no need to worry about it. */
- return bfd_reloc_continue;
- }
-
- if (bfd_is_com_section (bfd_get_section (symbol)))
- {
- /* I don't really know what the right action is for a common
- symbol. */
- return bfd_reloc_continue;
- }
-
- /* Convert the reloc to use the section symbol. FIXME: This method
- is ridiculous. */
- osec = bfd_get_section (symbol)->output_section;
- if (coff_section_data (output_bfd, osec) != NULL
- && coff_section_data (output_bfd, osec)->tdata != NULL)
- reloc_entry->sym_ptr_ptr =
- (asymbol **) coff_section_data (output_bfd, osec)->tdata;
- else
- {
- const char *sec_name;
- asymbol **syms, **sym_end;
-
- sec_name = bfd_get_section_name (output_bfd, osec);
- syms = bfd_get_outsymbols (output_bfd);
- sym_end = syms + bfd_get_symcount (output_bfd);
- for (; syms < sym_end; syms++)
- {
- if (bfd_asymbol_name (*syms) != NULL
- && (*syms)->value == 0
- && strcmp ((*syms)->section->output_section->name,
- sec_name) == 0)
- break;
- }
-
- if (syms >= sym_end)
- abort ();
-
- reloc_entry->sym_ptr_ptr = syms;
-
- if (coff_section_data (output_bfd, osec) == NULL)
- {
- osec->used_by_bfd =
- ((PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata)));
- if (osec->used_by_bfd == NULL)
- return bfd_reloc_overflow;
- }
- coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
- }
-
- /* Let bfd_perform_relocation do its thing, which will include
- stuffing the symbol addend into the object file. */
- return bfd_reloc_continue;
-}
-
-static reloc_howto_type howto_rellong =
- HOWTO ((unsigned int) R_RELLONG, 0, 2, 32,false, 0,
- complain_overflow_bitfield, coff_i960_relocate,"rellong", true,
- 0xffffffff, 0xffffffff, 0);
-static reloc_howto_type howto_iprmed =
- HOWTO (R_IPRMED, 0, 2, 24,true,0, complain_overflow_signed,
- coff_i960_relocate, "iprmed ", true, 0x00ffffff, 0x00ffffff, 0);
-static reloc_howto_type howto_optcall =
- HOWTO (R_OPTCALL, 0,2,24,true,0, complain_overflow_signed,
- optcall_callback, "optcall", true, 0x00ffffff, 0x00ffffff, 0);
-
-static reloc_howto_type *
-coff_i960_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- default:
- return 0;
- case BFD_RELOC_I960_CALLJ:
- return &howto_optcall;
- case BFD_RELOC_32:
- case BFD_RELOC_CTOR:
- return &howto_rellong;
- case BFD_RELOC_24_PCREL:
- return &howto_iprmed;
- }
-}
-
-/* The real code is in coffcode.h */
-
-#define RTYPE2HOWTO(cache_ptr, dst) \
-{ \
- reloc_howto_type *howto_ptr; \
- switch ((dst)->r_type) { \
- case 17: howto_ptr = &howto_rellong; break; \
- case 25: howto_ptr = &howto_iprmed; break; \
- case 27: howto_ptr = &howto_optcall; break; \
- default: howto_ptr = 0; break; \
- } \
- (cache_ptr)->howto = howto_ptr; \
- }
-
-/* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
- appear to correctly handle a reloc against a symbol defined in the
- same object file. It appears to simply discard such relocs, rather
- than adding their values into the object file. We handle this by
- converting all relocs against global symbols into relocs against
- internal symbols at the start of the section. This routine is
- called at the start of the linking process, and it creates the
- necessary symbols. */
-
-static boolean
-coff_i960_start_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- bfd_size_type symesz = bfd_coff_symesz (abfd);
- asection *o;
- bfd_byte *esym;
-
- if (! info->relocateable)
- return true;
-
- esym = (bfd_byte *) bfd_malloc (symesz);
- if (esym == NULL)
- return false;
-
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
- return false;
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- struct internal_syment isym;
-
- strncpy (isym._n._n_name, o->name, SYMNMLEN);
- isym.n_value = 0;
- isym.n_scnum = o->target_index;
- isym.n_type = T_NULL;
- isym.n_sclass = C_STAT;
- isym.n_numaux = 0;
-
- bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
-
- if (bfd_write (esym, symesz, 1, abfd) != symesz)
- {
- free (esym);
- return false;
- }
-
- obj_raw_syment_count (abfd) += 1;
- }
-
- free (esym);
-
- return true;
-}
-
-/* The reloc processing routine for the optimized COFF linker. */
-
-static boolean
-coff_i960_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, syms, sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- struct internal_reloc *relocs;
- struct internal_syment *syms;
- asection **sections;
-{
- struct internal_reloc *rel;
- struct internal_reloc *relend;
-
- rel = relocs;
- relend = rel + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- long symndx;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma addend;
- bfd_vma val;
- reloc_howto_type *howto;
- bfd_reloc_status_type rstat = bfd_reloc_ok;
- boolean done;
-
- symndx = rel->r_symndx;
-
- if (symndx == -1)
- {
- h = NULL;
- sym = NULL;
- }
- else
- {
- h = obj_coff_sym_hashes (input_bfd)[symndx];
- sym = syms + symndx;
- }
-
- if (sym != NULL && sym->n_scnum != 0)
- addend = - sym->n_value;
- else
- addend = 0;
-
- switch (rel->r_type)
- {
- case 17: howto = &howto_rellong; break;
- case 25: howto = &howto_iprmed; break;
- case 27: howto = &howto_optcall; break;
- default:
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- val = 0;
-
- if (h == NULL)
- {
- asection *sec;
-
- if (symndx == -1)
- {
- sec = bfd_abs_section_ptr;
- val = 0;
- }
- else
- {
- sec = sections[symndx];
- val = (sec->output_section->vma
- + sec->output_offset
- + sym->n_value
- - sec->vma);
- }
- }
- else
- {
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *sec;
-
- sec = h->root.u.def.section;
- val = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (! info->relocateable)
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
-
- done = false;
-
- if (howto->type == R_OPTCALL && ! info->relocateable && symndx != -1)
- {
- int class;
-
- if (h != NULL)
- class = h->class;
- else
- class = sym->n_sclass;
-
- switch (class)
- {
- case C_NULL:
- /* This symbol is apparently not from a COFF input file.
- We warn, and then assume that it is not a leaf
- function. */
- if (! ((*info->callbacks->reloc_dangerous)
- (info,
- "uncertain calling convention for non-COFF symbol",
- input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return false;
- break;
- case C_LEAFSTAT:
- case C_LEAFEXT:
- /* This is a call to a leaf procedure; use the bal
- instruction. */
- {
- long olf;
- unsigned long word;
-
- if (h != NULL)
- {
- BFD_ASSERT (h->numaux == 2);
- olf = h->aux[1].x_bal.x_balntry;
- }
- else
- {
- bfd_byte *esyms;
- union internal_auxent aux;
-
- BFD_ASSERT (sym->n_numaux == 2);
- esyms = (bfd_byte *) obj_coff_external_syms (input_bfd);
- esyms += (symndx + 2) * bfd_coff_symesz (input_bfd);
- bfd_coff_swap_aux_in (input_bfd, (PTR) esyms, sym->n_type,
- sym->n_sclass, 1, sym->n_numaux,
- (PTR) &aux);
- olf = aux.x_bal.x_balntry;
- }
-
- word = bfd_get_32 (input_bfd,
- (contents
- + (rel->r_vaddr - input_section->vma)));
- word = ((word + olf - val) & BAL_MASK) | BAL;
- bfd_put_32 (input_bfd,
- word,
- (contents
- + (rel->r_vaddr - input_section->vma)));
- done = true;
- }
- break;
- case C_SCALL:
- BFD_ASSERT (0);
- break;
- }
- }
-
- if (! done)
- {
- if (howto->pc_relative)
- addend += input_section->vma;
- rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents,
- rel->r_vaddr - input_section->vma,
- val, addend);
- }
-
- switch (rstat)
- {
- default:
- abort ();
- case bfd_reloc_ok:
- break;
- case bfd_reloc_overflow:
- {
- const char *name;
- char buf[SYMNMLEN + 1];
-
- if (symndx == -1)
- name = "*ABS*";
- else if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
- if (name == NULL)
- return false;
- }
-
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0, input_bfd,
- input_section, rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
- }
-
- return true;
-}
-
-/* Adjust the symbol index of any reloc against a global symbol to
- instead be a reloc against the internal symbol we created specially
- for the section. */
-
-/*ARGSUSED*/
-static boolean
-coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
- bfd *obfd;
- struct bfd_link_info *info;
- bfd *ibfd;
- asection *sec;
- struct internal_reloc *irel;
- boolean *adjustedp;
-{
- struct coff_link_hash_entry *h;
-
- *adjustedp = false;
-
- h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
- if (h == NULL
- || (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak))
- return true;
-
- irel->r_symndx = h->root.u.def.section->output_section->target_index - 1;
- *adjustedp = true;
-
- return true;
-}
-
-#define coff_start_final_link coff_i960_start_final_link
-
-#define coff_relocate_section coff_i960_relocate_section
-
-#define coff_adjust_symndx coff_i960_adjust_symndx
-
-#define coff_bfd_reloc_type_lookup coff_i960_reloc_type_lookup
-
-#include "coffcode.h"
-
-const bfd_target icoff_little_vec =
-{
- "coff-Intel-little", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
-
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
-
-
-const bfd_target icoff_big_vec =
-{
- "coff-Intel-big", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
-
-bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
-bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-m68k.c b/contrib/gdb/bfd/coff-m68k.c
deleted file mode 100644
index 77fb45b..0000000
--- a/contrib/gdb/bfd/coff-m68k.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* BFD back-end for Motorola 68000 COFF binaries.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "coff/m68k.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#ifndef LYNX_SPECIAL_FN
-#define LYNX_SPECIAL_FN 0
-#endif
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
-
-#ifndef COFF_PAGE_SIZE
-/* The page size is a guess based on ELF. */
-#define COFF_PAGE_SIZE 0x2000
-#endif
-
-/* Clean up namespace. */
-#define m68kcoff_howto_table _bfd_m68kcoff_howto_table
-#define m68k_rtype2howto _bfd_m68kcoff_rtype2howto
-#define m68k_howto2rtype _bfd_m68kcoff_howto2rtype
-#define m68k_reloc_type_lookup _bfd_m68kcoff_reloc_type_lookup
-
-#ifdef ONLY_DECLARE_RELOCS
-extern reloc_howto_type m68kcoff_howto_table[];
-#else
-reloc_howto_type m68kcoff_howto_table[] =
-{
- HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "8", true, 0x000000ff,0x000000ff, false),
- HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "16", true, 0x0000ffff,0x0000ffff, false),
- HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "32", true, 0xffffffff,0xffffffff, false),
- HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP8", true, 0x000000ff,0x000000ff, false),
- HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP16", true, 0x0000ffff,0x0000ffff, false),
- HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, LYNX_SPECIAL_FN, "DISP32", true, 0xffffffff,0xffffffff, false),
- HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, LYNX_SPECIAL_FN, "-32", true, 0xffffffff,0xffffffff, false),
-};
-#endif /* not ONLY_DECLARE_RELOCS */
-
-#ifndef BADMAG
-#define BADMAG(x) M68KBADMAG(x)
-#endif
-#define M68 1 /* Customize coffcode.h */
-
-/* Turn a howto into a reloc number */
-
-#ifdef ONLY_DECLARE_RELOCS
-extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
-extern int m68k_howto2rtype PARAMS ((reloc_howto_type *));
-extern reloc_howto_type *m68k_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-#else
-void
-m68k_rtype2howto(internal, relocentry)
- arelent *internal;
- int relocentry;
-{
- switch (relocentry)
- {
- case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break;
- case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break;
- case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break;
- case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break;
- case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break;
- case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break;
- case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break;
- }
-}
-
-int
-m68k_howto2rtype (internal)
- reloc_howto_type *internal;
-{
- if (internal->pc_relative)
- {
- switch (internal->bitsize)
- {
- case 32: return R_PCRLONG;
- case 16: return R_PCRWORD;
- case 8: return R_PCRBYTE;
- }
- }
- else
- {
- switch (internal->bitsize)
- {
- case 32: return R_RELLONG;
- case 16: return R_RELWORD;
- case 8: return R_RELBYTE;
- }
- }
- return R_RELLONG;
-}
-
-reloc_howto_type *
-m68k_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- default: return NULL;
- case BFD_RELOC_8: return m68kcoff_howto_table + 0;
- case BFD_RELOC_16: return m68kcoff_howto_table + 1;
- case BFD_RELOC_CTOR:
- case BFD_RELOC_32: return m68kcoff_howto_table + 2;
- case BFD_RELOC_8_PCREL: return m68kcoff_howto_table + 3;
- case BFD_RELOC_16_PCREL: return m68kcoff_howto_table + 4;
- case BFD_RELOC_32_PCREL: return m68kcoff_howto_table + 5;
- /* FIXME: There doesn't seem to be a code for R_RELLONG_NEG. */
- }
- /*NOTREACHED*/
-}
-
-#endif /* not ONLY_DECLARE_RELOCS */
-
-#define RTYPE2HOWTO(internal, relocentry) \
- m68k_rtype2howto(internal, (relocentry)->r_type)
-
-#define SELECT_RELOC(external, internal) \
- external.r_type = m68k_howto2rtype(internal);
-
-#define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup
-
-#define coff_relocate_section _bfd_coff_generic_relocate_section
-
-#include "coffcode.h"
-
-const bfd_target
-#ifdef TARGET_SYM
- TARGET_SYM =
-#else
- m68kcoff_vec =
-#endif
-{
-#ifdef TARGET_NAME
- TARGET_NAME,
-#else
- "coff-m68k", /* name */
-#endif
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-#ifdef NAMES_HAVE_UNDERSCORE
- '_',
-#else
- 0, /* leading underscore */
-#endif
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE
- };
diff --git a/contrib/gdb/bfd/coff-m88k.c b/contrib/gdb/bfd/coff-m88k.c
deleted file mode 100644
index 414106d..0000000
--- a/contrib/gdb/bfd/coff-m88k.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files.
- Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define M88 1 /* Customize various include files */
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "coff/m88k.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-static bfd_reloc_status_type m88k_special_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
-static void reloc_processing
- PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-
-static bfd_reloc_status_type
-m88k_special_reloc (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- reloc_howto_type *howto = reloc_entry->howto;
-
- switch (howto->type)
- {
- case R_HVRT16:
- case R_LVRT16:
- if (output_bfd != (bfd *) NULL)
- {
- /* 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->address += input_section->output_offset;
- }
- else
- {
- bfd_vma output_base = 0;
- bfd_vma addr = reloc_entry->address;
- bfd_vma x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
- asection *reloc_target_output_section;
- long relocation = 0;
-
- /* Work out which section the relocation is targetted at and the
- initial relocation command value. */
-
- /* Get symbol value. (Common symbols are special.) */
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
- reloc_target_output_section = symbol->section->output_section;
-
- /* Convert input-section-relative symbol value to absolute. */
- if (output_bfd)
- output_base = 0;
- else
- output_base = reloc_target_output_section->vma;
-
- relocation += output_base + symbol->section->output_offset;
-
- /* Add in supplied addend. */
- relocation += ((reloc_entry->addend << howto->bitsize) + x);
-
- reloc_entry->addend = 0;
-
- relocation >>= (bfd_vma) howto->rightshift;
-
- /* Shift everything up to where it's going to be used */
-
- relocation <<= (bfd_vma) howto->bitpos;
-
- if (relocation)
- bfd_put_16 (abfd, relocation, (unsigned char *) data + addr);
- }
-
- return bfd_reloc_ok;
- break;
-
- default:
- if (output_bfd != (bfd *) NULL)
- {
- /* 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->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
- break;
- }
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- return bfd_reloc_ok;
-}
-
-static reloc_howto_type howto_table[] =
-{
- HOWTO (R_PCR16L, /* type */
- 02, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- m88k_special_reloc, /* special_function */
- "PCR16L", /* name */
- false, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- true), /* pcrel_offset */
-
- HOWTO (R_PCR26L, /* type */
- 02, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- m88k_special_reloc, /* special_function */
- "PCR26L", /* name */
- false, /* partial_inplace */
- 0x03ffffff, /* src_mask */
- 0x03ffffff, /* dst_mask */
- true), /* pcrel_offset */
-
- HOWTO (R_VRT16, /* type */
- 00, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- m88k_special_reloc, /* special_function */
- "VRT16", /* name */
- false, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- true), /* pcrel_offset */
-
- HOWTO (R_HVRT16, /* type */
- 16, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- m88k_special_reloc, /* special_function */
- "HVRT16", /* name */
- false, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- true), /* pcrel_offset */
-
- HOWTO (R_LVRT16, /* type */
- 00, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- m88k_special_reloc, /* special_function */
- "LVRT16", /* name */
- false, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- true), /* pcrel_offset */
-
- HOWTO (R_VRT32, /* type */
- 00, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- m88k_special_reloc, /* special_function */
- "VRT32", /* name */
- false, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- true), /* pcrel_offset */
-};
-
-/* Code to turn an external r_type into a pointer to an entry in the
- above howto table. */
-static void
-rtype2howto (cache_ptr, dst)
- arelent *cache_ptr;
- struct internal_reloc *dst;
-{
- if (dst->r_type >= R_PCR16L && dst->r_type <= R_VRT32)
- {
- cache_ptr->howto = howto_table + dst->r_type - R_PCR16L;
- }
- else
- {
- BFD_ASSERT (0);
- }
-}
-
-#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
-
-
-/* Code to swap in the reloc offset */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
-
-
-#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
- reloc_processing(relent, reloc, symbols, abfd, section)
-
-static void
-reloc_processing (relent, reloc, symbols, abfd, section)
- arelent *relent;
- struct internal_reloc *reloc;
- asymbol **symbols;
- bfd *abfd;
- asection *section;
-{
- relent->address = reloc->r_vaddr;
- rtype2howto (relent, reloc);
-
- if (((int) reloc->r_symndx) > 0)
- {
- relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
- }
- else
- {
- relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- }
-
- relent->addend = reloc->r_offset;
- relent->address -= section->vma;
-}
-
-#define BADMAG(x) MC88BADMAG(x)
-#include "coffcode.h"
-
-#undef coff_write_armap
-
-const bfd_target m88kbcs_vec =
-{
- "coff-m88kbcs", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-mips.c b/contrib/gdb/bfd/coff-mips.c
deleted file mode 100644
index c860f9a..0000000
--- a/contrib/gdb/bfd/coff-mips.c
+++ /dev/null
@@ -1,2596 +0,0 @@
-/* BFD back-end for MIPS Extended-Coff files.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Original version by Per Bothner.
- Full support added by Ian Lance Taylor, ian@cygnus.com.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "coff/internal.h"
-#include "coff/sym.h"
-#include "coff/symconst.h"
-#include "coff/ecoff.h"
-#include "coff/mips.h"
-#include "libcoff.h"
-#include "libecoff.h"
-
-/* Prototypes for static functions. */
-
-static boolean mips_ecoff_bad_format_hook PARAMS ((bfd *abfd, PTR filehdr));
-static void mips_ecoff_swap_reloc_in PARAMS ((bfd *, PTR,
- struct internal_reloc *));
-static void mips_ecoff_swap_reloc_out PARAMS ((bfd *,
- const struct internal_reloc *,
- PTR));
-static void mips_adjust_reloc_in PARAMS ((bfd *,
- const struct internal_reloc *,
- arelent *));
-static void mips_adjust_reloc_out PARAMS ((bfd *, const arelent *,
- struct internal_reloc *));
-static bfd_reloc_status_type mips_generic_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_refhi_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_reflo_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_gprel_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_relhi_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_rello_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_switch_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static void mips_relocate_hi PARAMS ((struct internal_reloc *refhi,
- struct internal_reloc *reflo,
- bfd *input_bfd,
- asection *input_section,
- bfd_byte *contents,
- size_t adjust,
- bfd_vma relocation,
- boolean pcrel));
-static boolean mips_relocate_section PARAMS ((bfd *, struct bfd_link_info *,
- bfd *, asection *,
- bfd_byte *, PTR));
-static boolean mips_read_relocs PARAMS ((bfd *, asection *));
-static boolean mips_relax_section PARAMS ((bfd *, asection *,
- struct bfd_link_info *,
- boolean *));
-static boolean mips_relax_pcrel16 PARAMS ((struct bfd_link_info *, bfd *,
- asection *,
- struct ecoff_link_hash_entry *,
- bfd_byte *, bfd_vma));
-
-/* ECOFF has COFF sections, but the debugging information is stored in
- a completely different format. ECOFF targets use some of the
- swapping routines from coffswap.h, and some of the generic COFF
- routines in coffgen.c, but, unlike the real COFF targets, do not
- use coffcode.h itself.
-
- Get the generic COFF swapping routines, except for the reloc,
- symbol, and lineno ones. Give them ECOFF names. */
-#define MIPSECOFF
-#define NO_COFF_RELOCS
-#define NO_COFF_SYMBOLS
-#define NO_COFF_LINENOS
-#define coff_swap_filehdr_in mips_ecoff_swap_filehdr_in
-#define coff_swap_filehdr_out mips_ecoff_swap_filehdr_out
-#define coff_swap_aouthdr_in mips_ecoff_swap_aouthdr_in
-#define coff_swap_aouthdr_out mips_ecoff_swap_aouthdr_out
-#define coff_swap_scnhdr_in mips_ecoff_swap_scnhdr_in
-#define coff_swap_scnhdr_out mips_ecoff_swap_scnhdr_out
-#include "coffswap.h"
-
-/* Get the ECOFF swapping routines. */
-#define ECOFF_32
-#include "ecoffswap.h"
-
-/* How to process the various relocs types. */
-
-static reloc_howto_type mips_howto_table[] =
-{
- /* Reloc type 0 is ignored. The reloc reading code ensures that
- this is a reference to the .abs section, which will cause
- bfd_perform_relocation to do nothing. */
- HOWTO (MIPS_R_IGNORE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "IGNORE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 16 bit reference to a symbol, normally from a data section. */
- HOWTO (MIPS_R_REFHALF, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- mips_generic_reloc, /* special_function */
- "REFHALF", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 32 bit reference to a symbol, normally from a data section. */
- HOWTO (MIPS_R_REFWORD, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- mips_generic_reloc, /* special_function */
- "REFWORD", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 26 bit absolute jump address. */
- HOWTO (MIPS_R_JMPADDR, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- /* This needs complex overflow
- detection, because the upper four
- bits must match the PC. */
- mips_generic_reloc, /* special_function */
- "JMPADDR", /* name */
- true, /* partial_inplace */
- 0x3ffffff, /* src_mask */
- 0x3ffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* The high 16 bits of a symbol value. Handled by the function
- mips_refhi_reloc. */
- HOWTO (MIPS_R_REFHI, /* type */
- 16, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- mips_refhi_reloc, /* special_function */
- "REFHI", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* The low 16 bits of a symbol value. */
- HOWTO (MIPS_R_REFLO, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- mips_reflo_reloc, /* special_function */
- "REFLO", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A reference to an offset from the gp register. Handled by the
- function mips_gprel_reloc. */
- HOWTO (MIPS_R_GPREL, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- mips_gprel_reloc, /* special_function */
- "GPREL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A reference to a literal using an offset from the gp register.
- Handled by the function mips_gprel_reloc. */
- HOWTO (MIPS_R_LITERAL, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- mips_gprel_reloc, /* special_function */
- "LITERAL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- { 8 },
- { 9 },
- { 10 },
- { 11 },
-
- /* This reloc is a Cygnus extension used when generating position
- independent code for embedded systems. It represents a 16 bit PC
- relative reloc rightshifted twice as used in the MIPS branch
- instructions. */
- HOWTO (MIPS_R_PCREL16, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- mips_generic_reloc, /* special_function */
- "PCREL16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* This reloc is a Cygnus extension used when generating position
- independent code for embedded systems. It represents the high 16
- bits of a PC relative reloc. The next reloc must be
- MIPS_R_RELLO, and the addend is formed from the addends of the
- two instructions, just as in MIPS_R_REFHI and MIPS_R_REFLO. The
- final value is actually PC relative to the location of the
- MIPS_R_RELLO reloc, not the MIPS_R_RELHI reloc. */
- HOWTO (MIPS_R_RELHI, /* type */
- 16, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- mips_relhi_reloc, /* special_function */
- "RELHI", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* This reloc is a Cygnus extension used when generating position
- independent code for embedded systems. It represents the low 16
- bits of a PC relative reloc. */
- HOWTO (MIPS_R_RELLO, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- mips_rello_reloc, /* special_function */
- "RELLO", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- true), /* pcrel_offset */
-
- { 15 },
- { 16 },
- { 17 },
- { 18 },
- { 19 },
- { 20 },
- { 21 },
-
- /* This reloc is a Cygnus extension used when generating position
- independent code for embedded systems. It represents an entry in
- a switch table, which is the difference between two symbols in
- the .text section. The symndx is actually the offset from the
- reloc address to the subtrahend. See include/coff/mips.h for
- more details. */
- HOWTO (MIPS_R_SWITCH, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- mips_switch_reloc, /* special_function */
- "SWITCH", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- true) /* pcrel_offset */
-};
-
-#define MIPS_HOWTO_COUNT \
- (sizeof mips_howto_table / sizeof mips_howto_table[0])
-
-/* When the linker is doing relaxing, it may change a external PCREL16
- reloc. This typically represents an instruction like
- bal foo
- We change it to
- .set noreorder
- bal $L1
- lui $at,%hi(foo - $L1)
- $L1:
- addiu $at,%lo(foo - $L1)
- addu $at,$at,$31
- jalr $at
- PCREL16_EXPANSION_ADJUSTMENT is the number of bytes this changes the
- instruction by. */
-
-#define PCREL16_EXPANSION_ADJUSTMENT (4 * 4)
-
-/* See whether the magic number matches. */
-
-static boolean
-mips_ecoff_bad_format_hook (abfd, filehdr)
- bfd *abfd;
- PTR filehdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
-
- switch (internal_f->f_magic)
- {
- case MIPS_MAGIC_1:
- /* I don't know what endianness this implies. */
- return true;
-
- case MIPS_MAGIC_BIG:
- case MIPS_MAGIC_BIG2:
- case MIPS_MAGIC_BIG3:
- return bfd_big_endian (abfd);
-
- case MIPS_MAGIC_LITTLE:
- case MIPS_MAGIC_LITTLE2:
- case MIPS_MAGIC_LITTLE3:
- return bfd_little_endian (abfd);
-
- default:
- return false;
- }
-}
-
-/* Reloc handling. MIPS ECOFF relocs are packed into 8 bytes in
- external form. They use a bit which indicates whether the symbol
- is external. */
-
-/* Swap a reloc in. */
-
-static void
-mips_ecoff_swap_reloc_in (abfd, ext_ptr, intern)
- bfd *abfd;
- PTR ext_ptr;
- struct internal_reloc *intern;
-{
- const RELOC *ext = (RELOC *) ext_ptr;
-
- intern->r_vaddr = bfd_h_get_32 (abfd, (bfd_byte *) ext->r_vaddr);
- if (bfd_header_big_endian (abfd))
- {
- intern->r_symndx = (((int) ext->r_bits[0]
- << RELOC_BITS0_SYMNDX_SH_LEFT_BIG)
- | ((int) ext->r_bits[1]
- << RELOC_BITS1_SYMNDX_SH_LEFT_BIG)
- | ((int) ext->r_bits[2]
- << RELOC_BITS2_SYMNDX_SH_LEFT_BIG));
- intern->r_type = ((ext->r_bits[3] & RELOC_BITS3_TYPE_BIG)
- >> RELOC_BITS3_TYPE_SH_BIG);
- intern->r_extern = (ext->r_bits[3] & RELOC_BITS3_EXTERN_BIG) != 0;
- }
- else
- {
- intern->r_symndx = (((int) ext->r_bits[0]
- << RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE)
- | ((int) ext->r_bits[1]
- << RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE)
- | ((int) ext->r_bits[2]
- << RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE));
- intern->r_type = (((ext->r_bits[3] & RELOC_BITS3_TYPE_LITTLE)
- >> RELOC_BITS3_TYPE_SH_LITTLE)
- | ((ext->r_bits[3] & RELOC_BITS3_TYPEHI_LITTLE)
- << RELOC_BITS3_TYPEHI_SH_LITTLE));
- intern->r_extern = (ext->r_bits[3] & RELOC_BITS3_EXTERN_LITTLE) != 0;
- }
-
- /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
- MIPS_R_RELLO reloc, r_symndx is actually the offset from the
- reloc address to the base of the difference (see
- include/coff/mips.h for more details). We copy symndx into the
- r_offset field so as not to confuse ecoff_slurp_reloc_table in
- ecoff.c. In adjust_reloc_in we then copy r_offset into the reloc
- addend. */
- if (intern->r_type == MIPS_R_SWITCH
- || (! intern->r_extern
- && (intern->r_type == MIPS_R_RELLO
- || intern->r_type == MIPS_R_RELHI)))
- {
- BFD_ASSERT (! intern->r_extern);
- intern->r_offset = intern->r_symndx;
- if (intern->r_offset & 0x800000)
- intern->r_offset -= 0x1000000;
- intern->r_symndx = RELOC_SECTION_TEXT;
- }
-}
-
-/* Swap a reloc out. */
-
-static void
-mips_ecoff_swap_reloc_out (abfd, intern, dst)
- bfd *abfd;
- const struct internal_reloc *intern;
- PTR dst;
-{
- RELOC *ext = (RELOC *) dst;
- long r_symndx;
-
- BFD_ASSERT (intern->r_extern
- || (intern->r_symndx >= 0 && intern->r_symndx <= 12));
-
- /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELLO or
- MIPS_R_RELHI reloc, we actually want to write the contents of
- r_offset out as the symbol index. This undoes the change made by
- mips_ecoff_swap_reloc_in. */
- if (intern->r_type != MIPS_R_SWITCH
- && (intern->r_extern
- || (intern->r_type != MIPS_R_RELHI
- && intern->r_type != MIPS_R_RELLO)))
- r_symndx = intern->r_symndx;
- else
- {
- BFD_ASSERT (intern->r_symndx == RELOC_SECTION_TEXT);
- r_symndx = intern->r_offset & 0xffffff;
- }
-
- bfd_h_put_32 (abfd, intern->r_vaddr, (bfd_byte *) ext->r_vaddr);
- if (bfd_header_big_endian (abfd))
- {
- ext->r_bits[0] = r_symndx >> RELOC_BITS0_SYMNDX_SH_LEFT_BIG;
- ext->r_bits[1] = r_symndx >> RELOC_BITS1_SYMNDX_SH_LEFT_BIG;
- ext->r_bits[2] = r_symndx >> RELOC_BITS2_SYMNDX_SH_LEFT_BIG;
- ext->r_bits[3] = (((intern->r_type << RELOC_BITS3_TYPE_SH_BIG)
- & RELOC_BITS3_TYPE_BIG)
- | (intern->r_extern ? RELOC_BITS3_EXTERN_BIG : 0));
- }
- else
- {
- ext->r_bits[0] = r_symndx >> RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE;
- ext->r_bits[1] = r_symndx >> RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE;
- ext->r_bits[2] = r_symndx >> RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE;
- ext->r_bits[3] = (((intern->r_type << RELOC_BITS3_TYPE_SH_LITTLE)
- & RELOC_BITS3_TYPE_LITTLE)
- | ((intern->r_type >> RELOC_BITS3_TYPEHI_SH_LITTLE
- & RELOC_BITS3_TYPEHI_LITTLE))
- | (intern->r_extern ? RELOC_BITS3_EXTERN_LITTLE : 0));
- }
-}
-
-/* Finish canonicalizing a reloc. Part of this is generic to all
- ECOFF targets, and that part is in ecoff.c. The rest is done in
- this backend routine. It must fill in the howto field. */
-
-static void
-mips_adjust_reloc_in (abfd, intern, rptr)
- bfd *abfd;
- const struct internal_reloc *intern;
- arelent *rptr;
-{
- if (intern->r_type > MIPS_R_SWITCH)
- abort ();
-
- if (! intern->r_extern
- && (intern->r_type == MIPS_R_GPREL
- || intern->r_type == MIPS_R_LITERAL))
- rptr->addend += ecoff_data (abfd)->gp;
-
- /* If the type is MIPS_R_IGNORE, make sure this is a reference to
- the absolute section so that the reloc is ignored. */
- if (intern->r_type == MIPS_R_IGNORE)
- rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
-
- /* If this is a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
- MIPS_R_RELLO reloc, we want the addend field of the BFD relocto
- hold the value which was originally in the symndx field of the
- internal MIPS ECOFF reloc. This value was copied into
- intern->r_offset by mips_swap_reloc_in, and here we copy it into
- the addend field. */
- if (intern->r_type == MIPS_R_SWITCH
- || (! intern->r_extern
- && (intern->r_type == MIPS_R_RELHI
- || intern->r_type == MIPS_R_RELLO)))
- rptr->addend = intern->r_offset;
-
- rptr->howto = &mips_howto_table[intern->r_type];
-}
-
-/* Make any adjustments needed to a reloc before writing it out. None
- are needed for MIPS. */
-
-static void
-mips_adjust_reloc_out (abfd, rel, intern)
- bfd *abfd;
- const arelent *rel;
- struct internal_reloc *intern;
-{
- /* For a MIPS_R_SWITCH reloc, or an internal MIPS_R_RELHI or
- MIPS_R_RELLO reloc, we must copy rel->addend into
- intern->r_offset. This will then be written out as the symbol
- index by mips_ecoff_swap_reloc_out. This operation parallels the
- action of mips_adjust_reloc_in. */
- if (intern->r_type == MIPS_R_SWITCH
- || (! intern->r_extern
- && (intern->r_type == MIPS_R_RELHI
- || intern->r_type == MIPS_R_RELLO)))
- intern->r_offset = rel->addend;
-}
-
-/* ECOFF relocs are either against external symbols, or against
- sections. If we are producing relocateable output, and the reloc
- is against an external symbol, and nothing has given us any
- additional addend, the resulting reloc will also be against the
- same symbol. In such a case, we don't want to change anything
- about the way the reloc is handled, since it will all be done at
- final link time. Rather than put special case code into
- bfd_perform_relocation, all the reloc types use this howto
- function. It just short circuits the reloc if producing
- relocateable output against an external symbol. */
-
-static bfd_reloc_status_type
-mips_generic_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && reloc_entry->addend == 0)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- return bfd_reloc_continue;
-}
-
-/* Do a REFHI relocation. This has to be done in combination with a
- REFLO reloc, because there is a carry from the REFLO to the REFHI.
- Here we just save the information we need; we do the actual
- relocation when we see the REFLO. MIPS ECOFF requires that the
- REFLO immediately follow the REFHI, so this ought to work. */
-
-static bfd_byte *mips_refhi_addr;
-static bfd_vma mips_refhi_addend;
-
-static bfd_reloc_status_type
-mips_refhi_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_reloc_status_type ret;
- bfd_vma relocation;
-
- /* If we're relocating, and this an external symbol, we don't want
- to change anything. */
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && reloc_entry->addend == 0)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- ret = bfd_reloc_ok;
- if (bfd_is_und_section (symbol->section)
- && output_bfd == (bfd *) NULL)
- ret = bfd_reloc_undefined;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* Save the information, and let REFLO do the actual relocation. */
- mips_refhi_addr = (bfd_byte *) data + reloc_entry->address;
- mips_refhi_addend = relocation;
-
- if (output_bfd != (bfd *) NULL)
- reloc_entry->address += input_section->output_offset;
-
- return ret;
-}
-
-/* Do a REFLO relocation. This is a straightforward 16 bit inplace
- relocation; this function exists in order to do the REFHI
- relocation described above. */
-
-static bfd_reloc_status_type
-mips_reflo_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- if (mips_refhi_addr != (bfd_byte *) NULL)
- {
- unsigned long insn;
- unsigned long val;
- unsigned long vallo;
-
- /* Do the REFHI relocation. Note that we actually don't need to
- know anything about the REFLO itself, except where to find
- the low 16 bits of the addend needed by the REFHI. */
- insn = bfd_get_32 (abfd, mips_refhi_addr);
- vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
- & 0xffff);
- val = ((insn & 0xffff) << 16) + vallo;
- val += mips_refhi_addend;
-
- /* The low order 16 bits are always treated as a signed value.
- Therefore, a negative value in the low order bits requires an
- adjustment in the high order bits. We need to make this
- adjustment in two ways: once for the bits we took from the
- data, and once for the bits we are putting back in to the
- data. */
- if ((vallo & 0x8000) != 0)
- val -= 0x10000;
- if ((val & 0x8000) != 0)
- val += 0x10000;
-
- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
- bfd_put_32 (abfd, insn, mips_refhi_addr);
-
- mips_refhi_addr = (bfd_byte *) NULL;
- }
-
- /* Now do the REFLO reloc in the usual way. */
- return mips_generic_reloc (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message);
-}
-
-/* Do a GPREL relocation. This is a 16 bit value which must become
- the offset from the gp register. */
-
-static bfd_reloc_status_type
-mips_gprel_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- boolean relocateable;
- bfd_vma gp;
- bfd_vma relocation;
- unsigned long val;
- unsigned long insn;
-
- /* If we're relocating, and this is an external symbol with no
- addend, we don't want to change anything. We will only have an
- addend if this is a newly created reloc, not read from an ECOFF
- file. */
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && reloc_entry->addend == 0)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- if (output_bfd != (bfd *) NULL)
- relocateable = true;
- else
- {
- relocateable = false;
- output_bfd = symbol->section->output_section->owner;
- }
-
- if (bfd_is_und_section (symbol->section)
- && relocateable == false)
- return bfd_reloc_undefined;
-
- /* We have to figure out the gp value, so that we can adjust the
- symbol value correctly. We look up the symbol _gp in the output
- BFD. If we can't find it, we're stuck. We cache it in the ECOFF
- target data. We don't need to adjust the symbol value for an
- external symbol if we are producing relocateable output. */
- gp = _bfd_get_gp_value (output_bfd);
- if (gp == 0
- && (relocateable == false
- || (symbol->flags & BSF_SECTION_SYM) != 0))
- {
- if (relocateable != false)
- {
- /* Make up a value. */
- gp = symbol->section->output_section->vma + 0x4000;
- _bfd_set_gp_value (output_bfd, gp);
- }
- else
- {
- unsigned int count;
- asymbol **sym;
- unsigned int i;
-
- count = bfd_get_symcount (output_bfd);
- sym = bfd_get_outsymbols (output_bfd);
-
- if (sym == (asymbol **) NULL)
- i = count;
- else
- {
- for (i = 0; i < count; i++, sym++)
- {
- register CONST char *name;
-
- name = bfd_asymbol_name (*sym);
- if (*name == '_' && strcmp (name, "_gp") == 0)
- {
- gp = bfd_asymbol_value (*sym);
- _bfd_set_gp_value (output_bfd, gp);
- break;
- }
- }
- }
-
- if (i >= count)
- {
- /* Only get the error once. */
- gp = 4;
- _bfd_set_gp_value (output_bfd, gp);
- *error_message =
- (char *) "GP relative relocation when _gp not defined";
- return bfd_reloc_dangerous;
- }
- }
- }
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
-
- /* Set val to the offset into the section or symbol. */
- val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
- if (val & 0x8000)
- val -= 0x10000;
-
- /* Adjust val for the final section location and GP value. If we
- are producing relocateable output, we don't want to do this for
- an external symbol. */
- if (relocateable == false
- || (symbol->flags & BSF_SECTION_SYM) != 0)
- val += relocation - gp;
-
- insn = (insn &~ 0xffff) | (val & 0xffff);
- bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
-
- if (relocateable != false)
- reloc_entry->address += input_section->output_offset;
-
- /* Make sure it fit in 16 bits. */
- if (val >= 0x8000 && val < 0xffff8000)
- return bfd_reloc_overflow;
-
- return bfd_reloc_ok;
-}
-
-/* Do a RELHI relocation. We do this in conjunction with a RELLO
- reloc, just as REFHI and REFLO are done together. RELHI and RELLO
- are Cygnus extensions used when generating position independent
- code for embedded systems. */
-
-static bfd_byte *mips_relhi_addr;
-static bfd_vma mips_relhi_addend;
-
-static bfd_reloc_status_type
-mips_relhi_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_reloc_status_type ret;
- bfd_vma relocation;
-
- /* If this is a reloc against a section symbol, then it is correct
- in the object file. The only time we want to change this case is
- when we are relaxing, and that is handled entirely by
- mips_relocate_section and never calls this function. */
- if ((symbol->flags & BSF_SECTION_SYM) != 0)
- {
- if (output_bfd != (bfd *) NULL)
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* This is an external symbol. If we're relocating, we don't want
- to change anything. */
- if (output_bfd != (bfd *) NULL)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- ret = bfd_reloc_ok;
- if (bfd_is_und_section (symbol->section)
- && output_bfd == (bfd *) NULL)
- ret = bfd_reloc_undefined;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* Save the information, and let RELLO do the actual relocation. */
- mips_relhi_addr = (bfd_byte *) data + reloc_entry->address;
- mips_relhi_addend = relocation;
-
- if (output_bfd != (bfd *) NULL)
- reloc_entry->address += input_section->output_offset;
-
- return ret;
-}
-
-/* Do a RELLO relocation. This is a straightforward 16 bit PC
- relative relocation; this function exists in order to do the RELHI
- relocation described above. */
-
-static bfd_reloc_status_type
-mips_rello_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- if (mips_relhi_addr != (bfd_byte *) NULL)
- {
- unsigned long insn;
- unsigned long val;
- unsigned long vallo;
-
- /* Do the RELHI relocation. Note that we actually don't need to
- know anything about the RELLO itself, except where to find
- the low 16 bits of the addend needed by the RELHI. */
- insn = bfd_get_32 (abfd, mips_relhi_addr);
- vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
- & 0xffff);
- val = ((insn & 0xffff) << 16) + vallo;
- val += mips_relhi_addend;
-
- /* If the symbol is defined, make val PC relative. If the
- symbol is not defined we don't want to do this, because we
- don't want the value in the object file to incorporate the
- address of the reloc. */
- if (! bfd_is_und_section (bfd_get_section (symbol))
- && ! bfd_is_com_section (bfd_get_section (symbol)))
- val -= (input_section->output_section->vma
- + input_section->output_offset
- + reloc_entry->address);
-
- /* The low order 16 bits are always treated as a signed value.
- Therefore, a negative value in the low order bits requires an
- adjustment in the high order bits. We need to make this
- adjustment in two ways: once for the bits we took from the
- data, and once for the bits we are putting back in to the
- data. */
- if ((vallo & 0x8000) != 0)
- val -= 0x10000;
- if ((val & 0x8000) != 0)
- val += 0x10000;
-
- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
- bfd_put_32 (abfd, insn, mips_relhi_addr);
-
- mips_relhi_addr = (bfd_byte *) NULL;
- }
-
- /* If this is a reloc against a section symbol, then it is correct
- in the object file. The only time we want to change this case is
- when we are relaxing, and that is handled entirely by
- mips_relocate_section and never calls this function. */
- if ((symbol->flags & BSF_SECTION_SYM) != 0)
- {
- if (output_bfd != (bfd *) NULL)
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* bfd_perform_relocation does not handle pcrel_offset relocations
- correctly when generating a relocateable file, so handle them
- directly here. */
- if (output_bfd != (bfd *) NULL)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* Now do the RELLO reloc in the usual way. */
- return mips_generic_reloc (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message);
-}
-
-/* This is the special function for the MIPS_R_SWITCH reloc. This
- special reloc is normally correct in the object file, and only
- requires special handling when relaxing. We don't want
- bfd_perform_relocation to tamper with it at all. */
-
-/*ARGSUSED*/
-static bfd_reloc_status_type
-mips_switch_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- return bfd_reloc_ok;
-}
-
-/* Get the howto structure for a generic reloc type. */
-
-static reloc_howto_type *
-mips_bfd_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- int mips_type;
-
- switch (code)
- {
- case BFD_RELOC_16:
- mips_type = MIPS_R_REFHALF;
- break;
- case BFD_RELOC_32:
- case BFD_RELOC_CTOR:
- mips_type = MIPS_R_REFWORD;
- break;
- case BFD_RELOC_MIPS_JMP:
- mips_type = MIPS_R_JMPADDR;
- break;
- case BFD_RELOC_HI16_S:
- mips_type = MIPS_R_REFHI;
- break;
- case BFD_RELOC_LO16:
- mips_type = MIPS_R_REFLO;
- break;
- case BFD_RELOC_MIPS_GPREL:
- mips_type = MIPS_R_GPREL;
- break;
- case BFD_RELOC_MIPS_LITERAL:
- mips_type = MIPS_R_LITERAL;
- break;
- case BFD_RELOC_16_PCREL_S2:
- mips_type = MIPS_R_PCREL16;
- break;
- case BFD_RELOC_PCREL_HI16_S:
- mips_type = MIPS_R_RELHI;
- break;
- case BFD_RELOC_PCREL_LO16:
- mips_type = MIPS_R_RELLO;
- break;
- case BFD_RELOC_GPREL32:
- mips_type = MIPS_R_SWITCH;
- break;
- default:
- return (reloc_howto_type *) NULL;
- }
-
- return &mips_howto_table[mips_type];
-}
-
-/* A helper routine for mips_relocate_section which handles the REFHI
- and RELHI relocations. The REFHI relocation must be followed by a
- REFLO relocation (and RELHI by a RELLO), and the addend used is
- formed from the addends of both instructions. */
-
-static void
-mips_relocate_hi (refhi, reflo, input_bfd, input_section, contents, adjust,
- relocation, pcrel)
- struct internal_reloc *refhi;
- struct internal_reloc *reflo;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- size_t adjust;
- bfd_vma relocation;
- boolean pcrel;
-{
- unsigned long insn;
- unsigned long val;
- unsigned long vallo;
-
- insn = bfd_get_32 (input_bfd,
- contents + adjust + refhi->r_vaddr - input_section->vma);
- vallo = (bfd_get_32 (input_bfd,
- contents + adjust + reflo->r_vaddr - input_section->vma)
- & 0xffff);
- val = ((insn & 0xffff) << 16) + vallo;
- val += relocation;
-
- /* The low order 16 bits are always treated as a signed value.
- Therefore, a negative value in the low order bits requires an
- adjustment in the high order bits. We need to make this
- adjustment in two ways: once for the bits we took from the data,
- and once for the bits we are putting back in to the data. */
- if ((vallo & 0x8000) != 0)
- val -= 0x10000;
-
- if (pcrel)
- val -= (input_section->output_section->vma
- + input_section->output_offset
- + (reflo->r_vaddr - input_section->vma + adjust));
-
- if ((val & 0x8000) != 0)
- val += 0x10000;
-
- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
- bfd_put_32 (input_bfd, (bfd_vma) insn,
- contents + adjust + refhi->r_vaddr - input_section->vma);
-}
-
-/* Relocate a section while linking a MIPS ECOFF file. */
-
-static boolean
-mips_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, external_relocs)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- PTR external_relocs;
-{
- asection **symndx_to_section;
- struct ecoff_link_hash_entry **sym_hashes;
- bfd_vma gp;
- boolean gp_undefined;
- size_t adjust;
- long *offsets;
- struct external_reloc *ext_rel;
- struct external_reloc *ext_rel_end;
- unsigned int i;
- boolean got_lo;
- struct internal_reloc lo_int_rel;
-
- BFD_ASSERT (input_bfd->xvec->header_byteorder
- == output_bfd->xvec->header_byteorder);
-
- /* We keep a table mapping the symndx found in an internal reloc to
- the appropriate section. This is faster than looking up the
- section by name each time. */
- symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
- if (symndx_to_section == (asection **) NULL)
- {
- symndx_to_section = ((asection **)
- bfd_alloc (input_bfd,
- (NUM_RELOC_SECTIONS
- * sizeof (asection *))));
- if (!symndx_to_section)
- return false;
-
- symndx_to_section[RELOC_SECTION_NONE] = NULL;
- symndx_to_section[RELOC_SECTION_TEXT] =
- bfd_get_section_by_name (input_bfd, ".text");
- symndx_to_section[RELOC_SECTION_RDATA] =
- bfd_get_section_by_name (input_bfd, ".rdata");
- symndx_to_section[RELOC_SECTION_DATA] =
- bfd_get_section_by_name (input_bfd, ".data");
- symndx_to_section[RELOC_SECTION_SDATA] =
- bfd_get_section_by_name (input_bfd, ".sdata");
- symndx_to_section[RELOC_SECTION_SBSS] =
- bfd_get_section_by_name (input_bfd, ".sbss");
- symndx_to_section[RELOC_SECTION_BSS] =
- bfd_get_section_by_name (input_bfd, ".bss");
- symndx_to_section[RELOC_SECTION_INIT] =
- bfd_get_section_by_name (input_bfd, ".init");
- symndx_to_section[RELOC_SECTION_LIT8] =
- bfd_get_section_by_name (input_bfd, ".lit8");
- symndx_to_section[RELOC_SECTION_LIT4] =
- bfd_get_section_by_name (input_bfd, ".lit4");
- symndx_to_section[RELOC_SECTION_XDATA] = NULL;
- symndx_to_section[RELOC_SECTION_PDATA] = NULL;
- symndx_to_section[RELOC_SECTION_FINI] =
- bfd_get_section_by_name (input_bfd, ".fini");
- symndx_to_section[RELOC_SECTION_LITA] = NULL;
- symndx_to_section[RELOC_SECTION_ABS] = NULL;
-
- ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
- }
-
- sym_hashes = ecoff_data (input_bfd)->sym_hashes;
-
- gp = _bfd_get_gp_value (output_bfd);
- if (gp == 0)
- gp_undefined = true;
- else
- gp_undefined = false;
-
- got_lo = false;
-
- adjust = 0;
-
- if (ecoff_section_data (input_bfd, input_section) == NULL)
- offsets = NULL;
- else
- offsets = ecoff_section_data (input_bfd, input_section)->offsets;
-
- ext_rel = (struct external_reloc *) external_relocs;
- ext_rel_end = ext_rel + input_section->reloc_count;
- for (i = 0; ext_rel < ext_rel_end; ext_rel++, i++)
- {
- struct internal_reloc int_rel;
- bfd_vma addend;
- reloc_howto_type *howto;
- struct ecoff_link_hash_entry *h = NULL;
- asection *s = NULL;
- bfd_vma relocation;
- bfd_reloc_status_type r;
-
- if (! got_lo)
- mips_ecoff_swap_reloc_in (input_bfd, (PTR) ext_rel, &int_rel);
- else
- {
- int_rel = lo_int_rel;
- got_lo = false;
- }
-
- BFD_ASSERT (int_rel.r_type
- < sizeof mips_howto_table / sizeof mips_howto_table[0]);
-
- /* The REFHI and RELHI relocs requires special handling. they
- must be followed by a REFLO or RELLO reloc, respectively, and
- the addend is formed from both relocs. */
- if (int_rel.r_type == MIPS_R_REFHI
- || int_rel.r_type == MIPS_R_RELHI)
- {
- BFD_ASSERT ((ext_rel + 1) < ext_rel_end);
- mips_ecoff_swap_reloc_in (input_bfd, (PTR) (ext_rel + 1),
- &lo_int_rel);
- BFD_ASSERT ((lo_int_rel.r_type
- == (int_rel.r_type == MIPS_R_REFHI
- ? MIPS_R_REFLO
- : MIPS_R_RELLO))
- && int_rel.r_extern == lo_int_rel.r_extern
- && int_rel.r_symndx == lo_int_rel.r_symndx);
- got_lo = true;
- }
-
- howto = &mips_howto_table[int_rel.r_type];
-
- /* The SWITCH reloc must be handled specially. This reloc is
- marks the location of a difference between two portions of an
- object file. The symbol index does not reference a symbol,
- but is actually the offset from the reloc to the subtrahend
- of the difference. This reloc is correct in the object file,
- and needs no further adjustment, unless we are relaxing. If
- we are relaxing, we may have to add in an offset. Since no
- symbols are involved in this reloc, we handle it completely
- here. */
- if (int_rel.r_type == MIPS_R_SWITCH)
- {
- if (offsets != NULL
- && offsets[i] != 0)
- {
- r = _bfd_relocate_contents (howto, input_bfd,
- (bfd_vma) offsets[i],
- (contents
- + adjust
- + int_rel.r_vaddr
- - input_section->vma));
- BFD_ASSERT (r == bfd_reloc_ok);
- }
-
- continue;
- }
-
- if (int_rel.r_extern)
- {
- h = sym_hashes[int_rel.r_symndx];
- /* If h is NULL, that means that there is a reloc against an
- external symbol which we thought was just a debugging
- symbol. This should not happen. */
- if (h == (struct ecoff_link_hash_entry *) NULL)
- abort ();
- }
- else
- {
- if (int_rel.r_symndx < 0 || int_rel.r_symndx >= NUM_RELOC_SECTIONS)
- s = NULL;
- else
- s = symndx_to_section[int_rel.r_symndx];
-
- if (s == (asection *) NULL)
- abort ();
- }
-
- /* The GPREL reloc uses an addend: the difference in the GP
- values. */
- if (int_rel.r_type != MIPS_R_GPREL
- && int_rel.r_type != MIPS_R_LITERAL)
- addend = 0;
- else
- {
- if (gp_undefined)
- {
- if (! ((*info->callbacks->reloc_dangerous)
- (info, "GP relative relocation when GP not defined",
- input_bfd, input_section,
- int_rel.r_vaddr - input_section->vma)))
- return false;
- /* Only give the error once per link. */
- gp = 4;
- _bfd_set_gp_value (output_bfd, gp);
- gp_undefined = false;
- }
- if (! int_rel.r_extern)
- {
- /* This is a relocation against a section. The current
- addend in the instruction is the difference between
- INPUT_SECTION->vma and the GP value of INPUT_BFD. We
- must change this to be the difference between the
- final definition (which will end up in RELOCATION)
- and the GP value of OUTPUT_BFD (which is in GP). */
- addend = ecoff_data (input_bfd)->gp - gp;
- }
- else if (! info->relocateable
- || h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- /* This is a relocation against a defined symbol. The
- current addend in the instruction is simply the
- desired offset into the symbol (normally zero). We
- are going to change this into a relocation against a
- defined symbol, so we want the instruction to hold
- the difference between the final definition of the
- symbol (which will end up in RELOCATION) and the GP
- value of OUTPUT_BFD (which is in GP). */
- addend = - gp;
- }
- else
- {
- /* This is a relocation against an undefined or common
- symbol. The current addend in the instruction is
- simply the desired offset into the symbol (normally
- zero). We are generating relocateable output, and we
- aren't going to define this symbol, so we just leave
- the instruction alone. */
- addend = 0;
- }
- }
-
- /* If we are relaxing, mips_relax_section may have set
- offsets[i] to some value. A value of 1 means we must expand
- a PC relative branch into a multi-instruction of sequence,
- and any other value is an addend. */
- if (offsets != NULL
- && offsets[i] != 0)
- {
- BFD_ASSERT (! info->relocateable);
- BFD_ASSERT (int_rel.r_type == MIPS_R_PCREL16
- || int_rel.r_type == MIPS_R_RELHI
- || int_rel.r_type == MIPS_R_RELLO);
- if (offsets[i] != 1)
- addend += offsets[i];
- else
- {
- bfd_byte *here;
-
- BFD_ASSERT (int_rel.r_extern
- && int_rel.r_type == MIPS_R_PCREL16);
-
- /* Move the rest of the instructions up. */
- here = (contents
- + adjust
- + int_rel.r_vaddr
- - input_section->vma);
- memmove (here + PCREL16_EXPANSION_ADJUSTMENT, here,
- (size_t) (input_section->_raw_size
- - (int_rel.r_vaddr - input_section->vma)));
-
- /* Generate the new instructions. */
- if (! mips_relax_pcrel16 (info, input_bfd, input_section,
- h, here,
- (input_section->output_section->vma
- + input_section->output_offset
- + (int_rel.r_vaddr
- - input_section->vma)
- + adjust)))
- return false;
-
- /* We must adjust everything else up a notch. */
- adjust += PCREL16_EXPANSION_ADJUSTMENT;
-
- /* mips_relax_pcrel16 handles all the details of this
- relocation. */
- continue;
- }
- }
-
- /* If we are relaxing, and this is a reloc against the .text
- segment, we may need to adjust it if some branches have been
- expanded. The reloc types which are likely to occur in the
- .text section are handled efficiently by mips_relax_section,
- and thus do not need to be handled here. */
- if (ecoff_data (input_bfd)->debug_info.adjust != NULL
- && ! int_rel.r_extern
- && int_rel.r_symndx == RELOC_SECTION_TEXT
- && (strcmp (bfd_get_section_name (input_bfd, input_section),
- ".text") != 0
- || (int_rel.r_type != MIPS_R_PCREL16
- && int_rel.r_type != MIPS_R_SWITCH
- && int_rel.r_type != MIPS_R_RELHI
- && int_rel.r_type != MIPS_R_RELLO)))
- {
- bfd_vma adr;
- struct ecoff_value_adjust *a;
-
- /* We need to get the addend so that we know whether we need
- to adjust the address. */
- BFD_ASSERT (int_rel.r_type == MIPS_R_REFWORD);
-
- adr = bfd_get_32 (input_bfd,
- (contents
- + adjust
- + int_rel.r_vaddr
- - input_section->vma));
-
- for (a = ecoff_data (input_bfd)->debug_info.adjust;
- a != (struct ecoff_value_adjust *) NULL;
- a = a->next)
- {
- if (adr >= a->start && adr < a->end)
- addend += a->adjust;
- }
- }
-
- if (info->relocateable)
- {
- /* We are generating relocateable output, and must convert
- the existing reloc. */
- if (int_rel.r_extern)
- {
- if ((h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && ! bfd_is_abs_section (h->root.u.def.section))
- {
- const char *name;
-
- /* This symbol is defined in the output. Convert
- the reloc from being against the symbol to being
- against the section. */
-
- /* Clear the r_extern bit. */
- int_rel.r_extern = 0;
-
- /* Compute a new r_symndx value. */
- s = h->root.u.def.section;
- name = bfd_get_section_name (output_bfd,
- s->output_section);
-
- int_rel.r_symndx = -1;
- switch (name[1])
- {
- case 'b':
- if (strcmp (name, ".bss") == 0)
- int_rel.r_symndx = RELOC_SECTION_BSS;
- break;
- case 'd':
- if (strcmp (name, ".data") == 0)
- int_rel.r_symndx = RELOC_SECTION_DATA;
- break;
- case 'f':
- if (strcmp (name, ".fini") == 0)
- int_rel.r_symndx = RELOC_SECTION_FINI;
- break;
- case 'i':
- if (strcmp (name, ".init") == 0)
- int_rel.r_symndx = RELOC_SECTION_INIT;
- break;
- case 'l':
- if (strcmp (name, ".lit8") == 0)
- int_rel.r_symndx = RELOC_SECTION_LIT8;
- else if (strcmp (name, ".lit4") == 0)
- int_rel.r_symndx = RELOC_SECTION_LIT4;
- break;
- case 'r':
- if (strcmp (name, ".rdata") == 0)
- int_rel.r_symndx = RELOC_SECTION_RDATA;
- break;
- case 's':
- if (strcmp (name, ".sdata") == 0)
- int_rel.r_symndx = RELOC_SECTION_SDATA;
- else if (strcmp (name, ".sbss") == 0)
- int_rel.r_symndx = RELOC_SECTION_SBSS;
- break;
- case 't':
- if (strcmp (name, ".text") == 0)
- int_rel.r_symndx = RELOC_SECTION_TEXT;
- break;
- }
-
- if (int_rel.r_symndx == -1)
- abort ();
-
- /* Add the section VMA and the symbol value. */
- relocation = (h->root.u.def.value
- + s->output_section->vma
- + s->output_offset);
-
- /* For a PC relative relocation, the object file
- currently holds just the addend. We must adjust
- by the address to get the right value. */
- if (howto->pc_relative)
- {
- relocation -= int_rel.r_vaddr - input_section->vma;
-
- /* If we are converting a RELHI or RELLO reloc
- from being against an external symbol to
- being against a section, we must put a
- special value into the r_offset field. This
- value is the old addend. The r_offset for
- both the RELOHI and RELLO relocs are the
- same, and we set both when we see RELHI. */
- if (int_rel.r_type == MIPS_R_RELHI)
- {
- long addhi, addlo;
-
- addhi = bfd_get_32 (input_bfd,
- (contents
- + adjust
- + int_rel.r_vaddr
- - input_section->vma));
- addhi &= 0xffff;
- if (addhi & 0x8000)
- addhi -= 0x10000;
- addhi <<= 16;
-
- addlo = bfd_get_32 (input_bfd,
- (contents
- + adjust
- + lo_int_rel.r_vaddr
- - input_section->vma));
- addlo &= 0xffff;
- if (addlo & 0x8000)
- addlo -= 0x10000;
-
- int_rel.r_offset = addhi + addlo;
- lo_int_rel.r_offset = int_rel.r_offset;
- }
- }
-
- h = NULL;
- }
- else
- {
- /* Change the symndx value to the right one for the
- output BFD. */
- int_rel.r_symndx = h->indx;
- if (int_rel.r_symndx == -1)
- {
- /* This symbol is not being written out. */
- if (! ((*info->callbacks->unattached_reloc)
- (info, h->root.root.string, input_bfd,
- input_section,
- int_rel.r_vaddr - input_section->vma)))
- return false;
- int_rel.r_symndx = 0;
- }
- relocation = 0;
- }
- }
- else
- {
- /* This is a relocation against a section. Adjust the
- value by the amount the section moved. */
- relocation = (s->output_section->vma
- + s->output_offset
- - s->vma);
- }
-
- relocation += addend;
- addend = 0;
-
- /* Adjust a PC relative relocation by removing the reference
- to the original address in the section and including the
- reference to the new address. However, external RELHI
- and RELLO relocs are PC relative, but don't include any
- reference to the address. The addend is merely an
- addend. */
- if (howto->pc_relative
- && (! int_rel.r_extern
- || (int_rel.r_type != MIPS_R_RELHI
- && int_rel.r_type != MIPS_R_RELLO)))
- relocation -= (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma);
-
- /* Adjust the contents. */
- if (relocation == 0)
- r = bfd_reloc_ok;
- else
- {
- if (int_rel.r_type != MIPS_R_REFHI
- && int_rel.r_type != MIPS_R_RELHI)
- r = _bfd_relocate_contents (howto, input_bfd, relocation,
- (contents
- + adjust
- + int_rel.r_vaddr
- - input_section->vma));
- else
- {
- mips_relocate_hi (&int_rel, &lo_int_rel,
- input_bfd, input_section, contents,
- adjust, relocation,
- int_rel.r_type == MIPS_R_RELHI);
- r = bfd_reloc_ok;
- }
- }
-
- /* Adjust the reloc address. */
- int_rel.r_vaddr += (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma);
-
- /* Save the changed reloc information. */
- mips_ecoff_swap_reloc_out (input_bfd, &int_rel, (PTR) ext_rel);
- }
- else
- {
- /* We are producing a final executable. */
- if (int_rel.r_extern)
- {
- /* This is a reloc against a symbol. */
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *hsec;
-
- hsec = h->root.u.def.section;
- relocation = (h->root.u.def.value
- + hsec->output_section->vma
- + hsec->output_offset);
- }
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section,
- int_rel.r_vaddr - input_section->vma)))
- return false;
- relocation = 0;
- }
- }
- else
- {
- /* This is a reloc against a section. */
- relocation = (s->output_section->vma
- + s->output_offset
- - s->vma);
-
- /* A PC relative reloc is already correct in the object
- file. Make it look like a pcrel_offset relocation by
- adding in the start address. */
- if (howto->pc_relative)
- {
- if (int_rel.r_type != MIPS_R_RELHI)
- relocation += int_rel.r_vaddr + adjust;
- else
- relocation += lo_int_rel.r_vaddr + adjust;
- }
- }
-
- if (int_rel.r_type != MIPS_R_REFHI
- && int_rel.r_type != MIPS_R_RELHI)
- r = _bfd_final_link_relocate (howto,
- input_bfd,
- input_section,
- contents,
- (int_rel.r_vaddr
- - input_section->vma
- + adjust),
- relocation,
- addend);
- else
- {
- mips_relocate_hi (&int_rel, &lo_int_rel, input_bfd,
- input_section, contents, adjust,
- relocation,
- int_rel.r_type == MIPS_R_RELHI);
- r = bfd_reloc_ok;
- }
- }
-
- /* MIPS_R_JMPADDR requires peculiar overflow detection. The
- instruction provides a 28 bit address (the two lower bits are
- implicit zeroes) which is combined with the upper four bits
- of the instruction address. */
- if (r == bfd_reloc_ok
- && int_rel.r_type == MIPS_R_JMPADDR
- && (((relocation
- + addend
- + (int_rel.r_extern ? 0 : s->vma))
- & 0xf0000000)
- != ((input_section->output_section->vma
- + input_section->output_offset
- + (int_rel.r_vaddr - input_section->vma)
- + adjust)
- & 0xf0000000)))
- r = bfd_reloc_overflow;
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (int_rel.r_extern)
- name = h->root.root.string;
- else
- name = bfd_section_name (input_bfd, s);
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section,
- int_rel.r_vaddr - input_section->vma)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Read in the relocs for a section. */
-
-static boolean
-mips_read_relocs (abfd, sec)
- bfd *abfd;
- asection *sec;
-{
- struct ecoff_section_tdata *section_tdata;
-
- section_tdata = ecoff_section_data (abfd, sec);
- if (section_tdata == (struct ecoff_section_tdata *) NULL)
- {
- sec->used_by_bfd =
- (PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata));
- if (sec->used_by_bfd == NULL)
- return false;
-
- section_tdata = ecoff_section_data (abfd, sec);
- section_tdata->external_relocs = NULL;
- section_tdata->contents = NULL;
- section_tdata->offsets = NULL;
- }
-
- if (section_tdata->external_relocs == NULL)
- {
- bfd_size_type external_relocs_size;
-
- external_relocs_size = (ecoff_backend (abfd)->external_reloc_size
- * sec->reloc_count);
-
- section_tdata->external_relocs =
- (PTR) bfd_alloc (abfd, external_relocs_size);
- if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
- return false;
-
- if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || (bfd_read (section_tdata->external_relocs, 1,
- external_relocs_size, abfd)
- != external_relocs_size))
- return false;
- }
-
- return true;
-}
-
-/* Relax a section when linking a MIPS ECOFF file. This is used for
- embedded PIC code, which always uses PC relative branches which
- only have an 18 bit range on MIPS. If a branch is not in range, we
- generate a long instruction sequence to compensate. Each time we
- find a branch to expand, we have to check all the others again to
- make sure they are still in range. This is slow, but it only has
- to be done when -relax is passed to the linker.
-
- This routine figures out which branches need to expand; the actual
- expansion is done in mips_relocate_section when the section
- contents are relocated. The information is stored in the offsets
- field of the ecoff_section_tdata structure. An offset of 1 means
- that the branch must be expanded into a multi-instruction PC
- relative branch (such an offset will only occur for a PC relative
- branch to an external symbol). Any other offset must be a multiple
- of four, and is the amount to change the branch by (such an offset
- will only occur for a PC relative branch within the same section).
-
- We do not modify the section relocs or contents themselves so that
- if memory usage becomes an issue we can discard them and read them
- again. The only information we must save in memory between this
- routine and the mips_relocate_section routine is the table of
- offsets. */
-
-static boolean
-mips_relax_section (abfd, sec, info, again)
- bfd *abfd;
- asection *sec;
- struct bfd_link_info *info;
- boolean *again;
-{
- struct ecoff_section_tdata *section_tdata;
- bfd_byte *contents = NULL;
- long *offsets;
- struct external_reloc *ext_rel;
- struct external_reloc *ext_rel_end;
- unsigned int i;
-
- /* Assume we are not going to need another pass. */
- *again = false;
-
- /* If we are not generating an ECOFF file, this is much too
- confusing to deal with. */
- if (info->hash->creator->flavour != bfd_get_flavour (abfd))
- return true;
-
- /* If there are no relocs, there is nothing to do. */
- if (sec->reloc_count == 0)
- return true;
-
- /* We are only interested in PC relative relocs, and why would there
- ever be one from anything but the .text section? */
- if (strcmp (bfd_get_section_name (abfd, sec), ".text") != 0)
- return true;
-
- /* Read in the relocs, if we haven't already got them. */
- section_tdata = ecoff_section_data (abfd, sec);
- if (section_tdata == (struct ecoff_section_tdata *) NULL
- || section_tdata->external_relocs == NULL)
- {
- if (! mips_read_relocs (abfd, sec))
- goto error_return;
- section_tdata = ecoff_section_data (abfd, sec);
- }
-
- if (sec->_cooked_size == 0)
- {
- /* We must initialize _cooked_size only the first time we are
- called. */
- sec->_cooked_size = sec->_raw_size;
- }
-
- contents = section_tdata->contents;
- offsets = section_tdata->offsets;
-
- /* Look for any external PC relative relocs. Internal PC relative
- relocs are already correct in the object file, so they certainly
- can not overflow. */
- ext_rel = (struct external_reloc *) section_tdata->external_relocs;
- ext_rel_end = ext_rel + sec->reloc_count;
- for (i = 0; ext_rel < ext_rel_end; ext_rel++, i++)
- {
- struct internal_reloc int_rel;
- struct ecoff_link_hash_entry *h;
- asection *hsec;
- bfd_signed_vma relocation;
- struct external_reloc *adj_ext_rel;
- unsigned int adj_i;
- unsigned long ext_count;
- struct ecoff_link_hash_entry **adj_h_ptr;
- struct ecoff_link_hash_entry **adj_h_ptr_end;
- struct ecoff_value_adjust *adjust;
-
- /* If we have already expanded this reloc, we certainly don't
- need to do it again. */
- if (offsets != (long *) NULL && offsets[i] == 1)
- continue;
-
- /* Quickly check that this reloc is external PCREL16. */
- if (bfd_header_big_endian (abfd))
- {
- if ((ext_rel->r_bits[3] & RELOC_BITS3_EXTERN_BIG) == 0
- || (((ext_rel->r_bits[3] & RELOC_BITS3_TYPE_BIG)
- >> RELOC_BITS3_TYPE_SH_BIG)
- != MIPS_R_PCREL16))
- continue;
- }
- else
- {
- if ((ext_rel->r_bits[3] & RELOC_BITS3_EXTERN_LITTLE) == 0
- || (((ext_rel->r_bits[3] & RELOC_BITS3_TYPE_LITTLE)
- >> RELOC_BITS3_TYPE_SH_LITTLE)
- != MIPS_R_PCREL16))
- continue;
- }
-
- mips_ecoff_swap_reloc_in (abfd, (PTR) ext_rel, &int_rel);
-
- h = ecoff_data (abfd)->sym_hashes[int_rel.r_symndx];
- if (h == (struct ecoff_link_hash_entry *) NULL)
- abort ();
-
- if (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak)
- {
- /* Just ignore undefined symbols. These will presumably
- generate an error later in the link. */
- continue;
- }
-
- /* Get the value of the symbol. */
- hsec = h->root.u.def.section;
- relocation = (h->root.u.def.value
- + hsec->output_section->vma
- + hsec->output_offset);
-
- /* Subtract out the current address. */
- relocation -= (sec->output_section->vma
- + sec->output_offset
- + (int_rel.r_vaddr - sec->vma));
-
- /* The addend is stored in the object file. In the normal case
- of ``bal symbol'', the addend will be -4. It will only be
- different in the case of ``bal symbol+constant''. To avoid
- always reading in the section contents, we don't check the
- addend in the object file (we could easily check the contents
- if we happen to have already read them in, but I fear that
- this could be confusing). This means we will screw up if
- there is a branch to a symbol that is in range, but added to
- a constant which puts it out of range; in such a case the
- link will fail with a reloc overflow error. Since the
- compiler will never generate such code, it should be easy
- enough to work around it by changing the assembly code in the
- source file. */
- relocation -= 4;
-
- /* Now RELOCATION is the number we want to put in the object
- file. See whether it fits. */
- if (relocation >= -0x20000 && relocation < 0x20000)
- continue;
-
- /* Now that we know this reloc needs work, which will rarely
- happen, go ahead and grab the section contents. */
- if (contents == (bfd_byte *) NULL)
- {
- if (info->keep_memory)
- contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size);
- else
- contents = (bfd_byte *) bfd_malloc ((size_t) sec->_raw_size);
- if (contents == (bfd_byte *) NULL)
- goto error_return;
- if (! bfd_get_section_contents (abfd, sec, (PTR) contents,
- (file_ptr) 0, sec->_raw_size))
- goto error_return;
- if (info->keep_memory)
- section_tdata->contents = contents;
- }
-
- /* We only support changing the bal instruction. It would be
- possible to handle other PC relative branches, but some of
- them (the conditional branches) would require a different
- length instruction sequence which would complicate both this
- routine and mips_relax_pcrel16. It could be written if
- somebody felt it were important. Ignoring this reloc will
- presumably cause a reloc overflow error later on. */
- if (bfd_get_32 (abfd, contents + int_rel.r_vaddr - sec->vma)
- != 0x0411ffff) /* bgezal $0,. == bal . */
- continue;
-
- /* Bother. We need to expand this reloc, and we will need to
- make another relaxation pass since this change may put other
- relocs out of range. We need to examine the local branches
- and we need to allocate memory to hold the offsets we must
- add to them. We also need to adjust the values of all
- symbols in the object file following this location. */
-
- sec->_cooked_size += PCREL16_EXPANSION_ADJUSTMENT;
- *again = true;
-
- if (offsets == (long *) NULL)
- {
- size_t size;
-
- size = sec->reloc_count * sizeof (long);
- offsets = (long *) bfd_alloc_by_size_t (abfd, size);
- if (offsets == (long *) NULL)
- goto error_return;
- memset (offsets, 0, size);
- section_tdata->offsets = offsets;
- }
-
- offsets[i] = 1;
-
- /* Now look for all PC relative references that cross this reloc
- and adjust their offsets. */
- adj_ext_rel = (struct external_reloc *) section_tdata->external_relocs;
- for (adj_i = 0; adj_ext_rel < ext_rel_end; adj_ext_rel++, adj_i++)
- {
- struct internal_reloc adj_int_rel;
- bfd_vma start, stop;
- int change;
-
- mips_ecoff_swap_reloc_in (abfd, (PTR) adj_ext_rel, &adj_int_rel);
-
- if (adj_int_rel.r_type == MIPS_R_PCREL16)
- {
- unsigned long insn;
-
- /* We only care about local references. External ones
- will be relocated correctly anyhow. */
- if (adj_int_rel.r_extern)
- continue;
-
- /* We are only interested in a PC relative reloc within
- this section. FIXME: Cross section PC relative
- relocs may not be handled correctly; does anybody
- care? */
- if (adj_int_rel.r_symndx != RELOC_SECTION_TEXT)
- continue;
-
- start = adj_int_rel.r_vaddr;
-
- insn = bfd_get_32 (abfd,
- contents + adj_int_rel.r_vaddr - sec->vma);
-
- stop = (insn & 0xffff) << 2;
- if ((stop & 0x20000) != 0)
- stop -= 0x40000;
- stop += adj_int_rel.r_vaddr + 4;
- }
- else if (adj_int_rel.r_type == MIPS_R_RELHI)
- {
- struct internal_reloc rello;
- long addhi, addlo;
-
- /* The next reloc must be MIPS_R_RELLO, and we handle
- them together. */
- BFD_ASSERT (adj_ext_rel + 1 < ext_rel_end);
-
- mips_ecoff_swap_reloc_in (abfd, (PTR) (adj_ext_rel + 1), &rello);
-
- BFD_ASSERT (rello.r_type == MIPS_R_RELLO);
-
- addhi = bfd_get_32 (abfd,
- contents + adj_int_rel.r_vaddr - sec->vma);
- addhi &= 0xffff;
- if (addhi & 0x8000)
- addhi -= 0x10000;
- addhi <<= 16;
-
- addlo = bfd_get_32 (abfd, contents + rello.r_vaddr - sec->vma);
- addlo &= 0xffff;
- if (addlo & 0x8000)
- addlo -= 0x10000;
-
- if (adj_int_rel.r_extern)
- {
- /* The value we want here is
- sym - RELLOaddr + addend
- which we can express as
- sym - (RELLOaddr - addend)
- Therefore if we are expanding the area between
- RELLOaddr and RELLOaddr - addend we must adjust
- the addend. This is admittedly ambiguous, since
- we might mean (sym + addend) - RELLOaddr, but in
- practice we don't, and there is no way to handle
- that case correctly since at this point we have
- no idea whether any reloc is being expanded
- between sym and sym + addend. */
- start = rello.r_vaddr - (addhi + addlo);
- stop = rello.r_vaddr;
- }
- else
- {
- /* An internal RELHI/RELLO pair represents the
- difference between two addresses, $LC0 - foo.
- The symndx value is actually the difference
- between the reloc address and $LC0. This lets us
- compute $LC0, and, by considering the addend,
- foo. If the reloc we are expanding falls between
- those two relocs, we must adjust the addend. At
- this point, the symndx value is actually in the
- r_offset field, where it was put by
- mips_ecoff_swap_reloc_in. */
- start = rello.r_vaddr - adj_int_rel.r_offset;
- stop = start + addhi + addlo;
- }
- }
- else if (adj_int_rel.r_type == MIPS_R_SWITCH)
- {
- /* A MIPS_R_SWITCH reloc represents a word of the form
- .word $L3-$LS12
- The value in the object file is correct, assuming the
- original value of $L3. The symndx value is actually
- the difference between the reloc address and $LS12.
- This lets us compute the original value of $LS12 as
- vaddr - symndx
- and the original value of $L3 as
- vaddr - symndx + addend
- where addend is the value from the object file. At
- this point, the symndx value is actually found in the
- r_offset field, since it was moved by
- mips_ecoff_swap_reloc_in. */
- start = adj_int_rel.r_vaddr - adj_int_rel.r_offset;
- stop = start + bfd_get_32 (abfd,
- (contents
- + adj_int_rel.r_vaddr
- - sec->vma));
- }
- else
- continue;
-
- /* If the range expressed by this reloc, which is the
- distance between START and STOP crosses the reloc we are
- expanding, we must adjust the offset. The sign of the
- adjustment depends upon the direction in which the range
- crosses the reloc being expanded. */
- if (start <= int_rel.r_vaddr && stop > int_rel.r_vaddr)
- change = PCREL16_EXPANSION_ADJUSTMENT;
- else if (start > int_rel.r_vaddr && stop <= int_rel.r_vaddr)
- change = - PCREL16_EXPANSION_ADJUSTMENT;
- else
- change = 0;
-
- offsets[adj_i] += change;
-
- if (adj_int_rel.r_type == MIPS_R_RELHI)
- {
- adj_ext_rel++;
- adj_i++;
- offsets[adj_i] += change;
- }
- }
-
- /* Find all symbols in this section defined by this object file
- and adjust their values. Note that we decide whether to
- adjust the value based on the value stored in the ECOFF EXTR
- structure, because the value stored in the hash table may
- have been changed by an earlier expanded reloc and thus may
- no longer correctly indicate whether the symbol is before or
- after the expanded reloc. */
- ext_count = ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
- adj_h_ptr = ecoff_data (abfd)->sym_hashes;
- adj_h_ptr_end = adj_h_ptr + ext_count;
- for (; adj_h_ptr < adj_h_ptr_end; adj_h_ptr++)
- {
- struct ecoff_link_hash_entry *adj_h;
-
- adj_h = *adj_h_ptr;
- if (adj_h != (struct ecoff_link_hash_entry *) NULL
- && (adj_h->root.type == bfd_link_hash_defined
- || adj_h->root.type == bfd_link_hash_defweak)
- && adj_h->root.u.def.section == sec
- && adj_h->esym.asym.value > int_rel.r_vaddr)
- adj_h->root.u.def.value += PCREL16_EXPANSION_ADJUSTMENT;
- }
-
- /* Add an entry to the symbol value adjust list. This is used
- by bfd_ecoff_debug_accumulate to adjust the values of
- internal symbols and FDR's. */
- adjust = ((struct ecoff_value_adjust *)
- bfd_alloc (abfd, sizeof (struct ecoff_value_adjust)));
- if (adjust == (struct ecoff_value_adjust *) NULL)
- goto error_return;
-
- adjust->start = int_rel.r_vaddr;
- adjust->end = sec->vma + sec->_raw_size;
- adjust->adjust = PCREL16_EXPANSION_ADJUSTMENT;
-
- adjust->next = ecoff_data (abfd)->debug_info.adjust;
- ecoff_data (abfd)->debug_info.adjust = adjust;
- }
-
- if (contents != (bfd_byte *) NULL && ! info->keep_memory)
- free (contents);
-
- return true;
-
- error_return:
- if (contents != (bfd_byte *) NULL && ! info->keep_memory)
- free (contents);
- return false;
-}
-
-/* This routine is called from mips_relocate_section when a PC
- relative reloc must be expanded into the five instruction sequence.
- It handles all the details of the expansion, including resolving
- the reloc. */
-
-static boolean
-mips_relax_pcrel16 (info, input_bfd, input_section, h, location, address)
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- struct ecoff_link_hash_entry *h;
- bfd_byte *location;
- bfd_vma address;
-{
- bfd_vma relocation;
-
- /* 0x0411ffff is bgezal $0,. == bal . */
- BFD_ASSERT (bfd_get_32 (input_bfd, location) == 0x0411ffff);
-
- /* We need to compute the distance between the symbol and the
- current address plus eight. */
- relocation = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- relocation -= address + 8;
-
- /* If the lower half is negative, increment the upper 16 half. */
- if ((relocation & 0x8000) != 0)
- relocation += 0x10000;
-
- bfd_put_32 (input_bfd, 0x04110001, location); /* bal .+8 */
- bfd_put_32 (input_bfd,
- 0x3c010000 | ((relocation >> 16) & 0xffff), /* lui $at,XX */
- location + 4);
- bfd_put_32 (input_bfd,
- 0x24210000 | (relocation & 0xffff), /* addiu $at,$at,XX */
- location + 8);
- bfd_put_32 (input_bfd, 0x003f0821, location + 12); /* addu $at,$at,$ra */
- bfd_put_32 (input_bfd, 0x0020f809, location + 16); /* jalr $at */
-
- return true;
-}
-
-/* Given a .sdata section and a .rel.sdata in-memory section, store
- relocation information into the .rel.sdata section which can be
- used at runtime to relocate the section. This is called by the
- linker when the --embedded-relocs switch is used. This is called
- after the add_symbols entry point has been called for all the
- objects, and before the final_link entry point is called. This
- function presumes that the object was compiled using
- -membedded-pic. */
-
-boolean
-bfd_mips_ecoff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *datasec;
- asection *relsec;
- char **errmsg;
-{
- struct ecoff_link_hash_entry **sym_hashes;
- struct ecoff_section_tdata *section_tdata;
- struct external_reloc *ext_rel;
- struct external_reloc *ext_rel_end;
- bfd_byte *p;
-
- BFD_ASSERT (! info->relocateable);
-
- *errmsg = NULL;
-
- if (datasec->reloc_count == 0)
- return true;
-
- sym_hashes = ecoff_data (abfd)->sym_hashes;
-
- if (! mips_read_relocs (abfd, datasec))
- return false;
-
- relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 4);
- if (relsec->contents == NULL)
- return false;
-
- p = relsec->contents;
-
- section_tdata = ecoff_section_data (abfd, datasec);
- ext_rel = (struct external_reloc *) section_tdata->external_relocs;
- ext_rel_end = ext_rel + datasec->reloc_count;
- for (; ext_rel < ext_rel_end; ext_rel++, p += 4)
- {
- struct internal_reloc int_rel;
- boolean text_relative;
-
- mips_ecoff_swap_reloc_in (abfd, (PTR) ext_rel, &int_rel);
-
- /* We are going to write a four byte word into the runtime reloc
- section. The word will be the address in the data section
- which must be relocated. This must be on a word boundary,
- which means the lower two bits must be zero. We use the
- least significant bit to indicate how the value in the data
- section must be relocated. A 0 means that the value is
- relative to the text section, while a 1 indicates that the
- value is relative to the data section. Given that we are
- assuming the code was compiled using -membedded-pic, there
- should not be any other possibilities. */
-
- /* We can only relocate REFWORD relocs at run time. */
- if (int_rel.r_type != MIPS_R_REFWORD)
- {
- *errmsg = "unsupported reloc type";
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- if (int_rel.r_extern)
- {
- struct ecoff_link_hash_entry *h;
-
- h = sym_hashes[int_rel.r_symndx];
- /* If h is NULL, that means that there is a reloc against an
- external symbol which we thought was just a debugging
- symbol. This should not happen. */
- if (h == (struct ecoff_link_hash_entry *) NULL)
- abort ();
- if ((h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && (h->root.u.def.section->flags & SEC_CODE) != 0)
- text_relative = true;
- else
- text_relative = false;
- }
- else
- {
- switch (int_rel.r_symndx)
- {
- case RELOC_SECTION_TEXT:
- text_relative = true;
- break;
- case RELOC_SECTION_SDATA:
- case RELOC_SECTION_SBSS:
- case RELOC_SECTION_LIT8:
- text_relative = false;
- break;
- default:
- /* No other sections should appear in -membedded-pic
- code. */
- *errmsg = "reloc against unsupported section";
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- }
-
- if ((int_rel.r_offset & 3) != 0)
- {
- *errmsg = "reloc not properly aligned";
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- bfd_put_32 (abfd,
- (int_rel.r_vaddr - datasec->vma + datasec->output_offset
- + (text_relative ? 0 : 1)),
- p);
- }
-
- return true;
-}
-
-/* This is the ECOFF backend structure. The backend field of the
- target vector points to this. */
-
-static const struct ecoff_backend_data mips_ecoff_backend_data =
-{
- /* COFF backend structure. */
- {
- (void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
- (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
- (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
- (unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
- (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
- (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
- (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
- mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out,
- mips_ecoff_swap_scnhdr_out,
- FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, true,
- mips_ecoff_swap_filehdr_in, mips_ecoff_swap_aouthdr_in,
- mips_ecoff_swap_scnhdr_in, NULL,
- mips_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
- _bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
- _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
- },
- /* Supported architecture. */
- bfd_arch_mips,
- /* Initial portion of armap string. */
- "__________",
- /* The page boundary used to align sections in a demand-paged
- executable file. E.g., 0x1000. */
- 0x1000,
- /* True if the .rdata section is part of the text segment, as on the
- Alpha. False if .rdata is part of the data segment, as on the
- MIPS. */
- false,
- /* Bitsize of constructor entries. */
- 32,
- /* Reloc to use for constructor entries. */
- &mips_howto_table[MIPS_R_REFWORD],
- {
- /* Symbol table magic number. */
- magicSym,
- /* Alignment of debugging information. E.g., 4. */
- 4,
- /* Sizes of external symbolic information. */
- sizeof (struct hdr_ext),
- sizeof (struct dnr_ext),
- sizeof (struct pdr_ext),
- sizeof (struct sym_ext),
- sizeof (struct opt_ext),
- sizeof (struct fdr_ext),
- sizeof (struct rfd_ext),
- sizeof (struct ext_ext),
- /* Functions to swap in external symbolic data. */
- ecoff_swap_hdr_in,
- ecoff_swap_dnr_in,
- ecoff_swap_pdr_in,
- ecoff_swap_sym_in,
- ecoff_swap_opt_in,
- ecoff_swap_fdr_in,
- ecoff_swap_rfd_in,
- ecoff_swap_ext_in,
- _bfd_ecoff_swap_tir_in,
- _bfd_ecoff_swap_rndx_in,
- /* Functions to swap out external symbolic data. */
- ecoff_swap_hdr_out,
- ecoff_swap_dnr_out,
- ecoff_swap_pdr_out,
- ecoff_swap_sym_out,
- ecoff_swap_opt_out,
- ecoff_swap_fdr_out,
- ecoff_swap_rfd_out,
- ecoff_swap_ext_out,
- _bfd_ecoff_swap_tir_out,
- _bfd_ecoff_swap_rndx_out,
- /* Function to read in symbolic data. */
- _bfd_ecoff_slurp_symbolic_info
- },
- /* External reloc size. */
- RELSZ,
- /* Reloc swapping functions. */
- mips_ecoff_swap_reloc_in,
- mips_ecoff_swap_reloc_out,
- /* Backend reloc tweaking. */
- mips_adjust_reloc_in,
- mips_adjust_reloc_out,
- /* Relocate section contents while linking. */
- mips_relocate_section,
- /* Do final adjustments to filehdr and aouthdr. */
- NULL,
- /* Read an element from an archive at a given file position. */
- _bfd_get_elt_at_filepos
-};
-
-/* Looking up a reloc type is MIPS specific. */
-#define _bfd_ecoff_bfd_reloc_type_lookup mips_bfd_reloc_type_lookup
-
-/* Getting relocated section contents is generic. */
-#define _bfd_ecoff_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-
-/* Handling file windows is generic. */
-#define _bfd_ecoff_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-/* Relaxing sections is MIPS specific. */
-#define _bfd_ecoff_bfd_relax_section mips_relax_section
-
-const bfd_target ecoff_little_vec =
-{
- "ecoff-littlemips", /* name */
- bfd_target_ecoff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- _bfd_ecoff_archive_p, _bfd_dummy_target},
- {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
- BFD_JUMP_TABLE_COPY (_bfd_ecoff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
- BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
- BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
- BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
- BFD_JUMP_TABLE_LINK (_bfd_ecoff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) &mips_ecoff_backend_data
-};
-
-const bfd_target ecoff_big_vec =
-{
- "ecoff-bigmips", /* name */
- bfd_target_ecoff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- _bfd_ecoff_archive_p, _bfd_dummy_target},
- {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
- BFD_JUMP_TABLE_COPY (_bfd_ecoff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_ecoff),
- BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
- BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
- BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
- BFD_JUMP_TABLE_LINK (_bfd_ecoff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) &mips_ecoff_backend_data
-};
diff --git a/contrib/gdb/bfd/coff-pmac.c b/contrib/gdb/bfd/coff-pmac.c
deleted file mode 100644
index f3332d9..0000000
--- a/contrib/gdb/bfd/coff-pmac.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* BFD back-end for Apple et al PowerPC Mac "XCOFF" files.
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_SYM pmac_xcoff_vec
-#define TARGET_NAME "xcoff-powermac"
-
-/* Tweak coffcode.h based on this being a PowerMac instead of RS/6000. */
-
-#define POWERMAC
-
-#include "coff-rs6000.c"
diff --git a/contrib/gdb/bfd/coff-ppc.c b/contrib/gdb/bfd/coff-ppc.c
deleted file mode 100644
index 4caf3d8..0000000
--- a/contrib/gdb/bfd/coff-ppc.c
+++ /dev/null
@@ -1,3255 +0,0 @@
-/* BFD back-end for PowerPC Microsoft Portable Executable files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
-
- Original version pieced together by Kim Knuttila (krk@cygnus.com)
-
- There is nothing new under the sun. This file draws a lot on other
- coff files, in particular, those for the rs/6000, alpha, mips, and
- intel backends, and the PE work for the arm.
-
-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. */
-
-/* Current State:
- - objdump works
- - relocs generated by gas
- - ld will link files, but they do not run.
- - dlltool will not produce correct output in some .reloc cases, and will
- not produce the right glue code for dll function calls.
-*/
-
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#include "libbfd.h"
-#include "obstack.h"
-
-#include "coff/powerpc.h"
-#include "coff/internal.h"
-
-#include "coff/pe.h"
-
-#ifdef BADMAG
-#undef BADMAG
-#endif
-
-#define BADMAG(x) PPCBADMAG(x)
-
-#include "libcoff.h"
-
-/* The toc is a set of bfd_vma fields. We use the fact that valid */
-/* addresses are even (i.e. the bit representing "1" is off) to allow */
-/* us to encode a little extra information in the field */
-/* - Unallocated addresses are intialized to 1. */
-/* - Allocated addresses are even numbers. */
-/* The first time we actually write a reference to the toc in the bfd, */
-/* we want to record that fact in a fixup file (if it is asked for), so */
-/* we keep track of whether or not an address has been written by marking */
-/* the low order bit with a "1" upon writing */
-
-#define SET_UNALLOCATED(x) ((x) = 1)
-#define IS_UNALLOCATED(x) ((x) == 1)
-
-#define IS_WRITTEN(x) ((x) & 1)
-#define MARK_AS_WRITTEN(x) ((x) |= 1)
-#define MAKE_ADDR_AGAIN(x) ((x) &= ~1)
-
-/* In order not to add an int to every hash table item for every coff
- linker, we define our own hash table, derived from the coff one */
-
-/* PE linker hash table entries. */
-
-struct ppc_coff_link_hash_entry
-{
- struct coff_link_hash_entry root; /* First entry, as required */
-
- /* As we wonder around the relocs, we'll keep the assigned toc_offset
- here */
- bfd_vma toc_offset; /* Our addition, as required */
- int symbol_is_glue;
- unsigned long int glue_insn;
- char eye_catcher[8];
-};
-
-/* Need a 7 char string for an eye catcher */
-#define EYE "krkjunk"
-
-#define CHECK_EYE(addr) \
- if (strcmp(addr, EYE) != 0) \
- { \
- fprintf(stderr,\
- "File %s, line %d, Hash check failure, bad eye %8s\n", \
- __FILE__, __LINE__, addr); \
- abort(); \
- }
-
-/* PE linker hash table. */
-
-struct ppc_coff_link_hash_table
-{
- struct coff_link_hash_table root; /* First entry, as required */
-};
-
-static struct bfd_hash_entry *ppc_coff_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
- const char *));
-
-/* Routine to create an entry in the link hash table. */
-
-static struct bfd_hash_entry *
-ppc_coff_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct ppc_coff_link_hash_entry *ret =
- (struct ppc_coff_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct ppc_coff_link_hash_entry *) NULL)
- ret = (struct ppc_coff_link_hash_entry *)
- bfd_hash_allocate (table,
- sizeof (struct ppc_coff_link_hash_entry));
-
- if (ret == (struct ppc_coff_link_hash_entry *) NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct ppc_coff_link_hash_entry *)
- _bfd_coff_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- SET_UNALLOCATED(ret->toc_offset);
- ret->symbol_is_glue = 0;
- ret->glue_insn = 0;
- strcpy(ret->eye_catcher, EYE);
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize a PE linker hash table. */
-
-static boolean
-ppc_coff_link_hash_table_init (table, abfd, newfunc)
- struct ppc_coff_link_hash_table *table;
- bfd *abfd;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc);
-}
-
-/* Create a PE linker hash table. */
-
-static struct bfd_link_hash_table *
-ppc_coff_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct ppc_coff_link_hash_table *ret;
-
- ret = ((struct ppc_coff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct ppc_coff_link_hash_table)));
- if (ret == NULL)
- return NULL;
- if (! ppc_coff_link_hash_table_init (ret, abfd,
- ppc_coff_link_hash_newfunc))
- {
- bfd_release (abfd, ret);
- return (struct bfd_link_hash_table *) NULL;
- }
- return &ret->root.root;
-}
-
-/* Now, tailor coffcode.h to use our hash stuff */
-
-#define coff_bfd_link_hash_table_create ppc_coff_link_hash_table_create
-
-
-/* The nt loader points the toc register to &toc + 32768, in order to */
-/* use the complete range of a 16-bit displacement (I guess). We have */
-/* to adjust for this when we fix up loads displaced off the toc reg. */
-#define TOC_LOAD_ADJUSTMENT (-32768)
-#define TOC_SECTION_NAME ".private.toc"
-
-/* The main body of code is in coffcode.h. */
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-
-/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
- from smaller values. Start with zero, widen, *then* decrement. */
-#define MINUS_ONE (((bfd_vma)0) - 1)
-
-/* these should definitely go in a header file somewhere... */
-
-/* NOP */
-#define IMAGE_REL_PPC_ABSOLUTE 0x0000
-
-/* 64-bit address */
-#define IMAGE_REL_PPC_ADDR64 0x0001
-
-/* 32-bit address */
-#define IMAGE_REL_PPC_ADDR32 0x0002
-
-/* 26-bit address, shifted left 2 (branch absolute) */
-#define IMAGE_REL_PPC_ADDR24 0x0003
-
-/* 16-bit address */
-#define IMAGE_REL_PPC_ADDR16 0x0004
-
-/* 16-bit address, shifted left 2 (load doubleword) */
-#define IMAGE_REL_PPC_ADDR14 0x0005
-
-/* 26-bit PC-relative offset, shifted left 2 (branch relative) */
-#define IMAGE_REL_PPC_REL24 0x0006
-
-/* 16-bit PC-relative offset, shifted left 2 (br cond relative) */
-#define IMAGE_REL_PPC_REL14 0x0007
-
-/* 16-bit offset from TOC base */
-#define IMAGE_REL_PPC_TOCREL16 0x0008
-
-/* 16-bit offset from TOC base, shifted left 2 (load doubleword) */
-#define IMAGE_REL_PPC_TOCREL14 0x0009
-
-/* 32-bit addr w/o image base */
-#define IMAGE_REL_PPC_ADDR32NB 0x000A
-
-/* va of containing section (as in an image sectionhdr) */
-#define IMAGE_REL_PPC_SECREL 0x000B
-
-/* sectionheader number */
-#define IMAGE_REL_PPC_SECTION 0x000C
-
-/* substitute TOC restore instruction iff symbol is glue code */
-#define IMAGE_REL_PPC_IFGLUE 0x000D
-
-/* symbol is glue code; virtual address is TOC restore instruction */
-#define IMAGE_REL_PPC_IMGLUE 0x000E
-
-/* va of containing section (limited to 16 bits) */
-#define IMAGE_REL_PPC_SECREL16 0x000F
-
-/* stuff to handle immediate data when the number of bits in the */
-/* data is greater than the number of bits in the immediate field */
-/* We need to do (usually) 32 bit arithmetic on 16 bit chunks */
-#define IMAGE_REL_PPC_REFHI 0x0010
-#define IMAGE_REL_PPC_REFLO 0x0011
-#define IMAGE_REL_PPC_PAIR 0x0012
-
-/* This is essentially the same as tocrel16, with TOCDEFN assumed */
-#define IMAGE_REL_PPC_TOCREL16_DEFN 0x0013
-
-/* Flag bits in IMAGE_RELOCATION.TYPE */
-
-/* subtract reloc value rather than adding it */
-#define IMAGE_REL_PPC_NEG 0x0100
-
-/* fix branch prediction bit to predict branch taken */
-#define IMAGE_REL_PPC_BRTAKEN 0x0200
-
-/* fix branch prediction bit to predict branch not taken */
-#define IMAGE_REL_PPC_BRNTAKEN 0x0400
-
-/* toc slot defined in file (or, data in toc) */
-#define IMAGE_REL_PPC_TOCDEFN 0x0800
-
-/* masks to isolate above values in IMAGE_RELOCATION.Type */
-#define IMAGE_REL_PPC_TYPEMASK 0x00FF
-#define IMAGE_REL_PPC_FLAGMASK 0x0F00
-
-#define EXTRACT_TYPE(x) ((x) & IMAGE_REL_PPC_TYPEMASK)
-#define EXTRACT_FLAGS(x) ((x) & IMAGE_REL_PPC_FLAGMASK)
-#define EXTRACT_JUNK(x) \
- ((x) & ~(IMAGE_REL_PPC_TYPEMASK | IMAGE_REL_PPC_FLAGMASK))
-
-
-/* static helper functions to make relocation work */
-/* (Work In Progress) */
-
-static bfd_reloc_status_type ppc_refhi_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type ppc_reflo_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type ppc_pair_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-
-
-static bfd_reloc_status_type ppc_toc16_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-
-static bfd_reloc_status_type ppc_addr32nb_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-
-static bfd_reloc_status_type ppc_section_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-
-static bfd_reloc_status_type ppc_secrel_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-
-static bfd_reloc_status_type ppc_imglue_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-
-
-
-static boolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto));
-
-
-/* FIXME: It'll take a while to get through all of these. I only need a few to
- get us started, so those I'll make sure work. Those marked FIXME are either
- completely unverified or have a specific unknown marked in the comment */
-
-/*---------------------------------------------------------------------------*/
-/* */
-/* Relocation entries for Windows/NT on PowerPC. */
-/* */
-/* From the document "" we find the following listed as used relocs: */
-/* */
-/* ABSOLUTE : The noop */
-/* ADDR[64|32|16] : fields that hold addresses in data fields or the */
-/* 16 bit displacement field on a load/store. */
-/* ADDR[24|14] : fields that hold addresses in branch and cond */
-/* branches. These represent [26|16] bit addresses. */
-/* The low order 2 bits are preserved. */
-/* REL[24|14] : branches relative to the Instruction Address */
-/* register. These represent [26|16] bit addresses, */
-/* as before. The instruction field will be zero, and */
-/* the address of the SYM will be inserted at link time. */
-/* TOCREL16 : 16 bit displacement field referring to a slot in */
-/* toc. */
-/* TOCREL14 : 16 bit displacement field, similar to REL14 or ADDR14. */
-/* ADDR32NB : 32 bit address relative to the virtual origin. */
-/* (On the alpha, this is always a linker generated thunk)*/
-/* (i.e. 32bit addr relative to the image base) */
-/* SECREL : The value is relative to the start of the section */
-/* containing the symbol. */
-/* SECTION : access to the header containing the item. Supports the */
-/* codeview debugger. */
-/* */
-/* In particular, note that the document does not indicate that the */
-/* relocations listed in the header file are used. */
-/* */
-/* */
-/* */
-/*---------------------------------------------------------------------------*/
-
-static reloc_howto_type ppc_coff_howto_table[] =
-{
- /* IMAGE_REL_PPC_ABSOLUTE 0x0000 NOP */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_ABSOLUTE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* dont complain_on_overflow */
- 0, /* special_function */
- "ABSOLUTE", /* name */
- false, /* partial_inplace */
- 0x00, /* src_mask */
- 0x00, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_ADDR64 0x0001 64-bit address */
- /* Unused: */
- HOWTO(IMAGE_REL_PPC_ADDR64, /* type */
- 0, /* rightshift */
- 3, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "ADDR64", /* name */
- true, /* partial_inplace */
- MINUS_ONE, /* src_mask */
- MINUS_ONE, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_ADDR32 0x0002 32-bit address */
- /* Used: */
- HOWTO (IMAGE_REL_PPC_ADDR32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "ADDR32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_ADDR24 0x0003 26-bit address, shifted left 2 (branch absolute) */
- /* the LI field is in bit 6 through bit 29 is 24 bits, + 2 for the shift */
- /* Of course, That's the IBM approved bit numbering, which is not what */
- /* anyone else uses.... The li field is in bit 2 thru 25 */
- /* Used: */
- HOWTO (IMAGE_REL_PPC_ADDR24, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "ADDR24", /* name */
- true, /* partial_inplace */
- 0x07fffffc, /* src_mask */
- 0x07fffffc, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_ADDR16 0x0004 16-bit address */
- /* Used: */
- HOWTO (IMAGE_REL_PPC_ADDR16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "ADDR16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_ADDR14 0x0005 */
- /* 16-bit address, shifted left 2 (load doubleword) */
- /* FIXME: the mask is likely wrong, and the bit position may be as well */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_ADDR14, /* type */
- 1, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "ADDR16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_REL24 0x0006 */
- /* 26-bit PC-relative offset, shifted left 2 (branch relative) */
- /* Used: */
- HOWTO (IMAGE_REL_PPC_REL24, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "REL24", /* name */
- true, /* partial_inplace */
- 0x3fffffc, /* src_mask */
- 0x3fffffc, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_REL14 0x0007 */
- /* 16-bit PC-relative offset, shifted left 2 (br cond relative) */
- /* FIXME: the mask is likely wrong, and the bit position may be as well */
- /* FIXME: how does it know how far to shift? */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_ADDR14, /* type */
- 1, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "ADDR16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_TOCREL16 0x0008 */
- /* 16-bit offset from TOC base */
- /* Used: */
- HOWTO (IMAGE_REL_PPC_TOCREL16,/* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- ppc_toc16_reloc, /* special_function */
- "TOCREL16", /* name */
- false, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_TOCREL14 0x0009 */
- /* 16-bit offset from TOC base, shifted left 2 (load doubleword) */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_TOCREL14,/* type */
- 1, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "TOCREL14", /* name */
- false, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_ADDR32NB 0x000A */
- /* 32-bit addr w/ image base */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_ADDR32NB,/* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "ADDR32NB", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_SECREL 0x000B */
- /* va of containing section (as in an image sectionhdr) */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_SECREL,/* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- ppc_secrel_reloc, /* special_function */
- "SECREL", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_SECTION 0x000C */
- /* sectionheader number */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_SECTION,/* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- ppc_section_reloc, /* special_function */
- "SECTION", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_IFGLUE 0x000D */
- /* substitute TOC restore instruction iff symbol is glue code */
- /* Used: */
- HOWTO (IMAGE_REL_PPC_IFGLUE,/* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "IFGLUE", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_IMGLUE 0x000E */
- /* symbol is glue code; virtual address is TOC restore instruction */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_IMGLUE,/* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- ppc_imglue_reloc, /* special_function */
- "IMGLUE", /* name */
- false, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_SECREL16 0x000F */
- /* va of containing section (limited to 16 bits) */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_SECREL16,/* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "SECREL16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_REFHI 0x0010 */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_REFHI, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- ppc_refhi_reloc, /* special_function */
- "REFHI", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_REFLO 0x0011 */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_REFLO, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- ppc_refhi_reloc, /* special_function */
- "REFLO", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_PAIR 0x0012 */
- /* Unused: */
- HOWTO (IMAGE_REL_PPC_PAIR, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- ppc_pair_reloc, /* special_function */
- "PAIR", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* IMAGE_REL_PPC_TOCREL16_DEFN 0x0013 */
- /* 16-bit offset from TOC base, without causing a definition */
- /* Used: */
- HOWTO ( (IMAGE_REL_PPC_TOCREL16 | IMAGE_REL_PPC_TOCDEFN), /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "TOCREL16, TOCDEFN", /* name */
- false, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
-};
-
-
-
-
-/* Some really cheezy macros that can be turned on to test stderr :-) */
-
-#ifdef DEBUG_RELOC
-#define UN_IMPL(x) \
-{ \
- static int i; \
- if (i == 0) \
- { \
- i = 1; \
- fprintf(stderr,"Unimplemented Relocation -- %s\n",x); \
- } \
-}
-
-#define DUMP_RELOC(n,r) \
-{ \
- fprintf(stderr,"%s sym %d, addr %d, addend %d\n", \
- n, (*(r->sym_ptr_ptr))->name, \
- r->address, r->addend); \
-}
-
-/* Given a reloc name, n, and a pointer to an internal_reloc,
- dump out interesting information on the contents
-
-#define n_name _n._n_name
-#define n_zeroes _n._n_n._n_zeroes
-#define n_offset _n._n_n._n_offset
-
-*/
-
-#define DUMP_RELOC2(n,r) \
-{ \
- fprintf(stderr,"%s sym %d, r_vaddr %d %s\n", \
- n, r->r_symndx, r->r_vaddr,\
- (((r->r_type) & IMAGE_REL_PPC_TOCDEFN) == 0) \
- ?" ":" TOCDEFN" ); \
-}
-
-#else
-#define UN_IMPL(x)
-#define DUMP_RELOC(n,r)
-#define DUMP_RELOC2(n,r)
-#endif
-
-
-
-/* toc construction and management routines */
-extern bfd* bfd_of_toc_owner;
-extern long int global_toc_size;
-
-extern long int import_table_size;
-extern long int first_thunk_address;
-extern long int thunk_size;
-
-enum toc_type
-{
- default_toc,
- toc_32,
- toc_64
-};
-
-enum ref_category
-{
- priv,
- pub,
- data
-};
-
-struct list_ele
-{
- struct list_ele *next;
- bfd_vma addr;
- enum ref_category cat;
- int offset;
- const char *name;
-};
-
-extern struct list_ele *head;
-extern struct list_ele *tail;
-
-static void
-record_toc(toc_section, our_toc_offset, cat, name)
- asection *toc_section;
- int our_toc_offset;
- enum ref_category cat;
- const char *name;
-{
- /* add this entry to our toc addr-offset-name list */
- struct list_ele *t;
- t = bfd_malloc (sizeof (struct list_ele));
- if (t == NULL)
- abort ();
- t->next = 0;
- t->offset = our_toc_offset;
- t->name = name;
- t->cat = cat;
- t->addr = toc_section->output_offset + our_toc_offset;
-
- if (head == 0)
- {
- head = t;
- tail = t;
- }
- else
- {
- tail->next = t;
- tail = t;
- }
-}
-
-/* record a toc offset against a symbol */
-static int
-ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- int sym;
- enum toc_type toc_kind;
-{
- bfd_byte *t;
- bfd_byte *old_contents;
- asection *s;
- int element_size;
- int data;
- int offset;
- struct ppc_coff_link_hash_entry *h;
- struct coff_symbol_struct *target;
- int ret_val;
- const char *name;
-
- int *local_syms;
-
- h = 0;
-
- h = (struct ppc_coff_link_hash_entry *) (obj_coff_sym_hashes (abfd)[sym]);
- if (h != 0)
- {
- CHECK_EYE(h->eye_catcher);
- }
-
- if (h == 0)
- {
- local_syms = obj_coff_local_toc_table(abfd);
- if (local_syms == 0)
- {
- int i;
- /* allocate a table */
- local_syms =
- (int *) bfd_zalloc (abfd,
- obj_raw_syment_count(abfd) * sizeof(int));
- if (local_syms == 0)
- return false;
- obj_coff_local_toc_table(abfd) = local_syms;
- for (i = 0; i < obj_raw_syment_count(abfd); ++i)
- {
- SET_UNALLOCATED(local_syms[i]);
- }
- }
-
- if (IS_UNALLOCATED(local_syms[sym]))
- {
- local_syms[sym] = global_toc_size;
- ret_val = global_toc_size;
- global_toc_size += 4;
-
- /* The size must fit in a 16bit displacment */
- if (global_toc_size >= 65535)
- {
- fprintf(stderr,
- "Exceeded toc size of 65535\n");
- abort();
- }
-
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "Setting toc_offset for local sym %d to %d\n",
- sym, ret_val);
-#endif
- }
- else
- {
- ret_val = local_syms[sym];
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "toc_offset already set for local sym %d to %d\n",
- sym, ret_val);
-#endif
- }
- }
- else
- {
- name = h->root.root.root.string;
-
- /* check to see if there's a toc slot allocated. If not, do it
- here. It will be used in relocate_section */
- if (IS_UNALLOCATED(h->toc_offset))
- {
- h->toc_offset = global_toc_size;
- ret_val = global_toc_size;
- global_toc_size += 4;
-
- /* The size must fit in a 16bit displacment */
- if (global_toc_size >= 65535)
- {
- fprintf(stderr,
- "Exceeded toc size of 65535\n");
- abort();
- }
-
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "Setting toc_offset for sym %d (%s) [h=%p] to %d\n",
- sym, name, h, ret_val);
-#endif
- }
- else
- {
- ret_val = h->toc_offset;
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "toc_offset already set for sym %d (%s) [h=%p] to %d\n",
- sym, name, h, ret_val);
-#endif
- }
- }
-
- return ret_val;
-}
-/* FIXME: record a toc offset against a data-in-toc symbol */
-/* Now, there is currenly some confusion on what this means. In some
- compilers one sees the moral equivalent of:
- .tocd
- define some data
- .text
- refer to the data with a [tocv] qualifier
- In general, one sees something to indicate that a tocd has been
- seen, and that would trigger the allocation of data in toc. The IBM
- docs seem to suggest that anything with the TOCDEFN qualifier should
- never trigger storage allocation. However, in the kernel32.lib that
- we've been using for our test bed, there are a couple of variables
- referenced that fail that test.
-
- So it can't work that way.
-*/
-static int
-ppc_record_data_in_toc_entry(abfd, info, sec, sym, toc_kind)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- int sym;
- enum toc_type toc_kind;
-{
- bfd_byte *t;
- bfd_byte *old_contents;
- asection *s;
- int element_size;
- int data;
- int offset;
- struct ppc_coff_link_hash_entry *h = 0;
- struct coff_symbol_struct *target;
- int ret_val;
- const char *name;
-
- int *local_syms;
-
- h = (struct ppc_coff_link_hash_entry *) (obj_coff_sym_hashes (abfd)[sym]);
-
- if (h == 0)
- {
- local_syms = obj_coff_local_toc_table(abfd);
- if (local_syms == 0)
- {
- int i;
- /* allocate a table */
- local_syms =
- (int *) bfd_zalloc (abfd,
- obj_raw_syment_count(abfd) * sizeof(int));
- if (local_syms == 0)
- return false;
- obj_coff_local_toc_table(abfd) = local_syms;
- for (i = 0; i < obj_raw_syment_count(abfd); ++i)
- {
- SET_UNALLOCATED(local_syms[i]);
- }
- }
-
- if (IS_UNALLOCATED(local_syms[sym]))
- {
- local_syms[sym] = global_toc_size;
- ret_val = global_toc_size;
- global_toc_size += 4;
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "Setting data_in_toc_offset for local sym %d to %d\n",
- sym, ret_val);
-#endif
- }
- else
- {
- ret_val = local_syms[sym];
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "data_in_toc_offset already set for local sym %d to %d\n",
- sym, ret_val);
-#endif
- }
- }
- else
- {
- CHECK_EYE(h->eye_catcher);
-
- name = h->root.root.root.string;
-
- /* check to see if there's a toc slot allocated. If not, do it
- here. It will be used in relocate_section */
- if (IS_UNALLOCATED(h->toc_offset))
- {
-#if 0
- h->toc_offset = global_toc_size;
-#endif
- ret_val = global_toc_size;
- /* We're allocating a chunk of the toc, as opposed to a slot */
- /* FIXME: alignment? */
-
- global_toc_size += 4;
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "Setting data_in_toc_offset for sym %d (%s) [h=%p] to %d\n",
- sym, name, h, ret_val);
-#endif
- }
- else
- {
- ret_val = h->toc_offset;
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "data_in_toc_offset already set for sym %d (%s) [h=%p] to %d\n",
- sym, name, h, ret_val);
-#endif
- }
- }
-
- return ret_val;
-}
-
-/* record a toc offset against a symbol */
-static void
-ppc_mark_symbol_as_glue(abfd, sym, rel)
- bfd *abfd;
- int sym;
- struct internal_reloc *rel;
-{
- struct ppc_coff_link_hash_entry *h;
-
- h = (struct ppc_coff_link_hash_entry *) (obj_coff_sym_hashes (abfd)[sym]);
-
- CHECK_EYE(h->eye_catcher);
-
- h->symbol_is_glue = 1;
- h->glue_insn = bfd_get_32 (abfd, (bfd_byte *) &rel->r_vaddr);
-
- return;
-}
-
-
-/* Provided the symbol, returns the value reffed */
-static long get_symbol_value PARAMS ((asymbol *));
-
-static long
-get_symbol_value (symbol)
- asymbol *symbol;
-{
- long relocation = 0;
-
- if (bfd_is_com_section (symbol->section))
- {
- relocation = 0;
- }
- else
- {
- relocation = symbol->value +
- symbol->section->output_section->vma +
- symbol->section->output_offset;
- }
-
- return(relocation);
-}
-
-/* Return true if this relocation should
- appear in the output .reloc section. */
-
-static boolean in_reloc_p(abfd, howto)
- bfd * abfd;
- reloc_howto_type *howto;
-{
- return
- (! howto->pc_relative)
- && (howto->type != IMAGE_REL_PPC_ADDR32NB)
- && (howto->type != IMAGE_REL_PPC_TOCREL16)
- && (howto->type != IMAGE_REL_PPC_IMGLUE)
- && (howto->type != IMAGE_REL_PPC_IFGLUE)
- && (howto->type != IMAGE_REL_PPC_SECREL)
- && (howto->type != IMAGE_REL_PPC_SECTION)
- && (howto->type != IMAGE_REL_PPC_SECREL16)
- && (howto->type != IMAGE_REL_PPC_REFHI)
- && (howto->type != IMAGE_REL_PPC_REFLO)
- && (howto->type != IMAGE_REL_PPC_PAIR)
- && (howto->type != IMAGE_REL_PPC_TOCREL16_DEFN) ;
-}
-
-/* this function is in charge of performing all the ppc PE relocations */
-/* Don't yet know if we want to do this this particular way ... (krk) */
-/* FIXME: (it is not yet enabled) */
-
-static bfd_reloc_status_type
-pe_ppc_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol_in;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- /* 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;
-
- unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
- bfd_byte *hit_data =addr + (bfd_byte *)(data);
-
- fprintf(stderr, "pe_ppc_reloc (%s)\n", TARGET_LITTLE_NAME);
-
- r_type = reloc_entry->howto->type;
-
- if (output_bfd)
- {
- /* Partial linking - do nothing */
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- if (symbol_in != NULL
- && bfd_is_und_section (symbol_in->section))
- {
- /* Keep the state machine happy in case we're called again */
- if (r_type == IMAGE_REL_PPC_REFHI)
- {
- part1_consth_active = true;
- part1_consth_value = 0;
- }
- return(bfd_reloc_undefined);
- }
-
- if ((part1_consth_active) && (r_type != IMAGE_REL_PPC_PAIR))
- {
- part1_consth_active = false;
- *error_message = (char *) "Missing PAIR";
- return(bfd_reloc_dangerous);
- }
-
-
- sym_value = get_symbol_value(symbol_in);
-
- return(bfd_reloc_ok);
-}
-
-/* The reloc processing routine for the optimized COFF linker. */
-
-static boolean
-coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, syms, sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- struct internal_reloc *relocs;
- struct internal_syment *syms;
- asection **sections;
-{
- struct internal_reloc *rel;
- struct internal_reloc *relend;
- boolean hihalf;
- bfd_vma hihalf_val;
- asection *toc_section = 0;
- bfd_vma relocation;
- reloc_howto_type *howto = 0;
-
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- "pe_ppc_relocate_section (%s) for %s in bfd %s\n",
- TARGET_LITTLE_NAME,
- input_section->name,
- input_bfd->filename);
-
-#endif
-
- /* If we are performing a relocateable link, we don't need to do a
- thing. The caller will take care of adjusting the reloc
- addresses and symbol indices. */
- if (info->relocateable)
- return true;
-
- hihalf = false;
- hihalf_val = 0;
-
- rel = relocs;
- relend = rel + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- long symndx;
- struct ppc_coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma val;
-
- asection *sec;
- bfd_reloc_status_type rstat;
- bfd_byte *loc;
-
- unsigned short r_type = EXTRACT_TYPE (rel->r_type);
- unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
- unsigned short junk = EXTRACT_JUNK (rel->r_type);
-
-#ifdef DEBUG_RELOC
- /* now examine flags */
- if (r_flags != 0)
- {
- fprintf (stderr, "Reloc with flags found!");
- if ( r_flags & IMAGE_REL_PPC_NEG )
- fprintf (stderr, " NEG");
- if ( r_flags & IMAGE_REL_PPC_BRTAKEN )
- fprintf (stderr, " BRTAKEN");
- if ( r_flags & IMAGE_REL_PPC_BRNTAKEN )
- fprintf (stderr, " BRNTAKEN");
- if ( r_flags & IMAGE_REL_PPC_TOCDEFN )
- fprintf (stderr, " TOCDEFN");
- fprintf(stderr, "\n");
- }
-#endif
-
- symndx = rel->r_symndx;
- loc = contents + rel->r_vaddr - input_section->vma;
-
- /* FIXME: check bounds on r_type */
- howto = ppc_coff_howto_table + r_type;
-
- if (symndx == -1)
- {
- h = NULL;
- sym = NULL;
- }
- else
- {
- h = (struct ppc_coff_link_hash_entry *)
- (obj_coff_sym_hashes (input_bfd)[symndx]);
- if (h != 0)
- {
- CHECK_EYE(h->eye_catcher);
- }
-
- sym = syms + symndx;
- }
-
- sec = NULL;
- val = 0;
-
- /* FIXME: PAIR unsupported in the following code */
- if (h == NULL)
- {
- if (symndx == -1)
- sec = bfd_abs_section_ptr;
- else
- {
- sec = sections[symndx];
- val = (sec->output_section->vma
- + sec->output_offset
- + sym->n_value
- - sec->vma);
- }
- }
- else
- {
- CHECK_EYE(h->eye_catcher);
-
- if (h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak)
- {
- sec = h->root.root.u.def.section;
- val = (h->root.root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else
- {
-fprintf(stderr,
- "missing %s\n",h->root.root.root.string);
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.root.string, input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
-
- rstat = bfd_reloc_ok;
-
- /* Each case must do its own relocation, setting rstat appropriately */
- switch (r_type)
- {
- default:
- fprintf( stderr,
- "ERROR: during reloc processing -- unsupported reloc %s\n",
- howto->name);
- bfd_set_error (bfd_error_bad_value);
- abort();
- return false;
- case IMAGE_REL_PPC_TOCREL16:
- {
- bfd_vma our_toc_offset;
- int fixit;
-
- DUMP_RELOC2(howto->name, rel);
-
- if (toc_section == 0)
- {
- toc_section = bfd_get_section_by_name (bfd_of_toc_owner,
- TOC_SECTION_NAME);
-#ifdef TOC_DEBUG
-
- fprintf(stderr,
- "BFD of toc owner %p (%s), section addr of %s %p\n",
- bfd_of_toc_owner, bfd_of_toc_owner->filename,
- TOC_SECTION_NAME, toc_section);
-#endif
-
- if ( toc_section == NULL )
- {
- fprintf(stderr, "No Toc section!\n");
- abort();
- }
- }
-
- /*
- * Amazing bit tricks present. As we may have seen earlier, we
- * use the 1 bit to tell us whether or not a toc offset has been
- * allocated. Now that they've all been allocated, we will use
- * the 1 bit to tell us if we've written this particular toc
- * entry out.
- */
- fixit = false;
- if (h == 0)
- { /* it is a file local symbol */
- int *local_toc_table;
- const char *name;
-
- sym = syms + symndx;
- name = sym->_n._n_name;
-
- local_toc_table = obj_coff_local_toc_table(input_bfd);
- our_toc_offset = local_toc_table[symndx];
-
- if (IS_WRITTEN(our_toc_offset))
- {
- /* if it has been written out, it is marked with the
- 1 bit. Fix up our offset, but do not write it out
- again.
- */
- MAKE_ADDR_AGAIN(our_toc_offset);
-#ifdef TOC_DEBUG
-
- fprintf(stderr,
- "Not writing out toc_offset of %d for %s\n",
- our_toc_offset, name);
-#endif
- }
- else
- {
- /* write out the toc entry */
- record_toc(toc_section, our_toc_offset, priv, strdup(name));
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "Writing out toc_offset "
- "toc_section (%p,%p)+%d val %d for %s\n",
- toc_section,
- toc_section->contents,
- our_toc_offset,
- val,
- name);
-#endif
-
- bfd_put_32(output_bfd,
- val,
- toc_section->contents + our_toc_offset);
-
- MARK_AS_WRITTEN(local_toc_table[symndx]);
- fixit = true;
- }
- }
- else
- {
- const char *name = h->root.root.root.string;
- our_toc_offset = h->toc_offset;
-
- if ((r_flags & IMAGE_REL_PPC_TOCDEFN)
- == IMAGE_REL_PPC_TOCDEFN )
-#if 0
- /* This is wrong. If tocdefn is on, we must unconditionally
- assume the following path */
- && IS_UNALLOCATED(our_toc_offset))
-#endif
- {
- /* This is unbelievable cheese. Some knowledgable asm
- hacker has decided to use r2 as a base for loading
- a value. He/She does this by setting the tocdefn bit,
- and not supplying a toc definition. The behaviour is
- then to use the difference between the value of the
- symbol and the actual location of the toc as the toc
- index.
-
- In fact, what is usually happening is, because the
- Import Address Table is mapped immediately following
- the toc, some trippy library code trying for speed on
- dll linkage, takes advantage of that and considers
- the IAT to be part of the toc, thus saving a load.
- */
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- "TOCDEFN is on, (%s) (%p) our_toc_offset = %x\n",
- name, h, our_toc_offset);
-#endif
-
- our_toc_offset = val -
- (toc_section->output_section->vma +
- toc_section->output_offset);
-
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- " our_toc_offset set to %x\n", our_toc_offset);
-#endif
-
- /* The size must still fit in a 16bit displacment */
- if (our_toc_offset >= 65535)
- {
- fprintf(stderr,
- "TOCDEFN Relocation exceeded "
- "displacment of 65535\n");
- abort();
- }
-
- record_toc(toc_section, our_toc_offset, pub, strdup(name));
- }
- else if (IS_WRITTEN(our_toc_offset))
- {
- /* if it has been written out, it is marked with the
- 1 bit. Fix up our offset, but do not write it out
- again.
- */
- MAKE_ADDR_AGAIN(our_toc_offset);
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "Not writing out toc_offset of %d for %s\n",
- our_toc_offset, name);
-#endif
- }
- else
- {
- record_toc(toc_section, our_toc_offset, pub, strdup(name));
-
-#ifdef TOC_DEBUG
- /* write out the toc entry */
- fprintf(stderr,
- "Writing out toc_offset "
- "toc_section (%p,%p)+%d val %d for %s\n",
- toc_section,
- toc_section->contents,
- our_toc_offset,
- val,
- name);
-#endif
-
- /* write out the toc entry */
- bfd_put_32(output_bfd,
- val,
- toc_section->contents + our_toc_offset);
-
- MARK_AS_WRITTEN(h->toc_offset);
- /* The tricky part is that this is the address that */
- /* needs a .reloc entry for it */
- fixit = true;
- }
- }
-
- if (fixit && info->base_file)
- {
- /* So if this is non pcrelative, and is referenced
- to a section or a common symbol, then it needs a reloc */
-
- /* relocation to a symbol in a section which
- isn't absolute - we output the address here
- to a file */
-
- bfd_vma addr = toc_section->output_section->vma
- + toc_section->output_offset + our_toc_offset;
-
- if (coff_data(output_bfd)->pe)
- addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
-
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- " Toc Section .reloc candidate addr = %x\n", addr);
-#endif
- fwrite (&addr, 1,4, (FILE *) info->base_file);
- }
-
-
- /* FIXME: this test is conservative */
- if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN &&
- our_toc_offset > toc_section->_raw_size)
- {
- fprintf(stderr,
- "reloc offset is bigger than the toc size!\n");
- abort();
- }
-
- /* Now we know the relocation for this toc reference */
- relocation = our_toc_offset + TOC_LOAD_ADJUSTMENT;
- rstat = _bfd_relocate_contents (howto,
- input_bfd,
- relocation,
- loc);
- }
- break;
- case IMAGE_REL_PPC_IFGLUE:
- {
- /* To solve this, we need to know whether or not the symbol */
- /* appearing on the call instruction is a glue function or not. */
- /* A glue function must announce itself via a IMGLUE reloc, and */
- /* the reloc contains the required toc restore instruction */
-
- bfd_vma x;
- const char *my_name;
- DUMP_RELOC2(howto->name, rel);
-
- if (h != 0)
- {
- my_name = h->root.root.root.string;
- if (h->symbol_is_glue == 1)
- {
- x = bfd_get_32(input_bfd, loc);
- bfd_put_32(input_bfd, h->glue_insn, loc);
- }
- }
- }
- break;
- case IMAGE_REL_PPC_SECREL:
- /* Unimplemented: codeview debugging information */
- /* For fast access to the header of the section
- containing the item. */
- break;
- case IMAGE_REL_PPC_SECTION:
- /* Unimplemented: codeview debugging information */
- /* Is used to indicate that the value should be relative
- to the beginning of the section that contains the
- symbol */
- break;
- case IMAGE_REL_PPC_ABSOLUTE:
- {
- const char *my_name;
- if (h == 0)
- my_name = (syms+symndx)->_n._n_name;
- else
- {
- my_name = h->root.root.root.string;
- }
-
- fprintf(stderr,
- "Warning: unsupported reloc %s <file %s, section %s>\n",
- howto->name,
- bfd_get_filename(input_bfd),
- input_section->name);
-
- fprintf(stderr,"sym %d (%s), r_vaddr %d (%x)\n",
- rel->r_symndx, my_name, rel->r_vaddr, rel->r_vaddr);
- }
- break;
- case IMAGE_REL_PPC_IMGLUE:
- {
- /* There is nothing to do now. This reloc was noted in the first
- pass over the relocs, and the glue instruction extracted */
- const char *my_name;
- if (h->symbol_is_glue == 1)
- break;
- my_name = h->root.root.root.string;
- fprintf(stderr,
- "Warning: previously missed IMGLUE reloc %s <file %s, section %s>\n",
- howto->name,
- bfd_get_filename(input_bfd),
- input_section->name);
- break;
-
- }
- break;
-
- case IMAGE_REL_PPC_ADDR32NB:
- {
- struct coff_link_hash_entry *myh = 0;
- const char *name = 0;
- DUMP_RELOC2(howto->name, rel);
-
- if (strncmp(".idata$2",input_section->name,8) == 0 && first_thunk_address == 0)
- {
- /* set magic values */
- int idata5offset;
- struct coff_link_hash_entry *myh = 0;
- myh = coff_link_hash_lookup (coff_hash_table (info),
- "__idata5_magic__",
- false, false, true);
- first_thunk_address = myh->root.u.def.value +
- sec->output_section->vma +
- sec->output_offset -
- pe_data(output_bfd)->pe_opthdr.ImageBase;
-
- idata5offset = myh->root.u.def.value;
- myh = coff_link_hash_lookup (coff_hash_table (info),
- "__idata6_magic__",
- false, false, true);
-
- thunk_size = myh->root.u.def.value - idata5offset;
- myh = coff_link_hash_lookup (coff_hash_table (info),
- "__idata4_magic__",
- false, false, true);
- import_table_size = myh->root.u.def.value;
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- "first computation triggered fta %x, ts %d(%x), its %d(%x)\n",
- first_thunk_address, thunk_size, thunk_size, import_table_size,
- import_table_size);
-#endif
- }
-
- if (h == 0)
- { /* it is a file local symbol */
- sym = syms + symndx;
- name = sym->_n._n_name;
- }
- else
- {
- char *target = 0;
-
- name = h->root.root.root.string;
- if (strcmp(".idata$2", name) == 0)
- target = "__idata2_magic__";
- else if (strcmp(".idata$4", name) == 0)
- target = "__idata4_magic__";
- else if (strcmp(".idata$5", name) == 0)
- target = "__idata5_magic__";
-
- if (target != 0)
- {
- myh = 0;
-
- myh = coff_link_hash_lookup (coff_hash_table (info),
- target,
- false, false, true);
- if (myh == 0)
- {
- fprintf(stderr, "Missing idata magic cookies, "
- "this cannot work anyway...\n");
- abort();
- }
-
- val = myh->root.u.def.value +
- sec->output_section->vma + sec->output_offset;
- if (first_thunk_address == 0)
- {
- int idata5offset;
- myh = coff_link_hash_lookup (coff_hash_table (info),
- "__idata5_magic__",
- false, false, true);
- first_thunk_address = myh->root.u.def.value +
- sec->output_section->vma +
- sec->output_offset -
- pe_data(output_bfd)->pe_opthdr.ImageBase;
-
- idata5offset = myh->root.u.def.value;
- myh = coff_link_hash_lookup (coff_hash_table (info),
- "__idata6_magic__",
- false, false, true);
-
- thunk_size = myh->root.u.def.value - idata5offset;
- myh = coff_link_hash_lookup (coff_hash_table (info),
- "__idata4_magic__",
- false, false, true);
- import_table_size = myh->root.u.def.value;
-#ifdef DEBUG_RELOC
-
- fprintf(stderr,
- "second computation triggered fta %x, ts %d(%x), its %d(%x)\n",
- first_thunk_address, thunk_size, thunk_size, import_table_size,
- import_table_size);
-#endif
- }
- }
- }
-
- rstat = _bfd_relocate_contents (howto,
- input_bfd,
- val -
- pe_data(output_bfd)->pe_opthdr.ImageBase,
- loc);
- }
- break;
-
- case IMAGE_REL_PPC_REL24:
- DUMP_RELOC2(howto->name, rel);
- val -= (input_section->output_section->vma
- + input_section->output_offset);
-
- rstat = _bfd_relocate_contents (howto,
- input_bfd,
- val,
- loc);
- break;
- case IMAGE_REL_PPC_ADDR16:
- case IMAGE_REL_PPC_ADDR24:
- case IMAGE_REL_PPC_ADDR32:
- DUMP_RELOC2(howto->name, rel);
- rstat = _bfd_relocate_contents (howto,
- input_bfd,
- val,
- loc);
- break;
- }
-
- if ( info->base_file )
- {
- /* So if this is non pcrelative, and is referenced
- to a section or a common symbol, then it needs a reloc */
- if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
- {
- /* relocation to a symbol in a section which
- isn't absolute - we output the address here
- to a file */
- bfd_vma addr = rel->r_vaddr
- - input_section->vma
- + input_section->output_offset
- + input_section->output_section->vma;
-
- if (coff_data(output_bfd)->pe)
- {
- bfd_vma before_addr = addr;
- addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- " adjusted down from %x to %x", before_addr, addr);
-#endif
- }
-#ifdef DEBUG_RELOC
- fprintf(stderr, "\n");
-#endif
-
- fwrite (&addr, 1,4, (FILE *) info->base_file);
- }
- }
-
- switch (rstat)
- {
- default:
- abort ();
- case bfd_reloc_ok:
- break;
- case bfd_reloc_overflow:
- {
- const char *name;
- char buf[SYMNMLEN + 1];
-
- if (symndx == -1)
- name = "*ABS*";
- else if (h != NULL)
- name = h->root.root.root.string;
- else if (sym == NULL)
- name = "*unknown*";
- else if (sym->_n._n_n._n_zeroes == 0
- && sym->_n._n_n._n_offset != 0)
- name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
- else
- {
- strncpy (buf, sym->_n._n_name, SYMNMLEN);
- buf[SYMNMLEN] = '\0';
- name = buf;
- }
-#if 0
- else
- {
- name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
- if (name == NULL)
- return false;
- }
-#endif
-
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name,
- (bfd_vma) 0, input_bfd,
- input_section, rel->r_vaddr - input_section->vma)))
- {
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- "pe_ppc_relocate_section (%s) for %s in bfd %s RETURNING TRUE\n",
- TARGET_LITTLE_NAME,
- input_section->name,
- input_bfd->filename);
-
-#endif
- return false;
- }
- }
- }
-
- }
-
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- "pe_ppc_relocate_section (%s) for %s in bfd %s RETURNING TRUE\n",
- TARGET_LITTLE_NAME,
- input_section->name,
- input_bfd->filename);
-
-#endif
-
- return true;
-}
-
-
-#ifdef COFF_IMAGE_WITH_PE
-
-long int global_toc_size = 4;
-
-bfd* bfd_of_toc_owner = 0;
-
-long int import_table_size;
-long int first_thunk_address;
-long int thunk_size;
-
-struct list_ele *head;
-struct list_ele *tail;
-
-static char *
-h1 = "\n\t\t\tTOC MAPPING\n\n";
-static char *
-h2 = " TOC disassembly Comments Name\n";
-static char *
-h3 = " Offset spelling (if present)\n";
-
-void
-dump_toc(vfile)
- void *vfile;
-{
- FILE *file = vfile;
- struct list_ele *t;
-
- fprintf(file, h1);
- fprintf(file, h2);
- fprintf(file, h3);
-
- for(t = head; t != 0; t=t->next)
- {
- char *cat;
-
- if (t->cat == priv)
- cat = "private ";
- else if (t->cat == pub)
- cat = "public ";
- else if (t->cat == data)
- cat = "data-in-toc ";
-
- if (t->offset > global_toc_size)
- {
- if (t->offset <= global_toc_size + thunk_size)
- cat = "IAT reference ";
- else
- {
- fprintf(file,
- "**** global_toc_size %d(%x), thunk_size %d(%x)\n",
- global_toc_size, global_toc_size, thunk_size, thunk_size);
- cat = "Out of bounds!";
- }
- }
-
- fprintf(file,
- " %04lx (%d)", t->offset, t->offset - 32768);
- fprintf(file,
- " %s %s\n",
- cat, t->name);
-
- }
-
- fprintf(file, "\n");
-}
-
-boolean
-ppc_allocate_toc_section (info)
- struct bfd_link_info *info;
-{
- asection *s;
- bfd_byte *foo;
- static char test_char = '1';
-
- if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble? */
- return true;
-
- if (bfd_of_toc_owner == 0)
- {
- fprintf(stderr,
- "There is no bfd that owns the toc section!\n");
- abort();
- }
-
- s = bfd_get_section_by_name ( bfd_of_toc_owner , TOC_SECTION_NAME);
- if (s == NULL)
- {
- fprintf(stderr, "No Toc section!\n");
- abort();
- }
-
- foo = bfd_alloc(bfd_of_toc_owner, global_toc_size);
- memset(foo, test_char, global_toc_size);
-
- s->_raw_size = s->_cooked_size = global_toc_size;
- s->contents = foo;
-
- return true;
-}
-
-boolean
-ppc_process_before_allocation (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- asection *sec;
- struct internal_reloc *i, *rel;
-
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- "ppc_process_before_allocation: BFD %s\n",
- bfd_get_filename(abfd));
-#endif
-
- /* here we have a bfd that is to be included on the link. We have a hook
- to do reloc rummaging, before section sizes are nailed down. */
-
- _bfd_coff_get_external_symbols(abfd);
-
- /* rummage around all the relocs and map the toc */
- sec = abfd->sections;
-
- if (sec == 0)
- {
- return true;
- }
-
- for (; sec != 0; sec = sec->next)
- {
- int toc_offset;
-
-#ifdef DEBUG_RELOC
- fprintf(stderr,
- " section %s reloc count %d\n",
- sec->name,
- sec->reloc_count);
-#endif
-
- if (sec->reloc_count == 0)
- continue;
-
- /* load the relocs */
- /* FIXME: there may be a storage leak here */
- i=_bfd_coff_read_internal_relocs(abfd,sec,1,0,0,0);
-
- if (i == 0)
- abort();
-
- for (rel=i;rel<i+sec->reloc_count;++rel)
- {
- unsigned short r_type = EXTRACT_TYPE (rel->r_type);
- unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
- unsigned short junk = EXTRACT_JUNK (rel->r_type);
-
-#ifdef DEBUG_RELOC
- /* now examine flags */
- if (r_flags != 0)
- {
- fprintf (stderr, "Reloc with flags found!");
- if ( r_flags & IMAGE_REL_PPC_NEG )
- fprintf (stderr, " NEG");
- if ( r_flags & IMAGE_REL_PPC_BRTAKEN )
- fprintf (stderr, " BRTAKEN");
- if ( r_flags & IMAGE_REL_PPC_BRNTAKEN )
- fprintf (stderr, " BRNTAKEN");
- if ( r_flags & IMAGE_REL_PPC_TOCDEFN )
- fprintf (stderr, " TOCDEFN");
- fprintf(stderr, "\n");
- }
-#endif
-
- DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
-
- switch(r_type)
- {
- case IMAGE_REL_PPC_TOCREL16:
-#if 0
- /* FIXME:
- This remains unimplemented for now, as it currently adds
- un-necessary elements to the toc. All we need to do today
- is not do anything if TOCDEFN is on.
- */
- if ( r_flags & IMAGE_REL_PPC_TOCDEFN )
- toc_offset = ppc_record_data_in_toc_entry(abfd, info, sec,
- rel->r_symndx,
- default_toc);
- else
- toc_offset = ppc_record_toc_entry(abfd, info, sec,
- rel->r_symndx, default_toc);
-#endif
- if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN )
- toc_offset = ppc_record_toc_entry(abfd, info, sec,
- rel->r_symndx, default_toc);
- break;
- case IMAGE_REL_PPC_IMGLUE:
- ppc_mark_symbol_as_glue(abfd, rel->r_symndx, rel);
- break;
- default:
- break;
- }
- }
- }
-}
-
-#endif
-
-
-static bfd_reloc_status_type
-ppc_refhi_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- UN_IMPL("REFHI");
- DUMP_RELOC("REFHI",reloc_entry);
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- return bfd_reloc_undefined;
-}
-
-static bfd_reloc_status_type
-ppc_reflo_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- UN_IMPL("REFLO");
- DUMP_RELOC("REFLO",reloc_entry);
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- return bfd_reloc_undefined;
-}
-
-static bfd_reloc_status_type
-ppc_pair_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- UN_IMPL("PAIR");
- DUMP_RELOC("PAIR",reloc_entry);
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- return bfd_reloc_undefined;
-}
-
-
-static bfd_reloc_status_type
-ppc_toc16_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- UN_IMPL("TOCREL16");
- DUMP_RELOC("TOCREL16",reloc_entry);
-
- if (output_bfd == (bfd *) NULL)
- {
- return bfd_reloc_continue;
- }
-
- return bfd_reloc_ok;
-}
-
-/* ADDR32NB : 32 bit address relative to the virtual origin. */
-/* (On the alpha, this is always a linker generated thunk)*/
-/* (i.e. 32bit addr relative to the image base) */
-/* */
-/* */
-
-static bfd_reloc_status_type
-ppc_addr32nb_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- UN_IMPL("ADDR32NB");
- DUMP_RELOC("ADDR32NB",reloc_entry);
-
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_type
-ppc_secrel_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- UN_IMPL("SECREL");
- DUMP_RELOC("SECREL",reloc_entry);
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_type
-ppc_section_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- UN_IMPL("SECTION");
- DUMP_RELOC("SECTION",reloc_entry);
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_type
-ppc_imglue_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- UN_IMPL("IMGLUE");
- DUMP_RELOC("IMGLUE",reloc_entry);
-
- if (output_bfd == (bfd *) NULL)
- return bfd_reloc_continue;
-
- return bfd_reloc_ok;
-}
-
-
-
-#define MAX_RELOC_INDEX \
- (sizeof(ppc_coff_howto_table) / sizeof(ppc_coff_howto_table[0]) - 1)
-
-
-/* FIXME: There is a possiblity that when we read in a reloc from a file,
- that there are some bits encoded in the upper portion of the
- type field. Not yet implemented.
-*/
-static void ppc_coff_rtype2howto PARAMS ((arelent *relent,
- struct internal_reloc *internal));
-
-static void
-ppc_coff_rtype2howto (relent, internal)
- arelent *relent;
- struct internal_reloc *internal;
-{
-
- /* We can encode one of three things in the type field, aside from the
- type:
- 1. IMAGE_REL_PPC_NEG - indicates the value field is a subtraction
- value, rather than an addition value
- 2. IMAGE_REL_PPC_BRTAKEN, IMAGE_REL_PPC_BRNTAKEN - indicates that
- the branch is expected to be taken or not.
- 3. IMAGE_REL_PPC_TOCDEFN - toc slot definition in the file
- For now, we just strip this stuff to find the type, and ignore it other
- than that.
- */
- reloc_howto_type *howto;
- unsigned short r_type = EXTRACT_TYPE (internal->r_type);
- unsigned short r_flags = EXTRACT_FLAGS(internal->r_type);
- unsigned short junk = EXTRACT_JUNK (internal->r_type);
-
- /* the masking process only slices off the bottom byte for r_type. */
- if ( r_type > MAX_RELOC_INDEX )
- {
- fprintf(stderr,
- "ppc_coff_rtype2howto: reloc index %d out of range [%d, %d]\n",
- internal->r_type, 0, MAX_RELOC_INDEX);
- abort();
- }
-
- /* check for absolute crap */
- if ( junk != 0 )
- {
- fprintf(stderr,
- "ppc_coff_rtype2howto: reloc index %d contains junk %d\n",
- internal->r_type, junk);
- abort();
- }
-
-#ifdef DEBUG_RELOC
- /* now examine flags */
- if (r_flags != 0)
- {
- fprintf (stderr, "Reloc with flags found!");
- if ( r_flags & IMAGE_REL_PPC_NEG )
- fprintf (stderr, " NEG");
- if ( r_flags & IMAGE_REL_PPC_BRTAKEN )
- fprintf (stderr, " BRTAKEN");
- if ( r_flags & IMAGE_REL_PPC_BRNTAKEN )
- fprintf (stderr, " BRNTAKEN");
- if ( r_flags & IMAGE_REL_PPC_TOCDEFN )
- fprintf (stderr, " TOCDEFN");
- fprintf(stderr, "\n");
- }
-#endif
-
- switch(r_type)
- {
- case IMAGE_REL_PPC_ADDR16:
- case IMAGE_REL_PPC_REL24:
- case IMAGE_REL_PPC_ADDR24:
- case IMAGE_REL_PPC_ADDR32:
- case IMAGE_REL_PPC_IFGLUE:
- case IMAGE_REL_PPC_ADDR32NB:
- case IMAGE_REL_PPC_SECTION:
- case IMAGE_REL_PPC_SECREL:
- DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
- howto = ppc_coff_howto_table + r_type;
- break;
- case IMAGE_REL_PPC_IMGLUE:
- DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
- howto = ppc_coff_howto_table + r_type;
- break;
- case IMAGE_REL_PPC_TOCREL16:
- DUMP_RELOC2(ppc_coff_howto_table[r_type].name, internal);
- if (r_flags & IMAGE_REL_PPC_TOCDEFN)
- howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16_DEFN;
- else
- howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16;
- break;
- default:
- fprintf(stderr,
- "Warning: Unsupported reloc %s [%d] used -- it may not work.\n",
- ppc_coff_howto_table[r_type].name,
- r_type);
- howto = ppc_coff_howto_table + r_type;
- break;
- }
-
- relent->howto = howto;
-
-}
-
-static reloc_howto_type *
-coff_ppc_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
- bfd *abfd;
- asection *sec;
- struct internal_reloc *rel;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma *addendp;
-{
- reloc_howto_type *howto;
-
- /* We can encode one of three things in the type field, aside from the
- type:
- 1. IMAGE_REL_PPC_NEG - indicates the value field is a subtraction
- value, rather than an addition value
- 2. IMAGE_REL_PPC_BRTAKEN, IMAGE_REL_PPC_BRNTAKEN - indicates that
- the branch is expected to be taken or not.
- 3. IMAGE_REL_PPC_TOCDEFN - toc slot definition in the file
- For now, we just strip this stuff to find the type, and ignore it other
- than that.
- */
-
- unsigned short r_type = EXTRACT_TYPE (rel->r_type);
- unsigned short r_flags = EXTRACT_FLAGS(rel->r_type);
- unsigned short junk = EXTRACT_JUNK (rel->r_type);
-
- /* the masking process only slices off the bottom byte for r_type. */
- if ( r_type > MAX_RELOC_INDEX )
- {
- fprintf(stderr,
- "coff_ppc_rtype_to_howto: index %d out of range [%d, %d]\n",
- r_type, 0, MAX_RELOC_INDEX);
- abort();
- }
-
- /* check for absolute crap */
- if ( junk != 0 )
- {
- fprintf(stderr,
- "coff_ppc_rtype_to_howto: reloc index %d contains junk %d\n",
- rel->r_type, junk);
- abort();
- }
-
-#ifdef DEBUG_RELOC
- /* now examine flags */
- if (r_flags != 0)
- {
- fprintf (stderr, "Reloc with flags found!");
- if ( r_flags & IMAGE_REL_PPC_NEG )
- fprintf (stderr, " NEG");
- if ( r_flags & IMAGE_REL_PPC_BRTAKEN )
- fprintf (stderr, " BRTAKEN");
- if ( r_flags & IMAGE_REL_PPC_BRNTAKEN )
- fprintf (stderr, " BRNTAKEN");
- if ( r_flags & IMAGE_REL_PPC_TOCDEFN )
- fprintf (stderr, " TOCDEFN");
- fprintf(stderr, "\n");
- }
-#endif
-
- switch(r_type)
- {
- case IMAGE_REL_PPC_ADDR32NB:
- DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
- *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
- howto = ppc_coff_howto_table + r_type;
- break;
- case IMAGE_REL_PPC_TOCREL16:
- DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
- if (r_flags & IMAGE_REL_PPC_TOCDEFN)
- howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16_DEFN;
- else
- howto = ppc_coff_howto_table + IMAGE_REL_PPC_TOCREL16;
- break;
- case IMAGE_REL_PPC_ADDR16:
- case IMAGE_REL_PPC_REL24:
- case IMAGE_REL_PPC_ADDR24:
- case IMAGE_REL_PPC_ADDR32:
- case IMAGE_REL_PPC_IFGLUE:
- case IMAGE_REL_PPC_SECTION:
- case IMAGE_REL_PPC_SECREL:
- DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
- howto = ppc_coff_howto_table + r_type;
- break;
- case IMAGE_REL_PPC_IMGLUE:
- DUMP_RELOC2(ppc_coff_howto_table[r_type].name, rel);
- howto = ppc_coff_howto_table + r_type;
- break;
- default:
- fprintf(stderr,
- "Warning: Unsupported reloc %s [%d] used -- it may not work.\n",
- ppc_coff_howto_table[r_type].name,
- r_type);
- howto = ppc_coff_howto_table + r_type;
- break;
- }
-
- return howto;
-}
-
-
-/* a cheesy little macro to make the code a little more readable */
-#define HOW2MAP(bfd_rtype,ppc_rtype) \
- case bfd_rtype: return &ppc_coff_howto_table[ppc_rtype]
-
-static reloc_howto_type *ppc_coff_reloc_type_lookup
-PARAMS ((bfd *, bfd_reloc_code_real_type));
-
-static reloc_howto_type *
-ppc_coff_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
-
-#ifdef DEBUG_RELOC
- fprintf(stderr, "ppc_coff_reloc_type_lookup for %s\n",
- bfd_get_reloc_code_name(code));
-#endif
-
- switch (code)
- {
- HOW2MAP(BFD_RELOC_32_GOTOFF, IMAGE_REL_PPC_IMGLUE);
- HOW2MAP(BFD_RELOC_16_GOT_PCREL, IMAGE_REL_PPC_IFGLUE);
- HOW2MAP(BFD_RELOC_16, IMAGE_REL_PPC_ADDR16);
- HOW2MAP(BFD_RELOC_PPC_B26, IMAGE_REL_PPC_REL24);
- HOW2MAP(BFD_RELOC_PPC_BA26, IMAGE_REL_PPC_ADDR24);
- HOW2MAP(BFD_RELOC_PPC_TOC16, IMAGE_REL_PPC_TOCREL16);
- HOW2MAP(BFD_RELOC_16_GOTOFF, IMAGE_REL_PPC_TOCREL16_DEFN);
- HOW2MAP(BFD_RELOC_32, IMAGE_REL_PPC_ADDR32);
- HOW2MAP(BFD_RELOC_RVA, IMAGE_REL_PPC_ADDR32NB);
- default:
- return NULL;
- }
-
- return NULL;
-}
-
-#undef HOW2MAP
-
-
-/* Tailor coffcode.h -- macro heaven. */
-
-#define RTYPE2HOWTO(cache_ptr, dst) ppc_coff_rtype2howto (cache_ptr, dst)
-
-#ifndef COFF_IMAGE_WITH_PE
-static void
-ppc_coff_swap_sym_in_hook ();
-#endif
-
-/* We use the special COFF backend linker, with our own special touch. */
-
-#define coff_bfd_reloc_type_lookup ppc_coff_reloc_type_lookup
-#define coff_rtype_to_howto coff_ppc_rtype_to_howto
-#define coff_relocate_section coff_ppc_relocate_section
-#define coff_bfd_final_link ppc_bfd_coff_final_link
-
-#ifndef COFF_IMAGE_WITH_PE
-#define coff_swap_sym_in_hook ppc_coff_swap_sym_in_hook
-#endif
-
-#define SELECT_RELOC(internal, howto) {internal.r_type=howto->type;}
-
-#define COFF_PAGE_SIZE 0x1000
-
-#define POWERPC_LE_PE
-
-#include "coffcode.h"
-
-
-
-#ifndef COFF_IMAGE_WITH_PE
-/* FIXME:
- What we're trying to do here is allocate a toc section (early), and attach
- it to the last bfd to be processed. This avoids the problem of having a toc
- written out before all files have been processed. This code allocates
- a toc section for every file, and records the last one seen. There are
- at least two problems with this approach:
- 1. We allocate whole bunches of toc sections that are ignored, but at
- at least we will not allocate a toc if no .toc is present.
- 2. It's not clear to me that being the last bfd read necessarily means
- that you are the last bfd closed.
- 3. Doing it on a "swap in" hook depends on when the "swap in" is called,
- and how often, etc. It's not clear to me that there isn't a hole here.
-*/
-
-static void
-ppc_coff_swap_sym_in_hook (abfd, ext1, in1)
- bfd *abfd;
- PTR ext1;
- PTR in1;
-{
- SYMENT *ext = (SYMENT *)ext1;
- struct internal_syment *in = (struct internal_syment *)in1;
-
- if (bfd_of_toc_owner != 0) /* we already have a toc, so go home */
- return;
-
- if (strcmp(in->_n._n_name, ".toc") == 0)
- {
- flagword flags;
- register asection *s;
- char *foo;
-
- s = bfd_get_section_by_name ( abfd , TOC_SECTION_NAME);
- if (s != NULL)
- {
- return;
- }
-
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY ;
-
-#ifdef TOC_DEBUG
- fprintf(stderr,
- "ppc_coff_swap_sym_in_hook: about to create the %s section\n",
- TOC_SECTION_NAME);
-#endif
-
- s = bfd_make_section (abfd, TOC_SECTION_NAME);
-
- if (s == NULL
- || !bfd_set_section_flags (abfd, s, flags)
- || !bfd_set_section_alignment (abfd, s, 2))
- {
- fprintf(stderr,
- "toc section allocation failed!\n");
- abort();
- }
-
- /* save the bfd for later allocation */
- bfd_of_toc_owner = abfd;
- }
-
- return;
-}
-#endif
-
-boolean
-ppc_bfd_coff_final_link ();
-
-#ifndef COFF_IMAGE_WITH_PE
-
-static boolean
-ppc_do_last(abfd)
- bfd *abfd;
-{
- if (abfd == bfd_of_toc_owner)
- return true;
- else
- return false;
-}
-
-static bfd *
-ppc_get_last()
-{
- return bfd_of_toc_owner;
-}
-
-/* this piece of machinery exists only to guarantee that the bfd that holds
- the toc section is written last.
-
- This does depend on bfd_make_section attaching a new section to the
- end of the section list for the bfd.
-
- This is otherwise intended to be functionally the same as
- cofflink.c:_bfd_coff_final_link(). It is specifically different only
- where the POWERPC_LE_PE macro modifies the code. It is left in as a
- precise form of comment. krk@cygnus.com
-*/
-#define POWERPC_LE_PE
-
-
-/* Do the final link step. */
-
-boolean
-ppc_bfd_coff_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- bfd_size_type symesz;
- struct coff_final_link_info finfo;
- boolean debug_merge_allocated;
- asection *o;
- struct bfd_link_order *p;
- size_t max_sym_count;
- size_t max_lineno_count;
- size_t max_reloc_count;
- size_t max_output_reloc_count;
- size_t max_contents_size;
- file_ptr rel_filepos;
- unsigned int relsz;
- file_ptr line_filepos;
- unsigned int linesz;
- bfd *sub;
- bfd_byte *external_relocs = NULL;
- char strbuf[STRING_SIZE_SIZE];
-
- symesz = bfd_coff_symesz (abfd);
-
- finfo.info = info;
- finfo.output_bfd = abfd;
- finfo.strtab = NULL;
- finfo.section_info = NULL;
- finfo.last_file_index = -1;
- finfo.internal_syms = NULL;
- finfo.sec_ptrs = NULL;
- finfo.sym_indices = NULL;
- finfo.outsyms = NULL;
- finfo.linenos = NULL;
- finfo.contents = NULL;
- finfo.external_relocs = NULL;
- finfo.internal_relocs = NULL;
- debug_merge_allocated = false;
-
- coff_data (abfd)->link_info = info;
-
- finfo.strtab = _bfd_stringtab_init ();
- if (finfo.strtab == NULL)
- goto error_return;
-
- if (! coff_debug_merge_hash_table_init (&finfo.debug_merge))
- goto error_return;
- debug_merge_allocated = true;
-
- /* Compute the file positions for all the sections. */
- if (! abfd->output_has_begun)
- bfd_coff_compute_section_file_positions (abfd);
-
- /* Count the line numbers and relocation entries required for the
- output file. Set the file positions for the relocs. */
- rel_filepos = obj_relocbase (abfd);
- relsz = bfd_coff_relsz (abfd);
- max_contents_size = 0;
- max_lineno_count = 0;
- max_reloc_count = 0;
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- o->reloc_count = 0;
- o->lineno_count = 0;
- for (p = o->link_order_head; p != NULL; p = p->next)
- {
-
- if (p->type == bfd_indirect_link_order)
- {
- asection *sec;
-
- sec = p->u.indirect.section;
-
- if (info->strip == strip_none
- || info->strip == strip_some)
- o->lineno_count += sec->lineno_count;
-
- if (info->relocateable)
- o->reloc_count += sec->reloc_count;
-
- if (sec->_raw_size > max_contents_size)
- max_contents_size = sec->_raw_size;
- if (sec->lineno_count > max_lineno_count)
- max_lineno_count = sec->lineno_count;
- if (sec->reloc_count > max_reloc_count)
- max_reloc_count = sec->reloc_count;
- }
- else if (info->relocateable
- && (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order))
- ++o->reloc_count;
- }
- if (o->reloc_count == 0)
- o->rel_filepos = 0;
- else
- {
- o->flags |= SEC_RELOC;
- o->rel_filepos = rel_filepos;
- rel_filepos += o->reloc_count * relsz;
- }
- }
-
- /* If doing a relocateable link, allocate space for the pointers we
- need to keep. */
- if (info->relocateable)
- {
- unsigned int i;
-
- /* We use section_count + 1, rather than section_count, because
- the target_index fields are 1 based. */
- finfo.section_info =
- ((struct coff_link_section_info *)
- bfd_malloc ((abfd->section_count + 1)
- * sizeof (struct coff_link_section_info)));
- if (finfo.section_info == NULL)
- goto error_return;
- for (i = 0; i <= abfd->section_count; i++)
- {
- finfo.section_info[i].relocs = NULL;
- finfo.section_info[i].rel_hashes = NULL;
- }
- }
-
- /* We now know the size of the relocs, so we can determine the file
- positions of the line numbers. */
- line_filepos = rel_filepos;
- linesz = bfd_coff_linesz (abfd);
- max_output_reloc_count = 0;
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if (o->lineno_count == 0)
- o->line_filepos = 0;
- else
- {
- o->line_filepos = line_filepos;
- line_filepos += o->lineno_count * linesz;
- }
-
- if (o->reloc_count != 0)
- {
- /* We don't know the indices of global symbols until we have
- written out all the local symbols. For each section in
- the output file, we keep an array of pointers to hash
- table entries. Each entry in the array corresponds to a
- reloc. When we find a reloc against a global symbol, we
- set the corresponding entry in this array so that we can
- fix up the symbol index after we have written out all the
- local symbols.
-
- Because of this problem, we also keep the relocs in
- memory until the end of the link. This wastes memory,
- but only when doing a relocateable link, which is not the
- common case. */
- BFD_ASSERT (info->relocateable);
- finfo.section_info[o->target_index].relocs =
- ((struct internal_reloc *)
- bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
- finfo.section_info[o->target_index].rel_hashes =
- ((struct coff_link_hash_entry **)
- bfd_malloc (o->reloc_count
- * sizeof (struct coff_link_hash_entry *)));
- if (finfo.section_info[o->target_index].relocs == NULL
- || finfo.section_info[o->target_index].rel_hashes == NULL)
- goto error_return;
-
- if (o->reloc_count > max_output_reloc_count)
- max_output_reloc_count = o->reloc_count;
- }
-
- /* Reset the reloc and lineno counts, so that we can use them to
- count the number of entries we have output so far. */
- o->reloc_count = 0;
- o->lineno_count = 0;
- }
-
- obj_sym_filepos (abfd) = line_filepos;
-
- /* Figure out the largest number of symbols in an input BFD. Take
- the opportunity to clear the output_has_begun fields of all the
- input BFD's. */
- max_sym_count = 0;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- size_t sz;
-
- sub->output_has_begun = false;
- sz = obj_raw_syment_count (sub);
- if (sz > max_sym_count)
- max_sym_count = sz;
- }
-
- /* Allocate some buffers used while linking. */
- finfo.internal_syms = ((struct internal_syment *)
- bfd_malloc (max_sym_count
- * sizeof (struct internal_syment)));
- finfo.sec_ptrs = (asection **) bfd_malloc (max_sym_count
- * sizeof (asection *));
- finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
- finfo.outsyms = ((bfd_byte *)
- bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
- finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
- * bfd_coff_linesz (abfd));
- finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
- finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
- if (! info->relocateable)
- finfo.internal_relocs = ((struct internal_reloc *)
- bfd_malloc (max_reloc_count
- * sizeof (struct internal_reloc)));
- if ((finfo.internal_syms == NULL && max_sym_count > 0)
- || (finfo.sec_ptrs == NULL && max_sym_count > 0)
- || (finfo.sym_indices == NULL && max_sym_count > 0)
- || finfo.outsyms == NULL
- || (finfo.linenos == NULL && max_lineno_count > 0)
- || (finfo.contents == NULL && max_contents_size > 0)
- || (finfo.external_relocs == NULL && max_reloc_count > 0)
- || (! info->relocateable
- && finfo.internal_relocs == NULL
- && max_reloc_count > 0))
- goto error_return;
-
- /* We now know the position of everything in the file, except that
- we don't know the size of the symbol table and therefore we don't
- know where the string table starts. We just build the string
- table in memory as we go along. We process all the relocations
- for a single input file at once. */
- obj_raw_syment_count (abfd) = 0;
-
- if (coff_backend_info (abfd)->_bfd_coff_start_final_link)
- {
- if (! bfd_coff_start_final_link (abfd, info))
- goto error_return;
- }
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- for (p = o->link_order_head; p != NULL; p = p->next)
- {
- if (p->type == bfd_indirect_link_order
- && (bfd_get_flavour (p->u.indirect.section->owner)
- == bfd_target_coff_flavour))
- {
- sub = p->u.indirect.section->owner;
-#ifdef POWERPC_LE_PE
- if (! sub->output_has_begun && !ppc_do_last(sub))
-#else
- if (! sub->output_has_begun)
-#endif
- {
- if (! _bfd_coff_link_input_bfd (&finfo, sub))
- goto error_return;
- sub->output_has_begun = true;
- }
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- if (! _bfd_coff_reloc_link_order (abfd, &finfo, o, p))
- goto error_return;
- }
- else
- {
- if (! _bfd_default_link_order (abfd, info, o, p))
- goto error_return;
- }
- }
- }
-
-#ifdef POWERPC_LE_PE
- {
- extern bfd* ppc_get_last();
- bfd* last_one = ppc_get_last();
- if (last_one)
- {
- if (! _bfd_coff_link_input_bfd (&finfo, last_one))
- goto error_return;
- }
- last_one->output_has_begun = true;
- }
-#endif
-
- /* Free up the buffers used by _bfd_coff_link_input_bfd. */
-
- coff_debug_merge_hash_table_free (&finfo.debug_merge);
- debug_merge_allocated = false;
-
- if (finfo.internal_syms != NULL)
- {
- free (finfo.internal_syms);
- finfo.internal_syms = NULL;
- }
- if (finfo.sec_ptrs != NULL)
- {
- free (finfo.sec_ptrs);
- finfo.sec_ptrs = NULL;
- }
- if (finfo.sym_indices != NULL)
- {
- free (finfo.sym_indices);
- finfo.sym_indices = NULL;
- }
- if (finfo.linenos != NULL)
- {
- free (finfo.linenos);
- finfo.linenos = NULL;
- }
- if (finfo.contents != NULL)
- {
- free (finfo.contents);
- finfo.contents = NULL;
- }
- if (finfo.external_relocs != NULL)
- {
- free (finfo.external_relocs);
- finfo.external_relocs = NULL;
- }
- if (finfo.internal_relocs != NULL)
- {
- free (finfo.internal_relocs);
- finfo.internal_relocs = NULL;
- }
-
- /* The value of the last C_FILE symbol is supposed to be the symbol
- index of the first external symbol. Write it out again if
- necessary. */
- if (finfo.last_file_index != -1
- && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
- {
- finfo.last_file.n_value = obj_raw_syment_count (abfd);
- bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
- (PTR) finfo.outsyms);
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + finfo.last_file_index * symesz),
- SEEK_SET) != 0
- || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
- return false;
- }
-
- /* Write out the global symbols. */
- finfo.failed = false;
- coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym,
- (PTR) &finfo);
- if (finfo.failed)
- goto error_return;
-
- /* The outsyms buffer is used by _bfd_coff_write_global_sym. */
- if (finfo.outsyms != NULL)
- {
- free (finfo.outsyms);
- finfo.outsyms = NULL;
- }
-
- if (info->relocateable)
- {
- /* Now that we have written out all the global symbols, we know
- the symbol indices to use for relocs against them, and we can
- finally write out the relocs. */
- external_relocs = ((bfd_byte *)
- bfd_malloc (max_output_reloc_count * relsz));
- if (external_relocs == NULL)
- goto error_return;
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- struct internal_reloc *irel;
- struct internal_reloc *irelend;
- struct coff_link_hash_entry **rel_hash;
- bfd_byte *erel;
-
- if (o->reloc_count == 0)
- continue;
-
- irel = finfo.section_info[o->target_index].relocs;
- irelend = irel + o->reloc_count;
- rel_hash = finfo.section_info[o->target_index].rel_hashes;
- erel = external_relocs;
- for (; irel < irelend; irel++, rel_hash++, erel += relsz)
- {
- if (*rel_hash != NULL)
- {
- BFD_ASSERT ((*rel_hash)->indx >= 0);
- irel->r_symndx = (*rel_hash)->indx;
- }
- bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
- }
-
- if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
- || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
- abfd) != relsz * o->reloc_count)
- goto error_return;
- }
-
- free (external_relocs);
- external_relocs = NULL;
- }
-
- /* Free up the section information. */
- if (finfo.section_info != NULL)
- {
- unsigned int i;
-
- for (i = 0; i < abfd->section_count; i++)
- {
- if (finfo.section_info[i].relocs != NULL)
- free (finfo.section_info[i].relocs);
- if (finfo.section_info[i].rel_hashes != NULL)
- free (finfo.section_info[i].rel_hashes);
- }
- free (finfo.section_info);
- finfo.section_info = NULL;
- }
-
- /* Write out the string table. */
- if (obj_raw_syment_count (abfd) != 0)
- {
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * symesz),
- SEEK_SET) != 0)
- return false;
-
-#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd,
- _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
- (bfd_byte *) strbuf);
-#else
- #error Change bfd_h_put_32
-#endif
-
- if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
- return false;
-
- if (! _bfd_stringtab_emit (abfd, finfo.strtab))
- return false;
- }
-
- _bfd_stringtab_free (finfo.strtab);
-
- /* Setting bfd_get_symcount to 0 will cause write_object_contents to
- not try to write out the symbols. */
- bfd_get_symcount (abfd) = 0;
-
- return true;
-
- error_return:
- if (debug_merge_allocated)
- coff_debug_merge_hash_table_free (&finfo.debug_merge);
- if (finfo.strtab != NULL)
- _bfd_stringtab_free (finfo.strtab);
- if (finfo.section_info != NULL)
- {
- unsigned int i;
-
- for (i = 0; i < abfd->section_count; i++)
- {
- if (finfo.section_info[i].relocs != NULL)
- free (finfo.section_info[i].relocs);
- if (finfo.section_info[i].rel_hashes != NULL)
- free (finfo.section_info[i].rel_hashes);
- }
- free (finfo.section_info);
- }
- if (finfo.internal_syms != NULL)
- free (finfo.internal_syms);
- if (finfo.sec_ptrs != NULL)
- free (finfo.sec_ptrs);
- if (finfo.sym_indices != NULL)
- free (finfo.sym_indices);
- if (finfo.outsyms != NULL)
- free (finfo.outsyms);
- if (finfo.linenos != NULL)
- free (finfo.linenos);
- if (finfo.contents != NULL)
- free (finfo.contents);
- if (finfo.external_relocs != NULL)
- free (finfo.external_relocs);
- if (finfo.internal_relocs != NULL)
- free (finfo.internal_relocs);
- if (external_relocs != NULL)
- free (external_relocs);
- return false;
-}
-#endif
-
-
-/* The transfer vectors that lead the outside world to all of the above. */
-
-#ifdef TARGET_LITTLE_SYM
-const bfd_target
-TARGET_LITTLE_SYM =
-{
- TARGET_LITTLE_NAME, /* name or coff-arm-little */
- bfd_target_coff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
-
- (HAS_RELOC | EXEC_P | /* FIXME: object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading char */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen??? FIXMEmgo */
-
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
-
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_generic_archive_p, /* _bfd_dummy_target */ coff_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
-#endif
-
-#ifdef TARGET_BIG_SYM
-const bfd_target
-TARGET_BIG_SYM =
-{
- TARGET_BIG_NAME,
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* FIXME: object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading char */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen??? FIXMEmgo */
-
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
-
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_generic_archive_p, /* _bfd_dummy_target */ coff_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
-
-#endif
diff --git a/contrib/gdb/bfd/coff-rs6000.c b/contrib/gdb/bfd/coff-rs6000.c
deleted file mode 100644
index c065bd4..0000000
--- a/contrib/gdb/bfd/coff-rs6000.c
+++ /dev/null
@@ -1,1403 +0,0 @@
-/* BFD back-end for IBM RS/6000 "XCOFF" files.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- FIXME: Can someone provide a transliteration of this name into ASCII?
- Using the following chars caused a compiler warning on HIUX (so I replaced
- them with octal escapes), and isn't useful without an understanding of what
- character set it is.
- Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* 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 "coff/internal.h"
-#include "coff/rs6000.h"
-#include "libcoff.h"
-
-/* The main body of code is in coffcode.h. */
-
-static boolean xcoff_mkobject PARAMS ((bfd *));
-static boolean xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-static void xcoff_rtype2howto
- PARAMS ((arelent *, struct internal_reloc *));
-static reloc_howto_type *xcoff_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-static boolean xcoff_slurp_armap PARAMS ((bfd *));
-static const bfd_target *xcoff_archive_p PARAMS ((bfd *));
-static PTR xcoff_read_ar_hdr PARAMS ((bfd *));
-static bfd *xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
-static int xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
-static const char *normalize_filename PARAMS ((bfd *));
-static boolean xcoff_write_armap
- PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
-static boolean xcoff_write_archive_contents PARAMS ((bfd *));
-
-/* We use our own tdata type. Its first field is the COFF tdata type,
- so the COFF routines are compatible. */
-
-static boolean
-xcoff_mkobject (abfd)
- bfd *abfd;
-{
- coff_data_type *coff;
-
- abfd->tdata.xcoff_obj_data =
- ((struct xcoff_tdata *)
- bfd_zalloc (abfd, sizeof (struct xcoff_tdata)));
- if (abfd->tdata.xcoff_obj_data == NULL)
- return false;
- coff = coff_data (abfd);
- coff->symbols = (coff_symbol_type *) NULL;
- coff->conversion_table = (unsigned int *) NULL;
- coff->raw_syments = (struct coff_ptr_struct *) NULL;
- coff->relocbase = 0;
-
- xcoff_data (abfd)->modtype = ('1' << 8) | 'L';
-
- /* We set cputype to -1 to indicate that it has not been
- initialized. */
- xcoff_data (abfd)->cputype = -1;
-
- xcoff_data (abfd)->csects = NULL;
- xcoff_data (abfd)->debug_indices = NULL;
-
- return true;
-}
-
-/* Copy XCOFF data from one BFD to another. */
-
-static boolean
-xcoff_copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- struct xcoff_tdata *ix, *ox;
- asection *sec;
-
- if (ibfd->xvec != obfd->xvec)
- return true;
- ix = xcoff_data (ibfd);
- ox = xcoff_data (obfd);
- ox->full_aouthdr = ix->full_aouthdr;
- ox->toc = ix->toc;
- if (ix->sntoc == 0)
- ox->sntoc = 0;
- else
- {
- sec = coff_section_from_bfd_index (ibfd, ix->sntoc);
- if (sec == NULL)
- ox->sntoc = 0;
- else
- ox->sntoc = sec->output_section->target_index;
- }
- if (ix->snentry == 0)
- ox->snentry = 0;
- else
- {
- sec = coff_section_from_bfd_index (ibfd, ix->snentry);
- if (sec == NULL)
- ox->snentry = 0;
- else
- ox->snentry = sec->output_section->target_index;
- }
- ox->text_align_power = ix->text_align_power;
- ox->data_align_power = ix->data_align_power;
- ox->modtype = ix->modtype;
- ox->cputype = ix->cputype;
- ox->maxdata = ix->maxdata;
- ox->maxstack = ix->maxstack;
- return true;
-}
-
-/* The XCOFF reloc table. Actually, XCOFF relocations specify the
- bitsize and whether they are signed or not, along with a
- conventional type. This table is for the types, which are used for
- different algorithms for putting in the reloc. Many of these
- relocs need special_function entries, which I have not written. */
-
-static reloc_howto_type xcoff_howto_table[] =
-{
- /* Standard 32 bit relocation. */
- HOWTO (0, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_POS", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit relocation, but store negative value. */
- HOWTO (1, /* type */
- 0, /* rightshift */
- -2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_NEG", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit PC relative relocation. */
- HOWTO (2, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_REL", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit TOC relative relocation. */
- HOWTO (3, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TOC", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* I don't really know what this is. */
- HOWTO (4, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RTB", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* External TOC relative symbol. */
- HOWTO (5, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_GL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Local TOC relative symbol. */
- HOWTO (6, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TCL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- { 7 },
-
- /* Non modifiable absolute branch. */
- HOWTO (8, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_BA", /* name */
- true, /* partial_inplace */
- 0x3fffffc, /* src_mask */
- 0x3fffffc, /* dst_mask */
- false), /* pcrel_offset */
-
- { 9 },
-
- /* Non modifiable relative branch. */
- HOWTO (0xa, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_BR", /* name */
- true, /* partial_inplace */
- 0x3fffffc, /* src_mask */
- 0x3fffffc, /* dst_mask */
- false), /* pcrel_offset */
-
- { 0xb },
-
- /* Indirect load. */
- HOWTO (0xc, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Load address. */
- HOWTO (0xd, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RLA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- { 0xe },
-
- /* Non-relocating reference. */
- HOWTO (0xf, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_REF", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- { 0x10 },
- { 0x11 },
-
- /* TOC relative indirect load. */
- HOWTO (0x12, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TRL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* TOC relative load address. */
- HOWTO (0x13, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TRLA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable relative branch. */
- HOWTO (0x14, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RRTBI", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable absolute branch. */
- HOWTO (0x15, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RRTBA", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable call absolute indirect. */
- HOWTO (0x16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_CAI", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable call relative. */
- HOWTO (0x17, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_CREL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable branch absolute. */
- HOWTO (0x18, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable branch absolute. */
- HOWTO (0x19, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBAC", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable branch relative. */
- HOWTO (0x1a, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBR", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable branch absolute. */
- HOWTO (0x1b, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBRC", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false) /* pcrel_offset */
-};
-
-static void
-xcoff_rtype2howto (relent, internal)
- arelent *relent;
- struct internal_reloc *internal;
-{
- relent->howto = xcoff_howto_table + internal->r_type;
-
- /* The r_size field of an XCOFF reloc encodes the bitsize of the
- relocation, as well as indicating whether it is signed or not.
- Doublecheck that the relocation information gathered from the
- type matches this information. */
- if (relent->howto->bitsize != ((unsigned int) internal->r_size & 0x1f) + 1)
- abort ();
-#if 0
- if ((internal->r_size & 0x80) != 0
- ? (relent->howto->complain_on_overflow != complain_overflow_signed)
- : (relent->howto->complain_on_overflow != complain_overflow_bitfield))
- abort ();
-#endif
-}
-
-static reloc_howto_type *
-xcoff_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- case BFD_RELOC_PPC_B26:
- return &xcoff_howto_table[0xa];
- case BFD_RELOC_PPC_BA26:
- return &xcoff_howto_table[8];
- case BFD_RELOC_PPC_TOC16:
- return &xcoff_howto_table[3];
- case BFD_RELOC_32:
- case BFD_RELOC_CTOR:
- return &xcoff_howto_table[0];
- default:
- return NULL;
- }
-}
-
-#define SELECT_RELOC(internal, howto) \
- { \
- internal.r_type = howto->type; \
- internal.r_size = \
- ((howto->complain_on_overflow == complain_overflow_signed \
- ? 0x80 \
- : 0) \
- | (howto->bitsize - 1)); \
- }
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-
-#define COFF_LONG_FILENAMES
-
-#define RTYPE2HOWTO(cache_ptr, dst) xcoff_rtype2howto (cache_ptr, dst)
-
-#define coff_mkobject xcoff_mkobject
-#define coff_bfd_copy_private_bfd_data xcoff_copy_private_bfd_data
-#define coff_bfd_reloc_type_lookup xcoff_reloc_type_lookup
-#define coff_relocate_section _bfd_ppc_xcoff_relocate_section
-
-#include "coffcode.h"
-
-/* XCOFF archive support. The original version of this code was by
- Damon A. Permezel. It was enhanced to permit cross support, and
- writing archive files, by Ian Lance Taylor, Cygnus Support.
-
- XCOFF uses its own archive format. Everything is hooked together
- with file offset links, so it is possible to rapidly update an
- archive in place. Of course, we don't do that. An XCOFF archive
- has a real file header, not just an ARMAG string. The structure of
- the file header and of each archive header appear below.
-
- An XCOFF archive also has a member table, which is a list of
- elements in the archive (you can get that by looking through the
- linked list, but you have to read a lot more of the file). The
- member table has a normal archive header with an empty name. It is
- normally (and perhaps must be) the second to last entry in the
- archive. The member table data is almost printable ASCII. It
- starts with a 12 character decimal string which is the number of
- entries in the table. For each entry it has a 12 character decimal
- string which is the offset in the archive of that member. These
- entries are followed by a series of null terminated strings which
- are the member names for each entry.
-
- Finally, an XCOFF archive has a global symbol table, which is what
- we call the armap. The global symbol table has a normal archive
- header with an empty name. It is normally (and perhaps must be)
- the last entry in the archive. The contents start with a four byte
- binary number which is the number of entries. This is followed by
- a that many four byte binary numbers; each is the file offset of an
- entry in the archive. These numbers are followed by a series of
- null terminated strings, which are symbol names. */
-
-/* XCOFF archives use this as a magic string. */
-
-#define XCOFFARMAG "<aiaff>\012"
-#define SXCOFFARMAG 8
-
-/* This terminates an XCOFF archive member name. */
-
-#define XCOFFARFMAG "`\012"
-#define SXCOFFARFMAG 2
-
-/* XCOFF archives start with this (printable) structure. */
-
-struct xcoff_ar_file_hdr
-{
- /* Magic string. */
- char magic[SXCOFFARMAG];
-
- /* Offset of the member table (decimal ASCII string). */
- char memoff[12];
-
- /* Offset of the global symbol table (decimal ASCII string). */
- char symoff[12];
-
- /* Offset of the first member in the archive (decimal ASCII string). */
- char firstmemoff[12];
-
- /* Offset of the last member in the archive (decimal ASCII string). */
- char lastmemoff[12];
-
- /* Offset of the first member on the free list (decimal ASCII
- string). */
- char freeoff[12];
-};
-
-#define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG)
-
-/* Each XCOFF archive member starts with this (printable) structure. */
-
-struct xcoff_ar_hdr
-{
- /* File size not including the header (decimal ASCII string). */
- char size[12];
-
- /* File offset of next archive member (decimal ASCII string). */
- char nextoff[12];
-
- /* File offset of previous archive member (decimal ASCII string). */
- char prevoff[12];
-
- /* File mtime (decimal ASCII string). */
- char date[12];
-
- /* File UID (decimal ASCII string). */
- char uid[12];
-
- /* File GID (decimal ASCII string). */
- char gid[12];
-
- /* File mode (octal ASCII string). */
- char mode[12];
-
- /* Length of file name (decimal ASCII string). */
- char namlen[4];
-
- /* This structure is followed by the file name. The length of the
- name is given in the namlen field. If the length of the name is
- odd, the name is followed by a null byte. The name and optional
- null byte are followed by XCOFFARFMAG, which is not included in
- namlen. The contents of the archive member follow; the number of
- bytes is given in the size field. */
-};
-
-#define SIZEOF_AR_HDR (7 * 12 + 4)
-
-/* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
- artdata structure. */
-#define xcoff_ardata(abfd) \
- ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
-
-/* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
- archive element. */
-#define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
-#define arch_xhdr(bfd) \
- ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header)
-
-/* XCOFF archives do not have anything which corresponds to an
- extended name table. */
-
-#define xcoff_slurp_extended_name_table bfd_false
-#define xcoff_construct_extended_name_table \
- ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
- bfd_false)
-#define xcoff_truncate_arname bfd_dont_truncate_arname
-
-/* We can use the standard get_elt_at_index routine. */
-
-#define xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
-
-/* XCOFF archives do not have a timestamp. */
-
-#define xcoff_update_armap_timestamp bfd_true
-
-/* Read in the armap of an XCOFF archive. */
-
-static boolean
-xcoff_slurp_armap (abfd)
- bfd *abfd;
-{
- file_ptr off;
- struct xcoff_ar_hdr hdr;
- size_t namlen;
- bfd_size_type sz;
- bfd_byte *contents, *cend;
- unsigned int c, i;
- carsym *arsym;
- bfd_byte *p;
-
- if (xcoff_ardata (abfd) == NULL)
- {
- bfd_has_map (abfd) = false;
- return true;
- }
-
- off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10);
- if (off == 0)
- {
- bfd_has_map (abfd) = false;
- return true;
- }
-
- if (bfd_seek (abfd, off, SEEK_SET) != 0)
- return false;
-
- /* The symbol table starts with a normal archive header. */
- if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
- return false;
-
- /* Skip the name (normally empty). */
- namlen = strtol (hdr.namlen, (char **) NULL, 10);
- if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
- return false;
-
- /* Read in the entire symbol table. */
- sz = strtol (hdr.size, (char **) NULL, 10);
- contents = (bfd_byte *) bfd_alloc (abfd, sz);
- if (contents == NULL)
- return false;
- if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
- return false;
-
- /* The symbol table starts with a four byte count. */
- c = bfd_h_get_32 (abfd, contents);
-
- if (c * 4 >= sz)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- bfd_ardata (abfd)->symdefs = ((carsym *)
- bfd_alloc (abfd, c * sizeof (carsym)));
- if (bfd_ardata (abfd)->symdefs == NULL)
- return false;
-
- /* After the count comes a list of four byte file offsets. */
- for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
- i < c;
- ++i, ++arsym, p += 4)
- arsym->file_offset = bfd_h_get_32 (abfd, p);
-
- /* After the file offsets come null terminated symbol names. */
- cend = contents + sz;
- for (i = 0, arsym = bfd_ardata (abfd)->symdefs;
- i < c;
- ++i, ++arsym, p += strlen ((char *) p) + 1)
- {
- if (p >= cend)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- arsym->name = (char *) p;
- }
-
- bfd_ardata (abfd)->symdef_count = c;
- bfd_has_map (abfd) = true;
-
- return true;
-}
-
-/* See if this is an XCOFF archive. */
-
-static const bfd_target *
-xcoff_archive_p (abfd)
- bfd *abfd;
-{
- struct xcoff_ar_file_hdr hdr;
-
- if (bfd_read ((PTR) &hdr, SIZEOF_AR_FILE_HDR, 1, abfd)
- != SIZEOF_AR_FILE_HDR)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if (strncmp (hdr.magic, XCOFFARMAG, SXCOFFARMAG) != 0)
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* 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. */
- abfd->tdata.aout_ar_data =
- (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
-
- if (bfd_ardata (abfd) == (struct artdata *) NULL)
- return NULL;
-
- bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
- (char **) NULL, 10);
- bfd_ardata (abfd)->cache = NULL;
- bfd_ardata (abfd)->archive_head = NULL;
- bfd_ardata (abfd)->symdefs = NULL;
- bfd_ardata (abfd)->extended_names = NULL;
-
- bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
- if (bfd_ardata (abfd)->tdata == NULL)
- return NULL;
-
- memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
-
- if (! xcoff_slurp_armap (abfd))
- {
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = (struct artdata *) NULL;
- return NULL;
- }
-
- return abfd->xvec;
-}
-
-/* Read the archive header in an XCOFF archive. */
-
-static PTR
-xcoff_read_ar_hdr (abfd)
- bfd *abfd;
-{
- struct xcoff_ar_hdr hdr;
- size_t namlen;
- struct xcoff_ar_hdr *hdrp;
- struct areltdata *ret;
-
- if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
- return NULL;
-
- namlen = strtol (hdr.namlen, (char **) NULL, 10);
- hdrp = bfd_alloc (abfd, SIZEOF_AR_HDR + namlen + 1);
- if (hdrp == NULL)
- return NULL;
- memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
- if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
- return NULL;
- ((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0';
-
- ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
- if (ret == NULL)
- return NULL;
- ret->arch_header = (char *) hdrp;
- ret->parsed_size = strtol (hdr.size, (char **) NULL, 10);
- ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
-
- /* Skip over the XCOFFARFMAG at the end of the file name. */
- if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0)
- return NULL;
-
- return (PTR) ret;
-}
-
-/* Open the next element in an XCOFF archive. */
-
-static bfd *
-xcoff_openr_next_archived_file (archive, last_file)
- bfd *archive;
- bfd *last_file;
-{
- file_ptr filestart;
-
- if (xcoff_ardata (archive) == NULL)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
- }
-
- if (last_file == NULL)
- filestart = bfd_ardata (archive)->first_file_filepos;
- else
- filestart = strtol (arch_xhdr (last_file)->nextoff, (char **) NULL, 10);
-
- if (filestart == 0
- || filestart == strtol (xcoff_ardata (archive)->memoff,
- (char **) NULL, 10)
- || filestart == strtol (xcoff_ardata (archive)->symoff,
- (char **) NULL, 10))
- {
- bfd_set_error (bfd_error_no_more_archived_files);
- return NULL;
- }
-
- return _bfd_get_elt_at_filepos (archive, filestart);
-}
-
-/* Stat an element in an XCOFF archive. */
-
-static int
-xcoff_generic_stat_arch_elt (abfd, s)
- bfd *abfd;
- struct stat *s;
-{
- struct xcoff_ar_hdr *hdrp;
-
- if (abfd->arelt_data == NULL)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
-
- hdrp = arch_xhdr (abfd);
-
- s->st_mtime = strtol (hdrp->date, (char **) NULL, 10);
- s->st_uid = strtol (hdrp->uid, (char **) NULL, 10);
- s->st_gid = strtol (hdrp->gid, (char **) NULL, 10);
- s->st_mode = strtol (hdrp->mode, (char **) NULL, 8);
- s->st_size = arch_eltdata (abfd)->parsed_size;
-
- return 0;
-}
-
-/* Normalize a file name for inclusion in an archive. */
-
-static const char *
-normalize_filename (abfd)
- bfd *abfd;
-{
- const char *file;
- const char *filename;
-
- file = bfd_get_filename (abfd);
- filename = strrchr (file, '/');
- if (filename != NULL)
- filename++;
- else
- filename = file;
- return filename;
-}
-
-/* Write out an XCOFF armap. */
-
-/*ARGSUSED*/
-static boolean
-xcoff_write_armap (abfd, elength, map, orl_count, stridx)
- bfd *abfd;
- unsigned int elength;
- struct orl *map;
- unsigned int orl_count;
- int stridx;
-{
- struct xcoff_ar_hdr hdr;
- char *p;
- unsigned char buf[4];
- bfd *sub;
- file_ptr fileoff;
- unsigned int i;
-
- memset (&hdr, 0, sizeof hdr);
- sprintf (hdr.size, "%ld", (long) (4 + orl_count * 4 + stridx));
- sprintf (hdr.nextoff, "%d", 0);
- memcpy (hdr.prevoff, xcoff_ardata (abfd)->memoff, 12);
- sprintf (hdr.date, "%d", 0);
- sprintf (hdr.uid, "%d", 0);
- sprintf (hdr.gid, "%d", 0);
- sprintf (hdr.mode, "%d", 0);
- sprintf (hdr.namlen, "%d", 0);
-
- /* We need spaces, not null bytes, in the header. */
- for (p = (char *) &hdr; p < (char *) &hdr + SIZEOF_AR_HDR; p++)
- if (*p == '\0')
- *p = ' ';
-
- if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR
- || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
- return false;
-
- bfd_h_put_32 (abfd, orl_count, buf);
- if (bfd_write (buf, 1, 4, abfd) != 4)
- return false;
-
- sub = abfd->archive_head;
- fileoff = SIZEOF_AR_FILE_HDR;
- i = 0;
- while (sub != NULL && i < orl_count)
- {
- size_t namlen;
-
- while (((bfd *) (map[i]).pos) == sub)
- {
- bfd_h_put_32 (abfd, fileoff, buf);
- if (bfd_write (buf, 1, 4, abfd) != 4)
- return false;
- ++i;
- }
- namlen = strlen (normalize_filename (sub));
- namlen = (namlen + 1) &~ 1;
- fileoff += (SIZEOF_AR_HDR
- + namlen
- + SXCOFFARFMAG
- + arelt_size (sub));
- fileoff = (fileoff + 1) &~ 1;
- sub = sub->next;
- }
-
- for (i = 0; i < orl_count; i++)
- {
- const char *name;
- size_t namlen;
-
- name = *map[i].name;
- namlen = strlen (name);
- if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1)
- return false;
- }
-
- if ((stridx & 1) != 0)
- {
- char b;
-
- b = '\0';
- if (bfd_write (&b, 1, 1, abfd) != 1)
- return false;
- }
-
- return true;
-}
-
-/* Write out an XCOFF archive. We always write an entire archive,
- rather than fussing with the freelist and so forth. */
-
-static boolean
-xcoff_write_archive_contents (abfd)
- bfd *abfd;
-{
- struct xcoff_ar_file_hdr fhdr;
- size_t count;
- size_t total_namlen;
- file_ptr *offsets;
- boolean makemap;
- boolean hasobjects;
- file_ptr prevoff, nextoff;
- bfd *sub;
- unsigned int i;
- struct xcoff_ar_hdr ahdr;
- bfd_size_type size;
- char *p;
- char decbuf[13];
-
- memset (&fhdr, 0, sizeof fhdr);
- strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);
- sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR);
- sprintf (fhdr.freeoff, "%d", 0);
-
- count = 0;
- total_namlen = 0;
- for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
- {
- ++count;
- total_namlen += strlen (normalize_filename (sub)) + 1;
- }
- offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
- if (offsets == NULL)
- return false;
-
- if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
- return false;
-
- makemap = bfd_has_map (abfd);
- hasobjects = false;
- prevoff = 0;
- nextoff = SIZEOF_AR_FILE_HDR;
- for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
- {
- const char *name;
- size_t namlen;
- struct xcoff_ar_hdr *ahdrp;
- bfd_size_type remaining;
-
- if (makemap && ! hasobjects)
- {
- if (bfd_check_format (sub, bfd_object))
- hasobjects = true;
- }
-
- name = normalize_filename (sub);
- namlen = strlen (name);
-
- if (sub->arelt_data != NULL)
- ahdrp = arch_xhdr (sub);
- else
- ahdrp = NULL;
-
- if (ahdrp == NULL)
- {
- struct stat s;
-
- memset (&ahdr, 0, sizeof ahdr);
- ahdrp = &ahdr;
- if (stat (bfd_get_filename (sub), &s) != 0)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
-
- sprintf (ahdrp->size, "%ld", (long) s.st_size);
- sprintf (ahdrp->date, "%ld", (long) s.st_mtime);
- sprintf (ahdrp->uid, "%ld", (long) s.st_uid);
- sprintf (ahdrp->gid, "%ld", (long) s.st_gid);
- sprintf (ahdrp->mode, "%o", (unsigned int) s.st_mode);
-
- if (sub->arelt_data == NULL)
- {
- sub->arelt_data = ((struct areltdata *)
- bfd_alloc (sub, sizeof (struct areltdata)));
- if (sub->arelt_data == NULL)
- return false;
- }
-
- arch_eltdata (sub)->parsed_size = s.st_size;
- }
-
- sprintf (ahdrp->prevoff, "%ld", (long) prevoff);
- sprintf (ahdrp->namlen, "%ld", (long) namlen);
-
- /* If the length of the name is odd, we write out the null byte
- after the name as well. */
- namlen = (namlen + 1) &~ 1;
-
- remaining = arelt_size (sub);
- size = (SIZEOF_AR_HDR
- + namlen
- + SXCOFFARFMAG
- + remaining);
-
- BFD_ASSERT (nextoff == bfd_tell (abfd));
-
- offsets[i] = nextoff;
-
- prevoff = nextoff;
- nextoff += size + (size & 1);
-
- sprintf (ahdrp->nextoff, "%ld", (long) nextoff);
-
- /* We need spaces, not null bytes, in the header. */
- for (p = (char *) ahdrp; p < (char *) ahdrp + SIZEOF_AR_HDR; p++)
- if (*p == '\0')
- *p = ' ';
-
- if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
- || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
- || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
- != SXCOFFARFMAG))
- return false;
-
- if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)
- return false;
- while (remaining != 0)
- {
- bfd_size_type amt;
- bfd_byte buffer[DEFAULT_BUFFERSIZE];
-
- amt = sizeof buffer;
- if (amt > remaining)
- amt = remaining;
- if (bfd_read (buffer, 1, amt, sub) != amt
- || bfd_write (buffer, 1, amt, abfd) != amt)
- return false;
- remaining -= amt;
- }
-
- if ((size & 1) != 0)
- {
- bfd_byte b;
-
- b = '\0';
- if (bfd_write (&b, 1, 1, abfd) != 1)
- return false;
- }
- }
-
- sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);
-
- /* Write out the member table. */
-
- BFD_ASSERT (nextoff == bfd_tell (abfd));
- sprintf (fhdr.memoff, "%ld", (long) nextoff);
-
- memset (&ahdr, 0, sizeof ahdr);
- sprintf (ahdr.size, "%ld", (long) (12 + count * 12 + total_namlen));
- sprintf (ahdr.prevoff, "%ld", (long) prevoff);
- sprintf (ahdr.date, "%d", 0);
- sprintf (ahdr.uid, "%d", 0);
- sprintf (ahdr.gid, "%d", 0);
- sprintf (ahdr.mode, "%d", 0);
- sprintf (ahdr.namlen, "%d", 0);
-
- size = (SIZEOF_AR_HDR
- + 12
- + count * 12
- + total_namlen
- + SXCOFFARFMAG);
-
- prevoff = nextoff;
- nextoff += size + (size & 1);
-
- if (makemap && hasobjects)
- sprintf (ahdr.nextoff, "%ld", (long) nextoff);
- else
- sprintf (ahdr.nextoff, "%d", 0);
-
- /* We need spaces, not null bytes, in the header. */
- for (p = (char *) &ahdr; p < (char *) &ahdr + SIZEOF_AR_HDR; p++)
- if (*p == '\0')
- *p = ' ';
-
- if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
- || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
- != SXCOFFARFMAG))
- return false;
-
- sprintf (decbuf, "%-12ld", (long) count);
- if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
- return false;
- for (i = 0; i < count; i++)
- {
- sprintf (decbuf, "%-12ld", (long) offsets[i]);
- if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
- return false;
- }
- for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
- {
- const char *name;
- size_t namlen;
-
- name = normalize_filename (sub);
- namlen = strlen (name);
- if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1)
- return false;
- }
- if ((size & 1) != 0)
- {
- bfd_byte b;
-
- b = '\0';
- if (bfd_write ((PTR) &b, 1, 1, abfd) != 1)
- return false;
- }
-
- /* Write out the armap, if appropriate. */
-
- if (! makemap || ! hasobjects)
- sprintf (fhdr.symoff, "%d", 0);
- else
- {
- BFD_ASSERT (nextoff == bfd_tell (abfd));
- sprintf (fhdr.symoff, "%ld", (long) nextoff);
- bfd_ardata (abfd)->tdata = (PTR) &fhdr;
- if (! _bfd_compute_and_write_armap (abfd, 0))
- return false;
- }
-
- /* Write out the archive file header. */
-
- /* We need spaces, not null bytes, in the header. */
- for (p = (char *) &fhdr; p < (char *) &fhdr + SIZEOF_AR_FILE_HDR; p++)
- if (*p == '\0')
- *p = ' ';
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR, 1, abfd) !=
- SIZEOF_AR_FILE_HDR))
- return false;
-
- return true;
-}
-
-/* We can't use the usual coff_sizeof_headers routine, because AIX
- always uses an a.out header. */
-
-/*ARGSUSED*/
-static int
-_bfd_xcoff_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
-{
- int size;
-
- size = FILHSZ;
- if (xcoff_data (abfd)->full_aouthdr)
- size += AOUTSZ;
- else
- size += SMALL_AOUTSZ;
- size += abfd->section_count * SCNHSZ;
- return size;
-}
-
-#define CORE_FILE_P _bfd_dummy_target
-
-#define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
-#define coff_core_file_failing_signal _bfd_nocore_core_file_failing_signal
-#define coff_core_file_matches_executable_p \
- _bfd_nocore_core_file_matches_executable_p
-
-#ifdef AIX_CORE
-#undef CORE_FILE_P
-#define CORE_FILE_P rs6000coff_core_p
-extern const bfd_target * rs6000coff_core_p ();
-extern boolean rs6000coff_get_section_contents ();
-extern boolean rs6000coff_core_file_matches_executable_p ();
-
-#undef coff_core_file_matches_executable_p
-#define coff_core_file_matches_executable_p \
- rs6000coff_core_file_matches_executable_p
-
-extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
-#undef coff_core_file_failing_command
-#define coff_core_file_failing_command rs6000coff_core_file_failing_command
-
-extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
-#undef coff_core_file_failing_signal
-#define coff_core_file_failing_signal rs6000coff_core_file_failing_signal
-
-#undef coff_get_section_contents
-#define coff_get_section_contents rs6000coff_get_section_contents
-#endif /* AIX_CORE */
-
-#ifdef LYNX_CORE
-
-#undef CORE_FILE_P
-#define CORE_FILE_P lynx_core_file_p
-extern const bfd_target *lynx_core_file_p PARAMS ((bfd *abfd));
-
-extern boolean lynx_core_file_matches_executable_p PARAMS ((bfd *core_bfd,
- bfd *exec_bfd));
-#undef coff_core_file_matches_executable_p
-#define coff_core_file_matches_executable_p lynx_core_file_matches_executable_p
-
-extern char *lynx_core_file_failing_command PARAMS ((bfd *abfd));
-#undef coff_core_file_failing_command
-#define coff_core_file_failing_command lynx_core_file_failing_command
-
-extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
-#undef coff_core_file_failing_signal
-#define coff_core_file_failing_signal lynx_core_file_failing_signal
-
-#endif /* LYNX_CORE */
-
-#define _bfd_xcoff_bfd_get_relocated_section_contents \
- coff_bfd_get_relocated_section_contents
-#define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
-#define _bfd_xcoff_bfd_link_split_section coff_bfd_link_split_section
-
-/* The transfer vector that leads the outside world to all of the above. */
-
-const bfd_target
-#ifdef TARGET_SYM
- TARGET_SYM =
-#else
- rs6000coff_vec =
-#endif
-{
-#ifdef TARGET_NAME
- TARGET_NAME,
-#else
- "aixcoff-rs6000", /* name */
-#endif
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG | DYNAMIC |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading char */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen??? FIXMEmgo */
-
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- xcoff_archive_p, CORE_FILE_P},
- {bfd_false, coff_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, coff_write_object_contents, /* bfd_write_contents */
- xcoff_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (coff),
- BFD_JUMP_TABLE_ARCHIVE (xcoff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (_bfd_xcoff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-sh.c b/contrib/gdb/bfd/coff-sh.c
deleted file mode 100644
index 17bb4b1..0000000
--- a/contrib/gdb/bfd/coff-sh.c
+++ /dev/null
@@ -1,1525 +0,0 @@
-/* BFD back-end for Hitachi Super-H COFF binaries.
- Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
- Written by Steve Chamberlain, <sac@cygnus.com>.
- Relaxing code written by Ian Lance Taylor, <ian@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "obstack.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "coff/sh.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-/* Internal functions. */
-static bfd_reloc_status_type sh_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static long get_symbol_value PARAMS ((asymbol *));
-static boolean sh_relax_section
- PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
-static boolean sh_relax_delete_bytes
- PARAMS ((bfd *, asection *, bfd_vma, int));
-static boolean sh_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- struct internal_reloc *, struct internal_syment *, asection **));
-static bfd_byte *sh_coff_get_relocated_section_contents
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *, boolean, asymbol **));
-
-/* Default section alignment to 2**2. */
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
-
-/* Generate long file names. */
-#define COFF_LONG_FILENAMES
-
-/* The supported relocations. There are a lot of relocations defined
- in coff/internal.h which we do not expect to ever see. */
-static reloc_howto_type sh_coff_howtos[] =
-{
- { 0 },
- { 1 },
- { 2 },
- { 3 }, /* R_SH_PCREL8 */
- { 4 }, /* R_SH_PCREL16 */
- { 5 }, /* R_SH_HIGH8 */
- { 6 }, /* R_SH_IMM24 */
- { 7 }, /* R_SH_LOW16 */
- { 8 },
- { 9 }, /* R_SH_PCDISP8BY4 */
-
- HOWTO (R_SH_PCDISP8BY2, /* type */
- 1, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_pcdisp8by2", /* name */
- true, /* partial_inplace */
- 0xff, /* src_mask */
- 0xff, /* dst_mask */
- true), /* pcrel_offset */
-
- { 11 }, /* R_SH_PCDISP8 */
-
- HOWTO (R_SH_PCDISP, /* type */
- 1, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 12, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_pcdisp12by2", /* name */
- true, /* partial_inplace */
- 0xfff, /* src_mask */
- 0xfff, /* dst_mask */
- true), /* pcrel_offset */
-
- { 13 },
-
- HOWTO (R_SH_IMM32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_imm32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- { 15 },
- { 16 }, /* R_SH_IMM8 */
- { 17 }, /* R_SH_IMM8BY2 */
- { 18 }, /* R_SH_IMM8BY4 */
- { 19 }, /* R_SH_IMM4 */
- { 20 }, /* R_SH_IMM4BY2 */
- { 21 }, /* R_SH_IMM4BY4 */
-
- HOWTO (R_SH_PCRELIMM8BY2, /* type */
- 1, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_unsigned, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_pcrelimm8by2", /* name */
- true, /* partial_inplace */
- 0xff, /* src_mask */
- 0xff, /* dst_mask */
- true), /* pcrel_offset */
-
- HOWTO (R_SH_PCRELIMM8BY4, /* type */
- 2, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_unsigned, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_pcrelimm8by4", /* name */
- true, /* partial_inplace */
- 0xff, /* src_mask */
- 0xff, /* dst_mask */
- true), /* pcrel_offset */
-
- HOWTO (R_SH_IMM16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_imm16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- HOWTO (R_SH_SWITCH16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_switch16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- HOWTO (R_SH_SWITCH32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_switch32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- HOWTO (R_SH_USES, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_uses", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- HOWTO (R_SH_COUNT, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_count", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- HOWTO (R_SH_ALIGN, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- sh_reloc, /* special_function */
- "r_align", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false) /* pcrel_offset */
-};
-
-#define SH_COFF_HOWTO_COUNT (sizeof sh_coff_howtos / sizeof sh_coff_howtos[0])
-
-/* Check for a bad magic number. */
-#define BADMAG(x) SHBADMAG(x)
-
-/* Customize coffcode.h (this is not currently used). */
-#define SH 1
-
-/* FIXME: This should not be set here. */
-#define __A_MAGIC_SET__
-
-/* Swap the r_offset field in and out. */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
-
-/* Swap out extra information in the reloc structure. */
-#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
- do \
- { \
- dst->r_stuff[0] = 'S'; \
- dst->r_stuff[1] = 'C'; \
- } \
- while (0)
-
-/* Get the value of a symbol, when performing a relocation. */
-
-static long
-get_symbol_value (symbol)
- asymbol *symbol;
-{
- bfd_vma relocation;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = (symbol->value +
- symbol->section->output_section->vma +
- symbol->section->output_offset);
-
- return relocation;
-}
-
-/* This macro is used in coffcode.h to get the howto corresponding to
- an internal reloc. */
-
-#define RTYPE2HOWTO(relent, internal) \
- ((relent)->howto = \
- ((internal)->r_type < SH_COFF_HOWTO_COUNT \
- ? &sh_coff_howtos[(internal)->r_type] \
- : (reloc_howto_type *) NULL))
-
-/* This is the same as the macro in coffcode.h, except that it copies
- r_offset into reloc_entry->addend for some relocs. */
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
- { \
- coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
- if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
- coffsym = (obj_symbols (abfd) \
- + (cache_ptr->sym_ptr_ptr - symbols)); \
- else if (ptr) \
- coffsym = coff_symbol_from (abfd, ptr); \
- if (coffsym != (coff_symbol_type *) NULL \
- && coffsym->native->u.syment.n_scnum == 0) \
- cache_ptr->addend = 0; \
- else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
- && ptr->section != (asection *) NULL) \
- cache_ptr->addend = - (ptr->section->vma + ptr->value); \
- else \
- cache_ptr->addend = 0; \
- if ((reloc).r_type == R_SH_SWITCH16 \
- || (reloc).r_type == R_SH_SWITCH32 \
- || (reloc).r_type == R_SH_USES \
- || (reloc).r_type == R_SH_COUNT \
- || (reloc).r_type == R_SH_ALIGN) \
- cache_ptr->addend = (reloc).r_offset; \
- }
-
-/* This is the howto function for the SH relocations. */
-
-static bfd_reloc_status_type
-sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol_in;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- unsigned long insn;
- bfd_vma sym_value;
- unsigned short r_type;
- bfd_vma addr = reloc_entry->address;
- bfd_byte *hit_data = addr + (bfd_byte *) data;
-
- r_type = reloc_entry->howto->type;
-
- if (output_bfd != NULL)
- {
- /* Partial linking--do nothing. */
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* Almost all relocs have to do with relaxing. If any work must be
- done for them, it has been done in sh_relax_section. */
- if (r_type != R_SH_IMM32
- && (r_type != R_SH_PCDISP
- || (symbol_in->flags & BSF_LOCAL) != 0))
- return bfd_reloc_ok;
-
- if (symbol_in != NULL
- && bfd_is_und_section (symbol_in->section))
- return bfd_reloc_undefined;
-
- sym_value = get_symbol_value (symbol_in);
-
- switch (r_type)
- {
- case R_SH_IMM32:
- insn = bfd_get_32 (abfd, hit_data);
- insn += sym_value + reloc_entry->addend;
- bfd_put_32 (abfd, insn, hit_data);
- break;
- case R_SH_PCDISP:
- insn = bfd_get_16 (abfd, hit_data);
- sym_value += reloc_entry->addend;
- sym_value -= (input_section->output_section->vma
- + input_section->output_offset
- + addr
- + 4);
- sym_value += (insn & 0xfff) << 1;
- if (insn & 0x800)
- sym_value -= 0x1000;
- insn = (insn & 0xf000) | (sym_value & 0xfff);
- bfd_put_16 (abfd, insn, hit_data);
- if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000)
- return bfd_reloc_overflow;
- break;
- default:
- abort ();
- break;
- }
-
- return bfd_reloc_ok;
-}
-
-/* We can do relaxing. */
-#define coff_bfd_relax_section sh_relax_section
-
-/* We use the special COFF backend linker. */
-#define coff_relocate_section sh_relocate_section
-
-/* When relaxing, we need to use special code to get the relocated
- section contents. */
-#define coff_bfd_get_relocated_section_contents \
- sh_coff_get_relocated_section_contents
-
-#include "coffcode.h"
-
-/* This function handles relaxing on the SH.
-
- Function calls on the SH look like this:
-
- movl L1,r0
- ...
- jsr @r0
- ...
- L1:
- .long function
-
- The compiler and assembler will cooperate to create R_SH_USES
- relocs on the jsr instructions. The r_offset field of the
- R_SH_USES reloc is the PC relative offset to the instruction which
- loads the register (the r_offset field is computed as though it
- were a jump instruction, so the offset value is actually from four
- bytes past the instruction). The linker can use this reloc to
- determine just which function is being called, and thus decide
- whether it is possible to replace the jsr with a bsr.
-
- If multiple function calls are all based on a single register load
- (i.e., the same function is called multiple times), the compiler
- guarantees that each function call will have an R_SH_USES reloc.
- Therefore, if the linker is able to convert each R_SH_USES reloc
- which refers to that address, it can safely eliminate the register
- load.
-
- When the assembler creates an R_SH_USES reloc, it examines it to
- determine which address is being loaded (L1 in the above example).
- It then counts the number of references to that address, and
- creates an R_SH_COUNT reloc at that address. The r_offset field of
- the R_SH_COUNT reloc will be the number of references. If the
- linker is able to eliminate a register load, it can use the
- R_SH_COUNT reloc to see whether it can also eliminate the function
- address. */
-
-static boolean
-sh_relax_section (abfd, sec, link_info, again)
- bfd *abfd;
- asection *sec;
- struct bfd_link_info *link_info;
- boolean *again;
-{
- struct internal_reloc *internal_relocs;
- struct internal_reloc *free_relocs = NULL;
- struct internal_reloc *irel, *irelend;
- bfd_byte *contents = NULL;
- bfd_byte *free_contents = NULL;
-
- *again = false;
-
- if (link_info->relocateable
- || (sec->flags & SEC_RELOC) == 0
- || sec->reloc_count == 0)
- return true;
-
- /* If this is the first time we have been called for this section,
- initialize the cooked size. */
- if (sec->_cooked_size == 0)
- sec->_cooked_size = sec->_raw_size;
-
- internal_relocs = (_bfd_coff_read_internal_relocs
- (abfd, sec, link_info->keep_memory,
- (bfd_byte *) NULL, false,
- (struct internal_reloc *) NULL));
- if (internal_relocs == NULL)
- goto error_return;
- if (! link_info->keep_memory)
- free_relocs = internal_relocs;
-
- irelend = internal_relocs + sec->reloc_count;
- for (irel = internal_relocs; irel < irelend; irel++)
- {
- bfd_vma laddr, paddr, symval;
- unsigned short insn;
- struct internal_reloc *irelfn, *irelscan, *irelcount;
- struct internal_syment sym;
- bfd_signed_vma foff;
-
- if (irel->r_type != R_SH_USES)
- continue;
-
- /* Get the section contents. */
- if (contents == NULL)
- {
- if (coff_section_data (abfd, sec) != NULL
- && coff_section_data (abfd, sec)->contents != NULL)
- contents = coff_section_data (abfd, sec)->contents;
- else
- {
- contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
- if (contents == NULL)
- goto error_return;
- free_contents = contents;
-
- if (! bfd_get_section_contents (abfd, sec, contents,
- (file_ptr) 0, sec->_raw_size))
- goto error_return;
- }
- }
-
- /* The r_offset field of the R_SH_USES reloc will point us to
- the register load. The 4 is because the r_offset field is
- computed as though it were a jump offset, which are based
- from 4 bytes after the jump instruction. */
- laddr = irel->r_vaddr - sec->vma + 4 + irel->r_offset;
- if (laddr >= sec->_raw_size)
- {
- (*_bfd_error_handler) ("%s: 0x%lx: warning: bad R_SH_USES offset",
- bfd_get_filename (abfd),
- (unsigned long) irel->r_vaddr);
- continue;
- }
- insn = bfd_get_16 (abfd, contents + laddr);
-
- /* If the instruction is not mov.l NN,rN, we don't know what to
- do. */
- if ((insn & 0xf000) != 0xd000)
- {
- ((*_bfd_error_handler)
- ("%s: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x",
- bfd_get_filename (abfd), (unsigned long) irel->r_vaddr, insn));
- continue;
- }
-
- /* Get the address from which the register is being loaded. The
- displacement in the mov.l instruction is quadrupled. It is a
- displacement from four bytes after the movl instruction, but,
- before adding in the PC address, two least significant bits
- of the PC are cleared. We assume that the section is aligned
- on a four byte boundary. */
- paddr = insn & 0xff;
- paddr *= 4;
- paddr += (laddr + 4) &~ 3;
- if (paddr >= sec->_raw_size)
- {
- ((*_bfd_error_handler)
- ("%s: 0x%lx: warning: bad R_SH_USES load offset",
- bfd_get_filename (abfd), (unsigned long) irel->r_vaddr));
- continue;
- }
-
- /* Get the reloc for the address from which the register is
- being loaded. This reloc will tell us which function is
- actually being called. */
- paddr += sec->vma;
- for (irelfn = internal_relocs; irelfn < irelend; irelfn++)
- if (irelfn->r_vaddr == paddr
- && irelfn->r_type == R_SH_IMM32)
- break;
- if (irelfn >= irelend)
- {
- ((*_bfd_error_handler)
- ("%s: 0x%lx: warning: could not find expected reloc",
- bfd_get_filename (abfd), (unsigned long) paddr));
- continue;
- }
-
- /* Get the value of the symbol referred to by the reloc. */
- if (! _bfd_coff_get_external_symbols (abfd))
- goto error_return;
- bfd_coff_swap_sym_in (abfd,
- ((bfd_byte *) obj_coff_external_syms (abfd)
- + (irelfn->r_symndx
- * bfd_coff_symesz (abfd))),
- &sym);
- if (sym.n_scnum != 0 && sym.n_scnum != sec->target_index)
- {
- ((*_bfd_error_handler)
- ("%s: 0x%lx: warning: symbol in unexpected section",
- bfd_get_filename (abfd), (unsigned long) paddr));
- continue;
- }
-
- if (sym.n_sclass != C_EXT)
- {
- symval = (sym.n_value
- - sec->vma
- + sec->output_section->vma
- + sec->output_offset);
- }
- else
- {
- struct coff_link_hash_entry *h;
-
- h = obj_coff_sym_hashes (abfd)[irelfn->r_symndx];
- BFD_ASSERT (h != NULL);
- if (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak)
- {
- /* This appears to be a reference to an undefined
- symbol. Just ignore it--it will be caught by the
- regular reloc processing. */
- continue;
- }
-
- symval = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- }
-
- symval += bfd_get_32 (abfd, contents + paddr - sec->vma);
-
- /* See if this function call can be shortened. */
- foff = (symval
- - (irel->r_vaddr
- - sec->vma
- + sec->output_section->vma
- + sec->output_offset
- + 4));
- if (foff < -0x1000 || foff >= 0x1000)
- {
- /* After all that work, we can't shorten this function call. */
- continue;
- }
-
- /* Shorten the function call. */
-
- /* For simplicity of coding, we are going to modify the section
- contents, the section relocs, and the BFD symbol table. We
- must tell the rest of the code not to free up this
- information. It would be possible to instead create a table
- of changes which have to be made, as is done in coff-mips.c;
- that would be more work, but would require less memory when
- the linker is run. */
-
- if (coff_section_data (abfd, sec) == NULL)
- {
- sec->used_by_bfd =
- ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
- if (sec->used_by_bfd == NULL)
- goto error_return;
- }
-
- coff_section_data (abfd, sec)->relocs = internal_relocs;
- coff_section_data (abfd, sec)->keep_relocs = true;
- free_relocs = NULL;
-
- coff_section_data (abfd, sec)->contents = contents;
- coff_section_data (abfd, sec)->keep_contents = true;
- free_contents = NULL;
-
- obj_coff_keep_syms (abfd) = true;
-
- /* Replace the jsr with a bsr. */
-
- /* Change the R_SH_USES reloc into an R_SH_PCDISP reloc, and
- replace the jsr with a bsr. */
- irel->r_type = R_SH_PCDISP;
- irel->r_symndx = irelfn->r_symndx;
- if (sym.n_sclass != C_EXT)
- {
- /* If this needs to be changed because of future relaxing,
- it will be handled here like other internal PCDISP
- relocs. */
- bfd_put_16 (abfd,
- 0xb000 | ((foff >> 1) & 0xfff),
- contents + irel->r_vaddr - sec->vma);
- }
- else
- {
- /* We can't fully resolve this yet, because the external
- symbol value may be changed by future relaxing. We let
- the final link phase handle it. */
- bfd_put_16 (abfd, 0xb000, contents + irel->r_vaddr - sec->vma);
- }
-
- /* See if there is another R_SH_USES reloc referring to the same
- register load. */
- for (irelscan = internal_relocs; irelscan < irelend; irelscan++)
- if (irelscan->r_type == R_SH_USES
- && laddr == irelscan->r_vaddr - sec->vma + 4 + irelscan->r_offset)
- break;
- if (irelscan < irelend)
- {
- /* Some other function call depends upon this register load,
- and we have not yet converted that function call.
- Indeed, we may never be able to convert it. There is
- nothing else we can do at this point. */
- continue;
- }
-
- /* Look for a R_SH_COUNT reloc on the location where the
- function address is stored. Do this before deleting any
- bytes, to avoid confusion about the address. */
- for (irelcount = internal_relocs; irelcount < irelend; irelcount++)
- if (irelcount->r_vaddr == paddr
- && irelcount->r_type == R_SH_COUNT)
- break;
-
- /* Delete the register load. */
- if (! sh_relax_delete_bytes (abfd, sec, laddr, 2))
- goto error_return;
-
- /* That will change things, so, just in case it permits some
- other function call to come within range, we should relax
- again. Note that this is not required, and it may be slow. */
- *again = true;
-
- /* Now check whether we got a COUNT reloc. */
- if (irelcount >= irelend)
- {
- ((*_bfd_error_handler)
- ("%s: 0x%lx: warning: could not find expected COUNT reloc",
- bfd_get_filename (abfd), (unsigned long) paddr));
- continue;
- }
-
- /* The number of uses is stored in the r_offset field. We've
- just deleted one. */
- if (irelcount->r_offset == 0)
- {
- ((*_bfd_error_handler) ("%s: 0x%lx: warning: bad count",
- bfd_get_filename (abfd),
- (unsigned long) paddr));
- continue;
- }
-
- --irelcount->r_offset;
-
- /* If there are no more uses, we can delete the address. Reload
- the address from irelfn, in case it was changed by the
- previous call to sh_relax_delete_bytes. */
- if (irelcount->r_offset == 0)
- {
- if (! sh_relax_delete_bytes (abfd, sec,
- irelfn->r_vaddr - sec->vma, 4))
- goto error_return;
- }
-
- /* We've done all we can with that function call. */
- }
-
- if (free_relocs != NULL)
- {
- free (free_relocs);
- free_relocs = NULL;
- }
-
- if (free_contents != NULL)
- {
- if (! link_info->keep_memory)
- free (free_contents);
- else
- {
- /* Cache the section contents for coff_link_input_bfd. */
- if (coff_section_data (abfd, sec) == NULL)
- {
- sec->used_by_bfd =
- ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
- if (sec->used_by_bfd == NULL)
- goto error_return;
- coff_section_data (abfd, sec)->relocs = NULL;
- }
- coff_section_data (abfd, sec)->contents = contents;
- }
- }
-
- return true;
-
- error_return:
- if (free_relocs != NULL)
- free (free_relocs);
- if (free_contents != NULL)
- free (free_contents);
- return false;
-}
-
-/* Delete some bytes from a section while relaxing. */
-
-static boolean
-sh_relax_delete_bytes (abfd, sec, addr, count)
- bfd *abfd;
- asection *sec;
- bfd_vma addr;
- int count;
-{
- bfd_byte *contents;
- struct internal_reloc *irel, *irelend;
- struct internal_reloc *irelalign;
- bfd_vma toaddr;
- bfd_byte *esym, *esymend;
- bfd_size_type symesz;
- struct coff_link_hash_entry **sym_hash;
- asection *o;
-
- contents = coff_section_data (abfd, sec)->contents;
-
- /* The deletion must stop at the next ALIGN reloc for an aligment
- power larger than the number of bytes we are deleting. */
-
- irelalign = NULL;
- toaddr = sec->_cooked_size;
-
- irel = coff_section_data (abfd, sec)->relocs;
- irelend = irel + sec->reloc_count;
- for (; irel < irelend; irel++)
- {
- if (irel->r_type == R_SH_ALIGN
- && irel->r_vaddr - sec->vma > addr
- && count < (1 << irel->r_offset))
- {
- irelalign = irel;
- toaddr = irel->r_vaddr - sec->vma;
- break;
- }
- }
-
- /* Actually delete the bytes. */
- memmove (contents + addr, contents + addr + count, toaddr - addr - count);
- if (irelalign == NULL)
- sec->_cooked_size -= count;
- else
- memset (contents + toaddr - count, 0, count);
-
- /* Adjust all the relocs. */
- for (irel = coff_section_data (abfd, sec)->relocs; irel < irelend; irel++)
- {
- bfd_vma nraddr, start, stop;
- int insn = 0;
- struct internal_syment sym;
- int off, adjust, oinsn;
- bfd_signed_vma voff;
- boolean overflow;
-
- /* Get the new reloc address. */
- nraddr = irel->r_vaddr - sec->vma;
- if ((irel->r_vaddr - sec->vma > addr
- && irel->r_vaddr - sec->vma < toaddr)
- || (irel->r_type == R_SH_ALIGN
- && irel->r_vaddr - sec->vma == toaddr))
- nraddr -= count;
-
- /* See if this reloc was for the bytes we have deleted, in which
- case we no longer care about it. */
- if (irel->r_vaddr - sec->vma >= addr
- && irel->r_vaddr - sec->vma < addr + count
- && irel->r_type != R_SH_ALIGN)
- irel->r_type = R_SH_UNUSED;
-
- /* If this is a PC relative reloc, see if the range it covers
- includes the bytes we have deleted. */
- switch (irel->r_type)
- {
- default:
- break;
-
- case R_SH_PCDISP8BY2:
- case R_SH_PCDISP:
- case R_SH_PCRELIMM8BY2:
- case R_SH_PCRELIMM8BY4:
- start = irel->r_vaddr - sec->vma;
- insn = bfd_get_16 (abfd, contents + nraddr);
- break;
- }
-
- switch (irel->r_type)
- {
- default:
- start = stop = addr;
- break;
-
- case R_SH_IMM32:
- /* If this reloc is against a symbol defined in this
- section, and the symbol will not be adjusted below, we
- must check the addend to see it will put the value in
- range to be adjusted, and hence must be changed. */
- bfd_coff_swap_sym_in (abfd,
- ((bfd_byte *) obj_coff_external_syms (abfd)
- + (irel->r_symndx
- * bfd_coff_symesz (abfd))),
- &sym);
- if (sym.n_sclass != C_EXT
- && sym.n_scnum == sec->target_index
- && ((bfd_vma) sym.n_value <= addr
- || (bfd_vma) sym.n_value >= toaddr))
- {
- bfd_vma val;
-
- val = bfd_get_32 (abfd, contents + nraddr);
- val += sym.n_value;
- if (val >= addr && val < toaddr)
- bfd_put_32 (abfd, val - count, contents + nraddr);
- }
- start = stop = addr;
- break;
-
- case R_SH_PCDISP8BY2:
- off = insn & 0xff;
- if (off & 0x80)
- off -= 0x100;
- stop = (bfd_vma) ((bfd_signed_vma) start + 4 + off * 2);
- break;
-
- case R_SH_PCDISP:
- bfd_coff_swap_sym_in (abfd,
- ((bfd_byte *) obj_coff_external_syms (abfd)
- + (irel->r_symndx
- * bfd_coff_symesz (abfd))),
- &sym);
- if (sym.n_sclass == C_EXT)
- start = stop = addr;
- else
- {
- off = insn & 0xfff;
- if (off & 0x800)
- off -= 0x1000;
- stop = (bfd_vma) ((bfd_signed_vma) start + 4 + off * 2);
- }
- break;
-
- case R_SH_PCRELIMM8BY2:
- off = insn & 0xff;
- stop = start + 4 + off * 2;
- break;
-
- case R_SH_PCRELIMM8BY4:
- off = insn & 0xff;
- stop = (start &~ (bfd_vma) 3) + 4 + off * 4;
- break;
-
- case R_SH_SWITCH16:
- case R_SH_SWITCH32:
- /* These relocs types represent
- .word L2-L1
- The r_offset field holds the difference between the reloc
- address and L1. That is the start of the reloc, and
- adding in the contents gives us the top. We must adjust
- both the r_offset field and the section contents. */
-
- start = irel->r_vaddr - sec->vma;
- stop = (bfd_vma) ((bfd_signed_vma) start - (long) irel->r_offset);
-
- if (start > addr
- && start < toaddr
- && (stop <= addr || stop >= toaddr))
- irel->r_offset += count;
- else if (stop > addr
- && stop < toaddr
- && (start <= addr || start >= toaddr))
- irel->r_offset -= count;
-
- start = stop;
-
- if (irel->r_type == R_SH_SWITCH16)
- voff = bfd_get_signed_16 (abfd, contents + nraddr);
- else
- voff = bfd_get_signed_32 (abfd, contents + nraddr);
- stop = (bfd_vma) ((bfd_signed_vma) start + voff);
-
- break;
-
- case R_SH_USES:
- start = irel->r_vaddr - sec->vma;
- stop = (bfd_vma) ((bfd_signed_vma) start
- + (long) irel->r_offset
- + 4);
- break;
- }
-
- if (start > addr
- && start < toaddr
- && (stop <= addr || stop >= toaddr))
- adjust = count;
- else if (stop > addr
- && stop < toaddr
- && (start <= addr || start >= toaddr))
- adjust = - count;
- else
- adjust = 0;
-
- if (adjust != 0)
- {
- oinsn = insn;
- overflow = false;
- switch (irel->r_type)
- {
- default:
- abort ();
- break;
-
- case R_SH_PCDISP8BY2:
- case R_SH_PCRELIMM8BY2:
- insn += adjust / 2;
- if ((oinsn & 0xff00) != (insn & 0xff00))
- overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
- break;
-
- case R_SH_PCDISP:
- insn += adjust / 2;
- if ((oinsn & 0xf000) != (insn & 0xf000))
- overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
- break;
-
- case R_SH_PCRELIMM8BY4:
- BFD_ASSERT (adjust == count || count >= 4);
- if (count >= 4)
- insn += adjust / 4;
- else
- {
- if ((irel->r_vaddr & 3) == 0)
- ++insn;
- }
- if ((oinsn & 0xff00) != (insn & 0xff00))
- overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
- break;
-
- case R_SH_SWITCH16:
- voff += adjust;
- if (voff < - 0x8000 || voff >= 0x8000)
- overflow = true;
- bfd_put_signed_16 (abfd, voff, contents + nraddr);
- break;
-
- case R_SH_SWITCH32:
- voff += adjust;
- bfd_put_signed_32 (abfd, voff, contents + nraddr);
- break;
-
- case R_SH_USES:
- irel->r_offset += adjust;
- break;
- }
-
- if (overflow)
- {
- ((*_bfd_error_handler)
- ("%s: 0x%lx: fatal: reloc overflow while relaxing",
- bfd_get_filename (abfd), (unsigned long) irel->r_vaddr));
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- }
-
- irel->r_vaddr = nraddr + sec->vma;
- }
-
- /* Look through all the other sections. If there contain any IMM32
- relocs against internal symbols which we are not going to adjust
- below, we may need to adjust the addends. */
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- struct internal_reloc *internal_relocs;
- struct internal_reloc *irelscan, *irelscanend;
- bfd_byte *ocontents;
-
- if (o == sec
- || (o->flags & SEC_RELOC) == 0
- || o->reloc_count == 0)
- continue;
-
- /* We always cache the relocs. Perhaps, if info->keep_memory is
- false, we should free them, if we are permitted to, when we
- leave sh_coff_relax_section. */
- internal_relocs = (_bfd_coff_read_internal_relocs
- (abfd, o, true, (bfd_byte *) NULL, false,
- (struct internal_reloc *) NULL));
- if (internal_relocs == NULL)
- return false;
-
- ocontents = NULL;
- irelscanend = internal_relocs + o->reloc_count;
- for (irelscan = internal_relocs; irelscan < irelscanend; irelscan++)
- {
- struct internal_syment sym;
-
- if (irelscan->r_type != R_SH_IMM32)
- continue;
-
- bfd_coff_swap_sym_in (abfd,
- ((bfd_byte *) obj_coff_external_syms (abfd)
- + (irelscan->r_symndx
- * bfd_coff_symesz (abfd))),
- &sym);
- if (sym.n_sclass != C_EXT
- && sym.n_scnum == sec->target_index
- && ((bfd_vma) sym.n_value <= addr
- || (bfd_vma) sym.n_value >= toaddr))
- {
- bfd_vma val;
-
- if (ocontents == NULL)
- {
- if (coff_section_data (abfd, o)->contents != NULL)
- ocontents = coff_section_data (abfd, o)->contents;
- else
- {
- /* We always cache the section contents.
- Perhaps, if info->keep_memory is false, we
- should free them, if we are permitted to,
- when we leave sh_coff_relax_section. */
- ocontents = (bfd_byte *) bfd_malloc (o->_raw_size);
- if (ocontents == NULL)
- return false;
- if (! bfd_get_section_contents (abfd, o, ocontents,
- (file_ptr) 0,
- o->_raw_size))
- return false;
- coff_section_data (abfd, o)->contents = ocontents;
- }
- }
-
- val = bfd_get_32 (abfd, ocontents + irelscan->r_vaddr - o->vma);
- val += sym.n_value;
- if (val >= addr && val < toaddr)
- bfd_put_32 (abfd, val - count,
- ocontents + irelscan->r_vaddr - o->vma);
-
- coff_section_data (abfd, o)->keep_contents = true;
- }
- }
- }
-
- /* Adjusting the internal symbols will not work if something has
- already retrieved the generic symbols. It would be possible to
- make this work by adjusting the generic symbols at the same time.
- However, this case should not arise in normal usage. */
- if (obj_symbols (abfd) != NULL
- || obj_raw_syments (abfd) != NULL)
- {
- ((*_bfd_error_handler)
- ("%s: fatal: generic symbols retrieved before relaxing",
- bfd_get_filename (abfd)));
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- /* Adjust all the symbols. */
- sym_hash = obj_coff_sym_hashes (abfd);
- symesz = bfd_coff_symesz (abfd);
- esym = (bfd_byte *) obj_coff_external_syms (abfd);
- esymend = esym + obj_raw_syment_count (abfd) * symesz;
- while (esym < esymend)
- {
- struct internal_syment isym;
-
- bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &isym);
-
- if (isym.n_scnum == sec->target_index
- && (bfd_vma) isym.n_value > addr
- && (bfd_vma) isym.n_value < toaddr)
- {
- isym.n_value -= count;
-
- bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
-
- if (*sym_hash != NULL)
- {
- BFD_ASSERT ((*sym_hash)->root.type == bfd_link_hash_defined
- || (*sym_hash)->root.type == bfd_link_hash_defweak);
- BFD_ASSERT ((*sym_hash)->root.u.def.value >= addr
- && (*sym_hash)->root.u.def.value < toaddr);
- (*sym_hash)->root.u.def.value -= count;
- }
- }
-
- esym += (isym.n_numaux + 1) * symesz;
- sym_hash += isym.n_numaux + 1;
- }
-
- /* See if we can move the ALIGN reloc forward. We have adjusted
- r_vaddr for it already. */
- if (irelalign != NULL)
- {
- bfd_vma alignaddr;
-
- alignaddr = BFD_ALIGN (irelalign->r_vaddr - sec->vma,
- 1 << irelalign->r_offset);
- if (alignaddr != toaddr)
- {
- /* Tail recursion. */
- return sh_relax_delete_bytes (abfd, sec,
- irelalign->r_vaddr - sec->vma,
- 1 << irelalign->r_offset);
- }
- }
-
- return true;
-}
-
-/* This is a modification of _bfd_coff_generic_relocate_section, which
- will handle SH relaxing. */
-
-static boolean
-sh_relocate_section (output_bfd, info, input_bfd, input_section, contents,
- relocs, syms, sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- struct internal_reloc *relocs;
- struct internal_syment *syms;
- asection **sections;
-{
- struct internal_reloc *rel;
- struct internal_reloc *relend;
-
- rel = relocs;
- relend = rel + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- long symndx;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma addend;
- bfd_vma val;
- reloc_howto_type *howto;
- bfd_reloc_status_type rstat;
-
- /* Almost all relocs have to do with relaxing. If any work must
- be done for them, it has been done in sh_relax_section. */
- if (rel->r_type != R_SH_IMM32
- && rel->r_type != R_SH_PCDISP)
- continue;
-
- symndx = rel->r_symndx;
-
- if (symndx == -1)
- {
- h = NULL;
- sym = NULL;
- }
- else
- {
- h = obj_coff_sym_hashes (input_bfd)[symndx];
- sym = syms + symndx;
- }
-
- if (sym != NULL && sym->n_scnum != 0)
- addend = - sym->n_value;
- else
- addend = 0;
-
- if (rel->r_type == R_SH_PCDISP)
- addend -= 4;
-
- if (rel->r_type >= SH_COFF_HOWTO_COUNT)
- howto = NULL;
- else
- howto = &sh_coff_howtos[rel->r_type];
-
- if (howto == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- val = 0;
-
- if (h == NULL)
- {
- asection *sec;
-
- /* There is nothing to do for an internal PCDISP reloc. */
- if (rel->r_type == R_SH_PCDISP)
- continue;
-
- if (symndx == -1)
- {
- sec = bfd_abs_section_ptr;
- val = 0;
- }
- else
- {
- sec = sections[symndx];
- val = (sec->output_section->vma
- + sec->output_offset
- + sym->n_value
- - sec->vma);
- }
- }
- else
- {
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *sec;
-
- sec = h->root.u.def.section;
- val = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (! info->relocateable)
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
-
- rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents,
- rel->r_vaddr - input_section->vma,
- val, addend);
-
- switch (rstat)
- {
- default:
- abort ();
- case bfd_reloc_ok:
- break;
- case bfd_reloc_overflow:
- {
- const char *name;
- char buf[SYMNMLEN + 1];
-
- if (symndx == -1)
- name = "*ABS*";
- else if (h != NULL)
- name = h->root.root.string;
- else if (sym->_n._n_n._n_zeroes == 0
- && sym->_n._n_n._n_offset != 0)
- name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
- else
- {
- strncpy (buf, sym->_n._n_name, SYMNMLEN);
- buf[SYMNMLEN] = '\0';
- name = buf;
- }
-
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0, input_bfd,
- input_section, rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
- }
-
- return true;
-}
-
-/* This is a version of bfd_generic_get_relocated_section_contents
- which uses sh_relocate_section. */
-
-static bfd_byte *
-sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order,
- data, relocateable, symbols)
- bfd *output_bfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- bfd_byte *data;
- boolean relocateable;
- asymbol **symbols;
-{
- asection *input_section = link_order->u.indirect.section;
- bfd *input_bfd = input_section->owner;
- asection **sections = NULL;
- struct internal_reloc *internal_relocs = NULL;
- struct internal_syment *internal_syms = NULL;
-
- /* We only need to handle the case of relaxing, or of having a
- particular set of section contents, specially. */
- if (relocateable
- || coff_section_data (input_bfd, input_section) == NULL
- || coff_section_data (input_bfd, input_section)->contents == NULL)
- return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
- link_order, data,
- relocateable,
- symbols);
-
- memcpy (data, coff_section_data (input_bfd, input_section)->contents,
- input_section->_raw_size);
-
- if ((input_section->flags & SEC_RELOC) != 0
- && input_section->reloc_count > 0)
- {
- bfd_size_type symesz = bfd_coff_symesz (input_bfd);
- bfd_byte *esym, *esymend;
- struct internal_syment *isymp;
- asection **secpp;
-
- if (! _bfd_coff_get_external_symbols (input_bfd))
- goto error_return;
-
- internal_relocs = (_bfd_coff_read_internal_relocs
- (input_bfd, input_section, false, (bfd_byte *) NULL,
- false, (struct internal_reloc *) NULL));
- if (internal_relocs == NULL)
- goto error_return;
-
- internal_syms = ((struct internal_syment *)
- bfd_malloc (obj_raw_syment_count (input_bfd)
- * sizeof (struct internal_syment)));
- if (internal_syms == NULL)
- goto error_return;
-
- sections = (asection **) bfd_malloc (obj_raw_syment_count (input_bfd)
- * sizeof (asection *));
- if (sections == NULL)
- goto error_return;
-
- isymp = internal_syms;
- secpp = sections;
- esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
- esymend = esym + obj_raw_syment_count (input_bfd) * symesz;
- while (esym < esymend)
- {
- bfd_coff_swap_sym_in (input_bfd, (PTR) esym, (PTR) isymp);
-
- if (isymp->n_scnum != 0)
- *secpp = coff_section_from_bfd_index (input_bfd, isymp->n_scnum);
- else
- {
- if (isymp->n_value == 0)
- *secpp = bfd_und_section_ptr;
- else
- *secpp = bfd_com_section_ptr;
- }
-
- esym += (isymp->n_numaux + 1) * symesz;
- secpp += isymp->n_numaux + 1;
- isymp += isymp->n_numaux + 1;
- }
-
- if (! sh_relocate_section (output_bfd, link_info, input_bfd,
- input_section, data, internal_relocs,
- internal_syms, sections))
- goto error_return;
-
- free (sections);
- sections = NULL;
- free (internal_syms);
- internal_syms = NULL;
- free (internal_relocs);
- internal_relocs = NULL;
- }
-
- return data;
-
- error_return:
- if (internal_relocs != NULL)
- free (internal_relocs);
- if (internal_syms != NULL)
- free (internal_syms);
- if (sections != NULL)
- free (sections);
- return NULL;
-}
-
-/* The target vectors. */
-
-const bfd_target shcoff_vec =
-{
- "coff-sh", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC),
- '_', /* leading symbol underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
-
-const bfd_target shlcoff_vec =
-{
- "coff-shl", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little endian too*/
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC),
- '_', /* leading symbol underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* 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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-sparc.c b/contrib/gdb/bfd/coff-sparc.c
deleted file mode 100644
index b9bc595..0000000
--- a/contrib/gdb/bfd/coff-sparc.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/* BFD back-end for Sparc COFF files.
- Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "coff/sparc.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-
-#define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC)
-
-/* The page size is a guess based on ELF. */
-#define COFF_PAGE_SIZE 0x10000
-
-enum reloc_type
- {
- R_SPARC_NONE = 0,
- R_SPARC_8, R_SPARC_16, R_SPARC_32,
- R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
- R_SPARC_WDISP30, R_SPARC_WDISP22,
- R_SPARC_HI22, R_SPARC_22,
- R_SPARC_13, R_SPARC_LO10,
- R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
- R_SPARC_PC10, R_SPARC_PC22,
- R_SPARC_WPLT30,
- R_SPARC_COPY,
- R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
- R_SPARC_RELATIVE,
- R_SPARC_UA32,
- R_SPARC_max
- };
-
-#if 0
-static CONST char *CONST reloc_type_names[] =
-{
- "R_SPARC_NONE",
- "R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
- "R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
- "R_SPARC_WDISP30", "R_SPARC_WDISP22",
- "R_SPARC_HI22", "R_SPARC_22",
- "R_SPARC_13", "R_SPARC_LO10",
- "R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
- "R_SPARC_PC10", "R_SPARC_PC22",
- "R_SPARC_WPLT30",
- "R_SPARC_COPY",
- "R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
- "R_SPARC_RELATIVE",
- "R_SPARC_UA32",
-};
-#endif
-
-/* This is stolen pretty directly from elf.c. */
-static bfd_reloc_status_type
-bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-
-static bfd_reloc_status_type
-bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && reloc_entry->addend == 0)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- return bfd_reloc_continue;
-}
-
-static reloc_howto_type coff_sparc_howto_table[] =
-{
- HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_NONE", false,0,0x00000000,true),
- HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_8", false,0,0x000000ff,true),
- HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_16", false,0,0x0000ffff,true),
- HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_32", false,0,0xffffffff,true),
- HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP8", false,0,0x000000ff,true),
- HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP16", false,0,0x0000ffff,true),
- HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_DISP32", false,0,0x00ffffff,true),
- HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP30", false,0,0x3fffffff,true),
- HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_coff_generic_reloc,"R_SPARC_WDISP22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_HI22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_13", false,0,0x00001fff,true),
- HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_LO10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT13", false,0,0x00001fff,true),
- HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_GOT22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_PC10, 0,2,10,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_PC22, 0,2,22,false,0,complain_overflow_bitfield,bfd_coff_generic_reloc,"R_SPARC_PC22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_WPLT30", false,0,0x00000000,true),
- HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_COPY", false,0,0x00000000,true),
- HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,true),
- HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_JMP_SLOT",false,0,0x00000000,true),
- HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_RELATIVE",false,0,0x00000000,true),
- HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_coff_generic_reloc,"R_SPARC_UA32", false,0,0x00000000,true),
-};
-
-struct coff_reloc_map {
- unsigned char bfd_reloc_val;
- unsigned char coff_reloc_val;
-};
-
-static CONST struct coff_reloc_map sparc_reloc_map[] =
-{
- { BFD_RELOC_NONE, R_SPARC_NONE, },
- { BFD_RELOC_16, R_SPARC_16, },
- { BFD_RELOC_8, R_SPARC_8 },
- { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
- { BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
- { BFD_RELOC_32, R_SPARC_32 },
- { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
- { BFD_RELOC_HI22, R_SPARC_HI22 },
- { BFD_RELOC_LO10, R_SPARC_LO10, },
- { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
- { BFD_RELOC_SPARC22, R_SPARC_22 },
- { BFD_RELOC_SPARC13, R_SPARC_13 },
- { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
- { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
- { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
- { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
- { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
- { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
- { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
- { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
- { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
- { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
- { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
- /* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
-};
-
-static reloc_howto_type *
-coff_sparc_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- unsigned int i;
- for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
- {
- if (sparc_reloc_map[i].bfd_reloc_val == code)
- return &coff_sparc_howto_table[(int) sparc_reloc_map[i].coff_reloc_val];
- }
- return 0;
-}
-#define coff_bfd_reloc_type_lookup coff_sparc_reloc_type_lookup
-
-static void
-rtype2howto (cache_ptr, dst)
- arelent *cache_ptr;
- struct internal_reloc *dst;
-{
- BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max);
- cache_ptr->howto = &coff_sparc_howto_table[dst->r_type];
-}
-
-#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
-
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
-/* This is just like the standard one, except that we don't set up an
- addend for relocs against global symbols (otherwise linking objects
- created by -r fails), and we add in the reloc offset at the end. */
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
- { \
- coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
- if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
- coffsym = (obj_symbols (abfd) \
- + (cache_ptr->sym_ptr_ptr - symbols)); \
- else if (ptr) \
- coffsym = coff_symbol_from (abfd, ptr); \
- if (coffsym != (coff_symbol_type *) NULL \
- && coffsym->native->u.syment.n_scnum == 0) \
- cache_ptr->addend = 0; \
- else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
- && ptr->section != (asection *) NULL \
- && (ptr->flags & BSF_GLOBAL) == 0) \
- cache_ptr->addend = - (ptr->section->vma + ptr->value); \
- else \
- cache_ptr->addend = 0; \
- cache_ptr->addend += reloc.r_offset; \
- }
-
-/* Clear the r_spare field in relocs. */
-#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
- do { \
- dst->r_spare[0] = 0; \
- dst->r_spare[1] = 0; \
- } while (0)
-
-#define __A_MAGIC_SET__
-
-/* Enable Sparc-specific hacks in coffcode.h. */
-
-#define COFF_SPARC
-
-#include "coffcode.h"
-
-const bfd_target
-#ifdef TARGET_SYM
- TARGET_SYM =
-#else
- sparccoff_vec =
-#endif
-{
-#ifdef TARGET_NAME
- TARGET_NAME,
-#else
- "coff-sparc", /* name */
-#endif
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
-
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
-/* Note that we allow an object file to be treated as a core file as well. */
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_generic_archive_p, coff_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-u68k.c b/contrib/gdb/bfd/coff-u68k.c
deleted file mode 100644
index 97ea73f..0000000
--- a/contrib/gdb/bfd/coff-u68k.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* BFD back-end for Motorola 68000 COFF binaries having underscore with name.
- Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_SYM m68kcoffun_vec
-#define TARGET_NAME "coff-m68k-un"
-
-#define NAMES_HAVE_UNDERSCORE
-
-/* define this to not have multiple copy of m68k_rtype2howto
- in the executable file */
-#define ONLY_DECLARE_RELOCS
-
-/* This magic number indicates that the names have underscores.
- Other 68k magic numbers indicate that the names do not have
- underscores. */
-#define BADMAG(x) ((x).f_magic != MC68KBCSMAGIC)
-
-#include "coff-m68k.c"
diff --git a/contrib/gdb/bfd/coff-w65.c b/contrib/gdb/bfd/coff-w65.c
deleted file mode 100644
index a02243f..0000000
--- a/contrib/gdb/bfd/coff-w65.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/* BFD back-end for WDC 65816 COFF binaries.
- Copyright 1995 Free Software Foundation, Inc.
- Written by Steve Chamberlain, <sac@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "obstack.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "coff/w65.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
-static reloc_howto_type howto_table[] =
-{
- HOWTO (R_W65_ABS8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "abs8", true, 0x000000ff, 0x000000ff, false),
- HOWTO (R_W65_ABS16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_W65_ABS24, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs24", true, 0x00ffffff, 0x00ffffff, false),
- HOWTO (R_W65_ABS8S8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, ">abs8", true, 0x000000ff, 0x000000ff, false),
- HOWTO (R_W65_ABS8S16, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "^abs8", true, 0x000000ff, 0x000000ff, false),
- HOWTO (R_W65_ABS16S8, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, ">abs16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_W65_ABS16S16,1, 0, 16, false, 0, complain_overflow_bitfield, 0, "^abs16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_W65_PCR8, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "pcrel8", true, 0x000000ff, 0x000000ff, true),
- HOWTO (R_W65_PCR16, 1, 0, 16, false, 0, complain_overflow_bitfield, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, true),
- HOWTO (R_W65_DP, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "dp", true, 0x000000ff, 0x000000ff, false),
-
-};
-
-
-/* Turn a howto into a reloc number */
-
-#define SELECT_RELOC(x,howto) \
- { x.r_type = select_reloc(howto); }
-
-#define BADMAG(x) (W65BADMAG(x))
-#define W65 1 /* Customize coffcode.h */
-#define __A_MAGIC_SET__
-
-
-/* Code to swap in the reloc */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
-#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
- dst->r_stuff[0] = 'S'; \
- dst->r_stuff[1] = 'C';
-
-
-static int
-select_reloc (howto)
- reloc_howto_type *howto;
-{
- return howto->type ;
-}
-
-/* Code to turn a r_type into a howto ptr, uses the above howto table
- */
-
-static void
-rtype2howto (internal, dst)
- arelent *internal;
- struct internal_reloc *dst;
-{
- internal->howto = howto_table + dst->r_type - 1;
-}
-
-#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
-
-
-/* Perform any necessaru magic to the addend in a reloc entry */
-
-
-#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
- cache_ptr->addend = ext_reloc.r_offset;
-
-
-#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
- reloc_processing(relent, reloc, symbols, abfd, section)
-
-static void
-reloc_processing (relent, reloc, symbols, abfd, section)
- arelent * relent;
- struct internal_reloc *reloc;
- asymbol ** symbols;
- bfd * abfd;
- asection * section;
-{
- relent->address = reloc->r_vaddr;
- rtype2howto (relent, reloc);
-
- if (((int) reloc->r_symndx) > 0)
- {
- relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
- }
- else
- {
- relent->sym_ptr_ptr = (asymbol **)&(bfd_abs_symbol);
- }
-
-
-
- relent->addend = reloc->r_offset;
-
- relent->address -= section->vma;
- /* relent->section = 0;*/
-}
-
-
-static int
-h8300_reloc16_estimate(abfd, input_section, reloc, shrink, link_info)
- bfd *abfd;
- asection *input_section;
- arelent *reloc;
- unsigned int shrink;
- struct bfd_link_info *link_info;
-{
- bfd_vma value;
- bfd_vma dot;
- bfd_vma gap;
-
- /* The address of the thing to be relocated will have moved back by
- the size of the shrink - but we don't change reloc->address here,
- since we need it to know where the relocation lives in the source
- uncooked section */
-
- /* reloc->address -= shrink; conceptual */
-
- bfd_vma address = reloc->address - shrink;
-
-
- switch (reloc->howto->type)
- {
- case R_MOVB2:
- case R_JMP2:
- shrink+=2;
- break;
-
- /* Thing is a move one byte */
- case R_MOVB1:
- value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
-
- if (value >= 0xff00)
- {
-
- /* Change the reloc type from 16bit, possible 8 to 8bit
- possible 16 */
- reloc->howto = reloc->howto + 1;
- /* The place to relc moves back by one */
- /* This will be two bytes smaller in the long run */
- shrink +=2 ;
- bfd_perform_slip(abfd, 2, input_section, address);
- }
-
- break;
- /* This is the 24 bit branch which could become an 8 bitter,
- the relocation points to the first byte of the insn, not the
- actual data */
-
- case R_JMPL1:
- value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
-
- dot = input_section->output_section->vma +
- input_section->output_offset + address;
-
- /* See if the address we're looking at within 127 bytes of where
- we are, if so then we can use a small branch rather than the
- jump we were going to */
-
- gap = value - dot ;
-
- if (-120 < (long)gap && (long)gap < 120 )
- {
-
- /* Change the reloc type from 24bit, possible 8 to 8bit
- possible 32 */
- reloc->howto = reloc->howto + 1;
- /* This will be two bytes smaller in the long run */
- shrink +=2 ;
- bfd_perform_slip(abfd, 2, input_section, address);
- }
- break;
-
- case R_JMP1:
-
- value = bfd_coff_reloc16_get_value(reloc, link_info, input_section);
-
- dot = input_section->output_section->vma +
- input_section->output_offset + address;
-
- /* See if the address we're looking at within 127 bytes of where
- we are, if so then we can use a small branch rather than the
- jump we were going to */
-
- gap = value - (dot - shrink);
-
-
- if (-120 < (long)gap && (long)gap < 120 )
- {
-
- /* Change the reloc type from 16bit, possible 8 to 8bit
- possible 16 */
- reloc->howto = reloc->howto + 1;
- /* The place to relc moves back by one */
-
- /* This will be two bytes smaller in the long run */
- shrink +=2 ;
- bfd_perform_slip(abfd, 2, input_section, address);
- }
- break;
- }
-
-
- return shrink;
-}
-
-
-/* First phase of a relaxing link */
-
-/* Reloc types
- large small
- R_MOVB1 R_MOVB2 mov.b with 16bit or 8 bit address
- R_JMP1 R_JMP2 jmp or pcrel branch
- R_JMPL1 R_JMPL_B8 24jmp or pcrel branch
- R_MOVLB1 R_MOVLB2 24 or 8 bit reloc for mov.b
-
-*/
-
-static void
-h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
- dst_ptr)
- bfd *abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- arelent *reloc;
- bfd_byte *data;
- unsigned int *src_ptr;
- unsigned int *dst_ptr;
-{
- unsigned int src_address = *src_ptr;
- unsigned int dst_address = *dst_ptr;
- asection *input_section = link_order->u.indirect.section;
-
- switch (reloc->howto->type)
- {
- case R_W65_ABS8:
- case R_W65_DP:
- {
- unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- bfd_put_8 (abfd, gap, data + dst_address);
- dst_address += 1;
- src_address += 1;
- }
- break;
-
- case R_W65_ABS8S8:
- {
- unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- gap >>= 8;
- bfd_put_8 (abfd, gap, data + dst_address);
- dst_address += 1;
- src_address += 1;
- }
- break;
-
- case R_W65_ABS8S16:
- {
- unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- gap >>=16;
- bfd_put_8 (abfd, gap, data + dst_address);
- dst_address += 1;
- src_address += 1;
- }
- break;
-
- case R_W65_ABS16:
- {
- unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
-
- bfd_put_16 (abfd, gap, data + dst_address);
- dst_address += 2;
- src_address += 2;
- }
- break;
- case R_W65_ABS16S8:
- {
- unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- gap >>= 8;
- bfd_put_16 (abfd, gap, data + dst_address);
- dst_address += 2;
- src_address += 2;
- }
- break;
- case R_W65_ABS16S16:
- {
- unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- gap >>= 16;
- bfd_put_16 (abfd, gap, data + dst_address);
- dst_address += 2;
- src_address += 2;
- }
- break;
-
- case R_W65_ABS24:
- {
- unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- bfd_put_16 (abfd, gap, data + dst_address);
- bfd_put_8 (abfd, gap>>16, data+dst_address+2);
- dst_address += 3;
- src_address += 3;
- }
- break;
-
- case R_W65_PCR8:
- {
- int gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- bfd_vma dot = link_order->offset
- + dst_address
- + link_order->u.indirect.section->output_section->vma;
-
- gap -= dot + 1;
- if (gap < -128 || gap > 127) {
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
- reloc->howto->name, reloc->addend, input_section->owner,
- input_section, reloc->address)))
- abort();
- }
- bfd_put_8 (abfd, gap, data + dst_address);
- dst_address += 1;
- src_address += 1;
- }
- break;
-
- case R_W65_PCR16:
- {
- bfd_vma gap = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- bfd_vma dot = link_order->offset
- + dst_address
- + link_order->u.indirect.section->output_section->vma;
-
-
- /* This wraps within the page, so ignore the relativeness, look at the
- high part */
- if ((gap & 0xf0000) != (dot & 0xf0000)) {
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
- reloc->howto->name, reloc->addend, input_section->owner,
- input_section, reloc->address)))
- abort();
- }
-
- gap -= dot + 2;
- bfd_put_16 (abfd, gap, data + dst_address);
- dst_address += 2;
- src_address += 2;
- }
- break;
- default:
- printf("ignoring reloc %s\n", reloc->howto->name);
- break;
-
- }
- *src_ptr = src_address;
- *dst_ptr = dst_address;
-
-}
-
-#define coff_reloc16_extra_cases h8300_reloc16_extra_cases
-#define coff_reloc16_estimate h8300_reloc16_estimate
-
-#include "coffcode.h"
-
-
-#undef coff_bfd_get_relocated_section_contents
-#undef coff_bfd_relax_section
-#define coff_bfd_get_relocated_section_contents \
- bfd_coff_reloc16_get_relocated_section_contents
-#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
-
-
-
-bfd_target w65_vec =
-{
- "coff-w65", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* header byte order is little */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading char */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* 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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-we32k.c b/contrib/gdb/bfd/coff-we32k.c
deleted file mode 100644
index 36f1fa1..0000000
--- a/contrib/gdb/bfd/coff-we32k.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* BFD back-end for we32k COFF files.
- Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
- Contributed by Brendan Kehoe (brendan@cs.widener.edu).
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "coff/we32k.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-
-static reloc_howto_type howto_table[] =
-{
- {0},
- {1},
- {2},
- {3},
- {4},
- {5},
- HOWTO(R_DIR32, 0, 2, 32, false, 0,complain_overflow_bitfield, 0, "dir32", true, 0xffffffff,0xffffffff, false),
- {7},
- {010},
- {011},
- {012},
- {013},
- {014},
- {015},
- {016},
- HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
- HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
- HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
- HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
- HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
- HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
-};
-
-/* Turn a howto into a reloc nunmber */
-
-#define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
-#define BADMAG(x) WE32KBADMAG(x)
-#define WE32K 1
-
-#define RTYPE2HOWTO(cache_ptr, dst) \
- (cache_ptr)->howto = howto_table + (dst)->r_type;
-
-#include "coffcode.h"
-
-#define coff_write_armap bsd_write_armap
-
-const bfd_target we32kcoff_vec =
-{
- "coff-we32k", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
-
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/coff-z8k.c b/contrib/gdb/bfd/coff-z8k.c
deleted file mode 100644
index 5609d35..0000000
--- a/contrib/gdb/bfd/coff-z8k.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/* BFD back-end for Zilog Z800n COFF binaries.
- Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
- Written by Steve Chamberlain, <sac@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "obstack.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "coff/z8k.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
-
-static reloc_howto_type r_imm32 =
-HOWTO (R_IMM32, 0, 1, 32, false, 0,
- complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,
- 0xffffffff, false);
-
-static reloc_howto_type r_imm4l =
-HOWTO (R_IMM4L, 0, 1, 4, false, 0,
- complain_overflow_bitfield, 0, "r_imm4l", true, 0xf, 0xf, false);
-
-static reloc_howto_type r_da =
-HOWTO (R_IMM16, 0, 1, 16, false, 0,
- complain_overflow_bitfield, 0, "r_da", true, 0x0000ffff, 0x0000ffff,
- false);
-
-static reloc_howto_type r_imm8 =
-HOWTO (R_IMM8, 0, 1, 8, false, 0,
- complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff,
- false);
-
-static reloc_howto_type r_jr =
-HOWTO (R_JR, 0, 1, 8, true, 0, complain_overflow_signed, 0,
- "r_jr", true, 0, 0, true);
-
-/* Turn a howto into a reloc number */
-
-static int
-coff_z8k_select_reloc (howto)
- reloc_howto_type *howto;
-{
- return howto->type;
-}
-
-#define SELECT_RELOC(x,howto) x.r_type = coff_z8k_select_reloc(howto)
-
-
-#define BADMAG(x) Z8KBADMAG(x)
-#define Z8K 1 /* Customize coffcode.h */
-#define __A_MAGIC_SET__
-
-
-
-/* Code to swap in the reloc */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
-#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
- dst->r_stuff[0] = 'S'; \
- dst->r_stuff[1] = 'C';
-
-/* Code to turn a r_type into a howto ptr, uses the above howto table
- */
-
-static void
-rtype2howto (internal, dst)
- arelent * internal;
- struct internal_reloc *dst;
-{
- switch (dst->r_type)
- {
- default:
- abort ();
- break;
- case R_IMM8:
- internal->howto = &r_imm8;
- break;
- case R_IMM16:
- internal->howto = &r_da;
- break;
- case R_JR:
- internal->howto = &r_jr;
- break;
- case R_IMM32:
- internal->howto = &r_imm32;
- break;
- case R_IMM4L:
- internal->howto = &r_imm4l;
- break;
- }
-}
-
-#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
-
-
-/* Perform any necessaru magic to the addend in a reloc entry */
-
-
-#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
- cache_ptr->addend = ext_reloc.r_offset;
-
-
-#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
- reloc_processing(relent, reloc, symbols, abfd, section)
-
-static void
-reloc_processing (relent, reloc, symbols, abfd, section)
- arelent * relent;
- struct internal_reloc *reloc;
- asymbol ** symbols;
- bfd * abfd;
- asection * section;
-{
- relent->address = reloc->r_vaddr;
- rtype2howto (relent, reloc);
-
- if (reloc->r_symndx > 0)
- {
- relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
- }
- else
- {
- relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- }
-
-
- relent->addend = reloc->r_offset;
- relent->address -= section->vma;
-}
-
-static void
-extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
- bfd *in_abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- arelent *reloc;
- bfd_byte *data;
- unsigned int *src_ptr;
- unsigned int *dst_ptr;
-{
- asection *input_section = link_order->u.indirect.section;
-
- switch (reloc->howto->type)
- {
- case R_IMM8:
- bfd_put_8 (in_abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- data + *dst_ptr);
- (*dst_ptr) += 1;
- (*src_ptr) += 1;
- break;
-
- case R_IMM32:
- bfd_put_32 (in_abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- data + *dst_ptr);
- (*dst_ptr) += 4;
- (*src_ptr) += 4;
- break;
-
- case R_IMM4L:
- bfd_put_8 (in_abfd,
- ((bfd_get_8 (in_abfd, data + *dst_ptr) & 0xf0)
- | (0x0f
- & bfd_coff_reloc16_get_value (reloc, link_info,
- input_section))),
- data + *dst_ptr);
- (*dst_ptr) += 1;
- (*src_ptr) += 1;
- break;
-
- case R_IMM16:
- bfd_put_16 (in_abfd,
- bfd_coff_reloc16_get_value (reloc, link_info, input_section),
- data + *dst_ptr);
- (*dst_ptr) += 2;
- (*src_ptr) += 2;
- break;
-
- case R_JR:
- {
- bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
- input_section);
- bfd_vma dot = (link_order->offset
- + *dst_ptr
- + input_section->output_section->vma);
- int gap = dst - dot - 1;/* -1 since were in the odd byte of the
- word and the pc's been incremented */
-
- if (gap & 1)
- abort ();
- gap /= 2;
- if (gap > 128 || gap < -128)
- {
- if (! ((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),
- reloc->howto->name, reloc->addend, input_section->owner,
- input_section, reloc->address)))
- abort ();
- }
- bfd_put_8 (in_abfd, gap, data + *dst_ptr);
- (*dst_ptr)++;
- (*src_ptr)++;
- break;
- }
- default:
- abort ();
- }
-}
-
-#define coff_reloc16_extra_cases extra_case
-
-#include "coffcode.h"
-
-
-#undef coff_bfd_get_relocated_section_contents
-#undef coff_bfd_relax_section
-#define coff_bfd_get_relocated_section_contents \
- bfd_coff_reloc16_get_relocated_section_contents
-#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
-
-const bfd_target z8kcoff_vec =
-{
- "coff-z8k", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT),
-
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading symbol underscore */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_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},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
diff --git a/contrib/gdb/bfd/cofflink.c b/contrib/gdb/bfd/cofflink.c
deleted file mode 100644
index c4a42a0..0000000
--- a/contrib/gdb/bfd/cofflink.c
+++ /dev/null
@@ -1,2327 +0,0 @@
-/* COFF specific linker code.
- Copyright 1994, 1995, 1996 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file contains the COFF backend linker code. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-static boolean coff_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean coff_link_check_archive_element
- PARAMS ((bfd *, struct bfd_link_info *, boolean *));
-static boolean coff_link_check_ar_symbols
- PARAMS ((bfd *, struct bfd_link_info *, boolean *));
-static boolean coff_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Create an entry in a COFF linker hash table. */
-
-struct bfd_hash_entry *
-_bfd_coff_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct coff_link_hash_entry *ret = (struct coff_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct coff_link_hash_entry *) NULL)
- ret = ((struct coff_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct coff_link_hash_entry)));
- if (ret == (struct coff_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct coff_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != (struct coff_link_hash_entry *) NULL)
- {
- /* Set local fields. */
- ret->indx = -1;
- ret->type = T_NULL;
- ret->class = C_NULL;
- ret->numaux = 0;
- ret->auxbfd = NULL;
- ret->aux = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize a COFF linker hash table. */
-
-boolean
-_bfd_coff_link_hash_table_init (table, abfd, newfunc)
- struct coff_link_hash_table *table;
- bfd *abfd;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
-}
-
-/* Create a COFF linker hash table. */
-
-struct bfd_link_hash_table *
-_bfd_coff_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct coff_link_hash_table *ret;
-
- ret = ((struct coff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct coff_link_hash_table)));
- if (ret == NULL)
- return NULL;
- if (! _bfd_coff_link_hash_table_init (ret, abfd,
- _bfd_coff_link_hash_newfunc))
- {
- bfd_release (abfd, ret);
- return (struct bfd_link_hash_table *) NULL;
- }
- return &ret->root;
-}
-
-/* Create an entry in a COFF debug merge hash table. */
-
-struct bfd_hash_entry *
-_bfd_coff_debug_merge_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct coff_debug_merge_hash_entry *ret =
- (struct coff_debug_merge_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct coff_debug_merge_hash_entry *) NULL)
- ret = ((struct coff_debug_merge_hash_entry *)
- bfd_hash_allocate (table,
- sizeof (struct coff_debug_merge_hash_entry)));
- if (ret == (struct coff_debug_merge_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct coff_debug_merge_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
- if (ret != (struct coff_debug_merge_hash_entry *) NULL)
- {
- /* Set local fields. */
- ret->types = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Given a COFF BFD, add symbols to the global hash table as
- appropriate. */
-
-boolean
-_bfd_coff_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- return coff_link_add_object_symbols (abfd, info);
- case bfd_archive:
- return (_bfd_generic_link_add_archive_symbols
- (abfd, info, coff_link_check_archive_element));
- default:
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-}
-
-/* Add symbols from a COFF object file. */
-
-static boolean
-coff_link_add_object_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- if (! _bfd_coff_get_external_symbols (abfd))
- return false;
- if (! coff_link_add_symbols (abfd, info))
- return false;
-
- if (! info->keep_memory)
- {
- if (! _bfd_coff_free_symbols (abfd))
- return false;
- }
- return true;
-}
-
-/* Check a single archive element to see if we need to include it in
- the link. *PNEEDED is set according to whether this element is
- needed in the link or not. This is called via
- _bfd_generic_link_add_archive_symbols. */
-
-static boolean
-coff_link_check_archive_element (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- if (! _bfd_coff_get_external_symbols (abfd))
- return false;
-
- if (! coff_link_check_ar_symbols (abfd, info, pneeded))
- return false;
-
- if (*pneeded)
- {
- if (! coff_link_add_symbols (abfd, info))
- return false;
- }
-
- if (! info->keep_memory || ! *pneeded)
- {
- if (! _bfd_coff_free_symbols (abfd))
- return false;
- }
-
- return true;
-}
-
-/* Look through the symbols to see if this object file should be
- included in the link. */
-
-static boolean
-coff_link_check_ar_symbols (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- boolean (*sym_is_global) PARAMS ((bfd *, struct internal_syment *));
- bfd_size_type symesz;
- bfd_byte *esym;
- bfd_byte *esym_end;
-
- *pneeded = false;
-
- sym_is_global = coff_backend_info (abfd)->_bfd_coff_sym_is_global;
-
- symesz = bfd_coff_symesz (abfd);
- esym = (bfd_byte *) obj_coff_external_syms (abfd);
- esym_end = esym + obj_raw_syment_count (abfd) * symesz;
- while (esym < esym_end)
- {
- struct internal_syment sym;
-
- bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
-
- if ((sym.n_sclass == C_EXT
- || (sym_is_global && (*sym_is_global) (abfd, &sym)))
- && (sym.n_scnum != 0 || sym.n_value != 0))
- {
- const char *name;
- char buf[SYMNMLEN + 1];
- struct bfd_link_hash_entry *h;
-
- /* This symbol is externally visible, and is defined by this
- object file. */
-
- name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
- if (name == NULL)
- return false;
- h = bfd_link_hash_lookup (info->hash, name, false, false, true);
-
- /* We are only interested in symbols that are currently
- undefined. If a symbol is currently known to be common,
- COFF linkers do not bring in an object file which defines
- it. */
- if (h != (struct bfd_link_hash_entry *) NULL
- && h->type == bfd_link_hash_undefined)
- {
- if (! (*info->callbacks->add_archive_element) (info, abfd, name))
- return false;
- *pneeded = true;
- return true;
- }
- }
-
- esym += (sym.n_numaux + 1) * symesz;
- }
-
- /* We do not need this object file. */
- return true;
-}
-
-/* Add all the symbols from an object file to the hash table. */
-
-static boolean
-coff_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- boolean (*sym_is_global) PARAMS ((bfd *, struct internal_syment *));
- boolean default_copy;
- bfd_size_type symcount;
- struct coff_link_hash_entry **sym_hash;
- bfd_size_type symesz;
- bfd_byte *esym;
- bfd_byte *esym_end;
-
- sym_is_global = coff_backend_info (abfd)->_bfd_coff_sym_is_global;
-
- if (info->keep_memory)
- default_copy = false;
- else
- default_copy = true;
-
- symcount = obj_raw_syment_count (abfd);
-
- /* We keep a list of the linker hash table entries that correspond
- to particular symbols. */
- sym_hash = ((struct coff_link_hash_entry **)
- bfd_alloc (abfd,
- ((size_t) symcount
- * sizeof (struct coff_link_hash_entry *))));
- if (sym_hash == NULL && symcount != 0)
- return false;
- obj_coff_sym_hashes (abfd) = sym_hash;
- memset (sym_hash, 0,
- (size_t) symcount * sizeof (struct coff_link_hash_entry *));
-
- symesz = bfd_coff_symesz (abfd);
- BFD_ASSERT (symesz == bfd_coff_auxesz (abfd));
- esym = (bfd_byte *) obj_coff_external_syms (abfd);
- esym_end = esym + symcount * symesz;
- while (esym < esym_end)
- {
- struct internal_syment sym;
- boolean copy;
-
- bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
-
- if (sym.n_sclass == C_EXT
- || (sym_is_global && (*sym_is_global) (abfd, &sym)))
- {
- const char *name;
- char buf[SYMNMLEN + 1];
- flagword flags;
- asection *section;
- bfd_vma value;
-
- /* This symbol is externally visible. */
-
- name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
- if (name == NULL)
- return false;
-
- /* We must copy the name into memory if we got it from the
- syment itself, rather than the string table. */
- copy = default_copy;
- if (sym._n._n_n._n_zeroes != 0
- || sym._n._n_n._n_offset == 0)
- copy = true;
-
- value = sym.n_value;
-
- if (sym.n_scnum == 0)
- {
- if (value == 0)
- {
- flags = 0;
- section = bfd_und_section_ptr;
- }
- else
- {
- flags = BSF_GLOBAL;
- section = bfd_com_section_ptr;
- }
- }
- else
- {
- flags = BSF_EXPORT | BSF_GLOBAL;
- section = coff_section_from_bfd_index (abfd, sym.n_scnum);
- value -= section->vma;
- }
-
- if (! (bfd_coff_link_add_one_symbol
- (info, abfd, name, flags, section, value,
- (const char *) NULL, copy, false,
- (struct bfd_link_hash_entry **) sym_hash)))
- return false;
-
- if (info->hash->creator->flavour == bfd_get_flavour (abfd))
- {
- if (((*sym_hash)->class == C_NULL
- && (*sym_hash)->type == T_NULL)
- || sym.n_scnum != 0
- || (sym.n_value != 0
- && (*sym_hash)->root.type != bfd_link_hash_defined))
- {
- (*sym_hash)->class = sym.n_sclass;
- (*sym_hash)->type = sym.n_type;
- (*sym_hash)->numaux = sym.n_numaux;
- (*sym_hash)->auxbfd = abfd;
- if (sym.n_numaux != 0)
- {
- union internal_auxent *alloc;
- unsigned int i;
- bfd_byte *eaux;
- union internal_auxent *iaux;
-
- alloc = ((union internal_auxent *)
- bfd_hash_allocate (&info->hash->table,
- (sym.n_numaux
- * sizeof (*alloc))));
- if (alloc == NULL)
- return false;
- for (i = 0, eaux = esym + symesz, iaux = alloc;
- i < sym.n_numaux;
- i++, eaux += symesz, iaux++)
- bfd_coff_swap_aux_in (abfd, (PTR) eaux, sym.n_type,
- sym.n_sclass, i, sym.n_numaux,
- (PTR) iaux);
- (*sym_hash)->aux = alloc;
- }
- }
- }
- }
-
- esym += (sym.n_numaux + 1) * symesz;
- sym_hash += sym.n_numaux + 1;
- }
-
- return true;
-}
-
-/* Do the final link step. */
-
-boolean
-_bfd_coff_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- bfd_size_type symesz;
- struct coff_final_link_info finfo;
- boolean debug_merge_allocated;
- asection *o;
- struct bfd_link_order *p;
- size_t max_sym_count;
- size_t max_lineno_count;
- size_t max_reloc_count;
- size_t max_output_reloc_count;
- size_t max_contents_size;
- file_ptr rel_filepos;
- unsigned int relsz;
- file_ptr line_filepos;
- unsigned int linesz;
- bfd *sub;
- bfd_byte *external_relocs = NULL;
- char strbuf[STRING_SIZE_SIZE];
-
- symesz = bfd_coff_symesz (abfd);
-
- finfo.info = info;
- finfo.output_bfd = abfd;
- finfo.strtab = NULL;
- finfo.section_info = NULL;
- finfo.last_file_index = -1;
- finfo.internal_syms = NULL;
- finfo.sec_ptrs = NULL;
- finfo.sym_indices = NULL;
- finfo.outsyms = NULL;
- finfo.linenos = NULL;
- finfo.contents = NULL;
- finfo.external_relocs = NULL;
- finfo.internal_relocs = NULL;
- debug_merge_allocated = false;
-
- coff_data (abfd)->link_info = info;
-
- finfo.strtab = _bfd_stringtab_init ();
- if (finfo.strtab == NULL)
- goto error_return;
-
- if (! coff_debug_merge_hash_table_init (&finfo.debug_merge))
- goto error_return;
- debug_merge_allocated = true;
-
- /* Compute the file positions for all the sections. */
- if (! abfd->output_has_begun)
- bfd_coff_compute_section_file_positions (abfd);
-
- /* Count the line numbers and relocation entries required for the
- output file. Set the file positions for the relocs. */
- rel_filepos = obj_relocbase (abfd);
- relsz = bfd_coff_relsz (abfd);
- max_contents_size = 0;
- max_lineno_count = 0;
- max_reloc_count = 0;
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- o->reloc_count = 0;
- o->lineno_count = 0;
- for (p = o->link_order_head; p != NULL; p = p->next)
- {
-
- if (p->type == bfd_indirect_link_order)
- {
- asection *sec;
-
- sec = p->u.indirect.section;
-
- if (info->strip == strip_none
- || info->strip == strip_some)
- o->lineno_count += sec->lineno_count;
-
- if (info->relocateable)
- o->reloc_count += sec->reloc_count;
-
- if (sec->_raw_size > max_contents_size)
- max_contents_size = sec->_raw_size;
- if (sec->lineno_count > max_lineno_count)
- max_lineno_count = sec->lineno_count;
- if (sec->reloc_count > max_reloc_count)
- max_reloc_count = sec->reloc_count;
- }
- else if (info->relocateable
- && (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order))
- ++o->reloc_count;
- }
- if (o->reloc_count == 0)
- o->rel_filepos = 0;
- else
- {
- o->flags |= SEC_RELOC;
- o->rel_filepos = rel_filepos;
- rel_filepos += o->reloc_count * relsz;
- }
- }
-
- /* If doing a relocateable link, allocate space for the pointers we
- need to keep. */
- if (info->relocateable)
- {
- unsigned int i;
-
- /* We use section_count + 1, rather than section_count, because
- the target_index fields are 1 based. */
- finfo.section_info =
- ((struct coff_link_section_info *)
- bfd_malloc ((abfd->section_count + 1)
- * sizeof (struct coff_link_section_info)));
- if (finfo.section_info == NULL)
- goto error_return;
- for (i = 0; i <= abfd->section_count; i++)
- {
- finfo.section_info[i].relocs = NULL;
- finfo.section_info[i].rel_hashes = NULL;
- }
- }
-
- /* We now know the size of the relocs, so we can determine the file
- positions of the line numbers. */
- line_filepos = rel_filepos;
- linesz = bfd_coff_linesz (abfd);
- max_output_reloc_count = 0;
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if (o->lineno_count == 0)
- o->line_filepos = 0;
- else
- {
- o->line_filepos = line_filepos;
- line_filepos += o->lineno_count * linesz;
- }
-
- if (o->reloc_count != 0)
- {
- /* We don't know the indices of global symbols until we have
- written out all the local symbols. For each section in
- the output file, we keep an array of pointers to hash
- table entries. Each entry in the array corresponds to a
- reloc. When we find a reloc against a global symbol, we
- set the corresponding entry in this array so that we can
- fix up the symbol index after we have written out all the
- local symbols.
-
- Because of this problem, we also keep the relocs in
- memory until the end of the link. This wastes memory,
- but only when doing a relocateable link, which is not the
- common case. */
- BFD_ASSERT (info->relocateable);
- finfo.section_info[o->target_index].relocs =
- ((struct internal_reloc *)
- bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
- finfo.section_info[o->target_index].rel_hashes =
- ((struct coff_link_hash_entry **)
- bfd_malloc (o->reloc_count
- * sizeof (struct coff_link_hash_entry *)));
- if (finfo.section_info[o->target_index].relocs == NULL
- || finfo.section_info[o->target_index].rel_hashes == NULL)
- goto error_return;
-
- if (o->reloc_count > max_output_reloc_count)
- max_output_reloc_count = o->reloc_count;
- }
-
- /* Reset the reloc and lineno counts, so that we can use them to
- count the number of entries we have output so far. */
- o->reloc_count = 0;
- o->lineno_count = 0;
- }
-
- obj_sym_filepos (abfd) = line_filepos;
-
- /* Figure out the largest number of symbols in an input BFD. Take
- the opportunity to clear the output_has_begun fields of all the
- input BFD's. */
- max_sym_count = 0;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- size_t sz;
-
- sub->output_has_begun = false;
- sz = obj_raw_syment_count (sub);
- if (sz > max_sym_count)
- max_sym_count = sz;
- }
-
- /* Allocate some buffers used while linking. */
- finfo.internal_syms = ((struct internal_syment *)
- bfd_malloc (max_sym_count
- * sizeof (struct internal_syment)));
- finfo.sec_ptrs = (asection **) bfd_malloc (max_sym_count
- * sizeof (asection *));
- finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
- finfo.outsyms = ((bfd_byte *)
- bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
- finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
- * bfd_coff_linesz (abfd));
- finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
- finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
- if (! info->relocateable)
- finfo.internal_relocs = ((struct internal_reloc *)
- bfd_malloc (max_reloc_count
- * sizeof (struct internal_reloc)));
- if ((finfo.internal_syms == NULL && max_sym_count > 0)
- || (finfo.sec_ptrs == NULL && max_sym_count > 0)
- || (finfo.sym_indices == NULL && max_sym_count > 0)
- || finfo.outsyms == NULL
- || (finfo.linenos == NULL && max_lineno_count > 0)
- || (finfo.contents == NULL && max_contents_size > 0)
- || (finfo.external_relocs == NULL && max_reloc_count > 0)
- || (! info->relocateable
- && finfo.internal_relocs == NULL
- && max_reloc_count > 0))
- goto error_return;
-
- /* We now know the position of everything in the file, except that
- we don't know the size of the symbol table and therefore we don't
- know where the string table starts. We just build the string
- table in memory as we go along. We process all the relocations
- for a single input file at once. */
- obj_raw_syment_count (abfd) = 0;
-
- if (coff_backend_info (abfd)->_bfd_coff_start_final_link)
- {
- if (! bfd_coff_start_final_link (abfd, info))
- goto error_return;
- }
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- for (p = o->link_order_head; p != NULL; p = p->next)
- {
- if (p->type == bfd_indirect_link_order
- && (bfd_get_flavour (p->u.indirect.section->owner)
- == bfd_target_coff_flavour))
- {
- sub = p->u.indirect.section->owner;
- if (! sub->output_has_begun)
- {
- if (! _bfd_coff_link_input_bfd (&finfo, sub))
- goto error_return;
- sub->output_has_begun = true;
- }
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- if (! _bfd_coff_reloc_link_order (abfd, &finfo, o, p))
- goto error_return;
- }
- else
- {
- if (! _bfd_default_link_order (abfd, info, o, p))
- goto error_return;
- }
- }
- }
-
- /* Free up the buffers used by _bfd_coff_link_input_bfd. */
-
- coff_debug_merge_hash_table_free (&finfo.debug_merge);
- debug_merge_allocated = false;
-
- if (finfo.internal_syms != NULL)
- {
- free (finfo.internal_syms);
- finfo.internal_syms = NULL;
- }
- if (finfo.sec_ptrs != NULL)
- {
- free (finfo.sec_ptrs);
- finfo.sec_ptrs = NULL;
- }
- if (finfo.sym_indices != NULL)
- {
- free (finfo.sym_indices);
- finfo.sym_indices = NULL;
- }
- if (finfo.linenos != NULL)
- {
- free (finfo.linenos);
- finfo.linenos = NULL;
- }
- if (finfo.contents != NULL)
- {
- free (finfo.contents);
- finfo.contents = NULL;
- }
- if (finfo.external_relocs != NULL)
- {
- free (finfo.external_relocs);
- finfo.external_relocs = NULL;
- }
- if (finfo.internal_relocs != NULL)
- {
- free (finfo.internal_relocs);
- finfo.internal_relocs = NULL;
- }
-
- /* The value of the last C_FILE symbol is supposed to be the symbol
- index of the first external symbol. Write it out again if
- necessary. */
- if (finfo.last_file_index != -1
- && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
- {
- finfo.last_file.n_value = obj_raw_syment_count (abfd);
- bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
- (PTR) finfo.outsyms);
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + finfo.last_file_index * symesz),
- SEEK_SET) != 0
- || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
- return false;
- }
-
- /* Write out the global symbols. */
- finfo.failed = false;
- coff_link_hash_traverse (coff_hash_table (info), _bfd_coff_write_global_sym,
- (PTR) &finfo);
- if (finfo.failed)
- goto error_return;
-
- /* The outsyms buffer is used by _bfd_coff_write_global_sym. */
- if (finfo.outsyms != NULL)
- {
- free (finfo.outsyms);
- finfo.outsyms = NULL;
- }
-
- if (info->relocateable)
- {
- /* Now that we have written out all the global symbols, we know
- the symbol indices to use for relocs against them, and we can
- finally write out the relocs. */
- external_relocs = ((bfd_byte *)
- bfd_malloc (max_output_reloc_count * relsz));
- if (external_relocs == NULL)
- goto error_return;
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- struct internal_reloc *irel;
- struct internal_reloc *irelend;
- struct coff_link_hash_entry **rel_hash;
- bfd_byte *erel;
-
- if (o->reloc_count == 0)
- continue;
-
- irel = finfo.section_info[o->target_index].relocs;
- irelend = irel + o->reloc_count;
- rel_hash = finfo.section_info[o->target_index].rel_hashes;
- erel = external_relocs;
- for (; irel < irelend; irel++, rel_hash++, erel += relsz)
- {
- if (*rel_hash != NULL)
- {
- BFD_ASSERT ((*rel_hash)->indx >= 0);
- irel->r_symndx = (*rel_hash)->indx;
- }
- bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
- }
-
- if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
- || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
- abfd) != relsz * o->reloc_count)
- goto error_return;
- }
-
- free (external_relocs);
- external_relocs = NULL;
- }
-
- /* Free up the section information. */
- if (finfo.section_info != NULL)
- {
- unsigned int i;
-
- for (i = 0; i < abfd->section_count; i++)
- {
- if (finfo.section_info[i].relocs != NULL)
- free (finfo.section_info[i].relocs);
- if (finfo.section_info[i].rel_hashes != NULL)
- free (finfo.section_info[i].rel_hashes);
- }
- free (finfo.section_info);
- finfo.section_info = NULL;
- }
-
- /* Write out the string table. */
- if (obj_raw_syment_count (abfd) != 0)
- {
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * symesz),
- SEEK_SET) != 0)
- return false;
-
-#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd,
- _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
- (bfd_byte *) strbuf);
-#else
- #error Change bfd_h_put_32
-#endif
-
- if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
- return false;
-
- if (! _bfd_stringtab_emit (abfd, finfo.strtab))
- return false;
- }
-
- _bfd_stringtab_free (finfo.strtab);
-
- /* Setting bfd_get_symcount to 0 will cause write_object_contents to
- not try to write out the symbols. */
- bfd_get_symcount (abfd) = 0;
-
- return true;
-
- error_return:
- if (debug_merge_allocated)
- coff_debug_merge_hash_table_free (&finfo.debug_merge);
- if (finfo.strtab != NULL)
- _bfd_stringtab_free (finfo.strtab);
- if (finfo.section_info != NULL)
- {
- unsigned int i;
-
- for (i = 0; i < abfd->section_count; i++)
- {
- if (finfo.section_info[i].relocs != NULL)
- free (finfo.section_info[i].relocs);
- if (finfo.section_info[i].rel_hashes != NULL)
- free (finfo.section_info[i].rel_hashes);
- }
- free (finfo.section_info);
- }
- if (finfo.internal_syms != NULL)
- free (finfo.internal_syms);
- if (finfo.sec_ptrs != NULL)
- free (finfo.sec_ptrs);
- if (finfo.sym_indices != NULL)
- free (finfo.sym_indices);
- if (finfo.outsyms != NULL)
- free (finfo.outsyms);
- if (finfo.linenos != NULL)
- free (finfo.linenos);
- if (finfo.contents != NULL)
- free (finfo.contents);
- if (finfo.external_relocs != NULL)
- free (finfo.external_relocs);
- if (finfo.internal_relocs != NULL)
- free (finfo.internal_relocs);
- if (external_relocs != NULL)
- free (external_relocs);
- return false;
-}
-
-/* parse out a -heap <reserved>,<commit> line */
-
-static char *
-dores_com (ptr, output_bfd, heap)
- char *ptr;
- bfd *output_bfd;
- int heap;
-{
- if (coff_data(output_bfd)->pe)
- {
- int val = strtoul (ptr, &ptr, 0);
- if (heap)
- pe_data(output_bfd)->pe_opthdr.SizeOfHeapReserve =val;
- else
- pe_data(output_bfd)->pe_opthdr.SizeOfStackReserve =val;
-
- if (ptr[0] == ',')
- {
- int val = strtoul (ptr+1, &ptr, 0);
- if (heap)
- pe_data(output_bfd)->pe_opthdr.SizeOfHeapCommit =val;
- else
- pe_data(output_bfd)->pe_opthdr.SizeOfStackCommit =val;
- }
- }
- return ptr;
-}
-
-static char *get_name(ptr, dst)
-char *ptr;
-char **dst;
-{
- while (*ptr == ' ')
- ptr++;
- *dst = ptr;
- while (*ptr && *ptr != ' ')
- ptr++;
- *ptr = 0;
- return ptr+1;
-}
-
-/* Process any magic embedded commands in a section called .drectve */
-
-static int
-process_embedded_commands (output_bfd, info, abfd)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *abfd;
-{
- asection *sec = bfd_get_section_by_name (abfd, ".drectve");
- char *s;
- char *e;
- char *copy;
- if (!sec)
- return 1;
-
- copy = bfd_malloc ((size_t) sec->_raw_size);
- if (!copy)
- return 0;
- if (! bfd_get_section_contents(abfd, sec, copy, 0, sec->_raw_size))
- {
- free (copy);
- return 0;
- }
- e = copy + sec->_raw_size;
- for (s = copy; s < e ; )
- {
- if (s[0]!= '-') {
- s++;
- continue;
- }
- if (strncmp (s,"-attr", 5) == 0)
- {
- char *name;
- char *attribs;
- asection *asec;
-
- int loop = 1;
- int had_write = 0;
- int had_read = 0;
- int had_exec= 0;
- int had_shared= 0;
- s += 5;
- s = get_name(s, &name);
- s = get_name(s, &attribs);
- while (loop) {
- switch (*attribs++)
- {
- case 'W':
- had_write = 1;
- break;
- case 'R':
- had_read = 1;
- break;
- case 'S':
- had_shared = 1;
- break;
- case 'X':
- had_exec = 1;
- break;
- default:
- loop = 0;
- }
- }
- asec = bfd_get_section_by_name (abfd, name);
- if (asec) {
- if (had_exec)
- asec->flags |= SEC_CODE;
- if (!had_write)
- asec->flags |= SEC_READONLY;
- }
- }
- else if (strncmp (s,"-heap", 5) == 0)
- {
- s = dores_com (s+5, output_bfd, 1);
- }
- else if (strncmp (s,"-stack", 6) == 0)
- {
- s = dores_com (s+6, output_bfd, 0);
- }
- else
- s++;
- }
- free (copy);
- return 1;
-}
-
-/* Link an input file into the linker output file. This function
- handles all the sections and relocations of the input file at once. */
-
-boolean
-_bfd_coff_link_input_bfd (finfo, input_bfd)
- struct coff_final_link_info *finfo;
- bfd *input_bfd;
-{
- boolean (*sym_is_global) PARAMS ((bfd *, struct internal_syment *));
- boolean (*adjust_symndx) PARAMS ((bfd *, struct bfd_link_info *, bfd *,
- asection *, struct internal_reloc *,
- boolean *));
- bfd *output_bfd;
- const char *strings;
- bfd_size_type syment_base;
- unsigned int n_tmask;
- unsigned int n_btshft;
- boolean copy, hash;
- bfd_size_type isymesz;
- bfd_size_type osymesz;
- bfd_size_type linesz;
- bfd_byte *esym;
- bfd_byte *esym_end;
- struct internal_syment *isymp;
- asection **secpp;
- long *indexp;
- unsigned long output_index;
- bfd_byte *outsym;
- struct coff_link_hash_entry **sym_hash;
- asection *o;
-
- /* Move all the symbols to the output file. */
-
- output_bfd = finfo->output_bfd;
- sym_is_global = coff_backend_info (input_bfd)->_bfd_coff_sym_is_global;
- strings = NULL;
- syment_base = obj_raw_syment_count (output_bfd);
- isymesz = bfd_coff_symesz (input_bfd);
- osymesz = bfd_coff_symesz (output_bfd);
- linesz = bfd_coff_linesz (input_bfd);
- BFD_ASSERT (linesz == bfd_coff_linesz (output_bfd));
-
- n_tmask = coff_data (input_bfd)->local_n_tmask;
- n_btshft = coff_data (input_bfd)->local_n_btshft;
-
- /* Define macros so that ISFCN, et. al., macros work correctly. */
-#define N_TMASK n_tmask
-#define N_BTSHFT n_btshft
-
- copy = false;
- if (! finfo->info->keep_memory)
- copy = true;
- hash = true;
- if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
- hash = false;
-
- if (! _bfd_coff_get_external_symbols (input_bfd))
- return false;
-
- esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
- esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
- isymp = finfo->internal_syms;
- secpp = finfo->sec_ptrs;
- indexp = finfo->sym_indices;
- output_index = syment_base;
- outsym = finfo->outsyms;
-
- if (coff_data(output_bfd)->pe)
- {
- if (!process_embedded_commands (output_bfd, finfo->info, input_bfd))
- return false;
- }
-
- while (esym < esym_end)
- {
- struct internal_syment isym;
- boolean skip;
- boolean global;
- int add;
-
- bfd_coff_swap_sym_in (input_bfd, (PTR) esym, (PTR) isymp);
-
- /* Make a copy of *isymp so that the relocate_section function
- always sees the original values. This is more reliable than
- always recomputing the symbol value even if we are stripping
- the symbol. */
- isym = *isymp;
-
- if (isym.n_scnum != 0)
- *secpp = coff_section_from_bfd_index (input_bfd, isym.n_scnum);
- else
- {
- if (isym.n_value == 0)
- *secpp = bfd_und_section_ptr;
- else
- *secpp = bfd_com_section_ptr;
- }
-
- *indexp = -1;
-
- skip = false;
- global = false;
- add = 1 + isym.n_numaux;
-
- /* If we are stripping all symbols, we want to skip this one. */
- if (finfo->info->strip == strip_all)
- skip = true;
-
- if (! skip)
- {
- if (isym.n_sclass == C_EXT
- || (sym_is_global && (*sym_is_global) (input_bfd, &isym)))
- {
- /* This is a global symbol. Global symbols come at the
- end of the symbol table, so skip them for now.
- Function symbols, however, are an exception, and are
- not moved to the end. */
- global = true;
- if (! ISFCN (isym.n_type))
- skip = true;
- }
- else
- {
- /* This is a local symbol. Skip it if we are discarding
- local symbols. */
- if (finfo->info->discard == discard_all)
- skip = true;
- }
- }
-
- /* If we stripping debugging symbols, and this is a debugging
- symbol, then skip it. */
- if (! skip
- && finfo->info->strip == strip_debugger
- && isym.n_scnum == N_DEBUG)
- skip = true;
-
- /* If some symbols are stripped based on the name, work out the
- name and decide whether to skip this symbol. */
- if (! skip
- && (finfo->info->strip == strip_some
- || finfo->info->discard == discard_l))
- {
- const char *name;
- char buf[SYMNMLEN + 1];
-
- name = _bfd_coff_internal_syment_name (input_bfd, &isym, buf);
- if (name == NULL)
- return false;
-
- if ((finfo->info->strip == strip_some
- && (bfd_hash_lookup (finfo->info->keep_hash, name, false,
- false) == NULL))
- || (! global
- && finfo->info->discard == discard_l
- && strncmp (name, finfo->info->lprefix,
- finfo->info->lprefix_len) == 0))
- skip = true;
- }
-
- /* If this is an enum, struct, or union tag, see if we have
- already output an identical type. */
- if (! skip
- && (finfo->output_bfd->flags & BFD_TRADITIONAL_FORMAT) == 0
- && (isym.n_sclass == C_ENTAG
- || isym.n_sclass == C_STRTAG
- || isym.n_sclass == C_UNTAG)
- && isym.n_numaux == 1)
- {
- const char *name;
- char buf[SYMNMLEN + 1];
- struct coff_debug_merge_hash_entry *mh;
- struct coff_debug_merge_type *mt;
- union internal_auxent aux;
- struct coff_debug_merge_element **epp;
- bfd_byte *esl, *eslend;
- struct internal_syment *islp;
-
- name = _bfd_coff_internal_syment_name (input_bfd, &isym, buf);
- if (name == NULL)
- return false;
-
- /* Ignore fake names invented by compiler; treat them all as
- the same name. */
- if (*name == '~' || *name == '.' || *name == '$'
- || (*name == bfd_get_symbol_leading_char (input_bfd)
- && (name[1] == '~' || name[1] == '.' || name[1] == '$')))
- name = "";
-
- mh = coff_debug_merge_hash_lookup (&finfo->debug_merge, name,
- true, true);
- if (mh == NULL)
- return false;
-
- /* Allocate memory to hold type information. If this turns
- out to be a duplicate, we pass this address to
- bfd_release. */
- mt = ((struct coff_debug_merge_type *)
- bfd_alloc (input_bfd,
- sizeof (struct coff_debug_merge_type)));
- if (mt == NULL)
- return false;
- mt->class = isym.n_sclass;
-
- /* Pick up the aux entry, which points to the end of the tag
- entries. */
- bfd_coff_swap_aux_in (input_bfd, (PTR) (esym + isymesz),
- isym.n_type, isym.n_sclass, 0, isym.n_numaux,
- (PTR) &aux);
-
- /* Gather the elements. */
- epp = &mt->elements;
- mt->elements = NULL;
- islp = isymp + 2;
- esl = esym + 2 * isymesz;
- eslend = ((bfd_byte *) obj_coff_external_syms (input_bfd)
- + aux.x_sym.x_fcnary.x_fcn.x_endndx.l * isymesz);
- while (esl < eslend)
- {
- const char *elename;
- char elebuf[SYMNMLEN + 1];
- char *copy;
-
- bfd_coff_swap_sym_in (input_bfd, (PTR) esl, (PTR) islp);
-
- *epp = ((struct coff_debug_merge_element *)
- bfd_alloc (input_bfd,
- sizeof (struct coff_debug_merge_element)));
- if (*epp == NULL)
- return false;
-
- elename = _bfd_coff_internal_syment_name (input_bfd, islp,
- elebuf);
- if (elename == NULL)
- return false;
-
- copy = (char *) bfd_alloc (input_bfd, strlen (elename) + 1);
- if (copy == NULL)
- return false;
- strcpy (copy, elename);
-
- (*epp)->name = copy;
- (*epp)->type = islp->n_type;
- (*epp)->tagndx = 0;
- if (islp->n_numaux >= 1
- && islp->n_type != T_NULL
- && islp->n_sclass != C_EOS)
- {
- union internal_auxent eleaux;
- long indx;
-
- bfd_coff_swap_aux_in (input_bfd, (PTR) (esl + isymesz),
- islp->n_type, islp->n_sclass, 0,
- islp->n_numaux, (PTR) &eleaux);
- indx = eleaux.x_sym.x_tagndx.l;
-
- /* FIXME: If this tagndx entry refers to a symbol
- defined later in this file, we just ignore it.
- Handling this correctly would be tedious, and may
- not be required. */
-
- if (indx > 0
- && (indx
- < ((esym -
- (bfd_byte *) obj_coff_external_syms (input_bfd))
- / (long) isymesz)))
- {
- (*epp)->tagndx = finfo->sym_indices[indx];
- if ((*epp)->tagndx < 0)
- (*epp)->tagndx = 0;
- }
- }
- epp = &(*epp)->next;
- *epp = NULL;
-
- esl += (islp->n_numaux + 1) * isymesz;
- islp += islp->n_numaux + 1;
- }
-
- /* See if we already have a definition which matches this
- type. We always output the type if it has no elements,
- for simplicity. */
- if (mt->elements == NULL)
- bfd_release (input_bfd, (PTR) mt);
- else
- {
- struct coff_debug_merge_type *mtl;
-
- for (mtl = mh->types; mtl != NULL; mtl = mtl->next)
- {
- struct coff_debug_merge_element *me, *mel;
-
- if (mtl->class != mt->class)
- continue;
-
- for (me = mt->elements, mel = mtl->elements;
- me != NULL && mel != NULL;
- me = me->next, mel = mel->next)
- {
- if (strcmp (me->name, mel->name) != 0
- || me->type != mel->type
- || me->tagndx != mel->tagndx)
- break;
- }
-
- if (me == NULL && mel == NULL)
- break;
- }
-
- if (mtl == NULL || (bfd_size_type) mtl->indx >= syment_base)
- {
- /* This is the first definition of this type. */
- mt->indx = output_index;
- mt->next = mh->types;
- mh->types = mt;
- }
- else
- {
- /* This is a redefinition which can be merged. */
- bfd_release (input_bfd, (PTR) mt);
- *indexp = mtl->indx;
- add = (eslend - esym) / isymesz;
- skip = true;
- }
- }
- }
-
- /* We now know whether we are to skip this symbol or not. */
- if (! skip)
- {
- /* Adjust the symbol in order to output it. */
-
- if (isym._n._n_n._n_zeroes == 0
- && isym._n._n_n._n_offset != 0)
- {
- const char *name;
- bfd_size_type indx;
-
- /* This symbol has a long name. Enter it in the string
- table we are building. Note that we do not check
- bfd_coff_symname_in_debug. That is only true for
- XCOFF, and XCOFF requires different linking code
- anyhow. */
- name = _bfd_coff_internal_syment_name (input_bfd, &isym,
- (char *) NULL);
- if (name == NULL)
- return false;
- indx = _bfd_stringtab_add (finfo->strtab, name, hash, copy);
- if (indx == (bfd_size_type) -1)
- return false;
- isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
- }
-
- if (isym.n_scnum > 0)
- {
- isym.n_scnum = (*secpp)->output_section->target_index;
- isym.n_value += ((*secpp)->output_section->vma
- + (*secpp)->output_offset
- - (*secpp)->vma);
- }
-
- /* The value of a C_FILE symbol is the symbol index of the
- next C_FILE symbol. The value of the last C_FILE symbol
- is the symbol index to the first external symbol
- (actually, coff_renumber_symbols does not get this
- right--it just sets the value of the last C_FILE symbol
- to zero--and nobody has ever complained about it). We
- try to get this right, below, just before we write the
- symbols out, but in the general case we may have to write
- the symbol out twice. */
- if (isym.n_sclass == C_FILE)
- {
- if (finfo->last_file_index != -1
- && finfo->last_file.n_value != (long) output_index)
- {
- /* We must correct the value of the last C_FILE entry. */
- finfo->last_file.n_value = output_index;
- if ((bfd_size_type) finfo->last_file_index >= syment_base)
- {
- /* The last C_FILE symbol is in this input file. */
- bfd_coff_swap_sym_out (output_bfd,
- (PTR) &finfo->last_file,
- (PTR) (finfo->outsyms
- + ((finfo->last_file_index
- - syment_base)
- * osymesz)));
- }
- else
- {
- /* We have already written out the last C_FILE
- symbol. We need to write it out again. We
- borrow *outsym temporarily. */
- bfd_coff_swap_sym_out (output_bfd,
- (PTR) &finfo->last_file,
- (PTR) outsym);
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + finfo->last_file_index * osymesz),
- SEEK_SET) != 0
- || (bfd_write (outsym, osymesz, 1, output_bfd)
- != osymesz))
- return false;
- }
- }
-
- finfo->last_file_index = output_index;
- finfo->last_file = isym;
- }
-
- /* Output the symbol. */
-
- bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
-
- *indexp = output_index;
-
- if (global)
- {
- long indx;
- struct coff_link_hash_entry *h;
-
- indx = ((esym - (bfd_byte *) obj_coff_external_syms (input_bfd))
- / isymesz);
- h = obj_coff_sym_hashes (input_bfd)[indx];
- BFD_ASSERT (h != NULL);
- h->indx = output_index;
- }
-
- output_index += add;
- outsym += add * osymesz;
- }
-
- esym += add * isymesz;
- isymp += add;
- ++secpp;
- ++indexp;
- for (--add; add > 0; --add)
- {
- *secpp++ = NULL;
- *indexp++ = -1;
- }
- }
-
- /* Fix up the aux entries. This must be done in a separate pass,
- because we don't know the correct symbol indices until we have
- already decided which symbols we are going to keep. */
-
- esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
- esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
- isymp = finfo->internal_syms;
- indexp = finfo->sym_indices;
- sym_hash = obj_coff_sym_hashes (input_bfd);
- outsym = finfo->outsyms;
- while (esym < esym_end)
- {
- int add;
-
- add = 1 + isymp->n_numaux;
-
- if ((*indexp < 0
- || (bfd_size_type) *indexp < syment_base)
- && (*sym_hash == NULL
- || (*sym_hash)->auxbfd != input_bfd))
- esym += add * isymesz;
- else
- {
- struct coff_link_hash_entry *h;
- int i;
-
- h = NULL;
- if (*indexp < 0)
- {
- h = *sym_hash;
- BFD_ASSERT (h->numaux == isymp->n_numaux);
- }
-
- esym += isymesz;
-
- if (h == NULL)
- outsym += osymesz;
-
- /* Handle the aux entries. This handling is based on
- coff_pointerize_aux. I don't know if it always correct. */
- for (i = 0; i < isymp->n_numaux && esym < esym_end; i++)
- {
- union internal_auxent aux;
- union internal_auxent *auxp;
-
- if (h != NULL)
- auxp = h->aux + i;
- else
- {
- bfd_coff_swap_aux_in (input_bfd, (PTR) esym, isymp->n_type,
- isymp->n_sclass, i, isymp->n_numaux,
- (PTR) &aux);
- auxp = &aux;
- }
-
- if (isymp->n_sclass == C_FILE)
- {
- /* If this is a long filename, we must put it in the
- string table. */
- if (auxp->x_file.x_n.x_zeroes == 0
- && auxp->x_file.x_n.x_offset != 0)
- {
- const char *filename;
- bfd_size_type indx;
-
- BFD_ASSERT (auxp->x_file.x_n.x_offset
- >= STRING_SIZE_SIZE);
- if (strings == NULL)
- {
- strings = _bfd_coff_read_string_table (input_bfd);
- if (strings == NULL)
- return false;
- }
- filename = strings + auxp->x_file.x_n.x_offset;
- indx = _bfd_stringtab_add (finfo->strtab, filename,
- hash, copy);
- if (indx == (bfd_size_type) -1)
- return false;
- auxp->x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
- }
- }
- else if (isymp->n_sclass != C_STAT || isymp->n_type != T_NULL)
- {
- unsigned long indx;
-
- if (ISFCN (isymp->n_type)
- || ISTAG (isymp->n_sclass)
- || isymp->n_sclass == C_BLOCK)
- {
- indx = auxp->x_sym.x_fcnary.x_fcn.x_endndx.l;
- if (indx > 0
- && indx < obj_raw_syment_count (input_bfd))
- {
- /* We look forward through the symbol for
- the index of the next symbol we are going
- to include. I don't know if this is
- entirely right. */
- while ((finfo->sym_indices[indx] < 0
- || ((bfd_size_type) finfo->sym_indices[indx]
- < syment_base))
- && indx < obj_raw_syment_count (input_bfd))
- ++indx;
- if (indx >= obj_raw_syment_count (input_bfd))
- indx = output_index;
- else
- indx = finfo->sym_indices[indx];
- auxp->x_sym.x_fcnary.x_fcn.x_endndx.l = indx;
- }
- }
-
- indx = auxp->x_sym.x_tagndx.l;
- if (indx > 0 && indx < obj_raw_syment_count (input_bfd))
- {
- long symindx;
-
- symindx = finfo->sym_indices[indx];
- if (symindx < 0)
- auxp->x_sym.x_tagndx.l = 0;
- else
- auxp->x_sym.x_tagndx.l = symindx;
- }
- }
-
- if (h == NULL)
- {
- bfd_coff_swap_aux_out (output_bfd, (PTR) auxp, isymp->n_type,
- isymp->n_sclass, i, isymp->n_numaux,
- (PTR) outsym);
- outsym += osymesz;
- }
-
- esym += isymesz;
- }
- }
-
- indexp += add;
- isymp += add;
- sym_hash += add;
- }
-
- /* Relocate the line numbers, unless we are stripping them. */
- if (finfo->info->strip == strip_none
- || finfo->info->strip == strip_some)
- {
- for (o = input_bfd->sections; o != NULL; o = o->next)
- {
- bfd_vma offset;
- bfd_byte *eline;
- bfd_byte *elineend;
-
- /* FIXME: If SEC_HAS_CONTENTS is not for the section, then
- build_link_order in ldwrite.c will not have created a
- link order, which means that we will not have seen this
- input section in _bfd_coff_final_link, which means that
- we will not have allocated space for the line numbers of
- this section. I don't think line numbers can be
- meaningful for a section which does not have
- SEC_HAS_CONTENTS set, but, if they do, this must be
- changed. */
- if (o->lineno_count == 0
- || (o->output_section->flags & SEC_HAS_CONTENTS) == 0)
- continue;
-
- if (bfd_seek (input_bfd, o->line_filepos, SEEK_SET) != 0
- || bfd_read (finfo->linenos, linesz, o->lineno_count,
- input_bfd) != linesz * o->lineno_count)
- return false;
-
- offset = o->output_section->vma + o->output_offset - o->vma;
- eline = finfo->linenos;
- elineend = eline + linesz * o->lineno_count;
- for (; eline < elineend; eline += linesz)
- {
- struct internal_lineno iline;
-
- bfd_coff_swap_lineno_in (input_bfd, (PTR) eline, (PTR) &iline);
-
- if (iline.l_lnno != 0)
- iline.l_addr.l_paddr += offset;
- else if (iline.l_addr.l_symndx >= 0
- && ((unsigned long) iline.l_addr.l_symndx
- < obj_raw_syment_count (input_bfd)))
- {
- long indx;
-
- indx = finfo->sym_indices[iline.l_addr.l_symndx];
-
- if (indx < 0)
- {
- /* These line numbers are attached to a symbol
- which we are stripping. We should really
- just discard the line numbers, but that would
- be a pain because we have already counted
- them. */
- indx = 0;
- }
- else
- {
- struct internal_syment is;
- union internal_auxent ia;
-
- /* Fix up the lnnoptr field in the aux entry of
- the symbol. It turns out that we can't do
- this when we modify the symbol aux entries,
- because gas sometimes screws up the lnnoptr
- field and makes it an offset from the start
- of the line numbers rather than an absolute
- file index. */
- bfd_coff_swap_sym_in (output_bfd,
- (PTR) (finfo->outsyms
- + ((indx - syment_base)
- * osymesz)),
- (PTR) &is);
- if ((ISFCN (is.n_type)
- || is.n_sclass == C_BLOCK)
- && is.n_numaux >= 1)
- {
- PTR auxptr;
-
- auxptr = (PTR) (finfo->outsyms
- + ((indx - syment_base + 1)
- * osymesz));
- bfd_coff_swap_aux_in (output_bfd, auxptr,
- is.n_type, is.n_sclass,
- 0, is.n_numaux, (PTR) &ia);
- ia.x_sym.x_fcnary.x_fcn.x_lnnoptr =
- (o->output_section->line_filepos
- + o->output_section->lineno_count * linesz
- + eline - finfo->linenos);
- bfd_coff_swap_aux_out (output_bfd, (PTR) &ia,
- is.n_type, is.n_sclass, 0,
- is.n_numaux, auxptr);
- }
- }
-
- iline.l_addr.l_symndx = indx;
- }
-
- bfd_coff_swap_lineno_out (output_bfd, (PTR) &iline, (PTR) eline);
- }
-
- if (bfd_seek (output_bfd,
- (o->output_section->line_filepos
- + o->output_section->lineno_count * linesz),
- SEEK_SET) != 0
- || bfd_write (finfo->linenos, linesz, o->lineno_count,
- output_bfd) != linesz * o->lineno_count)
- return false;
-
- o->output_section->lineno_count += o->lineno_count;
- }
- }
-
- /* If we swapped out a C_FILE symbol, guess that the next C_FILE
- symbol will be the first symbol in the next input file. In the
- normal case, this will save us from writing out the C_FILE symbol
- again. */
- if (finfo->last_file_index != -1
- && (bfd_size_type) finfo->last_file_index >= syment_base)
- {
- finfo->last_file.n_value = output_index;
- bfd_coff_swap_sym_out (output_bfd, (PTR) &finfo->last_file,
- (PTR) (finfo->outsyms
- + ((finfo->last_file_index - syment_base)
- * osymesz)));
- }
-
- /* Write the modified symbols to the output file. */
- if (outsym > finfo->outsyms)
- {
- if (bfd_seek (output_bfd,
- obj_sym_filepos (output_bfd) + syment_base * osymesz,
- SEEK_SET) != 0
- || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1,
- output_bfd)
- != (bfd_size_type) (outsym - finfo->outsyms)))
- return false;
-
- BFD_ASSERT ((obj_raw_syment_count (output_bfd)
- + (outsym - finfo->outsyms) / osymesz)
- == output_index);
-
- obj_raw_syment_count (output_bfd) = output_index;
- }
-
- /* Relocate the contents of each section. */
- adjust_symndx = coff_backend_info (input_bfd)->_bfd_coff_adjust_symndx;
- for (o = input_bfd->sections; o != NULL; o = o->next)
- {
- bfd_byte *contents;
-
- if ((o->flags & SEC_HAS_CONTENTS) == 0)
- {
- if ((o->flags & SEC_RELOC) != 0
- && o->reloc_count != 0)
- {
- ((*_bfd_error_handler)
- ("%s: relocs in section `%s', but it has no contents",
- bfd_get_filename (input_bfd),
- bfd_get_section_name (input_bfd, o)));
- bfd_set_error (bfd_error_no_contents);
- return false;
- }
-
- continue;
- }
-
- if (coff_section_data (input_bfd, o) != NULL
- && coff_section_data (input_bfd, o)->contents != NULL)
- contents = coff_section_data (input_bfd, o)->contents;
- else
- {
- if (! bfd_get_section_contents (input_bfd, o, finfo->contents,
- (file_ptr) 0, o->_raw_size))
- return false;
- contents = finfo->contents;
- }
-
- if ((o->flags & SEC_RELOC) != 0)
- {
- int target_index;
- struct internal_reloc *internal_relocs;
- struct internal_reloc *irel;
-
- /* Read in the relocs. */
- target_index = o->output_section->target_index;
- internal_relocs = (_bfd_coff_read_internal_relocs
- (input_bfd, o, false, finfo->external_relocs,
- finfo->info->relocateable,
- (finfo->info->relocateable
- ? (finfo->section_info[target_index].relocs
- + o->output_section->reloc_count)
- : finfo->internal_relocs)));
- if (internal_relocs == NULL)
- return false;
-
- /* Call processor specific code to relocate the section
- contents. */
- if (! bfd_coff_relocate_section (output_bfd, finfo->info,
- input_bfd, o,
- contents,
- internal_relocs,
- finfo->internal_syms,
- finfo->sec_ptrs))
- return false;
-
- if (finfo->info->relocateable)
- {
- bfd_vma offset;
- struct internal_reloc *irelend;
- struct coff_link_hash_entry **rel_hash;
-
- offset = o->output_section->vma + o->output_offset - o->vma;
- irel = internal_relocs;
- irelend = irel + o->reloc_count;
- rel_hash = (finfo->section_info[target_index].rel_hashes
- + o->output_section->reloc_count);
- for (; irel < irelend; irel++, rel_hash++)
- {
- struct coff_link_hash_entry *h;
- boolean adjusted;
-
- *rel_hash = NULL;
-
- /* Adjust the reloc address and symbol index. */
-
- irel->r_vaddr += offset;
-
- if (irel->r_symndx == -1)
- continue;
-
- if (adjust_symndx)
- {
- if (! (*adjust_symndx) (output_bfd, finfo->info,
- input_bfd, o, irel,
- &adjusted))
- return false;
- if (adjusted)
- continue;
- }
-
- h = obj_coff_sym_hashes (input_bfd)[irel->r_symndx];
- if (h != NULL)
- {
- /* This is a global symbol. */
- if (h->indx >= 0)
- irel->r_symndx = h->indx;
- else
- {
- /* This symbol is being written at the end
- of the file, and we do not yet know the
- symbol index. We save the pointer to the
- hash table entry in the rel_hash list.
- We set the indx field to -2 to indicate
- that this symbol must not be stripped. */
- *rel_hash = h;
- h->indx = -2;
- }
- }
- else
- {
- long indx;
-
- indx = finfo->sym_indices[irel->r_symndx];
- if (indx != -1)
- irel->r_symndx = indx;
- else
- {
- struct internal_syment *is;
- const char *name;
- char buf[SYMNMLEN + 1];
-
- /* This reloc is against a symbol we are
- stripping. It would be possible to
- handle this case, but I don't think it's
- worth it. */
- is = finfo->internal_syms + irel->r_symndx;
-
- name = (_bfd_coff_internal_syment_name
- (input_bfd, is, buf));
- if (name == NULL)
- return false;
-
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, o,
- irel->r_vaddr)))
- return false;
- }
- }
- }
-
- o->output_section->reloc_count += o->reloc_count;
- }
- }
-
- /* Write out the modified section contents. */
- if (! bfd_set_section_contents (output_bfd, o->output_section,
- contents, o->output_offset,
- (o->_cooked_size != 0
- ? o->_cooked_size
- : o->_raw_size)))
- return false;
- }
-
- if (! finfo->info->keep_memory)
- {
- if (! _bfd_coff_free_symbols (input_bfd))
- return false;
- }
-
- return true;
-}
-
-/* Write out a global symbol. Called via coff_link_hash_traverse. */
-
-boolean
-_bfd_coff_write_global_sym (h, data)
- struct coff_link_hash_entry *h;
- PTR data;
-{
- struct coff_final_link_info *finfo = (struct coff_final_link_info *) data;
- bfd *output_bfd;
- struct internal_syment isym;
- bfd_size_type symesz;
- unsigned int i;
-
- output_bfd = finfo->output_bfd;
-
- if (h->indx >= 0)
- return true;
-
- if (h->indx != -2
- && (finfo->info->strip == strip_all
- || (finfo->info->strip == strip_some
- && (bfd_hash_lookup (finfo->info->keep_hash,
- h->root.root.string, false, false)
- == NULL))))
- return true;
-
- switch (h->root.type)
- {
- default:
- case bfd_link_hash_new:
- abort ();
- return false;
-
- case bfd_link_hash_undefined:
- case bfd_link_hash_undefweak:
- isym.n_scnum = N_UNDEF;
- isym.n_value = 0;
- break;
-
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- {
- asection *sec;
-
- sec = h->root.u.def.section->output_section;
- if (bfd_is_abs_section (sec))
- isym.n_scnum = N_ABS;
- else
- isym.n_scnum = sec->target_index;
- isym.n_value = (h->root.u.def.value
- + sec->vma
- + h->root.u.def.section->output_offset);
- }
- break;
-
- case bfd_link_hash_common:
- isym.n_scnum = N_UNDEF;
- isym.n_value = h->root.u.c.size;
- break;
-
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* Just ignore these. They can't be handled anyhow. */
- return true;
- }
-
- if (strlen (h->root.root.string) <= SYMNMLEN)
- strncpy (isym._n._n_name, h->root.root.string, SYMNMLEN);
- else
- {
- boolean hash;
- bfd_size_type indx;
-
- hash = true;
- if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
- hash = false;
- indx = _bfd_stringtab_add (finfo->strtab, h->root.root.string, hash,
- false);
- if (indx == (bfd_size_type) -1)
- {
- finfo->failed = true;
- return false;
- }
- isym._n._n_n._n_zeroes = 0;
- isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
- }
-
- isym.n_sclass = h->class;
- isym.n_type = h->type;
-
- if (isym.n_sclass == C_NULL)
- isym.n_sclass = C_EXT;
-
- isym.n_numaux = h->numaux;
-
- bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) finfo->outsyms);
-
- symesz = bfd_coff_symesz (output_bfd);
-
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + obj_raw_syment_count (output_bfd) * symesz),
- SEEK_SET) != 0
- || bfd_write (finfo->outsyms, symesz, 1, output_bfd) != symesz)
- {
- finfo->failed = true;
- return false;
- }
-
- h->indx = obj_raw_syment_count (output_bfd);
-
- ++obj_raw_syment_count (output_bfd);
-
- /* Write out any associated aux entries. There normally will be
- none. If there are any, I have no idea how to modify them. */
- for (i = 0; i < isym.n_numaux; i++)
- {
- bfd_coff_swap_aux_out (output_bfd, (PTR) (h->aux + i), isym.n_type,
- isym.n_sclass, i, isym.n_numaux,
- (PTR) finfo->outsyms);
- if (bfd_write (finfo->outsyms, symesz, 1, output_bfd) != symesz)
- {
- finfo->failed = true;
- return false;
- }
- ++obj_raw_syment_count (output_bfd);
- }
-
- return true;
-}
-
-/* Handle a link order which is supposed to generate a reloc. */
-
-boolean
-_bfd_coff_reloc_link_order (output_bfd, finfo, output_section, link_order)
- bfd *output_bfd;
- struct coff_final_link_info *finfo;
- asection *output_section;
- struct bfd_link_order *link_order;
-{
- reloc_howto_type *howto;
- struct internal_reloc *irel;
- struct coff_link_hash_entry **rel_hash_ptr;
-
- howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
- if (howto == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- if (link_order->u.reloc.p->addend != 0)
- {
- bfd_size_type size;
- bfd_byte *buf;
- bfd_reloc_status_type rstat;
- boolean ok;
-
- size = bfd_get_reloc_size (howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == NULL)
- return false;
-
- rstat = _bfd_relocate_contents (howto, output_bfd,
- link_order->u.reloc.p->addend, buf);
- switch (rstat)
- {
- case bfd_reloc_ok:
- break;
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- if (! ((*finfo->info->callbacks->reloc_overflow)
- (finfo->info,
- (link_order->type == bfd_section_reloc_link_order
- ? bfd_section_name (output_bfd,
- link_order->u.reloc.p->u.section)
- : link_order->u.reloc.p->u.name),
- howto->name, link_order->u.reloc.p->addend,
- (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
- {
- free (buf);
- return false;
- }
- break;
- }
- ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
- (file_ptr) link_order->offset, size);
- free (buf);
- if (! ok)
- return false;
- }
-
- /* Store the reloc information in the right place. It will get
- swapped and written out at the end of the final_link routine. */
-
- irel = (finfo->section_info[output_section->target_index].relocs
- + output_section->reloc_count);
- rel_hash_ptr = (finfo->section_info[output_section->target_index].rel_hashes
- + output_section->reloc_count);
-
- memset (irel, 0, sizeof (struct internal_reloc));
- *rel_hash_ptr = NULL;
-
- irel->r_vaddr = output_section->vma + link_order->offset;
-
- if (link_order->type == bfd_section_reloc_link_order)
- {
- /* We need to somehow locate a symbol in the right section. The
- symbol must either have a value of zero, or we must adjust
- the addend by the value of the symbol. FIXME: Write this
- when we need it. The old linker couldn't handle this anyhow. */
- abort ();
- *rel_hash_ptr = NULL;
- irel->r_symndx = 0;
- }
- else
- {
- struct coff_link_hash_entry *h;
-
- h = ((struct coff_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (output_bfd, finfo->info,
- link_order->u.reloc.p->u.name,
- false, false, true));
- if (h != NULL)
- {
- if (h->indx >= 0)
- irel->r_symndx = h->indx;
- else
- {
- /* Set the index to -2 to force this symbol to get
- written out. */
- h->indx = -2;
- *rel_hash_ptr = h;
- irel->r_symndx = 0;
- }
- }
- else
- {
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, link_order->u.reloc.p->u.name, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- return false;
- irel->r_symndx = 0;
- }
- }
-
- /* FIXME: Is this always right? */
- irel->r_type = howto->type;
-
- /* r_size is only used on the RS/6000, which needs its own linker
- routines anyhow. r_extern is only used for ECOFF. */
-
- /* FIXME: What is the right value for r_offset? Is zero OK? */
-
- ++output_section->reloc_count;
-
- return true;
-}
-
-/* A basic reloc handling routine which may be used by processors with
- simple relocs. */
-
-boolean
-_bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
- input_section, contents, relocs, syms,
- sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- struct internal_reloc *relocs;
- struct internal_syment *syms;
- asection **sections;
-{
- struct internal_reloc *rel;
- struct internal_reloc *relend;
-
- rel = relocs;
- relend = rel + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- long symndx;
- struct coff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma addend;
- bfd_vma val;
- reloc_howto_type *howto;
- bfd_reloc_status_type rstat;
-
- symndx = rel->r_symndx;
-
- if (symndx == -1)
- {
- h = NULL;
- sym = NULL;
- }
- else
- {
- h = obj_coff_sym_hashes (input_bfd)[symndx];
- sym = syms + symndx;
- }
-
- /* COFF treats common symbols in one of two ways. Either the
- size of the symbol is included in the section contents, or it
- is not. We assume that the size is not included, and force
- the rtype_to_howto function to adjust the addend as needed. */
-
- if (sym != NULL && sym->n_scnum != 0)
- addend = - sym->n_value;
- else
- addend = 0;
-
-
- howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
- sym, &addend);
- if (howto == NULL)
- return false;
-
- val = 0;
-
- if (h == NULL)
- {
- asection *sec;
-
- if (symndx == -1)
- {
- sec = bfd_abs_section_ptr;
- val = 0;
- }
- else
- {
- sec = sections[symndx];
- val = (sec->output_section->vma
- + sec->output_offset
- + sym->n_value
- - sec->vma);
- }
- }
- else
- {
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *sec;
-
- sec = h->root.u.def.section;
- val = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
-
- else if (! info->relocateable)
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
-
- if (info->base_file)
- {
- /* Emit a reloc if the backend thinks it needs it. */
- if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
- {
- /* relocation to a symbol in a section which
- isn't absolute - we output the address here
- to a file */
- bfd_vma addr = rel->r_vaddr
- - input_section->vma
- + input_section->output_offset
- + input_section->output_section->vma;
- if (coff_data(output_bfd)->pe)
- addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
- fwrite (&addr, 1,4, (FILE *) info->base_file);
- }
- }
-
- rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents,
- rel->r_vaddr - input_section->vma,
- val, addend);
-
- switch (rstat)
- {
- default:
- abort ();
- case bfd_reloc_ok:
- break;
- case bfd_reloc_overflow:
- {
- const char *name;
- char buf[SYMNMLEN + 1];
-
- if (symndx == -1)
- name = "*ABS*";
- else if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
- if (name == NULL)
- return false;
- }
-
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0, input_bfd,
- input_section, rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
- }
- return true;
-}
-
diff --git a/contrib/gdb/bfd/configure.bat b/contrib/gdb/bfd/configure.bat
deleted file mode 100644
index 78fe79e..0000000
--- a/contrib/gdb/bfd/configure.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@echo off
-if "%1" == "h8/300" goto h8300
-
-echo Configuring bfd for go32
-update hosts\go32.h sysdep.h
-update Makefile.dos Makefile
-echo s/@WORDSIZE@/32/g>config.sed
-sed -e s/^/s\/@VERSION@\// -e s/$/\/g/g version >>config.sed
-sed -f config.sed < bfd-in2.h > bfd.h2
-update bfd.h2 bfd.h
-goto exit
-
-:h8300
-echo Configuring bfd for H8/300
-update hosts\h-go32.h sysdep.h
-update Makefile.dos Makefile
-
-:exit
diff --git a/contrib/gdb/bfd/cpu-a29k.c b/contrib/gdb/bfd/cpu-a29k.c
deleted file mode 100644
index 5bd25a4..0000000
--- a/contrib/gdb/bfd/cpu-a29k.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* BFD support for the AMD 29000 architecture.
- Copyright 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-const bfd_arch_info_type bfd_a29k_arch =
- {
- 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",
- 4,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-alpha.c b/contrib/gdb/bfd/cpu-alpha.c
deleted file mode 100644
index 0d66a8b..0000000
--- a/contrib/gdb/bfd/cpu-alpha.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD support for the Alpha architecture.
- Copyright 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-const bfd_arch_info_type bfd_alpha_arch =
- {
- 64, /* 32 bits in a word */
- 64, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_alpha,
- 0, /* only 1 machine */
- "alpha",
- "alpha",
- 3,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-arm.c b/contrib/gdb/bfd/cpu-arm.c
deleted file mode 100644
index 92103e6..0000000
--- a/contrib/gdb/bfd/cpu-arm.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* BFD support for the ARM processor
- Copyright 1994 Free Software Foundation, Inc.
- Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-const bfd_arch_info_type bfd_arm_arch =
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_arm,
- 0, /* only 1 machine */
- "arm",
- "arm",
- 4,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-h8300.c b/contrib/gdb/bfd/cpu-h8300.c
deleted file mode 100644
index 380dfb5..0000000
--- a/contrib/gdb/bfd/cpu-h8300.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* BFD library support routines for the Hitachi H8/300 architecture.
- Copyright (C) 1990, 91, 92, 93, 94, 1995 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#if 0 /* not used currently */
-/*
-Relocations for the H8
-
-*/
-static bfd_reloc_status_type
-howto16_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd * abfd;
- arelent * reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection * ignore_input_section;
- bfd * ignore_bfd;
-{
- 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_type
-howto8_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd * abfd;
- arelent * reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection * ignore_input_section;
- bfd * ignore_bfd;
-{
- 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_type
-howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd * abfd;
- arelent * reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection * ignore_input_section;
- bfd * ignore_bfd;
-{
- 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_type
-howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd * abfd;
- arelent * reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection * ignore_input_section;
- bfd * ignore_bfd;
-{
- 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, false, false);
-static reloc_howto_type howto_8
-= NEWHOWTO (howto8_callback, "abs8", 0, false, false);
-
-static reloc_howto_type howto_8_FFnn
-= NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
-
-static reloc_howto_type howto_8_pcrel
-= NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
-
-static reloc_howto_type *
-local_bfd_reloc_type_lookup (arch, code)
- const struct bfd_arch_info *arch;
- bfd_reloc_code_real_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;
- default:
- return (reloc_howto_type *) NULL;
- }
- }
-#endif
-
-int bfd_default_scan_num_mach ();
-
-static boolean
-h8300_scan (info, string)
- const struct bfd_arch_info *info;
- const char *string;
-{
- if (*string != 'h' && *string != 'H')
- return false;
-
- string++;
- if (*string != '8')
- return false;
-
- string++;
- if (*string == '/')
- string++;
-
- if (*string != '3')
- return false;
- string++;
- if (*string != '0')
- return false;
- string++;
- if (*string != '0')
- return false;
- string++;
- if (*string == '-')
- string++;
- if (*string == 'h' || *string == 'H')
- {
- return (info->mach == bfd_mach_h8300h);
- }
- else
- {
- return info->mach == bfd_mach_h8300;
- }
-}
-
-
-/* This routine is provided two arch_infos and works out the
- machine which would be compatible with both and returns a pointer
- to its info structure */
-
-static const bfd_arch_info_type *
-compatible (in, out)
- const bfd_arch_info_type * in;
- const bfd_arch_info_type * out;
-{
- /* If the output is non-H and the input is -H, that's bad */
- if (in->mach == bfd_mach_h8300h &&
- out->mach == bfd_mach_h8300)
- return 0;
-
- /* If either is an -H, the answer is -H */
- if (in->mach == bfd_mach_h8300h)
- return in;
- return out;
-}
-
-static const bfd_arch_info_type h8300_info_struct =
-{
- 16, /* 16 bits in a word */
- 16, /* 16 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_h8300,
- bfd_mach_h8300,
- "h8300", /* arch_name */
- "h8300", /* printable name */
- 1,
- true, /* the default machine */
- compatible,
- h8300_scan,
-/* local_bfd_reloc_type_lookup, */
- 0,
-};
-
-
-const bfd_arch_info_type bfd_h8300_arch =
-{
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_h8300,
- bfd_mach_h8300h,
- "h8300h", /* arch_name */
- "h8300h", /* printable name */
- 1,
- false, /* the default machine */
- compatible,
- h8300_scan,
-/* local_bfd_reloc_type_lookup, */
- &h8300_info_struct,
-};
diff --git a/contrib/gdb/bfd/cpu-h8500.c b/contrib/gdb/bfd/cpu-h8500.c
deleted file mode 100644
index e4abfd1..0000000
--- a/contrib/gdb/bfd/cpu-h8500.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/* BFD library support routines for the H8/500 architecture.
- Copyright (C) 1993 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#if 0
-
-/*
-Relocations for the Z8K
-
-*/
-static bfd_reloc_status_type
-howto16_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection *ignore_input_section;
- bfd *ignore_bfd;
-{
- 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_type
-howto8_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection *ignore_input_section;
- bfd *ignore_bfd;
-{
- 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_type
-howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection *ignore_input_section;
- bfd *ignore_bfd;
-{
- 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_type
-howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection *ignore_input_section;
- bfd *ignore_bfd;
-{
- 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,false,false);
-static reloc_howto_type howto_8
- = NEWHOWTO(howto8_callback,"abs8",0,false,false);
-
-static reloc_howto_type howto_8_FFnn
- = NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,false,false);
-
-static reloc_howto_type howto_8_pcrel
- = NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,false,true);
-
-
-static reloc_howto_type *
-local_bfd_reloc_type_lookup (arch, code)
- const struct bfd_arch_info *arch;
- bfd_reloc_code_real_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;
-}
-#endif
-
-int bfd_default_scan_num_mach();
-
-static boolean
-scan_mach (info, string)
- const struct bfd_arch_info *info;
- const char *string;
-{
- if (strcmp(string,"h8/500") == 0) return true;
- if (strcmp(string,"H8/500") == 0) return true;
- if (strcmp(string,"h8500") == 0) return true;
- if (strcmp(string,"H8500") == 0) return true;
- return false;
-}
-
-
-#if 0 /* not used currently */
-/* This routine is provided two arch_infos and returns whether
- they'd be compatible */
-
-static const bfd_arch_info_type *
-compatible (a,b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- if (a->arch != b->arch || a->mach != b->mach)
- return NULL;
- return a;
-}
-#endif
-
-const bfd_arch_info_type bfd_h8500_arch =
-{
- 16, /* 16 bits in a word */
- 24, /* 24 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_h8500,
- 0, /* only 1 machine */
- "h8500", /* arch_name */
- "h8500", /* printable name */
- 1,
- true, /* the default machine */
- bfd_default_compatible,
- scan_mach,
- 0,
-};
diff --git a/contrib/gdb/bfd/cpu-hppa.c b/contrib/gdb/bfd/cpu-hppa.c
deleted file mode 100644
index 5201008..0000000
--- a/contrib/gdb/bfd/cpu-hppa.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* BFD support for the HP Precision Architecture architecture.
- Copyright 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-static const bfd_arch_info_type bfd_hppa10_arch =
-{
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_hppa,
- 10, /* By convention PA1.0 = 10 */
- "hppa",
- "hppa1.0",
- 3,
- true, /* Unless we use 1.1 specific features */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
-};
-
-const bfd_arch_info_type bfd_hppa_arch =
-{
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_hppa,
- 11, /* By convention PA1.1 = 11 */
- "hppa",
- "hppa1.1",
- 3,
- false, /* 1.1 specific features used */
- bfd_default_compatible,
- bfd_default_scan ,
- &bfd_hppa10_arch,
-};
diff --git a/contrib/gdb/bfd/cpu-i860.c b/contrib/gdb/bfd/cpu-i860.c
deleted file mode 100644
index 57c867c..0000000
--- a/contrib/gdb/bfd/cpu-i860.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* BFD support for the Intel 860 architecture.
- Copyright 1992, 1995 Free Software Foundation, Inc.
- Created mostly by substituting "860" for "386" in cpu-i386.c
- Harry Dolan <dolan@ssd.intel.com>, October 1995
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-const bfd_arch_info_type bfd_i860_arch =
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_i860,
- 0, /* only 1 machine */
- "i860",
- "i860",
- 3,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-i960.c b/contrib/gdb/bfd/cpu-i960.c
deleted file mode 100644
index 6970f89..0000000
--- a/contrib/gdb/bfd/cpu-i960.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* BFD library support routines for the i960 architecture.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#include "bfd.h"
-#include "sysdep.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
-scan_960_mach (ap, string)
- const bfd_arch_info_type *ap;
- const char *string;
-{
- unsigned long machine;
-
- /* Look for the string i960, or somesuch at the front of the string */
-
- if (strncmp("i960",string,4) == 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 if (string[0] == 'j' && string[1] == 'x')
- machine = bfd_mach_i960_jx;
- else if (string[0] == 'h' && string[1] == 'x')
- machine = bfd_mach_i960_hx;
- 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 */
-
-static const bfd_arch_info_type *
-compatible (a,b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
-
- /* The i960 has distinct subspecies which may not interbreed:
- CORE CA
- CORE KA KB MC XA
- CORE HX JX
- 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*/
-#define JX bfd_mach_i960_jx /*7*/
-#define HX bfd_mach_i960_hx /*8*/
-#define MAX_ARCH ((int)HX)
-
- static CONST unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
- {
- { ERROR, CORE, KA, KB, MC, XA, CA, JX, HX },
- { CORE, CORE, KA, KB, MC, XA, CA, JX, HX },
- { KA, KA, KA, KB, MC, XA, ERROR, ERROR, ERROR},
- { KB, KB, KB, KB, MC, XA, ERROR, ERROR, ERROR},
- { MC, MC, MC, MC, MC, XA, ERROR, ERROR, ERROR},
- { XA, XA, XA, XA, XA, XA, ERROR, ERROR, ERROR},
- { CA, CA, ERROR, ERROR, ERROR, ERROR, CA, ERROR, ERROR},
- { JX, JX, ERROR, ERROR, ERROR, ERROR, ERROR, JX, HX },
- { HX, HX, ERROR, ERROR, ERROR, ERROR, ERROR, HX, HX },
- };
-
-
- if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR)
- {
- return NULL;
- }
- else
- {
- return (a->mach == matrix[a->mach][b->mach]) ? a : b;
- }
-}
-
-
-
-int bfd_default_scan_num_mach();
-#define N(a,b,d,n) \
-{ 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,}
-
-static const bfd_arch_info_type arch_info_struct[] =
-{
- N(bfd_mach_i960_ka_sa,"i960:ka_sa",false, &arch_info_struct[1]),
- N(bfd_mach_i960_kb_sb,"i960:kb_sb",false, &arch_info_struct[2]),
- N(bfd_mach_i960_mc, "i960:mc", false, &arch_info_struct[3]),
- N(bfd_mach_i960_xa, "i960:xa", false, &arch_info_struct[4]),
- N(bfd_mach_i960_ca, "i960:ca", false, &arch_info_struct[5]),
- N(bfd_mach_i960_jx, "i960:jx", false, &arch_info_struct[6]),
- N(bfd_mach_i960_hx, "i960:hx", false, 0),
-};
-
-const bfd_arch_info_type bfd_i960_arch =
- N(bfd_mach_i960_core, "i960:core", true, &arch_info_struct[0]);
diff --git a/contrib/gdb/bfd/cpu-m68k.c b/contrib/gdb/bfd/cpu-m68k.c
deleted file mode 100644
index 17a3739..0000000
--- a/contrib/gdb/bfd/cpu-m68k.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* BFD library support routines for architectures.
- Copyright (C) 1990, 91, 92, 93, 94 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-int bfd_default_scan_num_mach();
-
-
-#define N(name, print,d,next) \
-{ 32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_default_compatible,bfd_default_scan, next, }
-
-static const bfd_arch_info_type arch_info_struct[] =
-{
- N(68008,"m68k:68008",false, &arch_info_struct[1]),
- N(68010,"m68k:68010",false, &arch_info_struct[2]),
- N(68020,"m68k:68020",true, &arch_info_struct[3]),
- N(68030,"m68k:68030",false, &arch_info_struct[4]),
- N(68040,"m68k:68040",false, &arch_info_struct[5]),
- N(68070,"m68k:68070",false, 0),
-};
-
-const bfd_arch_info_type bfd_m68k_arch =
- N(68000,"m68k:68000",false, &arch_info_struct[0]);
diff --git a/contrib/gdb/bfd/cpu-m88k.c b/contrib/gdb/bfd/cpu-m88k.c
deleted file mode 100644
index c3716c5..0000000
--- a/contrib/gdb/bfd/cpu-m88k.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* bfd back-end for m88k support
- Copyright (C) 1990, 91, 92, 93, 94 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-
-
-
-const bfd_arch_info_type bfd_m88k_arch =
- {
- 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",
- 3,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-mips.c b/contrib/gdb/bfd/cpu-mips.c
deleted file mode 100644
index 5e19342..0000000
--- a/contrib/gdb/bfd/cpu-mips.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* bfd back-end for mips support
- Copyright (C) 1990, 91, 92, 93, 94 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-static const 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_mips,
- 6000,
- "mips",
- "mips:6000",
- 3,
- false,
- bfd_default_compatible,
- bfd_default_scan,
- &arch_info_struct[1],
- },
- {
- 64, /* 64 bits in a word */
- 64, /* 64 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_mips,
- 4000,
- "mips",
- "mips:4000",
- 3,
- false,
- bfd_default_compatible,
- bfd_default_scan ,
- &arch_info_struct[2],
- },
- {
- 64, /* 64 bits in a word */
- 64, /* 64 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_mips,
- 8000,
- "mips",
- "mips:8000",
- 3,
- false,
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- }
-};
-
-const bfd_arch_info_type bfd_mips_arch =
-{
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_mips,
- 3000,
- "mips",
- "mips:3000",
- 3,
- true,
- bfd_default_compatible,
- bfd_default_scan,
- &arch_info_struct[0],
-};
diff --git a/contrib/gdb/bfd/cpu-ns32k.c b/contrib/gdb/bfd/cpu-ns32k.c
deleted file mode 100644
index e18e3cf..0000000
--- a/contrib/gdb/bfd/cpu-ns32k.c
+++ /dev/null
@@ -1,868 +0,0 @@
-/* BFD support for the ns32k architecture.
- Copyright (C) 1990, 1991, 1994, 1995 Free Software Foundation, Inc.
- Almost totally rewritten by Ian Dall from initial work
- by Andrew Cagney.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-long ns32k_get_displacement PARAMS ((bfd_byte *buffer, long offset, long size));
-int ns32k_put_displacement PARAMS ((long value, bfd_byte *buffer, long offset, long size));
-long ns32k_get_immediate PARAMS ((bfd_byte *buffer, long offset, long size));
-int ns32k_put_immediate PARAMS ((long value, bfd_byte *buffer, long offset, long size));
-bfd_reloc_status_type
- ns32k_reloc_disp PARAMS ((bfd *abfd, arelent *reloc_entry,
- struct symbol_cache_entry *symbol,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-bfd_reloc_status_type
- ns32k_reloc_imm PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- struct symbol_cache_entry *symbol,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-bfd_reloc_status_type ns32k_final_link_relocate PARAMS ((reloc_howto_type *howto,
- bfd *input_bfd,
- asection *input_section,
- bfd_byte *contents,
- bfd_vma address,
- bfd_vma value,
- bfd_vma addend ));
-bfd_reloc_status_type ns32k_relocate_contents PARAMS ((reloc_howto_type *howto,
- bfd *input_bfd,
- bfd_vma relocation,
- bfd_byte *location));
-
-int bfd_default_scan_num_mach();
-
-#define N(machine, printable, d, next) \
-{ 32, 32, 8, bfd_arch_ns32k, machine, "ns32k",printable,3,d,bfd_default_compatible,bfd_default_scan, next, }
-
-static const bfd_arch_info_type arch_info_struct[] =
-{
- N(32532,"ns32k:32532",true, 0), /* the word ns32k will match this too */
-};
-
-const bfd_arch_info_type bfd_ns32k_arch =
- N(32032,"ns32k:32032",false, &arch_info_struct[0]);
-
-static long
-ns32k_sign_extend(value, bits)
- int value;
- int bits;
-{
- value = value & ((1 << bits) - 1);
- return (value & (1 << (bits-1))
- ? value | (~((1 << bits) - 1))
- : value);
-}
-
-long
-ns32k_get_displacement(buffer, offset, size)
- bfd_byte *buffer;
- long offset;
- long size;
-{
- long value;
- buffer += offset;
- switch (size)
- {
- case 1:
- value = ns32k_sign_extend (*buffer, 7);
- break;
- case 2:
- value = ns32k_sign_extend(*buffer++, 6);
- value = (value << 8) | (0xff & *buffer);
- break;
- case 4:
- value = ns32k_sign_extend(*buffer++, 6);
- value = (value << 8) | (0xff & *buffer++);
- value = (value << 8) | (0xff & *buffer++);
- value = (value << 8) | (0xff & *buffer);
- break;
- }
- return value;
-}
-
-int
-ns32k_put_displacement(value, buffer, offset, size)
- long value;
- bfd_byte *buffer;
- long offset;
- long size;
-{
- buffer += offset;
- switch (size)
- {
- case 1:
- if (value < -64 || value > 63)
- return -1;
- value&=0x7f;
- *buffer++=value;
- break;
- case 2:
- if (value < -8192 || value > 8191)
- return -1;
- value&=0x3fff;
- value|=0x8000;
- *buffer++=(value>>8);
- *buffer++=value;
- break;
- case 4:
- if (value < -0x1f000000 || value >= 0x20000000)
- return -1;
- value|=0xc0000000;
- *buffer++=(value>>24);
- *buffer++=(value>>16);
- *buffer++=(value>>8);
- *buffer++=value;
- break;
- default:
- return -1;
- }
- return 0;
-}
-
-long
-ns32k_get_immediate(buffer, offset, size)
- bfd_byte *buffer;
- long offset;
- long size;
-{
- long value = 0;
- buffer += offset;
- switch (size)
- {
- case 4:
- value = (value << 8) | (*buffer++ & 0xff);
- case 3:
- value = (value << 8) | (*buffer++ & 0xff);
- case 2:
- value = (value << 8) | (*buffer++ & 0xff);
- case 1:
- value = (value << 8) | (*buffer++ & 0xff);
- }
- return value;
-}
-
-int
-ns32k_put_immediate (value, buffer, offset, size)
- long value;
- bfd_byte *buffer;
- long offset;
- long size;
-{
- buffer += offset + size - 1;
- switch (size)
- {
- case 4:
- *buffer-- = (value & 0xff); value >>= 8;
- case 3:
- *buffer-- = (value & 0xff); value >>= 8;
- case 2:
- *buffer-- = (value & 0xff); value >>= 8;
- case 1:
- *buffer-- = (value & 0xff); value >>= 8;
- }
- return 0;
-}
-
-/* This is just like the standard perform_relocation except we
- * use get_data and put_data which know about the ns32k
- * storage methods.
- * This is probably a lot more complicated than it needs to be!
- */
-static bfd_reloc_status_type
-do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
- error_message, get_data, put_data)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
- long (*get_data)();
- int (*put_data)();
-{
- int overflow = 0;
- bfd_vma relocation;
- bfd_reloc_status_type flag = bfd_reloc_ok;
- bfd_size_type addr = reloc_entry->address;
- bfd_vma output_base = 0;
- reloc_howto_type *howto = reloc_entry->howto;
- asection *reloc_target_output_section;
-
- if ((symbol->section == &bfd_abs_section)
- && output_bfd != (bfd *) NULL)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* If we are not producing relocateable output, return an error if
- the symbol is not defined. An undefined weak symbol is
- considered to have a value of zero (SVR4 ABI, p. 4-27). */
- if (symbol->section == &bfd_und_section
- && (symbol->flags & BSF_WEAK) == 0
- && output_bfd == (bfd *) NULL)
- flag = bfd_reloc_undefined;
-
-
- /* Is the address of the relocation really within the section? */
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* Work out which section the relocation is targetted at and the
- initial relocation command value. */
-
- /* Get symbol value. (Common symbols are special.) */
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
-
- reloc_target_output_section = symbol->section->output_section;
-
- /* Convert input-section-relative symbol value to absolute. */
- if (output_bfd && howto->partial_inplace == false)
- output_base = 0;
- else
- output_base = reloc_target_output_section->vma;
-
- relocation += output_base + symbol->section->output_offset;
-
- /* Add in supplied addend. */
- relocation += reloc_entry->addend;
-
- /* Here the variable relocation holds the final address of the
- symbol we are relocating against, plus any addend. */
-
- if (howto->pc_relative == true)
- {
- /* This is a PC relative relocation. We want to set RELOCATION
- to the distance between the address of the symbol and the
- location. RELOCATION is already the address of the symbol.
-
- We start by subtracting the address of the section containing
- the location.
-
- If pcrel_offset is set, we must further subtract the position
- of the location within the section. Some targets arrange for
- the addend to be the negative of the position of the location
- within the section; for example, i386-aout does this. For
- i386-aout, pcrel_offset is false. Some other targets do not
- include the position of the location; for example, m88kbcs,
- or ELF. For those targets, pcrel_offset is true.
-
- If we are producing relocateable output, then we must ensure
- that this reloc will be correctly computed when the final
- relocation is done. If pcrel_offset is false we want to wind
- up with the negative of the location within the section,
- which means we must adjust the existing addend by the change
- in the location within the section. If pcrel_offset is true
- we do not want to adjust the existing addend at all.
-
- FIXME: This seems logical to me, but for the case of
- producing relocateable output it is not what the code
- actually does. I don't want to change it, because it seems
- far too likely that something will break. */
-
- 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->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. */
-
- reloc_entry->address += input_section->output_offset;
-
- /* WTF?? */
- if (abfd->xvec->flavour == bfd_target_coff_flavour
- && strcmp (abfd->xvec->name, "aixcoff-rs6000") != 0)
- {
-#if 1
- /* For m68k-coff, the addend was being subtracted twice during
- relocation with -r. Removing the line below this comment
- fixes that problem; see PR 2953.
-
-However, Ian wrote the following, regarding removing the line below,
-which explains why it is still enabled: --djm
-
-If you put a patch like that into BFD you need to check all the COFF
-linkers. I am fairly certain that patch will break coff-i386 (e.g.,
-SCO); see coff_i386_reloc in coff-i386.c where I worked around the
-problem in a different way. There may very well be a reason that the
-code works as it does.
-
-Hmmm. The first obvious point is that bfd_perform_relocation should
-not have any tests that depend upon the flavour. It's seem like
-entirely the wrong place for such a thing. The second obvious point
-is that the current code ignores the reloc addend when producing
-relocateable output for COFF. That's peculiar. In fact, I really
-have no idea what the point of the line you want to remove is.
-
-A typical COFF reloc subtracts the old value of the symbol and adds in
-the new value to the location in the object file (if it's a pc
-relative reloc it adds the difference between the symbol value and the
-location). When relocating we need to preserve that property.
-
-BFD handles this by setting the addend to the negative of the old
-value of the symbol. Unfortunately it handles common symbols in a
-non-standard way (it doesn't subtract the old value) but that's a
-different story (we can't change it without losing backward
-compatibility with old object files) (coff-i386 does subtract the old
-value, to be compatible with existing coff-i386 targets, like SCO).
-
-So everything works fine when not producing relocateable output. When
-we are producing relocateable output, logically we should do exactly
-what we do when not producing relocateable output. Therefore, your
-patch is correct. In fact, it should probably always just set
-reloc_entry->addend to 0 for all cases, since it is, in fact, going to
-add the value into the object file. This won't hurt the COFF code,
-which doesn't use the addend; I'm not sure what it will do to other
-formats (the thing to check for would be whether any formats both use
-the addend and set partial_inplace).
-
-When I wanted to make coff-i386 produce relocateable output, I ran
-into the problem that you are running into: I wanted to remove that
-line. Rather than risk it, I made the coff-i386 relocs use a special
-function; it's coff_i386_reloc in coff-i386.c. The function
-specifically adds the addend field into the object file, knowing that
-bfd_perform_relocation is not going to. If you remove that line, then
-coff-i386.c will wind up adding the addend field in twice. It's
-trivial to fix; it just needs to be done.
-
-The problem with removing the line is just that it may break some
-working code. With BFD it's hard to be sure of anything. The right
-way to deal with this is simply to build and test at least all the
-supported COFF targets. It should be straightforward if time and disk
-space consuming. For each target:
- 1) build the linker
- 2) generate some executable, and link it using -r (I would
- probably use paranoia.o and link against newlib/libc.a, which
- for all the supported targets would be available in
- /usr/cygnus/progressive/H-host/target/lib/libc.a).
- 3) make the change to reloc.c
- 4) rebuild the linker
- 5) repeat step 2
- 6) if the resulting object files are the same, you have at least
- made it no worse
- 7) if they are different you have to figure out which version is
- right
-*/
- relocation -= reloc_entry->addend;
-#endif
- reloc_entry->addend = 0;
- }
- else
- {
- reloc_entry->addend = relocation;
- }
- }
- }
- else
- {
- reloc_entry->addend = 0;
- }
-
- /* FIXME: This overflow checking is incomplete, because the value
- might have overflowed before we get here. For a correct check we
- need to compute the value in a size larger than bitsize, but we
- can't reasonably do that for a reloc the same size as a host
- machine word.
- FIXME: We should also do overflow checking on the result after
- adding in the value contained in the object file. */
- if (howto->complain_on_overflow != complain_overflow_dont)
- {
- bfd_vma check;
-
- /* Get the value that will be used for the relocation, but
- starting at bit position zero. */
- if (howto->rightshift > howto->bitpos)
- check = relocation >> (howto->rightshift - howto->bitpos);
- else
- check = relocation << (howto->bitpos - howto->rightshift);
- switch (howto->complain_on_overflow)
- {
- case complain_overflow_signed:
- {
- /* Assumes two's complement. */
- bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
- bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
-
- /* The above right shift is incorrect for a signed value.
- Fix it up by forcing on the upper bits. */
- if (howto->rightshift > howto->bitpos
- && (bfd_signed_vma) relocation < 0)
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> (howto->rightshift - howto->bitpos)));
- if ((bfd_signed_vma) check > reloc_signed_max
- || (bfd_signed_vma) check < reloc_signed_min)
- flag = bfd_reloc_overflow;
- }
- break;
- case complain_overflow_unsigned:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_unsigned_max =
- (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if ((bfd_vma) check > reloc_unsigned_max)
- flag = bfd_reloc_overflow;
- }
- break;
- case complain_overflow_bitfield:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if (((bfd_vma) check & ~reloc_bits) != 0
- && ((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
- {
- /* The above right shift is incorrect for a signed
- value. See if turning on the upper bits fixes the
- overflow. */
- if (howto->rightshift > howto->bitpos
- && (bfd_signed_vma) relocation < 0)
- {
- check |= ((bfd_vma) - 1
- & ~((bfd_vma) - 1
- >> (howto->rightshift - howto->bitpos)));
- if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
- flag = bfd_reloc_overflow;
- }
- else
- flag = bfd_reloc_overflow;
- }
- }
- break;
- default:
- abort ();
- }
- }
-
- /*
- 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)
- */
-
- /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler
- (OSF version 1.3, compiler version 3.11). It miscompiles the
- following program:
-
- struct str
- {
- unsigned int i0;
- } s = { 0 };
-
- int
- main ()
- {
- unsigned long x;
-
- x = 0x100000000;
- x <<= (unsigned long) s.i0;
- if (x == 0)
- printf ("failed\n");
- else
- printf ("succeeded (%lx)\n", x);
- }
- */
-
- relocation >>= (bfd_vma) howto->rightshift;
-
- /* Shift everything up to where it's going to be used */
-
- relocation <<= (bfd_vma) 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<size>
- 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<size>
- 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<size>
- */
-
-#define DOIT(x) \
- x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
-
- switch (howto->size)
- {
- case 0:
- {
- char x = get_data (data, addr, 1);
- DOIT (x);
- overflow = put_data(x, data, addr, 1);
- }
- break;
-
- case 1:
- if (relocation)
- {
- short x = get_data (data, addr, 2);
- DOIT (x);
- overflow = put_data(x, (unsigned char *) data, addr, 2);
- }
- break;
- case 2:
- if (relocation)
- {
- long x = get_data (data, addr, 4);
- DOIT (x);
- overflow = put_data(x, data, addr, 4);
- }
- break;
- case -2:
- {
- long x = get_data(data, addr, 4);
- relocation = -relocation;
- DOIT(x);
- overflow = put_data(x, data , addr, 4);
- }
- break;
-
- case 3:
- /* Do nothing */
- break;
-
- case 4:
-#ifdef BFD64
- if (relocation)
- {
- bfd_vma x = get_data (data, addr, 8);
- DOIT (x);
- overflow = put_data(x, data, addr, 8);
- }
-#else
- abort ();
-#endif
- break;
- default:
- return bfd_reloc_other;
- }
- if ((howto->complain_on_overflow != complain_overflow_dont) && overflow)
- return bfd_reloc_overflow;
-
- return flag;
-}
-
-/* Relocate a given location using a given value and howto. */
-
-bfd_reloc_status_type
-do_ns32k_reloc_contents ( howto, input_bfd, relocation, location, get_data,
- put_data)
- reloc_howto_type *howto;
- bfd *input_bfd;
- bfd_vma relocation;
- bfd_byte *location;
- long (*get_data)();
- int (*put_data)();
-{
- int size;
- bfd_vma x;
- boolean overflow;
-
- /* If the size is negative, negate RELOCATION. This isn't very
- general. */
- if (howto->size < 0)
- relocation = -relocation;
-
- /* Get the value we are going to relocate. */
- size = bfd_get_reloc_size (howto);
- switch (size)
- {
- default:
- case 0:
- abort ();
- case 1:
- case 2:
- case 4:
-#ifdef BFD64
- case 8:
-#endif
- x = get_data (location, 0, size);
- break;
- }
-
- /* Check for overflow. FIXME: We may drop bits during the addition
- which we don't check for. We must either check at every single
- operation, which would be tedious, or we must do the computations
- in a type larger than bfd_vma, which would be inefficient. */
- overflow = false;
- if (howto->complain_on_overflow != complain_overflow_dont)
- {
- bfd_vma check;
- bfd_signed_vma signed_check;
- bfd_vma add;
- bfd_signed_vma signed_add;
-
- if (howto->rightshift == 0)
- {
- check = relocation;
- signed_check = (bfd_signed_vma) relocation;
- }
- else
- {
- /* Drop unwanted bits from the value we are relocating to. */
- check = relocation >> howto->rightshift;
-
- /* If this is a signed value, the rightshift just dropped
- leading 1 bits (assuming twos complement). */
- if ((bfd_signed_vma) relocation >= 0)
- signed_check = check;
- else
- signed_check = (check
- | ((bfd_vma) - 1
- & ~((bfd_vma) - 1 >> howto->rightshift)));
- }
-
- /* Get the value from the object file. */
- add = x & howto->src_mask;
-
- /* Get the value from the object file with an appropriate sign.
- The expression involving howto->src_mask isolates the upper
- bit of src_mask. If that bit is set in the value we are
- adding, it is negative, and we subtract out that number times
- two. If src_mask includes the highest possible bit, then we
- can not get the upper bit, but that does not matter since
- signed_add needs no adjustment to become negative in that
- case. */
- signed_add = add;
- if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
- signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
-
- /* Add the value from the object file, shifted so that it is a
- straight number. */
- if (howto->bitpos == 0)
- {
- check += add;
- signed_check += signed_add;
- }
- else
- {
- check += add >> howto->bitpos;
-
- /* For the signed case we use ADD, rather than SIGNED_ADD,
- to avoid warnings from SVR4 cc. This is OK since we
- explictly handle the sign bits. */
- if (signed_add >= 0)
- signed_check += add >> howto->bitpos;
- else
- signed_check += ((add >> howto->bitpos)
- | ((bfd_vma) - 1
- & ~((bfd_vma) - 1 >> howto->bitpos)));
- }
-
- switch (howto->complain_on_overflow)
- {
- case complain_overflow_signed:
- {
- /* Assumes two's complement. */
- bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
- bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
-
- if (signed_check > reloc_signed_max
- || signed_check < reloc_signed_min)
- overflow = true;
- }
- break;
- case complain_overflow_unsigned:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_unsigned_max =
- (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if (check > reloc_unsigned_max)
- overflow = true;
- }
- break;
- case complain_overflow_bitfield:
- {
- /* Assumes two's complement. This expression avoids
- overflow if howto->bitsize is the number of bits in
- bfd_vma. */
- bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
-
- if ((check & ~reloc_bits) != 0
- && (((bfd_vma) signed_check & ~reloc_bits)
- != (-1 & ~reloc_bits)))
- overflow = true;
- }
- break;
- default:
- abort ();
- }
- }
-
- /* Put RELOCATION in the right bits. */
- relocation >>= (bfd_vma) howto->rightshift;
- relocation <<= (bfd_vma) howto->bitpos;
-
- /* Add RELOCATION to the right bits of X. */
- x = ((x & ~howto->dst_mask)
- | (((x & howto->src_mask) + relocation) & howto->dst_mask));
-
- /* Put the relocated value back in the object file. */
- switch (size)
- {
- default:
- case 0:
- abort ();
- case 1:
- case 2:
- case 4:
-#ifdef BFD64
- case 8:
-#endif
- put_data(x, location, 0, size);
- break;
- }
-
- return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
-}
-
-bfd_reloc_status_type
-ns32k_reloc_disp(abfd, reloc_entry, symbol, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- return do_ns32k_reloc(abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, ns32k_get_displacement, ns32k_put_displacement);
-}
-
-bfd_reloc_status_type
-ns32k_reloc_imm (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- return do_ns32k_reloc(abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, ns32k_get_immediate, ns32k_put_immediate);
-}
-
-bfd_reloc_status_type
-ns32k_final_link_relocate (howto, input_bfd, input_section, contents, address, value, addend )
- reloc_howto_type *howto;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- bfd_vma address;
- bfd_vma value;
- bfd_vma addend;
-{
- bfd_vma relocation;
-
- /* Sanity check the address. */
- if (address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* This function assumes that we are dealing with a basic relocation
- against a symbol. We want to compute the value of the symbol to
- relocate to. This is just VALUE, the value of the symbol, plus
- ADDEND, any addend associated with the reloc. */
- relocation = value + addend;
-
- /* If the relocation is PC relative, we want to set RELOCATION to
- the distance between the symbol (currently in RELOCATION) and the
- location we are relocating. Some targets (e.g., i386-aout)
- arrange for the contents of the section to be the negative of the
- offset of the location within the section; for such targets
- pcrel_offset is false. Other targets (e.g., m88kbcs or ELF)
- simply leave the contents of the section as zero; for such
- targets pcrel_offset is true. If pcrel_offset is false we do not
- need to subtract out the offset of the location within the
- section (which is just ADDRESS). */
- if (howto->pc_relative)
- {
- relocation -= (input_section->output_section->vma
- + input_section->output_offset);
- if (howto->pcrel_offset)
- relocation -= address;
- }
-
- return ns32k_relocate_contents (howto, input_bfd, relocation,
- contents + address);
-}
diff --git a/contrib/gdb/bfd/cpu-powerpc.c b/contrib/gdb/bfd/cpu-powerpc.c
deleted file mode 100644
index 11f0f80..0000000
--- a/contrib/gdb/bfd/cpu-powerpc.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* BFD PowerPC CPU definition
- Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
- Contributed by Ian Lance Taylor, Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/* The common PowerPC architecture is compatible with the RS/6000. */
-
-static const bfd_arch_info_type *powerpc_compatible
- PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
-static const bfd_arch_info_type *
-powerpc_compatible (a,b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- BFD_ASSERT (a->arch == bfd_arch_powerpc);
- switch (b->arch)
- {
- default:
- return NULL;
- case bfd_arch_powerpc:
- return bfd_default_compatible (a, b);
- case bfd_arch_rs6000:
- if (a->mach == 0)
- return a;
- return NULL;
- }
- /*NOTREACHED*/
-}
-
-static const 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_powerpc,
- 603, /* for the mpc603 */
- "powerpc",
- "powerpc:603",
- 3,
- false, /* not the default */
- powerpc_compatible,
- bfd_default_scan,
- &arch_info_struct[1]
- },
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_powerpc,
- 604, /* for the mpc604 */
- "powerpc",
- "powerpc:604",
- 3,
- false, /* not the default */
- powerpc_compatible,
- bfd_default_scan,
- &arch_info_struct[2]
- },
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_powerpc,
- 403, /* for the 403 */
- "powerpc",
- "powerpc:403",
- 3,
- false, /* not the default */
- powerpc_compatible,
- bfd_default_scan,
- &arch_info_struct[3]
- },
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_powerpc,
- 601, /* for the mpc601 */
- "powerpc",
- "powerpc:601",
- 3,
- false, /* not the default */
- powerpc_compatible,
- bfd_default_scan,
- 0
- }
-};
-
-const bfd_arch_info_type bfd_powerpc_arch =
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_powerpc,
- 0, /* for the POWER/PowerPC common architecture */
- "powerpc",
- "powerpc:common",
- 3,
- true, /* the default */
- powerpc_compatible,
- bfd_default_scan,
- &arch_info_struct[0]
- };
diff --git a/contrib/gdb/bfd/cpu-rs6000.c b/contrib/gdb/bfd/cpu-rs6000.c
deleted file mode 100644
index 9852ae9..0000000
--- a/contrib/gdb/bfd/cpu-rs6000.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* BFD back-end for rs6000 support
- Copyright (C) 1990, 1991 Free Software Foundation, Inc.
- FIXME: Can someone provide a transliteration of this name into ASCII?
- Using the following chars caused a compiler warning on HIUX (so I replaced
- them with octal escapes), and isn't useful without an understanding of what
- character set it is.
- Written by Mimi Ph\373\364ng-Th\345o V\365 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/* The RS/6000 architecture is compatible with the PowerPC common
- architecture. */
-
-static const bfd_arch_info_type *rs6000_compatible
- PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
-static const bfd_arch_info_type *
-rs6000_compatible (a,b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- BFD_ASSERT (a->arch == bfd_arch_rs6000);
- switch (b->arch)
- {
- default:
- return NULL;
- case bfd_arch_rs6000:
- return bfd_default_compatible (a, b);
- case bfd_arch_powerpc:
- if (b->mach == 0)
- return b;
- return NULL;
- }
- /*NOTREACHED*/
-}
-
-const bfd_arch_info_type bfd_rs6000_arch =
- {
- 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",
- 3,
- true, /* the one and only */
- rs6000_compatible,
- bfd_default_scan,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-sh.c b/contrib/gdb/bfd/cpu-sh.c
deleted file mode 100644
index 7f6dd68..0000000
--- a/contrib/gdb/bfd/cpu-sh.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* BFD library support routines for the Hitachi-SH architecture.
- Copyright (C) 1993 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-
-int bfd_default_scan_num_mach();
-
-static boolean
-scan_mach (info, string)
- const struct bfd_arch_info *info;
- const char *string;
-{
- if (strcmp(string,"sh") == 0) return true;
- if (strcmp(string,"SH") == 0) return true;
- return false;
-}
-
-
-#if 0
-/* This routine is provided two arch_infos and returns whether
- they'd be compatible */
-
-static const bfd_arch_info_type *
-compatible (a,b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- if (a->arch != b->arch || a->mach != b->mach)
- return NULL;
- return a;
-}
-#endif
-
-const bfd_arch_info_type bfd_sh_arch =
-{
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_sh,
- 0, /* only 1 machine */
- "sh", /* arch_name */
- "sh", /* printable name */
- 1,
- true, /* the default machine */
- bfd_default_compatible,
- scan_mach,
- 0,
-};
diff --git a/contrib/gdb/bfd/cpu-sparc.c b/contrib/gdb/bfd/cpu-sparc.c
deleted file mode 100644
index e48aa5e..0000000
--- a/contrib/gdb/bfd/cpu-sparc.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/* BFD support for the SPARC architecture.
- Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/* Don't mix 32 bit and 64 bit files. */
-
-static const bfd_arch_info_type *
-sparc_compatible (a, b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- if (a->bits_per_word != b->bits_per_word)
- return NULL;
-
- return bfd_default_compatible (a, b);
-}
-
-static const bfd_arch_info_type arch_info_struct[] =
-{
- {
- 32, /* bits in a word */
- 32, /* bits in an address */
- 8, /* bits in a byte */
- bfd_arch_sparc,
- bfd_mach_sparc_v8plus,
- "sparc",
- "sparc:v8plus",
- 3,
- false,
- sparc_compatible,
- bfd_default_scan,
- &arch_info_struct[1],
- },
- {
- 32, /* bits in a word */
- 32, /* bits in an address */
- 8, /* bits in a byte */
- bfd_arch_sparc,
- bfd_mach_sparc_v8plusa,
- "sparc",
- "sparc:v8plusa",
- 3,
- false,
- sparc_compatible,
- bfd_default_scan,
- &arch_info_struct[2],
- },
- {
- 64, /* bits in a word */
- 64, /* bits in an address */
- 8, /* bits in a byte */
- bfd_arch_sparc,
- bfd_mach_sparc_v9,
- "sparc",
- "sparc:v9",
- 3,
- false,
- sparc_compatible,
- bfd_default_scan,
- &arch_info_struct[3],
- },
- {
- 64, /* bits in a word */
- 64, /* bits in an address */
- 8, /* bits in a byte */
- bfd_arch_sparc,
- bfd_mach_sparc_v9a,
- "sparc",
- "sparc:v9a",
- 3,
- false,
- sparc_compatible,
- bfd_default_scan,
- 0,
- }
-};
-
-const bfd_arch_info_type bfd_sparc_arch =
- {
- 32, /* bits in a word */
- 32, /* bits in an address */
- 8, /* bits in a byte */
- bfd_arch_sparc,
- bfd_mach_sparc,
- "sparc",
- "sparc",
- 3,
- true, /* the default */
- sparc_compatible,
- bfd_default_scan,
- &arch_info_struct[0],
- };
diff --git a/contrib/gdb/bfd/cpu-vax.c b/contrib/gdb/bfd/cpu-vax.c
deleted file mode 100644
index bdc6d39..0000000
--- a/contrib/gdb/bfd/cpu-vax.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* bfd back-end for vax support
- Copyright (C) 1990, 91, 92, 93, 94 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-const bfd_arch_info_type bfd_vax_arch =
- {
- 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",
- 3,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-w65.c b/contrib/gdb/bfd/cpu-w65.c
deleted file mode 100644
index c0bbf04..0000000
--- a/contrib/gdb/bfd/cpu-w65.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* BFD library support routines for the WDC 65816 architecture.
- Copyright (C) 1995 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 publiw65ed by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You w65ould have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-
-int bfd_default_scan_num_mach();
-
-static boolean
-scan_mach (info, string)
- const struct bfd_arch_info *info;
- const char *string;
-{
- if (strcmp(string,"w65") == 0) return true;
- if (strcmp(string,"w65816") == 0) return true;
- return false;
-}
-
-
-
-const bfd_arch_info_type bfd_w65_arch =
-{
- 16, /* 16 bits in a word */
- 24, /* 24 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_w65,
- 0, /* only 1 machine */
- "w65", /* arch_name */
- "w65", /* printable name */
- 1,
- true, /* the default machine */
- bfd_default_compatible,
- scan_mach,
- 0,
-};
diff --git a/contrib/gdb/bfd/cpu-we32k.c b/contrib/gdb/bfd/cpu-we32k.c
deleted file mode 100644
index a38cbc1..0000000
--- a/contrib/gdb/bfd/cpu-we32k.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* bfd back-end for we32k support
- Copyright (C) 1992 Free Software Foundation, Inc.
- Contributed by Brendan Kehoe (brendan@cs.widener.edu).
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-const bfd_arch_info_type bfd_we32k_arch =
- {
- 32, /* 32 bits in a word */
- 32, /* 32 bits in an address */
- 8, /* 8 bits in a byte */
- bfd_arch_we32k,
- 32000, /* only 1 machine */
- "we32k",
- "we32k:32000",
- 3,
- true, /* the one and only */
- bfd_default_compatible,
- bfd_default_scan ,
- 0,
- };
diff --git a/contrib/gdb/bfd/cpu-z8k.c b/contrib/gdb/bfd/cpu-z8k.c
deleted file mode 100644
index 5cce8eb..0000000
--- a/contrib/gdb/bfd/cpu-z8k.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* BFD library support routines for the Z800n architecture.
- Copyright (C) 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-
-#if 0 /* not used currently */
-/*
-Relocations for the Z8K
-
-*/
-static bfd_reloc_status_type
-howto16_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection *ignore_input_section;
- bfd *ignore_bfd;
-{
- 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_type
-howto8_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection *ignore_input_section;
- bfd *ignore_bfd;
-{
- 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_type
-howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection *ignore_input_section;
- bfd *ignore_bfd;
-{
- 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_type
-howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
- ignore_input_section, ignore_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol_in;
- PTR data;
- asection *ignore_input_section;
- bfd *ignore_bfd;
-{
- 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, false, false);
-static reloc_howto_type howto_8
-= NEWHOWTO (howto8_callback, "abs8", 0, false, false);
-
-static reloc_howto_type howto_8_FFnn
-= NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
-
-static reloc_howto_type howto_8_pcrel
-= NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
-
-
-static reloc_howto_type *
-local_bfd_reloc_type_lookup (arch, code)
- const struct bfd_arch_info *arch;
- bfd_reloc_code_real_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;
- default:
- return (reloc_howto_type *) NULL;
- }
-}
-#endif
-
-int bfd_default_scan_num_mach ();
-
-static boolean
-scan_mach (info, string)
- const struct bfd_arch_info *info;
- const char *string;
-{
- if (strcmp (string, "z8001") == 0 || strcmp (string, "z8k") == 0)
- {
- return bfd_mach_z8001 == info->mach;
- }
- if (strcmp (string, "z8002") == 0)
- {
- return bfd_mach_z8002 == info->mach;
- }
- return false;
-}
-
-
-/* This routine is provided two arch_infos and returns whether
- they'd be compatible */
-
-static const bfd_arch_info_type *
-compatible (a, b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- if (a->arch != b->arch || a->mach != b->mach)
- return NULL;
- return a;
-}
-
-
-static const bfd_arch_info_type arch_info_struct[] =
-{
- {32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, false, compatible, scan_mach, 0,},
-};
-
-const bfd_arch_info_type bfd_z8k_arch =
-{
- 32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, true, compatible, scan_mach, &arch_info_struct[0],
-};
diff --git a/contrib/gdb/bfd/demo64.c b/contrib/gdb/bfd/demo64.c
deleted file mode 100644
index c91381d..0000000
--- a/contrib/gdb/bfd/demo64.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* BFD backend for demonstration 64-bit a.out binaries.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define ARCH_SIZE 64
-#define MY(OP) CAT(demo_64_,OP)
-#define TARGETNAME "demo64"
-#include "aoutf1.h"
diff --git a/contrib/gdb/bfd/ecoffswap.h b/contrib/gdb/bfd/ecoffswap.h
deleted file mode 100644
index 0d28d16..0000000
--- a/contrib/gdb/bfd/ecoffswap.h
+++ /dev/null
@@ -1,853 +0,0 @@
-/* Generic ECOFF swapping routines, for BFD.
- Copyright 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* NOTE: This is a header file, but it contains executable routines.
- This is done this way because these routines are substantially
- similar, but are not identical, for all ECOFF targets.
-
- These are routines to swap the ECOFF symbolic information in and
- out. The routines are defined statically. You can set breakpoints
- on them in gdb by naming the including source file; e.g.,
- 'coff-mips.c':ecoff_swap_hdr_in.
-
- Before including this header file, one of ECOFF_32 or ECOFF_64 must
- be defined. These are checked when swapping information that
- depends upon the target size. This code works for 32 bit and 64
- bit ECOFF, but may need to be generalized in the future.
-
- Some header file which defines the external forms of these
- structures must also be included before including this header file.
- Currently this is either coff/mips.h or coff/alpha.h.
-
- If the symbol TEST is defined when this file is compiled, a
- comparison is made to ensure that, in fact, the output is
- bit-for-bit the same as the input. Of course, this symbol should
- only be defined when deliberately testing the code on a machine
- with the proper byte sex and such. */
-
-#ifdef ECOFF_32
-#define ecoff_get_off bfd_h_get_32
-#define ecoff_put_off bfd_h_put_32
-#endif
-#ifdef ECOFF_64
-#define ecoff_get_off bfd_h_get_64
-#define ecoff_put_off bfd_h_put_64
-#endif
-
-/* ECOFF auxiliary information swapping routines. These are the same
- for all ECOFF targets, so they are defined in ecofflink.c. */
-
-extern void _bfd_ecoff_swap_tir_in
- PARAMS ((int, const struct tir_ext *, TIR *));
-extern void _bfd_ecoff_swap_tir_out
- PARAMS ((int, const TIR *, struct tir_ext *));
-extern void _bfd_ecoff_swap_rndx_in
- PARAMS ((int, const struct rndx_ext *, RNDXR *));
-extern void _bfd_ecoff_swap_rndx_out
- PARAMS ((int, const RNDXR *, struct rndx_ext *));
-
-/* Prototypes for functions defined in this file. */
-
-static void ecoff_swap_hdr_in PARAMS ((bfd *, PTR, HDRR *));
-static void ecoff_swap_hdr_out PARAMS ((bfd *, const HDRR *, PTR));
-static void ecoff_swap_fdr_in PARAMS ((bfd *, PTR, FDR *));
-static void ecoff_swap_fdr_out PARAMS ((bfd *, const FDR *, PTR));
-static void ecoff_swap_pdr_in PARAMS ((bfd *, PTR, PDR *));
-static void ecoff_swap_pdr_out PARAMS ((bfd *, const PDR *, PTR));
-static void ecoff_swap_sym_in PARAMS ((bfd *, PTR, SYMR *));
-static void ecoff_swap_sym_out PARAMS ((bfd *, const SYMR *, PTR));
-static void ecoff_swap_ext_in PARAMS ((bfd *, PTR, EXTR *));
-static void ecoff_swap_ext_out PARAMS ((bfd *, const EXTR *, PTR));
-static void ecoff_swap_rfd_in PARAMS ((bfd *, PTR, RFDT *));
-static void ecoff_swap_rfd_out PARAMS ((bfd *, const RFDT *, PTR));
-static void ecoff_swap_opt_in PARAMS ((bfd *, PTR, OPTR *));
-static void ecoff_swap_opt_out PARAMS ((bfd *, const OPTR *, PTR));
-static void ecoff_swap_dnr_in PARAMS ((bfd *, PTR, DNR *));
-static void ecoff_swap_dnr_out PARAMS ((bfd *, const DNR *, PTR));
-
-/* Swap in the symbolic header. */
-
-static void
-ecoff_swap_hdr_in (abfd, ext_copy, intern)
- bfd *abfd;
- PTR ext_copy;
- HDRR *intern;
-{
- struct hdr_ext ext[1];
-
- *ext = *(struct hdr_ext *) ext_copy;
-
- intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic);
- intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp);
- intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
- intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine);
- intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset);
- intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
- intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset);
- intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
- intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset);
- intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
- intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset);
- intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
- intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset);
- intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
- intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset);
- intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
- intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset);
- intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
- intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
- intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
- intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset);
- intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
- intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset);
- intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
- intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out the symbolic header. */
-
-static void
-ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr)
- bfd *abfd;
- const HDRR *intern_copy;
- PTR ext_ptr;
-{
- struct hdr_ext *ext = (struct hdr_ext *) ext_ptr;
- HDRR intern[1];
-
- *intern = *intern_copy;
-
- bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
- bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
- bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
- ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
- ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
- bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
- ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
- bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
- ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
- bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
- ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
- bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
- ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
- bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
- ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
- bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
- ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
- bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
- ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
- bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
- ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
- bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
- ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
- bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
- ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap in the file descriptor record. */
-
-static void
-ecoff_swap_fdr_in (abfd, ext_copy, intern)
- bfd *abfd;
- PTR ext_copy;
- FDR *intern;
-{
- struct fdr_ext ext[1];
-
- *ext = *(struct fdr_ext *) ext_copy;
-
- intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr);
- intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
-#ifdef ECOFF_64
- if (intern->rss == 0xffffffff)
- intern->rss = -1;
-#endif
- intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
- intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs);
- intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
- intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
- intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
- intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
- intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
- intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
-#ifdef ECOFF_32
- intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
- intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
-#endif
-#ifdef ECOFF_64
- intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst);
- intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd);
-#endif
- intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
- intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
- intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
- intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
-
- /* now the fun stuff... */
- if (bfd_header_big_endian (abfd)) {
- intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
- >> FDR_BITS1_LANG_SH_BIG;
- intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
- intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
- intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
- intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
- >> FDR_BITS2_GLEVEL_SH_BIG;
- } else {
- intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
- >> FDR_BITS1_LANG_SH_LITTLE;
- intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
- intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
- intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
- intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
- >> FDR_BITS2_GLEVEL_SH_LITTLE;
- }
- intern->reserved = 0;
-
- intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset);
- intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out the file descriptor record. */
-
-static void
-ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr)
- bfd *abfd;
- const FDR *intern_copy;
- PTR ext_ptr;
-{
- struct fdr_ext *ext = (struct fdr_ext *) ext_ptr;
- FDR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr);
- bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
- bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
- ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
- bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
- bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
- bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
- bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
- bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
- bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
-#ifdef ECOFF_32
- bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
- bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
-#endif
-#ifdef ECOFF_64
- bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
- bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
-#endif
- bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
- bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
- bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
- bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
-
- /* now the fun stuff... */
- if (bfd_header_big_endian (abfd)) {
- ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
- & FDR_BITS1_LANG_BIG)
- | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
- | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
- | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
- ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
- & FDR_BITS2_GLEVEL_BIG);
- ext->f_bits2[1] = 0;
- ext->f_bits2[2] = 0;
- } else {
- ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
- & FDR_BITS1_LANG_LITTLE)
- | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
- | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
- | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
- ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
- & FDR_BITS2_GLEVEL_LITTLE);
- ext->f_bits2[1] = 0;
- ext->f_bits2[2] = 0;
- }
-
- ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
- ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-#ifndef MPW_C
-
-/* Swap in the procedure descriptor record. */
-
-static void
-ecoff_swap_pdr_in (abfd, ext_copy, intern)
- bfd *abfd;
- PTR ext_copy;
- PDR *intern;
-{
- struct pdr_ext ext[1];
-
- *ext = *(struct pdr_ext *) ext_copy;
-
- memset ((PTR) intern, 0, sizeof (*intern));
-
- intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
- intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
- intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
- intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
- intern->regoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_regoffset);
- intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
- intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
- intern->fregoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_fregoffset);
- intern->frameoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_frameoffset);
- intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
- intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
- intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
- intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
- intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
-
-#ifdef ECOFF_64
- intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue);
- if (bfd_header_big_endian (abfd))
- {
- intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG);
- intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_BIG);
- intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_BIG);
- intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_BIG)
- << PDR_BITS1_RESERVED_SH_LEFT_BIG)
- | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_BIG)
- >> PDR_BITS2_RESERVED_SH_BIG));
- }
- else
- {
- intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_LITTLE);
- intern->reg_frame = 0 != (ext->p_bits1[0] & PDR_BITS1_REG_FRAME_LITTLE);
- intern->prof = 0 != (ext->p_bits1[0] & PDR_BITS1_PROF_LITTLE);
- intern->reserved = (((ext->p_bits1[0] & PDR_BITS1_RESERVED_LITTLE)
- >> PDR_BITS1_RESERVED_SH_LITTLE)
- | ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE)
- << PDR_BITS2_RESERVED_SH_LEFT_LITTLE));
- }
- intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff);
-#endif
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out the procedure descriptor record. */
-
-static void
-ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
- bfd *abfd;
- const PDR *intern_copy;
- PTR ext_ptr;
-{
- struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
- PDR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
- bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
- bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
- bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
- bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
- bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
- bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
- bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
- bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
- bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
- bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
- bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
- bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
- ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
-
-#ifdef ECOFF_64
- bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue);
- if (bfd_header_big_endian (abfd))
- {
- ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0)
- | (intern->reg_frame ? PDR_BITS1_REG_FRAME_BIG : 0)
- | (intern->prof ? PDR_BITS1_PROF_BIG : 0)
- | ((intern->reserved
- >> PDR_BITS1_RESERVED_SH_LEFT_BIG)
- & PDR_BITS1_RESERVED_BIG));
- ext->p_bits2[0] = ((intern->reserved << PDR_BITS2_RESERVED_SH_BIG)
- & PDR_BITS2_RESERVED_BIG);
- }
- else
- {
- ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_LITTLE : 0)
- | (intern->reg_frame ? PDR_BITS1_REG_FRAME_LITTLE : 0)
- | (intern->prof ? PDR_BITS1_PROF_LITTLE : 0)
- | ((intern->reserved << PDR_BITS1_RESERVED_SH_LITTLE)
- & PDR_BITS1_RESERVED_LITTLE));
- ext->p_bits2[0] = ((intern->reserved >>
- PDR_BITS2_RESERVED_SH_LEFT_LITTLE)
- & PDR_BITS2_RESERVED_LITTLE);
- }
- bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff);
-#endif
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-#else /* MPW_C */
-/* Same routines, but with ECOFF_64 code removed, so ^&%$#&! MPW C doesn't
- corrupt itself and then freak out. */
-/* Swap in the procedure descriptor record. */
-
-static void
-ecoff_swap_pdr_in (abfd, ext_copy, intern)
- bfd *abfd;
- PTR ext_copy;
- PDR *intern;
-{
- struct pdr_ext ext[1];
-
- *ext = *(struct pdr_ext *) ext_copy;
-
- intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
- intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
- intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
- intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
- intern->regoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_regoffset);
- intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
- intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
- intern->fregoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_fregoffset);
- intern->frameoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_frameoffset);
- intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
- intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
- intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
- intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
- intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out the procedure descriptor record. */
-
-static void
-ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr)
- bfd *abfd;
- const PDR *intern_copy;
- PTR ext_ptr;
-{
- struct pdr_ext *ext = (struct pdr_ext *) ext_ptr;
- PDR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
- bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
- bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
- bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
- bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
- bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
- bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
- bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
- bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
- bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
- bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
- bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
- bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
- ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-#endif /* MPW_C */
-
-/* Swap in a symbol record. */
-
-static void
-ecoff_swap_sym_in (abfd, ext_copy, intern)
- bfd *abfd;
- PTR ext_copy;
- SYMR *intern;
-{
- struct sym_ext ext[1];
-
- *ext = *(struct sym_ext *) ext_copy;
-
- intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
- intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value);
-
- /* now the fun stuff... */
- if (bfd_header_big_endian (abfd)) {
- intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_BIG)
- >> SYM_BITS1_ST_SH_BIG;
- intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_BIG)
- << SYM_BITS1_SC_SH_LEFT_BIG)
- | ((ext->s_bits2[0] & SYM_BITS2_SC_BIG)
- >> SYM_BITS2_SC_SH_BIG);
- intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_BIG);
- intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_BIG)
- << SYM_BITS2_INDEX_SH_LEFT_BIG)
- | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_BIG)
- | (ext->s_bits4[0] << SYM_BITS4_INDEX_SH_LEFT_BIG);
- } else {
- intern->st = (ext->s_bits1[0] & SYM_BITS1_ST_LITTLE)
- >> SYM_BITS1_ST_SH_LITTLE;
- intern->sc = ((ext->s_bits1[0] & SYM_BITS1_SC_LITTLE)
- >> SYM_BITS1_SC_SH_LITTLE)
- | ((ext->s_bits2[0] & SYM_BITS2_SC_LITTLE)
- << SYM_BITS2_SC_SH_LEFT_LITTLE);
- intern->reserved = 0 != (ext->s_bits2[0] & SYM_BITS2_RESERVED_LITTLE);
- intern->index = ((ext->s_bits2[0] & SYM_BITS2_INDEX_LITTLE)
- >> SYM_BITS2_INDEX_SH_LITTLE)
- | (ext->s_bits3[0] << SYM_BITS3_INDEX_SH_LEFT_LITTLE)
- | ((unsigned int) ext->s_bits4[0]
- << SYM_BITS4_INDEX_SH_LEFT_LITTLE);
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a symbol record. */
-
-static void
-ecoff_swap_sym_out (abfd, intern_copy, ext_ptr)
- bfd *abfd;
- const SYMR *intern_copy;
- PTR ext_ptr;
-{
- struct sym_ext *ext = (struct sym_ext *) ext_ptr;
- SYMR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
- ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value);
-
- /* now the fun stuff... */
- if (bfd_header_big_endian (abfd)) {
- ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_BIG)
- & SYM_BITS1_ST_BIG)
- | ((intern->sc >> SYM_BITS1_SC_SH_LEFT_BIG)
- & SYM_BITS1_SC_BIG));
- ext->s_bits2[0] = (((intern->sc << SYM_BITS2_SC_SH_BIG)
- & SYM_BITS2_SC_BIG)
- | (intern->reserved ? SYM_BITS2_RESERVED_BIG : 0)
- | ((intern->index >> SYM_BITS2_INDEX_SH_LEFT_BIG)
- & SYM_BITS2_INDEX_BIG));
- ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_BIG) & 0xff;
- ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_BIG) & 0xff;
- } else {
- ext->s_bits1[0] = (((intern->st << SYM_BITS1_ST_SH_LITTLE)
- & SYM_BITS1_ST_LITTLE)
- | ((intern->sc << SYM_BITS1_SC_SH_LITTLE)
- & SYM_BITS1_SC_LITTLE));
- ext->s_bits2[0] = (((intern->sc >> SYM_BITS2_SC_SH_LEFT_LITTLE)
- & SYM_BITS2_SC_LITTLE)
- | (intern->reserved ? SYM_BITS2_RESERVED_LITTLE : 0)
- | ((intern->index << SYM_BITS2_INDEX_SH_LITTLE)
- & SYM_BITS2_INDEX_LITTLE));
- ext->s_bits3[0] = (intern->index >> SYM_BITS3_INDEX_SH_LEFT_LITTLE) & 0xff;
- ext->s_bits4[0] = (intern->index >> SYM_BITS4_INDEX_SH_LEFT_LITTLE) & 0xff;
- }
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap in an external symbol record. */
-
-static void
-ecoff_swap_ext_in (abfd, ext_copy, intern)
- bfd *abfd;
- PTR ext_copy;
- EXTR *intern;
-{
- struct ext_ext ext[1];
-
- *ext = *(struct ext_ext *) ext_copy;
-
- /* now the fun stuff... */
- if (bfd_header_big_endian (abfd)) {
- intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_BIG);
- intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_BIG);
- intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_BIG);
- } else {
- intern->jmptbl = 0 != (ext->es_bits1[0] & EXT_BITS1_JMPTBL_LITTLE);
- intern->cobol_main = 0 != (ext->es_bits1[0] & EXT_BITS1_COBOL_MAIN_LITTLE);
- intern->weakext = 0 != (ext->es_bits1[0] & EXT_BITS1_WEAKEXT_LITTLE);
- }
- intern->reserved = 0;
-
-#ifdef ECOFF_32
- intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd);
-#endif
-#ifdef ECOFF_64
- intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd);
-#endif
-
- ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out an external symbol record. */
-
-static void
-ecoff_swap_ext_out (abfd, intern_copy, ext_ptr)
- bfd *abfd;
- const EXTR *intern_copy;
- PTR ext_ptr;
-{
- struct ext_ext *ext = (struct ext_ext *) ext_ptr;
- EXTR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- /* now the fun stuff... */
- if (bfd_header_big_endian (abfd)) {
- ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_BIG : 0)
- | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_BIG : 0)
- | (intern->weakext ? EXT_BITS1_WEAKEXT_BIG : 0));
- ext->es_bits2[0] = 0;
-#ifdef ECOFF_64
- ext->es_bits2[1] = 0;
- ext->es_bits2[2] = 0;
-#endif
- } else {
- ext->es_bits1[0] = ((intern->jmptbl ? EXT_BITS1_JMPTBL_LITTLE : 0)
- | (intern->cobol_main ? EXT_BITS1_COBOL_MAIN_LITTLE : 0)
- | (intern->weakext ? EXT_BITS1_WEAKEXT_LITTLE : 0));
- ext->es_bits2[0] = 0;
-#ifdef ECOFF_64
- ext->es_bits2[1] = 0;
- ext->es_bits2[2] = 0;
-#endif
- }
-
-#ifdef ECOFF_32
- bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
-#endif
-#ifdef ECOFF_64
- bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
-#endif
-
- ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap in a relative file descriptor. */
-
-static void
-ecoff_swap_rfd_in (abfd, ext_ptr, intern)
- bfd *abfd;
- PTR ext_ptr;
- RFDT *intern;
-{
- struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
-
- *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a relative file descriptor. */
-
-static void
-ecoff_swap_rfd_out (abfd, intern, ext_ptr)
- bfd *abfd;
- const RFDT *intern;
- PTR ext_ptr;
-{
- struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
-
- bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap in an optimization symbol. */
-
-static void
-ecoff_swap_opt_in (abfd, ext_copy, intern)
- bfd *abfd;
- PTR ext_copy;
- OPTR *intern;
-{
- struct opt_ext ext[1];
-
- *ext = *(struct opt_ext *) ext_copy;
-
- if (bfd_header_big_endian (abfd))
- {
- intern->ot = ext->o_bits1[0];
- intern->value = (((unsigned int) ext->o_bits2[0]
- << OPT_BITS2_VALUE_SH_LEFT_BIG)
- | ((unsigned int) ext->o_bits3[0]
- << OPT_BITS2_VALUE_SH_LEFT_BIG)
- | ((unsigned int) ext->o_bits4[0]
- << OPT_BITS2_VALUE_SH_LEFT_BIG));
- }
- else
- {
- intern->ot = ext->o_bits1[0];
- intern->value = ((ext->o_bits2[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
- | (ext->o_bits3[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE)
- | (ext->o_bits4[0] << OPT_BITS2_VALUE_SH_LEFT_LITTLE));
- }
-
- _bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd),
- &ext->o_rndx, &intern->rndx);
-
- intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out an optimization symbol. */
-
-static void
-ecoff_swap_opt_out (abfd, intern_copy, ext_ptr)
- bfd *abfd;
- const OPTR *intern_copy;
- PTR ext_ptr;
-{
- struct opt_ext *ext = (struct opt_ext *) ext_ptr;
- OPTR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- if (bfd_header_big_endian (abfd))
- {
- ext->o_bits1[0] = intern->ot;
- ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_BIG;
- ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_BIG;
- ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_BIG;
- }
- else
- {
- ext->o_bits1[0] = intern->ot;
- ext->o_bits2[0] = intern->value >> OPT_BITS2_VALUE_SH_LEFT_LITTLE;
- ext->o_bits3[0] = intern->value >> OPT_BITS3_VALUE_SH_LEFT_LITTLE;
- ext->o_bits4[0] = intern->value >> OPT_BITS4_VALUE_SH_LEFT_LITTLE;
- }
-
- _bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd),
- &intern->rndx, &ext->o_rndx);
-
- bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap in a dense number. */
-
-static void
-ecoff_swap_dnr_in (abfd, ext_copy, intern)
- bfd *abfd;
- PTR ext_copy;
- DNR *intern;
-{
- struct dnr_ext ext[1];
-
- *ext = *(struct dnr_ext *) ext_copy;
-
- intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
- intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
-
-/* Swap out a dense number. */
-
-static void
-ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr)
- bfd *abfd;
- const DNR *intern_copy;
- PTR ext_ptr;
-{
- struct dnr_ext *ext = (struct dnr_ext *) ext_ptr;
- DNR intern[1];
-
- *intern = *intern_copy; /* Make it reasonable to do in-place. */
-
- bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
- bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
-
-#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
- abort();
-#endif
-}
diff --git a/contrib/gdb/bfd/elf32-gen.c b/contrib/gdb/bfd/elf32-gen.c
deleted file mode 100644
index 385fda2..0000000
--- a/contrib/gdb/bfd/elf32-gen.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Generic support for 32-bit ELF
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-
-/* This does not include any relocations, but should be good enough
- for GDB to read the file. */
-
-#define TARGET_LITTLE_SYM bfd_elf32_little_generic_vec
-#define TARGET_LITTLE_NAME "elf32-little"
-#define TARGET_BIG_SYM bfd_elf32_big_generic_vec
-#define TARGET_BIG_NAME "elf32-big"
-#define ELF_ARCH bfd_arch_unknown
-#define ELF_MACHINE_CODE EM_NONE
-#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
-#define elf_info_to_howto _bfd_elf_no_info_to_howto
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32-hppa.c b/contrib/gdb/bfd/elf32-hppa.c
deleted file mode 100644
index 2386731..0000000
--- a/contrib/gdb/bfd/elf32-hppa.c
+++ /dev/null
@@ -1,2984 +0,0 @@
-/* BFD back-end for HP PA-RISC ELF files.
- Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
-
- Written by
-
- Center for Software Science
- Department of Computer Science
- University of Utah
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "obstack.h"
-#include "elf-bfd.h"
-
-/* The internal type of a symbol table extension entry. */
-typedef unsigned long symext_entryS;
-
-/* The external type of a symbol table extension entry. */
-#define ELF32_PARISC_SX_SIZE (4)
-#define ELF32_PARISC_SX_GET(bfd, addr) bfd_h_get_32 ((bfd), (addr))
-#define ELF32_PARISC_SX_PUT(bfd, val, addr) \
- bfd_h_put_32 ((bfd), (val), (addr))
-
-/* HPPA symbol table extension entry types */
-enum elf32_hppa_symextn_types
-{
- PARISC_SXT_NULL,
- PARISC_SXT_SYMNDX,
- PARISC_SXT_ARG_RELOC,
-};
-
-/* These macros compose and decompose the value of a symextn entry:
-
- entry_type = ELF32_PARISC_SX_TYPE(word);
- entry_value = ELF32_PARISC_SX_VAL(word);
- word = ELF32_PARISC_SX_WORD(type,val); */
-
-#define ELF32_PARISC_SX_TYPE(p) ((p) >> 24)
-#define ELF32_PARISC_SX_VAL(p) ((p) & 0xFFFFFF)
-#define ELF32_PARISC_SX_WORD(type,val) (((type) << 24) + (val & 0xFFFFFF))
-
-/* The following was added facilitate implementation of the .hppa_symextn
- section. This section is built after the symbol table is built in the
- elf_write_object_contents routine (called from bfd_close). It is built
- so late because it requires information that is not known until
- the symbol and string table sections have been allocated, and
- the symbol table has been built. */
-
-#define SYMEXTN_SECTION_NAME ".PARISC.symext"
-
-struct symext_chain
- {
- symext_entryS entry;
- struct symext_chain *next;
- };
-
-typedef struct symext_chain symext_chainS;
-
-/* We use three different hash tables to hold information for
- linking PA ELF objects.
-
- The first is the elf32_hppa_link_hash_table which is derived
- from the standard ELF linker hash table. We use this as a place to
- attach other hash tables and static information.
-
- The second is the stub hash table which is derived from the
- base BFD hash table. The stub hash table holds the information
- necessary to build the linker stubs during a link.
-
- The last hash table keeps track of argument location information needed
- to build hash tables. Each function with nonzero argument location
- bits will have an entry in this table. */
-
-/* Hash table for linker stubs. */
-
-struct elf32_hppa_stub_hash_entry
-{
- /* Base hash table entry structure, we can get the name of the stub
- (and thus know exactly what actions it performs) from the base
- hash table entry. */
- struct bfd_hash_entry root;
-
- /* Offset of the beginning of this stub. */
- bfd_vma offset;
-
- /* Given the symbol's value and its section we can determine its final
- value when building the stubs (so the stub knows where to jump. */
- symvalue target_value;
- asection *target_section;
-};
-
-struct elf32_hppa_stub_hash_table
-{
- /* The hash table itself. */
- struct bfd_hash_table root;
-
- /* The stub BFD. */
- bfd *stub_bfd;
-
- /* Where to place the next stub. */
- bfd_byte *location;
-
- /* Current offset in the stub section. */
- unsigned int offset;
-
-};
-
-/* Hash table for argument location information. */
-
-struct elf32_hppa_args_hash_entry
-{
- /* Base hash table entry structure. */
- struct bfd_hash_entry root;
-
- /* The argument location bits for this entry. */
- int arg_bits;
-};
-
-struct elf32_hppa_args_hash_table
-{
- /* The hash table itself. */
- struct bfd_hash_table root;
-};
-
-struct elf32_hppa_link_hash_entry
-{
- struct elf_link_hash_entry root;
-};
-
-struct elf32_hppa_link_hash_table
-{
- /* The main hash table. */
- struct elf_link_hash_table root;
-
- /* The stub hash table. */
- struct elf32_hppa_stub_hash_table *stub_hash_table;
-
- /* The argument relocation bits hash table. */
- struct elf32_hppa_args_hash_table *args_hash_table;
-
- /* A count of the number of output symbols. */
- unsigned int output_symbol_count;
-
- /* Stuff so we can handle DP relative relocations. */
- long global_value;
- int global_sym_defined;
-};
-
-/* FIXME. */
-#define ARGUMENTS 0
-#define RETURN_VALUE 1
-
-/* The various argument relocations that may be performed. */
-typedef enum
-{
- /* No relocation. */
- NO,
- /* Relocate 32 bits from GR to FP register. */
- GF,
- /* Relocate 64 bits from a GR pair to FP pair. */
- GD,
- /* Relocate 32 bits from FP to GR. */
- FG,
- /* Relocate 64 bits from FP pair to GR pair. */
- DG,
-} arg_reloc_type;
-
-/* What is being relocated (eg which argument or the return value). */
-typedef enum
-{
- ARG0, ARG1, ARG2, ARG3, RET,
-} arg_reloc_location;
-
-
-/* ELF32/HPPA relocation support
-
- This file contains ELF32/HPPA relocation support as specified
- in the Stratus FTX/Golf Object File Format (SED-1762) dated
- February 1994. */
-
-#include "elf32-hppa.h"
-#include "hppa_stubs.h"
-
-static bfd_reloc_status_type hppa_elf_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-
-static unsigned long hppa_elf_relocate_insn
- PARAMS ((bfd *, asection *, unsigned long, unsigned long, long,
- long, unsigned long, unsigned long, unsigned long));
-
-static bfd_reloc_status_type hppa_elf_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd*, char **));
-
-static reloc_howto_type * elf_hppa_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-
-static boolean elf32_hppa_set_section_contents
- PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
-
-static void elf_info_to_howto
- PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
-
-static boolean elf32_hppa_backend_symbol_table_processing
- PARAMS ((bfd *, elf_symbol_type *, unsigned int));
-
-static void elf32_hppa_backend_begin_write_processing
- PARAMS ((bfd *, struct bfd_link_info *));
-
-static void elf32_hppa_backend_final_write_processing
- PARAMS ((bfd *, boolean));
-
-static void add_entry_to_symext_chain
- PARAMS ((bfd *, unsigned int, unsigned int, symext_chainS **,
- symext_chainS **));
-
-static void
-elf_hppa_tc_make_sections PARAMS ((bfd *, symext_chainS *));
-
-static boolean hppa_elf_is_local_label PARAMS ((bfd *, asymbol *));
-
-static boolean elf32_hppa_add_symbol_hook
- PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
- const char **, flagword *, asection **, bfd_vma *));
-
-static bfd_reloc_status_type elf32_hppa_bfd_final_link_relocate
- PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *,
- bfd_byte *, bfd_vma, bfd_vma, bfd_vma, struct bfd_link_info *,
- asection *, const char *, int));
-
-static struct bfd_link_hash_table *elf32_hppa_link_hash_table_create
- PARAMS ((bfd *));
-
-static struct bfd_hash_entry *
-elf32_hppa_stub_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-
-static struct bfd_hash_entry *
-elf32_hppa_args_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-
-static boolean
-elf32_hppa_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
- bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-
-static boolean
-elf32_hppa_stub_hash_table_init
- PARAMS ((struct elf32_hppa_stub_hash_table *, bfd *,
- struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *))));
-
-static boolean
-elf32_hppa_build_one_stub PARAMS ((struct bfd_hash_entry *, PTR));
-
-static boolean
-elf32_hppa_read_symext_info
- PARAMS ((bfd *, Elf_Internal_Shdr *, struct elf32_hppa_args_hash_table *,
- Elf_Internal_Sym *));
-
-static unsigned int elf32_hppa_size_of_stub
- PARAMS ((unsigned int, unsigned int, bfd_vma, bfd_vma, const char *));
-
-static boolean elf32_hppa_arg_reloc_needed
- PARAMS ((unsigned int, unsigned int, arg_reloc_type []));
-
-static void elf32_hppa_name_of_stub
- PARAMS ((unsigned int, unsigned int, bfd_vma, bfd_vma, char *));
-
-static boolean elf32_hppa_size_symext PARAMS ((struct bfd_hash_entry *, PTR));
-
-static boolean elf32_hppa_link_output_symbol_hook
- PARAMS ((bfd *, struct bfd_link_info *, const char *,
- Elf_Internal_Sym *, asection *));
-
-/* ELF/PA relocation howto entries. */
-
-static reloc_howto_type elf_hppa_howto_table[ELF_HOWTO_TABLE_SIZE] =
-{
- {R_PARISC_NONE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_NONE"},
- {R_PARISC_DIR32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR32"},
- {R_PARISC_DIR21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR21L"},
- {R_PARISC_DIR17R, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR17R"},
- {R_PARISC_DIR17F, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR17F"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_DIR14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DIR14R"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_PCREL21L, 0, 0, 21, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL21L"},
- {R_PARISC_PCREL17R, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17R"},
- {R_PARISC_PCREL17F, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17F"},
- {R_PARISC_PCREL17C, 0, 0, 17, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL17C"},
- {R_PARISC_PCREL14R, 0, 0, 14, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL14R"},
- {R_PARISC_PCREL14F, 0, 0, 14, true, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PCREL14F"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_DPREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL21L"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_DPREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL14R"},
- {R_PARISC_DPREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DPREL14F"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_DLTREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL21L"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_DLTREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL14R"},
- {R_PARISC_DLTREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTREL14F"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_DLTIND21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND21L"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_DLTIND14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND14R"},
- {R_PARISC_DLTIND14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_DLTIND14F"},
-
- {R_PARISC_SETBASE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_SETBASE"},
- {R_PARISC_BASEREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL32"},
- {R_PARISC_BASEREL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL21L"},
- {R_PARISC_BASEREL17R, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL17R"},
- {R_PARISC_BASEREL17F, 0, 0, 17, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL17F"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_BASEREL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL14R"},
- {R_PARISC_BASEREL14F, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_BASEREL14F"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_TEXTREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_TEXTREL32"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_DATAREL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
-
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_PLABEL32, 0, 0, 32, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL32"},
- {R_PARISC_PLABEL21L, 0, 0, 21, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL21L"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_PLABEL14R, 0, 0, 14, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLABEL14R"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
-
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_PLTIND21L, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND21L"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_UNIMPLEMENTED"},
- {R_PARISC_PLTIND14R, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND14R"},
- {R_PARISC_PLTIND14F, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_PLTIND14F"},
-
-
- {R_PARISC_COPY, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_COPY"},
- {R_PARISC_GLOB_DAT, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_GLOB_DAT"},
- {R_PARISC_JMP_SLOT, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_JMP_SLOT"},
- {R_PARISC_RELATIVE, 0, 0, 0, false, 0, complain_overflow_bitfield, hppa_elf_reloc, "R_PARISC_RELATIVE"},
-
- {R_PARISC_UNIMPLEMENTED, 0, 0, 0, false, 0, complain_overflow_dont, NULL, "R_PARISC_UNIMPLEMENTED"},
-};
-
-/* Where (what register type) is an argument comming from? */
-typedef enum
-{
- AR_NO,
- AR_GR,
- AR_FR,
- AR_FU,
- AR_FPDBL1,
- AR_FPDBL2,
-} arg_location;
-
-/* Horizontal represents the callee's argument location information,
- vertical represents caller's argument location information. Value at a
- particular X,Y location represents what (if any) argument relocation
- needs to be performed to make caller and callee agree. */
-
-static CONST arg_reloc_type arg_mismatches[6][6] =
-{
- {NO, NO, NO, NO, NO, NO},
- {NO, NO, GF, NO, GD, NO},
- {NO, FG, NO, NO, NO, NO},
- {NO, NO, NO, NO, NO, NO},
- {NO, DG, NO, NO, NO, NO},
- {NO, DG, NO, NO, NO, NO},
-};
-
-/* Likewise, but reversed for the return value. */
-static CONST arg_reloc_type ret_mismatches[6][6] =
-{
- {NO, NO, NO, NO, NO, NO},
- {NO, NO, FG, NO, DG, NO},
- {NO, GF, NO, NO, NO, NO},
- {NO, NO, NO, NO, NO, NO},
- {NO, GD, NO, NO, NO, NO},
- {NO, GD, NO, NO, NO, NO},
-};
-
-/* Misc static crud for symbol extension records. */
-static symext_chainS *symext_rootP;
-static symext_chainS *symext_lastP;
-static bfd_size_type symext_chain_size;
-
-/* FIXME: We should be able to try this static variable! */
-static bfd_byte *symextn_contents;
-
-
-/* For linker stub hash tables. */
-#define elf32_hppa_stub_hash_lookup(table, string, create, copy) \
- ((struct elf32_hppa_stub_hash_entry *) \
- bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
-
-#define elf32_hppa_stub_hash_traverse(table, func, info) \
- (bfd_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \
- (info)))
-
-/* For linker args hash tables. */
-#define elf32_hppa_args_hash_lookup(table, string, create, copy) \
- ((struct elf32_hppa_args_hash_entry *) \
- bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
-
-#define elf32_hppa_args_hash_traverse(table, func, info) \
- (bfd_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \
- (info)))
-
-#define elf32_hppa_args_hash_table_init(table, newfunc) \
- (bfd_hash_table_init \
- (&(table)->root, \
- (struct bfd_hash_entry *(*) PARAMS ((struct bfd_hash_entry *, \
- struct bfd_hash_table *, \
- const char *))) (newfunc)))
-
-/* For HPPA linker hash table. */
-
-#define elf32_hppa_link_hash_lookup(table, string, create, copy, follow)\
- ((struct elf32_hppa_link_hash_entry *) \
- elf_link_hash_lookup (&(table)->root, (string), (create), \
- (copy), (follow)))
-
-#define elf32_hppa_link_hash_traverse(table, func, info) \
- (elf_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the PA ELF linker hash table from a link_info structure. */
-
-#define elf32_hppa_hash_table(p) \
- ((struct elf32_hppa_link_hash_table *) ((p)->hash))
-
-
-/* Extract specific argument location bits for WHICH from
- the full argument location in AR. */
-#define EXTRACT_ARBITS(ar, which) ((ar) >> (8 - ((which) * 2))) & 3
-
-/* Assorted hash table functions. */
-
-/* Initialize an entry in the stub hash table. */
-
-static struct bfd_hash_entry *
-elf32_hppa_stub_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct elf32_hppa_stub_hash_entry *ret;
-
- ret = (struct elf32_hppa_stub_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == NULL)
- ret = ((struct elf32_hppa_stub_hash_entry *)
- bfd_hash_allocate (table,
- sizeof (struct elf32_hppa_stub_hash_entry)));
- if (ret == NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct elf32_hppa_stub_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- if (ret)
- {
- /* Initialize the local fields. */
- ret->offset = 0;
- ret->target_value = 0;
- ret->target_section = NULL;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Initialize a stub hash table. */
-
-static boolean
-elf32_hppa_stub_hash_table_init (table, stub_bfd, newfunc)
- struct elf32_hppa_stub_hash_table *table;
- bfd *stub_bfd;
- struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
-{
- table->offset = 0;
- table->location = 0;
- table->stub_bfd = stub_bfd;
- return (bfd_hash_table_init (&table->root, newfunc));
-}
-
-/* Initialize an entry in the argument location hash table. */
-
-static struct bfd_hash_entry *
-elf32_hppa_args_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct elf32_hppa_args_hash_entry *ret;
-
- ret = (struct elf32_hppa_args_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == NULL)
- ret = ((struct elf32_hppa_args_hash_entry *)
- bfd_hash_allocate (table,
- sizeof (struct elf32_hppa_args_hash_entry)));
- if (ret == NULL)
- return NULL;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct elf32_hppa_args_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
-
- /* Initialize the local fields. */
- if (ret)
- ret->arg_bits = 0;
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create the derived linker hash table. The PA ELF port uses the derived
- hash table to keep information specific to the PA ELF linker (without
- using static variables). */
-
-static struct bfd_link_hash_table *
-elf32_hppa_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct elf32_hppa_link_hash_table *ret;
-
- ret = ((struct elf32_hppa_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf32_hppa_link_hash_table)));
- if (ret == NULL)
- return NULL;
- if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
- _bfd_elf_link_hash_newfunc))
- {
- bfd_release (abfd, ret);
- return NULL;
- }
- ret->stub_hash_table = NULL;
- ret->args_hash_table = NULL;
- ret->output_symbol_count = 0;
- ret->global_value = 0;
- ret->global_sym_defined = 0;
-
- return &ret->root.root;
-}
-
-/* Relocate the given INSN given the various input parameters.
-
- FIXME: endianness and sizeof (long) issues abound here. */
-
-static unsigned long
-hppa_elf_relocate_insn (abfd, input_sect, insn, address, sym_value,
- r_addend, r_format, r_field, pcrel)
- bfd *abfd;
- asection *input_sect;
- unsigned long insn;
- unsigned long address;
- long sym_value;
- long r_addend;
- unsigned long r_format;
- unsigned long r_field;
- unsigned long pcrel;
-{
- unsigned char opcode = get_opcode (insn);
- long constant_value;
-
- switch (opcode)
- {
- case LDO:
- case LDB:
- case LDH:
- case LDW:
- case LDWM:
- case STB:
- case STH:
- case STW:
- case STWM:
- case COMICLR:
- case SUBI:
- case ADDIT:
- case ADDI:
- case LDIL:
- case ADDIL:
- constant_value = HPPA_R_CONSTANT (r_addend);
-
- if (pcrel)
- sym_value -= address;
-
- sym_value = hppa_field_adjust (sym_value, constant_value, r_field);
- return hppa_rebuild_insn (abfd, insn, sym_value, r_format);
-
- case BL:
- case BE:
- case BLE:
- /* XXX computing constant_value is not needed??? */
- constant_value = assemble_17 ((insn & 0x001f0000) >> 16,
- (insn & 0x00001ffc) >> 2,
- insn & 1);
-
- constant_value = (constant_value << 15) >> 15;
- if (pcrel)
- {
- sym_value -=
- address + input_sect->output_offset
- + input_sect->output_section->vma;
- sym_value = hppa_field_adjust (sym_value, -8, r_field);
- }
- else
- sym_value = hppa_field_adjust (sym_value, constant_value, r_field);
-
- return hppa_rebuild_insn (abfd, insn, sym_value >> 2, r_format);
-
- default:
- if (opcode == 0)
- {
- constant_value = HPPA_R_CONSTANT (r_addend);
-
- if (pcrel)
- sym_value -= address;
-
- return hppa_field_adjust (sym_value, constant_value, r_field);
- }
- else
- abort ();
- }
-}
-
-/* Relocate an HPPA ELF section. */
-
-static boolean
-elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, local_syms, local_sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- Elf_Internal_Rela *relocs;
- Elf_Internal_Sym *local_syms;
- asection **local_sections;
-{
- Elf_Internal_Shdr *symtab_hdr;
- Elf_Internal_Rela *rel;
- Elf_Internal_Rela *relend;
-
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
-
- rel = relocs;
- relend = relocs + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- int r_type;
- reloc_howto_type *howto;
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
- asection *sym_sec;
- bfd_vma relocation;
- bfd_reloc_status_type r;
- const char *sym_name;
-
- r_type = ELF32_R_TYPE (rel->r_info);
- if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- howto = elf_hppa_howto_table + r_type;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sym_sec = local_sections[r_symndx];
- rel->r_addend += sym_sec->output_offset;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
- h = NULL;
- sym = NULL;
- sym_sec = NULL;
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- sym_sec = local_sections[r_symndx];
- relocation = ((ELF_ST_TYPE (sym->st_info) == STT_SECTION
- ? 0 : sym->st_value)
- + sym_sec->output_offset
- + sym_sec->output_section->vma);
- }
- else
- {
- long indx;
-
- indx = r_symndx - symtab_hdr->sh_info;
- h = elf_sym_hashes (input_bfd)[indx];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sym_sec = h->root.u.def.section;
- relocation = (h->root.u.def.value
- + sym_sec->output_offset
- + sym_sec->output_section->vma);
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else
- {
- if (!((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset)))
- return false;
- break;
- }
- }
-
- if (h != NULL)
- sym_name = h->root.root.string;
- else
- {
- sym_name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
- if (sym_name == NULL)
- return false;
- if (*sym_name == '\0')
- sym_name = bfd_section_name (input_bfd, sym_sec);
- }
-
- /* If args_hash_table is NULL, then we have encountered some
- kind of link error (ex. undefined symbols). Do not try to
- apply any relocations, continue the loop so we can notify
- the user of several errors in a single attempted link. */
- if (elf32_hppa_hash_table (info)->args_hash_table == NULL)
- continue;
-
- r = elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd,
- input_section, contents,
- rel->r_offset, relocation,
- rel->r_addend, info, sym_sec,
- sym_name, h == NULL);
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- /* This can happen for DP relative relocs if $global$ is
- undefined. This is a panic situation so we don't try
- to continue. */
- case bfd_reloc_undefined:
- case bfd_reloc_notsupported:
- if (!((*info->callbacks->undefined_symbol)
- (info, "$global$", input_bfd,
- input_section, rel->r_offset)))
- return false;
- return false;
- case bfd_reloc_dangerous:
- {
- /* We use this return value to indicate that we performed
- a "dangerous" relocation. This doesn't mean we did
- the wrong thing, it just means there may be some cleanup
- that needs to be done here.
-
- In particular we had to swap the last call insn and its
- delay slot. If the delay slot insn needed a relocation,
- then we'll need to adjust the next relocation entry's
- offset to account for the fact that the insn moved.
-
- This hair wouldn't be necessary if we inserted stubs
- between procedures and used a "bl" to get to the stub. */
- if (rel != relend)
- {
- Elf_Internal_Rela *next_rel = rel + 1;
-
- if (rel->r_offset + 4 == next_rel->r_offset)
- next_rel->r_offset -= 4;
- }
- break;
- }
- default:
- case bfd_reloc_outofrange:
- case bfd_reloc_overflow:
- {
- if (!((*info->callbacks->reloc_overflow)
- (info, sym_name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Return one (or more) BFD relocations which implement the base
- relocation with modifications based on format and field. */
-
-elf32_hppa_reloc_type **
-hppa_elf_gen_reloc_type (abfd, base_type, format, field, ignore)
- bfd *abfd;
- elf32_hppa_reloc_type base_type;
- int format;
- int field;
- int ignore;
-{
- elf32_hppa_reloc_type *finaltype;
- elf32_hppa_reloc_type **final_types;
-
- /* Allocate slots for the BFD relocation. */
- final_types = (elf32_hppa_reloc_type **)
- bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type *) * 2);
- if (final_types == NULL)
- return NULL;
-
- /* Allocate space for the relocation itself. */
- finaltype = (elf32_hppa_reloc_type *)
- bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type));
- if (finaltype == NULL)
- return NULL;
-
- /* Some reasonable defaults. */
- final_types[0] = finaltype;
- final_types[1] = NULL;
-
-#define final_type finaltype[0]
-
- final_type = base_type;
-
- /* Just a tangle of nested switch statements to deal with the braindamage
- that a different field selector means a completely different relocation
- for PA ELF. */
- switch (base_type)
- {
- case R_HPPA:
- case R_HPPA_ABS_CALL:
- switch (format)
- {
- case 14:
- switch (field)
- {
- case e_rsel:
- case e_rrsel:
- final_type = R_PARISC_DIR14R;
- break;
- case e_rtsel:
- final_type = R_PARISC_DLTREL14R;
- break;
- case e_tsel:
- final_type = R_PARISC_DLTREL14F;
- break;
- case e_rpsel:
- final_type = R_PARISC_PLABEL14R;
- break;
- default:
- return NULL;
- }
- break;
-
- case 17:
- switch (field)
- {
- case e_fsel:
- final_type = R_PARISC_DIR17F;
- break;
- case e_rsel:
- case e_rrsel:
- final_type = R_PARISC_DIR17R;
- break;
- default:
- return NULL;
- }
- break;
-
- case 21:
- switch (field)
- {
- case e_lsel:
- case e_lrsel:
- final_type = R_PARISC_DIR21L;
- break;
- case e_ltsel:
- final_type = R_PARISC_DLTREL21L;
- break;
- case e_lpsel:
- final_type = R_PARISC_PLABEL21L;
- break;
- default:
- return NULL;
- }
- break;
-
- case 32:
- switch (field)
- {
- case e_fsel:
- final_type = R_PARISC_DIR32;
- break;
- case e_psel:
- final_type = R_PARISC_PLABEL32;
- break;
- default:
- return NULL;
- }
- break;
-
- default:
- return NULL;
- }
- break;
-
-
- case R_HPPA_GOTOFF:
- switch (format)
- {
- case 14:
- switch (field)
- {
- case e_rsel:
- case e_rrsel:
- final_type = R_PARISC_DPREL14R;
- break;
- case e_fsel:
- final_type = R_PARISC_DPREL14F;
- break;
- default:
- return NULL;
- }
- break;
-
- case 21:
- switch (field)
- {
- case e_lrsel:
- case e_lsel:
- final_type = R_PARISC_DPREL21L;
- break;
- default:
- return NULL;
- }
- break;
-
- default:
- return NULL;
- }
- break;
-
-
- case R_HPPA_PCREL_CALL:
- switch (format)
- {
- case 14:
- switch (field)
- {
- case e_rsel:
- case e_rrsel:
- final_type = R_PARISC_PCREL14R;
- break;
- case e_fsel:
- final_type = R_PARISC_PCREL14F;
- break;
- default:
- return NULL;
- }
- break;
-
- case 17:
- switch (field)
- {
- case e_rsel:
- case e_rrsel:
- final_type = R_PARISC_PCREL17R;
- break;
- case e_fsel:
- final_type = R_PARISC_PCREL17F;
- break;
- default:
- return NULL;
- }
- break;
-
- case 21:
- switch (field)
- {
- case e_lsel:
- case e_lrsel:
- final_type = R_PARISC_PCREL21L;
- break;
- default:
- return NULL;
- }
- break;
-
- default:
- return NULL;
- }
- break;
-
- default:
- return NULL;
- }
-
- return final_types;
-}
-
-#undef final_type
-
-/* Set the contents of a particular section at a particular location. */
-
-static boolean
-elf32_hppa_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- /* Ignore write requests for the symbol extension section until we've
- had the chance to rebuild it ourselves. */
- if (!strcmp (section->name, ".PARISC.symextn") && !symext_chain_size)
- return true;
- else
- return _bfd_elf_set_section_contents (abfd, section, location,
- offset, count);
-}
-
-/* Translate from an elf into field into a howto relocation pointer. */
-
-static void
-elf_info_to_howto (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf32_Internal_Rela *dst;
-{
- BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_PARISC_UNIMPLEMENTED);
- cache_ptr->howto = &elf_hppa_howto_table[ELF32_R_TYPE (dst->r_info)];
-}
-
-
-/* Actually perform a relocation. NOTE this is (mostly) superceeded
- by elf32_hppa_bfd_final_link_relocate which is called by the new
- fast linker. */
-
-static bfd_reloc_status_type
-hppa_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol_in;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- /* It is no longer valid to call hppa_elf_reloc when creating
- a final executable. */
- if (output_bfd)
- {
- reloc_entry->address += input_section->output_offset;
-
- /* Work around lossage in generic elf code to write relocations.
- (maps different section symbols into the same symbol index). */
- if ((symbol_in->flags & BSF_SECTION_SYM)
- && symbol_in->section)
- reloc_entry->addend += symbol_in->section->output_offset;
- return bfd_reloc_ok;
- }
- else
- {
- *error_message = (char *) "Unsupported call to hppa_elf_reloc";
- return bfd_reloc_notsupported;
- }
-}
-
-/* Actually perform a relocation as part of a final link. This can get
- rather hairy when linker stubs are needed. */
-
-static bfd_reloc_status_type
-elf32_hppa_bfd_final_link_relocate (howto, input_bfd, output_bfd,
- input_section, contents, offset, value,
- addend, info, sym_sec, sym_name, is_local)
- reloc_howto_type *howto;
- bfd *input_bfd;
- bfd *output_bfd;
- asection *input_section;
- bfd_byte *contents;
- bfd_vma offset;
- bfd_vma value;
- bfd_vma addend;
- struct bfd_link_info *info;
- asection *sym_sec;
- const char *sym_name;
- int is_local;
-{
- unsigned long insn;
- unsigned long r_type = howto->type;
- unsigned long r_format = howto->bitsize;
- unsigned long r_field = e_fsel;
- bfd_byte *hit_data = contents + offset;
- boolean r_pcrel = howto->pc_relative;
-
- insn = bfd_get_32 (input_bfd, hit_data);
-
- /* Make sure we have a value for $global$. FIXME isn't this effectively
- just like the gp pointer on MIPS? Can we use those routines for this
- purpose? */
- if (!elf32_hppa_hash_table (info)->global_sym_defined)
- {
- struct elf_link_hash_entry *h;
- asection *sec;
-
- h = elf_link_hash_lookup (elf_hash_table (info), "$global$", false,
- false, false);
-
- /* If there isn't a $global$, then we're in deep trouble. */
- if (h == NULL)
- return bfd_reloc_notsupported;
-
- /* If $global$ isn't a defined symbol, then we're still in deep
- trouble. */
- if (h->root.type != bfd_link_hash_defined)
- return bfd_reloc_undefined;
-
- sec = h->root.u.def.section;
- elf32_hppa_hash_table (info)->global_value = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- elf32_hppa_hash_table (info)->global_sym_defined = 1;
- }
-
- switch (r_type)
- {
- case R_PARISC_NONE:
- break;
-
- case R_PARISC_DIR32:
- case R_PARISC_DIR17F:
- case R_PARISC_PCREL17C:
- r_field = e_fsel;
- goto do_basic_type_1;
- case R_PARISC_DIR21L:
- case R_PARISC_PCREL21L:
- r_field = e_lrsel;
- goto do_basic_type_1;
- case R_PARISC_DIR17R:
- case R_PARISC_PCREL17R:
- case R_PARISC_DIR14R:
- case R_PARISC_PCREL14R:
- r_field = e_rrsel;
- goto do_basic_type_1;
-
- /* For all the DP relative relocations, we need to examine the symbol's
- section. If it's a code section, then "data pointer relative" makes
- no sense. In that case we don't adjust the "value", and for 21 bit
- addil instructions, we change the source addend register from %dp to
- %r0. */
- case R_PARISC_DPREL21L:
- r_field = e_lrsel;
- if (sym_sec->flags & SEC_CODE)
- {
- if ((insn & 0xfc000000) >> 26 == 0xa
- && (insn & 0x03e00000) >> 21 == 0x1b)
- insn &= ~0x03e00000;
- }
- else
- value -= elf32_hppa_hash_table (info)->global_value;
- goto do_basic_type_1;
- case R_PARISC_DPREL14R:
- r_field = e_rrsel;
- if ((sym_sec->flags & SEC_CODE) == 0)
- value -= elf32_hppa_hash_table (info)->global_value;
- goto do_basic_type_1;
- case R_PARISC_DPREL14F:
- r_field = e_fsel;
- if ((sym_sec->flags & SEC_CODE) == 0)
- value -= elf32_hppa_hash_table (info)->global_value;
- goto do_basic_type_1;
-
- /* These cases are separate as they may involve a lot more work
- to deal with linker stubs. */
- case R_PARISC_PLABEL32:
- case R_PARISC_PLABEL21L:
- case R_PARISC_PLABEL14R:
- case R_PARISC_PCREL17F:
- {
- bfd_vma location;
- unsigned int len, caller_args, callee_args;
- arg_reloc_type arg_reloc_types[5];
- struct elf32_hppa_args_hash_table *args_hash_table;
- struct elf32_hppa_args_hash_entry *args_hash;
- char *new_name, *stub_name;
-
- /* Get the field selector right. We'll need it in a minute. */
- if (r_type == R_PARISC_PCREL17F
- || r_type == R_PARISC_PLABEL32)
- r_field = e_fsel;
- else if (r_type == R_PARISC_PLABEL21L)
- r_field = e_lrsel;
- else if (r_type == R_PARISC_PLABEL14R)
- r_field = e_rrsel;
-
- /* Find out where we are and where we're going. */
- location = (offset +
- input_section->output_offset +
- input_section->output_section->vma);
-
- /* Now look for the argument relocation bits associated with the
- target. */
- len = strlen (sym_name) + 1;
- if (is_local)
- len += 9;
- new_name = bfd_malloc (len);
- if (!new_name)
- return bfd_reloc_notsupported;
- strcpy (new_name, sym_name);
-
- /* Local symbols have unique IDs. */
- if (is_local)
- sprintf (new_name + len - 10, "_%08x", (int)sym_sec);
-
- args_hash_table = elf32_hppa_hash_table (info)->args_hash_table;
-
- args_hash = elf32_hppa_args_hash_lookup (args_hash_table,
- new_name, false, false);
- if (args_hash == NULL)
- callee_args = 0;
- else
- callee_args = args_hash->arg_bits;
-
- /* If this is a CALL relocation, then get the caller's bits
- from the addend. Else use the magic 0x155 value for PLABELS.
-
- Also we don't care about the destination (value) for PLABELS. */
- if (r_type == R_PARISC_PCREL17F)
- caller_args = HPPA_R_ARG_RELOC (addend);
- else
- {
- caller_args = 0x155;
- location = value;
- }
-
- /* Any kind of linker stub needed? */
- if (((int)(value - location) > 0x3ffff)
- || ((int)(value - location) < (int)0xfffc0000)
- || elf32_hppa_arg_reloc_needed (caller_args, callee_args,
- arg_reloc_types))
- {
- struct elf32_hppa_stub_hash_table *stub_hash_table;
- struct elf32_hppa_stub_hash_entry *stub_hash;
- asection *stub_section;
-
- /* Build a name for the stub. */
-
- len = strlen (new_name);
- len += 23;
- stub_name = bfd_malloc (len);
- if (!stub_name)
- return bfd_reloc_notsupported;
- elf32_hppa_name_of_stub (caller_args, callee_args,
- location, value, stub_name);
- strcat (stub_name, new_name);
- free (new_name);
-
- stub_hash_table = elf32_hppa_hash_table (info)->stub_hash_table;
-
- stub_hash
- = elf32_hppa_stub_hash_lookup (stub_hash_table, stub_name,
- false, false);
-
- /* We're done with that name. */
- free (stub_name);
-
- /* The stub BFD only has one section. */
- stub_section = stub_hash_table->stub_bfd->sections;
-
- if (stub_hash != NULL)
- {
-
- if (r_type == R_PARISC_PCREL17F)
- {
- unsigned long delay_insn;
- unsigned int opcode, rtn_reg, ldo_target_reg, ldo_src_reg;
-
- /* We'll need to peek at the next insn. */
- delay_insn = bfd_get_32 (input_bfd, hit_data + 4);
- opcode = get_opcode (delay_insn);
-
- /* We also need to know the return register for this
- call. */
- rtn_reg = (insn & 0x03e00000) >> 21;
-
- ldo_src_reg = (delay_insn & 0x03e00000) >> 21;
- ldo_target_reg = (delay_insn & 0x001f0000) >> 16;
-
- /* Munge up the value and other parameters for
- hppa_elf_relocate_insn. */
-
- value = (stub_hash->offset
- + stub_section->output_offset
- + stub_section->output_section->vma);
-
- r_format = 17;
- r_field = e_fsel;
- r_pcrel = 0;
- addend = 0;
-
- /* We need to peek at the delay insn and determine if
- we'll need to swap the branch and its delay insn. */
- if ((insn & 2)
- || (opcode == LDO
- && ldo_target_reg == rtn_reg)
- || (delay_insn == 0x08000240))
- {
- /* No need to swap the branch and its delay slot, but
- we do need to make sure to jump past the return
- pointer update in the stub. */
- value += 4;
-
- /* If the delay insn does a return pointer adjustment,
- then we have to make sure it stays valid. */
- if (opcode == LDO
- && ldo_target_reg == rtn_reg)
- {
- delay_insn &= 0xfc00ffff;
- delay_insn |= ((31 << 21) | (31 << 16));
- bfd_put_32 (input_bfd, delay_insn, hit_data + 4);
- }
- /* Use a BLE to reach the stub. */
- insn = BLE_SR4_R0;
- }
- else
- {
- /* Wonderful, we have to swap the call insn and its
- delay slot. */
- bfd_put_32 (input_bfd, delay_insn, hit_data);
- /* Use a BLE,n to reach the stub. */
- insn = (BLE_SR4_R0 | 0x2);
- bfd_put_32 (input_bfd, insn, hit_data + 4);
- insn = hppa_elf_relocate_insn (input_bfd,
- input_section,
- insn, offset + 4,
- value, addend,
- r_format, r_field,
- r_pcrel);
- /* Update the instruction word. */
- bfd_put_32 (input_bfd, insn, hit_data + 4);
- return bfd_reloc_dangerous;
- }
- }
- else
- {
- /* PLABEL stuff is easy. */
-
- value = (stub_hash->offset
- + stub_section->output_offset
- + stub_section->output_section->vma);
- /* We don't need the RP adjustment for PLABELs. */
- value += 4;
- if (r_type == R_PARISC_PLABEL32)
- r_format = 32;
- else if (r_type == R_PARISC_PLABEL21L)
- r_format = 21;
- else if (r_type == R_PARISC_PLABEL14R)
- r_format = 14;
-
- r_pcrel = 0;
- addend = 0;
- }
- }
- else
- return bfd_reloc_notsupported;
- }
- goto do_basic_type_1;
- }
-
-do_basic_type_1:
- insn = hppa_elf_relocate_insn (input_bfd, input_section, insn,
- offset, value, addend, r_format,
- r_field, r_pcrel);
- break;
-
- /* Something we don't know how to handle. */
- default:
- return bfd_reloc_notsupported;
- }
-
- /* Update the instruction word. */
- bfd_put_32 (input_bfd, insn, hit_data);
- return (bfd_reloc_ok);
-}
-
-/* Return the address of the howto table entry to perform the CODE
- relocation for an ARCH machine. */
-
-static reloc_howto_type *
-elf_hppa_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- if ((int) code < (int) R_PARISC_UNIMPLEMENTED)
- {
- BFD_ASSERT ((int) elf_hppa_howto_table[(int) code].type == (int) code);
- return &elf_hppa_howto_table[(int) code];
- }
- return NULL;
-}
-
-/* Return true if SYM represents a local label symbol. */
-
-static boolean
-hppa_elf_is_local_label (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- return (sym->name[0] == 'L' && sym->name[1] == '$');
-}
-
-/* Do any backend specific processing when beginning to write an object
- file. For PA ELF we need to determine the size of the symbol extension
- section *before* any other output processing happens. */
-
-static void
-elf32_hppa_backend_begin_write_processing (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- unsigned int i;
- asection *symextn_sec;
-
- /* Size up the symbol extension section. */
- if ((abfd->outsymbols == NULL
- && info == NULL)
- || symext_chain_size != 0)
- return;
-
- if (info == NULL)
- {
- /* We were not called from the BFD ELF linker code, so we need
- to examine the output BFD's outsymbols.
-
- Note we can not build the symbol extensions now as the symbol
- map hasn't been set up. */
- for (i = 0; i < abfd->symcount; i++)
- {
- elf_symbol_type *symbol = (elf_symbol_type *)abfd->outsymbols[i];
-
- /* Only functions ever need an entry in the symbol extension
- section. */
- if (!(symbol->symbol.flags & BSF_FUNCTION))
- continue;
-
- /* And only if they specify the locations of their arguments. */
- if (symbol->tc_data.hppa_arg_reloc == 0)
- continue;
-
- /* Yup. This function symbol needs an entry. */
- symext_chain_size += 2 * ELF32_PARISC_SX_SIZE;
- }
- }
- else if (info->relocateable == true)
- {
- struct elf32_hppa_args_hash_table *table;
- table = elf32_hppa_hash_table (info)->args_hash_table;
-
- /* Determine the size of the symbol extension section. */
- elf32_hppa_args_hash_traverse (table,
- elf32_hppa_size_symext,
- &symext_chain_size);
- }
-
- /* Now create the section and set its size. We'll fill in the
- contents later. */
- symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME);
- if (symextn_sec == NULL)
- symextn_sec = bfd_make_section (abfd, SYMEXTN_SECTION_NAME);
-
- bfd_set_section_flags (abfd, symextn_sec,
- SEC_LOAD | SEC_HAS_CONTENTS | SEC_DATA);
- symextn_sec->output_section = symextn_sec;
- symextn_sec->output_offset = 0;
- bfd_set_section_alignment (abfd, symextn_sec, 2);
- bfd_set_section_size (abfd, symextn_sec, symext_chain_size);
-}
-
-/* Called for each entry in the args location hash table. For each
- entry we bump the size pointer by 2 records (16 bytes). */
-
-static boolean
-elf32_hppa_size_symext (gen_entry, in_args)
- struct bfd_hash_entry *gen_entry;
- PTR in_args;
-{
- bfd_size_type *sizep = (bfd_size_type *)in_args;
-
- *sizep += 2 * ELF32_PARISC_SX_SIZE;
- return true;
-}
-
-/* Backend routine called by the linker for each output symbol.
-
- For PA ELF we use this opportunity to add an appropriate entry
- to the symbol extension chain for function symbols. */
-
-static boolean
-elf32_hppa_link_output_symbol_hook (abfd, info, name, sym, section)
- bfd *abfd;
- struct bfd_link_info *info;
- const char *name;
- Elf_Internal_Sym *sym;
- asection *section;
-{
- char *new_name;
- unsigned int len, index;
- struct elf32_hppa_args_hash_table *args_hash_table;
- struct elf32_hppa_args_hash_entry *args_hash;
-
- /* If the args hash table is NULL, then we've encountered an error
- of some sorts (for example, an undefined symbol). In that case
- we've got nothing else to do.
-
- NOTE: elf_link_output_symbol will abort if we return false here! */
- if (elf32_hppa_hash_table (info)->args_hash_table == NULL)
- return true;
-
- index = elf32_hppa_hash_table (info)->output_symbol_count++;
-
- /* We need to look up this symbol in the args hash table to see if
- it has argument relocation bits. */
- if (ELF_ST_TYPE (sym->st_info) != STT_FUNC)
- return true;
-
- /* We know it's a function symbol of some kind. */
- len = strlen (name) + 1;
- if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
- len += 9;
-
- new_name = bfd_malloc (len);
- if (new_name == NULL)
- return false;
-
- strcpy (new_name, name);
- if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
- sprintf (new_name + len - 10, "_%08x", (int)section);
-
- /* Now that we have the unique name, we can look it up in the
- args hash table. */
- args_hash_table = elf32_hppa_hash_table (info)->args_hash_table;
- args_hash = elf32_hppa_args_hash_lookup (args_hash_table, new_name,
- false, false);
- free (new_name);
- if (args_hash == NULL)
- return true;
-
- /* We know this symbol has arg reloc bits. */
- add_entry_to_symext_chain (abfd, args_hash->arg_bits,
- index, &symext_rootP, &symext_lastP);
- return true;
-}
-
-/* Perform any processing needed late in the object file writing process.
- For PA ELF we build and set the contents of the symbol extension
- section. */
-
-static void
-elf32_hppa_backend_final_write_processing (abfd, linker)
- bfd *abfd;
- boolean linker;
-{
- asection *symextn_sec;
- unsigned int i;
-
- /* Now build the symbol extension section. */
- if (symext_chain_size == 0)
- return;
-
- if (! linker)
- {
- /* We were not called from the backend linker, so we still need
- to build the symbol extension chain.
-
- Look at each symbol, adding the appropriate information to the
- symbol extension section list as necessary. */
- for (i = 0; i < abfd->symcount; i++)
- {
- elf_symbol_type *symbol = (elf_symbol_type *) abfd->outsymbols[i];
-
- /* Only functions ever need an entry in the symbol extension
- section. */
- if (!(symbol->symbol.flags & BSF_FUNCTION))
- continue;
-
- /* And only if they specify the locations of their arguments. */
- if (symbol->tc_data.hppa_arg_reloc == 0)
- continue;
-
- /* Add this symbol's information to the chain. */
- add_entry_to_symext_chain (abfd, symbol->tc_data.hppa_arg_reloc,
- symbol->symbol.udata.i, &symext_rootP,
- &symext_lastP);
- }
- }
-
- /* Now fill in the contents of the symbol extension section. */
- elf_hppa_tc_make_sections (abfd, symext_rootP);
-
- /* And attach that as the section's contents. */
- symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME);
- if (symextn_sec == (asection *) 0)
- abort();
-
- symextn_sec->contents = (void *)symextn_contents;
-
- bfd_set_section_contents (abfd, symextn_sec, symextn_sec->contents,
- symextn_sec->output_offset, symextn_sec->_raw_size);
-}
-
-/* Update the symbol extention chain to include the symbol pointed to
- by SYMBOLP if SYMBOLP is a function symbol. Used internally and by GAS. */
-
-static void
-add_entry_to_symext_chain (abfd, arg_reloc, sym_idx, symext_root, symext_last)
- bfd *abfd;
- unsigned int arg_reloc;
- unsigned int sym_idx;
- symext_chainS **symext_root;
- symext_chainS **symext_last;
-{
- symext_chainS *symextP;
-
- /* Allocate memory and initialize this entry. */
- symextP = (symext_chainS *) bfd_alloc (abfd, sizeof (symext_chainS) * 2);
- if (!symextP)
- abort(); /* FIXME */
-
- symextP[0].entry = ELF32_PARISC_SX_WORD (PARISC_SXT_SYMNDX, sym_idx);
- symextP[0].next = &symextP[1];
-
- symextP[1].entry = ELF32_PARISC_SX_WORD (PARISC_SXT_ARG_RELOC, arg_reloc);
- symextP[1].next = NULL;
-
- /* Now update the chain itself so it can be walked later to build
- the symbol extension section. */
- if (*symext_root == NULL)
- {
- *symext_root = &symextP[0];
- *symext_last = &symextP[1];
- }
- else
- {
- (*symext_last)->next = &symextP[0];
- *symext_last = &symextP[1];
- }
-}
-
-/* Build the symbol extension section. */
-
-static void
-elf_hppa_tc_make_sections (abfd, symext_root)
- bfd *abfd;
- symext_chainS *symext_root;
-{
- symext_chainS *symextP;
- unsigned int i;
- asection *symextn_sec;
-
- symextn_sec = bfd_get_section_by_name (abfd, SYMEXTN_SECTION_NAME);
-
- /* Grab some memory for the contents of the symbol extension section
- itself. */
- symextn_contents = (bfd_byte *) bfd_zalloc (abfd,
- symextn_sec->_raw_size);
- if (!symextn_contents)
- abort(); /* FIXME */
-
- /* Fill in the contents of the symbol extension chain. */
- for (i = 0, symextP = symext_root; symextP; symextP = symextP->next, ++i)
- ELF32_PARISC_SX_PUT (abfd, (bfd_vma) symextP->entry,
- symextn_contents + i * ELF32_PARISC_SX_SIZE);
-
- return;
-}
-
-/* Do some PA ELF specific work after reading in the symbol table.
- In particular attach the argument relocation from the
- symbol extension section to the appropriate symbols. */
-
-static boolean
-elf32_hppa_backend_symbol_table_processing (abfd, esyms,symcnt)
- bfd *abfd;
- elf_symbol_type *esyms;
- unsigned int symcnt;
-{
- Elf32_Internal_Shdr *symextn_hdr =
- bfd_elf_find_section (abfd, SYMEXTN_SECTION_NAME);
- unsigned int i, current_sym_idx = 0;
-
- /* If no symbol extension existed, then all symbol extension information
- is assumed to be zero. */
- if (symextn_hdr == NULL)
- {
- for (i = 0; i < symcnt; i++)
- esyms[i].tc_data.hppa_arg_reloc = 0;
- return (true);
- }
-
- /* FIXME: Why not use bfd_get_section_contents here? Also should give
- memory back when we're done. */
- /* Allocate a buffer of the appropriate size for the symextn section. */
- symextn_hdr->contents = bfd_zalloc(abfd,symextn_hdr->sh_size);
- if (!symextn_hdr->contents)
- return false;
-
- /* Read in the symextn section. */
- if (bfd_seek (abfd, symextn_hdr->sh_offset, SEEK_SET) == -1)
- return false;
- if (bfd_read ((PTR) symextn_hdr->contents, 1, symextn_hdr->sh_size, abfd)
- != symextn_hdr->sh_size)
- return false;
-
- /* Parse entries in the symbol extension section, updating the symtab
- entries as we go */
- for (i = 0; i < symextn_hdr->sh_size / ELF32_PARISC_SX_SIZE; i++)
- {
- symext_entryS se =
- ELF32_PARISC_SX_GET (abfd,
- ((unsigned char *)symextn_hdr->contents
- + i * ELF32_PARISC_SX_SIZE));
- unsigned int se_value = ELF32_PARISC_SX_VAL (se);
- unsigned int se_type = ELF32_PARISC_SX_TYPE (se);
-
- switch (se_type)
- {
- case PARISC_SXT_NULL:
- break;
-
- case PARISC_SXT_SYMNDX:
- if (se_value >= symcnt)
- {
- bfd_set_error (bfd_error_bad_value);
- return (false);
- }
- current_sym_idx = se_value - 1;
- break;
-
- case PARISC_SXT_ARG_RELOC:
- esyms[current_sym_idx].tc_data.hppa_arg_reloc = se_value;
- break;
-
- default:
- bfd_set_error (bfd_error_bad_value);
- return (false);
- }
- }
- return (true);
-}
-
-/* Read and attach the symbol extension information for the symbols
- in INPUT_BFD to the argument location hash table. Handle locals
- if DO_LOCALS is true; likewise for globals when DO_GLOBALS is true. */
-
-static boolean
-elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table, local_syms)
- bfd *input_bfd;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf32_hppa_args_hash_table *args_hash_table;
- Elf_Internal_Sym *local_syms;
-{
- asection *symextn_sec;
- bfd_byte *contents;
- unsigned int i, n_entries, current_index = 0;
-
- /* Get the symbol extension section for this BFD. If no section exists
- then there's nothing to do. Likewise if the section exists, but
- has no contents. */
- symextn_sec = bfd_get_section_by_name (input_bfd, SYMEXTN_SECTION_NAME);
- if (symextn_sec == NULL)
- return true;
-
- /* Done separately so we can turn off SEC_HAS_CONTENTS (see below). */
- if (symextn_sec->_raw_size == 0)
- {
- symextn_sec->flags &= ~SEC_HAS_CONTENTS;
- return true;
- }
-
- contents = (bfd_byte *) bfd_malloc ((size_t) symextn_sec->_raw_size);
- if (contents == NULL)
- return false;
-
- /* How gross. We turn off SEC_HAS_CONTENTS for the input symbol extension
- sections to keep the generic ELF/BFD code from trying to do anything
- with them. We have to undo that hack temporarily so that we can read
- in the contents with the generic code. */
- symextn_sec->flags |= SEC_HAS_CONTENTS;
- if (bfd_get_section_contents (input_bfd, symextn_sec, contents,
- 0, symextn_sec->_raw_size) == false)
- {
- symextn_sec->flags &= ~SEC_HAS_CONTENTS;
- free (contents);
- return false;
- }
-
- /* Gross. Turn off SEC_HAS_CONTENTS for the input symbol extension
- sections (see above). */
- symextn_sec->flags &= ~SEC_HAS_CONTENTS;
-
- n_entries = symextn_sec->_raw_size / ELF32_PARISC_SX_SIZE;
- for (i = 0; i < n_entries; i++)
- {
- symext_entryS entry =
- ELF32_PARISC_SX_GET (input_bfd, contents + i * ELF32_PARISC_SX_SIZE);
- unsigned int value = ELF32_PARISC_SX_VAL (entry);
- unsigned int type = ELF32_PARISC_SX_TYPE (entry);
- struct elf32_hppa_args_hash_entry *args_hash;
-
- switch (type)
- {
- case PARISC_SXT_NULL:
- break;
-
- case PARISC_SXT_SYMNDX:
- if (value >= symtab_hdr->sh_size / sizeof (Elf32_External_Sym))
- {
- bfd_set_error (bfd_error_bad_value);
- free (contents);
- return false;
- }
- current_index = value;
- break;
-
- case PARISC_SXT_ARG_RELOC:
- if (current_index < symtab_hdr->sh_info)
- {
- Elf_Internal_Shdr *hdr;
- char *new_name;
- const char *sym_name;
- asection *sym_sec;
- unsigned int len;
-
- hdr = elf_elfsections (input_bfd)[local_syms[current_index].st_shndx];
- sym_sec = hdr->bfd_section;
- sym_name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- local_syms[current_index].st_name);
- len = strlen (sym_name) + 10;
- new_name = bfd_malloc (len);
- if (new_name == NULL)
- {
- free (contents);
- return false;
- }
- strcpy (new_name, sym_name);
- sprintf (new_name + len - 10, "_%08x", (int)sym_sec);
-
- /* This is a global symbol with argument location info.
- We need to enter it into the hash table. */
- args_hash = elf32_hppa_args_hash_lookup (args_hash_table,
- new_name, true,
- true);
- free (new_name);
- if (args_hash == NULL)
- {
- free (contents);
- return false;
- }
- args_hash->arg_bits = value;
- break;
- }
- else if (current_index >= symtab_hdr->sh_info)
- {
- struct elf_link_hash_entry *h;
-
- current_index -= symtab_hdr->sh_info;
- h = elf_sym_hashes(input_bfd)[current_index];
- /* This is a global symbol with argument location
- information. We need to enter it into the hash table. */
- args_hash = elf32_hppa_args_hash_lookup (args_hash_table,
- h->root.root.string,
- true, true);
- if (args_hash == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- free (contents);
- return false;
- }
- args_hash->arg_bits = value;
- break;
- }
- else
- break;
-
- default:
- bfd_set_error (bfd_error_bad_value);
- free (contents);
- return false;
- }
- }
- free (contents);
- return true;
-}
-
-/* Undo the generic ELF code's subtraction of section->vma from the
- value of each external symbol. */
-
-static boolean
-elf32_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
- bfd *abfd;
- struct bfd_link_info *info;
- const Elf_Internal_Sym *sym;
- const char **namep;
- flagword *flagsp;
- asection **secp;
- bfd_vma *valp;
-{
- *valp += (*secp)->vma;
- return true;
-}
-
-/* Determine the name of the stub needed to perform a call assuming the
- argument relocation bits for caller and callee are in CALLER and CALLEE
- for a call from LOCATION to DESTINATION. Copy the name into STUB_NAME. */
-
-static void
-elf32_hppa_name_of_stub (caller, callee, location, destination, stub_name)
- unsigned int caller, callee;
- bfd_vma location, destination;
- char *stub_name;
-{
- arg_reloc_type arg_reloc_types[5];
-
- if (elf32_hppa_arg_reloc_needed (caller, callee, arg_reloc_types))
- {
- arg_reloc_location i;
- /* Fill in the basic template. */
- strcpy (stub_name, "__XX_XX_XX_XX_XX_stub_");
-
- /* Now fix the specifics. */
- for (i = ARG0; i <= RET; i++)
- switch (arg_reloc_types[i])
- {
- case NO:
- stub_name[3 * i + 2] = 'N';
- stub_name[3 * i + 3] = 'O';
- break;
- case GF:
- stub_name[3 * i + 2] = 'G';
- stub_name[3 * i + 3] = 'F';
- break;
- case FG:
- stub_name[3 * i + 2] = 'F';
- stub_name[3 * i + 3] = 'G';
- break;
- case GD:
- stub_name[3 * i + 2] = 'G';
- stub_name[3 * i + 3] = 'D';
- break;
- case DG:
- stub_name[3 * i + 2] = 'D';
- stub_name[3 * i + 3] = 'G';
- break;
- }
- }
- else
- strcpy (stub_name, "_____long_branch_stub_");
-}
-
-/* Determine if an argument relocation stub is needed to perform a
- call assuming the argument relocation bits for caller and callee
- are in CALLER and CALLEE. Place the type of relocations (if any)
- into stub_types_p. */
-
-static boolean
-elf32_hppa_arg_reloc_needed (caller, callee, stub_types)
- unsigned int caller, callee;
- arg_reloc_type stub_types[5];
-{
- /* Special case for no relocations. */
- if (caller == 0 || callee == 0)
- return 0;
- else
- {
- arg_location caller_loc[5];
- arg_location callee_loc[5];
-
- /* Extract the location information for the argument and return
- value on both the caller and callee sides. */
- caller_loc[ARG0] = EXTRACT_ARBITS (caller, ARG0);
- callee_loc[ARG0] = EXTRACT_ARBITS (callee, ARG0);
- caller_loc[ARG1] = EXTRACT_ARBITS (caller, ARG1);
- callee_loc[ARG1] = EXTRACT_ARBITS (callee, ARG1);
- caller_loc[ARG2] = EXTRACT_ARBITS (caller, ARG2);
- callee_loc[ARG2] = EXTRACT_ARBITS (callee, ARG2);
- caller_loc[ARG3] = EXTRACT_ARBITS (caller, ARG3);
- callee_loc[ARG3] = EXTRACT_ARBITS (callee, ARG3);
- caller_loc[RET] = EXTRACT_ARBITS (caller, RET);
- callee_loc[RET] = EXTRACT_ARBITS (callee, RET);
-
- /* Check some special combinations. This is necessary to
- deal with double precision FP arguments. */
- if (caller_loc[ARG0] == AR_FU || caller_loc[ARG1] == AR_FU)
- {
- caller_loc[ARG0] = AR_FPDBL1;
- caller_loc[ARG1] = AR_NO;
- }
- if (caller_loc[ARG2] == AR_FU || caller_loc[ARG3] == AR_FU)
- {
- caller_loc[ARG2] = AR_FPDBL2;
- caller_loc[ARG3] = AR_NO;
- }
- if (callee_loc[ARG0] == AR_FU || callee_loc[ARG1] == AR_FU)
- {
- callee_loc[ARG0] = AR_FPDBL1;
- callee_loc[ARG1] = AR_NO;
- }
- if (callee_loc[ARG2] == AR_FU || callee_loc[ARG3] == AR_FU)
- {
- callee_loc[ARG2] = AR_FPDBL2;
- callee_loc[ARG3] = AR_NO;
- }
-
- /* Now look up any relocation needed for each argument and the
- return value. */
- stub_types[ARG0] = arg_mismatches[caller_loc[ARG0]][callee_loc[ARG0]];
- stub_types[ARG1] = arg_mismatches[caller_loc[ARG1]][callee_loc[ARG1]];
- stub_types[ARG2] = arg_mismatches[caller_loc[ARG2]][callee_loc[ARG2]];
- stub_types[ARG3] = arg_mismatches[caller_loc[ARG3]][callee_loc[ARG3]];
- stub_types[RET] = ret_mismatches[caller_loc[RET]][callee_loc[RET]];
-
- return (stub_types[ARG0] != NO
- || stub_types[ARG1] != NO
- || stub_types[ARG2] != NO
- || stub_types[ARG3] != NO
- || stub_types[RET] != NO);
- }
-}
-
-/* Compute the size of the stub needed to call from LOCATION to DESTINATION
- (a function named SYM_NAME), with argument relocation bits CALLER and
- CALLEE. Return zero if no stub is needed to perform such a call. */
-
-static unsigned int
-elf32_hppa_size_of_stub (callee, caller, location, destination, sym_name)
- unsigned int callee, caller;
- bfd_vma location, destination;
- const char *sym_name;
-{
- arg_reloc_type arg_reloc_types[5];
-
- /* Determine if a long branch or argument relocation stub is needed.
- If an argument relocation stub is needed, the relocation will be
- stored into arg_reloc_types. */
- if (!(((int)(location - destination) > 0x3ffff)
- || ((int)(location - destination) < (int)0xfffc0000)
- || elf32_hppa_arg_reloc_needed (caller, callee, arg_reloc_types)))
- return 0;
-
- /* Some kind of stub is needed. Determine how big it needs to be.
- First check for argument relocation stubs as they also handle
- long calls. Then check for long calls to millicode and finally
- the normal long calls. */
- if (arg_reloc_types[ARG0] != NO
- || arg_reloc_types[ARG1] != NO
- || arg_reloc_types[ARG2] != NO
- || arg_reloc_types[ARG3] != NO
- || arg_reloc_types[RET] != NO)
- {
- /* Some kind of argument relocation stub is needed. */
- unsigned int len = 16;
- arg_reloc_location i;
-
- /* Each GR or FG relocation takes 2 insns, each GD or DG
- relocation takes 3 insns. Plus 4 more insns for the
- RP adjustment, ldil & (be | ble) and copy. */
- for (i = ARG0; i <= RET; i++)
- switch (arg_reloc_types[i])
- {
- case GF:
- case FG:
- len += 8;
- break;
-
- case GD:
- case DG:
- len += 12;
- break;
-
- default:
- break;
- }
-
- /* Extra instructions are needed if we're relocating a return value. */
- if (arg_reloc_types[RET] != NO)
- len += 12;
-
- return len;
- }
- else if (!strncmp ("$$", sym_name, 2)
- && strcmp ("$$dyncall", sym_name))
- return 12;
- else
- return 16;
-}
-
-/* Build one linker stub as defined by the stub hash table entry GEN_ENTRY.
- IN_ARGS contains the stub BFD and link info pointers. */
-
-static boolean
-elf32_hppa_build_one_stub (gen_entry, in_args)
- struct bfd_hash_entry *gen_entry;
- PTR in_args;
-{
- void **args = (void **)in_args;
- bfd *stub_bfd = (bfd *)args[0];
- struct bfd_link_info *info = (struct bfd_link_info *)args[1];
- struct elf32_hppa_stub_hash_entry *entry;
- struct elf32_hppa_stub_hash_table *stub_hash_table;
- bfd_byte *loc;
- symvalue sym_value;
- const char *sym_name;
-
- /* Initialize pointers to the stub hash table, the particular entry we
- are building a stub for, and where (in memory) we should place the stub
- instructions. */
- entry = (struct elf32_hppa_stub_hash_entry *)gen_entry;
- stub_hash_table = elf32_hppa_hash_table(info)->stub_hash_table;
- loc = stub_hash_table->location;
-
- /* Make a note of the offset within the stubs for this entry. */
- entry->offset = stub_hash_table->offset;
-
- /* The symbol's name starts at offset 22. */
- sym_name = entry->root.string + 22;
-
- sym_value = (entry->target_value
- + entry->target_section->output_offset
- + entry->target_section->output_section->vma);
-
- if (strncmp ("_____long_branch_stub_", entry->root.string, 22))
- {
- /* This must be an argument or return value relocation stub. */
- unsigned long insn;
- arg_reloc_location i;
- bfd_byte *begin_loc = loc;
-
- /* First the return pointer adjustment. Depending on exact calling
- sequence this instruction may be skipped. */
- bfd_put_32 (stub_bfd, LDO_M4_R31_R31, loc);
- loc += 4;
-
- /* If we are relocating a return value, then we're going to have
- to return into the stub. So we have to save off the user's
- return pointer into the stack at RP'. */
- if (strncmp (entry->root.string + 14, "NO", 2))
- {
- bfd_put_32 (stub_bfd, STW_R31_M8R30, loc);
- loc += 4;
- }
-
- /* Iterate over the argument relocations, emitting instructions
- to move them around as necessary. */
- for (i = ARG0; i <= ARG3; i++)
- {
- if (!strncmp (entry->root.string + 3 * i + 2, "GF", 2))
- {
- bfd_put_32 (stub_bfd, STW_ARG_M16R30 | ((26 - i) << 16), loc);
- bfd_put_32 (stub_bfd, FLDW_M16R30_FARG | (4 + i), loc + 4);
- loc += 8;
- }
- else if (!strncmp (entry->root.string + 3 * i + 2, "FG", 2))
- {
- bfd_put_32 (stub_bfd, FSTW_FARG_M16R30 | (4 + i), loc);
- bfd_put_32 (stub_bfd, LDW_M16R30_ARG | ((26 - i) << 16), loc + 4);
- loc += 8;
- }
- else if (!strncmp (entry->root.string + 3 * i + 2, "GD", 2))
- {
- bfd_put_32 (stub_bfd, STW_ARG_M12R30 | ((26 - i) << 16), loc);
- bfd_put_32 (stub_bfd, STW_ARG_M16R30 | ((25 - i) << 16), loc + 4);
- bfd_put_32 (stub_bfd, FLDD_M16R30_FARG | (5 + i), loc + 8);
- loc += 12;
- }
- else if (!strncmp (entry->root.string + 3 * i + 2, "DG", 2))
- {
- bfd_put_32 (stub_bfd, FSTD_FARG_M16R30 | (5 + i), loc);
- bfd_put_32 (stub_bfd, LDW_M12R30_ARG | ((26 - i) << 16), loc + 4);
- bfd_put_32 (stub_bfd, LDW_M16R30_ARG | ((25 - i) << 16), loc + 8);
- loc += 12;
- }
- }
-
- /* Load the high bits of the target address into %r1. */
- insn = hppa_rebuild_insn (stub_bfd, LDIL_R1,
- hppa_field_adjust (sym_value, 0, e_lrsel), 21);
- bfd_put_32 (stub_bfd, insn, loc);
- loc += 4;
-
- /* If we are relocating a return value, then we're going to have
- to return into the stub, then perform the return value relocation. */
- if (strncmp (entry->root.string + 14, "NO", 2))
- {
- /* To return to the stub we "ble" to the target and copy the return
- pointer from %r31 into %r2. */
- insn = hppa_rebuild_insn (stub_bfd,
- BLE_SR4_R1,
- hppa_field_adjust (sym_value, 0,
- e_rrsel) >> 2,
- 17);
- bfd_put_32 (stub_bfd, insn, loc);
- bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 4);
-
- /* Reload the return pointer for our caller from the stack. */
- bfd_put_32 (stub_bfd, LDW_M8R30_R31, loc + 8);
- loc += 12;
-
- /* Perform the return value relocation. */
- if (!strncmp (entry->root.string + 14, "GF", 2))
- {
- bfd_put_32 (stub_bfd, STW_ARG_M16R30 | (28 << 16), loc);
- bfd_put_32 (stub_bfd, FLDW_M16R30_FARG | 4, loc + 4);
- loc += 8;
- }
- else if (!strncmp (entry->root.string + 14, "FG", 2))
- {
- bfd_put_32 (stub_bfd, FSTW_FARG_M16R30 | 4, loc);
- bfd_put_32 (stub_bfd, LDW_M16R30_ARG | (28 << 16), loc + 4);
- loc += 8;
- }
- else if (!strncmp (entry->root.string + 2, "GD", 2))
- {
- bfd_put_32 (stub_bfd, STW_ARG_M12R30 | (28 << 16), loc);
- bfd_put_32 (stub_bfd, STW_ARG_M16R30 | (29 << 16), loc + 4);
- bfd_put_32 (stub_bfd, FLDD_M16R30_FARG | 4, loc + 8);
- loc += 12;
- }
- else if (!strncmp (entry->root.string + 2, "DG", 2))
- {
- bfd_put_32 (stub_bfd, FSTD_FARG_M16R30 | 4, loc);
- bfd_put_32 (stub_bfd, LDW_M12R30_ARG | (28 << 16), loc + 4);
- bfd_put_32 (stub_bfd, LDW_M16R30_ARG | (29 << 16), loc + 8);
- loc += 12;
- }
- /* Branch back to the user's code now. */
- bfd_put_32 (stub_bfd, BV_N_0_R31, loc);
- loc += 4;
- }
- else
- {
- /* No return value relocation, so we can simply "be" to the
- target and copy out return pointer into %r2. */
- insn = hppa_rebuild_insn (stub_bfd, BE_SR4_R1,
- hppa_field_adjust (sym_value, 0,
- e_rrsel) >> 2, 17);
- bfd_put_32 (stub_bfd, insn, loc);
- bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 4);
- loc += 8;
- }
-
- /* Update the location and offsets. */
- stub_hash_table->location += (loc - begin_loc);
- stub_hash_table->offset += (loc - begin_loc);
- }
- else
- {
- /* Create one of two variant long branch stubs. One for $$dyncall and
- normal calls, the other for calls to millicode. */
- unsigned long insn;
- int millicode_call = 0;
-
- if (!strncmp ("$$", sym_name, 2) && strcmp ("$$dyncall", sym_name))
- millicode_call = 1;
-
- /* First the return pointer adjustment. Depending on exact calling
- sequence this instruction may be skipped. */
- bfd_put_32 (stub_bfd, LDO_M4_R31_R31, loc);
-
- /* The next two instructions are the long branch itself. A long branch
- is formed with "ldil" loading the upper bits of the target address
- into a register, then branching with "be" which adds in the lower bits.
- Long branches to millicode nullify the delay slot of the "be". */
- insn = hppa_rebuild_insn (stub_bfd, LDIL_R1,
- hppa_field_adjust (sym_value, 0, e_lrsel), 21);
- bfd_put_32 (stub_bfd, insn, loc + 4);
- insn = hppa_rebuild_insn (stub_bfd, BE_SR4_R1 | (millicode_call ? 2 : 0),
- hppa_field_adjust (sym_value, 0, e_rrsel) >> 2,
- 17);
- bfd_put_32 (stub_bfd, insn, loc + 8);
-
- if (!millicode_call)
- {
- /* The sequence to call this stub places the return pointer into %r31,
- the final target expects the return pointer in %r2, so copy the
- return pointer into the proper register. */
- bfd_put_32 (stub_bfd, COPY_R31_R2, loc + 12);
-
- /* Update the location and offsets. */
- stub_hash_table->location += 16;
- stub_hash_table->offset += 16;
- }
- else
- {
- /* Update the location and offsets. */
- stub_hash_table->location += 12;
- stub_hash_table->offset += 12;
- }
-
- }
- return true;
-}
-
-/* External entry points for sizing and building linker stubs. */
-
-/* Build all the stubs associated with the current output file. The
- stubs are kept in a hash table attached to the main linker hash
- table. This is called via hppaelf_finish in the linker. */
-
-boolean
-elf32_hppa_build_stubs (stub_bfd, info)
- bfd *stub_bfd;
- struct bfd_link_info *info;
-{
- /* The stub BFD only has one section. */
- asection *stub_sec = stub_bfd->sections;
- struct elf32_hppa_stub_hash_table *table;
- unsigned int size;
- void *args[2];
-
- /* So we can pass both the BFD for the stubs and the link info
- structure to the routine which actually builds stubs. */
- args[0] = stub_bfd;
- args[1] = info;
-
- /* Allocate memory to hold the linker stubs. */
- size = bfd_section_size (stub_bfd, stub_sec);
- stub_sec->contents = (unsigned char *) bfd_zalloc (stub_bfd, size);
- if (stub_sec->contents == NULL)
- return false;
- table = elf32_hppa_hash_table(info)->stub_hash_table;
- table->location = stub_sec->contents;
-
- /* Build the stubs as directed by the stub hash table. */
- elf32_hppa_stub_hash_traverse (table, elf32_hppa_build_one_stub, args);
-
- return true;
-}
-
-/* Determine and set the size of the stub section for a final link.
-
- The basic idea here is to examine all the relocations looking for
- PC-relative calls to a target that is unreachable with a "bl"
- instruction or calls where the caller and callee disagree on the
- location of their arguments or return value. */
-
-boolean
-elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info)
- bfd *stub_bfd;
- bfd *output_bfd;
- struct bfd_link_info *link_info;
-{
- bfd *input_bfd;
- asection *section, *stub_sec = 0;
- Elf_Internal_Shdr *symtab_hdr;
- Elf_Internal_Sym *local_syms, *isym, **all_local_syms;
- Elf32_External_Sym *ext_syms, *esym;
- unsigned int i, index, bfd_count = 0;
- struct elf32_hppa_stub_hash_table *stub_hash_table = 0;
- struct elf32_hppa_args_hash_table *args_hash_table = 0;
-
- /* Create and initialize the stub hash table. */
- stub_hash_table = ((struct elf32_hppa_stub_hash_table *)
- bfd_malloc (sizeof (struct elf32_hppa_stub_hash_table)));
- if (!stub_hash_table)
- goto error_return;
-
- if (!elf32_hppa_stub_hash_table_init (stub_hash_table, stub_bfd,
- elf32_hppa_stub_hash_newfunc))
- goto error_return;
-
- /* Likewise for the argument location hash table. */
- args_hash_table = ((struct elf32_hppa_args_hash_table *)
- bfd_malloc (sizeof (struct elf32_hppa_args_hash_table)));
- if (!args_hash_table)
- goto error_return;
-
- if (!elf32_hppa_args_hash_table_init (args_hash_table,
- elf32_hppa_args_hash_newfunc))
- goto error_return;
-
- /* Attach the hash tables to the main hash table. */
- elf32_hppa_hash_table(link_info)->stub_hash_table = stub_hash_table;
- elf32_hppa_hash_table(link_info)->args_hash_table = args_hash_table;
-
- /* Count the number of input BFDs. */
- for (input_bfd = link_info->input_bfds;
- input_bfd != NULL;
- input_bfd = input_bfd->link_next)
- bfd_count++;
-
- /* We want to read in symbol extension records only once. To do this
- we need to read in the local symbols in parallel and save them for
- later use; so hold pointers to the local symbols in an array. */
- all_local_syms
- = (Elf_Internal_Sym **) bfd_malloc (sizeof (Elf_Internal_Sym *)
- * bfd_count);
- if (all_local_syms == NULL)
- goto error_return;
- memset (all_local_syms, 0, sizeof (Elf_Internal_Sym *) * bfd_count);
-
- /* Walk over all the input BFDs adding entries to the args hash table
- for all the external functions. */
- for (input_bfd = link_info->input_bfds, index = 0;
- input_bfd != NULL;
- input_bfd = input_bfd->link_next, index++)
- {
- /* We'll need the symbol table in a second. */
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- if (symtab_hdr->sh_info == 0)
- continue;
-
- /* We need an array of the local symbols attached to the input bfd.
- Unfortunately, we're going to have to read & swap them in. */
- local_syms
- = (Elf_Internal_Sym *) bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf_Internal_Sym));
- if (local_syms == NULL)
- {
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
- all_local_syms[index] = local_syms;
-
- ext_syms
- = (Elf32_External_Sym *) bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf32_External_Sym));
- if (ext_syms == NULL)
- {
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
-
- if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || bfd_read (ext_syms, 1,
- (symtab_hdr->sh_info
- * sizeof (Elf32_External_Sym)), input_bfd)
- != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym)))
- {
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- free (ext_syms);
- goto error_return;
- }
-
- /* Swap the local symbols in. */
- isym = local_syms;
- esym = ext_syms;
- for (i = 0; i < symtab_hdr->sh_info; i++, esym++, isym++)
- bfd_elf32_swap_symbol_in (input_bfd, esym, isym);
-
- /* Now we can free the external symbols. */
- free (ext_syms);
-
- if (elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table,
- local_syms) == false)
- {
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
- }
-
- /* Magic as we know the stub bfd only has one section. */
- stub_sec = stub_bfd->sections;
-
- /* If generating a relocateable output file, then we don't
- have to examine the relocs. */
- if (link_info->relocateable)
- {
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- return true;
- }
-
- /* Now that we have argument location information for all the global
- functions we can start looking for stubs. */
- for (input_bfd = link_info->input_bfds, index = 0;
- input_bfd != NULL;
- input_bfd = input_bfd->link_next, index++)
- {
- /* We'll need the symbol table in a second. */
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- if (symtab_hdr->sh_info == 0)
- continue;
-
- local_syms = all_local_syms[index];
-
- /* Walk over each section attached to the input bfd. */
- for (section = input_bfd->sections;
- section != NULL;
- section = section->next)
- {
- Elf_Internal_Shdr *input_rel_hdr;
- Elf32_External_Rela *external_relocs, *erelaend, *erela;
- Elf_Internal_Rela *internal_relocs, *irelaend, *irela;
-
- /* If there aren't any relocs, then there's nothing to do. */
- if ((section->flags & SEC_RELOC) == 0
- || section->reloc_count == 0)
- continue;
-
- /* Allocate space for the external relocations. */
- external_relocs
- = ((Elf32_External_Rela *)
- bfd_malloc (section->reloc_count
- * sizeof (Elf32_External_Rela)));
- if (external_relocs == NULL)
- {
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
-
- /* Likewise for the internal relocations. */
- internal_relocs
- = ((Elf_Internal_Rela *)
- bfd_malloc (section->reloc_count * sizeof (Elf_Internal_Rela)));
- if (internal_relocs == NULL)
- {
- free (external_relocs);
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
-
- /* Read in the external relocs. */
- input_rel_hdr = &elf_section_data (section)->rel_hdr;
- if (bfd_seek (input_bfd, input_rel_hdr->sh_offset, SEEK_SET) != 0
- || bfd_read (external_relocs, 1, input_rel_hdr->sh_size,
- input_bfd) != input_rel_hdr->sh_size)
- {
- free (external_relocs);
- free (internal_relocs);
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
-
- /* Swap in the relocs. */
- erela = external_relocs;
- erelaend = erela + section->reloc_count;
- irela = internal_relocs;
- for (; erela < erelaend; erela++, irela++)
- bfd_elf32_swap_reloca_in (input_bfd, erela, irela);
-
- /* We're done with the external relocs, free them. */
- free (external_relocs);
-
- /* Now examine each relocation. */
- irela = internal_relocs;
- irelaend = irela + section->reloc_count;
- for (; irela < irelaend; irela++)
- {
- long r_type, callee_args, caller_args, size_of_stub;
- unsigned long r_index;
- struct elf_link_hash_entry *hash;
- struct elf32_hppa_stub_hash_entry *stub_hash;
- struct elf32_hppa_args_hash_entry *args_hash;
- Elf_Internal_Sym *sym;
- asection *sym_sec;
- const char *sym_name;
- symvalue sym_value;
- bfd_vma location, destination;
- char *new_name = NULL;
-
- r_type = ELF32_R_TYPE (irela->r_info);
- r_index = ELF32_R_SYM (irela->r_info);
-
- if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
- {
- bfd_set_error (bfd_error_bad_value);
- free (internal_relocs);
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
-
- /* Only look for stubs on call instructions or plabel
- references. */
- if (r_type != R_PARISC_PCREL17F
- && r_type != R_PARISC_PLABEL32
- && r_type != R_PARISC_PLABEL21L
- && r_type != R_PARISC_PLABEL14R)
- continue;
-
- /* Now determine the call target, its name, value, section
- and argument relocation bits. */
- hash = NULL;
- sym = NULL;
- sym_sec = NULL;
- if (r_index < symtab_hdr->sh_info)
- {
- /* It's a local symbol. */
- Elf_Internal_Shdr *hdr;
-
- sym = local_syms + r_index;
- hdr = elf_elfsections (input_bfd)[sym->st_shndx];
- sym_sec = hdr->bfd_section;
- sym_name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
- sym_value = (ELF_ST_TYPE (sym->st_info) == STT_SECTION
- ? 0 : sym->st_value);
- destination = (sym_value
- + sym_sec->output_offset
- + sym_sec->output_section->vma);
-
- /* Tack on an ID so we can uniquely identify this local
- symbol in the stub or arg info hash tables. */
- new_name = bfd_malloc (strlen (sym_name) + 10);
- if (new_name == 0)
- {
- free (internal_relocs);
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
- sprintf (new_name, "%s_%08x", sym_name, (int)sym_sec);
- sym_name = new_name;
- }
- else
- {
- /* It's an external symbol. */
- long index;
-
- index = r_index - symtab_hdr->sh_info;
- hash = elf_sym_hashes (input_bfd)[index];
- if (hash->root.type == bfd_link_hash_defined
- || hash->root.type == bfd_link_hash_defweak)
- {
- sym_sec = hash->root.u.def.section;
- sym_name = hash->root.root.string;
- sym_value = hash->root.u.def.value;
- destination = (sym_value
- + sym_sec->output_offset
- + sym_sec->output_section->vma);
- }
- else
- {
- bfd_set_error (bfd_error_bad_value);
- free (internal_relocs);
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
- }
-
- args_hash = elf32_hppa_args_hash_lookup (args_hash_table,
- sym_name, false, false);
-
- /* Get both caller and callee argument information. */
- if (args_hash == NULL)
- callee_args = 0;
- else
- callee_args = args_hash->arg_bits;
-
- /* For calls get the caller's bits from the addend of
- the call relocation. For PLABELS the caller's bits
- are assumed to have all args & return values in general
- registers (0x155). */
- if (r_type == R_PARISC_PCREL17F)
- caller_args = HPPA_R_ARG_RELOC (irela->r_addend);
- else
- caller_args = 0x155;
-
- /* Now determine where the call point is. */
- location = (section->output_offset
- + section->output_section->vma
- + irela->r_offset);
-
- /* We only care about the destination for PCREL function
- calls (eg. we don't care for PLABELS). */
- if (r_type != R_PARISC_PCREL17F)
- location = destination;
-
- /* Determine what (if any) linker stub is needed and its
- size (in bytes). */
- size_of_stub = elf32_hppa_size_of_stub (callee_args,
- caller_args,
- location,
- destination,
- sym_name);
- if (size_of_stub != 0)
- {
- char *stub_name;
- unsigned int len;
-
- /* Get the name of this stub. */
- len = strlen (sym_name);
- len += 23;
-
- stub_name = bfd_malloc (len);
- if (!stub_name)
- {
- /* Because sym_name was mallocd above for local
- symbols. */
- if (r_index < symtab_hdr->sh_info)
- free (new_name);
-
- free (internal_relocs);
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
- elf32_hppa_name_of_stub (caller_args, callee_args,
- location, destination, stub_name);
- strcat (stub_name + 22, sym_name);
-
- /* Because sym_name was malloced above for local symbols. */
- if (r_index < symtab_hdr->sh_info)
- free (new_name);
-
- stub_hash
- = elf32_hppa_stub_hash_lookup (stub_hash_table, stub_name,
- false, false);
- if (stub_hash != NULL)
- {
- /* The proper stub has already been created, nothing
- else to do. */
- free (stub_name);
- }
- else
- {
- bfd_set_section_size (stub_bfd, stub_sec,
- (bfd_section_size (stub_bfd,
- stub_sec)
- + size_of_stub));
-
- /* Enter this entry into the linker stub hash table. */
- stub_hash
- = elf32_hppa_stub_hash_lookup (stub_hash_table,
- stub_name, true, true);
- if (stub_hash == NULL)
- {
- free (stub_name);
- free (internal_relocs);
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- goto error_return;
- }
-
- /* We'll need these to determine the address that the
- stub will branch to. */
- stub_hash->target_value = sym_value;
- stub_hash->target_section = sym_sec;
- }
- free (stub_name);
- }
- }
- /* We're done with the internal relocs, free them. */
- free (internal_relocs);
- }
- }
- /* We're done with the local symbols, free them. */
- for (i = 0; i < bfd_count; i++)
- if (all_local_syms[i])
- free (all_local_syms[i]);
- free (all_local_syms);
- return true;
-
-error_return:
- /* Return gracefully, avoiding dangling references to the hash tables. */
- if (stub_hash_table)
- {
- elf32_hppa_hash_table(link_info)->stub_hash_table = NULL;
- free (stub_hash_table);
- }
- if (args_hash_table)
- {
- elf32_hppa_hash_table(link_info)->args_hash_table = NULL;
- free (args_hash_table);
- }
- /* Set the size of the stub section to zero since we're never going
- to create them. Avoids losing when we try to get its contents
- too. */
- bfd_set_section_size (stub_bfd, stub_sec, 0);
- return false;
-}
-
-/* Misc BFD support code. */
-#define bfd_elf32_bfd_reloc_type_lookup elf_hppa_reloc_type_lookup
-#define bfd_elf32_bfd_is_local_label hppa_elf_is_local_label
-
-/* Symbol extension stuff. */
-#define bfd_elf32_set_section_contents elf32_hppa_set_section_contents
-#define elf_backend_symbol_table_processing \
- elf32_hppa_backend_symbol_table_processing
-#define elf_backend_begin_write_processing \
- elf32_hppa_backend_begin_write_processing
-#define elf_backend_final_write_processing \
- elf32_hppa_backend_final_write_processing
-
-/* Stuff for the BFD linker. */
-#define elf_backend_relocate_section elf32_hppa_relocate_section
-#define elf_backend_add_symbol_hook elf32_hppa_add_symbol_hook
-#define elf_backend_link_output_symbol_hook \
- elf32_hppa_link_output_symbol_hook
-#define bfd_elf32_bfd_link_hash_table_create \
- elf32_hppa_link_hash_table_create
-
-#define TARGET_BIG_SYM bfd_elf32_hppa_vec
-#define TARGET_BIG_NAME "elf32-hppa"
-#define ELF_ARCH bfd_arch_hppa
-#define ELF_MACHINE_CODE EM_PARISC
-#define ELF_MAXPAGESIZE 0x1000
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32-hppa.h b/contrib/gdb/bfd/elf32-hppa.h
deleted file mode 100644
index 63ee522..0000000
--- a/contrib/gdb/bfd/elf32-hppa.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* ELF32/HPPA support
-
- This file contains ELF32/HPPA relocation support as specified
- in the Stratus FTX/Golf Object File Format (SED-1762) dated
- February 1994.
-
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
-
- Written by:
-
- Center for Software Science
- Department of Computer Science
- University of Utah
-
- This file is part of BFD, the Binary File Descriptor library.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _ELF32_HPPA_H
-#define _ELF32_HPPA_H
-
-#include "elf-bfd.h"
-#include "libhppa.h"
-#include "elf/hppa.h"
-
-/* ELF/HPPA relocation types */
-
-typedef enum
- {
- /* Address relocation types
- These relocation types do simple base + offset relocations. */
-
- R_PARISC_NONE = 0x00,
- R_PARISC_DIR32 = 0x01,
- R_PARISC_DIR21L = 0x02,
- R_PARISC_DIR17R = 0x03,
- R_PARISC_DIR17F = 0x04,
- R_PARISC_DIR14R = 0x06,
-
- /* PC-relative relocation types
- Typically used for calls.
- Note PCREL17C and PCREL17F differ only in overflow handling.
- PCREL17C never reports a relocation error.
-
- When supporting argument relocations, function calls must be
- accompanied by parameter relocation information. This information is
- carried in the ten high-order bits of the addend field. The remaining
- 22 bits of of the addend field are sign-extended to form the Addend.
-
- Note the code to build argument relocations depends on the
- addend being zero. A consequence of this limitation is GAS
- can not perform relocation reductions for function symbols. */
- R_PARISC_PCREL21L = 0x0a,
- R_PARISC_PCREL17R = 0x0b,
- R_PARISC_PCREL17F = 0x0c,
- R_PARISC_PCREL17C = 0x0d,
- R_PARISC_PCREL14R = 0x0e,
- R_PARISC_PCREL14F = 0x0f,
-
- /* DP-relative relocation types. */
- R_PARISC_DPREL21L = 0x12,
- R_PARISC_DPREL14R = 0x16,
- R_PARISC_DPREL14F = 0x17,
-
- /* Data linkage table (DLT) relocation types
-
- SOM DLT_REL fixup requests are used to for static data references
- from position-independent code within shared libraries. They are
- similar to the GOT relocation types in some SVR4 implementations. */
-
- R_PARISC_DLTREL21L = 0x1a,
- R_PARISC_DLTREL14R = 0x1e,
- R_PARISC_DLTREL14F = 0x1f,
-
- /* DLT indirect relocation types */
- R_PARISC_DLTIND21L = 0x22,
- R_PARISC_DLTIND14R = 0x26,
- R_PARISC_DLTIND14F = 0x27,
-
- /* Base relative relocation types. Ugh. These imply lots of state */
- R_PARISC_SETBASE = 0x28,
- R_PARISC_BASEREL32 = 0x29,
- R_PARISC_BASEREL21L = 0x2a,
- R_PARISC_BASEREL17R = 0x2b,
- R_PARISC_BASEREL17F = 0x2c,
- R_PARISC_BASEREL14R = 0x2e,
- R_PARISC_BASEREL14F = 0x2f,
-
- /* Segment relative relocation types. */
- R_PARISC_TEXTREL32 = 0x31,
- R_PARISC_DATAREL32 = 0x39,
-
- /* Plabel relocation types. */
- R_PARISC_PLABEL32 = 0x41,
- R_PARISC_PLABEL21L = 0x42,
- R_PARISC_PLABEL14R = 0x46,
-
- /* PLT relocations. */
- R_PARISC_PLTIND21L = 0x82,
- R_PARISC_PLTIND14R = 0x86,
- R_PARISC_PLTIND14F = 0x87,
-
- /* Misc relocation types. */
- R_PARISC_COPY = 0x88,
- R_PARISC_GLOB_DAT = 0x89,
- R_PARISC_JMP_SLOT = 0x8a,
- R_PARISC_RELATIVE = 0x8b,
- R_PARISC_UNIMPLEMENTED,
- }
-elf32_hppa_reloc_type;
-
-#define ELF_HOWTO_TABLE_SIZE R_PARISC_UNIMPLEMENTED + 1
-#define N_PARISC_RELOCS R_PARISC_UNIMPLEMENTED + 1
-
-/* Define groups of basic relocations. FIXME: These should
- be the only basic relocations created by GAS. The rest
- should be internal to the BFD backend.
-
- The idea is both SOM and ELF define these basic relocation
- types so they map into a SOM or ELF specific relocation
- as appropriate. This allows GAS to share much more code
- between the two target object formats. */
-
-#define R_HPPA_NONE R_PARISC_NONE
-#define R_HPPA R_PARISC_DIR32
-#define R_HPPA_GOTOFF R_PARISC_DPREL21L
-#define R_HPPA_PCREL_CALL R_PARISC_PCREL21L
-#define R_HPPA_ABS_CALL R_PARISC_DIR17F
-#define R_HPPA_COMPLEX R_PARISC_UNIMPLEMENTED
-
-elf32_hppa_reloc_type **hppa_elf_gen_reloc_type
- PARAMS ((bfd *, elf32_hppa_reloc_type, int, int, int));
-
-boolean elf32_hppa_size_stubs
- PARAMS ((bfd *, bfd *, struct bfd_link_info *));
-
-boolean elf32_hppa_build_stubs
- PARAMS ((bfd *, struct bfd_link_info *));
-
-#endif /* _ELF32_HPPA_H */
diff --git a/contrib/gdb/bfd/elf32-i386.c b/contrib/gdb/bfd/elf32-i386.c
deleted file mode 100644
index 3b39aac..0000000
--- a/contrib/gdb/bfd/elf32-i386.c
+++ /dev/null
@@ -1,1546 +0,0 @@
-/* Intel 80386/80486-specific support for 32-bit ELF
- Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-
-static reloc_howto_type *elf_i386_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void elf_i386_info_to_howto
- PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
-static void elf_i386_info_to_howto_rel
- PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
-static boolean elf_i386_check_relocs
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- const Elf_Internal_Rela *));
-static boolean elf_i386_adjust_dynamic_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static boolean elf_i386_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean elf_i386_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static boolean elf_i386_finish_dynamic_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
- Elf_Internal_Sym *));
-static boolean elf_i386_finish_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-#define USE_REL 1 /* 386 uses REL relocations instead of RELA */
-
-enum reloc_type
- {
- R_386_NONE = 0,
- R_386_32,
- R_386_PC32,
- R_386_GOT32,
- R_386_PLT32,
- R_386_COPY,
- R_386_GLOB_DAT,
- R_386_JUMP_SLOT,
- R_386_RELATIVE,
- R_386_GOTOFF,
- R_386_GOTPC,
- R_386_max
- };
-
-#if 0
-static CONST char *CONST reloc_type_names[] =
-{
- "R_386_NONE",
- "R_386_32",
- "R_386_PC32",
- "R_386_GOT32",
- "R_386_PLT32",
- "R_386_COPY",
- "R_386_GLOB_DAT",
- "R_386_JUMP_SLOT",
- "R_386_RELATIVE",
- "R_386_GOTOFF",
- "R_386_GOTPC",
-};
-#endif
-
-static reloc_howto_type elf_howto_table[]=
-{
- HOWTO(R_386_NONE, 0,0, 0,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_NONE", true,0x00000000,0x00000000,false),
- HOWTO(R_386_32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_32", true,0xffffffff,0xffffffff,false),
- HOWTO(R_386_PC32, 0,2,32,true, 0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PC32", true,0xffffffff,0xffffffff,true),
- HOWTO(R_386_GOT32, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOT32", true,0xffffffff,0xffffffff,false),
- HOWTO(R_386_PLT32, 0,2,32,true,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_PLT32", true,0xffffffff,0xffffffff,true),
- HOWTO(R_386_COPY, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_COPY", true,0xffffffff,0xffffffff,false),
- HOWTO(R_386_GLOB_DAT, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GLOB_DAT", true,0xffffffff,0xffffffff,false),
- HOWTO(R_386_JUMP_SLOT, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_JUMP_SLOT",true,0xffffffff,0xffffffff,false),
- HOWTO(R_386_RELATIVE, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_RELATIVE", true,0xffffffff,0xffffffff,false),
- HOWTO(R_386_GOTOFF, 0,2,32,false,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTOFF", true,0xffffffff,0xffffffff,false),
- HOWTO(R_386_GOTPC, 0,2,32,true,0,complain_overflow_bitfield, bfd_elf_generic_reloc,"R_386_GOTPC", true,0xffffffff,0xffffffff,true),
-};
-
-#ifdef DEBUG_GEN_RELOC
-#define TRACE(str) fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
-#else
-#define TRACE(str)
-#endif
-
-static reloc_howto_type *
-elf_i386_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- switch (code)
- {
- case BFD_RELOC_NONE:
- TRACE ("BFD_RELOC_NONE");
- return &elf_howto_table[ (int)R_386_NONE ];
-
- case BFD_RELOC_32:
- TRACE ("BFD_RELOC_32");
- return &elf_howto_table[ (int)R_386_32 ];
-
- case BFD_RELOC_32_PCREL:
- TRACE ("BFD_RELOC_PC32");
- return &elf_howto_table[ (int)R_386_PC32 ];
-
- case BFD_RELOC_386_GOT32:
- TRACE ("BFD_RELOC_386_GOT32");
- return &elf_howto_table[ (int)R_386_GOT32 ];
-
- case BFD_RELOC_386_PLT32:
- TRACE ("BFD_RELOC_386_PLT32");
- return &elf_howto_table[ (int)R_386_PLT32 ];
-
- case BFD_RELOC_386_COPY:
- TRACE ("BFD_RELOC_386_COPY");
- return &elf_howto_table[ (int)R_386_COPY ];
-
- case BFD_RELOC_386_GLOB_DAT:
- TRACE ("BFD_RELOC_386_GLOB_DAT");
- return &elf_howto_table[ (int)R_386_GLOB_DAT ];
-
- case BFD_RELOC_386_JUMP_SLOT:
- TRACE ("BFD_RELOC_386_JUMP_SLOT");
- return &elf_howto_table[ (int)R_386_JUMP_SLOT ];
-
- case BFD_RELOC_386_RELATIVE:
- TRACE ("BFD_RELOC_386_RELATIVE");
- return &elf_howto_table[ (int)R_386_RELATIVE ];
-
- case BFD_RELOC_386_GOTOFF:
- TRACE ("BFD_RELOC_386_GOTOFF");
- return &elf_howto_table[ (int)R_386_GOTOFF ];
-
- case BFD_RELOC_386_GOTPC:
- TRACE ("BFD_RELOC_386_GOTPC");
- return &elf_howto_table[ (int)R_386_GOTPC ];
-
- default:
- break;
- }
-
- TRACE ("Unknown");
- return 0;
-}
-
-static void
-elf_i386_info_to_howto (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf32_Internal_Rela *dst;
-{
- BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max);
-
- cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
-}
-
-static void
-elf_i386_info_to_howto_rel (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf32_Internal_Rel *dst;
-{
- BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_386_max);
-
- cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
-}
-
-/* Functions for the i386 ELF linker. */
-
-/* The name of the dynamic interpreter. This is put in the .interp
- section. */
-
-#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
-
-/* The size in bytes of an entry in the procedure linkage table. */
-
-#define PLT_ENTRY_SIZE 16
-
-/* The first entry in an absolute procedure linkage table looks like
- this. See the SVR4 ABI i386 supplement to see how this works. */
-
-static const bfd_byte elf_i386_plt0_entry[PLT_ENTRY_SIZE] =
-{
- 0xff, 0x35, /* pushl contents of address */
- 0, 0, 0, 0, /* replaced with address of .got + 4. */
- 0xff, 0x25, /* jmp indirect */
- 0, 0, 0, 0, /* replaced with address of .got + 8. */
- 0, 0, 0, 0 /* pad out to 16 bytes. */
-};
-
-/* Subsequent entries in an absolute procedure linkage table look like
- this. */
-
-static const bfd_byte elf_i386_plt_entry[PLT_ENTRY_SIZE] =
-{
- 0xff, 0x25, /* jmp indirect */
- 0, 0, 0, 0, /* replaced with address of this symbol in .got. */
- 0x68, /* pushl immediate */
- 0, 0, 0, 0, /* replaced with offset into relocation table. */
- 0xe9, /* jmp relative */
- 0, 0, 0, 0 /* replaced with offset to start of .plt. */
-};
-
-/* The first entry in a PIC procedure linkage table look like this. */
-
-static const bfd_byte elf_i386_pic_plt0_entry[PLT_ENTRY_SIZE] =
-{
- 0xff, 0xb3, 4, 0, 0, 0, /* pushl 4(%ebx) */
- 0xff, 0xa3, 8, 0, 0, 0, /* jmp *8(%ebx) */
- 0, 0, 0, 0 /* pad out to 16 bytes. */
-};
-
-/* Subsequent entries in a PIC procedure linkage table look like this. */
-
-static const bfd_byte elf_i386_pic_plt_entry[PLT_ENTRY_SIZE] =
-{
- 0xff, 0xa3, /* jmp *offset(%ebx) */
- 0, 0, 0, 0, /* replaced with offset of this symbol in .got. */
- 0x68, /* pushl immediate */
- 0, 0, 0, 0, /* replaced with offset into relocation table. */
- 0xe9, /* jmp relative */
- 0, 0, 0, 0 /* replaced with offset to start of .plt. */
-};
-
-/* Look through the relocs for a section during the first phase, and
- allocate space in the global offset table or procedure linkage
- table. */
-
-static boolean
-elf_i386_check_relocs (abfd, info, sec, relocs)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- const Elf_Internal_Rela *relocs;
-{
- bfd *dynobj;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- bfd_vma *local_got_offsets;
- const Elf_Internal_Rela *rel;
- const Elf_Internal_Rela *rel_end;
- asection *sgot;
- asection *srelgot;
- asection *sreloc;
-
- if (info->relocateable)
- return true;
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (abfd);
- local_got_offsets = elf_local_got_offsets (abfd);
-
- sgot = NULL;
- srelgot = NULL;
- sreloc = NULL;
-
- rel_end = relocs + sec->reloc_count;
- for (rel = relocs; rel < rel_end; rel++)
- {
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (r_symndx < symtab_hdr->sh_info)
- h = NULL;
- else
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-
- /* Some relocs require a global offset table. */
- if (dynobj == NULL)
- {
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_386_GOT32:
- case R_386_GOTOFF:
- case R_386_GOTPC:
- elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! _bfd_elf_create_got_section (dynobj, info))
- return false;
- break;
-
- default:
- break;
- }
- }
-
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_386_GOT32:
- /* This symbol requires a global offset table entry. */
-
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- if (srelgot == NULL
- && (h != NULL || info->shared))
- {
- srelgot = bfd_get_section_by_name (dynobj, ".rel.got");
- if (srelgot == NULL)
- {
- srelgot = bfd_make_section (dynobj, ".rel.got");
- if (srelgot == NULL
- || ! bfd_set_section_flags (dynobj, srelgot,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, srelgot, 2))
- return false;
- }
- }
-
- if (h != NULL)
- {
- if (h->got_offset != (bfd_vma) -1)
- {
- /* We have already allocated space in the .got. */
- break;
- }
- h->got_offset = sgot->_raw_size;
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- srelgot->_raw_size += sizeof (Elf32_External_Rel);
- }
- else
- {
- /* This is a global offset table entry for a local
- symbol. */
- if (local_got_offsets == NULL)
- {
- size_t size;
- register unsigned int i;
-
- size = symtab_hdr->sh_info * sizeof (bfd_vma);
- local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
- if (local_got_offsets == NULL)
- return false;
- elf_local_got_offsets (abfd) = local_got_offsets;
- for (i = 0; i < symtab_hdr->sh_info; i++)
- local_got_offsets[i] = (bfd_vma) -1;
- }
- if (local_got_offsets[r_symndx] != (bfd_vma) -1)
- {
- /* We have already allocated space in the .got. */
- break;
- }
- local_got_offsets[r_symndx] = sgot->_raw_size;
-
- if (info->shared)
- {
- /* If we are generating a shared object, we need to
- output a R_386_RELATIVE reloc so that the dynamic
- linker can adjust this GOT entry. */
- srelgot->_raw_size += sizeof (Elf32_External_Rel);
- }
- }
-
- sgot->_raw_size += 4;
-
- break;
-
- case R_386_PLT32:
- /* This symbol requires a procedure linkage table entry. We
- actually build the entry in adjust_dynamic_symbol,
- because this might be a case of linking PIC code which is
- never referenced by a dynamic object, in which case we
- don't need to generate a procedure linkage table entry
- after all. */
-
- /* If this is a local symbol, we resolve it directly without
- creating a procedure linkage table entry. */
- if (h == NULL)
- continue;
-
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
-
- break;
-
- case R_386_32:
- case R_386_PC32:
- if (info->shared
- && (sec->flags & SEC_ALLOC) != 0
- && (ELF32_R_TYPE (rel->r_info) != R_386_PC32 || h != NULL))
- {
- /* When creating a shared object, we must copy these
- reloc types into the output file. We create a reloc
- section in dynobj and make room for this reloc. */
- if (sreloc == NULL)
- {
- const char *name;
-
- name = (bfd_elf_string_from_elf_section
- (abfd,
- elf_elfheader (abfd)->e_shstrndx,
- elf_section_data (sec)->rel_hdr.sh_name));
- if (name == NULL)
- return false;
-
- BFD_ASSERT (strncmp (name, ".rel", 4) == 0
- && strcmp (bfd_get_section_name (abfd, sec),
- name + 4) == 0);
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- if (sreloc == NULL)
- {
- sreloc = bfd_make_section (dynobj, name);
- if (sreloc == NULL
- || ! bfd_set_section_flags (dynobj, sreloc,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, sreloc, 2))
- return false;
- }
- }
-
- sreloc->_raw_size += sizeof (Elf32_External_Rel);
- }
-
- break;
-
- default:
- break;
- }
- }
-
- return true;
-}
-
-/* Adjust a symbol defined by a dynamic object and referenced by a
- regular object. The current definition is in some section of the
- dynamic object, but we're not including those sections. We have to
- change the definition to something the rest of the link can
- understand. */
-
-static boolean
-elf_i386_adjust_dynamic_symbol (info, h)
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
-{
- bfd *dynobj;
- asection *s;
- unsigned int power_of_two;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- /* Make sure we know what is going on here. */
- BFD_ASSERT (dynobj != NULL
- && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
- || h->weakdef != NULL
- || ((h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_REF_REGULAR) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)));
-
- /* If this is a function, put it in the procedure linkage table. We
- will fill in the contents of the procedure linkage table later,
- when we know the address of the .got section. */
- if (h->type == STT_FUNC
- || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
- {
- if (! info->shared
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
- && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0)
- {
- /* This case can occur if we saw a PLT32 reloc in an input
- file, but the symbol was never referred to by a dynamic
- object. In such a case, we don't actually need to build
- a procedure linkage table, and we can just do a PC32
- reloc instead. */
- BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
- return true;
- }
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- s = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (s != NULL);
-
- /* If this is the first .plt entry, make room for the special
- first entry. */
- if (s->_raw_size == 0)
- s->_raw_size += PLT_ENTRY_SIZE;
-
- /* If this symbol is not defined in a regular file, and we are
- not generating a shared library, then set the symbol to this
- location in the .plt. This is required to make function
- pointers compare as equal between the normal executable and
- the shared library. */
- if (! info->shared
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
- }
-
- h->plt_offset = s->_raw_size;
-
- /* Make room for this entry. */
- s->_raw_size += PLT_ENTRY_SIZE;
-
- /* We also need to make an entry in the .got.plt section, which
- will be placed in the .got section by the linker script. */
-
- s = bfd_get_section_by_name (dynobj, ".got.plt");
- BFD_ASSERT (s != NULL);
- s->_raw_size += 4;
-
- /* We also need to make an entry in the .rel.plt section. */
-
- s = bfd_get_section_by_name (dynobj, ".rel.plt");
- BFD_ASSERT (s != NULL);
- s->_raw_size += sizeof (Elf32_External_Rel);
-
- return true;
- }
-
- /* If this is a weak symbol, and there is a real definition, the
- processor independent code will have arranged for us to see the
- real definition first, and we can just use the same value. */
- if (h->weakdef != NULL)
- {
- BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
- || h->weakdef->root.type == bfd_link_hash_defweak);
- h->root.u.def.section = h->weakdef->root.u.def.section;
- h->root.u.def.value = h->weakdef->root.u.def.value;
- return true;
- }
-
- /* This is a reference to a symbol defined by a dynamic object which
- is not a function. */
-
- /* If we are creating a shared library, we must presume that the
- only references to the symbol are via the global offset table.
- For such cases we need not do anything here; the relocations will
- be handled correctly by relocate_section. */
- if (info->shared)
- return true;
-
- /* We must allocate the symbol in our .dynbss section, which will
- become part of the .bss section of the executable. There will be
- an entry for this symbol in the .dynsym section. The dynamic
- object will contain position independent code, so all references
- from the dynamic object to this symbol will go through the global
- offset table. The dynamic linker will use the .dynsym entry to
- determine the address it must put in the global offset table, so
- both the dynamic object and the regular object will refer to the
- same memory location for the variable. */
-
- s = bfd_get_section_by_name (dynobj, ".dynbss");
- BFD_ASSERT (s != NULL);
-
- /* If the symbol is currently defined in the .bss section of the
- dynamic object, then it is OK to simply initialize it to zero.
- If the symbol is in some other section, we must generate a
- R_386_COPY reloc to tell the dynamic linker to copy the initial
- value out of the dynamic object and into the runtime process
- image. We need to remember the offset into the .rel.bss section
- we are going to use. */
- if ((h->root.u.def.section->flags & SEC_LOAD) != 0)
- {
- asection *srel;
-
- srel = bfd_get_section_by_name (dynobj, ".rel.bss");
- BFD_ASSERT (srel != NULL);
- srel->_raw_size += sizeof (Elf32_External_Rel);
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
- }
-
- /* We need to figure out the alignment required for this symbol. I
- have no idea how ELF linkers handle this. */
- power_of_two = bfd_log2 (h->size);
- if (power_of_two > 3)
- power_of_two = 3;
-
- /* Apply the required alignment. */
- s->_raw_size = BFD_ALIGN (s->_raw_size,
- (bfd_size_type) (1 << power_of_two));
- if (power_of_two > bfd_get_section_alignment (dynobj, s))
- {
- if (! bfd_set_section_alignment (dynobj, s, power_of_two))
- return false;
- }
-
- /* Define the symbol as being at this point in the section. */
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
-
- /* Increment the section size to make room for the symbol. */
- s->_raw_size += h->size;
-
- return true;
-}
-
-/* Set the sizes of the dynamic sections. */
-
-static boolean
-elf_i386_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *s;
- boolean plt;
- boolean relocs;
- boolean reltext;
-
- dynobj = elf_hash_table (info)->dynobj;
- BFD_ASSERT (dynobj != NULL);
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Set the contents of the .interp section to the interpreter. */
- if (! info->shared)
- {
- s = bfd_get_section_by_name (dynobj, ".interp");
- BFD_ASSERT (s != NULL);
- s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
- s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
- }
- }
- else
- {
- /* We may have created entries in the .rel.got section.
- However, if we are not creating the dynamic sections, we will
- not actually use these entries. Reset the size of .rel.got,
- which will cause it to get stripped from the output file
- below. */
- s = bfd_get_section_by_name (dynobj, ".rel.got");
- if (s != NULL)
- s->_raw_size = 0;
- }
-
- /* The check_relocs and adjust_dynamic_symbol entry points have
- determined the sizes of the various dynamic sections. Allocate
- memory for them. */
- plt = false;
- relocs = false;
- reltext = false;
- for (s = dynobj->sections; s != NULL; s = s->next)
- {
- const char *name;
- boolean strip;
-
- if ((s->flags & SEC_IN_MEMORY) == 0)
- continue;
-
- /* It's OK to base decisions on the section name, because none
- of the dynobj section names depend upon the input files. */
- name = bfd_get_section_name (dynobj, s);
-
- strip = false;
-
- if (strcmp (name, ".plt") == 0)
- {
- if (s->_raw_size == 0)
- {
- /* Strip this section if we don't need it; see the
- comment below. */
- strip = true;
- }
- else
- {
- /* Remember whether there is a PLT. */
- plt = true;
- }
- }
- else if (strncmp (name, ".rel", 4) == 0)
- {
- if (s->_raw_size == 0)
- {
- /* If we don't need this section, strip it from the
- output file. This is mostly to handle .rel.bss and
- .rel.plt. We must create both sections in
- create_dynamic_sections, because they must be created
- before the linker maps input sections to output
- sections. The linker does that before
- adjust_dynamic_symbol is called, and it is that
- function which decides whether anything needs to go
- into these sections. */
- strip = true;
- }
- else
- {
- asection *target;
-
- /* Remember whether there are any reloc sections other
- than .rel.plt. */
- if (strcmp (name, ".rel.plt") != 0)
- {
- relocs = true;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL
- entry. The entries in the .rel.plt section
- really apply to the .got section, which we
- created ourselves and so know is not readonly. */
- target = bfd_get_section_by_name (output_bfd, name + 4);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0)
- reltext = true;
- }
-
- /* We use the reloc_count field as a counter if we need
- to copy relocs into the output file. */
- s->reloc_count = 0;
- }
- }
- else if (strncmp (name, ".got", 4) != 0)
- {
- /* It's not one of our sections, so don't allocate space. */
- continue;
- }
-
- if (strip)
- {
- asection **spp;
-
- for (spp = &s->output_section->owner->sections;
- *spp != s->output_section;
- spp = &(*spp)->next)
- ;
- *spp = s->output_section->next;
- --s->output_section->owner->section_count;
-
- continue;
- }
-
- /* Allocate memory for the section contents. */
- s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
- if (s->contents == NULL && s->_raw_size != 0)
- return false;
- }
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in elf_i386_finish_dynamic_sections, but we
- must add the entries now so that we get the correct size for
- the .dynamic section. The DT_DEBUG entry is filled in by the
- dynamic linker and used by the debugger. */
- if (! info->shared)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
- return false;
- }
-
- if (plt)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_REL)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
- return false;
- }
-
- if (relocs)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELENT,
- sizeof (Elf32_External_Rel)))
- return false;
- }
-
- if (reltext)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
- return false;
- }
- }
-
- return true;
-}
-
-/* Relocate an i386 ELF section. */
-
-static boolean
-elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, local_syms, local_sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- Elf_Internal_Rela *relocs;
- Elf_Internal_Sym *local_syms;
- asection **local_sections;
-{
- bfd *dynobj;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- bfd_vma *local_got_offsets;
- asection *sgot;
- asection *splt;
- asection *sreloc;
- Elf_Internal_Rela *rel;
- Elf_Internal_Rela *relend;
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (input_bfd);
- local_got_offsets = elf_local_got_offsets (input_bfd);
-
- sgot = NULL;
- splt = NULL;
- sreloc = NULL;
-
- rel = relocs;
- relend = relocs + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- int r_type;
- reloc_howto_type *howto;
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
- asection *sec;
- bfd_vma relocation;
- bfd_reloc_status_type r;
-
- r_type = ELF32_R_TYPE (rel->r_info);
- if (r_type < 0 || r_type >= (int) R_386_max)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- howto = elf_howto_table + r_type;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- bfd_vma val;
-
- sec = local_sections[r_symndx];
- val = bfd_get_32 (input_bfd, contents + rel->r_offset);
- val += sec->output_offset + sym->st_value;
- bfd_put_32 (input_bfd, val, contents + rel->r_offset);
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
- h = NULL;
- sym = NULL;
- sec = NULL;
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- sec = local_sections[r_symndx];
- relocation = (sec->output_section->vma
- + sec->output_offset
- + sym->st_value);
- }
- else
- {
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- if (r_type == R_386_GOTPC
- || (r_type == R_386_PLT32
- && h->plt_offset != (bfd_vma) -1)
- || (r_type == R_386_GOT32
- && elf_hash_table (info)->dynamic_sections_created
- && (! info->shared
- || ! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))
- || (info->shared
- && (! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)
- && (r_type == R_386_32
- || r_type == R_386_PC32)
- && (input_section->flags & SEC_ALLOC) != 0))
- {
- /* In these cases, we don't need the relocation
- value. We check specially because in some
- obscure cases sec->output_section will be NULL. */
- relocation = 0;
- }
- else
- relocation = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else if (info->shared && !info->symbolic)
- relocation = 0;
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset)))
- return false;
- relocation = 0;
- }
- }
-
- switch (r_type)
- {
- case R_386_GOT32:
- /* Relocation is to the entry for this symbol in the global
- offset table. */
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- if (h != NULL)
- {
- bfd_vma off;
-
- off = h->got_offset;
- BFD_ASSERT (off != (bfd_vma) -1);
-
- if (! elf_hash_table (info)->dynamic_sections_created
- || (info->shared
- && info->symbolic
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
- {
- /* This is actually a static link, or it is a
- -Bsymbolic link and the symbol is defined
- locally. We must initialize this entry in the
- global offset table. Since the offset must
- always be a multiple of 4, we use the least
- significant bit to record whether we have
- initialized it already.
-
- When doing a dynamic link, we create a .rel.got
- relocation entry to initialize the value. This
- is done in the finish_dynamic_symbol routine. */
- if ((off & 1) != 0)
- off &= ~1;
- else
- {
- bfd_put_32 (output_bfd, relocation,
- sgot->contents + off);
- h->got_offset |= 1;
- }
- }
-
- relocation = sgot->output_offset + off;
- }
- else
- {
- bfd_vma off;
-
- BFD_ASSERT (local_got_offsets != NULL
- && local_got_offsets[r_symndx] != (bfd_vma) -1);
-
- off = local_got_offsets[r_symndx];
-
- /* The offset must always be a multiple of 4. We use
- the least significant bit to record whether we have
- already generated the necessary reloc. */
- if ((off & 1) != 0)
- off &= ~1;
- else
- {
- bfd_put_32 (output_bfd, relocation, sgot->contents + off);
-
- if (info->shared)
- {
- asection *srelgot;
- Elf_Internal_Rel outrel;
-
- srelgot = bfd_get_section_by_name (dynobj, ".rel.got");
- BFD_ASSERT (srelgot != NULL);
-
- outrel.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + off);
- outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel,
- (((Elf32_External_Rel *)
- srelgot->contents)
- + srelgot->reloc_count));
- ++srelgot->reloc_count;
- }
-
- local_got_offsets[r_symndx] |= 1;
- }
-
- relocation = sgot->output_offset + off;
- }
-
- break;
-
- case R_386_GOTOFF:
- /* Relocation is relative to the start of the global offset
- table. */
-
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- /* Note that sgot->output_offset is not involved in this
- calculation. We always want the start of .got. If we
- defined _GLOBAL_OFFSET_TABLE in a different way, as is
- permitted by the ABI, we might have to change this
- calculation. */
- relocation -= sgot->output_section->vma;
-
- break;
-
- case R_386_GOTPC:
- /* Use global offset table as symbol value. */
-
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- relocation = sgot->output_section->vma;
-
- break;
-
- case R_386_PLT32:
- /* Relocation is to the entry for this symbol in the
- procedure linkage table. */
-
- /* Resolve a PLT32 reloc again a local symbol directly,
- without using the procedure linkage table. */
- if (h == NULL)
- break;
-
- if (h->plt_offset == (bfd_vma) -1)
- {
- /* We didn't make a PLT entry for this symbol. This
- happens when statically linking PIC code, or when
- using -Bsymbolic. */
- break;
- }
-
- if (splt == NULL)
- {
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL);
- }
-
- relocation = (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset);
-
- break;
-
- case R_386_32:
- case R_386_PC32:
- if (info->shared
- && (input_section->flags & SEC_ALLOC) != 0
- && (r_type != R_386_PC32
- || (h != NULL
- && (! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))))
- {
- Elf_Internal_Rel outrel;
- boolean relocate;
-
- /* When generating a shared object, these relocations
- are copied into the output file to be resolved at run
- time. */
-
- if (sreloc == NULL)
- {
- const char *name;
-
- name = (bfd_elf_string_from_elf_section
- (input_bfd,
- elf_elfheader (input_bfd)->e_shstrndx,
- elf_section_data (input_section)->rel_hdr.sh_name));
- if (name == NULL)
- return false;
-
- BFD_ASSERT (strncmp (name, ".rel", 4) == 0
- && strcmp (bfd_get_section_name (input_bfd,
- input_section),
- name + 4) == 0);
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- BFD_ASSERT (sreloc != NULL);
- }
-
- outrel.r_offset = (rel->r_offset
- + input_section->output_section->vma
- + input_section->output_offset);
- if (r_type == R_386_PC32)
- {
- BFD_ASSERT (h != NULL && h->dynindx != -1);
- relocate = false;
- outrel.r_info = ELF32_R_INFO (h->dynindx, R_386_PC32);
- }
- else
- {
- if (h == NULL
- || (info->symbolic
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) != 0))
- {
- relocate = true;
- outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
- }
- else
- {
- BFD_ASSERT (h->dynindx != -1);
- relocate = false;
- outrel.r_info = ELF32_R_INFO (h->dynindx, R_386_32);
- }
- }
-
- bfd_elf32_swap_reloc_out (output_bfd, &outrel,
- (((Elf32_External_Rel *)
- sreloc->contents)
- + sreloc->reloc_count));
- ++sreloc->reloc_count;
-
- /* If this reloc is against an external symbol, we do
- not want to fiddle with the addend. Otherwise, we
- need to include the symbol value so that it becomes
- an addend for the dynamic reloc. */
- if (! relocate)
- continue;
- }
-
- break;
-
- default:
- break;
- }
-
- r = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents, rel->r_offset,
- relocation, (bfd_vma) 0);
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
- if (name == NULL)
- return false;
- if (*name == '\0')
- name = bfd_section_name (input_bfd, sec);
- }
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Finish up dynamic symbol handling. We set the contents of various
- dynamic sections here. */
-
-static boolean
-elf_i386_finish_dynamic_symbol (output_bfd, info, h, sym)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
-{
- bfd *dynobj;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- if (h->plt_offset != (bfd_vma) -1)
- {
- asection *splt;
- asection *sgot;
- asection *srel;
- bfd_vma plt_index;
- bfd_vma got_offset;
- Elf_Internal_Rel rel;
-
- /* This symbol has an entry in the procedure linkage table. Set
- it up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- sgot = bfd_get_section_by_name (dynobj, ".got.plt");
- srel = bfd_get_section_by_name (dynobj, ".rel.plt");
- BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
-
- /* Get the index in the procedure linkage table which
- corresponds to this symbol. This is the index of this symbol
- in all the symbols for which we are making plt entries. The
- first entry in the procedure linkage table is reserved. */
- plt_index = h->plt_offset / PLT_ENTRY_SIZE - 1;
-
- /* Get the offset into the .got table of the entry that
- corresponds to this function. Each .got entry is 4 bytes.
- The first three are reserved. */
- got_offset = (plt_index + 3) * 4;
-
- /* Fill in the entry in the procedure linkage table. */
- if (! info->shared)
- {
- memcpy (splt->contents + h->plt_offset, elf_i386_plt_entry,
- PLT_ENTRY_SIZE);
- bfd_put_32 (output_bfd,
- (sgot->output_section->vma
- + sgot->output_offset
- + got_offset),
- splt->contents + h->plt_offset + 2);
- }
- else
- {
- memcpy (splt->contents + h->plt_offset, elf_i386_pic_plt_entry,
- PLT_ENTRY_SIZE);
- bfd_put_32 (output_bfd, got_offset,
- splt->contents + h->plt_offset + 2);
- }
-
- bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rel),
- splt->contents + h->plt_offset + 7);
- bfd_put_32 (output_bfd, - (h->plt_offset + PLT_ENTRY_SIZE),
- splt->contents + h->plt_offset + 12);
-
- /* Fill in the entry in the global offset table. */
- bfd_put_32 (output_bfd,
- (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset
- + 6),
- sgot->contents + got_offset);
-
- /* Fill in the entry in the .rel.plt section. */
- rel.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + got_offset);
- rel.r_info = ELF32_R_INFO (h->dynindx, R_386_JUMP_SLOT);
- bfd_elf32_swap_reloc_out (output_bfd, &rel,
- ((Elf32_External_Rel *) srel->contents
- + plt_index));
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- /* Mark the symbol as undefined, rather than as defined in
- the .plt section. Leave the value alone. */
- sym->st_shndx = SHN_UNDEF;
- }
- }
-
- if (h->got_offset != (bfd_vma) -1)
- {
- asection *sgot;
- asection *srel;
- Elf_Internal_Rel rel;
-
- /* This symbol has an entry in the global offset table. Set it
- up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- sgot = bfd_get_section_by_name (dynobj, ".got");
- srel = bfd_get_section_by_name (dynobj, ".rel.got");
- BFD_ASSERT (sgot != NULL && srel != NULL);
-
- rel.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + (h->got_offset &~ 1));
-
- /* If this is a -Bsymbolic link, and the symbol is defined
- locally, we just want to emit a RELATIVE reloc. The entry in
- the global offset table will already have been initialized in
- the relocate_section function. */
- if (info->shared
- && info->symbolic
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
- rel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
- else
- {
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got_offset);
- rel.r_info = ELF32_R_INFO (h->dynindx, R_386_GLOB_DAT);
- }
-
- bfd_elf32_swap_reloc_out (output_bfd, &rel,
- ((Elf32_External_Rel *) srel->contents
- + srel->reloc_count));
- ++srel->reloc_count;
- }
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
- {
- asection *s;
- Elf_Internal_Rel rel;
-
- /* This symbol needs a copy reloc. Set it up. */
-
- BFD_ASSERT (h->dynindx != -1
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak));
-
- s = bfd_get_section_by_name (h->root.u.def.section->owner,
- ".rel.bss");
- BFD_ASSERT (s != NULL);
-
- rel.r_offset = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- rel.r_info = ELF32_R_INFO (h->dynindx, R_386_COPY);
- bfd_elf32_swap_reloc_out (output_bfd, &rel,
- ((Elf32_External_Rel *) s->contents
- + s->reloc_count));
- ++s->reloc_count;
- }
-
- /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
- if (strcmp (h->root.root.string, "_DYNAMIC") == 0
- || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
- sym->st_shndx = SHN_ABS;
-
- return true;
-}
-
-/* Finish up the dynamic sections. */
-
-static boolean
-elf_i386_finish_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *sgot;
- asection *sdyn;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- sgot = bfd_get_section_by_name (dynobj, ".got.plt");
- BFD_ASSERT (sgot != NULL);
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- asection *splt;
- Elf32_External_Dyn *dyncon, *dynconend;
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL && sdyn != NULL);
-
- dyncon = (Elf32_External_Dyn *) sdyn->contents;
- dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
- for (; dyncon < dynconend; dyncon++)
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- asection *s;
-
- bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
-
- switch (dyn.d_tag)
- {
- default:
- break;
-
- case DT_PLTGOT:
- name = ".got";
- goto get_vma;
- case DT_JMPREL:
- name = ".rel.plt";
- get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rel.plt");
- BFD_ASSERT (s != NULL);
- if (s->_cooked_size != 0)
- dyn.d_un.d_val = s->_cooked_size;
- else
- dyn.d_un.d_val = s->_raw_size;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_RELSZ:
- /* My reading of the SVR4 ABI indicates that the
- procedure linkage table relocs (DT_JMPREL) should be
- included in the overall relocs (DT_REL). This is
- what Solaris does. However, UnixWare can not handle
- that case. Therefore, we override the DT_RELSZ entry
- here to make it not include the JMPREL relocs. Since
- the linker script arranges for .rel.plt to follow all
- other relocation sections, we don't have to worry
- about changing the DT_REL entry. */
- s = bfd_get_section_by_name (output_bfd, ".rel.plt");
- if (s != NULL)
- {
- if (s->_cooked_size != 0)
- dyn.d_un.d_val -= s->_cooked_size;
- else
- dyn.d_un.d_val -= s->_raw_size;
- }
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
- }
- }
-
- /* Fill in the first entry in the procedure linkage table. */
- if (splt->_raw_size > 0)
- {
- if (info->shared)
- memcpy (splt->contents, elf_i386_pic_plt0_entry, PLT_ENTRY_SIZE);
- else
- {
- memcpy (splt->contents, elf_i386_plt0_entry, PLT_ENTRY_SIZE);
- bfd_put_32 (output_bfd,
- sgot->output_section->vma + sgot->output_offset + 4,
- splt->contents + 2);
- bfd_put_32 (output_bfd,
- sgot->output_section->vma + sgot->output_offset + 8,
- splt->contents + 8);
- }
- }
-
- /* UnixWare sets the entsize of .plt to 4, although that doesn't
- really seem like the right value. */
- elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
- }
-
- /* Fill in the first three entries in the global offset table. */
- if (sgot->_raw_size > 0)
- {
- if (sdyn == NULL)
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
- else
- bfd_put_32 (output_bfd,
- sdyn->output_section->vma + sdyn->output_offset,
- sgot->contents);
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
- }
-
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
-
- return true;
-}
-
-#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
-#define TARGET_LITTLE_NAME "elf32-i386"
-#define ELF_ARCH bfd_arch_i386
-#define ELF_MACHINE_CODE EM_386
-#define elf_info_to_howto elf_i386_info_to_howto
-#define elf_info_to_howto_rel elf_i386_info_to_howto_rel
-#define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup
-#define ELF_MAXPAGESIZE 0x1000
-#define elf_backend_create_dynamic_sections \
- _bfd_elf_create_dynamic_sections
-#define elf_backend_check_relocs elf_i386_check_relocs
-#define elf_backend_adjust_dynamic_symbol \
- elf_i386_adjust_dynamic_symbol
-#define elf_backend_size_dynamic_sections \
- elf_i386_size_dynamic_sections
-#define elf_backend_relocate_section elf_i386_relocate_section
-#define elf_backend_finish_dynamic_symbol \
- elf_i386_finish_dynamic_symbol
-#define elf_backend_finish_dynamic_sections \
- elf_i386_finish_dynamic_sections
-#define elf_backend_want_got_plt 1
-#define elf_backend_plt_readonly 1
-#define elf_backend_want_plt_sym 0
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32-i860.c b/contrib/gdb/bfd/elf32-i860.c
deleted file mode 100644
index a8537a7..0000000
--- a/contrib/gdb/bfd/elf32-i860.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Intel 860 specific support for 32-bit ELF
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-
-#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
-#define elf_info_to_howto _bfd_elf_no_info_to_howto
-
-#define TARGET_BIG_SYM bfd_elf32_i860_vec
-#define TARGET_BIG_NAME "elf32-i860"
-#define ELF_ARCH bfd_arch_i860
-#define ELF_MACHINE_CODE EM_860
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32-m68k.c b/contrib/gdb/bfd/elf32-m68k.c
deleted file mode 100644
index 752dfae..0000000
--- a/contrib/gdb/bfd/elf32-m68k.c
+++ /dev/null
@@ -1,1600 +0,0 @@
-/* Motorola 68k series support for 32-bit ELF
- Copyright 1993, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-
-static reloc_howto_type *reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void rtype_to_howto
- PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
-static void rtype_to_howto_rel
- PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
-static boolean elf_m68k_check_relocs
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- const Elf_Internal_Rela *));
-static boolean elf_m68k_adjust_dynamic_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static boolean elf_m68k_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean elf_m68k_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static boolean elf_m68k_finish_dynamic_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
- Elf_Internal_Sym *));
-static boolean elf_m68k_finish_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* elf32 m68k code, generated by elf.el */
-enum reloc_type {
- R_68K_NONE = 0,
- R_68K_32 = 1,
- R_68K_16 = 2,
- R_68K_8 = 3,
- R_68K_PC32 = 4,
- R_68K_PC16 = 5,
- R_68K_PC8 = 6,
- R_68K_GOT32 = 7,
- R_68K_GOT16 = 8,
- R_68K_GOT8 = 9,
- R_68K_GOT32O = 10,
- R_68K_GOT16O = 11,
- R_68K_GOT8O = 12,
- R_68K_PLT32 = 13,
- R_68K_PLT16 = 14,
- R_68K_PLT8 = 15,
- R_68K_PLT32O = 16,
- R_68K_PLT16O = 17,
- R_68K_PLT8O = 18,
- R_68K_COPY = 19,
- R_68K_GLOB_DAT = 20,
- R_68K_JMP_SLOT = 21,
- R_68K_RELATIVE = 22,
- R_68K__max
-};
-
-static reloc_howto_type howto_table[] = {
- HOWTO(R_68K_NONE, 0, 0, 0, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_NONE", false, 0, 0x00000000,false),
- HOWTO(R_68K_32, 0, 2,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_32", false, 0, 0xffffffff,false),
- HOWTO(R_68K_16, 0, 1,16, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_16", false, 0, 0x0000ffff,false),
- HOWTO(R_68K_8, 0, 0, 8, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_8", false, 0, 0x000000ff,false),
- HOWTO(R_68K_PC32, 0, 2,32, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PC32", false, 0, 0xffffffff,true),
- HOWTO(R_68K_PC16, 0, 1,16, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PC16", false, 0, 0x0000ffff,true),
- HOWTO(R_68K_PC8, 0, 0, 8, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PC8", false, 0, 0x000000ff,true),
- HOWTO(R_68K_GOT32, 0, 2,32, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT32", false, 0, 0xffffffff,true),
- HOWTO(R_68K_GOT16, 0, 1,16, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT16", false, 0, 0x0000ffff,true),
- HOWTO(R_68K_GOT8, 0, 0, 8, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT8", false, 0, 0x000000ff,true),
- HOWTO(R_68K_GOT32O, 0, 2,32, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT32O", false, 0, 0xffffffff,false),
- HOWTO(R_68K_GOT16O, 0, 1,16, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT16O", false, 0, 0x0000ffff,false),
- HOWTO(R_68K_GOT8O, 0, 0, 8, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_GOT8O", false, 0, 0x000000ff,false),
- HOWTO(R_68K_PLT32, 0, 2,32, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT32", false, 0, 0xffffffff,true),
- HOWTO(R_68K_PLT16, 0, 1,16, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT16", false, 0, 0x0000ffff,true),
- HOWTO(R_68K_PLT8, 0, 0, 8, true, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT8", false, 0, 0x000000ff,true),
- HOWTO(R_68K_PLT32O, 0, 2,32, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT32O", false, 0, 0xffffffff,false),
- HOWTO(R_68K_PLT16O, 0, 1,16, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT16O", false, 0, 0x0000ffff,false),
- HOWTO(R_68K_PLT8O, 0, 0, 8, false,0, complain_overflow_signed, bfd_elf_generic_reloc, "R_68K_PLT8O", false, 0, 0x000000ff,false),
- HOWTO(R_68K_COPY, 0, 0, 0, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_COPY", false, 0, 0xffffffff,false),
- HOWTO(R_68K_GLOB_DAT, 0, 2,32, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_GLOB_DAT", false, 0, 0xffffffff,false),
- HOWTO(R_68K_JMP_SLOT, 0, 2,32, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_JMP_SLOT", false, 0, 0xffffffff,false),
- HOWTO(R_68K_RELATIVE, 0, 2,32, false,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_RELATIVE", false, 0, 0xffffffff,false),
-};
-
-static void
-rtype_to_howto (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf_Internal_Rela *dst;
-{
- BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_68K__max);
- cache_ptr->howto = &howto_table[ELF32_R_TYPE(dst->r_info)];
-}
-
-static void
-rtype_to_howto_rel (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf_Internal_Rel *dst;
-{
- BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_68K__max);
- cache_ptr->howto = &howto_table[ELF32_R_TYPE(dst->r_info)];
-}
-
-#define elf_info_to_howto rtype_to_howto
-#define elf_info_to_howto_rel rtype_to_howto_rel
-
-static const struct { unsigned char bfd_val, elf_val; } reloc_map[] = {
- { BFD_RELOC_NONE, R_68K_NONE },
- { BFD_RELOC_32, R_68K_32 },
- { BFD_RELOC_16, R_68K_16 },
- { BFD_RELOC_8, R_68K_8 },
- { BFD_RELOC_32_PCREL, R_68K_PC32 },
- { BFD_RELOC_16_PCREL, R_68K_PC16 },
- { BFD_RELOC_8_PCREL, R_68K_PC8 },
- { BFD_RELOC_32_GOT_PCREL, R_68K_GOT32 },
- { BFD_RELOC_16_GOT_PCREL, R_68K_GOT16 },
- { BFD_RELOC_8_GOT_PCREL, R_68K_GOT8 },
- { BFD_RELOC_32_GOTOFF, R_68K_GOT32O },
- { BFD_RELOC_16_GOTOFF, R_68K_GOT16O },
- { BFD_RELOC_8_GOTOFF, R_68K_GOT8O },
- { BFD_RELOC_32_PLT_PCREL, R_68K_PLT32 },
- { BFD_RELOC_16_PLT_PCREL, R_68K_PLT16 },
- { BFD_RELOC_8_PLT_PCREL, R_68K_PLT8 },
- { BFD_RELOC_32_PLTOFF, R_68K_PLT32O },
- { BFD_RELOC_16_PLTOFF, R_68K_PLT16O },
- { BFD_RELOC_8_PLTOFF, R_68K_PLT8O },
- { BFD_RELOC_NONE, R_68K_COPY },
- { BFD_RELOC_68K_GLOB_DAT, R_68K_GLOB_DAT },
- { BFD_RELOC_68K_JMP_SLOT, R_68K_JMP_SLOT },
- { BFD_RELOC_68K_RELATIVE, R_68K_RELATIVE },
- { BFD_RELOC_CTOR, R_68K_32 },
-};
-
-static reloc_howto_type *
-reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- unsigned int i;
- for (i = 0; i < sizeof (reloc_map) / sizeof (reloc_map[0]); i++)
- {
- if (reloc_map[i].bfd_val == code)
- return &howto_table[(int) reloc_map[i].elf_val];
- }
- return 0;
-}
-
-#define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup
-#define ELF_ARCH bfd_arch_m68k
-/* end code generated by elf.el */
-
-#define USE_RELA
-
-
-/* Functions for the m68k ELF linker. */
-
-/* The name of the dynamic interpreter. This is put in the .interp
- section. */
-
-#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
-
-/* The size in bytes of an entry in the procedure linkage table. */
-
-#define PLT_ENTRY_SIZE 20
-
-/* The first entry in a procedure linkage table looks like this. See
- the SVR4 ABI m68k supplement to see how this works. */
-
-static const bfd_byte elf_m68k_plt0_entry[PLT_ENTRY_SIZE] =
-{
- 0x2f, 0x3b, 0x01, 0x70, /* move.l (%pc,addr),-(%sp) */
- 0, 0, 0, 0, /* replaced with offset to .got + 4. */
- 0x4e, 0xfb, 0x01, 0x71, /* jmp ([%pc,addr]) */
- 0, 0, 0, 0, /* replaced with offset to .got + 8. */
- 0, 0, 0, 0 /* pad out to 20 bytes. */
-};
-
-/* Subsequent entries in a procedure linkage table look like this. */
-
-static const bfd_byte elf_m68k_plt_entry[PLT_ENTRY_SIZE] =
-{
- 0x4e, 0xfb, 0x01, 0x71, /* jmp ([%pc,symbol@GOTPC]) */
- 0, 0, 0, 0, /* replaced with offset to symbol's .got entry. */
- 0x2f, 0x3c, /* move.l #offset,-(%sp) */
- 0, 0, 0, 0, /* replaced with offset into relocation table. */
- 0x60, 0xff, /* bra.l .plt */
- 0, 0, 0, 0 /* replaced with offset to start of .plt. */
-};
-
-/* Look through the relocs for a section during the first phase, and
- allocate space in the global offset table or procedure linkage
- table. */
-
-static boolean
-elf_m68k_check_relocs (abfd, info, sec, relocs)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- const Elf_Internal_Rela *relocs;
-{
- bfd *dynobj;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- bfd_vma *local_got_offsets;
- const Elf_Internal_Rela *rel;
- const Elf_Internal_Rela *rel_end;
- asection *sgot;
- asection *srelgot;
- asection *sreloc;
-
- if (info->relocateable)
- return true;
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (abfd);
- local_got_offsets = elf_local_got_offsets (abfd);
-
- sgot = NULL;
- srelgot = NULL;
- sreloc = NULL;
-
- rel_end = relocs + sec->reloc_count;
- for (rel = relocs; rel < rel_end; rel++)
- {
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (r_symndx < symtab_hdr->sh_info)
- h = NULL;
- else
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_68K_GOT8:
- case R_68K_GOT16:
- case R_68K_GOT32:
- if (h != NULL
- && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
- break;
- /* Fall through. */
- case R_68K_GOT8O:
- case R_68K_GOT16O:
- case R_68K_GOT32O:
- /* This symbol requires a global offset table entry. */
-
- if (dynobj == NULL)
- {
- /* Create the .got section. */
- elf_hash_table (info)->dynobj = dynobj = abfd;
- if (!_bfd_elf_create_got_section (dynobj, info))
- return false;
- }
-
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- if (srelgot == NULL
- && (h != NULL || info->shared))
- {
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
- if (srelgot == NULL)
- {
- srelgot = bfd_make_section (dynobj, ".rela.got");
- if (srelgot == NULL
- || !bfd_set_section_flags (dynobj, srelgot,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || !bfd_set_section_alignment (dynobj, srelgot, 2))
- return false;
- }
- }
-
- if (h != NULL)
- {
- if (h->got_offset != (bfd_vma) -1)
- {
- /* We have already allocated space in the .got. */
- break;
- }
- h->got_offset = sgot->_raw_size;
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (!bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- srelgot->_raw_size += sizeof (Elf32_External_Rela);
- }
- else
- {
- /* This is a global offset table entry for a local
- symbol. */
- if (local_got_offsets == NULL)
- {
- size_t size;
- register unsigned int i;
-
- size = symtab_hdr->sh_info * sizeof (bfd_vma);
- local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
- if (local_got_offsets == NULL)
- return false;
- elf_local_got_offsets (abfd) = local_got_offsets;
- for (i = 0; i < symtab_hdr->sh_info; i++)
- local_got_offsets[i] = (bfd_vma) -1;
- }
- if (local_got_offsets[r_symndx] != (bfd_vma) -1)
- {
- /* We have already allocated space in the .got. */
- break;
- }
- local_got_offsets[r_symndx] = sgot->_raw_size;
-
- if (info->shared)
- {
- /* If we are generating a shared object, we need to
- output a R_68K_RELATIVE reloc so that the dynamic
- linker can adjust this GOT entry. */
- srelgot->_raw_size += sizeof (Elf32_External_Rela);
- }
- }
-
- sgot->_raw_size += 4;
- break;
-
- case R_68K_PLT8:
- case R_68K_PLT16:
- case R_68K_PLT32:
- /* This symbol requires a procedure linkage table entry. We
- actually build the entry in adjust_dynamic_symbol,
- because this might be a case of linking PIC code which is
- never referenced by a dynamic object, in which case we
- don't need to generate a procedure linkage table entry
- after all. */
-
- /* If this is a local symbol, we resolve it directly without
- creating a procedure linkage table entry. */
- if (h == NULL)
- continue;
-
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
- break;
-
- case R_68K_PLT8O:
- case R_68K_PLT16O:
- case R_68K_PLT32O:
- /* This symbol requires a procedure linkage table entry. */
-
- if (h == NULL)
- {
- /* It does not make sense to have this relocation for a
- local symbol. FIXME: does it? How to handle it if
- it does make sense? */
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (!bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
- break;
-
- case R_68K_PC8:
- case R_68K_PC16:
- case R_68K_PC32:
- if (h == NULL)
- break;
- /* Fall through. */
- case R_68K_8:
- case R_68K_16:
- case R_68K_32:
- if (info->shared
- && (sec->flags & SEC_ALLOC) != 0
- && ((ELF32_R_TYPE (rel->r_info) != R_68K_PC8
- && ELF32_R_TYPE (rel->r_info) != R_68K_PC16
- && ELF32_R_TYPE (rel->r_info) != R_68K_PC32)
- || (!info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)))
- {
- /* When creating a shared object, we must copy these
- reloc types into the output file. We create a reloc
- section in dynobj and make room for this reloc. */
- if (sreloc == NULL)
- {
- const char *name;
-
- name = (bfd_elf_string_from_elf_section
- (abfd,
- elf_elfheader (abfd)->e_shstrndx,
- elf_section_data (sec)->rel_hdr.sh_name));
- if (name == NULL)
- return false;
-
- BFD_ASSERT (strncmp (name, ".rela", 5) == 0
- && strcmp (bfd_get_section_name (abfd, sec),
- name + 5) == 0);
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- if (sreloc == NULL)
- {
- sreloc = bfd_make_section (dynobj, name);
- if (sreloc == NULL
- || !bfd_set_section_flags (dynobj, sreloc,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || !bfd_set_section_alignment (dynobj, sreloc, 2))
- return false;
- }
- }
-
- sreloc->_raw_size += sizeof (Elf32_External_Rela);
- }
-
- break;
-
- default:
- break;
- }
- }
-
- return true;
-}
-
-/* Adjust a symbol defined by a dynamic object and referenced by a
- regular object. The current definition is in some section of the
- dynamic object, but we're not including those sections. We have to
- change the definition to something the rest of the link can
- understand. */
-
-static boolean
-elf_m68k_adjust_dynamic_symbol (info, h)
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
-{
- bfd *dynobj;
- asection *s;
- unsigned int power_of_two;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- /* Make sure we know what is going on here. */
- BFD_ASSERT (dynobj != NULL
- && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
- || h->weakdef != NULL
- || ((h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_REF_REGULAR) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)));
-
- /* If this is a function, put it in the procedure linkage table. We
- will fill in the contents of the procedure linkage table later,
- when we know the address of the .got section. */
- if (h->type == STT_FUNC
- || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
- {
- if (! info->shared
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
- && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0
- /* We must always create the plt entry if it was referenced
- by a PLTxxO relocation. In this case we already recorded
- it as a dynamic symbol. */
- && h->dynindx == -1)
- {
- /* This case can occur if we saw a PLTxx reloc in an input
- file, but the symbol was never referred to by a dynamic
- object. In such a case, we don't actually need to build
- a procedure linkage table, and we can just do a PCxx
- reloc instead. */
- BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
- return true;
- }
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- s = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (s != NULL);
-
- /* If this is the first .plt entry, make room for the special
- first entry. */
- if (s->_raw_size == 0)
- s->_raw_size += PLT_ENTRY_SIZE;
-
- /* If this symbol is not defined in a regular file, and we are
- not generating a shared library, then set the symbol to this
- location in the .plt. This is required to make function
- pointers compare as equal between the normal executable and
- the shared library. */
- if (!info->shared
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
- }
-
- h->plt_offset = s->_raw_size;
-
- /* Make room for this entry. */
- s->_raw_size += PLT_ENTRY_SIZE;
-
- /* We also need to make an entry in the .got.plt section, which
- will be placed in the .got section by the linker script. */
-
- s = bfd_get_section_by_name (dynobj, ".got.plt");
- BFD_ASSERT (s != NULL);
- s->_raw_size += 4;
-
- /* We also need to make an entry in the .rela.plt section. */
-
- s = bfd_get_section_by_name (dynobj, ".rela.plt");
- BFD_ASSERT (s != NULL);
- s->_raw_size += sizeof (Elf32_External_Rela);
-
- return true;
- }
-
- /* If this is a weak symbol, and there is a real definition, the
- processor independent code will have arranged for us to see the
- real definition first, and we can just use the same value. */
- if (h->weakdef != NULL)
- {
- BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
- || h->weakdef->root.type == bfd_link_hash_defweak);
- h->root.u.def.section = h->weakdef->root.u.def.section;
- h->root.u.def.value = h->weakdef->root.u.def.value;
- return true;
- }
-
- /* This is a reference to a symbol defined by a dynamic object which
- is not a function. */
-
- /* If we are creating a shared library, we must presume that the
- only references to the symbol are via the global offset table.
- For such cases we need not do anything here; the relocations will
- be handled correctly by relocate_section. */
- if (info->shared)
- return true;
-
- /* We must allocate the symbol in our .dynbss section, which will
- become part of the .bss section of the executable. There will be
- an entry for this symbol in the .dynsym section. The dynamic
- object will contain position independent code, so all references
- from the dynamic object to this symbol will go through the global
- offset table. The dynamic linker will use the .dynsym entry to
- determine the address it must put in the global offset table, so
- both the dynamic object and the regular object will refer to the
- same memory location for the variable. */
-
- s = bfd_get_section_by_name (dynobj, ".dynbss");
- BFD_ASSERT (s != NULL);
-
- /* If the symbol is currently defined in the .bss section of the
- dynamic object, then it is OK to simply initialize it to zero.
- If the symbol is in some other section, we must generate a
- R_68K_COPY reloc to tell the dynamic linker to copy the initial
- value out of the dynamic object and into the runtime process
- image. We need to remember the offset into the .rela.bss section
- we are going to use. */
- if ((h->root.u.def.section->flags & SEC_LOAD) != 0)
- {
- asection *srel;
-
- srel = bfd_get_section_by_name (dynobj, ".rela.bss");
- BFD_ASSERT (srel != NULL);
- srel->_raw_size += sizeof (Elf32_External_Rela);
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
- }
-
- /* We need to figure out the alignment required for this symbol. I
- have no idea how ELF linkers handle this. */
- power_of_two = bfd_log2 (h->size);
- if (power_of_two > 3)
- power_of_two = 3;
-
- /* Apply the required alignment. */
- s->_raw_size = BFD_ALIGN (s->_raw_size,
- (bfd_size_type) (1 << power_of_two));
- if (power_of_two > bfd_get_section_alignment (dynobj, s))
- {
- if (!bfd_set_section_alignment (dynobj, s, power_of_two))
- return false;
- }
-
- /* Define the symbol as being at this point in the section. */
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
-
- /* Increment the section size to make room for the symbol. */
- s->_raw_size += h->size;
-
- return true;
-}
-
-/* Set the sizes of the dynamic sections. */
-
-static boolean
-elf_m68k_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *s;
- boolean plt;
- boolean relocs;
- boolean reltext;
-
- dynobj = elf_hash_table (info)->dynobj;
- BFD_ASSERT (dynobj != NULL);
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Set the contents of the .interp section to the interpreter. */
- if (!info->shared)
- {
- s = bfd_get_section_by_name (dynobj, ".interp");
- BFD_ASSERT (s != NULL);
- s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
- s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
- }
- }
- else
- {
- /* We may have created entries in the .rela.got section.
- However, if we are not creating the dynamic sections, we will
- not actually use these entries. Reset the size of .rela.got,
- which will cause it to get stripped from the output file
- below. */
- s = bfd_get_section_by_name (dynobj, ".rela.got");
- if (s != NULL)
- s->_raw_size = 0;
- }
-
- /* The check_relocs and adjust_dynamic_symbol entry points have
- determined the sizes of the various dynamic sections. Allocate
- memory for them. */
- plt = false;
- relocs = false;
- reltext = false;
- for (s = dynobj->sections; s != NULL; s = s->next)
- {
- const char *name;
- boolean strip;
-
- if ((s->flags & SEC_IN_MEMORY) == 0)
- continue;
-
- /* It's OK to base decisions on the section name, because none
- of the dynobj section names depend upon the input files. */
- name = bfd_get_section_name (dynobj, s);
-
- strip = false;
-
- if (strcmp (name, ".plt") == 0)
- {
- if (s->_raw_size == 0)
- {
- /* Strip this section if we don't need it; see the
- comment below. */
- strip = true;
- }
- else
- {
- /* Remember whether there is a PLT. */
- plt = true;
- }
- }
- else if (strncmp (name, ".rela", 5) == 0)
- {
- if (s->_raw_size == 0)
- {
- /* If we don't need this section, strip it from the
- output file. This is mostly to handle .rela.bss and
- .rela.plt. We must create both sections in
- create_dynamic_sections, because they must be created
- before the linker maps input sections to output
- sections. The linker does that before
- adjust_dynamic_symbol is called, and it is that
- function which decides whether anything needs to go
- into these sections. */
- strip = true;
- }
- else
- {
- asection *target;
-
- /* Remember whether there are any reloc sections other
- than .rela.plt. */
- if (strcmp (name, ".rela.plt") != 0)
- {
- relocs = true;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL
- entry. .rela.plt is actually associated with
- .got.plt, which is never readonly. */
- target = bfd_get_section_by_name (output_bfd, name + 5);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0)
- reltext = true;
- }
-
- /* We use the reloc_count field as a counter if we need
- to copy relocs into the output file. */
- s->reloc_count = 0;
- }
- }
- else if (strncmp (name, ".got", 4) != 0)
- {
- /* It's not one of our sections, so don't allocate space. */
- continue;
- }
-
- if (strip)
- {
- asection **spp;
-
- for (spp = &s->output_section->owner->sections;
- *spp != s->output_section;
- spp = &(*spp)->next)
- ;
- *spp = s->output_section->next;
- --s->output_section->owner->section_count;
-
- continue;
- }
-
- /* Allocate memory for the section contents. */
- s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
- if (s->contents == NULL && s->_raw_size != 0)
- return false;
- }
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in elf_m68k_finish_dynamic_sections, but we
- must add the entries now so that we get the correct size for
- the .dynamic section. The DT_DEBUG entry is filled in by the
- dynamic linker and used by the debugger. */
- if (!info->shared)
- {
- if (!bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
- return false;
- }
-
- if (plt)
- {
- if (!bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || !bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
- return false;
- }
-
- if (relocs)
- {
- if (!bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
- return false;
- }
-
- if (reltext)
- {
- if (!bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
- return false;
- }
- }
-
- return true;
-}
-
-/* Relocate an M68K ELF section. */
-
-static boolean
-elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, local_syms, local_sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- Elf_Internal_Rela *relocs;
- Elf_Internal_Sym *local_syms;
- asection **local_sections;
-{
- bfd *dynobj;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- bfd_vma *local_got_offsets;
- asection *sgot;
- asection *splt;
- asection *sreloc;
- Elf_Internal_Rela *rel;
- Elf_Internal_Rela *relend;
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (input_bfd);
- local_got_offsets = elf_local_got_offsets (input_bfd);
-
- sgot = NULL;
- splt = NULL;
- sreloc = NULL;
-
- rel = relocs;
- relend = relocs + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- int r_type;
- reloc_howto_type *howto;
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
- asection *sec;
- bfd_vma relocation;
- bfd_reloc_status_type r;
-
- r_type = ELF32_R_TYPE (rel->r_info);
- if (r_type < 0 || r_type >= (int) R_68K__max)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- howto = howto_table + r_type;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
- h = NULL;
- sym = NULL;
- sec = NULL;
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- sec = local_sections[r_symndx];
- relocation = (sec->output_section->vma
- + sec->output_offset
- + sym->st_value);
- }
- else
- {
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- if (((r_type == R_68K_PLT8
- || r_type == R_68K_PLT16
- || r_type == R_68K_PLT32
- || r_type == R_68K_PLT8O
- || r_type == R_68K_PLT16O
- || r_type == R_68K_PLT32O)
- && h->plt_offset != (bfd_vma) -1)
- || ((r_type == R_68K_GOT8O
- || r_type == R_68K_GOT16O
- || r_type == R_68K_GOT32O
- || ((r_type == R_68K_GOT8
- || r_type == R_68K_GOT16
- || r_type == R_68K_GOT32)
- && strcmp (h->root.root.string,
- "_GLOBAL_OFFSET_TABLE_") != 0))
- && elf_hash_table (info)->dynamic_sections_created
- && (! info->shared
- || ! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))
- || (info->shared
- && (! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)
- && (input_section->flags & SEC_ALLOC) != 0
- && (r_type == R_68K_8
- || r_type == R_68K_16
- || r_type == R_68K_32
- || r_type == R_68K_PC8
- || r_type == R_68K_PC16
- || r_type == R_68K_PC32)))
- {
- /* In these cases, we don't need the relocation
- value. We check specially because in some
- obscure cases sec->output_section will be NULL. */
- relocation = 0;
- }
- else
- relocation = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else if (info->shared && !info->symbolic)
- relocation = 0;
- else
- {
- if (!(info->callbacks->undefined_symbol
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset)))
- return false;
- relocation = 0;
- }
- }
-
- switch (r_type)
- {
- case R_68K_GOT8:
- case R_68K_GOT16:
- case R_68K_GOT32:
- /* Relocation is to the address of the entry for this symbol
- in the global offset table. */
- if (h != NULL
- && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
- break;
- /* Fall through. */
- case R_68K_GOT8O:
- case R_68K_GOT16O:
- case R_68K_GOT32O:
- /* Relocation is the offset of the entry for this symbol in
- the global offset table. */
-
- {
- bfd_vma off;
-
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- if (h != NULL)
- {
- off = h->got_offset;
- BFD_ASSERT (off != (bfd_vma) -1);
-
- if (!elf_hash_table (info)->dynamic_sections_created
- || (info->shared
- && info->symbolic
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
- {
- /* This is actually a static link, or it is a
- -Bsymbolic link and the symbol is defined
- locally. We must initialize this entry in the
- global offset table. Since the offset must
- always be a multiple of 4, we use the least
- significant bit to record whether we have
- initialized it already.
-
- When doing a dynamic link, we create a .rela.got
- relocation entry to initialize the value. This
- is done in the finish_dynamic_symbol routine. */
- if ((off & 1) != 0)
- off &= ~1;
- else
- {
- bfd_put_32 (output_bfd, relocation,
- sgot->contents + off);
- h->got_offset |= 1;
- }
- }
- }
- else
- {
- BFD_ASSERT (local_got_offsets != NULL
- && local_got_offsets[r_symndx] != (bfd_vma) -1);
-
- off = local_got_offsets[r_symndx];
-
- /* The offset must always be a multiple of 4. We use
- the least significant bit to record whether we have
- already generated the necessary reloc. */
- if ((off & 1) != 0)
- off &= ~1;
- else
- {
- bfd_put_32 (output_bfd, relocation, sgot->contents + off);
-
- if (info->shared)
- {
- asection *srelgot;
- Elf_Internal_Rela outrel;
-
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
- BFD_ASSERT (srelgot != NULL);
-
- outrel.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + off);
- outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
- outrel.r_addend = relocation;
- bfd_elf32_swap_reloca_out (output_bfd, &outrel,
- (((Elf32_External_Rela *)
- srelgot->contents)
- + srelgot->reloc_count));
- ++srelgot->reloc_count;
- }
-
- local_got_offsets[r_symndx] |= 1;
- }
- }
-
- relocation = sgot->output_offset + off;
- if (r_type == R_68K_GOT8O
- || r_type == R_68K_GOT16O
- || r_type == R_68K_GOT32O)
- {
- /* This relocation does not use the addend. */
- rel->r_addend = 0;
- }
- else
- relocation += sgot->output_section->vma;
- }
- break;
-
- case R_68K_PLT8:
- case R_68K_PLT16:
- case R_68K_PLT32:
- /* Relocation is to the entry for this symbol in the
- procedure linkage table. */
-
- /* Resolve a PLTxx reloc against a local symbol directly,
- without using the procedure linkage table. */
- if (h == NULL)
- break;
-
- if (h->plt_offset == (bfd_vma) -1)
- {
- /* We didn't make a PLT entry for this symbol. This
- happens when statically linking PIC code, or when
- using -Bsymbolic. */
- break;
- }
-
- if (splt == NULL)
- {
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL);
- }
-
- relocation = (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset);
- break;
-
- case R_68K_PLT8O:
- case R_68K_PLT16O:
- case R_68K_PLT32O:
- /* Relocation is the offset of the entry for this symbol in
- the procedure linkage table. */
- BFD_ASSERT (h != NULL && h->plt_offset == (bfd_vma) -1);
-
- if (splt == NULL)
- {
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL);
- }
-
- relocation = h->plt_offset;
-
- /* This relocation does not use the addend. */
- rel->r_addend = 0;
-
- break;
-
- case R_68K_PC8:
- case R_68K_PC16:
- case R_68K_PC32:
- if (h == NULL)
- break;
- /* Fall through. */
- case R_68K_8:
- case R_68K_16:
- case R_68K_32:
- if (info->shared
- && (input_section->flags & SEC_ALLOC) != 0
- && ((r_type != R_68K_PC8
- && r_type != R_68K_PC16
- && r_type != R_68K_PC32)
- || (!info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)))
- {
- Elf_Internal_Rela outrel;
- int relocate;
-
- /* When generating a shared object, these relocations
- are copied into the output file to be resolved at run
- time. */
-
- if (sreloc == NULL)
- {
- const char *name;
-
- name = (bfd_elf_string_from_elf_section
- (input_bfd,
- elf_elfheader (input_bfd)->e_shstrndx,
- elf_section_data (input_section)->rel_hdr.sh_name));
- if (name == NULL)
- return false;
-
- BFD_ASSERT (strncmp (name, ".rela", 5) == 0
- && strcmp (bfd_get_section_name (input_bfd,
- input_section),
- name + 5) == 0);
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- BFD_ASSERT (sreloc != NULL);
- }
-
- outrel.r_offset = (rel->r_offset
- + input_section->output_section->vma
- + input_section->output_offset);
- if (h != NULL
- && (! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))
- {
- BFD_ASSERT (h->dynindx != -1);
- relocate = false;
- outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
- outrel.r_addend = relocation + rel->r_addend;
- }
- else
- {
- if (r_type == R_68K_32)
- {
- relocate = true;
- outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
- outrel.r_addend = relocation + rel->r_addend;
- }
- else
- {
- long indx;
-
- if (h == NULL)
- sec = local_sections[r_symndx];
- else
- {
- BFD_ASSERT (h->root.type == bfd_link_hash_defined
- || (h->root.type
- == bfd_link_hash_defweak));
- sec = h->root.u.def.section;
- }
- if (sec != NULL && bfd_is_abs_section (sec))
- indx = 0;
- else if (sec == NULL || sec->owner == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- else
- {
- asection *osec;
-
- osec = sec->output_section;
- indx = elf_section_data (osec)->dynindx;
- if (indx == 0)
- abort ();
- }
-
- relocate = false;
- outrel.r_info = ELF32_R_INFO (indx, r_type);
- outrel.r_addend = relocation + rel->r_addend;
- }
- }
-
- bfd_elf32_swap_reloca_out (output_bfd, &outrel,
- (((Elf32_External_Rela *)
- sreloc->contents)
- + sreloc->reloc_count));
- ++sreloc->reloc_count;
-
- /* This reloc will be computed at runtime, so there's no
- need to do anything now, except for R_68K_32
- relocations that have been turned into
- R_68K_RELATIVE. */
- if (!relocate)
- continue;
- }
-
- break;
-
- default:
- break;
- }
-
- r = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents, rel->r_offset,
- relocation, rel->r_addend);
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
- if (name == NULL)
- return false;
- if (*name == '\0')
- name = bfd_section_name (input_bfd, sec);
- }
- if (!(info->callbacks->reloc_overflow
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Finish up dynamic symbol handling. We set the contents of various
- dynamic sections here. */
-
-static boolean
-elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
-{
- bfd *dynobj;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- if (h->plt_offset != (bfd_vma) -1)
- {
- asection *splt;
- asection *sgot;
- asection *srela;
- bfd_vma plt_index;
- bfd_vma got_offset;
- Elf_Internal_Rela rela;
-
- /* This symbol has an entry in the procedure linkage table. Set
- it up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- sgot = bfd_get_section_by_name (dynobj, ".got.plt");
- srela = bfd_get_section_by_name (dynobj, ".rela.plt");
- BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
-
- /* Get the index in the procedure linkage table which
- corresponds to this symbol. This is the index of this symbol
- in all the symbols for which we are making plt entries. The
- first entry in the procedure linkage table is reserved. */
- plt_index = h->plt_offset / PLT_ENTRY_SIZE - 1;
-
- /* Get the offset into the .got table of the entry that
- corresponds to this function. Each .got entry is 4 bytes.
- The first three are reserved. */
- got_offset = (plt_index + 3) * 4;
-
- /* Fill in the entry in the procedure linkage table. */
- memcpy (splt->contents + h->plt_offset, elf_m68k_plt_entry,
- PLT_ENTRY_SIZE);
- /* The offset is relative to the first extension word. */
- bfd_put_32 (output_bfd,
- (sgot->output_section->vma
- + sgot->output_offset
- + got_offset
- - (splt->output_section->vma
- + h->plt_offset + 2)),
- splt->contents + h->plt_offset + 4);
-
- bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
- splt->contents + h->plt_offset + 10);
- bfd_put_32 (output_bfd, - (h->plt_offset + 16),
- splt->contents + h->plt_offset + 16);
-
- /* Fill in the entry in the global offset table. */
- bfd_put_32 (output_bfd,
- (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset
- + 8),
- sgot->contents + got_offset);
-
- /* Fill in the entry in the .rela.plt section. */
- rela.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + got_offset);
- rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_JMP_SLOT);
- rela.r_addend = 0;
- bfd_elf32_swap_reloca_out (output_bfd, &rela,
- ((Elf32_External_Rela *) srela->contents
- + plt_index));
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- /* Mark the symbol as undefined, rather than as defined in
- the .plt section. Leave the value alone. */
- sym->st_shndx = SHN_UNDEF;
- }
- }
-
- if (h->got_offset != (bfd_vma) -1)
- {
- asection *sgot;
- asection *srela;
- Elf_Internal_Rela rela;
-
- /* This symbol has an entry in the global offset table. Set it
- up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- sgot = bfd_get_section_by_name (dynobj, ".got");
- srela = bfd_get_section_by_name (dynobj, ".rela.got");
- BFD_ASSERT (sgot != NULL && srela != NULL);
-
- rela.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + (h->got_offset &~ 1));
-
- /* If this is a -Bsymbolic link, and the symbol is defined
- locally, we just want to emit a RELATIVE reloc. The entry in
- the global offset table will already have been initialized in
- the relocate_section function. */
- if (info->shared
- && info->symbolic
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
- {
- rela.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
- rela.r_addend = bfd_get_32 (output_bfd,
- sgot->contents + (h->got_offset & ~1));
- }
- else
- {
- bfd_put_32 (output_bfd, (bfd_vma) 0,
- sgot->contents + (h->got_offset & ~1));
- rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_GLOB_DAT);
- rela.r_addend = 0;
- }
-
- bfd_elf32_swap_reloca_out (output_bfd, &rela,
- ((Elf32_External_Rela *) srela->contents
- + srela->reloc_count));
- ++srela->reloc_count;
- }
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
- {
- asection *s;
- Elf_Internal_Rela rela;
-
- /* This symbol needs a copy reloc. Set it up. */
-
- BFD_ASSERT (h->dynindx != -1
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak));
-
- s = bfd_get_section_by_name (h->root.u.def.section->owner,
- ".rela.bss");
- BFD_ASSERT (s != NULL);
-
- rela.r_offset = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_COPY);
- rela.r_addend = 0;
- bfd_elf32_swap_reloca_out (output_bfd, &rela,
- ((Elf32_External_Rela *) s->contents
- + s->reloc_count));
- ++s->reloc_count;
- }
-
- /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
- if (strcmp (h->root.root.string, "_DYNAMIC") == 0
- || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
- sym->st_shndx = SHN_ABS;
-
- return true;
-}
-
-/* Finish up the dynamic sections. */
-
-static boolean
-elf_m68k_finish_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *sgot;
- asection *sdyn;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- sgot = bfd_get_section_by_name (dynobj, ".got.plt");
- BFD_ASSERT (sgot != NULL);
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- asection *splt;
- Elf32_External_Dyn *dyncon, *dynconend;
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL && sdyn != NULL);
-
- dyncon = (Elf32_External_Dyn *) sdyn->contents;
- dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
- for (; dyncon < dynconend; dyncon++)
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- asection *s;
-
- bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
-
- switch (dyn.d_tag)
- {
- default:
- break;
-
- case DT_PLTGOT:
- name = ".got";
- goto get_vma;
- case DT_JMPREL:
- name = ".rela.plt";
- get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_PLTRELSZ:
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- BFD_ASSERT (s != NULL);
- if (s->_cooked_size != 0)
- dyn.d_un.d_val = s->_cooked_size;
- else
- dyn.d_un.d_val = s->_raw_size;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_RELASZ:
- /* The procedure linkage table relocs (DT_JMPREL) should
- not be included in the overall relocs (DT_RELA).
- Therefore, we override the DT_RELASZ entry here to
- make it not include the JMPREL relocs. Since the
- linker script arranges for .rela.plt to follow all
- other relocation sections, we don't have to worry
- about changing the DT_RELA entry. */
- s = bfd_get_section_by_name (output_bfd, ".rela.plt");
- if (s != NULL)
- {
- if (s->_cooked_size != 0)
- dyn.d_un.d_val -= s->_cooked_size;
- else
- dyn.d_un.d_val -= s->_raw_size;
- }
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
- }
- }
-
- /* Fill in the first entry in the procedure linkage table. */
- if (splt->_raw_size > 0)
- {
- memcpy (splt->contents, elf_m68k_plt0_entry, PLT_ENTRY_SIZE);
- bfd_put_32 (output_bfd,
- (sgot->output_section->vma
- + sgot->output_offset + 4
- - (splt->output_section->vma + 2)),
- splt->contents + 4);
- bfd_put_32 (output_bfd,
- (sgot->output_section->vma
- + sgot->output_offset + 8
- - (splt->output_section->vma + 10)),
- splt->contents + 12);
- }
-
- elf_section_data (splt->output_section)->this_hdr.sh_entsize
- = PLT_ENTRY_SIZE;
- }
-
- /* Fill in the first three entries in the global offset table. */
- if (sgot->_raw_size > 0)
- {
- if (sdyn == NULL)
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
- else
- bfd_put_32 (output_bfd,
- sdyn->output_section->vma + sdyn->output_offset,
- sgot->contents);
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
- }
-
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
-
- return true;
-}
-
-#define TARGET_BIG_SYM bfd_elf32_m68k_vec
-#define TARGET_BIG_NAME "elf32-m68k"
-#define ELF_MACHINE_CODE EM_68K
-#define ELF_MAXPAGESIZE 0x2000
-#define elf_backend_create_dynamic_sections \
- _bfd_elf_create_dynamic_sections
-#define elf_backend_check_relocs elf_m68k_check_relocs
-#define elf_backend_adjust_dynamic_symbol \
- elf_m68k_adjust_dynamic_symbol
-#define elf_backend_size_dynamic_sections \
- elf_m68k_size_dynamic_sections
-#define elf_backend_relocate_section elf_m68k_relocate_section
-#define elf_backend_finish_dynamic_symbol \
- elf_m68k_finish_dynamic_symbol
-#define elf_backend_finish_dynamic_sections \
- elf_m68k_finish_dynamic_sections
-#define elf_backend_want_got_plt 1
-#define elf_backend_plt_readonly 1
-#define elf_backend_want_plt_sym 0
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32-m88k.c b/contrib/gdb/bfd/elf32-m88k.c
deleted file mode 100644
index f3c535e..0000000
--- a/contrib/gdb/bfd/elf32-m88k.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Motorola 88k-specific support for 32-bit ELF
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-
-/* This does not include any relocations, but should be good enough
- for GDB. */
-
-#define TARGET_BIG_SYM bfd_elf32_m88k_vec
-#define TARGET_BIG_NAME "elf32-m88k"
-#define ELF_ARCH bfd_arch_m88k
-#define ELF_MACHINE_CODE EM_88K
-#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
-#define elf_info_to_howto _bfd_elf_no_info_to_howto
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32-mips.c b/contrib/gdb/bfd/elf32-mips.c
deleted file mode 100644
index ced0000..0000000
--- a/contrib/gdb/bfd/elf32-mips.c
+++ /dev/null
@@ -1,5867 +0,0 @@
-/* MIPS-specific support for 32-bit ELF
- Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
-
- Most of the information added by Ian Lance Taylor, Cygnus Support,
- <ian@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
- different MIPS ELF from other targets. This matters when linking.
- This file supports both, switching at runtime. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "genlink.h"
-#include "elf-bfd.h"
-#include "elf/mips.h"
-
-/* Get the ECOFF swapping routines. */
-#include "coff/sym.h"
-#include "coff/symconst.h"
-#include "coff/internal.h"
-#include "coff/ecoff.h"
-#include "coff/mips.h"
-#define ECOFF_32
-#include "ecoffswap.h"
-
-static bfd_reloc_status_type mips_elf_hi16_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_elf_got16_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_elf_lo16_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_elf_gprel16_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static bfd_reloc_status_type mips_elf_gprel32_reloc PARAMS ((bfd *abfd,
- arelent *reloc,
- asymbol *symbol,
- PTR data,
- asection *section,
- bfd *output_bfd,
- char **error));
-static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void mips_info_to_howto_rel
- PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
-static void bfd_mips_elf32_swap_gptab_in
- PARAMS ((bfd *, const Elf32_External_gptab *, Elf32_gptab *));
-static void bfd_mips_elf32_swap_gptab_out
- PARAMS ((bfd *, const Elf32_gptab *, Elf32_External_gptab *));
-static boolean mips_elf_sym_is_global PARAMS ((bfd *, asymbol *));
-static boolean mips_elf_object_p PARAMS ((bfd *));
-static boolean mips_elf_create_procedure_table
- PARAMS ((PTR, bfd *, struct bfd_link_info *, asection *,
- struct ecoff_debug_info *));
-static int mips_elf_additional_program_headers PARAMS ((bfd *));
-static boolean mips_elf_modify_segment_map PARAMS ((bfd *));
-static void mips_elf_final_write_processing
- PARAMS ((bfd *, boolean));
-static boolean mips_elf_set_private_flags PARAMS ((bfd *, flagword));
-static boolean mips_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-static boolean mips_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
-static boolean mips_elf_section_from_shdr
- PARAMS ((bfd *, Elf32_Internal_Shdr *, char *));
-static boolean mips_elf_fake_sections
- PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
-static boolean mips_elf_section_from_bfd_section
- PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *));
-static boolean mips_elf_section_processing
- PARAMS ((bfd *, Elf32_Internal_Shdr *));
-static void mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
-static boolean mips_elf_read_ecoff_info
- PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
-static boolean mips_elf_is_local_label
- PARAMS ((bfd *, asymbol *));
-static boolean mips_elf_find_nearest_line
- PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
- const char **, unsigned int *));
-static struct bfd_hash_entry *mips_elf_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *mips_elf_link_hash_table_create
- PARAMS ((bfd *));
-static int gptab_compare PARAMS ((const void *, const void *));
-static boolean mips_elf_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-static void mips_elf_relocate_hi16
- PARAMS ((bfd *, Elf_Internal_Rela *, Elf_Internal_Rela *, bfd_byte *,
- bfd_vma));
-static void mips_elf_relocate_got_local
- PARAMS ((bfd *, bfd *, asection *, Elf_Internal_Rela *,
- Elf_Internal_Rela *, bfd_byte *, bfd_vma));
-static void mips_elf_relocate_global_got
- PARAMS ((bfd *, Elf_Internal_Rela *, bfd_byte *, bfd_vma));
-static boolean mips_elf_adjust_dynindx
- PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean mips_elf_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static boolean mips_elf_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean mips_elf_create_compact_rel_section
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean mips_elf_create_got_section
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean mips_elf_check_relocs
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- const Elf_Internal_Rela *));
-static boolean mips_elf_adjust_dynamic_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static boolean mips_elf_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean mips_elf_finish_dynamic_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
- Elf_Internal_Sym *));
-static boolean mips_elf_finish_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean mips_elf_add_symbol_hook
- PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
- const char **, flagword *, asection **, bfd_vma *));
-static bfd_reloc_status_type mips_elf_final_gp
- PARAMS ((bfd *, asymbol *, boolean, char **, bfd_vma *));
-static bfd_byte *elf32_mips_get_relocated_section_contents
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *, boolean, asymbol **));
-
-/* This is true for Irix 5 executables, false for normal MIPS ELF ABI
- executables. FIXME: At the moment, we default to always generating
- Irix 5 executables. */
-
-#define SGI_COMPAT(abfd) (1)
-
-/* This structure is used to hold .got information when linking. It
- is stored in the tdata field of the bfd_elf_section_data structure. */
-
-struct mips_got_info
-{
- /* The symbol index of the first global .got symbol. */
- unsigned long global_gotsym;
- /* The number of local .got entries. */
- unsigned int local_gotno;
-};
-
-/* The number of local .got entries we reserve. */
-#define MIPS_RESERVED_GOTNO (2)
-
-/* Instructions which appear in a stub. For some reason the stub is
- slightly different on an SGI system. */
-#define ELF_MIPS_GP_OFFSET(abfd) (SGI_COMPAT (abfd) ? 0x7ff0 : 0x8000)
-#define STUB_LW(abfd) \
- (SGI_COMPAT (abfd) \
- ? 0x8f998010 /* lw t9,0x8010(gp) */ \
- : 0x8f998000) /* lw t9,0x8000(gp) */
-#define STUB_MOVE 0x03e07825 /* move t7,ra */
-#define STUB_JALR 0x0320f809 /* jal t9 */
-#define STUB_LI16 0x34180000 /* ori t8,zero,0 */
-#define MIPS_FUNCTION_STUB_SIZE (16)
-
-/* Names of sections which appear in the .dynsym section in an Irix 5
- executable. */
-
-static const char * const mips_elf_dynsym_sec_names[] =
-{
- ".text",
- ".init",
- ".fini",
- ".data",
- ".rodata",
- ".sdata",
- ".sbss",
- ".bss",
- NULL
-};
-
-#define SIZEOF_MIPS_DYNSYM_SECNAMES \
- (sizeof mips_elf_dynsym_sec_names / sizeof mips_elf_dynsym_sec_names[0])
-
-/* The number of entries in mips_elf_dynsym_sec_names which go in the
- text segment. */
-
-#define MIPS_TEXT_DYNSYM_SECNO (3)
-
-/* The names of the runtime procedure table symbols used on Irix 5. */
-
-static const char * const mips_elf_dynsym_rtproc_names[] =
-{
- "_procedure_table",
- "_procedure_string_table",
- "_procedure_table_size",
- NULL
-};
-
-/* These structures are used to generate the .compact_rel section on
- Irix 5. */
-
-typedef struct
-{
- unsigned long id1; /* Always one? */
- unsigned long num; /* Number of compact relocation entries. */
- unsigned long id2; /* Always two? */
- unsigned long offset; /* The file offset of the first relocation. */
- unsigned long reserved0; /* Zero? */
- unsigned long reserved1; /* Zero? */
-} Elf32_compact_rel;
-
-typedef struct
-{
- bfd_byte id1[4];
- bfd_byte num[4];
- bfd_byte id2[4];
- bfd_byte offset[4];
- bfd_byte reserved0[4];
- bfd_byte reserved1[4];
-} Elf32_External_compact_rel;
-
-typedef struct
-{
- unsigned int ctype : 1; /* 1: long 0: short format. See below. */
- unsigned int rtype : 4; /* Relocation types. See below. */
- unsigned int dist2to : 8;
- unsigned int relvaddr : 19; /* (VADDR - vaddr of the previous entry)/ 4 */
- unsigned long konst; /* KONST field. See below. */
- unsigned long vaddr; /* VADDR to be relocated. */
-} Elf32_crinfo;
-
-typedef struct
-{
- unsigned int ctype : 1; /* 1: long 0: short format. See below. */
- unsigned int rtype : 4; /* Relocation types. See below. */
- unsigned int dist2to : 8;
- unsigned int relvaddr : 19; /* (VADDR - vaddr of the previous entry)/ 4 */
- unsigned long konst; /* KONST field. See below. */
-} Elf32_crinfo2;
-
-typedef struct
-{
- bfd_byte info[4];
- bfd_byte konst[4];
- bfd_byte vaddr[4];
-} Elf32_External_crinfo;
-
-typedef struct
-{
- bfd_byte info[4];
- bfd_byte konst[4];
-} Elf32_External_crinfo2;
-
-/* These are the constants used to swap the bitfields in a crinfo. */
-
-#define CRINFO_CTYPE (0x1)
-#define CRINFO_CTYPE_SH (31)
-#define CRINFO_RTYPE (0xf)
-#define CRINFO_RTYPE_SH (27)
-#define CRINFO_DIST2TO (0xff)
-#define CRINFO_DIST2TO_SH (19)
-#define CRINFO_RELVADDR (0x7ffff)
-#define CRINFO_RELVADDR_SH (0)
-
-/* A compact relocation info has long (3 words) or short (2 words)
- formats. A short format doesn't have VADDR field and relvaddr
- fields contains ((VADDR - vaddr of the previous entry) >> 2). */
-#define CRF_MIPS_LONG 1
-#define CRF_MIPS_SHORT 0
-
-/* There are 4 types of compact relocation at least. The value KONST
- has different meaning for each type:
-
- (type) (konst)
- CT_MIPS_REL32 Address in data
- CT_MIPS_WORD Address in word (XXX)
- CT_MIPS_GPHI_LO GP - vaddr
- CT_MIPS_JMPAD Address to jump
- */
-
-#define CRT_MIPS_REL32 0xa
-#define CRT_MIPS_WORD 0xb
-#define CRT_MIPS_GPHI_LO 0xc
-#define CRT_MIPS_JMPAD 0xd
-
-#define mips_elf_set_cr_format(x,format) ((x).ctype = (format))
-#define mips_elf_set_cr_type(x,type) ((x).rtype = (type))
-#define mips_elf_set_cr_dist2to(x,v) ((x).dist2to = (v))
-#define mips_elf_set_cr_relvaddr(x,d) ((x).relvaddr = (d)<<2)
-
-static void bfd_elf32_swap_compact_rel_out
- PARAMS ((bfd *, const Elf32_compact_rel *, Elf32_External_compact_rel *));
-static void bfd_elf32_swap_crinfo_out
- PARAMS ((bfd *, const Elf32_crinfo *, Elf32_External_crinfo *));
-
-#define USE_REL 1 /* MIPS uses REL relocations instead of RELA */
-
-enum reloc_type
-{
- R_MIPS_NONE = 0,
- R_MIPS_16, R_MIPS_32,
- R_MIPS_REL32, R_MIPS_26,
- R_MIPS_HI16, R_MIPS_LO16,
- R_MIPS_GPREL16, R_MIPS_LITERAL,
- R_MIPS_GOT16, R_MIPS_PC16,
- R_MIPS_CALL16, R_MIPS_GPREL32,
- /* The remaining relocs are defined on Irix, although they are not
- in the MIPS ELF ABI. */
- R_MIPS_UNUSED1, R_MIPS_UNUSED2,
- R_MIPS_UNUSED3,
- R_MIPS_SHIFT5, R_MIPS_SHIFT6,
- R_MIPS_64, R_MIPS_GOT_DISP,
- R_MIPS_GOT_PAGE, R_MIPS_GOT_OFST,
- R_MIPS_GOT_HI16, R_MIPS_GOT_LO16,
- R_MIPS_SUB, R_MIPS_INSERT_A,
- R_MIPS_INSERT_B, R_MIPS_DELETE,
- R_MIPS_HIGHER, R_MIPS_HIGHEST,
- R_MIPS_CALL_HI16, R_MIPS_CALL_LO16,
- R_MIPS_max
-};
-
-static reloc_howto_type elf_mips_howto_table[] =
-{
- /* No relocation. */
- HOWTO (R_MIPS_NONE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_NONE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit relocation. */
- HOWTO (R_MIPS_16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit relocation. */
- HOWTO (R_MIPS_32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit symbol relative relocation. */
- HOWTO (R_MIPS_REL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_REL32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 26 bit branch address. */
- HOWTO (R_MIPS_26, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- /* This needs complex overflow
- detection, because the upper four
- bits must match the PC. */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_26", /* name */
- true, /* partial_inplace */
- 0x3ffffff, /* src_mask */
- 0x3ffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* High 16 bits of symbol value. */
- HOWTO (R_MIPS_HI16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- mips_elf_hi16_reloc, /* special_function */
- "R_MIPS_HI16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Low 16 bits of symbol value. */
- HOWTO (R_MIPS_LO16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- mips_elf_lo16_reloc, /* special_function */
- "R_MIPS_LO16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* GP relative reference. */
- HOWTO (R_MIPS_GPREL16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- mips_elf_gprel16_reloc, /* special_function */
- "R_MIPS_GPREL16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Reference to literal section. */
- HOWTO (R_MIPS_LITERAL, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- mips_elf_gprel16_reloc, /* special_function */
- "R_MIPS_LITERAL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Reference to global offset table. */
- HOWTO (R_MIPS_GOT16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- mips_elf_got16_reloc, /* special_function */
- "R_MIPS_GOT16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit PC relative reference. */
- HOWTO (R_MIPS_PC16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_PC16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit call through global offset table. */
- /* FIXME: This is not handled correctly. */
- HOWTO (R_MIPS_CALL16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_CALL16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit GP relative reference. */
- HOWTO (R_MIPS_GPREL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- mips_elf_gprel32_reloc, /* special_function */
- "R_MIPS_GPREL32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* The remaining relocs are defined on Irix 5, although they are
- not defined by the ABI. */
- { 13 },
- { 14 },
- { 15 },
-
- /* A 5 bit shift field. */
- HOWTO (R_MIPS_SHIFT5, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 5, /* bitsize */
- false, /* pc_relative */
- 6, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_SHIFT5", /* name */
- true, /* partial_inplace */
- 0x000007c0, /* src_mask */
- 0x000007c0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 6 bit shift field. */
- /* FIXME: This is not handled correctly; a special function is
- needed to put the most significant bit in the right place. */
- HOWTO (R_MIPS_SHIFT6, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 6, /* bitsize */
- false, /* pc_relative */
- 6, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_SHIFT6", /* name */
- true, /* partial_inplace */
- 0x000007c4, /* src_mask */
- 0x000007c4, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 64 bit relocation. Presumably not used in 32 bit ELF. */
- { R_MIPS_64 },
-
- /* Displacement in the global offset table. */
- /* FIXME: Not handled correctly. */
- HOWTO (R_MIPS_GOT_DISP, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_GOT_DISP", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Displacement to page pointer in the global offset table. */
- /* FIXME: Not handled correctly. */
- HOWTO (R_MIPS_GOT_PAGE, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_GOT_PAGE", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Offset from page pointer in the global offset table. */
- /* FIXME: Not handled correctly. */
- HOWTO (R_MIPS_GOT_OFST, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_GOT_OFST", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* High 16 bits of displacement in global offset table. */
- /* FIXME: Not handled correctly. */
- HOWTO (R_MIPS_GOT_HI16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_GOT_HI16", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Low 16 bits of displacement in global offset table. */
- /* FIXME: Not handled correctly. */
- HOWTO (R_MIPS_GOT_LO16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_GOT_LO16", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 64 bit subtraction. Presumably not used in 32 bit ELF. */
- { R_MIPS_SUB },
-
- /* Used to cause the linker to insert and delete instructions? */
- { R_MIPS_INSERT_A },
- { R_MIPS_INSERT_B },
- { R_MIPS_DELETE },
-
- /* Get the higher values of a 64 bit addend. Presumably not used in
- 32 bit ELF. */
- { R_MIPS_HIGHER },
- { R_MIPS_HIGHEST },
-
- /* High 16 bits of displacement in global offset table. */
- /* FIXME: Not handled correctly. */
- HOWTO (R_MIPS_CALL_HI16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_CALL_HI16", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Low 16 bits of displacement in global offset table. */
- /* FIXME: Not handled correctly. */
- HOWTO (R_MIPS_CALL_LO16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_MIPS_CALL_LO16", /* name */
- true, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
- false) /* pcrel_offset */
-};
-
-/* Do a R_MIPS_HI16 relocation. This has to be done in combination
- with a R_MIPS_LO16 reloc, because there is a carry from the LO16 to
- the HI16. Here we just save the information we need; we do the
- actual relocation when we see the LO16. MIPS ELF requires that the
- LO16 immediately follow the HI16, so this ought to work. */
-
-static bfd_byte *mips_hi16_addr;
-static bfd_vma mips_hi16_addend;
-
-static bfd_reloc_status_type
-mips_elf_hi16_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_reloc_status_type ret;
- bfd_vma relocation;
-
- /* If we're relocating, and this an external symbol, we don't want
- to change anything. */
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && reloc_entry->addend == 0)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- ret = bfd_reloc_ok;
-
- if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
- {
- boolean relocateable;
- bfd_vma gp;
-
- if (ret == bfd_reloc_undefined)
- abort ();
-
- if (output_bfd != NULL)
- relocateable = true;
- else
- {
- relocateable = false;
- output_bfd = symbol->section->output_section->owner;
- }
-
- ret = mips_elf_final_gp (output_bfd, symbol, relocateable,
- error_message, &gp);
- if (ret != bfd_reloc_ok)
- return ret;
-
- relocation = gp - reloc_entry->address;
- }
- else
- {
- if (bfd_is_und_section (symbol->section)
- && output_bfd == (bfd *) NULL)
- ret = bfd_reloc_undefined;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
- }
-
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* Save the information, and let LO16 do the actual relocation. */
- mips_hi16_addr = (bfd_byte *) data + reloc_entry->address;
- mips_hi16_addend = relocation;
-
- if (output_bfd != (bfd *) NULL)
- reloc_entry->address += input_section->output_offset;
-
- return ret;
-}
-
-/* Do a R_MIPS_LO16 relocation. This is a straightforward 16 bit
- inplace relocation; this function exists in order to do the
- R_MIPS_HI16 relocation described above. */
-
-static bfd_reloc_status_type
-mips_elf_lo16_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- arelent gp_disp_relent;
-
- if (mips_hi16_addr != (bfd_byte *) NULL)
- {
- unsigned long insn;
- unsigned long val;
- unsigned long vallo;
-
- /* Do the HI16 relocation. Note that we actually don't need to
- know anything about the LO16 itself, except where to find the
- low 16 bits of the addend needed by the LO16. */
- insn = bfd_get_32 (abfd, mips_hi16_addr);
- vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address)
- & 0xffff);
- val = ((insn & 0xffff) << 16) + vallo;
- val += mips_hi16_addend;
-
- /* The low order 16 bits are always treated as a signed value.
- Therefore, a negative value in the low order bits requires an
- adjustment in the high order bits. We need to make this
- adjustment in two ways: once for the bits we took from the
- data, and once for the bits we are putting back in to the
- data. */
- if ((vallo & 0x8000) != 0)
- val -= 0x10000;
- if ((val & 0x8000) != 0)
- val += 0x10000;
-
- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
- bfd_put_32 (abfd, insn, mips_hi16_addr);
-
- mips_hi16_addr = (bfd_byte *) NULL;
-
- if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
- {
- gp_disp_relent = *reloc_entry;
- reloc_entry = &gp_disp_relent;
- reloc_entry->addend = mips_hi16_addend;
- }
- }
- else if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
- {
- bfd_reloc_status_type ret;
- bfd_vma gp, relocation;
-
- /* FIXME: Does this case ever occur? */
-
- ret = mips_elf_final_gp (output_bfd, symbol, true, error_message, &gp);
- if (ret != bfd_reloc_ok)
- return ret;
-
- relocation = gp - reloc_entry->address;
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- gp_disp_relent = *reloc_entry;
- reloc_entry = &gp_disp_relent;
- reloc_entry->addend = relocation - 4;
- }
-
- /* Now do the LO16 reloc in the usual way. */
- return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message);
-}
-
-/* Do a R_MIPS_GOT16 reloc. This is a reloc against the global offset
- table used for PIC code. If the symbol is an external symbol, the
- instruction is modified to contain the offset of the appropriate
- entry in the global offset table. If the symbol is a section
- symbol, the next reloc is a R_MIPS_LO16 reloc. The two 16 bit
- addends are combined to form the real addend against the section
- symbol; the GOT16 is modified to contain the offset of an entry in
- the global offset table, and the LO16 is modified to offset it
- appropriately. Thus an offset larger than 16 bits requires a
- modified value in the global offset table.
-
- This implementation suffices for the assembler, but the linker does
- not yet know how to create global offset tables. */
-
-static bfd_reloc_status_type
-mips_elf_got16_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- /* If we're relocating, and this an external symbol, we don't want
- to change anything. */
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && reloc_entry->addend == 0)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- /* If we're relocating, and this is a local symbol, we can handle it
- just like HI16. */
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) != 0)
- return mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message);
-
- abort ();
-}
-
-/* We have to figure out the gp value, so that we can adjust the
- symbol value correctly. We look up the symbol _gp in the output
- BFD. If we can't find it, we're stuck. We cache it in the ELF
- target data. We don't need to adjust the symbol value for an
- external symbol if we are producing relocateable output. */
-
-static bfd_reloc_status_type
-mips_elf_final_gp (output_bfd, symbol, relocateable, error_message, pgp)
- bfd *output_bfd;
- asymbol *symbol;
- boolean relocateable;
- char **error_message;
- bfd_vma *pgp;
-{
- if (bfd_is_und_section (symbol->section)
- && ! relocateable)
- {
- *pgp = 0;
- return bfd_reloc_undefined;
- }
-
- *pgp = _bfd_get_gp_value (output_bfd);
- if (*pgp == 0
- && (! relocateable
- || (symbol->flags & BSF_SECTION_SYM) != 0))
- {
- if (relocateable)
- {
- /* Make up a value. */
- *pgp = symbol->section->output_section->vma + 0x4000;
- _bfd_set_gp_value (output_bfd, *pgp);
- }
- else
- {
- unsigned int count;
- asymbol **sym;
- unsigned int i;
-
- count = bfd_get_symcount (output_bfd);
- sym = bfd_get_outsymbols (output_bfd);
-
- if (sym == (asymbol **) NULL)
- i = count;
- else
- {
- for (i = 0; i < count; i++, sym++)
- {
- register CONST char *name;
-
- name = bfd_asymbol_name (*sym);
- if (*name == '_' && strcmp (name, "_gp") == 0)
- {
- *pgp = bfd_asymbol_value (*sym);
- _bfd_set_gp_value (output_bfd, *pgp);
- break;
- }
- }
- }
-
- if (i >= count)
- {
- /* Only get the error once. */
- *pgp = 4;
- _bfd_set_gp_value (output_bfd, *pgp);
- *error_message =
- (char *) "GP relative relocation when _gp not defined";
- return bfd_reloc_dangerous;
- }
- }
- }
-
- return bfd_reloc_ok;
-}
-
-/* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
- become the offset from the gp register. This function also handles
- R_MIPS_LITERAL relocations, although those can be handled more
- cleverly because the entries in the .lit8 and .lit4 sections can be
- merged. */
-
-static bfd_reloc_status_type gprel16_with_gp PARAMS ((bfd *, asymbol *,
- arelent *, asection *,
- boolean, PTR, bfd_vma));
-
-static bfd_reloc_status_type
-mips_elf_gprel16_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- boolean relocateable;
- bfd_reloc_status_type ret;
- bfd_vma gp;
-
- /* If we're relocating, and this is an external symbol with no
- addend, we don't want to change anything. We will only have an
- addend if this is a newly created reloc, not read from an ELF
- file. */
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && reloc_entry->addend == 0)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- if (output_bfd != (bfd *) NULL)
- relocateable = true;
- else
- {
- relocateable = false;
- output_bfd = symbol->section->output_section->owner;
- }
-
- ret = mips_elf_final_gp (output_bfd, symbol, relocateable, error_message,
- &gp);
- if (ret != bfd_reloc_ok)
- return ret;
-
- return gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
- relocateable, data, gp);
-}
-
-static bfd_reloc_status_type
-gprel16_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data,
- gp)
- bfd *abfd;
- asymbol *symbol;
- arelent *reloc_entry;
- asection *input_section;
- boolean relocateable;
- PTR data;
- bfd_vma gp;
-{
- bfd_vma relocation;
- unsigned long insn;
- unsigned long val;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
-
- /* Set val to the offset into the section or symbol. */
- val = ((insn & 0xffff) + reloc_entry->addend) & 0xffff;
- if (val & 0x8000)
- val -= 0x10000;
-
- /* Adjust val for the final section location and GP value. If we
- are producing relocateable output, we don't want to do this for
- an external symbol. */
- if (! relocateable
- || (symbol->flags & BSF_SECTION_SYM) != 0)
- val += relocation - gp;
-
- insn = (insn &~ 0xffff) | (val & 0xffff);
- bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
-
- if (relocateable)
- reloc_entry->address += input_section->output_offset;
-
- /* Make sure it fit in 16 bits. */
- if (val >= 0x8000 && val < 0xffff8000)
- return bfd_reloc_overflow;
-
- return bfd_reloc_ok;
-}
-
-/* Do a R_MIPS_GPREL32 relocation. Is this 32 bit value the offset
- from the gp register? XXX */
-
-static bfd_reloc_status_type gprel32_with_gp PARAMS ((bfd *, asymbol *,
- arelent *, asection *,
- boolean, PTR, bfd_vma));
-
-static bfd_reloc_status_type
-mips_elf_gprel32_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- boolean relocateable;
- bfd_reloc_status_type ret;
- bfd_vma gp;
-
- /* If we're relocating, and this is an external symbol with no
- addend, we don't want to change anything. We will only have an
- addend if this is a newly created reloc, not read from an ELF
- file. */
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && reloc_entry->addend == 0)
- {
- *error_message = (char *)
- "32bits gp relative relocation occurs for an external symbol";
- return bfd_reloc_outofrange;
- }
-
- if (output_bfd != (bfd *) NULL)
- {
- relocateable = true;
- gp = _bfd_get_gp_value (output_bfd);
- }
- else
- {
- relocateable = false;
- output_bfd = symbol->section->output_section->owner;
-
- ret = mips_elf_final_gp (output_bfd, symbol, relocateable,
- error_message, &gp);
- if (ret != bfd_reloc_ok)
- return ret;
- }
-
- return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
- relocateable, data, gp);
-}
-
-static bfd_reloc_status_type
-gprel32_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data,
- gp)
- bfd *abfd;
- asymbol *symbol;
- arelent *reloc_entry;
- asection *input_section;
- boolean relocateable;
- PTR data;
- bfd_vma gp;
-{
- bfd_vma relocation;
- unsigned long val;
-
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
-
- /* Set val to the offset into the section or symbol. */
- val += reloc_entry->addend;
-
- /* Adjust val for the final section location and GP value. If we
- are producing relocateable output, we don't want to do this for
- an external symbol. */
- if (! relocateable
- || (symbol->flags & BSF_SECTION_SYM) != 0)
- val += relocation - gp;
-
- bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
-
- if (relocateable)
- reloc_entry->address += input_section->output_offset;
-
- return bfd_reloc_ok;
-}
-
-/* A mapping from BFD reloc types to MIPS ELF reloc types. */
-
-struct elf_reloc_map {
- bfd_reloc_code_real_type bfd_reloc_val;
- enum reloc_type elf_reloc_val;
-};
-
-static CONST struct elf_reloc_map mips_reloc_map[] =
-{
- { BFD_RELOC_NONE, R_MIPS_NONE, },
- { BFD_RELOC_16, R_MIPS_16 },
- { BFD_RELOC_32, R_MIPS_32 },
- { BFD_RELOC_CTOR, R_MIPS_32 },
- { BFD_RELOC_32_PCREL, R_MIPS_REL32 },
- { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
- { BFD_RELOC_HI16_S, R_MIPS_HI16 },
- { BFD_RELOC_LO16, R_MIPS_LO16 },
- { BFD_RELOC_MIPS_GPREL, R_MIPS_GPREL16 },
- { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
- { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
- { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
- { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
- { BFD_RELOC_MIPS_GPREL32, R_MIPS_GPREL32 },
- { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
- { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
- { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
- { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 }
-};
-
-/* Given a BFD reloc type, return a howto structure. */
-
-static reloc_howto_type *
-bfd_elf32_bfd_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- unsigned int i;
-
- for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map); i++)
- {
- if (mips_reloc_map[i].bfd_reloc_val == code)
- return &elf_mips_howto_table[(int) mips_reloc_map[i].elf_reloc_val];
- }
- return NULL;
-}
-
-/* Given a MIPS reloc type, fill in an arelent structure. */
-
-static void
-mips_info_to_howto_rel (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf32_Internal_Rel *dst;
-{
- unsigned int r_type;
-
- r_type = ELF32_R_TYPE (dst->r_info);
- BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
- cache_ptr->howto = &elf_mips_howto_table[r_type];
-
- /* The addend for a GPREL16 or LITERAL relocation comes from the GP
- value for the object file. We get the addend now, rather than
- when we do the relocation, because the symbol manipulations done
- by the linker may cause us to lose track of the input BFD. */
- if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
- && (r_type == (unsigned int) R_MIPS_GPREL16
- || r_type == (unsigned int) R_MIPS_LITERAL))
- cache_ptr->addend = elf_gp (abfd);
-}
-
-/* A .reginfo section holds a single Elf32_RegInfo structure. These
- routines swap this structure in and out. They are used outside of
- BFD, so they are globally visible. */
-
-void
-bfd_mips_elf32_swap_reginfo_in (abfd, ex, in)
- bfd *abfd;
- const Elf32_External_RegInfo *ex;
- Elf32_RegInfo *in;
-{
- in->ri_gprmask = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gprmask);
- in->ri_cprmask[0] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[0]);
- in->ri_cprmask[1] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[1]);
- in->ri_cprmask[2] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[2]);
- in->ri_cprmask[3] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[3]);
- in->ri_gp_value = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gp_value);
-}
-
-void
-bfd_mips_elf32_swap_reginfo_out (abfd, in, ex)
- bfd *abfd;
- const Elf32_RegInfo *in;
- Elf32_External_RegInfo *ex;
-{
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_gprmask,
- (bfd_byte *) ex->ri_gprmask);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[0],
- (bfd_byte *) ex->ri_cprmask[0]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[1],
- (bfd_byte *) ex->ri_cprmask[1]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[2],
- (bfd_byte *) ex->ri_cprmask[2]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[3],
- (bfd_byte *) ex->ri_cprmask[3]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_gp_value,
- (bfd_byte *) ex->ri_gp_value);
-}
-
-/* Swap an entry in a .gptab section. Note that these routines rely
- on the equivalence of the two elements of the union. */
-
-static void
-bfd_mips_elf32_swap_gptab_in (abfd, ex, in)
- bfd *abfd;
- const Elf32_External_gptab *ex;
- Elf32_gptab *in;
-{
- in->gt_entry.gt_g_value = bfd_h_get_32 (abfd, ex->gt_entry.gt_g_value);
- in->gt_entry.gt_bytes = bfd_h_get_32 (abfd, ex->gt_entry.gt_bytes);
-}
-
-static void
-bfd_mips_elf32_swap_gptab_out (abfd, in, ex)
- bfd *abfd;
- const Elf32_gptab *in;
- Elf32_External_gptab *ex;
-{
- bfd_h_put_32 (abfd, (bfd_vma) in->gt_entry.gt_g_value,
- ex->gt_entry.gt_g_value);
- bfd_h_put_32 (abfd, (bfd_vma) in->gt_entry.gt_bytes,
- ex->gt_entry.gt_bytes);
-}
-
-static void
-bfd_elf32_swap_compact_rel_out (abfd, in, ex)
- bfd *abfd;
- const Elf32_compact_rel *in;
- Elf32_External_compact_rel *ex;
-{
- bfd_h_put_32 (abfd, (bfd_vma) in->id1, ex->id1);
- bfd_h_put_32 (abfd, (bfd_vma) in->num, ex->num);
- bfd_h_put_32 (abfd, (bfd_vma) in->id2, ex->id2);
- bfd_h_put_32 (abfd, (bfd_vma) in->offset, ex->offset);
- bfd_h_put_32 (abfd, (bfd_vma) in->reserved0, ex->reserved0);
- bfd_h_put_32 (abfd, (bfd_vma) in->reserved1, ex->reserved1);
-}
-
-static void
-bfd_elf32_swap_crinfo_out (abfd, in, ex)
- bfd *abfd;
- const Elf32_crinfo *in;
- Elf32_External_crinfo *ex;
-{
- unsigned long l;
-
- l = (((in->ctype & CRINFO_CTYPE) << CRINFO_CTYPE_SH)
- | ((in->rtype & CRINFO_RTYPE) << CRINFO_RTYPE_SH)
- | ((in->dist2to & CRINFO_DIST2TO) << CRINFO_DIST2TO_SH)
- | ((in->relvaddr & CRINFO_RELVADDR) << CRINFO_RELVADDR_SH));
- bfd_h_put_32 (abfd, (bfd_vma) l, ex->info);
- bfd_h_put_32 (abfd, (bfd_vma) in->konst, ex->konst);
- bfd_h_put_32 (abfd, (bfd_vma) in->vaddr, ex->vaddr);
-}
-
-/* Determine whether a symbol is global for the purposes of splitting
- the symbol table into global symbols and local symbols. At least
- on Irix 5, this split must be between section symbols and all other
- symbols. On most ELF targets the split is between static symbols
- and externally visible symbols. */
-
-/*ARGSUSED*/
-static boolean
-mips_elf_sym_is_global (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- return (sym->flags & BSF_SECTION_SYM) == 0 ? true : false;
-}
-
-/* Set the right machine number for a MIPS ELF file. */
-
-static boolean
-mips_elf_object_p (abfd)
- bfd *abfd;
-{
- switch (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH)
- {
- default:
- case E_MIPS_ARCH_1:
- /* Just use the default, which was set in elfcode.h. */
- break;
-
- case E_MIPS_ARCH_2:
- (void) bfd_default_set_arch_mach (abfd, bfd_arch_mips, 6000);
- break;
-
- case E_MIPS_ARCH_3:
- (void) bfd_default_set_arch_mach (abfd, bfd_arch_mips, 4000);
- break;
- }
-
- /* Irix 5 is broken. Object file symbol tables are not always
- sorted correctly such that local symbols precede global symbols,
- and the sh_info field in the symbol table is not always right. */
- elf_bad_symtab (abfd) = true;
-
- return true;
-}
-
-/* The final processing done just before writing out a MIPS ELF object
- file. This gets the MIPS architecture right based on the machine
- number. */
-
-/*ARGSUSED*/
-static void
-mips_elf_final_write_processing (abfd, linker)
- bfd *abfd;
- boolean linker;
-{
- unsigned long val;
- unsigned int i;
- Elf_Internal_Shdr **hdrpp;
-
- switch (bfd_get_mach (abfd))
- {
- case 3000:
- val = E_MIPS_ARCH_1;
- break;
-
- case 6000:
- val = E_MIPS_ARCH_2;
- break;
-
- case 4000:
- val = E_MIPS_ARCH_3;
- break;
-
- default:
- val = 0;
- break;
- }
-
- elf_elfheader (abfd)->e_flags &=~ EF_MIPS_ARCH;
- elf_elfheader (abfd)->e_flags |= val;
-
- /* Set the sh_info field for .gptab sections. */
- for (i = 1, hdrpp = elf_elfsections (abfd) + 1;
- i < elf_elfheader (abfd)->e_shnum;
- i++, hdrpp++)
- {
- if ((*hdrpp)->sh_type == SHT_MIPS_GPTAB)
- {
- const char *name;
- asection *sec;
-
- BFD_ASSERT ((*hdrpp)->bfd_section != NULL);
- name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section);
- BFD_ASSERT (name != NULL
- && strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0);
- sec = bfd_get_section_by_name (abfd, name + sizeof ".gptab" - 1);
- BFD_ASSERT (sec != NULL);
- (*hdrpp)->sh_info = elf_section_data (sec)->this_idx;
- }
- }
-}
-
-/* Function to keep MIPS specific file flags like as EF_MIPS_PIC. */
-
-static boolean
-mips_elf_set_private_flags (abfd, flags)
- bfd *abfd;
- flagword flags;
-{
- BFD_ASSERT (!elf_flags_init (abfd)
- || elf_elfheader (abfd)->e_flags == flags);
-
- elf_elfheader (abfd)->e_flags = flags;
- elf_flags_init (abfd) = true;
- return true;
-}
-
-/* Copy backend specific data from one object module to another */
-
-static boolean
-mips_elf_copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- /* This function is selected based on the input vector. We only
- want to copy information over if the output BFD also uses Elf
- format. */
- if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return true;
-
- BFD_ASSERT (!elf_flags_init (obfd)
- || (elf_elfheader (obfd)->e_flags
- == elf_elfheader (ibfd)->e_flags));
-
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = true;
- return true;
-}
-
-/* Merge backend specific data from an object file to the output
- object file when linking. */
-
-static boolean
-mips_elf_merge_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- flagword old_flags;
- flagword new_flags;
-
- /* Check if we have the same endianess */
- if (ibfd->xvec->byteorder != obfd->xvec->byteorder
- && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
- {
- (*_bfd_error_handler)
- ("%s: compiled for a %s endian system and target is %s endian",
- bfd_get_filename (ibfd),
- bfd_big_endian (ibfd) ? "big" : "little",
- bfd_big_endian (obfd) ? "big" : "little");
-
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- /* This function is selected based on the input vector. We only
- want to copy information over if the output BFD also uses Elf
- format. */
- if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return true;
-
- new_flags = elf_elfheader (ibfd)->e_flags;
- elf_elfheader (obfd)->e_flags |= new_flags & EF_MIPS_NOREORDER;
- old_flags = elf_elfheader (obfd)->e_flags;
-
- if (!elf_flags_init (obfd)) /* First call, no flags set */
- {
- elf_flags_init (obfd) = true;
- elf_elfheader (obfd)->e_flags = new_flags;
- }
- else if (((new_flags ^ old_flags) & ~EF_MIPS_NOREORDER)
- == 0) /* Compatible flags are ok */
- ;
- else /* Incompatible flags */
- {
- /* Warn about -fPIC mismatch */
- if ((new_flags & EF_MIPS_PIC) != (old_flags & EF_MIPS_PIC))
- {
- new_flags &= ~EF_MIPS_PIC;
- (*_bfd_error_handler)
- ("%s: needs all files compiled with -fPIC",
- bfd_get_filename (ibfd));
- }
-
- if ((new_flags & EF_MIPS_CPIC) != (old_flags & EF_MIPS_CPIC))
- {
- new_flags &= ~EF_MIPS_CPIC;
- (*_bfd_error_handler)
- ("%s: needs all files compiled with -mabicalls",
- bfd_get_filename (ibfd));
- }
-
- /* Warn about any other mismatches */
- if (new_flags != old_flags)
- (*_bfd_error_handler)
- ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
- bfd_get_filename (ibfd), (unsigned long) new_flags,
- (unsigned long) old_flags);
-
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- return true;
-}
-
-/* Handle a MIPS specific section when reading an object file. This
- is called when elfcode.h finds a section with an unknown type.
- FIXME: We need to handle the SHF_MIPS_GPREL flag, but I'm not sure
- how to. */
-
-static boolean
-mips_elf_section_from_shdr (abfd, hdr, name)
- bfd *abfd;
- Elf32_Internal_Shdr *hdr;
- char *name;
-{
- asection *newsect;
-
- /* There ought to be a place to keep ELF backend specific flags, but
- at the moment there isn't one. We just keep track of the
- sections by their name, instead. Fortunately, the ABI gives
- suggested names for all the MIPS specific sections, so we will
- probably get away with this. */
- switch (hdr->sh_type)
- {
- case SHT_MIPS_LIBLIST:
- if (strcmp (name, ".liblist") != 0)
- return false;
- break;
- case SHT_MIPS_MSYM:
- if (strcmp (name, ".msym") != 0)
- return false;
- break;
- case SHT_MIPS_CONFLICT:
- if (strcmp (name, ".conflict") != 0)
- return false;
- break;
- case SHT_MIPS_GPTAB:
- if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) != 0)
- return false;
- break;
- case SHT_MIPS_UCODE:
- if (strcmp (name, ".ucode") != 0)
- return false;
- break;
- case SHT_MIPS_DEBUG:
- if (strcmp (name, ".mdebug") != 0)
- return false;
- break;
- case SHT_MIPS_REGINFO:
- if (strcmp (name, ".reginfo") != 0
- || hdr->sh_size != sizeof (Elf32_External_RegInfo))
- return false;
- break;
- case SHT_MIPS_OPTIONS:
- if (strcmp (name, ".options") != 0)
- return false;
- break;
- case SHT_MIPS_DWARF:
- if (strncmp (name, ".debug_", sizeof ".debug_" - 1) != 0)
- return false;
- break;
- case SHT_MIPS_EVENTS:
- if (strncmp (name, ".MIPS.events.", sizeof ".MIPS.events." - 1) != 0)
- return false;
- break;
- default:
- return false;
- }
-
- if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
- return false;
- newsect = hdr->bfd_section;
-
- if (hdr->sh_type == SHT_MIPS_DEBUG)
- {
- if (! bfd_set_section_flags (abfd, newsect,
- (bfd_get_section_flags (abfd, newsect)
- | SEC_DEBUGGING)))
- return false;
- }
-
- /* FIXME: We should record sh_info for a .gptab section. */
-
- /* For a .reginfo section, set the gp value in the tdata information
- from the contents of this section. We need the gp value while
- processing relocs, so we just get it now. */
- if (hdr->sh_type == SHT_MIPS_REGINFO)
- {
- Elf32_External_RegInfo ext;
- Elf32_RegInfo s;
-
- if (! bfd_get_section_contents (abfd, newsect, (PTR) &ext,
- (file_ptr) 0, sizeof ext))
- return false;
- bfd_mips_elf32_swap_reginfo_in (abfd, &ext, &s);
- elf_gp (abfd) = s.ri_gp_value;
- }
-
- return true;
-}
-
-/* Set the correct type for a MIPS ELF section. We do this by the
- section name, which is a hack, but ought to work. */
-
-static boolean
-mips_elf_fake_sections (abfd, hdr, sec)
- bfd *abfd;
- Elf32_Internal_Shdr *hdr;
- asection *sec;
-{
- register const char *name;
-
- name = bfd_get_section_name (abfd, sec);
-
- if (strcmp (name, ".liblist") == 0)
- {
- hdr->sh_type = SHT_MIPS_LIBLIST;
- hdr->sh_info = sec->_raw_size / sizeof (Elf32_Lib);
- /* FIXME: Set the sh_link field. */
- }
- else if (strcmp (name, ".msym") == 0)
- {
- hdr->sh_type = SHT_MIPS_MSYM;
- hdr->sh_entsize = 8;
- /* FIXME: Set the sh_info field. */
- }
- else if (strcmp (name, ".conflict") == 0)
- hdr->sh_type = SHT_MIPS_CONFLICT;
- else if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0)
- {
- hdr->sh_type = SHT_MIPS_GPTAB;
- hdr->sh_entsize = sizeof (Elf32_External_gptab);
- /* The sh_info field is set in mips_elf_final_write_processing. */
- }
- else if (strcmp (name, ".ucode") == 0)
- hdr->sh_type = SHT_MIPS_UCODE;
- else if (strcmp (name, ".mdebug") == 0)
- {
- hdr->sh_type = SHT_MIPS_DEBUG;
- /* In a shared object on Irix 5.3, the .mdebug section has an
- entsize of 0. FIXME: Does this matter? */
- if (SGI_COMPAT (abfd) && (abfd->flags & DYNAMIC) != 0)
- hdr->sh_entsize = 0;
- else
- hdr->sh_entsize = 1;
- }
- else if (strcmp (name, ".reginfo") == 0)
- {
- hdr->sh_type = SHT_MIPS_REGINFO;
- /* In a shared object on Irix 5.3, the .reginfo section has an
- entsize of 0x18. FIXME: Does this matter? */
- if (SGI_COMPAT (abfd) && (abfd->flags & DYNAMIC) != 0)
- hdr->sh_entsize = sizeof (Elf32_External_RegInfo);
- else
- hdr->sh_entsize = 1;
-
- /* Force the section size to the correct value, even if the
- linker thinks it is larger. The link routine below will only
- write out this much data for .reginfo. */
- hdr->sh_size = sec->_raw_size = sizeof (Elf32_External_RegInfo);
- }
- else if (SGI_COMPAT (abfd)
- && (strcmp (name, ".hash") == 0
- || strcmp (name, ".dynamic") == 0
- || strcmp (name, ".dynstr") == 0))
- {
- hdr->sh_entsize = 0;
- hdr->sh_info = SIZEOF_MIPS_DYNSYM_SECNAMES;
- }
- else if (strcmp (name, ".got") == 0
- || strcmp (name, ".sdata") == 0
- || strcmp (name, ".sbss") == 0
- || strcmp (name, ".lit4") == 0
- || strcmp (name, ".lit8") == 0)
- hdr->sh_flags |= SHF_MIPS_GPREL;
- else if (strcmp (name, ".options") == 0)
- {
- hdr->sh_type = SHT_MIPS_OPTIONS;
- hdr->sh_entsize = 1;
- }
- else if (strncmp (name, ".debug_", sizeof ".debug_" - 1) == 0)
- hdr->sh_type = SHT_MIPS_DWARF;
- else if (strncmp (name, ".MIPS.events.", sizeof ".MIPS.events." - 1) == 0)
- hdr->sh_type = SHT_MIPS_EVENTS;
-
- return true;
-}
-
-/* Given a BFD section, try to locate the corresponding ELF section
- index. */
-
-static boolean
-mips_elf_section_from_bfd_section (abfd, hdr, sec, retval)
- bfd *abfd;
- Elf32_Internal_Shdr *hdr;
- asection *sec;
- int *retval;
-{
- if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
- {
- *retval = SHN_MIPS_SCOMMON;
- return true;
- }
- if (strcmp (bfd_get_section_name (abfd, sec), ".acommon") == 0)
- {
- *retval = SHN_MIPS_ACOMMON;
- return true;
- }
- return false;
-}
-
-/* Work over a section just before writing it out. We update the GP
- value in the .reginfo section based on the value we are using.
- FIXME: We recognize sections that need the SHF_MIPS_GPREL flag by
- name; there has to be a better way. */
-
-static boolean
-mips_elf_section_processing (abfd, hdr)
- bfd *abfd;
- Elf32_Internal_Shdr *hdr;
-{
- if (hdr->sh_type == SHT_MIPS_REGINFO)
- {
- bfd_byte buf[4];
-
- BFD_ASSERT (hdr->sh_size == sizeof (Elf32_External_RegInfo));
- BFD_ASSERT (hdr->contents == NULL);
-
- if (bfd_seek (abfd,
- hdr->sh_offset + sizeof (Elf32_External_RegInfo) - 4,
- SEEK_SET) == -1)
- return false;
- bfd_h_put_32 (abfd, (bfd_vma) elf_gp (abfd), buf);
- if (bfd_write (buf, (bfd_size_type) 1, (bfd_size_type) 4, abfd) != 4)
- return false;
- }
-
- if (hdr->bfd_section != NULL)
- {
- const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
-
- if (strcmp (name, ".sdata") == 0)
- {
- hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
- hdr->sh_type = SHT_PROGBITS;
- }
- else if (strcmp (name, ".sbss") == 0)
- {
- hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
- hdr->sh_type = SHT_NOBITS;
- }
- else if (strcmp (name, ".lit8") == 0
- || strcmp (name, ".lit4") == 0)
- {
- hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
- hdr->sh_type = SHT_PROGBITS;
- }
- else if (strcmp (name, ".compact_rel") == 0)
- {
- hdr->sh_flags = 0;
- hdr->sh_type = SHT_PROGBITS;
- }
- else if (strcmp (name, ".rtproc") == 0)
- {
- if (hdr->sh_addralign != 0 && hdr->sh_entsize == 0)
- {
- unsigned int adjust;
-
- adjust = hdr->sh_size % hdr->sh_addralign;
- if (adjust != 0)
- hdr->sh_size += hdr->sh_addralign - adjust;
- }
- }
- }
-
- return true;
-}
-
-/* MIPS ELF uses two common sections. One is the usual one, and the
- other is for small objects. All the small objects are kept
- together, and then referenced via the gp pointer, which yields
- faster assembler code. This is what we use for the small common
- section. This approach is copied from ecoff.c. */
-static asection mips_elf_scom_section;
-static asymbol mips_elf_scom_symbol;
-static asymbol *mips_elf_scom_symbol_ptr;
-
-/* MIPS ELF also uses an acommon section, which represents an
- allocated common symbol which may be overridden by a
- definition in a shared library. */
-static asection mips_elf_acom_section;
-static asymbol mips_elf_acom_symbol;
-static asymbol *mips_elf_acom_symbol_ptr;
-
-/* The Irix 5 support uses two virtual sections, which represent
- text/data symbols defined in dynamic objects. */
-static asection mips_elf_text_section;
-static asection *mips_elf_text_section_ptr;
-static asymbol mips_elf_text_symbol;
-static asymbol *mips_elf_text_symbol_ptr;
-
-static asection mips_elf_data_section;
-static asection *mips_elf_data_section_ptr;
-static asymbol mips_elf_data_symbol;
-static asymbol *mips_elf_data_symbol_ptr;
-
-/* Handle the special MIPS section numbers that a symbol may use. */
-
-static void
-mips_elf_symbol_processing (abfd, asym)
- bfd *abfd;
- asymbol *asym;
-{
- elf_symbol_type *elfsym;
-
- elfsym = (elf_symbol_type *) asym;
- switch (elfsym->internal_elf_sym.st_shndx)
- {
- case SHN_MIPS_ACOMMON:
- /* This section is used in a dynamically linked executable file.
- It is an allocated common section. The dynamic linker can
- either resolve these symbols to something in a shared
- library, or it can just leave them here. For our purposes,
- we can consider these symbols to be in a new section. */
- if (mips_elf_acom_section.name == NULL)
- {
- /* Initialize the acommon section. */
- mips_elf_acom_section.name = ".acommon";
- mips_elf_acom_section.flags = SEC_ALLOC;
- mips_elf_acom_section.output_section = &mips_elf_acom_section;
- mips_elf_acom_section.symbol = &mips_elf_acom_symbol;
- mips_elf_acom_section.symbol_ptr_ptr = &mips_elf_acom_symbol_ptr;
- mips_elf_acom_symbol.name = ".acommon";
- mips_elf_acom_symbol.flags = BSF_SECTION_SYM;
- mips_elf_acom_symbol.section = &mips_elf_acom_section;
- mips_elf_acom_symbol_ptr = &mips_elf_acom_symbol;
- }
- asym->section = &mips_elf_acom_section;
- break;
-
- case SHN_COMMON:
- /* Common symbols less than the GP size are automatically
- treated as SHN_MIPS_SCOMMON symbols. */
- if (asym->value > elf_gp_size (abfd))
- break;
- /* Fall through. */
- case SHN_MIPS_SCOMMON:
- if (mips_elf_scom_section.name == NULL)
- {
- /* Initialize the small common section. */
- mips_elf_scom_section.name = ".scommon";
- mips_elf_scom_section.flags = SEC_IS_COMMON;
- mips_elf_scom_section.output_section = &mips_elf_scom_section;
- mips_elf_scom_section.symbol = &mips_elf_scom_symbol;
- mips_elf_scom_section.symbol_ptr_ptr = &mips_elf_scom_symbol_ptr;
- mips_elf_scom_symbol.name = ".scommon";
- mips_elf_scom_symbol.flags = BSF_SECTION_SYM;
- mips_elf_scom_symbol.section = &mips_elf_scom_section;
- mips_elf_scom_symbol_ptr = &mips_elf_scom_symbol;
- }
- asym->section = &mips_elf_scom_section;
- asym->value = elfsym->internal_elf_sym.st_size;
- break;
-
- case SHN_MIPS_SUNDEFINED:
- asym->section = bfd_und_section_ptr;
- break;
-
-#if 0 /* for SGI_COMPAT */
- case SHN_MIPS_TEXT:
- asym->section = mips_elf_text_section_ptr;
- break;
-
- case SHN_MIPS_DATA:
- asym->section = mips_elf_data_section_ptr;
- break;
-#endif
- }
-}
-
-/* When creating an Irix 5 executable, we need REGINFO and RTPROC
- segments. */
-
-static int
-mips_elf_additional_program_headers (abfd)
- bfd *abfd;
-{
- asection *s;
- int ret;
-
- ret = 0;
-
- if (! SGI_COMPAT (abfd))
- return ret;
-
- s = bfd_get_section_by_name (abfd, ".reginfo");
- if (s != NULL && (s->flags & SEC_LOAD) != 0)
- {
- /* We need a PT_MIPS_REGINFO segment. */
- ++ret;
- }
-
- if (bfd_get_section_by_name (abfd, ".dynamic") != NULL
- && bfd_get_section_by_name (abfd, ".mdebug") != NULL)
- {
- /* We need a PT_MIPS_RTPROC segment. */
- ++ret;
- }
-
- return ret;
-}
-
-/* Modify the segment map for an Irix 5 executable. */
-
-static boolean
-mips_elf_modify_segment_map (abfd)
- bfd *abfd;
-{
- asection *s;
- struct elf_segment_map *m, **pm;
-
- if (! SGI_COMPAT (abfd))
- return true;
-
- /* If there is a .reginfo section, we need a PT_MIPS_REGINFO
- segment. */
- s = bfd_get_section_by_name (abfd, ".reginfo");
- if (s != NULL && (s->flags & SEC_LOAD) != 0)
- {
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
- if (m->p_type == PT_MIPS_REGINFO)
- break;
- if (m == NULL)
- {
- m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
- if (m == NULL)
- return false;
-
- m->p_type = PT_MIPS_REGINFO;
- m->count = 1;
- m->sections[0] = s;
-
- /* We want to put it after the PHDR and INTERP segments. */
- pm = &elf_tdata (abfd)->segment_map;
- while (*pm != NULL
- && ((*pm)->p_type == PT_PHDR
- || (*pm)->p_type == PT_INTERP))
- pm = &(*pm)->next;
-
- m->next = *pm;
- *pm = m;
- }
- }
-
- /* If there are .dynamic and .mdebug sections, we make a room for
- the RTPROC header. FIXME: Rewrite without section names. */
- if (bfd_get_section_by_name (abfd, ".interp") == NULL
- && bfd_get_section_by_name (abfd, ".dynamic") != NULL
- && bfd_get_section_by_name (abfd, ".mdebug") != NULL)
- {
- for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
- if (m->p_type == PT_MIPS_RTPROC)
- break;
- if (m == NULL)
- {
- m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
- if (m == NULL)
- return false;
-
- m->p_type = PT_MIPS_RTPROC;
-
- s = bfd_get_section_by_name (abfd, ".rtproc");
- if (s == NULL)
- {
- m->count = 0;
- m->p_flags = 0;
- m->p_flags_valid = 1;
- }
- else
- {
- m->count = 1;
- m->sections[0] = s;
- }
-
- /* We want to put it after the DYNAMIC segment. */
- pm = &elf_tdata (abfd)->segment_map;
- while (*pm != NULL && (*pm)->p_type != PT_DYNAMIC)
- pm = &(*pm)->next;
- if (*pm != NULL)
- pm = &(*pm)->next;
-
- m->next = *pm;
- *pm = m;
- }
- }
-
- /* On Irix 5, the PT_DYNAMIC segment includes the .dynamic, .dynstr,
- .dynsym, and .hash sections, and everything in between. */
- for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
- if ((*pm)->p_type == PT_DYNAMIC)
- break;
- m = *pm;
- if (m != NULL
- && m->count == 1
- && strcmp (m->sections[0]->name, ".dynamic") == 0)
- {
- static const char *sec_names[] =
- { ".dynamic", ".dynstr", ".dynsym", ".hash" };
- bfd_vma low, high;
- unsigned int i, c;
- struct elf_segment_map *n;
-
- low = 0xffffffff;
- high = 0;
- for (i = 0; i < sizeof sec_names / sizeof sec_names[0]; i++)
- {
- s = bfd_get_section_by_name (abfd, sec_names[i]);
- if (s != NULL && (s->flags & SEC_LOAD) != 0)
- {
- bfd_size_type sz;
-
- if (low > s->vma)
- low = s->vma;
- sz = s->_cooked_size;
- if (sz == 0)
- sz = s->_raw_size;
- if (high < s->vma + sz)
- high = s->vma + sz;
- }
- }
-
- c = 0;
- for (s = abfd->sections; s != NULL; s = s->next)
- if ((s->flags & SEC_LOAD) != 0
- && s->vma >= low
- && ((s->vma
- + (s->_cooked_size != 0 ? s->_cooked_size : s->_raw_size))
- <= high))
- ++c;
-
- n = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof *n + (c - 1) * sizeof (asection *)));
- if (n == NULL)
- return false;
- *n = *m;
- n->count = c;
-
- i = 0;
- for (s = abfd->sections; s != NULL; s = s->next)
- {
- if ((s->flags & SEC_LOAD) != 0
- && s->vma >= low
- && ((s->vma
- + (s->_cooked_size != 0 ? s->_cooked_size : s->_raw_size))
- <= high))
- {
- n->sections[i] = s;
- ++i;
- }
- }
-
- *pm = n;
- }
-
- return true;
-}
-
-/* The structure of the runtime procedure descriptor created by the
- loader for use by the static exception system. */
-
-typedef struct runtime_pdr {
- bfd_vma adr; /* memory address of start of procedure */
- long regmask; /* save register mask */
- long regoffset; /* save register offset */
- long fregmask; /* save floating point register mask */
- long fregoffset; /* save floating point register offset */
- long frameoffset; /* frame size */
- short framereg; /* frame pointer register */
- short pcreg; /* offset or reg of return pc */
- long irpss; /* index into the runtime string table */
- long reserved;
- struct exception_info *exception_info;/* pointer to exception array */
-} RPDR, *pRPDR;
-#define cbRPDR sizeof(RPDR)
-#define rpdNil ((pRPDR) 0)
-
-/* Swap RPDR (runtime procedure table entry) for output. */
-
-static void ecoff_swap_rpdr_out
- PARAMS ((bfd *, const RPDR *, struct rpdr_ext *));
-
-static void
-ecoff_swap_rpdr_out (abfd, in, ex)
- bfd *abfd;
- const RPDR *in;
- struct rpdr_ext *ex;
-{
- /* ecoff_put_off was defined in ecoffswap.h. */
- ecoff_put_off (abfd, in->adr, (bfd_byte *) ex->p_adr);
- bfd_h_put_32 (abfd, in->regmask, (bfd_byte *) ex->p_regmask);
- bfd_h_put_32 (abfd, in->regoffset, (bfd_byte *) ex->p_regoffset);
- bfd_h_put_32 (abfd, in->fregmask, (bfd_byte *) ex->p_fregmask);
- bfd_h_put_32 (abfd, in->fregoffset, (bfd_byte *) ex->p_fregoffset);
- bfd_h_put_32 (abfd, in->frameoffset, (bfd_byte *) ex->p_frameoffset);
-
- bfd_h_put_16 (abfd, in->framereg, (bfd_byte *) ex->p_framereg);
- bfd_h_put_16 (abfd, in->pcreg, (bfd_byte *) ex->p_pcreg);
-
- bfd_h_put_32 (abfd, in->irpss, (bfd_byte *) ex->p_irpss);
-#if 0 /* FIXME */
- ecoff_put_off (abfd, in->exception_info, (bfd_byte *) ex->p_exception_info);
-#endif
-}
-
-/* Read ECOFF debugging information from a .mdebug section into a
- ecoff_debug_info structure. */
-
-static boolean
-mips_elf_read_ecoff_info (abfd, section, debug)
- bfd *abfd;
- asection *section;
- struct ecoff_debug_info *debug;
-{
- HDRR *symhdr;
- const struct ecoff_debug_swap *swap;
- char *ext_hdr = NULL;
-
- swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
-
- ext_hdr = (char *) bfd_malloc ((size_t) swap->external_hdr_size);
- if (ext_hdr == NULL && swap->external_hdr_size != 0)
- goto error_return;
-
- if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0,
- swap->external_hdr_size)
- == false)
- goto error_return;
-
- symhdr = &debug->symbolic_header;
- (*swap->swap_hdr_in) (abfd, ext_hdr, symhdr);
-
- /* The symbolic header contains absolute file offsets and sizes to
- read. */
-#define READ(ptr, offset, count, size, type) \
- if (symhdr->count == 0) \
- debug->ptr = NULL; \
- else \
- { \
- debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
- if (debug->ptr == NULL) \
- goto error_return; \
- if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \
- || (bfd_read (debug->ptr, size, symhdr->count, \
- abfd) != size * symhdr->count)) \
- goto error_return; \
- }
-
- READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
- READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
- READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
- READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
- READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
- READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
- union aux_ext *);
- READ (ss, cbSsOffset, issMax, sizeof (char), char *);
- READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
- READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
- READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
- READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
-#undef READ
-
- debug->fdr = NULL;
- debug->adjust = NULL;
-
- return true;
-
- error_return:
- if (ext_hdr != NULL)
- free (ext_hdr);
- if (debug->line != NULL)
- free (debug->line);
- if (debug->external_dnr != NULL)
- free (debug->external_dnr);
- if (debug->external_pdr != NULL)
- free (debug->external_pdr);
- if (debug->external_sym != NULL)
- free (debug->external_sym);
- if (debug->external_opt != NULL)
- free (debug->external_opt);
- if (debug->external_aux != NULL)
- free (debug->external_aux);
- if (debug->ss != NULL)
- free (debug->ss);
- if (debug->ssext != NULL)
- free (debug->ssext);
- if (debug->external_fdr != NULL)
- free (debug->external_fdr);
- if (debug->external_rfd != NULL)
- free (debug->external_rfd);
- if (debug->external_ext != NULL)
- free (debug->external_ext);
- return false;
-}
-
-/* MIPS ELF local labels start with '$', not 'L'. */
-
-/*ARGSUSED*/
-static boolean
-mips_elf_is_local_label (abfd, symbol)
- bfd *abfd;
- asymbol *symbol;
-{
- return symbol->name[0] == '$';
-}
-
-/* MIPS ELF uses a special find_nearest_line routine in order the
- handle the ECOFF debugging information. */
-
-struct mips_elf_find_line
-{
- struct ecoff_debug_info d;
- struct ecoff_find_line i;
-};
-
-static boolean
-mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
- functionname_ptr, line_ptr)
- bfd *abfd;
- asection *section;
- asymbol **symbols;
- bfd_vma offset;
- const char **filename_ptr;
- const char **functionname_ptr;
- unsigned int *line_ptr;
-{
- asection *msec;
-
- msec = bfd_get_section_by_name (abfd, ".mdebug");
- if (msec != NULL)
- {
- flagword origflags;
- struct mips_elf_find_line *fi;
- const struct ecoff_debug_swap * const swap =
- get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
-
- /* If we are called during a link, mips_elf_final_link may have
- cleared the SEC_HAS_CONTENTS field. We force it back on here
- if appropriate (which it normally will be). */
- origflags = msec->flags;
- if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
- msec->flags |= SEC_HAS_CONTENTS;
-
- fi = elf_tdata (abfd)->find_line_info;
- if (fi == NULL)
- {
- bfd_size_type external_fdr_size;
- char *fraw_src;
- char *fraw_end;
- struct fdr *fdr_ptr;
-
- fi = ((struct mips_elf_find_line *)
- bfd_alloc (abfd, sizeof (struct mips_elf_find_line)));
- if (fi == NULL)
- {
- msec->flags = origflags;
- return false;
- }
-
- memset (fi, 0, sizeof (struct mips_elf_find_line));
-
- if (! mips_elf_read_ecoff_info (abfd, msec, &fi->d))
- {
- msec->flags = origflags;
- return false;
- }
-
- /* Swap in the FDR information. */
- fi->d.fdr = ((struct fdr *)
- bfd_alloc (abfd,
- (fi->d.symbolic_header.ifdMax *
- sizeof (struct fdr))));
- if (fi->d.fdr == NULL)
- {
- msec->flags = origflags;
- return false;
- }
- external_fdr_size = swap->external_fdr_size;
- fdr_ptr = fi->d.fdr;
- fraw_src = (char *) fi->d.external_fdr;
- fraw_end = (fraw_src
- + fi->d.symbolic_header.ifdMax * external_fdr_size);
- for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
- (*swap->swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
-
- elf_tdata (abfd)->find_line_info = fi;
-
- /* Note that we don't bother to ever free this information.
- find_nearest_line is either called all the time, as in
- objdump -l, so the information should be saved, or it is
- rarely called, as in ld error messages, so the memory
- wasted is unimportant. Still, it would probably be a
- good idea for free_cached_info to throw it away. */
- }
-
- if (_bfd_ecoff_locate_line (abfd, section, offset, &fi->d, swap,
- &fi->i, filename_ptr, functionname_ptr,
- line_ptr))
- {
- msec->flags = origflags;
- return true;
- }
-
- msec->flags = origflags;
- }
-
- /* Fall back on the generic ELF find_nearest_line routine. */
-
- return _bfd_elf_find_nearest_line (abfd, section, symbols, offset,
- filename_ptr, functionname_ptr,
- line_ptr);
-}
-
-/* The MIPS ELF linker needs additional information for each symbol in
- the global hash table. */
-
-struct mips_elf_link_hash_entry
-{
- struct elf_link_hash_entry root;
-
- /* External symbol information. */
- EXTR esym;
-};
-
-/* MIPS ELF linker hash table. */
-
-struct mips_elf_link_hash_table
-{
- struct elf_link_hash_table root;
- /* String section indices for the dynamic section symbols. */
- bfd_size_type dynsym_sec_strindex[SIZEOF_MIPS_DYNSYM_SECNAMES];
- /* The number of .rtproc entries. */
- bfd_size_type procedure_count;
- /* The size of the .compact_rel section (if SGI_COMPAT). */
- bfd_size_type compact_rel_size;
-};
-
-/* Look up an entry in a MIPS ELF linker hash table. */
-
-#define mips_elf_link_hash_lookup(table, string, create, copy, follow) \
- ((struct mips_elf_link_hash_entry *) \
- elf_link_hash_lookup (&(table)->root, (string), (create), \
- (copy), (follow)))
-
-/* Traverse a MIPS ELF linker hash table. */
-
-#define mips_elf_link_hash_traverse(table, func, info) \
- (elf_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the MIPS ELF linker hash table from a link_info structure. */
-
-#define mips_elf_hash_table(p) \
- ((struct mips_elf_link_hash_table *) ((p)->hash))
-
-static boolean mips_elf_output_extsym
- PARAMS ((struct mips_elf_link_hash_entry *, PTR));
-
-/* Create an entry in a MIPS ELF linker hash table. */
-
-static struct bfd_hash_entry *
-mips_elf_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct mips_elf_link_hash_entry *ret =
- (struct mips_elf_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct mips_elf_link_hash_entry *) NULL)
- ret = ((struct mips_elf_link_hash_entry *)
- bfd_hash_allocate (table,
- sizeof (struct mips_elf_link_hash_entry)));
- if (ret == (struct mips_elf_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct mips_elf_link_hash_entry *)
- _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != (struct mips_elf_link_hash_entry *) NULL)
- {
- /* Set local fields. */
- memset (&ret->esym, 0, sizeof (EXTR));
- /* We use -2 as a marker to indicate that the information has
- not been set. -1 means there is no associated ifd. */
- ret->esym.ifd = -2;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create a MIPS ELF linker hash table. */
-
-static struct bfd_link_hash_table *
-mips_elf_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct mips_elf_link_hash_table *ret;
- unsigned int i;
-
- ret = ((struct mips_elf_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct mips_elf_link_hash_table)));
- if (ret == (struct mips_elf_link_hash_table *) NULL)
- return NULL;
-
- if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
- mips_elf_link_hash_newfunc))
- {
- bfd_release (abfd, ret);
- return NULL;
- }
-
- for (i = 0; i < SIZEOF_MIPS_DYNSYM_SECNAMES; i++)
- ret->dynsym_sec_strindex[i] = (bfd_size_type) -1;
- ret->procedure_count = 0;
- ret->compact_rel_size = 0;
-
- return &ret->root.root;
-}
-
-/* Hook called by the linker routine which adds symbols from an object
- file. We must handle the special MIPS section numbers here. */
-
-/*ARGSUSED*/
-static boolean
-mips_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
- bfd *abfd;
- struct bfd_link_info *info;
- const Elf_Internal_Sym *sym;
- const char **namep;
- flagword *flagsp;
- asection **secp;
- bfd_vma *valp;
-{
- if (SGI_COMPAT (abfd)
- && (abfd->flags & DYNAMIC) != 0
- && strcmp (*namep, "_rld_new_interface") == 0)
- {
- /* Skip Irix 5 rld entry name. */
- *namep = NULL;
- return true;
- }
-
- switch (sym->st_shndx)
- {
- case SHN_COMMON:
- /* Common symbols less than the GP size are automatically
- treated as SHN_MIPS_SCOMMON symbols. */
- if (sym->st_size > elf_gp_size (abfd))
- break;
- /* Fall through. */
- case SHN_MIPS_SCOMMON:
- *secp = bfd_make_section_old_way (abfd, ".scommon");
- (*secp)->flags |= SEC_IS_COMMON;
- *valp = sym->st_size;
- break;
-
- case SHN_MIPS_TEXT:
- /* This section is used in a shared object. */
- if (mips_elf_text_section_ptr == NULL)
- {
- /* Initialize the section. */
- mips_elf_text_section.name = ".text";
- mips_elf_text_section.flags = SEC_NO_FLAGS;
- mips_elf_text_section.output_section = NULL;
- mips_elf_text_section.owner = abfd;
- mips_elf_text_section.symbol = &mips_elf_text_symbol;
- mips_elf_text_section.symbol_ptr_ptr = &mips_elf_text_symbol_ptr;
- mips_elf_text_symbol.name = ".text";
- mips_elf_text_symbol.flags = BSF_SECTION_SYM;
- mips_elf_text_symbol.section = &mips_elf_text_section;
- mips_elf_text_symbol_ptr = &mips_elf_text_symbol;
- mips_elf_text_section_ptr = &mips_elf_text_section;
- }
- if (info->shared)
- *secp = bfd_und_section_ptr;
- else
- *secp = mips_elf_text_section_ptr;
- break;
-
- case SHN_MIPS_ACOMMON:
- /* Fall through. XXX Can we treat this as allocated data? */
- case SHN_MIPS_DATA:
- /* This section is used in a shared object. */
- if (mips_elf_data_section_ptr == NULL)
- {
- /* Initialize the section. */
- mips_elf_data_section.name = ".data";
- mips_elf_data_section.flags = SEC_NO_FLAGS;
- mips_elf_data_section.output_section = NULL;
- mips_elf_data_section.owner = abfd;
- mips_elf_data_section.symbol = &mips_elf_data_symbol;
- mips_elf_data_section.symbol_ptr_ptr = &mips_elf_data_symbol_ptr;
- mips_elf_data_symbol.name = ".data";
- mips_elf_data_symbol.flags = BSF_SECTION_SYM;
- mips_elf_data_symbol.section = &mips_elf_data_section;
- mips_elf_data_symbol_ptr = &mips_elf_data_symbol;
- mips_elf_data_section_ptr = &mips_elf_data_section;
- }
- if (info->shared)
- *secp = bfd_und_section_ptr;
- else
- *secp = mips_elf_data_section_ptr;
- break;
-
- case SHN_MIPS_SUNDEFINED:
- *secp = bfd_und_section_ptr;
- break;
- }
-
- return true;
-}
-
-/* Structure used to pass information to mips_elf_output_extsym. */
-
-struct extsym_info
-{
- bfd *abfd;
- struct bfd_link_info *info;
- struct ecoff_debug_info *debug;
- const struct ecoff_debug_swap *swap;
- boolean failed;
-};
-
-/* This routine is used to write out ECOFF debugging external symbol
- information. It is called via mips_elf_link_hash_traverse. The
- ECOFF external symbol information must match the ELF external
- symbol information. Unfortunately, at this point we don't know
- whether a symbol is required by reloc information, so the two
- tables may wind up being different. We must sort out the external
- symbol information before we can set the final size of the .mdebug
- section, and we must set the size of the .mdebug section before we
- can relocate any sections, and we can't know which symbols are
- required by relocation until we relocate the sections.
- Fortunately, it is relatively unlikely that any symbol will be
- stripped but required by a reloc. In particular, it can not happen
- when generating a final executable. */
-
-static boolean
-mips_elf_output_extsym (h, data)
- struct mips_elf_link_hash_entry *h;
- PTR data;
-{
- struct extsym_info *einfo = (struct extsym_info *) data;
- boolean strip;
- asection *sec, *output_section;
-
- if (h->root.indx == -2)
- strip = false;
- else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
- && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
- && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
- strip = true;
- else if (einfo->info->strip == strip_all
- || (einfo->info->strip == strip_some
- && bfd_hash_lookup (einfo->info->keep_hash,
- h->root.root.root.string,
- false, false) == NULL))
- strip = true;
- else
- strip = false;
-
- if (strip)
- return true;
-
- if (h->esym.ifd == -2)
- {
- h->esym.jmptbl = 0;
- h->esym.cobol_main = 0;
- h->esym.weakext = 0;
- h->esym.reserved = 0;
- h->esym.ifd = ifdNil;
- h->esym.asym.value = 0;
- h->esym.asym.st = stGlobal;
-
- if (SGI_COMPAT (einfo->abfd)
- && (h->root.root.type == bfd_link_hash_undefined
- || h->root.root.type == bfd_link_hash_undefweak))
- {
- const char *name;
-
- /* Use undefined class. Also, set class and type for some
- special symbols. */
- name = h->root.root.root.string;
- if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
- || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
- {
- h->esym.asym.sc = scData;
- h->esym.asym.st = stLabel;
- h->esym.asym.value = 0;
- }
- else if (strcmp (name, mips_elf_dynsym_rtproc_names[2]) == 0)
- {
- h->esym.asym.sc = scAbs;
- h->esym.asym.st = stLabel;
- h->esym.asym.value =
- mips_elf_hash_table (einfo->info)->procedure_count;
- }
- else if (strcmp (name, "_gp_disp") == 0)
- {
- h->esym.asym.sc = scAbs;
- h->esym.asym.st = stLabel;
- h->esym.asym.value = elf_gp (einfo->abfd);
- }
- else
- h->esym.asym.sc = scUndefined;
- }
- else if (h->root.root.type != bfd_link_hash_defined
- && h->root.root.type != bfd_link_hash_defweak)
- h->esym.asym.sc = scAbs;
- else
- {
- const char *name;
-
- sec = h->root.root.u.def.section;
- output_section = sec->output_section;
-
- /* When making a shared library and symbol h is the one from
- the another shared library, OUTPUT_SECTION may be null. */
- if (output_section == NULL)
- h->esym.asym.sc = scUndefined;
- else
- {
- name = bfd_section_name (output_section->owner, output_section);
-
- if (strcmp (name, ".text") == 0)
- h->esym.asym.sc = scText;
- else if (strcmp (name, ".data") == 0)
- h->esym.asym.sc = scData;
- else if (strcmp (name, ".sdata") == 0)
- h->esym.asym.sc = scSData;
- else if (strcmp (name, ".rodata") == 0
- || strcmp (name, ".rdata") == 0)
- h->esym.asym.sc = scRData;
- else if (strcmp (name, ".bss") == 0)
- h->esym.asym.sc = scBss;
- else if (strcmp (name, ".sbss") == 0)
- h->esym.asym.sc = scSBss;
- else if (strcmp (name, ".init") == 0)
- h->esym.asym.sc = scInit;
- else if (strcmp (name, ".fini") == 0)
- h->esym.asym.sc = scFini;
- else
- h->esym.asym.sc = scAbs;
- }
- }
-
- h->esym.asym.reserved = 0;
- h->esym.asym.index = indexNil;
- }
-
- if (h->root.root.type == bfd_link_hash_common)
- h->esym.asym.value = h->root.root.u.c.size;
- else if (h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak)
- {
- if (h->esym.asym.sc == scCommon)
- h->esym.asym.sc = scBss;
- else if (h->esym.asym.sc == scSCommon)
- h->esym.asym.sc = scSBss;
-
- sec = h->root.root.u.def.section;
- output_section = sec->output_section;
- if (output_section != NULL)
- h->esym.asym.value = (h->root.root.u.def.value
- + sec->output_offset
- + output_section->vma);
- else
- h->esym.asym.value = 0;
- }
- else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
- {
- /* Set type and value for a symbol with a function stub. */
- h->esym.asym.st = stProc;
- sec = h->root.root.u.def.section;
- if (sec == NULL)
- h->esym.asym.value = 0;
- else
- {
- output_section = sec->output_section;
- if (output_section != NULL)
- h->esym.asym.value = (h->root.plt_offset
- + sec->output_offset
- + output_section->vma);
- else
- h->esym.asym.value = 0;
- }
-#if 0 /* FIXME? */
- h->esym.ifd = 0;
-#endif
- }
-
- if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap,
- h->root.root.root.string,
- &h->esym))
- {
- einfo->failed = true;
- return false;
- }
-
- return true;
-}
-
-/* Create a runtime procedure table from the .mdebug section. */
-
-static boolean
-mips_elf_create_procedure_table (handle, abfd, info, s, debug)
- PTR handle;
- bfd *abfd;
- struct bfd_link_info *info;
- asection *s;
- struct ecoff_debug_info *debug;
-{
- const struct ecoff_debug_swap *swap;
- HDRR *hdr = &debug->symbolic_header;
- RPDR *rpdr, *rp;
- struct rpdr_ext *erp;
- PTR rtproc;
- struct pdr_ext *epdr;
- struct sym_ext *esym;
- char *ss, **sv;
- char *str;
- unsigned long size, count;
- unsigned long sindex;
- unsigned long i;
- PDR pdr;
- SYMR sym;
- const char *no_name_func = "static procedure (no name)";
-
- epdr = NULL;
- rpdr = NULL;
- esym = NULL;
- ss = NULL;
- sv = NULL;
-
- swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
-
- sindex = strlen (no_name_func) + 1;
- count = hdr->ipdMax;
- if (count > 0)
- {
- size = swap->external_pdr_size;
-
- epdr = (struct pdr_ext *) bfd_malloc (size * count);
- if (epdr == NULL)
- goto error_return;
-
- if (! _bfd_ecoff_get_accumulated_pdr (handle, (PTR) epdr))
- goto error_return;
-
- size = sizeof (RPDR);
- rp = rpdr = (RPDR *) bfd_malloc (size * count);
- if (rpdr == NULL)
- goto error_return;
-
- sv = (char **) bfd_malloc (sizeof (char *) * count);
- if (sv == NULL)
- goto error_return;
-
- count = hdr->isymMax;
- size = swap->external_sym_size;
- esym = (struct sym_ext *) bfd_malloc (size * count);
- if (esym == NULL)
- goto error_return;
-
- if (! _bfd_ecoff_get_accumulated_sym (handle, (PTR) esym))
- goto error_return;
-
- count = hdr->issMax;
- ss = (char *) bfd_malloc (count);
- if (ss == NULL)
- goto error_return;
- if (! _bfd_ecoff_get_accumulated_ss (handle, (PTR) ss))
- goto error_return;
-
- count = hdr->ipdMax;
- for (i = 0; i < count; i++, rp++)
- {
- (*swap->swap_pdr_in) (abfd, (PTR) (epdr + i), &pdr);
- (*swap->swap_sym_in) (abfd, (PTR) &esym[pdr.isym], &sym);
- rp->adr = sym.value;
- rp->regmask = pdr.regmask;
- rp->regoffset = pdr.regoffset;
- rp->fregmask = pdr.fregmask;
- rp->fregoffset = pdr.fregoffset;
- rp->frameoffset = pdr.frameoffset;
- rp->framereg = pdr.framereg;
- rp->pcreg = pdr.pcreg;
- rp->irpss = sindex;
- sv[i] = ss + sym.iss;
- sindex += strlen (sv[i]) + 1;
- }
- }
-
- size = sizeof (struct rpdr_ext) * (count + 2) + sindex;
- size = BFD_ALIGN (size, 16);
- rtproc = (PTR) bfd_alloc (abfd, size);
- if (rtproc == NULL)
- {
- mips_elf_hash_table (info)->procedure_count = 0;
- goto error_return;
- }
-
- mips_elf_hash_table (info)->procedure_count = count + 2;
-
- erp = (struct rpdr_ext *) rtproc;
- memset (erp, 0, sizeof (struct rpdr_ext));
- erp++;
- str = (char *) rtproc + sizeof (struct rpdr_ext) * (count + 2);
- strcpy (str, no_name_func);
- str += strlen (no_name_func) + 1;
- for (i = 0; i < count; i++)
- {
- ecoff_swap_rpdr_out (abfd, rpdr + i, erp + i);
- strcpy (str, sv[i]);
- str += strlen (sv[i]) + 1;
- }
- ecoff_put_off (abfd, (bfd_vma) -1, (bfd_byte *) (erp + count)->p_adr);
-
- /* Set the size and contents of .rtproc section. */
- s->_raw_size = size;
- s->contents = rtproc;
-
- /* Skip this section later on (I don't think this currently
- matters, but someday it might). */
- s->link_order_head = (struct bfd_link_order *) NULL;
-
- if (epdr != NULL)
- free (epdr);
- if (rpdr != NULL)
- free (rpdr);
- if (esym != NULL)
- free (esym);
- if (ss != NULL)
- free (ss);
- if (sv != NULL)
- free (sv);
-
- return true;
-
- error_return:
- if (epdr != NULL)
- free (epdr);
- if (rpdr != NULL)
- free (rpdr);
- if (esym != NULL)
- free (esym);
- if (ss != NULL)
- free (ss);
- if (sv != NULL)
- free (sv);
- return false;
-}
-
-/* A comparison routine used to sort .gptab entries. */
-
-static int
-gptab_compare (p1, p2)
- const PTR p1;
- const PTR p2;
-{
- const Elf32_gptab *a1 = (const Elf32_gptab *) p1;
- const Elf32_gptab *a2 = (const Elf32_gptab *) p2;
-
- return a1->gt_entry.gt_g_value - a2->gt_entry.gt_g_value;
-}
-
-/* We need to use a special link routine to handle the .reginfo and
- the .mdebug sections. We need to merge all instances of these
- sections together, not write them all out sequentially. */
-
-static boolean
-mips_elf_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- asection **secpp;
- asection *o;
- struct bfd_link_order *p;
- asection *reginfo_sec, *mdebug_sec, *gptab_data_sec, *gptab_bss_sec;
- asection *rtproc_sec;
- Elf32_RegInfo reginfo;
- struct ecoff_debug_info debug;
- const struct ecoff_debug_swap *swap
- = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
- HDRR *symhdr = &debug.symbolic_header;
- PTR mdebug_handle = NULL;
-
- /* Drop the .options section, since it has special semantics which I
- haven't bothered to figure out. */
- for (secpp = &abfd->sections; *secpp != NULL; secpp = &(*secpp)->next)
- {
- if (strcmp ((*secpp)->name, ".options") == 0)
- {
- for (p = (*secpp)->link_order_head; p != NULL; p = p->next)
- if (p->type == bfd_indirect_link_order)
- p->u.indirect.section->flags &=~ SEC_HAS_CONTENTS;
- (*secpp)->link_order_head = NULL;
- *secpp = (*secpp)->next;
- --abfd->section_count;
- break;
- }
- }
-
- /* Get a value for the GP register. */
- if (elf_gp (abfd) == 0)
- {
- struct bfd_link_hash_entry *h;
-
- h = bfd_link_hash_lookup (info->hash, "_gp", false, false, true);
- if (h != (struct bfd_link_hash_entry *) NULL
- && h->type == bfd_link_hash_defined)
- elf_gp (abfd) = (h->u.def.value
- + h->u.def.section->output_section->vma
- + h->u.def.section->output_offset);
- else if (info->relocateable)
- {
- bfd_vma lo;
-
- /* Make up a value. */
- lo = (bfd_vma) -1;
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- if (o->vma < lo
- && (strcmp (o->name, ".sbss") == 0
- || strcmp (o->name, ".sdata") == 0
- || strcmp (o->name, ".lit4") == 0
- || strcmp (o->name, ".lit8") == 0))
- lo = o->vma;
- }
- elf_gp (abfd) = lo + ELF_MIPS_GP_OFFSET (abfd);
- }
- else
- {
- /* If the relocate_section function needs to do a reloc
- involving the GP value, it should make a reloc_dangerous
- callback to warn that GP is not defined. */
- }
- }
-
- /* Go through the sections and collect the .reginfo and .mdebug
- information. */
- reginfo_sec = NULL;
- mdebug_sec = NULL;
- gptab_data_sec = NULL;
- gptab_bss_sec = NULL;
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- if (strcmp (o->name, ".reginfo") == 0)
- {
- memset (&reginfo, 0, sizeof reginfo);
-
- /* We have found the .reginfo section in the output file.
- Look through all the link_orders comprising it and merge
- the information together. */
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- asection *input_section;
- bfd *input_bfd;
- Elf32_External_RegInfo ext;
- Elf32_RegInfo sub;
-
- if (p->type != bfd_indirect_link_order)
- {
- if (p->type == bfd_fill_link_order)
- continue;
- abort ();
- }
-
- input_section = p->u.indirect.section;
- input_bfd = input_section->owner;
-
- /* The linker emulation code has probably clobbered the
- size to be zero bytes. */
- if (input_section->_raw_size == 0)
- input_section->_raw_size = sizeof (Elf32_External_RegInfo);
-
- if (! bfd_get_section_contents (input_bfd, input_section,
- (PTR) &ext,
- (file_ptr) 0,
- sizeof ext))
- return false;
-
- bfd_mips_elf32_swap_reginfo_in (input_bfd, &ext, &sub);
-
- reginfo.ri_gprmask |= sub.ri_gprmask;
- reginfo.ri_cprmask[0] |= sub.ri_cprmask[0];
- reginfo.ri_cprmask[1] |= sub.ri_cprmask[1];
- reginfo.ri_cprmask[2] |= sub.ri_cprmask[2];
- reginfo.ri_cprmask[3] |= sub.ri_cprmask[3];
-
- /* ri_gp_value is set by the function
- mips_elf_section_processing when the section is
- finally written out. */
-
- /* Hack: reset the SEC_HAS_CONTENTS flag so that
- elf_link_input_bfd ignores this section. */
- input_section->flags &=~ SEC_HAS_CONTENTS;
- }
-
- /* Force the section size to the value we want. */
- o->_raw_size = sizeof (Elf32_External_RegInfo);
-
- /* Skip this section later on (I don't think this currently
- matters, but someday it might). */
- o->link_order_head = (struct bfd_link_order *) NULL;
-
- reginfo_sec = o;
- }
-
- if (strcmp (o->name, ".mdebug") == 0)
- {
- struct extsym_info einfo;
-
- /* We have found the .mdebug section in the output file.
- Look through all the link_orders comprising it and merge
- the information together. */
- symhdr->magic = swap->sym_magic;
- /* FIXME: What should the version stamp be? */
- symhdr->vstamp = 0;
- symhdr->ilineMax = 0;
- symhdr->cbLine = 0;
- symhdr->idnMax = 0;
- symhdr->ipdMax = 0;
- symhdr->isymMax = 0;
- symhdr->ioptMax = 0;
- symhdr->iauxMax = 0;
- symhdr->issMax = 0;
- symhdr->issExtMax = 0;
- symhdr->ifdMax = 0;
- symhdr->crfd = 0;
- symhdr->iextMax = 0;
-
- /* We accumulate the debugging information itself in the
- debug_info structure. */
- debug.line = NULL;
- debug.external_dnr = NULL;
- debug.external_pdr = NULL;
- debug.external_sym = NULL;
- debug.external_opt = NULL;
- debug.external_aux = NULL;
- debug.ss = NULL;
- debug.ssext = debug.ssext_end = NULL;
- debug.external_fdr = NULL;
- debug.external_rfd = NULL;
- debug.external_ext = debug.external_ext_end = NULL;
-
- mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
- if (mdebug_handle == (PTR) NULL)
- return false;
-
- if (SGI_COMPAT (abfd))
- {
- asection *s;
- EXTR esym;
- bfd_vma last;
- unsigned int i;
- static const char * const name[] =
- { ".text", ".init", ".fini", ".data",
- ".rodata", ".sdata", ".sbss", ".bss" };
- static const int sc[] = { scText, scInit, scFini, scData,
- scRData, scSData, scSBss, scBss };
-
- esym.jmptbl = 0;
- esym.cobol_main = 0;
- esym.weakext = 0;
- esym.reserved = 0;
- esym.ifd = ifdNil;
- esym.asym.iss = issNil;
- esym.asym.st = stLocal;
- esym.asym.reserved = 0;
- esym.asym.index = indexNil;
- for (i = 0; i < 8; i++)
- {
- esym.asym.sc = sc[i];
- s = bfd_get_section_by_name (abfd, name[i]);
- if (s != NULL)
- {
- esym.asym.value = s->vma;
- last = s->vma + s->_raw_size;
- }
- else
- esym.asym.value = last;
-
- if (! bfd_ecoff_debug_one_external (abfd, &debug, swap,
- name[i], &esym))
- return false;
- }
- }
-
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- asection *input_section;
- bfd *input_bfd;
- const struct ecoff_debug_swap *input_swap;
- struct ecoff_debug_info input_debug;
- char *eraw_src;
- char *eraw_end;
-
- if (p->type != bfd_indirect_link_order)
- {
- if (p->type == bfd_fill_link_order)
- continue;
- abort ();
- }
-
- input_section = p->u.indirect.section;
- input_bfd = input_section->owner;
-
- if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour
- || (get_elf_backend_data (input_bfd)
- ->elf_backend_ecoff_debug_swap) == NULL)
- {
- /* I don't know what a non MIPS ELF bfd would be
- doing with a .mdebug section, but I don't really
- want to deal with it. */
- continue;
- }
-
- input_swap = (get_elf_backend_data (input_bfd)
- ->elf_backend_ecoff_debug_swap);
-
- BFD_ASSERT (p->size == input_section->_raw_size);
-
- /* The ECOFF linking code expects that we have already
- read in the debugging information and set up an
- ecoff_debug_info structure, so we do that now. */
- if (! mips_elf_read_ecoff_info (input_bfd, input_section,
- &input_debug))
- return false;
-
- if (! (bfd_ecoff_debug_accumulate
- (mdebug_handle, abfd, &debug, swap, input_bfd,
- &input_debug, input_swap, info)))
- return false;
-
- /* Loop through the external symbols. For each one with
- interesting information, try to find the symbol in
- the linker global hash table and save the information
- for the output external symbols. */
- eraw_src = input_debug.external_ext;
- eraw_end = (eraw_src
- + (input_debug.symbolic_header.iextMax
- * input_swap->external_ext_size));
- for (;
- eraw_src < eraw_end;
- eraw_src += input_swap->external_ext_size)
- {
- EXTR ext;
- const char *name;
- struct mips_elf_link_hash_entry *h;
-
- (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext);
- if (ext.asym.sc == scNil
- || ext.asym.sc == scUndefined
- || ext.asym.sc == scSUndefined)
- continue;
-
- name = input_debug.ssext + ext.asym.iss;
- h = mips_elf_link_hash_lookup (mips_elf_hash_table (info),
- name, false, false, true);
- if (h == NULL || h->esym.ifd != -2)
- continue;
-
- if (ext.ifd != -1)
- {
- BFD_ASSERT (ext.ifd
- < input_debug.symbolic_header.ifdMax);
- ext.ifd = input_debug.ifdmap[ext.ifd];
- }
-
- h->esym = ext;
- }
-
- /* Free up the information we just read. */
- free (input_debug.line);
- free (input_debug.external_dnr);
- free (input_debug.external_pdr);
- free (input_debug.external_sym);
- free (input_debug.external_opt);
- free (input_debug.external_aux);
- free (input_debug.ss);
- free (input_debug.ssext);
- free (input_debug.external_fdr);
- free (input_debug.external_rfd);
- free (input_debug.external_ext);
-
- /* Hack: reset the SEC_HAS_CONTENTS flag so that
- elf_link_input_bfd ignores this section. */
- input_section->flags &=~ SEC_HAS_CONTENTS;
- }
-
- if (SGI_COMPAT (abfd) && info->shared)
- {
- /* Create .rtproc section. */
- rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
- if (rtproc_sec == NULL)
- {
- flagword flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY
- | SEC_READONLY);
-
- rtproc_sec = bfd_make_section (abfd, ".rtproc");
- if (rtproc_sec == NULL
- || ! bfd_set_section_flags (abfd, rtproc_sec, flags)
- || ! bfd_set_section_alignment (abfd, rtproc_sec, 12))
- return false;
- }
-
- if (! mips_elf_create_procedure_table (mdebug_handle, abfd,
- info, rtproc_sec, &debug))
- return false;
- }
-
- /* Build the external symbol information. */
- einfo.abfd = abfd;
- einfo.info = info;
- einfo.debug = &debug;
- einfo.swap = swap;
- einfo.failed = false;
- mips_elf_link_hash_traverse (mips_elf_hash_table (info),
- mips_elf_output_extsym,
- (PTR) &einfo);
- if (einfo.failed)
- return false;
-
- /* Set the size of the .mdebug section. */
- o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap);
-
- /* Skip this section later on (I don't think this currently
- matters, but someday it might). */
- o->link_order_head = (struct bfd_link_order *) NULL;
-
- mdebug_sec = o;
- }
-
- if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0)
- {
- const char *subname;
- unsigned int c;
- Elf32_gptab *tab;
- Elf32_External_gptab *ext_tab;
- unsigned int i;
-
- /* The .gptab.sdata and .gptab.sbss sections hold
- information describing how the small data area would
- change depending upon the -G switch. These sections
- not used in executables files. */
- if (! info->relocateable)
- {
- asection **secpp;
-
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- asection *input_section;
-
- if (p->type != bfd_indirect_link_order)
- {
- if (p->type == bfd_fill_link_order)
- continue;
- abort ();
- }
-
- input_section = p->u.indirect.section;
-
- /* Hack: reset the SEC_HAS_CONTENTS flag so that
- elf_link_input_bfd ignores this section. */
- input_section->flags &=~ SEC_HAS_CONTENTS;
- }
-
- /* Skip this section later on (I don't think this
- currently matters, but someday it might). */
- o->link_order_head = (struct bfd_link_order *) NULL;
-
- /* Really remove the section. */
- for (secpp = &abfd->sections;
- *secpp != o;
- secpp = &(*secpp)->next)
- ;
- *secpp = (*secpp)->next;
- --abfd->section_count;
-
- continue;
- }
-
- /* There is one gptab for initialized data, and one for
- uninitialized data. */
- if (strcmp (o->name, ".gptab.sdata") == 0)
- gptab_data_sec = o;
- else if (strcmp (o->name, ".gptab.sbss") == 0)
- gptab_bss_sec = o;
- else
- {
- (*_bfd_error_handler)
- ("%s: illegal section name `%s'",
- bfd_get_filename (abfd), o->name);
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
-
- /* The linker script always combines .gptab.data and
- .gptab.sdata into .gptab.sdata, and likewise for
- .gptab.bss and .gptab.sbss. It is possible that there is
- no .sdata or .sbss section in the output file, in which
- case we must change the name of the output section. */
- subname = o->name + sizeof ".gptab" - 1;
- if (bfd_get_section_by_name (abfd, subname) == NULL)
- {
- if (o == gptab_data_sec)
- o->name = ".gptab.data";
- else
- o->name = ".gptab.bss";
- subname = o->name + sizeof ".gptab" - 1;
- BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL);
- }
-
- /* Set up the first entry. */
- c = 1;
- tab = (Elf32_gptab *) bfd_malloc (c * sizeof (Elf32_gptab));
- if (tab == NULL)
- return false;
- tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);
- tab[0].gt_header.gt_unused = 0;
-
- /* Combine the input sections. */
- for (p = o->link_order_head;
- p != (struct bfd_link_order *) NULL;
- p = p->next)
- {
- asection *input_section;
- bfd *input_bfd;
- bfd_size_type size;
- unsigned long last;
- bfd_size_type gpentry;
-
- if (p->type != bfd_indirect_link_order)
- {
- if (p->type == bfd_fill_link_order)
- continue;
- abort ();
- }
-
- input_section = p->u.indirect.section;
- input_bfd = input_section->owner;
-
- /* Combine the gptab entries for this input section one
- by one. We know that the input gptab entries are
- sorted by ascending -G value. */
- size = bfd_section_size (input_bfd, input_section);
- last = 0;
- for (gpentry = sizeof (Elf32_External_gptab);
- gpentry < size;
- gpentry += sizeof (Elf32_External_gptab))
- {
- Elf32_External_gptab ext_gptab;
- Elf32_gptab int_gptab;
- unsigned long val;
- unsigned long add;
- boolean exact;
- unsigned int look;
-
- if (! (bfd_get_section_contents
- (input_bfd, input_section, (PTR) &ext_gptab,
- gpentry, sizeof (Elf32_External_gptab))))
- {
- free (tab);
- return false;
- }
-
- bfd_mips_elf32_swap_gptab_in (input_bfd, &ext_gptab,
- &int_gptab);
- val = int_gptab.gt_entry.gt_g_value;
- add = int_gptab.gt_entry.gt_bytes - last;
-
- exact = false;
- for (look = 1; look < c; look++)
- {
- if (tab[look].gt_entry.gt_g_value >= val)
- tab[look].gt_entry.gt_bytes += add;
-
- if (tab[look].gt_entry.gt_g_value == val)
- exact = true;
- }
-
- if (! exact)
- {
- Elf32_gptab *new_tab;
- unsigned int max;
-
- /* We need a new table entry. */
- new_tab = ((Elf32_gptab *)
- bfd_realloc ((PTR) tab,
- (c + 1) * sizeof (Elf32_gptab)));
- if (new_tab == NULL)
- {
- free (tab);
- return false;
- }
- tab = new_tab;
- tab[c].gt_entry.gt_g_value = val;
- tab[c].gt_entry.gt_bytes = add;
-
- /* Merge in the size for the next smallest -G
- value, since that will be implied by this new
- value. */
- max = 0;
- for (look = 1; look < c; look++)
- {
- if (tab[look].gt_entry.gt_g_value < val
- && (max == 0
- || (tab[look].gt_entry.gt_g_value
- > tab[max].gt_entry.gt_g_value)))
- max = look;
- }
- if (max != 0)
- tab[c].gt_entry.gt_bytes +=
- tab[max].gt_entry.gt_bytes;
-
- ++c;
- }
-
- last = int_gptab.gt_entry.gt_bytes;
- }
-
- /* Hack: reset the SEC_HAS_CONTENTS flag so that
- elf_link_input_bfd ignores this section. */
- input_section->flags &=~ SEC_HAS_CONTENTS;
- }
-
- /* The table must be sorted by -G value. */
- if (c > 2)
- qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);
-
- /* Swap out the table. */
- ext_tab = ((Elf32_External_gptab *)
- bfd_alloc (abfd, c * sizeof (Elf32_External_gptab)));
- if (ext_tab == NULL)
- {
- free (tab);
- return false;
- }
-
- for (i = 0; i < c; i++)
- bfd_mips_elf32_swap_gptab_out (abfd, tab + i, ext_tab + i);
- free (tab);
-
- o->_raw_size = c * sizeof (Elf32_External_gptab);
- o->contents = (bfd_byte *) ext_tab;
-
- /* Skip this section later on (I don't think this currently
- matters, but someday it might). */
- o->link_order_head = (struct bfd_link_order *) NULL;
- }
- }
-
- /* Invoke the regular ELF backend linker to do all the work. */
- if (! bfd_elf32_bfd_final_link (abfd, info))
- return false;
-
- /* Now write out the computed sections. */
-
- if (reginfo_sec != (asection *) NULL)
- {
- Elf32_External_RegInfo ext;
-
- bfd_mips_elf32_swap_reginfo_out (abfd, &reginfo, &ext);
- if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,
- (file_ptr) 0, sizeof ext))
- return false;
- }
-
- if (mdebug_sec != (asection *) NULL)
- {
- BFD_ASSERT (abfd->output_has_begun);
- if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,
- swap, info,
- mdebug_sec->filepos))
- return false;
-
- bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
- }
-
- if (gptab_data_sec != (asection *) NULL)
- {
- if (! bfd_set_section_contents (abfd, gptab_data_sec,
- gptab_data_sec->contents,
- (file_ptr) 0,
- gptab_data_sec->_raw_size))
- return false;
- }
-
- if (gptab_bss_sec != (asection *) NULL)
- {
- if (! bfd_set_section_contents (abfd, gptab_bss_sec,
- gptab_bss_sec->contents,
- (file_ptr) 0,
- gptab_bss_sec->_raw_size))
- return false;
- }
-
- if (SGI_COMPAT (abfd))
- {
- rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
- if (rtproc_sec != NULL)
- {
- if (! bfd_set_section_contents (abfd, rtproc_sec,
- rtproc_sec->contents,
- (file_ptr) 0,
- rtproc_sec->_raw_size))
- return false;
- }
- }
-
- return true;
-}
-
-/* Handle a MIPS ELF HI16 reloc. */
-
-static void
-mips_elf_relocate_hi16 (input_bfd, relhi, rello, contents, addend)
- bfd *input_bfd;
- Elf_Internal_Rela *relhi;
- Elf_Internal_Rela *rello;
- bfd_byte *contents;
- bfd_vma addend;
-{
- bfd_vma insn;
- bfd_vma addlo;
-
- insn = bfd_get_32 (input_bfd, contents + relhi->r_offset);
-
- addlo = bfd_get_32 (input_bfd, contents + rello->r_offset);
- addlo &= 0xffff;
-
- addend += ((insn & 0xffff) << 16) + addlo;
-
- if ((addlo & 0x8000) != 0)
- addend -= 0x10000;
- if ((addend & 0x8000) != 0)
- addend += 0x10000;
-
- bfd_put_32 (input_bfd,
- (insn & 0xffff0000) | ((addend >> 16) & 0xffff),
- contents + relhi->r_offset);
-}
-
-/* Handle a MIPS ELF local GOT16 reloc. */
-
-static void
-mips_elf_relocate_got_local (output_bfd, input_bfd, sgot, relhi, rello,
- contents, addend)
- bfd *output_bfd;
- bfd *input_bfd;
- asection *sgot;
- Elf_Internal_Rela *relhi;
- Elf_Internal_Rela *rello;
- bfd_byte *contents;
- bfd_vma addend;
-{
- int local_gotno;
- int i;
- bfd_vma insn;
- bfd_vma addlo;
- bfd_vma address;
- bfd_vma hipage;
- bfd_byte *got_contents;
- struct mips_got_info *g;
-
- insn = bfd_get_32 (input_bfd, contents + relhi->r_offset);
-
- addlo = bfd_get_32 (input_bfd, contents + rello->r_offset);
- addlo &= 0xffff;
-
- addend += ((insn & 0xffff) << 16) + addlo;
-
- if ((addlo & 0x8000) != 0)
- addend -= 0x10000;
- if ((addend & 0x8000) != 0)
- addend += 0x10000;
-
- /* Get a got entry representing requested hipage. */
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
- BFD_ASSERT (g != NULL);
-
- local_gotno = g->local_gotno;
- got_contents = sgot->contents;
- hipage = addend & 0xffff0000;
-
- for (i = MIPS_RESERVED_GOTNO; i < local_gotno; i++)
- {
- address = bfd_get_32 (input_bfd, got_contents + i * 4);
- if (hipage == (address & 0xffff0000))
- break;
- if (address == (bfd_vma) 0)
- {
- bfd_put_32 (input_bfd, hipage, got_contents + i * 4);
- break;
- }
- }
-
- BFD_ASSERT (i < local_gotno);
-#if 1
- if (i == local_gotno)
- (*_bfd_error_handler)
- ("ELF MIPS linker: more got entries are needed for hipage: %x",
- hipage);
-#endif
-
- i = - ELF_MIPS_GP_OFFSET (output_bfd) + i * 4;
- bfd_put_32 (input_bfd, (insn & 0xffff0000) | (i & 0xffff),
- contents + relhi->r_offset);
-}
-
-/* Handle MIPS ELF CALL16 reloc and global GOT16 reloc. */
-
-static void
-mips_elf_relocate_global_got (input_bfd, rel, contents, offset)
- bfd *input_bfd;
- Elf_Internal_Rela *rel;
- bfd_byte *contents;
- bfd_vma offset;
-{
- bfd_vma insn;
-
- insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
- bfd_put_32 (input_bfd,
- (insn & 0xffff0000) | (offset & 0xffff),
- contents + rel->r_offset);
-}
-
-/* Relocate a MIPS ELF section. */
-
-static boolean
-mips_elf_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, local_syms, local_sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- Elf_Internal_Rela *relocs;
- Elf_Internal_Sym *local_syms;
- asection **local_sections;
-{
- Elf_Internal_Shdr *symtab_hdr;
- size_t locsymcount;
- size_t extsymoff;
- asection *sgot, *sreloc, *scpt;
- bfd *dynobj;
- bfd_vma gp;
- Elf_Internal_Rela *rel;
- Elf_Internal_Rela *relend;
- struct mips_got_info *g;
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
-
- sgot = NULL;
- sreloc = NULL;
- if (dynobj == NULL || ! SGI_COMPAT (output_bfd))
- scpt = NULL;
- else
- scpt = bfd_get_section_by_name (dynobj, ".compact_rel");
- g = NULL;
-
- if (elf_bad_symtab (input_bfd))
- {
- locsymcount = symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
- extsymoff = 0;
- }
- else
- {
- locsymcount = symtab_hdr->sh_info;
- extsymoff = symtab_hdr->sh_info;
- }
-
- gp = _bfd_get_gp_value (output_bfd);
-
- rel = relocs;
- relend = relocs + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- int r_type;
- reloc_howto_type *howto;
- unsigned long r_symndx;
- bfd_vma addend;
- struct elf_link_hash_entry *h;
- asection *sec;
- Elf_Internal_Sym *sym;
- bfd_reloc_status_type r;
-
- r_type = ELF32_R_TYPE (rel->r_info);
- if (r_type < 0 || r_type >= (int) R_MIPS_max)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- howto = elf_mips_howto_table + r_type;
-
- if (dynobj != NULL
- && (r_type == R_MIPS_CALL16
- || r_type == R_MIPS_GOT16
- || r_type == R_MIPS_CALL_HI16
- || r_type == R_MIPS_CALL_LO16
- || r_type == R_MIPS_GOT_HI16
- || r_type == R_MIPS_GOT_LO16))
- {
- /* We need the .got section. */
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
- BFD_ASSERT (g != NULL);
- }
- }
-
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- /* Mix in the change in GP address for a GP relative reloc. */
- if (r_type != R_MIPS_GPREL16
- && r_type != R_MIPS_LITERAL
- && r_type != R_MIPS_GPREL32)
- addend = 0;
- else
- {
- if (gp == 0)
- {
- if (! ((*info->callbacks->reloc_dangerous)
- (info,
- "GP relative relocation when GP not defined",
- input_bfd, input_section,
- rel->r_offset)))
- return false;
- /* Only give the error once per link. */
- gp = 4;
- _bfd_set_gp_value (output_bfd, gp);
- }
-
- if (r_symndx < extsymoff
- || (elf_bad_symtab (input_bfd)
- && local_sections[r_symndx] != NULL))
- {
- /* This is a relocation against a section. The current
- addend in the instruction is the difference between
- INPUT_SECTION->vma and the GP value of INPUT_BFD. We
- must change this to be the difference between the
- final definition (which will end up in RELOCATION)
- and the GP value of OUTPUT_BFD (which is in GP). */
- addend = elf_gp (input_bfd) - gp;
- }
- else if (! info->relocateable)
- {
- /* We are doing a final link. The current addend in the
- instruction is simply the desired offset into the
- symbol (normally zero). We want the instruction to
- hold the difference between the final definition of
- the symbol (which will end up in RELOCATION) and the
- GP value of OUTPUT_BFD (which is in GP). */
- addend = - gp;
- }
- else
- {
- /* We are generating relocateable output, and we aren't
- going to define this symbol, so we just leave the
- instruction alone. */
- addend = 0;
- }
- }
-
- h = NULL;
- sym = NULL;
- sec = NULL;
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx >= locsymcount
- || (elf_bad_symtab (input_bfd)
- && local_sections[r_symndx] == NULL))
- r = bfd_reloc_ok;
- else
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
- r = bfd_reloc_ok;
- else
- {
- sec = local_sections[r_symndx];
-
- /* It would be logical to add sym->st_value here,
- but Irix 5 sometimes generates a garbage symbol
- value. */
- addend += sec->output_offset;
-
- /* If this is HI16 or GOT16 with an associated LO16,
- adjust the addend accordingly. Otherwise, just
- relocate. */
- if ((r_type != R_MIPS_HI16 && r_type != R_MIPS_GOT16)
- || (rel + 1) >= relend
- || ELF32_R_TYPE ((rel + 1)->r_info) != R_MIPS_LO16)
- r = _bfd_relocate_contents (howto, input_bfd,
- addend,
- contents + rel->r_offset);
- else
- {
- mips_elf_relocate_hi16 (input_bfd, rel, rel + 1,
- contents, addend);
- r = bfd_reloc_ok;
- }
- }
- }
- }
- else
- {
- bfd_vma relocation;
- boolean local;
-
- /* This is a final link. */
- sym = NULL;
- if (r_symndx < extsymoff
- || (elf_bad_symtab (input_bfd)
- && local_sections[r_symndx] != NULL))
- {
- local = true;
- sym = local_syms + r_symndx;
- sec = local_sections[r_symndx];
- relocation = (sec->output_section->vma
- + sec->output_offset);
-
- /* It would be logical to always add sym->st_value here,
- but Irix 5 sometimes generates a garbage symbol
- value. */
- if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
- relocation += sym->st_value;
- }
- else
- {
- long indx;
-
- local = false;
- indx = r_symndx - extsymoff;
- h = elf_sym_hashes (input_bfd)[indx];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- if (strcmp (h->root.root.string, "_gp_disp") == 0)
- {
- if (gp == 0)
- {
- if (! ((*info->callbacks->reloc_dangerous)
- (info,
- "_gp_disp used when GP not defined",
- input_bfd, input_section,
- rel->r_offset)))
- return false;
- /* Only give the error once per link. */
- gp = 4;
- _bfd_set_gp_value (output_bfd, gp);
- relocation = 0;
- }
- else
- {
- sec = input_section;
- if (sec->output_section != NULL)
- relocation = (gp
- - (rel->r_offset
- + sec->output_section->vma
- + sec->output_offset));
- else
- relocation = gp - rel->r_offset;
- if (r_type == R_MIPS_LO16)
- relocation += 4;
- }
- }
- else if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- if (sec->output_section == NULL)
- relocation = 0;
- else
- relocation = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else if (info->shared && ! info->symbolic)
- relocation = 0;
- else if (strcmp (h->root.root.string, "_DYNAMIC_LINK") == 0)
- {
- /* If this is a dynamic link, we should have created
- a _DYNAMIC_LINK symbol in
- mips_elf_create_dynamic_sections. Otherwise, we
- should define the symbol with a value of 0.
- FIXME: It should probably get into the symbol
- table somehow as well. */
- BFD_ASSERT (! info->shared);
- BFD_ASSERT (bfd_get_section_by_name (output_bfd,
- ".dynamic") == NULL);
- relocation = 0;
- }
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset)))
- return false;
- relocation = 0;
- }
- }
-
- if (r_type == R_MIPS_HI16
- && (rel + 1) < relend
- && ELF32_R_TYPE ((rel + 1)->r_info) == R_MIPS_LO16)
- {
- mips_elf_relocate_hi16 (input_bfd, rel, rel + 1,
- contents, relocation + addend);
- r = bfd_reloc_ok;
- }
- else if (r_type == R_MIPS_GOT16 && local)
- {
- /* GOT16 must be also with associated LO16 in the local
- case. In this case, the addend is extracted and the
- section in which the referenced object is determined.
- Then the final address of the object is computed and
- the GOT entry for the hipage (an aligned 64kb chunk)
- is added to .got section if needed. The offset field
- of the GOT16-relocated instruction is replaced by the
- index of this GOT entry for the hipage. */
- if ((rel + 1) < relend
- && ELF32_R_TYPE ((rel + 1)->r_info) == R_MIPS_LO16)
- {
- mips_elf_relocate_got_local (output_bfd, input_bfd, sgot,
- rel, rel + 1,
- contents,
- relocation + addend);
- r = bfd_reloc_ok;
- }
- else
- r = bfd_reloc_outofrange;
- }
- else if (r_type == R_MIPS_CALL16
- || r_type == R_MIPS_GOT16
- || r_type == R_MIPS_CALL_LO16
- || r_type == R_MIPS_GOT_LO16)
- {
- bfd_vma offset;
-
- /* This symbol must be registered as a global symbol
- having the corresponding got entry. */
- BFD_ASSERT (h->got_offset != (bfd_vma) -1);
-
- offset = (h->dynindx - g->global_gotsym + g->local_gotno) * 4;
- BFD_ASSERT (g->local_gotno <= offset
- && offset < sgot->_raw_size);
- bfd_put_32 (output_bfd, relocation + addend,
- sgot->contents + offset);
- offset = (sgot->output_section->vma + sgot->output_offset
- + offset - gp);
- mips_elf_relocate_global_got (input_bfd, rel, contents,
- offset);
- r = bfd_reloc_ok;
- }
- else if (r_type == R_MIPS_CALL_HI16
- || r_type == R_MIPS_GOT_HI16)
- {
- bfd_vma offset;
-
- /* This must be a global symbol with a got entry. The
- next reloc must be the corresponding LO16 reloc. */
- BFD_ASSERT (h != NULL && h->got_offset != (bfd_vma) -1);
- BFD_ASSERT ((rel + 1) < relend);
- BFD_ASSERT (ELF32_R_TYPE ((rel + 1)->r_info)
- == (r_type == R_MIPS_CALL_HI16
- ? R_MIPS_CALL_LO16
- : R_MIPS_GOT_LO16));
-
- offset = (h->dynindx - g->global_gotsym + g->local_gotno) * 4;
- BFD_ASSERT (g->local_gotno <= offset
- && offset < sgot->_raw_size);
- bfd_put_32 (output_bfd, relocation + addend,
- sgot->contents + offset);
- offset = (sgot->output_section->vma + sgot->output_offset
- + offset - gp);
- mips_elf_relocate_hi16 (input_bfd, rel, rel + 1, contents,
- offset);
- r = bfd_reloc_ok;
- }
- else if (r_type == R_MIPS_REL32
- || r_type == R_MIPS_32)
- {
- Elf_Internal_Rel outrel;
- Elf32_crinfo cptrel;
- bfd_byte *cr;
-
- if (info->shared
- && (input_section->flags & SEC_ALLOC) != 0)
- {
- /* When generating a shared object, these
- relocations are copied into the output file to be
- resolved at run time. */
- if (sreloc == NULL)
- {
- sreloc = bfd_get_section_by_name (dynobj, ".rel.dyn");
- BFD_ASSERT (sreloc != NULL);
- }
-
- outrel.r_offset = (rel->r_offset
- + input_section->output_section->vma
- + input_section->output_offset);
-
- addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
-
- if (h != NULL
- && (! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))
- {
- BFD_ASSERT (h->dynindx != -1);
- outrel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_REL32);
- sec = input_section;
- }
- else
- {
- long indx;
-
- if (h == NULL)
- sec = local_sections[r_symndx];
- else
- {
- BFD_ASSERT (h->root.type == bfd_link_hash_defined
- || (h->root.type
- == bfd_link_hash_defweak));
- sec = h->root.u.def.section;
- }
- if (sec != NULL && bfd_is_abs_section (sec))
- indx = 0;
- else if (sec == NULL || sec->owner == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- else
- {
- asection *osec;
-
- osec = sec->output_section;
- indx = elf_section_data (osec)->dynindx;
- if (indx == 0)
- abort ();
- }
-
- outrel.r_info = ELF32_R_INFO (indx, R_MIPS_REL32);
- addend += relocation;
- }
-
- bfd_put_32 (output_bfd, addend, contents + rel->r_offset);
- bfd_elf32_swap_reloc_out (output_bfd, &outrel,
- (((Elf32_External_Rel *)
- sreloc->contents)
- + sreloc->reloc_count));
- ++sreloc->reloc_count;
-
- if (SGI_COMPAT (output_bfd))
- {
- if (scpt == NULL)
- continue;
-
- /* Make an entry of compact relocation info. */
- mips_elf_set_cr_format (cptrel, CRF_MIPS_LONG);
- cptrel.vaddr = (rel->r_offset
- + input_section->output_section->vma
- + input_section->output_offset);
- if (r_type == R_MIPS_REL32)
- mips_elf_set_cr_type (cptrel, CRT_MIPS_REL32);
- else
- mips_elf_set_cr_type (cptrel, CRT_MIPS_WORD);
- mips_elf_set_cr_dist2to (cptrel, 0);
- cptrel.konst = addend;
-
- cr = (scpt->contents
- + sizeof (Elf32_External_compact_rel));
- bfd_elf32_swap_crinfo_out (output_bfd, &cptrel,
- ((Elf32_External_crinfo *) cr
- + scpt->reloc_count));
- ++scpt->reloc_count;
- }
-
- /* This reloc will be computed at runtime, so
- there's no need to do anything now. */
- continue;
- }
- else
- r = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents, rel->r_offset,
- relocation, addend);
- }
- else
- r = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents, rel->r_offset,
- relocation, addend);
-
- if (SGI_COMPAT (abfd)
- && scpt != NULL
- && (input_section->flags & SEC_ALLOC) != 0)
- {
- Elf32_crinfo cptrel;
- bfd_byte *cr;
-
- /* Make an entry of compact relocation info. */
- mips_elf_set_cr_format (cptrel, CRF_MIPS_LONG);
- cptrel.vaddr = (rel->r_offset
- + input_section->output_section->vma
- + input_section->output_offset);
-
- switch (r_type)
- {
- case R_MIPS_26:
- mips_elf_set_cr_type (cptrel, CRT_MIPS_JMPAD);
- /* XXX How should we set dist2to in this case. */
- mips_elf_set_cr_dist2to (cptrel, 8);
- cptrel.konst = addend + relocation;
- cr = scpt->contents + sizeof (Elf32_External_compact_rel);
- bfd_elf32_swap_crinfo_out (output_bfd, &cptrel,
- ((Elf32_External_crinfo *) cr
- + scpt->reloc_count));
- ++scpt->reloc_count;
- break;
-
- case R_MIPS_GPREL16:
- case R_MIPS_LITERAL:
- case R_MIPS_GPREL32:
- mips_elf_set_cr_type (cptrel, CRT_MIPS_GPHI_LO);
- cptrel.konst = gp - cptrel.vaddr;
- mips_elf_set_cr_dist2to (cptrel, 4);
- cr = scpt->contents + sizeof (Elf32_External_compact_rel);
- bfd_elf32_swap_crinfo_out (output_bfd, &cptrel,
- ((Elf32_External_crinfo *) cr
- + scpt->reloc_count));
- ++scpt->reloc_count;
- break;
-
- default:
- break;
- }
- }
- }
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
- if (name == NULL)
- return false;
- if (*name == '\0')
- name = bfd_section_name (input_bfd, sec);
- }
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Functions for the dynamic linker. */
-
-/* The name of the dynamic interpreter. This is put in the .interp
- section. */
-
-#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
-
-/* Create dynamic sections when linking against a dynamic object. */
-
-static boolean
-mips_elf_create_dynamic_sections (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- struct elf_link_hash_entry *h;
- flagword flags;
- register asection *s;
- const char * const *namep;
-
- flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
- | SEC_READONLY);
-
- /* Mips ABI requests the .dynamic section to be read only. */
- s = bfd_get_section_by_name (abfd, ".dynamic");
- if (s != NULL)
- {
- if (! bfd_set_section_flags (abfd, s, flags))
- return false;
- }
-
- /* We need to create .got section. */
- if (! mips_elf_create_got_section (abfd, info))
- return false;
-
- /* Create .stub section. */
- if (bfd_get_section_by_name (abfd, ".stub") == NULL)
- {
- s = bfd_make_section (abfd, ".stub");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
- }
-
- if (SGI_COMPAT (abfd))
- {
- for (namep = mips_elf_dynsym_rtproc_names; *namep != NULL; namep++)
- {
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, *namep, BSF_GLOBAL, bfd_und_section_ptr,
- (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_SECTION;
-
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- /* We need to create a .compact_rel section. */
- if (! mips_elf_create_compact_rel_section (abfd, info))
- return false;
-
- /* Change aligments of some sections. */
- s = bfd_get_section_by_name (abfd, ".hash");
- if (s != NULL)
- bfd_set_section_alignment (abfd, s, 4);
- s = bfd_get_section_by_name (abfd, ".dynsym");
- if (s != NULL)
- bfd_set_section_alignment (abfd, s, 4);
- s = bfd_get_section_by_name (abfd, ".dynstr");
- if (s != NULL)
- bfd_set_section_alignment (abfd, s, 4);
- s = bfd_get_section_by_name (abfd, ".reginfo");
- if (s != NULL)
- bfd_set_section_alignment (abfd, s, 4);
- s = bfd_get_section_by_name (abfd, ".dynamic");
- if (s != NULL)
- bfd_set_section_alignment (abfd, s, 4);
- }
-
- if (!info->shared)
- {
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, "_DYNAMIC_LINK", BSF_GLOBAL, bfd_abs_section_ptr,
- (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- h->elf_link_hash_flags ^=~ ELF_LINK_NON_ELF;
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_SECTION;
-
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- return true;
-}
-
-/* Create the .compact_rel section. */
-
-static boolean
-mips_elf_create_compact_rel_section (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- flagword flags;
- register asection *s;
-
- if (bfd_get_section_by_name (abfd, ".compact_rel") == NULL)
- {
- flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_READONLY;
-
- s = bfd_make_section (abfd, ".compact_rel");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- s->_raw_size = sizeof (Elf32_External_compact_rel);
- }
-
- return true;
-}
-
-/* Create the .got section to hold the global offset table. */
-
-static boolean
-mips_elf_create_got_section (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- flagword flags;
- register asection *s;
- struct elf_link_hash_entry *h;
- struct mips_got_info *g;
-
- /* This function may be called more than once. */
- if (bfd_get_section_by_name (abfd, ".got") != NULL)
- return true;
-
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- s = bfd_make_section (abfd, ".got");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
- || ! bfd_set_section_alignment (abfd, s, 4))
- return false;
-
- /* Define the symbol _GLOBAL_OFFSET_TABLE_. We don't do this in the
- linker script because we don't want to define the symbol if we
- are not creating a global offset table. */
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
- (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_OBJECT;
-
- if (info->shared
- && ! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
-
- /* The first several global offset table entries are reserved. */
- s->_raw_size = MIPS_RESERVED_GOTNO * 4;
-
- g = (struct mips_got_info *) bfd_alloc (abfd,
- sizeof (struct mips_got_info));
- if (g == NULL)
- return false;
- g->global_gotsym = 0;
- g->local_gotno = MIPS_RESERVED_GOTNO;
- if (elf_section_data (s) == NULL)
- {
- s->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct bfd_elf_section_data));
- if (elf_section_data (s) == NULL)
- return false;
- }
- elf_section_data (s)->tdata = (PTR) g;
-
- return true;
-}
-
-/* Look through the relocs for a section during the first phase, and
- allocate space in the global offset table. */
-
-static boolean
-mips_elf_check_relocs (abfd, info, sec, relocs)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- const Elf_Internal_Rela *relocs;
-{
- bfd *dynobj;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- struct mips_got_info *g;
- size_t extsymoff;
- const Elf_Internal_Rela *rel;
- const Elf_Internal_Rela *rel_end;
- asection *sgot;
- asection *sreloc;
-
- if (info->relocateable)
- return true;
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (abfd);
- extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
-
- sgot = NULL;
- sreloc = NULL;
-
- rel_end = relocs + sec->reloc_count;
- for (rel = relocs; rel < rel_end; rel++)
- {
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (r_symndx < extsymoff)
- h = NULL;
- else
- h = sym_hashes[r_symndx - extsymoff];
-
- /* Some relocs require a global offset table. */
- if (dynobj == NULL)
- {
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_MIPS_GOT16:
- case R_MIPS_CALL16:
- case R_MIPS_CALL_HI16:
- case R_MIPS_CALL_LO16:
- case R_MIPS_GOT_HI16:
- case R_MIPS_GOT_LO16:
- elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! mips_elf_create_got_section (dynobj, info))
- return false;
- break;
-
- default:
- break;
- }
- }
-
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_MIPS_CALL16:
- case R_MIPS_CALL_HI16:
- case R_MIPS_CALL_LO16:
- /* This symbol requires a global offset table entry. */
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
- BFD_ASSERT (g != NULL);
- }
-
- BFD_ASSERT (h != NULL);
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- if (h->got_offset != (bfd_vma) -1)
- {
- /* We have already allocated space in the .got. */
- break;
- }
-
- /* Note the index of the first global got symbol in .dynsym. */
- if (g->global_gotsym == 0
- || g->global_gotsym > (unsigned long) h->dynindx)
- g->global_gotsym = h->dynindx;
-
- /* Make this symbol to have the corresponding got entry. */
- h->got_offset = 0;
-
- /* We need a stub, not a plt entry for the undefined
- function. But we record it as if it needs plt. See
- elf_adjust_dynamic_symbol in elflink.h. */
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
- h->type = STT_FUNC;
-
- break;
-
- case R_MIPS_GOT16:
- case R_MIPS_GOT_HI16:
- case R_MIPS_GOT_LO16:
- /* This symbol requires a global offset table entry. */
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
- BFD_ASSERT (g != NULL);
- }
-
- if (h != NULL)
- {
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- if (h->got_offset != (bfd_vma) -1)
- {
- /* We have already allocated space in the .got. */
- break;
- }
- /* Note the index of the first global got symbol in
- .dynsym. */
- if (g->global_gotsym == 0
- || g->global_gotsym > (unsigned long) h->dynindx)
- g->global_gotsym = h->dynindx;
-
- /* Make this symbol to be the global got symbol. */
- h->got_offset = 0;
- }
-
- break;
-
- case R_MIPS_32:
- case R_MIPS_REL32:
- if (info->shared
- && (sec->flags & SEC_ALLOC) != 0)
- {
- /* When creating a shared object, we must copy these
- reloc types into the output file as R_MIPS_REL32
- relocs. We create the .rel.dyn reloc section in
- dynobj and make room for this reloc. */
- if (sreloc == NULL)
- {
- const char *name = ".rel.dyn";
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- if (sreloc == NULL)
- {
- sreloc = bfd_make_section (dynobj, name);
- if (sreloc == NULL
- || ! bfd_set_section_flags (dynobj, sreloc,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, sreloc, 4))
- return false;
-
- /* Add a null element. */
- sreloc->_raw_size += sizeof (Elf32_External_Rel);
- ++sreloc->reloc_count;
- }
- }
-
- sreloc->_raw_size += sizeof (Elf32_External_Rel);
- }
-
- if (SGI_COMPAT (abfd))
- mips_elf_hash_table (info)->compact_rel_size +=
- sizeof (Elf32_External_crinfo);
-
- break;
-
- case R_MIPS_26:
- case R_MIPS_GPREL16:
- case R_MIPS_LITERAL:
- case R_MIPS_GPREL32:
- if (SGI_COMPAT (abfd))
- mips_elf_hash_table (info)->compact_rel_size +=
- sizeof (Elf32_External_crinfo);
- break;
-
- default:
- break;
- }
- }
-
- return true;
-}
-
-/* Adjust a symbol defined by a dynamic object and referenced by a
- regular object. The current definition is in some section of the
- dynamic object, but we're not including those sections. We have to
- change the definition to something the rest of the link can
- understand. */
-
-static boolean
-mips_elf_adjust_dynamic_symbol (info, h)
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
-{
- bfd *dynobj;
- asection *s;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- /* Make sure we know what is going on here. */
- BFD_ASSERT (dynobj != NULL
- && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
- || h->weakdef != NULL
- || ((h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_REF_REGULAR) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)));
-
- /* For a function, create a stub, if needed. */
- if (h->type == STT_FUNC
- || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
- {
- if (! elf_hash_table (info)->dynamic_sections_created)
- return true;
-
- /* If this symbol is not defined in a regular file, then set
- the symbol to the stub location. This is required to make
- function pointers compare as equal between the normal
- executable and the shared library. */
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- /* We need .stub section. */
- s = bfd_get_section_by_name (dynobj, ".stub");
- BFD_ASSERT (s != NULL);
-
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
-
- /* XXX Write this stub address somewhere. */
- h->plt_offset = s->_raw_size;
-
- /* Make room for this stub code. */
- s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
-
- /* The last half word of the stub will be filled with the index
- of this symbol in .dynsym section. */
- return true;
- }
- }
-
- /* If this is a weak symbol, and there is a real definition, the
- processor independent code will have arranged for us to see the
- real definition first, and we can just use the same value. */
- if (h->weakdef != NULL)
- {
- BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
- || h->weakdef->root.type == bfd_link_hash_defweak);
- h->root.u.def.section = h->weakdef->root.u.def.section;
- h->root.u.def.value = h->weakdef->root.u.def.value;
- return true;
- }
-
- /* This is a reference to a symbol defined by a dynamic object which
- is not a function. */
-
- return true;
-}
-
-/* Set the sizes of the dynamic sections. */
-
-static boolean
-mips_elf_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *s;
- boolean reltext;
- asection *sgot;
- struct mips_got_info *g;
-
- dynobj = elf_hash_table (info)->dynobj;
- BFD_ASSERT (dynobj != NULL);
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Set the contents of the .interp section to the interpreter. */
- if (! info->shared)
- {
- s = bfd_get_section_by_name (dynobj, ".interp");
- BFD_ASSERT (s != NULL);
- s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
- s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
- }
- }
-
- /* Recompute the size of .got for local entires (reserved and
- hipages) if needed. To estimate it, get the upper bound of total
- size of loadable sections. */
- sgot = bfd_get_section_by_name (dynobj, ".got");
-
- if (sgot != NULL)
- {
- bfd_size_type loadable_size = 0;
- bfd_size_type local_gotno;
- struct _bfd *sub;
-
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
- BFD_ASSERT (g != NULL);
-
- for (sub = info->input_bfds; sub; sub = sub->link_next)
- for (s = sub->sections; s != NULL; s = s->next)
- {
- if ((s->flags & SEC_ALLOC) == 0)
- continue;
- loadable_size += (s->_raw_size + 0xf) & ~0xf;
- }
-
- loadable_size += MIPS_FUNCTION_STUB_SIZE;
-
- /* Assume there are two loadable segments consisting of
- contiguous sections. Is 5 enough? */
- local_gotno = (loadable_size >> 16) + 5 + MIPS_RESERVED_GOTNO;
- g->local_gotno = local_gotno;
- sgot->_raw_size += local_gotno * 4;
- }
-
- /* The check_relocs and adjust_dynamic_symbol entry points have
- determined the sizes of the various dynamic sections. Allocate
- memory for them. */
- reltext = false;
- for (s = dynobj->sections; s != NULL; s = s->next)
- {
- const char *name;
- boolean strip;
-
- /* It's OK to base decisions on the section name, because none
- of the dynobj section names depend upon the input files. */
- name = bfd_get_section_name (dynobj, s);
-
- if ((s->flags & SEC_IN_MEMORY) == 0)
- continue;
-
- strip = false;
-
- if (strncmp (name, ".rel", 4) == 0)
- {
- if (s->_raw_size == 0)
- strip = true;
- else
- {
- asection *target;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL entry.
- If the relocation section is .rel.dyn, we always
- assert a DT_TEXTREL entry rather than testing whether
- there exists a relocation to a read only section or
- not. */
- target = bfd_get_section_by_name (output_bfd, name + 4);
- if ((target != NULL && (target->flags & SEC_READONLY) != 0)
- || strcmp (name, ".rel.dyn") == 0)
- reltext = true;
-
- /* We use the reloc_count field as a counter if we need
- to copy relocs into the output file. */
- if (strcmp (name, ".rel.dyn") != 0)
- s->reloc_count = 0;
- }
- }
- else if (strncmp (name, ".got", 4) == 0)
- {
- int i;
-
- BFD_ASSERT (elf_section_data (s) != NULL);
- g = (struct mips_got_info *) elf_section_data (s)->tdata;
- BFD_ASSERT (g != NULL);
-
- /* Fix the size of .got section for the correspondence of
- global symbols and got entries. This adds some useless
- got entries. Is this required by ABI really? */
- i = elf_hash_table (info)->dynsymcount - g->global_gotsym;
- s->_raw_size += i * 4;
- }
- else if (strncmp (name, ".stub", 5) == 0)
- {
- /* Irix rld assumes that the function stub isn't at the end
- of .text section. So put a dummy. XXX */
- s->_raw_size += MIPS_FUNCTION_STUB_SIZE;
- }
- else if (SGI_COMPAT (output_bfd)
- && strncmp (name, ".compact_rel", 12) == 0)
- s->_raw_size += mips_elf_hash_table (info)->compact_rel_size;
- else if (strncmp (name, ".init", 5) != 0)
- {
- /* It's not one of our sections, so don't allocate space. */
- continue;
- }
-
- if (strip)
- {
- asection **spp;
-
- for (spp = &s->output_section->owner->sections;
- *spp != s->output_section;
- spp = &(*spp)->next)
- ;
- *spp = s->output_section->next;
- --s->output_section->owner->section_count;
-
- continue;
- }
-
- /* Allocate memory for the section contents. */
- s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
- if (s->contents == NULL && s->_raw_size != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- memset (s->contents, 0, s->_raw_size);
- }
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in elf_mips_finish_dynamic_sections, but we
- must add the entries now so that we get the correct size for
- the .dynamic section. The DT_DEBUG entry is filled in by the
- dynamic linker and used by the debugger. */
- if (! info->shared)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
- return false;
- }
-
- if (reltext)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
- return false;
- }
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
- return false;
-
- if (bfd_get_section_by_name (dynobj, ".rel.dyn"))
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELENT, 0))
- return false;
- }
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_CONFLICTNO, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_LIBLISTNO, 0))
- return false;
-
- if (bfd_get_section_by_name (dynobj, ".conflict") != NULL)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_CONFLICT, 0))
- return false;
-
- s = bfd_get_section_by_name (dynobj, ".liblist");
- BFD_ASSERT (s != NULL);
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_LIBLIST, 0))
- return false;
- }
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_RLD_VERSION, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_FLAGS, 0))
- return false;
-
-#if 0
- /* Time stamps in executable files are a bad idea. */
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_TIME_STAMP, 0))
- return false;
-#endif
-
-#if 0 /* FIXME */
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_ICHECKSUM, 0))
- return false;
-#endif
-
-#if 0 /* FIXME */
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_IVERSION, 0))
- return false;
-#endif
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_BASE_ADDRESS, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_LOCAL_GOTNO, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_SYMTABNO, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_UNREFEXTNO, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_GOTSYM, 0))
- return false;
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_MIPS_HIPAGENO, 0))
- return false;
-
-#if 0 /* (SGI_COMPAT) */
- if (! bfd_get_section_by_name (dynobj, ".init"))
- if (! bfd_elf32_add_dynamic_entry (info, DT_INIT, 0))
- return false;
-
- if (! bfd_get_section_by_name (dynobj, ".fini"))
- if (! bfd_elf32_add_dynamic_entry (info, DT_FINI, 0))
- return false;
-#endif
- }
-
- /* If we use dynamic linking, we generate a section symbol for each
- output section. These are local symbols, which means that they
- must come first in the dynamic symbol table.
- That means we must increment the dynamic symbol index of every
- other dynamic symbol. */
- {
- const char * const *namep;
- unsigned int c, i;
- bfd_size_type strindex;
- struct bfd_strtab_hash *dynstr;
- struct mips_got_info *g;
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- if (SGI_COMPAT (output_bfd))
- {
- c = SIZEOF_MIPS_DYNSYM_SECNAMES - 1;
- elf_link_hash_traverse (elf_hash_table (info),
- mips_elf_adjust_dynindx,
- (PTR) &c);
- elf_hash_table (info)->dynsymcount += c;
-
- dynstr = elf_hash_table (info)->dynstr;
- BFD_ASSERT (dynstr != NULL);
-
- for (i = 1, namep = mips_elf_dynsym_sec_names;
- *namep != NULL;
- i++, namep++)
- {
- s = bfd_get_section_by_name (output_bfd, *namep);
- if (s != NULL)
- elf_section_data (s)->dynindx = i;
-
- strindex = _bfd_stringtab_add (dynstr, *namep, true, false);
- if (strindex == (bfd_size_type) -1)
- return false;
-
- mips_elf_hash_table (info)->dynsym_sec_strindex[i] = strindex;
- }
- }
- else
- {
- c = bfd_count_sections (output_bfd);
- elf_link_hash_traverse (elf_hash_table (info),
- mips_elf_adjust_dynindx,
- (PTR) &c);
- elf_hash_table (info)->dynsymcount += c;
-
- for (i = 1, s = output_bfd->sections; s != NULL; s = s->next, i++)
- {
- elf_section_data (s)->dynindx = i;
- /* These symbols will have no names, so we don't need to
- fiddle with dynstr_index. */
- }
- }
- }
-
- s = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (s != NULL);
- BFD_ASSERT (elf_section_data (s) != NULL);
- g = (struct mips_got_info *) elf_section_data (s)->tdata;
- BFD_ASSERT (g != NULL);
-
- /* If there are no global got symbols, fake the last symbol so for
- safety. */
- if (g->global_gotsym)
- g->global_gotsym += c;
- else
- g->global_gotsym = elf_hash_table (info)->dynsymcount - 1;
- }
-
- return true;
-}
-
-/* Increment the index of a dynamic symbol by a given amount. Called
- via elf_link_hash_traverse. */
-
-static boolean
-mips_elf_adjust_dynindx (h, cparg)
- struct elf_link_hash_entry *h;
- PTR cparg;
-{
- unsigned int *cp = (unsigned int *) cparg;
-
- if (h->dynindx != -1)
- h->dynindx += *cp;
- return true;
-}
-
-/* Finish up dynamic symbol handling. We set the contents of various
- dynamic sections here. */
-
-static boolean
-mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
-{
- bfd *dynobj;
- bfd_vma gval;
- asection *sgot;
- struct mips_got_info *g;
- const char *name;
-
- dynobj = elf_hash_table (info)->dynobj;
- gval = sym->st_value;
-
- if (h->plt_offset != (bfd_vma) -1)
- {
- asection *s;
- bfd_byte *p;
- bfd_byte stub[MIPS_FUNCTION_STUB_SIZE];
-
- /* This symbol has a stub. Set it up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- s = bfd_get_section_by_name (dynobj, ".stub");
- BFD_ASSERT (s != NULL);
-
- /* Fill the stub. */
- p = stub;
- bfd_put_32 (output_bfd, STUB_LW(output_bfd), p);
- p += 4;
- bfd_put_32 (output_bfd, STUB_MOVE, p);
- p += 4;
-
- /* FIXME: Can h->dynindex be more than 64K? */
- if (h->dynindx & 0xffff0000)
- return false;
-
- bfd_put_32 (output_bfd, STUB_JALR, p);
- p += 4;
- bfd_put_32 (output_bfd, STUB_LI16 + h->dynindx, p);
-
- BFD_ASSERT (h->plt_offset <= s->_raw_size);
- memcpy (s->contents + h->plt_offset, stub, MIPS_FUNCTION_STUB_SIZE);
-
- /* Mark the symbol as undefined. plt_offset != -1 occurs
- only for the referenced symbol. */
- sym->st_shndx = SHN_UNDEF;
-
- /* The run-time linker uses the st_value field of the symbol
- to reset the global offset table entry for this external
- to its stub address when unlinking a shared object. */
- gval = s->output_section->vma + s->output_offset + h->plt_offset;
- sym->st_value = gval;
- }
-
- BFD_ASSERT (h->dynindx != -1);
-
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
- BFD_ASSERT (g != NULL);
-
- if ((unsigned long) h->dynindx >= g->global_gotsym)
- {
- bfd_size_type offset;
-
- /* This symbol has an entry in the global offset table. Set its
- value to the corresponding got entry, if needed. */
- if (h->got_offset == (bfd_vma) -1)
- {
- offset = (h->dynindx - g->global_gotsym + g->local_gotno) * 4;
- BFD_ASSERT (g->local_gotno * 4 <= offset
- && offset < sgot->_raw_size);
- bfd_put_32 (output_bfd, gval, sgot->contents + offset);
- }
- }
-
- /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
- name = h->root.root.string;
- if (strcmp (name, "_DYNAMIC") == 0
- || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
- sym->st_shndx = SHN_ABS;
- else if (strcmp (name, "_DYNAMIC_LINK") == 0)
- {
- sym->st_shndx = SHN_ABS;
- sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
- sym->st_value = 1;
- }
- else if (SGI_COMPAT (output_bfd))
- {
- if (strcmp (name, "_gp_disp") == 0)
- {
- sym->st_shndx = SHN_ABS;
- sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
- sym->st_value = elf_gp (output_bfd);
- }
- else if (strcmp (name, mips_elf_dynsym_rtproc_names[0]) == 0
- || strcmp (name, mips_elf_dynsym_rtproc_names[1]) == 0)
- {
- sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
- sym->st_other = STO_PROTECTED;
- sym->st_value = 0;
- sym->st_shndx = SHN_MIPS_DATA;
- }
- else if (strcmp (name, mips_elf_dynsym_rtproc_names[2]) == 0)
- {
- sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
- sym->st_other = STO_PROTECTED;
- sym->st_value = mips_elf_hash_table (info)->procedure_count;
- sym->st_shndx = SHN_ABS;
- }
- else if (sym->st_shndx != SHN_UNDEF)
- {
- if (h->type == STT_FUNC)
- sym->st_shndx = SHN_MIPS_TEXT;
- else if (h->type == STT_OBJECT)
- sym->st_shndx = SHN_MIPS_DATA;
- }
- }
-
- return true;
-}
-
-/* Finish up the dynamic sections. */
-
-static boolean
-mips_elf_finish_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *sdyn;
- asection *sgot;
- struct mips_got_info *g;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
-
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
-
- BFD_ASSERT (elf_section_data (sgot) != NULL);
- g = (struct mips_got_info *) elf_section_data (sgot)->tdata;
- BFD_ASSERT (g != NULL);
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- Elf32_External_Dyn *dyncon, *dynconend;
-
- BFD_ASSERT (sdyn != NULL);
-
- dyncon = (Elf32_External_Dyn *) sdyn->contents;
- dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
- for (; dyncon < dynconend; dyncon++)
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- size_t elemsize;
- asection *s;
-
- bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
-
- switch (dyn.d_tag)
- {
- default:
- break;
-
- case DT_RELENT:
- s = bfd_get_section_by_name (dynobj, ".rel.dyn");
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_val = sizeof (Elf32_External_Rel);
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_STRSZ:
- /* Rewrite DT_STRSZ. */
- dyn.d_un.d_val =
- _bfd_stringtab_size (elf_hash_table (info)->dynstr);
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_PLTGOT:
- name = ".got";
- goto get_vma;
- case DT_MIPS_CONFLICT:
- name = ".conflict";
- goto get_vma;
- case DT_MIPS_LIBLIST:
- name = ".liblist";
- get_vma:
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_RLD_VERSION:
- dyn.d_un.d_val = 1; /* XXX */
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_FLAGS:
- dyn.d_un.d_val = RHF_NOTPOT; /* XXX */
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_CONFLICTNO:
- name = ".conflict";
- elemsize = sizeof (Elf32_Conflict);
- goto set_elemno;
-
- case DT_MIPS_LIBLISTNO:
- name = ".liblist";
- elemsize = sizeof (Elf32_Lib);
- set_elemno:
- s = bfd_get_section_by_name (output_bfd, name);
- if (s != NULL)
- {
- if (s->_cooked_size != 0)
- dyn.d_un.d_val = s->_cooked_size / elemsize;
- else
- dyn.d_un.d_val = s->_raw_size / elemsize;
- }
- else
- dyn.d_un.d_val = 0;
-
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_TIME_STAMP:
- time ((time_t *) &dyn.d_un.d_val);
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_ICHECKSUM:
- /* XXX FIXME: */
- break;
-
- case DT_MIPS_IVERSION:
- /* XXX FIXME: */
- break;
-
- case DT_MIPS_BASE_ADDRESS:
- s = output_bfd->sections;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma & ~(0xffff);
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_LOCAL_GOTNO:
- dyn.d_un.d_val = g->local_gotno;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_SYMTABNO:
- name = ".dynsym";
- elemsize = sizeof (Elf32_External_Sym);
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
-
- if (s->_cooked_size != 0)
- dyn.d_un.d_val = s->_cooked_size / elemsize;
- else
- dyn.d_un.d_val = s->_raw_size / elemsize;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_UNREFEXTNO:
- /* XXX FIXME: */
- dyn.d_un.d_val = SIZEOF_MIPS_DYNSYM_SECNAMES;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_GOTSYM:
- dyn.d_un.d_val = g->global_gotsym;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- case DT_MIPS_HIPAGENO:
- dyn.d_un.d_val = g->local_gotno - MIPS_RESERVED_GOTNO;
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- break;
-
- }
- }
- }
-
- /* The first entry of the global offset table will be filled at
- runtime. The second entry will be used by some runtime loaders.
- This isn't the case of Irix rld. */
- if (sgot->_raw_size > 0)
- {
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
- bfd_put_32 (output_bfd, (bfd_vma) 0x80000000, sgot->contents + 4);
- }
-
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
-
- {
- asection *sdynsym;
- asection *s;
- unsigned int i;
- bfd_vma last;
- Elf_Internal_Sym sym;
- long dindx;
- const char *name;
- const char * const * namep = mips_elf_dynsym_sec_names;
- Elf32_compact_rel cpt;
-
- /* Set up the section symbols for the output sections. SGI sets
- the STT_NOTYPE attribute for these symbols. Should we do so? */
-
- sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
- if (sdynsym != NULL)
- {
- if (SGI_COMPAT (output_bfd))
- {
- sym.st_size = 0;
- sym.st_name = 0;
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
- sym.st_other = 0;
-
- i = 0;
- while ((name = *namep++) != NULL)
- {
- s = bfd_get_section_by_name (output_bfd, name);
- if (s != NULL)
- {
- sym.st_value = s->vma;
- dindx = elf_section_data (s)->dynindx;
- last = s->vma + s->_raw_size;
- }
- else
- {
- sym.st_value = last;
- dindx++;
- }
-
- sym.st_shndx = (i < MIPS_TEXT_DYNSYM_SECNO
- ? SHN_MIPS_TEXT
- : SHN_MIPS_DATA);
- ++i;
- sym.st_name =
- mips_elf_hash_table (info)->dynsym_sec_strindex[dindx];
-
- bfd_elf32_swap_symbol_out (output_bfd, &sym,
- (((Elf32_External_Sym *)
- sdynsym->contents)
- + dindx));
- }
-
- /* Set the sh_info field of the output .dynsym section to
- the index of the first global symbol. */
- elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
- SIZEOF_MIPS_DYNSYM_SECNAMES;
- }
- else
- {
- sym.st_size = 0;
- sym.st_name = 0;
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
- sym.st_other = 0;
-
- for (s = output_bfd->sections; s != NULL; s = s->next)
- {
- int indx;
-
- sym.st_value = s->vma;
-
- indx = elf_section_data (s)->this_idx;
- BFD_ASSERT (indx > 0);
- sym.st_shndx = indx;
-
- bfd_elf32_swap_symbol_out (output_bfd, &sym,
- (((Elf32_External_Sym *)
- sdynsym->contents)
- + elf_section_data (s)->dynindx));
- }
-
- /* Set the sh_info field of the output .dynsym section to
- the index of the first global symbol. */
- elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
- bfd_count_sections (output_bfd) + 1;
- }
- }
-
- if (SGI_COMPAT (output_bfd))
- {
- /* Write .compact_rel section out. */
- s = bfd_get_section_by_name (dynobj, ".compact_rel");
- if (s != NULL)
- {
- cpt.id1 = 1;
- cpt.num = s->reloc_count;
- cpt.id2 = 2;
- cpt.offset = (s->output_section->filepos
- + sizeof (Elf32_External_compact_rel));
- cpt.reserved0 = 0;
- cpt.reserved1 = 0;
- bfd_elf32_swap_compact_rel_out (output_bfd, &cpt,
- ((Elf32_External_compact_rel *)
- s->contents));
-
- /* Clean up a dummy stub function entry in .text. */
- s = bfd_get_section_by_name (dynobj, ".stub");
- if (s != NULL)
- {
- file_ptr dummy_offset;
-
- BFD_ASSERT (s->_raw_size >= MIPS_FUNCTION_STUB_SIZE);
- dummy_offset = s->_raw_size - MIPS_FUNCTION_STUB_SIZE;
- memset (s->contents + dummy_offset, 0,
- MIPS_FUNCTION_STUB_SIZE);
- }
- }
- }
-
- /* Clean up a first relocation in .rel.dyn. */
- s = bfd_get_section_by_name (dynobj, ".rel.dyn");
- if (s != NULL)
- memset (s->contents, 0, sizeof (Elf32_External_Rel));
- }
-
- return true;
-}
-
-/* This is almost identical to bfd_generic_get_... except that some
- MIPS relocations need to be handled specially. Sigh. */
-
-static bfd_byte *
-elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data,
- relocateable, symbols)
- bfd *abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- bfd_byte *data;
- boolean relocateable;
- asymbol **symbols;
-{
- /* Get enough memory to hold the stuff */
- bfd *input_bfd = link_order->u.indirect.section->owner;
- asection *input_section = link_order->u.indirect.section;
-
- long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
- arelent **reloc_vector = NULL;
- long reloc_count;
-
- if (reloc_size < 0)
- goto error_return;
-
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
- if (reloc_vector == NULL && reloc_size != 0)
- goto error_return;
-
- /* read in the section */
- if (!bfd_get_section_contents (input_bfd,
- input_section,
- (PTR) data,
- 0,
- input_section->_raw_size))
- goto error_return;
-
- /* We're not relaxing the section, so just copy the size info */
- input_section->_cooked_size = input_section->_raw_size;
- input_section->reloc_done = true;
-
- reloc_count = bfd_canonicalize_reloc (input_bfd,
- input_section,
- reloc_vector,
- symbols);
- if (reloc_count < 0)
- goto error_return;
-
- if (reloc_count > 0)
- {
- arelent **parent;
- /* for mips */
- int gp_found;
- bfd_vma gp = 0x12345678; /* initialize just to shut gcc up */
-
- {
- struct bfd_hash_entry *h;
- struct bfd_link_hash_entry *lh;
- /* Skip all this stuff if we aren't mixing formats. */
- if (abfd && input_bfd
- && abfd->xvec == input_bfd->xvec)
- lh = 0;
- else
- {
- h = bfd_hash_lookup (&link_info->hash->table, "_gp", false, false);
- lh = (struct bfd_link_hash_entry *) h;
- }
- lookup:
- if (lh)
- {
- switch (lh->type)
- {
- case bfd_link_hash_undefined:
- case bfd_link_hash_undefweak:
- case bfd_link_hash_common:
- gp_found = 0;
- break;
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- gp_found = 1;
- gp = lh->u.def.value;
- break;
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- lh = lh->u.i.link;
- /* @@FIXME ignoring warning for now */
- goto lookup;
- case bfd_link_hash_new:
- default:
- abort ();
- }
- }
- else
- gp_found = 0;
- }
- /* end mips */
- for (parent = reloc_vector; *parent != (arelent *) NULL;
- parent++)
- {
- char *error_message = (char *) NULL;
- bfd_reloc_status_type r;
-
- /* Specific to MIPS: Deal with relocation types that require
- knowing the gp of the output bfd. */
- asymbol *sym = *(*parent)->sym_ptr_ptr;
- if (bfd_is_abs_section (sym->section) && abfd)
- {
- /* The special_function wouldn't get called anyways. */
- }
- else if (!gp_found)
- {
- /* The gp isn't there; let the special function code
- fall over on its own. */
- }
- else if ((*parent)->howto->special_function
- == mips_elf_gprel16_reloc)
- {
- /* bypass special_function call */
- r = gprel16_with_gp (input_bfd, sym, *parent, input_section,
- relocateable, (PTR) data, gp);
- goto skip_bfd_perform_relocation;
- }
- /* end mips specific stuff */
-
- r = bfd_perform_relocation (input_bfd,
- *parent,
- (PTR) data,
- input_section,
- relocateable ? abfd : (bfd *) NULL,
- &error_message);
- skip_bfd_perform_relocation:
-
- if (relocateable)
- {
- asection *os = input_section->output_section;
-
- /* A partial link, so keep the relocs */
- os->orelocation[os->reloc_count] = *parent;
- os->reloc_count++;
- }
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- case bfd_reloc_undefined:
- if (!((*link_info->callbacks->undefined_symbol)
- (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
- input_bfd, input_section, (*parent)->address)))
- goto error_return;
- break;
- case bfd_reloc_dangerous:
- BFD_ASSERT (error_message != (char *) NULL);
- if (!((*link_info->callbacks->reloc_dangerous)
- (link_info, error_message, input_bfd, input_section,
- (*parent)->address)))
- goto error_return;
- break;
- case bfd_reloc_overflow:
- if (!((*link_info->callbacks->reloc_overflow)
- (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr),
- (*parent)->howto->name, (*parent)->addend,
- input_bfd, input_section, (*parent)->address)))
- goto error_return;
- break;
- case bfd_reloc_outofrange:
- default:
- abort ();
- break;
- }
-
- }
- }
- }
- if (reloc_vector != NULL)
- free (reloc_vector);
- return data;
-
-error_return:
- if (reloc_vector != NULL)
- free (reloc_vector);
- return NULL;
-}
-#define bfd_elf32_bfd_get_relocated_section_contents \
- elf32_mips_get_relocated_section_contents
-
-/* ECOFF swapping routines. These are used when dealing with the
- .mdebug section, which is in the ECOFF debugging format. */
-static const struct ecoff_debug_swap mips_elf_ecoff_debug_swap =
-{
- /* Symbol table magic number. */
- magicSym,
- /* Alignment of debugging information. E.g., 4. */
- 4,
- /* Sizes of external symbolic information. */
- sizeof (struct hdr_ext),
- sizeof (struct dnr_ext),
- sizeof (struct pdr_ext),
- sizeof (struct sym_ext),
- sizeof (struct opt_ext),
- sizeof (struct fdr_ext),
- sizeof (struct rfd_ext),
- sizeof (struct ext_ext),
- /* Functions to swap in external symbolic data. */
- ecoff_swap_hdr_in,
- ecoff_swap_dnr_in,
- ecoff_swap_pdr_in,
- ecoff_swap_sym_in,
- ecoff_swap_opt_in,
- ecoff_swap_fdr_in,
- ecoff_swap_rfd_in,
- ecoff_swap_ext_in,
- _bfd_ecoff_swap_tir_in,
- _bfd_ecoff_swap_rndx_in,
- /* Functions to swap out external symbolic data. */
- ecoff_swap_hdr_out,
- ecoff_swap_dnr_out,
- ecoff_swap_pdr_out,
- ecoff_swap_sym_out,
- ecoff_swap_opt_out,
- ecoff_swap_fdr_out,
- ecoff_swap_rfd_out,
- ecoff_swap_ext_out,
- _bfd_ecoff_swap_tir_out,
- _bfd_ecoff_swap_rndx_out,
- /* Function to read in symbolic data. */
- mips_elf_read_ecoff_info
-};
-
-#define TARGET_LITTLE_SYM bfd_elf32_littlemips_vec
-#define TARGET_LITTLE_NAME "elf32-littlemips"
-#define TARGET_BIG_SYM bfd_elf32_bigmips_vec
-#define TARGET_BIG_NAME "elf32-bigmips"
-#define ELF_ARCH bfd_arch_mips
-#define ELF_MACHINE_CODE EM_MIPS
-#define ELF_MAXPAGESIZE 0x10000
-#define elf_backend_collect true
-#define elf_backend_type_change_ok true
-#define elf_info_to_howto 0
-#define elf_info_to_howto_rel mips_info_to_howto_rel
-#define elf_backend_sym_is_global mips_elf_sym_is_global
-#define elf_backend_object_p mips_elf_object_p
-#define elf_backend_section_from_shdr mips_elf_section_from_shdr
-#define elf_backend_fake_sections mips_elf_fake_sections
-#define elf_backend_section_from_bfd_section \
- mips_elf_section_from_bfd_section
-#define elf_backend_section_processing mips_elf_section_processing
-#define elf_backend_symbol_processing mips_elf_symbol_processing
-#define elf_backend_additional_program_headers \
- mips_elf_additional_program_headers
-#define elf_backend_modify_segment_map mips_elf_modify_segment_map
-#define elf_backend_final_write_processing \
- mips_elf_final_write_processing
-#define elf_backend_ecoff_debug_swap &mips_elf_ecoff_debug_swap
-
-#define bfd_elf32_bfd_is_local_label mips_elf_is_local_label
-#define bfd_elf32_find_nearest_line mips_elf_find_nearest_line
-
-#define bfd_elf32_bfd_link_hash_table_create \
- mips_elf_link_hash_table_create
-#define bfd_elf32_bfd_final_link mips_elf_final_link
-#define bfd_elf32_bfd_copy_private_bfd_data \
- mips_elf_copy_private_bfd_data
-#define bfd_elf32_bfd_merge_private_bfd_data \
- mips_elf_merge_private_bfd_data
-#define bfd_elf32_bfd_set_private_flags mips_elf_set_private_flags
-#define elf_backend_add_symbol_hook mips_elf_add_symbol_hook
-#define elf_backend_create_dynamic_sections \
- mips_elf_create_dynamic_sections
-#define elf_backend_check_relocs mips_elf_check_relocs
-#define elf_backend_adjust_dynamic_symbol \
- mips_elf_adjust_dynamic_symbol
-#define elf_backend_size_dynamic_sections \
- mips_elf_size_dynamic_sections
-#define elf_backend_relocate_section mips_elf_relocate_section
-#define elf_backend_finish_dynamic_symbol \
- mips_elf_finish_dynamic_symbol
-#define elf_backend_finish_dynamic_sections \
- mips_elf_finish_dynamic_sections
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32-ppc.c b/contrib/gdb/bfd/elf32-ppc.c
deleted file mode 100644
index a8e5ad3..0000000
--- a/contrib/gdb/bfd/elf32-ppc.c
+++ /dev/null
@@ -1,2554 +0,0 @@
-/* PowerPC-specific support for 32-bit ELF
- Copyright 1994, 1995, 1996 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file is based on a preliminary PowerPC ELF ABI. The
- information may not match the final PowerPC ELF ABI. It includes
- suggestions from the in-progress Embedded PowerPC ABI, and that
- information may also not match. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-#include "elf/ppc.h"
-
-#define USE_RELA /* we want RELA relocations, not REL */
-
-/* PowerPC relocations defined by the ABIs */
-enum ppc_reloc_type
-{
- R_PPC_NONE = 0,
- R_PPC_ADDR32 = 1,
- R_PPC_ADDR24 = 2,
- R_PPC_ADDR16 = 3,
- R_PPC_ADDR16_LO = 4,
- R_PPC_ADDR16_HI = 5,
- R_PPC_ADDR16_HA = 6,
- R_PPC_ADDR14 = 7,
- R_PPC_ADDR14_BRTAKEN = 8,
- R_PPC_ADDR14_BRNTAKEN = 9,
- R_PPC_REL24 = 10,
- R_PPC_REL14 = 11,
- R_PPC_REL14_BRTAKEN = 12,
- R_PPC_REL14_BRNTAKEN = 13,
- R_PPC_GOT16 = 14,
- R_PPC_GOT16_LO = 15,
- R_PPC_GOT16_HI = 16,
- R_PPC_GOT16_HA = 17,
- R_PPC_PLTREL24 = 18,
- R_PPC_COPY = 19,
- R_PPC_GLOB_DAT = 20,
- R_PPC_JMP_SLOT = 21,
- R_PPC_RELATIVE = 22,
- R_PPC_LOCAL24PC = 23,
- R_PPC_UADDR32 = 24,
- R_PPC_UADDR16 = 25,
- R_PPC_REL32 = 26,
- R_PPC_PLT32 = 27,
- R_PPC_PLTREL32 = 28,
- R_PPC_PLT16_LO = 29,
- R_PPC_PLT16_HI = 30,
- R_PPC_PLT16_HA = 31,
- R_PPC_SDAREL16 = 32,
- R_PPC_SECTOFF = 33,
- R_PPC_SECTOFF_LO = 34,
- R_PPC_SECTOFF_HI = 35,
- R_PPC_SECTOFF_HA = 36,
-
- /* The remaining relocs are from the Embedded ELF ABI, and are not
- in the SVR4 ELF ABI. */
- R_PPC_EMB_NADDR32 = 101,
- R_PPC_EMB_NADDR16 = 102,
- R_PPC_EMB_NADDR16_LO = 103,
- R_PPC_EMB_NADDR16_HI = 104,
- R_PPC_EMB_NADDR16_HA = 105,
- R_PPC_EMB_SDAI16 = 106,
- R_PPC_EMB_SDA2I16 = 107,
- R_PPC_EMB_SDA2REL = 108,
- R_PPC_EMB_SDA21 = 109,
- R_PPC_EMB_MRKREF = 110,
- R_PPC_EMB_RELSEC16 = 111,
- R_PPC_EMB_RELST_LO = 112,
- R_PPC_EMB_RELST_HI = 113,
- R_PPC_EMB_RELST_HA = 114,
- R_PPC_EMB_BIT_FLD = 115,
- R_PPC_EMB_RELSDA = 116,
-
- /* This is a phony reloc to handle any old fashioned TOC16 references
- that may still be in object files. */
- R_PPC_TOC16 = 255,
-
- R_PPC_max
-};
-
-static reloc_howto_type *ppc_elf_reloc_type_lookup
- PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-static void ppc_elf_info_to_howto
- PARAMS ((bfd *abfd, arelent *cache_ptr, Elf32_Internal_Rela *dst));
-static void ppc_elf_howto_init PARAMS ((void));
-static boolean ppc_elf_set_private_flags PARAMS ((bfd *, flagword));
-static boolean ppc_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
-
-static int ppc_elf_additional_program_headers PARAMS ((bfd *));
-static boolean ppc_elf_modify_segment_map PARAMS ((bfd *));
-
-static boolean ppc_elf_section_from_shdr PARAMS ((bfd *,
- Elf32_Internal_Shdr *,
- char *));
-
-static elf_linker_section_t *ppc_elf_create_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- enum elf_linker_section_enum));
-
-static boolean ppc_elf_check_relocs PARAMS ((bfd *,
- struct bfd_link_info *,
- asection *,
- const Elf_Internal_Rela *));
-
-static boolean ppc_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *,
- struct elf_link_hash_entry *));
-
-static boolean ppc_elf_adjust_dynindx PARAMS ((struct elf_link_hash_entry *, PTR));
-
-static boolean ppc_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
-
-static boolean ppc_elf_relocate_section PARAMS ((bfd *,
- struct bfd_link_info *info,
- bfd *,
- asection *,
- bfd_byte *,
- Elf_Internal_Rela *relocs,
- Elf_Internal_Sym *local_syms,
- asection **));
-
-static boolean ppc_elf_add_symbol_hook PARAMS ((bfd *,
- struct bfd_link_info *,
- const Elf_Internal_Sym *,
- const char **,
- flagword *,
- asection **,
- bfd_vma *));
-
-static boolean ppc_elf_finish_dynamic_symbol PARAMS ((bfd *,
- struct bfd_link_info *,
- struct elf_link_hash_entry *,
- Elf_Internal_Sym *));
-
-static boolean ppc_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
-
-#define BRANCH_PREDICT_BIT 0x200000 /* branch prediction bit for branch taken relocs */
-#define RA_REGISTER_MASK 0x001f0000 /* mask to set RA in memory instructions */
-#define RA_REGISTER_SHIFT 16 /* value to shift register by to insert RA */
-
-/* The name of the dynamic interpreter. This is put in the .interp
- section. */
-
-#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
-
-
-static reloc_howto_type *ppc_elf_howto_table[ (int)R_PPC_max ];
-
-static reloc_howto_type ppc_elf_howto_raw[] =
-{
- /* This reloc does nothing. */
- HOWTO (R_PPC_NONE, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_NONE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A standard 32 bit relocation. */
- HOWTO (R_PPC_ADDR32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR32", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* An absolute 26 bit branch; the lower two bits must be zero.
- FIXME: we don't check that, we just clear them. */
- HOWTO (R_PPC_ADDR24, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR24", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0x3fffffc, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A standard 16 bit relocation. */
- HOWTO (R_PPC_ADDR16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 16 bit relocation without overflow. */
- HOWTO (R_PPC_ADDR16_LO, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont,/* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR16_LO", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* The high order 16 bits of an address. */
- HOWTO (R_PPC_ADDR16_HI, /* type */
- 16, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR16_HI", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* The high order 16 bits of an address, plus 1 if the contents of
- the low 16 bits, treated as a signed number, is negative. */
- HOWTO (R_PPC_ADDR16_HA, /* type */
- 16, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR16_HA", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* An absolute 16 bit branch; the lower two bits must be zero.
- FIXME: we don't check that, we just clear them. */
- HOWTO (R_PPC_ADDR14, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR14", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xfffc, /* dst_mask */
- false), /* pcrel_offset */
-
- /* An absolute 16 bit branch, for which bit 10 should be set to
- indicate that the branch is expected to be taken. The lower two
- bits must be zero. */
- HOWTO (R_PPC_ADDR14_BRTAKEN, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR14_BRTAKEN",/* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xfffc, /* dst_mask */
- false), /* pcrel_offset */
-
- /* An absolute 16 bit branch, for which bit 10 should be set to
- indicate that the branch is not expected to be taken. The lower
- two bits must be zero. */
- HOWTO (R_PPC_ADDR14_BRNTAKEN, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_ADDR14_BRNTAKEN",/* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xfffc, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A relative 26 bit branch; the lower two bits must be zero. */
- HOWTO (R_PPC_REL24, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_REL24", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0x3fffffc, /* dst_mask */
- true), /* pcrel_offset */
-
- /* A relative 16 bit branch; the lower two bits must be zero. */
- HOWTO (R_PPC_REL14, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_REL14", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xfffc, /* dst_mask */
- true), /* pcrel_offset */
-
- /* A relative 16 bit branch. Bit 10 should be set to indicate that
- the branch is expected to be taken. The lower two bits must be
- zero. */
- HOWTO (R_PPC_REL14_BRTAKEN, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_REL14_BRTAKEN", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xfffc, /* dst_mask */
- true), /* pcrel_offset */
-
- /* A relative 16 bit branch. Bit 10 should be set to indicate that
- the branch is not expected to be taken. The lower two bits must
- be zero. */
- HOWTO (R_PPC_REL14_BRNTAKEN, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_REL14_BRNTAKEN",/* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xfffc, /* dst_mask */
- true), /* pcrel_offset */
-
- /* Like R_PPC_ADDR16, but referring to the GOT table entry for the
- symbol. */
- HOWTO (R_PPC_GOT16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_GOT16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_ADDR16_LO, but referring to the GOT table entry for
- the symbol. */
- HOWTO (R_PPC_GOT16_LO, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_GOT16_LO", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_ADDR16_HI, but referring to the GOT table entry for
- the symbol. */
- HOWTO (R_PPC_GOT16_HI, /* type */
- 16, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_GOT16_HI", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_ADDR16_HA, but referring to the GOT table entry for
- the symbol. */
- HOWTO (R_PPC_GOT16_HA, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_GOT16_HA", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_REL24, but referring to the procedure linkage table
- entry for the symbol. FIXME: Not supported. */
- HOWTO (R_PPC_PLTREL24, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_PLTREL24", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0x3fffffc, /* dst_mask */
- true), /* pcrel_offset */
-
- /* This is used only by the dynamic linker. The symbol should exist
- both in the object being run and in some shared library. The
- dynamic linker copies the data addressed by the symbol from the
- shared library into the object. I have no idea what the purpose
- of this is. */
- HOWTO (R_PPC_COPY, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_COPY", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_ADDR32, but used when setting global offset table
- entries. */
- HOWTO (R_PPC_GLOB_DAT, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_GLOB_DAT", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Marks a procedure linkage table entry for a symbol. */
- HOWTO (R_PPC_JMP_SLOT, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_JMP_SLOT", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Used only by the dynamic linker. When the object is run, this
- longword is set to the load address of the object, plus the
- addend. */
- HOWTO (R_PPC_RELATIVE, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_RELATIVE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_REL24, but uses the value of the symbol within the
- object rather than the final value. Normally used for
- _GLOBAL_OFFSET_TABLE_. FIXME: Not supported. */
- HOWTO (R_PPC_LOCAL24PC, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_LOCAL24PC", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0x3fffffc, /* dst_mask */
- true), /* pcrel_offset */
-
- /* Like R_PPC_ADDR32, but may be unaligned. */
- HOWTO (R_PPC_UADDR32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_UADDR32", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_ADDR16, but may be unaligned. */
- HOWTO (R_PPC_UADDR16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_UADDR16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32-bit PC relative */
- HOWTO (R_PPC_REL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_REL32", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* 32-bit relocation to the symbol's procedure linkage table.
- FIXEME: not supported. */
- HOWTO (R_PPC_PLT32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_PLT32", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32-bit PC relative relocation to the symbol's procedure linkage table.
- FIXEME: not supported. */
- HOWTO (R_PPC_PLTREL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_PLTREL32", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- true), /* pcrel_offset */
-
- /* Like R_PPC_ADDR16_LO, but referring to the PLT table entry for
- the symbol. */
- HOWTO (R_PPC_PLT16_LO, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_PLT16_LO", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_ADDR16_HI, but referring to the PLT table entry for
- the symbol. */
- HOWTO (R_PPC_PLT16_HI, /* type */
- 16, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_PLT16_HI", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Like R_PPC_ADDR16_HA, but referring to the PLT table entry for
- the symbol. FIXME: Not supported. */
- HOWTO (R_PPC_PLT16_HA, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_PLT16_HA", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A sign-extended 16 bit value relative to _SDA_BASE_, for use with
- small data items. */
- HOWTO (R_PPC_SDAREL16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_SDAREL16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32-bit section relative relocation. */
- HOWTO (R_PPC_SECTOFF, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_SECTOFF", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- true), /* pcrel_offset */
-
- /* 16-bit lower half section relative relocation. */
- HOWTO (R_PPC_SECTOFF_LO, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_SECTOFF_LO", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16-bit upper half section relative relocation. */
- HOWTO (R_PPC_SECTOFF_HI, /* type */
- 16, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_SECTOFF_HI", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16-bit upper half adjusted section relative relocation. */
- HOWTO (R_PPC_SECTOFF_HA, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_SECTOFF_HA", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* The remaining relocs are from the Embedded ELF ABI, and are not
- in the SVR4 ELF ABI. */
-
- /* 32 bit value resulting from the addend minus the symbol */
- HOWTO (R_PPC_EMB_NADDR32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_NADDR32", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit value resulting from the addend minus the symbol */
- HOWTO (R_PPC_EMB_NADDR16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_NADDR16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit value resulting from the addend minus the symbol */
- HOWTO (R_PPC_EMB_NADDR16_LO, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont,/* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_ADDR16_LO", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* The high order 16 bits of the addend minus the symbol */
- HOWTO (R_PPC_EMB_NADDR16_HI, /* type */
- 16, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_NADDR16_HI", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* The high order 16 bits of the result of the addend minus the address,
- plus 1 if the contents of the low 16 bits, treated as a signed number,
- is negative. */
- HOWTO (R_PPC_EMB_NADDR16_HA, /* type */
- 16, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_NADDR16_HA", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit value resulting from allocating a 4 byte word to hold an
- address in the .sdata section, and returning the offset from
- _SDA_BASE_ for that relocation */
- HOWTO (R_PPC_EMB_SDAI16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_SDAI16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit value resulting from allocating a 4 byte word to hold an
- address in the .sdata2 section, and returning the offset from
- _SDA2_BASE_ for that relocation */
- HOWTO (R_PPC_EMB_SDA2I16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_SDA2I16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A sign-extended 16 bit value relative to _SDA2_BASE_, for use with
- small data items. */
- HOWTO (R_PPC_EMB_SDA2REL, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_SDA2REL", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Relocate against either _SDA_BASE_ or _SDA2_BASE_, filling in the 16 bit
- signed offset from the appropriate base, and filling in the register
- field with the appropriate register (0, 2, or 13). */
- HOWTO (R_PPC_EMB_SDA21, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_SDA21", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Relocation not handled: R_PPC_EMB_MRKREF */
- /* Relocation not handled: R_PPC_EMB_RELSEC16 */
- /* Relocation not handled: R_PPC_EMB_RELST_LO */
- /* Relocation not handled: R_PPC_EMB_RELST_HI */
- /* Relocation not handled: R_PPC_EMB_RELST_HA */
- /* Relocation not handled: R_PPC_EMB_BIT_FLD */
-
- /* PC relative relocation against either _SDA_BASE_ or _SDA2_BASE_, filling
- in the 16 bit signed offset from the appropriate base, and filling in the
- register field with the appropriate register (0, 2, or 13). */
- HOWTO (R_PPC_EMB_RELSDA, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_EMB_RELSDA", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Phony reloc to handle AIX style TOC entries */
- HOWTO (R_PPC_TOC16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_PPC_TOC16", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-};
-
-
-/* Initialize the ppc_elf_howto_table, so that linear accesses can be done. */
-
-static void
-ppc_elf_howto_init ()
-{
- unsigned int i, type;
-
- for (i = 0; i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); i++)
- {
- type = ppc_elf_howto_raw[i].type;
- BFD_ASSERT (type < sizeof(ppc_elf_howto_table) / sizeof(ppc_elf_howto_table[0]));
- ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i];
- }
-}
-
-
-static reloc_howto_type *
-ppc_elf_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- enum ppc_reloc_type ppc_reloc = R_PPC_NONE;
-
- if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
- ppc_elf_howto_init ();
-
- switch ((int)code)
- {
- default:
- return (reloc_howto_type *)NULL;
-
- case BFD_RELOC_NONE: ppc_reloc = R_PPC_NONE; break;
- case BFD_RELOC_32: ppc_reloc = R_PPC_ADDR32; break;
- case BFD_RELOC_PPC_BA26: ppc_reloc = R_PPC_ADDR24; break;
- case BFD_RELOC_16: ppc_reloc = R_PPC_ADDR16; break;
- case BFD_RELOC_LO16: ppc_reloc = R_PPC_ADDR16_LO; break;
- case BFD_RELOC_HI16: ppc_reloc = R_PPC_ADDR16_HI; break;
- case BFD_RELOC_HI16_S: ppc_reloc = R_PPC_ADDR16_HA; break;
- case BFD_RELOC_PPC_BA16: ppc_reloc = R_PPC_ADDR14; break;
- case BFD_RELOC_PPC_BA16_BRTAKEN: ppc_reloc = R_PPC_ADDR14_BRTAKEN; break;
- case BFD_RELOC_PPC_BA16_BRNTAKEN: ppc_reloc = R_PPC_ADDR14_BRNTAKEN; break;
- case BFD_RELOC_PPC_B26: ppc_reloc = R_PPC_REL24; break;
- case BFD_RELOC_PPC_B16: ppc_reloc = R_PPC_REL14; break;
- case BFD_RELOC_PPC_B16_BRTAKEN: ppc_reloc = R_PPC_REL14_BRTAKEN; break;
- case BFD_RELOC_PPC_B16_BRNTAKEN: ppc_reloc = R_PPC_REL14_BRNTAKEN; break;
- case BFD_RELOC_16_GOTOFF: ppc_reloc = R_PPC_GOT16; break;
- case BFD_RELOC_LO16_GOTOFF: ppc_reloc = R_PPC_GOT16_LO; break;
- case BFD_RELOC_HI16_GOTOFF: ppc_reloc = R_PPC_GOT16_HI; break;
- case BFD_RELOC_HI16_S_GOTOFF: ppc_reloc = R_PPC_GOT16_HA; break;
- case BFD_RELOC_24_PLT_PCREL: ppc_reloc = R_PPC_PLTREL24; break;
- case BFD_RELOC_PPC_COPY: ppc_reloc = R_PPC_COPY; break;
- case BFD_RELOC_PPC_GLOB_DAT: ppc_reloc = R_PPC_GLOB_DAT; break;
- case BFD_RELOC_PPC_LOCAL24PC: ppc_reloc = R_PPC_LOCAL24PC; break;
- case BFD_RELOC_32_PCREL: ppc_reloc = R_PPC_REL32; break;
- case BFD_RELOC_32_PLTOFF: ppc_reloc = R_PPC_PLT32; break;
- case BFD_RELOC_32_PLT_PCREL: ppc_reloc = R_PPC_PLTREL32; break;
- case BFD_RELOC_LO16_PLTOFF: ppc_reloc = R_PPC_PLT16_LO; break;
- case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC_PLT16_HI; break;
- case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC_PLT16_HA; break;
- case BFD_RELOC_GPREL16: ppc_reloc = R_PPC_SDAREL16; break;
- case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC_SECTOFF; break;
- case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC_SECTOFF_LO; break;
- case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC_SECTOFF_HI; break;
- case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC_SECTOFF_HA; break;
- case BFD_RELOC_CTOR: ppc_reloc = R_PPC_ADDR32; break;
- case BFD_RELOC_PPC_TOC16: ppc_reloc = R_PPC_TOC16; break;
- case BFD_RELOC_PPC_EMB_NADDR32: ppc_reloc = R_PPC_EMB_NADDR32; break;
- case BFD_RELOC_PPC_EMB_NADDR16: ppc_reloc = R_PPC_EMB_NADDR16; break;
- case BFD_RELOC_PPC_EMB_NADDR16_LO: ppc_reloc = R_PPC_EMB_NADDR16_LO; break;
- case BFD_RELOC_PPC_EMB_NADDR16_HI: ppc_reloc = R_PPC_EMB_NADDR16_HI; break;
- case BFD_RELOC_PPC_EMB_NADDR16_HA: ppc_reloc = R_PPC_EMB_NADDR16_HA; break;
- case BFD_RELOC_PPC_EMB_SDAI16: ppc_reloc = R_PPC_EMB_SDAI16; break;
- case BFD_RELOC_PPC_EMB_SDA2I16: ppc_reloc = R_PPC_EMB_SDA2I16; break;
- case BFD_RELOC_PPC_EMB_SDA2REL: ppc_reloc = R_PPC_EMB_SDA2REL; break;
- case BFD_RELOC_PPC_EMB_SDA21: ppc_reloc = R_PPC_EMB_SDA21; break;
- case BFD_RELOC_PPC_EMB_MRKREF: ppc_reloc = R_PPC_EMB_MRKREF; break;
- case BFD_RELOC_PPC_EMB_RELSEC16: ppc_reloc = R_PPC_EMB_RELSEC16; break;
- case BFD_RELOC_PPC_EMB_RELST_LO: ppc_reloc = R_PPC_EMB_RELST_LO; break;
- case BFD_RELOC_PPC_EMB_RELST_HI: ppc_reloc = R_PPC_EMB_RELST_HI; break;
- case BFD_RELOC_PPC_EMB_RELST_HA: ppc_reloc = R_PPC_EMB_RELST_HA; break;
- case BFD_RELOC_PPC_EMB_BIT_FLD: ppc_reloc = R_PPC_EMB_BIT_FLD; break;
- case BFD_RELOC_PPC_EMB_RELSDA: ppc_reloc = R_PPC_EMB_RELSDA; break;
- }
-
- return ppc_elf_howto_table[ (int)ppc_reloc ];
-};
-
-/* Set the howto pointer for a PowerPC ELF reloc. */
-
-static void
-ppc_elf_info_to_howto (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf32_Internal_Rela *dst;
-{
- if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
- ppc_elf_howto_init ();
-
- BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max);
- cache_ptr->howto = ppc_elf_howto_table[ELF32_R_TYPE (dst->r_info)];
-}
-
-/* Function to set whether a module needs the -mrelocatable bit set. */
-
-static boolean
-ppc_elf_set_private_flags (abfd, flags)
- bfd *abfd;
- flagword flags;
-{
- BFD_ASSERT (!elf_flags_init (abfd)
- || elf_elfheader (abfd)->e_flags == flags);
-
- elf_elfheader (abfd)->e_flags = flags;
- elf_flags_init (abfd) = true;
- return true;
-}
-
-/* Copy backend specific data from one object module to another */
-static boolean
-ppc_elf_copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- /* This function is selected based on the input vector. We only
- want to copy information over if the output BFD also uses Elf
- format. */
- if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return true;
-
- BFD_ASSERT (!elf_flags_init (obfd)
- || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
-
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = true;
- return true;
-}
-
-/* Merge backend specific data from an object file to the output
- object file when linking */
-static boolean
-ppc_elf_merge_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- flagword old_flags;
- flagword new_flags;
- boolean error;
-
- /* Check if we have the same endianess */
- if (ibfd->xvec->byteorder != obfd->xvec->byteorder
- && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
- {
- (*_bfd_error_handler)
- ("%s: compiled for a %s endian system and target is %s endian",
- bfd_get_filename (ibfd),
- bfd_big_endian (ibfd) ? "big" : "little",
- bfd_big_endian (obfd) ? "big" : "little");
-
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-
- /* This function is selected based on the input vector. We only
- want to copy information over if the output BFD also uses Elf
- format. */
- if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return true;
-
- new_flags = elf_elfheader (ibfd)->e_flags;
- old_flags = elf_elfheader (obfd)->e_flags;
- if (!elf_flags_init (obfd)) /* First call, no flags set */
- {
- elf_flags_init (obfd) = true;
- elf_elfheader (obfd)->e_flags = new_flags;
- }
-
- else if (new_flags == old_flags) /* Compatible flags are ok */
- ;
-
- else /* Incompatible flags */
- {
- /* Warn about -mrelocatable mismatch. Allow -mrelocatable-lib to be linked
- with either. */
- error = false;
- if ((new_flags & EF_PPC_RELOCATABLE) != 0
- && (old_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0)
- {
- error = true;
- (*_bfd_error_handler)
- ("%s: compiled with -mrelocatable and linked with modules compiled normally",
- bfd_get_filename (ibfd));
- }
- else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0
- && (old_flags & EF_PPC_RELOCATABLE) != 0)
- {
- error = true;
- (*_bfd_error_handler)
- ("%s: compiled normally and linked with modules compiled with -mrelocatable",
- bfd_get_filename (ibfd));
- }
- else if ((new_flags & EF_PPC_RELOCATABLE_LIB) != 0)
- elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE_LIB;
-
-
- /* Do not warn about eabi vs. V.4 mismatch, just or in the bit if any module uses it */
- elf_elfheader (obfd)->e_flags |= (new_flags & EF_PPC_EMB);
-
- new_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB);
- old_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB);
-
- /* Warn about any other mismatches */
- if (new_flags != old_flags)
- {
- error = true;
- (*_bfd_error_handler)
- ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
- bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
- }
-
- if (error)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- }
-
- return true;
-}
-
-
-/* Handle a PowerPC specific section when reading an object file. This
- is called when elfcode.h finds a section with an unknown type. */
-
-static boolean
-ppc_elf_section_from_shdr (abfd, hdr, name)
- bfd *abfd;
- Elf32_Internal_Shdr *hdr;
- char *name;
-{
- asection *newsect;
- flagword flags;
-
- if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
- return false;
-
- newsect = hdr->bfd_section;
- flags = bfd_get_section_flags (abfd, newsect);
- if (hdr->sh_flags & SHF_EXCLUDE)
- flags |= SEC_EXCLUDE;
-
- if (hdr->sh_type == SHT_ORDERED)
- flags |= SEC_SORT_ENTRIES;
-
- bfd_set_section_flags (abfd, newsect, flags);
- return true;
-}
-
-
-/* Set up any other section flags and such that may be necessary. */
-
-boolean
-ppc_elf_fake_sections (abfd, shdr, asect)
- bfd *abfd;
- Elf32_Internal_Shdr *shdr;
- asection *asect;
-{
- if ((asect->flags & SEC_EXCLUDE) != 0)
- shdr->sh_flags |= SHF_EXCLUDE;
-
- if ((asect->flags & SEC_SORT_ENTRIES) != 0)
- shdr->sh_type = SHT_ORDERED;
-}
-
-
-/* Create a special linker section */
-static elf_linker_section_t *
-ppc_elf_create_linker_section (abfd, info, which)
- bfd *abfd;
- struct bfd_link_info *info;
- enum elf_linker_section_enum which;
-{
- bfd *dynobj = elf_hash_table (info)->dynobj;
- elf_linker_section_t *lsect;
-
- /* Record the first bfd section that needs the special section */
- if (!dynobj)
- dynobj = elf_hash_table (info)->dynobj = abfd;
-
- /* If this is the first time, create the section */
- lsect = elf_linker_section (dynobj, which);
- if (!lsect)
- {
- elf_linker_section_t defaults;
- static elf_linker_section_t zero_section;
-
- defaults = zero_section;
- defaults.which = which;
- defaults.hole_written_p = false;
- defaults.alignment = 2;
- defaults.flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- switch (which)
- {
- default:
- (*_bfd_error_handler) ("%s: Unknown special linker type %d",
- bfd_get_filename (abfd),
- (int)which);
-
- bfd_set_error (bfd_error_bad_value);
- return (elf_linker_section_t *)0;
-
- case LINKER_SECTION_GOT: /* .got section */
- defaults.name = ".got";
- defaults.rel_name = ".rela.got";
- defaults.sym_name = "_GLOBAL_OFFSET_TABLE_";
- defaults.max_hole_offset = 32764;
- defaults.hole_size = 16;
- defaults.sym_offset = 4;
- break;
-
- case LINKER_SECTION_SDATA: /* .sdata/.sbss section */
- defaults.name = ".sdata";
- defaults.rel_name = ".rela.sdata";
- defaults.bss_name = ".sbss";
- defaults.sym_name = "_SDA_BASE_";
- defaults.sym_offset = 32768;
- break;
-
- case LINKER_SECTION_SDATA2: /* .sdata2/.sbss2 section */
- defaults.name = ".sdata2";
- defaults.rel_name = ".rela.sdata2";
- defaults.bss_name = ".sbss2";
- defaults.sym_name = "_SDA2_BASE_";
- defaults.sym_offset = 32768;
- defaults.flags |= SEC_READONLY;
- break;
- }
-
- lsect = _bfd_elf_create_linker_section (abfd, info, which, &defaults);
- }
-
- return lsect;
-}
-
-
-/* If we have a non-zero sized .sbss2 or .PPC.EMB.sbss0 sections, we need to bump up
- the number of section headers. */
-
-static int
-ppc_elf_additional_program_headers (abfd)
- bfd *abfd;
-{
- asection *s;
- int ret;
-
- ret = 0;
-
- s = bfd_get_section_by_name (abfd, ".sbss2");
- if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0)
- ++ret;
-
- s = bfd_get_section_by_name (abfd, ".PPC.EMB.sbss0");
- if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0)
- ++ret;
-
- return ret;
-}
-
-/* Modify the segment map if needed */
-
-static boolean
-ppc_elf_modify_segment_map (abfd)
- bfd *abfd;
-{
- return true;
-}
-
-/* Adjust a symbol defined by a dynamic object and referenced by a
- regular object. The current definition is in some section of the
- dynamic object, but we're not including those sections. We have to
- change the definition to something the rest of the link can
- understand. */
-
-static boolean
-ppc_elf_adjust_dynamic_symbol (info, h)
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
-{
-#ifdef DEBUG
- fprintf (stderr, "ppc_elf_adjust_dynamic_symbol called\n");
-#endif
- return true;
-}
-
-
-/* Increment the index of a dynamic symbol by a given amount. Called
- via elf_link_hash_traverse. */
-
-static boolean
-ppc_elf_adjust_dynindx (h, cparg)
- struct elf_link_hash_entry *h;
- PTR cparg;
-{
- int *cp = (int *) cparg;
-
-#ifdef DEBUG
- fprintf (stderr, "ppc_elf_adjust_dynindx called, h->dynindx = %d, *cp = %d\n", h->dynindx, *cp);
-#endif
-
- if (h->dynindx != -1)
- h->dynindx += *cp;
-
- return true;
-}
-
-
-/* Set the sizes of the dynamic sections. */
-
-static boolean
-ppc_elf_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *s;
- boolean reltext;
- boolean relplt;
-
-#ifdef DEBUG
- fprintf (stderr, "ppc_elf_size_dynamic_sections called\n");
-#endif
-
- dynobj = elf_hash_table (info)->dynobj;
- BFD_ASSERT (dynobj != NULL);
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Set the contents of the .interp section to the interpreter. */
- if (! info->shared)
- {
- s = bfd_get_section_by_name (dynobj, ".interp");
- BFD_ASSERT (s != NULL);
- s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
- s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
- }
-
- /* Make space for the trailing nop in .plt. */
- s = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (s != NULL);
- if (s->_raw_size > 0)
- s->_raw_size += 4;
- }
- else
- {
- /* We may have created entries in the .rela.got, .rela.sdata, and
- .rela.sdata2 section2. However, if we are not creating the
- dynamic sections, we will not actually use these entries. Reset
- the size of .rela.got, et al, which will cause it to get
- stripped from the output file below. */
- static char *rela_sections[] = { ".rela.got", ".rela.sdata", ".rela.sdata", (char *)0 };
- char **p;
-
- for (p = rela_sections; *p != (char *)0; p++)
- {
- s = bfd_get_section_by_name (dynobj, *p);
- if (s != NULL)
- s->_raw_size = 0;
- }
- }
-
- /* The check_relocs and adjust_dynamic_symbol entry points have
- determined the sizes of the various dynamic sections. Allocate
- memory for them. */
- reltext = false;
- relplt = false;
- for (s = dynobj->sections; s != NULL; s = s->next)
- {
- const char *name;
- boolean strip;
-
- if ((s->flags & SEC_IN_MEMORY) == 0)
- continue;
-
- /* It's OK to base decisions on the section name, because none
- of the dynobj section names depend upon the input files. */
- name = bfd_get_section_name (dynobj, s);
-
- strip = false;
-
-#if 0
- if (strncmp (name, ".rela", 5) == 0)
- {
- if (s->_raw_size == 0)
- {
- /* If we don't need this section, strip it from the
- output file. This is to handle .rela.bss and
- .rel.plt. We must create it in
- create_dynamic_sections, because it must be created
- before the linker maps input sections to output
- sections. The linker does that before
- adjust_dynamic_symbol is called, and it is that
- function which decides whether anything needs to go
- into these sections. */
- strip = true;
- }
- else
- {
- asection *target;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL entry. */
- target = bfd_get_section_by_name (output_bfd, name + 5);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0)
- reltext = true;
-
- if (strcmp (name, ".rela.plt") == 0)
- relplt = true;
-
- /* We use the reloc_count field as a counter if we need
- to copy relocs into the output file. */
- s->reloc_count = 0;
- }
- }
- else
-#endif
- if (strcmp (name, ".plt") != 0
- && strcmp (name, ".got") != 0
- && strcmp (name, ".sdata") != 0
- && strcmp (name, ".sdata2") != 0
- && strcmp (name, ".rela.sdata") != 0
- && strcmp (name, ".rela.sdata2") != 0)
- {
- /* It's not one of our sections, so don't allocate space. */
- continue;
- }
-
- if (strip)
- {
- asection **spp;
-
- for (spp = &s->output_section->owner->sections;
- *spp != s->output_section;
- spp = &(*spp)->next)
- ;
- *spp = s->output_section->next;
- --s->output_section->owner->section_count;
-
- continue;
- }
-
- /* Allocate memory for the section contents. */
- s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
- if (s->contents == NULL && s->_raw_size != 0)
- return false;
- }
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in ppc_elf_finish_dynamic_sections, but we
- must add the entries now so that we get the correct size for
- the .dynamic section. The DT_DEBUG entry is filled in by the
- dynamic linker and used by the debugger. */
- if (! info->shared)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
- return false;
- }
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
- return false;
-
- if (relplt)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
- return false;
- }
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
- return false;
-
- if (reltext)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
- return false;
- }
- }
-
- /* If we are generating a shared library, we generate a section
- symbol for each output section. These are local symbols, which
- means that they must come first in the dynamic symbol table.
- That means we must increment the dynamic symbol index of every
- other dynamic symbol. */
- if (info->shared)
- {
- int c, i;
-
- c = bfd_count_sections (output_bfd);
- elf_link_hash_traverse (elf_hash_table (info),
- ppc_elf_adjust_dynindx,
- (PTR) &c);
- elf_hash_table (info)->dynsymcount += c;
-
- for (i = 1, s = output_bfd->sections; s != NULL; s = s->next, i++)
- {
- elf_section_data (s)->dynindx = i;
- /* These symbols will have no names, so we don't need to
- fiddle with dynstr_index. */
- }
- }
-
- return true;
-}
-
-
-/* Look through the relocs for a section during the first phase, and
- allocate space in the global offset table or procedure linkage
- table. */
-
-static boolean
-ppc_elf_check_relocs (abfd, info, sec, relocs)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- const Elf_Internal_Rela *relocs;
-{
- bfd *dynobj;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- const Elf_Internal_Rela *rel;
- const Elf_Internal_Rela *rel_end;
- elf_linker_section_t *got;
- elf_linker_section_t *sdata;
- elf_linker_section_t *sdata2;
- asection *sreloc;
-
- if (info->relocateable)
- return true;
-
-#ifdef DEBUG
- fprintf (stderr, "ppc_elf_check_relocs called for section %s\n",
- bfd_get_section_name (abfd, sec));
-#endif
-
- /* Create the linker generated sections all the time so that the special
- symbols are created. */
- if ((got = elf_linker_section (abfd, LINKER_SECTION_GOT)) == NULL)
- {
- got = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_GOT);
- if (!got)
- return false;
- }
-
- if ((sdata = elf_linker_section (abfd, LINKER_SECTION_SDATA)) == NULL)
- {
- sdata = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA);
- if (!sdata)
- return false;
- }
-
-
- if ((sdata2 = elf_linker_section (abfd, LINKER_SECTION_SDATA2)) == NULL)
- {
- sdata2 = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA2);
- if (!sdata2)
- return false;
- }
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (abfd);
-
- sreloc = NULL;
-
- rel_end = relocs + sec->reloc_count;
- for (rel = relocs; rel < rel_end; rel++)
- {
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
- if (r_symndx < symtab_hdr->sh_info)
- h = NULL;
- else
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-
- switch (ELF32_R_TYPE (rel->r_info))
- {
- default:
- break;
-
- /* GOT16 relocations */
- case R_PPC_GOT16:
- case R_PPC_GOT16_LO:
- case R_PPC_GOT16_HI:
- case R_PPC_GOT16_HA:
- if (got->rel_section == NULL
- && (h != NULL || info->shared)
- && !_bfd_elf_make_linker_section_rela (dynobj, got, 2))
- return false;
-
- if (!bfd_elf32_create_pointer_linker_section (abfd, info, got, h, rel))
- return false;
-
- break;
-
- /* Indirect .sdata relocation */
- case R_PPC_EMB_SDAI16:
- if (got->rel_section == NULL
- && (h != NULL || info->shared)
- && !_bfd_elf_make_linker_section_rela (dynobj, got, 2))
- return false;
-
- if (!bfd_elf32_create_pointer_linker_section (abfd, info, sdata, h, rel))
- return false;
-
- break;
-
- /* Indirect .sdata2 relocation */
- case R_PPC_EMB_SDA2I16:
- if (got->rel_section == NULL
- && (h != NULL || info->shared)
- && !_bfd_elf_make_linker_section_rela (dynobj, got, 2))
- return false;
-
- if (!bfd_elf32_create_pointer_linker_section (abfd, info, sdata2, h, rel))
- return false;
-
- break;
-
-#if 0
- case R_PPC_PLT32:
- case R_PPC_PLTREL24:
- case R_PPC_PLT16_LO:
- case R_PPC_PLT16_HI:
- case R_PPC_PLT16_HA:
-#ifdef DEBUG
- fprintf (stderr, "Reloc requires a PLT entry\n");
-#endif
- /* This symbol requires a procedure linkage table entry. We
- actually build the entry in adjust_dynamic_symbol,
- because this might be a case of linking PIC code without
- linking in any dynamic objects, in which case we don't
- need to generate a procedure linkage table after all. */
-
- if (h == NULL)
- {
- /* It does not make sense to have a procedure linkage
- table entry for a local symbol. */
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
- break;
-
- case R_SPARC_PC10:
- case R_SPARC_PC22:
- if (h != NULL
- && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
- break;
- /* Fall through. */
- case R_SPARC_DISP8:
- case R_SPARC_DISP16:
- case R_SPARC_DISP32:
- case R_SPARC_WDISP30:
- case R_SPARC_WDISP22:
- if (h == NULL)
- break;
- /* Fall through. */
- case R_SPARC_8:
- case R_SPARC_16:
- case R_SPARC_32:
- case R_SPARC_HI22:
- case R_SPARC_22:
- case R_SPARC_13:
- case R_SPARC_LO10:
- case R_SPARC_UA32:
- if (info->shared
- && (sec->flags & SEC_ALLOC) != 0)
- {
- /* When creating a shared object, we must copy these
- relocs into the output file. We create a reloc
- section in dynobj and make room for the reloc. */
- if (sreloc == NULL)
- {
- const char *name;
-
- name = (bfd_elf_string_from_elf_section
- (abfd,
- elf_elfheader (abfd)->e_shstrndx,
- elf_section_data (sec)->rel_hdr.sh_name));
- if (name == NULL)
- return false;
-
- BFD_ASSERT (strncmp (name, ".rela", 5) == 0
- && strcmp (bfd_get_section_name (abfd, sec),
- name + 5) == 0);
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- if (sreloc == NULL)
- {
- sreloc = bfd_make_section (dynobj, name);
- if (sreloc == NULL
- || ! bfd_set_section_flags (dynobj, sreloc,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, sreloc, 2))
- return false;
- }
- }
-
- sreloc->_raw_size += sizeof (Elf32_External_Rela);
- }
-
- break;
-#endif
- }
- }
-
- return true;
-}
-
-
-/* Hook called by the linker routine which adds symbols from an object
- file. We use it to put .comm items in .sbss, and not .bss. */
-
-/*ARGSUSED*/
-static boolean
-ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
- bfd *abfd;
- struct bfd_link_info *info;
- const Elf_Internal_Sym *sym;
- const char **namep;
- flagword *flagsp;
- asection **secp;
- bfd_vma *valp;
-{
- if (sym->st_shndx == SHN_COMMON && sym->st_size <= bfd_get_gp_size (abfd))
- {
- /* Common symbols less than or equal to -G nn bytes are automatically
- put into .sdata. */
- elf_linker_section_t *sdata = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA);
- if (!sdata->bss_section)
- {
- sdata->bss_section = bfd_make_section (elf_hash_table (info)->dynobj, sdata->bss_name);
- sdata->bss_section->flags = (sdata->bss_section->flags & ~SEC_LOAD) | SEC_IS_COMMON;
- }
-
- *secp = sdata->bss_section;
- *valp = sym->st_size;
- }
-
- return true;
-}
-
-
-/* Finish up dynamic symbol handling. We set the contents of various
- dynamic sections here. */
-
-static boolean
-ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
-{
- bfd *dynobj;
-
-#ifdef DEBUG
- fprintf (stderr, "ppc_elf_finish_dynamic_symbol called for %s\n", h->root.root.string);
-#endif
-
- dynobj = elf_hash_table (info)->dynobj;
- BFD_ASSERT (dynobj != NULL);
-
- if (h->plt_offset != (bfd_vma) -1)
- {
- asection *splt;
- asection *srela;
- Elf_Internal_Rela rela;
-
- /* This symbol has an entry in the procedure linkage table. Set
- it up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- srela = bfd_get_section_by_name (dynobj, ".rela.plt");
- BFD_ASSERT (splt != NULL && srela != NULL);
-
- /* Fill in the entry in the procedure linkage table. */
-#if 0
- bfd_put_32 (output_bfd,
- PLT_ENTRY_WORD0 + h->plt_offset,
- splt->contents + h->plt_offset);
- bfd_put_32 (output_bfd,
- (PLT_ENTRY_WORD1
- + (((- (h->plt_offset + 4)) >> 2) & 0x3fffff)),
- splt->contents + h->plt_offset + 4);
- bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,
- splt->contents + h->plt_offset + 8);
-
- /* Fill in the entry in the .rela.plt section. */
- rela.r_offset = (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset);
- rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
- rela.r_addend = 0;
- bfd_elf32_swap_reloca_out (output_bfd, &rela,
- ((Elf32_External_Rela *) srela->contents
- + h->plt_offset / PLT_ENTRY_SIZE - 4));
-#endif
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- /* Mark the symbol as undefined, rather than as defined in
- the .plt section. Leave the value alone. */
- sym->st_shndx = SHN_UNDEF;
- }
- }
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
- {
- asection *s;
- Elf_Internal_Rela rela;
-
- /* This symbols needs a copy reloc. Set it up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- s = bfd_get_section_by_name (h->root.u.def.section->owner,
- ".rela.bss");
- BFD_ASSERT (s != NULL);
-
- rela.r_offset = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_COPY);
- rela.r_addend = 0;
- bfd_elf32_swap_reloca_out (output_bfd, &rela,
- ((Elf32_External_Rela *) s->contents
- + s->reloc_count));
- ++s->reloc_count;
- }
-
- /* Mark some specially defined symbols as absolute. */
- if (strcmp (h->root.root.string, "_DYNAMIC") == 0
- || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
- || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
- sym->st_shndx = SHN_ABS;
-
- return true;
-}
-
-
-/* Finish up the dynamic sections. */
-
-static boolean
-ppc_elf_finish_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- asection *sdyn;
- bfd *dynobj = elf_hash_table (info)->dynobj;
- elf_linker_section_t *got = elf_linker_section (dynobj, LINKER_SECTION_GOT);
-
-#ifdef DEBUG
- fprintf (stderr, "ppc_elf_finish_dynamic_sections called\n");
-#endif
-
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- asection *splt;
- Elf32_External_Dyn *dyncon, *dynconend;
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL && sdyn != NULL);
-
- dyncon = (Elf32_External_Dyn *) sdyn->contents;
- dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
- for (; dyncon < dynconend; dyncon++)
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- boolean size;
-
- bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
-
- switch (dyn.d_tag)
- {
- case DT_PLTGOT: name = ".plt"; size = false; break;
- case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
- case DT_JMPREL: name = ".rela.plt"; size = false; break;
- default: name = NULL; size = false; break;
- }
-
- if (name != NULL)
- {
- asection *s;
-
- s = bfd_get_section_by_name (output_bfd, name);
- if (s == NULL)
- dyn.d_un.d_val = 0;
- else
- {
- if (! size)
- dyn.d_un.d_ptr = s->vma;
- else
- {
- if (s->_cooked_size != 0)
- dyn.d_un.d_val = s->_cooked_size;
- else
- dyn.d_un.d_val = s->_raw_size;
- }
- }
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- }
- }
- }
-
- /* Add a blrl instruction at _GLOBAL_OFFSET_TABLE_-4 so that a function can
- easily find the address of the _GLOBAL_OFFSET_TABLE_. */
- if (got)
- {
- unsigned char *contents = got->section->contents + got->hole_offset;
- bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);
-
- if (sdyn == NULL)
- bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4);
- else
- bfd_put_32 (output_bfd,
- sdyn->output_section->vma + sdyn->output_offset,
- contents+4);
-
- elf_section_data (got->section->output_section)->this_hdr.sh_entsize = 4;
- }
-
- if (info->shared)
- {
- asection *sdynsym;
- asection *s;
- Elf_Internal_Sym sym;
-
- /* Set up the section symbols for the output sections. */
-
- sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
- BFD_ASSERT (sdynsym != NULL);
-
- sym.st_size = 0;
- sym.st_name = 0;
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
- sym.st_other = 0;
-
- for (s = output_bfd->sections; s != NULL; s = s->next)
- {
- int indx;
-
- sym.st_value = s->vma;
-
- indx = elf_section_data (s)->this_idx;
- BFD_ASSERT (indx > 0);
- sym.st_shndx = indx;
-
- bfd_elf32_swap_symbol_out (output_bfd, &sym,
- (PTR) (((Elf32_External_Sym *)
- sdynsym->contents)
- + elf_section_data (s)->dynindx));
- }
-
- /* Set the sh_info field of the output .dynsym section to the
- index of the first global symbol. */
- elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
- bfd_count_sections (output_bfd) + 1;
- }
-
- return true;
-}
-
-
-/* The RELOCATE_SECTION function is called by the ELF backend linker
- to handle the relocations for a section.
-
- The relocs are always passed as Rela structures; if the section
- actually uses Rel structures, the r_addend field will always be
- zero.
-
- This function is responsible for adjust the section contents as
- necessary, and (if using Rela relocs and generating a
- relocateable output file) adjusting the reloc addend as
- necessary.
-
- This function does not have to worry about setting the reloc
- address or the reloc symbol index.
-
- LOCAL_SYMS is a pointer to the swapped in local symbols.
-
- LOCAL_SECTIONS is an array giving the section in the input file
- corresponding to the st_shndx field of each local symbol.
-
- The global hash table entry for the global symbols can be found
- via elf_sym_hashes (input_bfd).
-
- When generating relocateable output, this function must handle
- STB_LOCAL/STT_SECTION symbols specially. The output symbol is
- going to be the section symbol corresponding to the output
- section, which means that the addend must be adjusted
- accordingly. */
-
-static boolean
-ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, local_syms, local_sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- Elf_Internal_Rela *relocs;
- Elf_Internal_Sym *local_syms;
- asection **local_sections;
-{
- Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
- bfd *dynobj = elf_hash_table (info)->dynobj;
- elf_linker_section_t *got = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_GOT) : NULL;
- elf_linker_section_t *sdata = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_SDATA) : NULL;
- elf_linker_section_t *sdata2 = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_SDATA2) : NULL;
- Elf_Internal_Rela *rel = relocs;
- Elf_Internal_Rela *relend = relocs + input_section->reloc_count;
- boolean ret = true;
- long insn;
-
-#ifdef DEBUG
- fprintf (stderr, "ppc_elf_relocate_section called for %s section %s, %ld relocations%s\n",
- bfd_get_filename (input_bfd),
- bfd_section_name(input_bfd, input_section),
- (long)input_section->reloc_count,
- (info->relocateable) ? " (relocatable)" : "");
-#endif
-
- if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
- ppc_elf_howto_init ();
-
- for (; rel < relend; rel++)
- {
- enum ppc_reloc_type r_type = (enum ppc_reloc_type)ELF32_R_TYPE (rel->r_info);
- bfd_vma offset = rel->r_offset;
- bfd_vma addend = rel->r_addend;
- bfd_reloc_status_type r = bfd_reloc_other;
- Elf_Internal_Sym *sym = (Elf_Internal_Sym *)0;
- asection *sec = (asection *)0;
- struct elf_link_hash_entry *h = (struct elf_link_hash_entry *)0;
- const char *sym_name = (const char *)0;
- reloc_howto_type *howto;
- unsigned long r_symndx;
- bfd_vma relocation;
-
- /* Unknown relocation handling */
- if ((unsigned)r_type >= (unsigned)R_PPC_max || !ppc_elf_howto_table[(int)r_type])
- {
- (*_bfd_error_handler) ("%s: unknown relocation type %d",
- bfd_get_filename (input_bfd),
- (int)r_type);
-
- bfd_set_error (bfd_error_bad_value);
- ret = false;
- continue;
- }
-
- howto = ppc_elf_howto_table[(int)r_type];
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- addend = rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
-#ifdef DEBUG
- fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
- howto->name,
- (int)r_type,
- r_symndx,
- (long)offset,
- (long)addend);
-#endif
- continue;
- }
-
- /* This is a final link. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- sec = local_sections[r_symndx];
- sym_name = "<local symbol>";
-
- relocation = (sec->output_section->vma
- + sec->output_offset
- + sym->st_value);
- }
- else
- {
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- sym_name = h->root.root.string;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- relocation = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else if (info->shared)
- relocation = 0;
- else
- {
- (*info->callbacks->undefined_symbol)(info,
- h->root.root.string,
- input_bfd,
- input_section,
- rel->r_offset);
- ret = false;
- continue;
- }
- }
-
- switch ((int)r_type)
- {
- default:
- (*_bfd_error_handler) ("%s: unknown relocation type %d for symbol %s",
- bfd_get_filename (input_bfd),
- (int)r_type, sym_name);
-
- bfd_set_error (bfd_error_bad_value);
- ret = false;
- continue;
-
- /* relocations that need no special processing */
- case (int)R_PPC_NONE:
- case (int)R_PPC_ADDR32:
- case (int)R_PPC_ADDR24:
- case (int)R_PPC_ADDR16:
- case (int)R_PPC_ADDR16_LO:
- case (int)R_PPC_ADDR16_HI:
- case (int)R_PPC_ADDR14:
- case (int)R_PPC_REL24:
- case (int)R_PPC_REL14:
- case (int)R_PPC_UADDR32:
- case (int)R_PPC_UADDR16:
- case (int)R_PPC_REL32:
- break;
-
- /* branch taken prediction relocations */
- case (int)R_PPC_ADDR14_BRTAKEN:
- case (int)R_PPC_REL14_BRTAKEN:
- insn = bfd_get_32 (output_bfd, contents + offset);
- if ((relocation - offset) & 0x8000)
- insn &= ~BRANCH_PREDICT_BIT;
- else
- insn |= BRANCH_PREDICT_BIT;
- bfd_put_32 (output_bfd, insn, contents + offset);
- break;
-
- /* branch not taken predicition relocations */
- case (int)R_PPC_ADDR14_BRNTAKEN:
- case (int)R_PPC_REL14_BRNTAKEN:
- insn = bfd_get_32 (output_bfd, contents + offset);
- if ((relocation - offset) & 0x8000)
- insn |= BRANCH_PREDICT_BIT;
- else
- insn &= ~BRANCH_PREDICT_BIT;
- bfd_put_32 (output_bfd, insn, contents + offset);
- break;
-
- /* GOT16 relocations */
- case (int)R_PPC_GOT16:
- case (int)R_PPC_GOT16_LO:
- case (int)R_PPC_GOT16_HI:
- case (int)R_PPC_GOT16_HA:
- relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info,
- got, h, relocation, rel,
- R_PPC_RELATIVE);
- break;
-
- /* Indirect .sdata relocation */
- case (int)R_PPC_EMB_SDAI16:
- BFD_ASSERT (sdata != NULL);
- relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info,
- sdata, h, relocation, rel,
- R_PPC_RELATIVE);
- break;
-
- /* Indirect .sdata2 relocation */
- case (int)R_PPC_EMB_SDA2I16:
- BFD_ASSERT (sdata2 != NULL);
- relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info,
- sdata2, h, relocation, rel,
- R_PPC_RELATIVE);
- break;
-
- /* Handle the TOC16 reloc. We want to use the offset within the .got
- section, not the actual VMA. This is appropriate when generating
- an embedded ELF object, for which the .got section acts like the
- AIX .toc section. */
- case (int)R_PPC_TOC16: /* phony GOT16 relocations */
- BFD_ASSERT (sec != (asection *)0);
- BFD_ASSERT (bfd_is_und_section (sec)
- || strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
- || strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0)
-
- addend -= sec->output_section->vma + sec->output_offset + 0x8000;
- break;
-
- /* arithmetic adjust relocations */
- case (int)R_PPC_ADDR16_HA:
- BFD_ASSERT (sec != (asection *)0);
- addend += ((relocation + addend) & 0x8000) << 1;
- break;
-
- /* relocate against _SDA_BASE_ */
- case (int)R_PPC_SDAREL16:
- BFD_ASSERT (sec != (asection *)0);
- if (strcmp (bfd_get_section_name (abfd, sec), ".sdata") != 0
- && strcmp (bfd_get_section_name (abfd, sec), ".sbss") != 0)
- {
- (*_bfd_error_handler) ("%s: The target (%s) of a %s relocation is in the wrong section (%s)",
- bfd_get_filename (input_bfd),
- sym_name,
- ppc_elf_howto_table[ (int)r_type ]->name,
- bfd_get_section_name (abfd, sec));
-
- bfd_set_error (bfd_error_bad_value);
- ret = false;
- continue;
- }
- addend -= (sdata->sym_hash->root.u.def.value
- + sdata->sym_hash->root.u.def.section->output_section->vma
- + sdata->sym_hash->root.u.def.section->output_offset);
- break;
-
-
- /* relocate against _SDA2_BASE_ */
- case (int)R_PPC_EMB_SDA2REL:
- BFD_ASSERT (sec != (asection *)0);
- if (strcmp (bfd_get_section_name (abfd, sec), ".sdata2") != 0
- && strcmp (bfd_get_section_name (abfd, sec), ".sbss2") != 0)
- {
- (*_bfd_error_handler) ("%s: The target (%s) of a %s relocation is in the wrong section (%s)",
- bfd_get_filename (input_bfd),
- sym_name,
- ppc_elf_howto_table[ (int)r_type ]->name,
- bfd_get_section_name (abfd, sec));
-
- bfd_set_error (bfd_error_bad_value);
- ret = false;
- continue;
- }
- addend -= (sdata2->sym_hash->root.u.def.value
- + sdata2->sym_hash->root.u.def.section->output_section->vma
- + sdata2->sym_hash->root.u.def.section->output_offset);
- break;
-
-
- /* relocate against either _SDA_BASE_, _SDA2_BASE_, or 0 */
- case (int)R_PPC_EMB_SDA21:
- case (int)R_PPC_EMB_RELSDA:
- {
- const char *name = bfd_get_section_name (abfd, sec);
- int reg;
-
- BFD_ASSERT (sec != (asection *)0);
- if (strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0)
- {
- reg = 13;
- addend -= (sdata->sym_hash->root.u.def.value
- + sdata->sym_hash->root.u.def.section->output_section->vma
- + sdata->sym_hash->root.u.def.section->output_offset);
- }
-
- else if (strcmp (name, ".sdata2") == 0 || strcmp (name, ".sbss2") == 0)
- {
- reg = 2;
- addend -= (sdata2->sym_hash->root.u.def.value
- + sdata2->sym_hash->root.u.def.section->output_section->vma
- + sdata2->sym_hash->root.u.def.section->output_offset);
- }
-
- else if (strcmp (name, ".PPC.EMB.sdata0") == 0 || strcmp (name, ".PPC.EMB.sbss0") == 0)
- {
- reg = 0;
- }
-
- else
- {
- (*_bfd_error_handler) ("%s: The target (%s) of a %s relocation is in the wrong section (%s)",
- bfd_get_filename (input_bfd),
- sym_name,
- ppc_elf_howto_table[ (int)r_type ]->name,
- bfd_get_section_name (abfd, sec));
-
- bfd_set_error (bfd_error_bad_value);
- ret = false;
- continue;
- }
-
- if (r_type == R_PPC_EMB_SDA21)
- { /* fill in register field */
- insn = bfd_get_32 (output_bfd, contents + offset);
- insn = (insn & ~RA_REGISTER_MASK) | (reg << RA_REGISTER_SHIFT);
- bfd_put_32 (output_bfd, insn, contents + offset);
- }
- }
- break;
-
- /* Relocate against the beginning of the section */
- case (int)R_PPC_SECTOFF:
- case (int)R_PPC_SECTOFF_LO:
- case (int)R_PPC_SECTOFF_HI:
- BFD_ASSERT (sec != (asection *)0);
- addend -= sec->output_section->vma;
- break;
-
- case (int)R_PPC_SECTOFF_HA:
- BFD_ASSERT (sec != (asection *)0);
- addend -= sec->output_section->vma;
- addend += ((relocation + addend) & 0x8000) << 1;
- break;
-
- /* Negative relocations */
- case (int)R_PPC_EMB_NADDR32:
- case (int)R_PPC_EMB_NADDR16:
- case (int)R_PPC_EMB_NADDR16_LO:
- case (int)R_PPC_EMB_NADDR16_HI:
- addend -= 2*relocation;
- break;
-
- case (int)R_PPC_EMB_NADDR16_HA:
- addend -= 2*relocation;
- addend += ((relocation + addend) & 0x8000) << 1;
- break;
-
- /* NOP relocation that prevents garbage collecting linkers from omitting a
- reference. */
- case (int)R_PPC_EMB_MRKREF:
- continue;
-
- case (int)R_PPC_PLTREL24:
- case (int)R_PPC_COPY:
- case (int)R_PPC_GLOB_DAT:
- case (int)R_PPC_JMP_SLOT:
- case (int)R_PPC_RELATIVE:
- case (int)R_PPC_LOCAL24PC:
- case (int)R_PPC_PLT32:
- case (int)R_PPC_PLTREL32:
- case (int)R_PPC_PLT16_LO:
- case (int)R_PPC_PLT16_HI:
- case (int)R_PPC_PLT16_HA:
- case (int)R_PPC_EMB_RELSEC16:
- case (int)R_PPC_EMB_RELST_LO:
- case (int)R_PPC_EMB_RELST_HI:
- case (int)R_PPC_EMB_RELST_HA:
- case (int)R_PPC_EMB_BIT_FLD:
- (*_bfd_error_handler) ("%s: Relocation %s is not yet supported for symbol %s.",
- bfd_get_filename (input_bfd),
- ppc_elf_howto_table[ (int)r_type ]->name,
- sym_name);
-
- bfd_set_error (bfd_error_invalid_operation);
- ret = false;
- continue;
- }
-
-
-#ifdef DEBUG
- fprintf (stderr, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n",
- howto->name,
- (int)r_type,
- sym_name,
- r_symndx,
- (long)offset,
- (long)addend);
-#endif
-
- r = _bfd_final_link_relocate (howto,
- input_bfd,
- input_section,
- contents,
- offset,
- relocation,
- addend);
-
- if (r != bfd_reloc_ok)
- {
- ret = false;
- switch (r)
- {
- default:
- break;
-
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
- if (name == NULL)
- break;
-
- if (*name == '\0')
- name = bfd_section_name (input_bfd, sec);
- }
-
- (*info->callbacks->reloc_overflow)(info,
- name,
- howto->name,
- (bfd_vma) 0,
- input_bfd,
- input_section,
- offset);
- }
- break;
-
- }
- }
- }
-
-
-#ifdef DEBUG
- fprintf (stderr, "\n");
-#endif
-
- return ret;
-}
-
-
-#define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec
-#define TARGET_LITTLE_NAME "elf32-powerpcle"
-#define TARGET_BIG_SYM bfd_elf32_powerpc_vec
-#define TARGET_BIG_NAME "elf32-powerpc"
-#define ELF_ARCH bfd_arch_powerpc
-#define ELF_MACHINE_CODE EM_PPC
-#define ELF_MAXPAGESIZE 0x10000
-#define elf_info_to_howto ppc_elf_info_to_howto
-
-#ifdef EM_CYGNUS_POWERPC
-#define ELF_MACHINE_ALT1 EM_CYGNUS_POWERPC
-#endif
-
-#ifdef EM_PPC_OLD
-#define ELF_MACHINE_ALT2 EM_PPC_OLD
-#endif
-
-#define bfd_elf32_bfd_copy_private_bfd_data ppc_elf_copy_private_bfd_data
-#define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data
-#define bfd_elf32_bfd_set_private_flags ppc_elf_set_private_flags
-#define bfd_elf32_bfd_reloc_type_lookup ppc_elf_reloc_type_lookup
-#define elf_backend_section_from_shdr ppc_elf_section_from_shdr
-#define elf_backend_relocate_section ppc_elf_relocate_section
-#define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
-#define elf_backend_check_relocs ppc_elf_check_relocs
-#define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol
-#define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook
-#define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections
-#define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol
-#define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections
-#define elf_backend_fake_sections ppc_elf_fake_sections
-#define elf_backend_additional_program_headers ppc_elf_additional_program_headers
-#define elf_backend_modify_segment_map ppc_elf_modify_segment_map
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32-sparc.c b/contrib/gdb/bfd/elf32-sparc.c
deleted file mode 100644
index 918eb00..0000000
--- a/contrib/gdb/bfd/elf32-sparc.c
+++ /dev/null
@@ -1,1795 +0,0 @@
-/* SPARC-specific support for 32-bit ELF
- Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-#include "elf/sparc.h"
-
-static reloc_howto_type *elf32_sparc_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void elf_info_to_howto
- PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static boolean elf32_sparc_check_relocs
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- const Elf_Internal_Rela *));
-static boolean elf32_sparc_adjust_dynamic_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static boolean elf32_sparc_adjust_dynindx
- PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean elf32_sparc_size_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean elf32_sparc_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static boolean elf32_sparc_finish_dynamic_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
- Elf_Internal_Sym *));
-static boolean elf32_sparc_finish_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean elf32_sparc_merge_private_bfd_data PARAMS ((bfd *, bfd *));
-static boolean elf32_sparc_object_p
- PARAMS ((bfd *));
-static void elf32_sparc_final_write_processing
- PARAMS ((bfd *, boolean));
-
-/* The howto table and associated functions.
- ??? elf64-sparc.c has its own copy for the moment to ease transition
- since some of the relocation values have changed. At some point we'll
- want elf64-sparc.c to switch over and use this table.
- ??? Do we want to recognize (or flag as errors) some of the 64 bit entries
- if the target is elf32-sparc.
-*/
-
-static bfd_reloc_status_type sparc_elf_notsupported_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_reloc_status_type sparc_elf_wdisp16_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-
-reloc_howto_type _bfd_sparc_elf_howto_table[] =
-{
- HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
- HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_8", false,0,0x000000ff,true),
- HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_16", false,0,0x0000ffff,true),
- HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_32", false,0,0xffffffff,true),
- HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP8", false,0,0x000000ff,true),
- HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP16", false,0,0x0000ffff,true),
- HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP32", false,0,0x00ffffff,true),
- HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP30", false,0,0x3fffffff,true),
- HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HI22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_13", false,0,0x00001fff,true),
- HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LO10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_GOT13", false,0,0x00001fff,true),
- HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_PC10, 0,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_PC22, 10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PC22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_WPLT30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WPLT30", false,0,0x3fffffff,true),
- HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_COPY", false,0,0x00000000,true),
- HOWTO(R_SPARC_GLOB_DAT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
- HOWTO(R_SPARC_JMP_SLOT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_JMP_SLOT",false,0,0x00000000,true),
- HOWTO(R_SPARC_RELATIVE, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_RELATIVE",false,0,0x00000000,true),
- HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UA32", false,0,0x00000000,true),
- HOWTO(R_SPARC_PLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PLT32", false,0,0x00000000,true),
- HOWTO(R_SPARC_HIPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HIPLT22", false,0,0x00000000,true),
- HOWTO(R_SPARC_LOPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LOPLT10", false,0,0x00000000,true),
- HOWTO(R_SPARC_PCPLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT32", false,0,0x00000000,true),
- HOWTO(R_SPARC_PCPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT22", false,0,0x00000000,true),
- HOWTO(R_SPARC_PCPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT10", false,0,0x00000000,true),
- HOWTO(R_SPARC_10, 0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_11, 0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_11", false,0,0x000007ff,true),
- /* ??? If we need to handle R_SPARC_64 then we need (figuratively)
- --enable-64-bit-bfd. That causes objdump to print address as 64 bits
- which we really don't want on an elf32-sparc system. There may be other
- consequences which we may not want (at least not until it's proven they're
- necessary) so for now these are only enabled ifdef BFD64. */
-#ifdef BFD64
- HOWTO(R_SPARC_64, 0,4,00,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_64", false,0,~ (bfd_vma) 0, true),
- /* ??? These don't make sense except in 64 bit systems so they're disabled
- ifndef BFD64 too (for now). */
- HOWTO(R_SPARC_OLO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_OLO10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_HH22, 42,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HH22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_HM10, 32,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HM10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_LM22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LM22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_PC_HH22, 42,2,22,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HH22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_PC_HM10, 32,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HM10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_PC_LM22, 10,2,22,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LM22", false,0,0x003fffff,true),
-#else
- HOWTO(R_SPARC_64, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_64", false,0,0x00000000,true),
- HOWTO(R_SPARC_OLO10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_OLO10", false,0,0x00000000,true),
- HOWTO(R_SPARC_HH22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HH22", false,0,0x00000000,true),
- HOWTO(R_SPARC_HM10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HM10", false,0,0x00000000,true),
- HOWTO(R_SPARC_LM22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LM22", false,0,0x00000000,true),
- HOWTO(R_SPARC_PC_HH22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_HH22", false,0,0x00000000,true),
- HOWTO(R_SPARC_PC_HM10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_HM10", false,0,0x00000000,true),
- HOWTO(R_SPARC_PC_LM22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_LM22", false,0,0x00000000,true),
-#endif
- HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,complain_overflow_signed, sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true),
- HOWTO(R_SPARC_WDISP19, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP19", false,0,0x0007ffff,true),
- HOWTO(R_SPARC_GLOB_JMP, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
- HOWTO(R_SPARC_7, 0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_7", false,0,0x0000007f,true),
- HOWTO(R_SPARC_5, 0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_5", false,0,0x0000001f,true),
- HOWTO(R_SPARC_6, 0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_6", false,0,0x0000003f,true),
-};
-
-struct elf_reloc_map {
- unsigned char bfd_reloc_val;
- unsigned char elf_reloc_val;
-};
-
-static CONST struct elf_reloc_map sparc_reloc_map[] =
-{
- { BFD_RELOC_NONE, R_SPARC_NONE, },
- { BFD_RELOC_16, R_SPARC_16, },
- { BFD_RELOC_8, R_SPARC_8 },
- { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
- /* ??? This might cause us to need separate functions in elf{32,64}-sparc.c
- (we could still have just one table), but is this reloc ever used? */
- { BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
- { BFD_RELOC_32, R_SPARC_32 },
- { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
- { BFD_RELOC_HI22, R_SPARC_HI22 },
- { BFD_RELOC_LO10, R_SPARC_LO10, },
- { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
- { BFD_RELOC_SPARC22, R_SPARC_22 },
- { BFD_RELOC_SPARC13, R_SPARC_13 },
- { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
- { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
- { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
- { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
- { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
- { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
- { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
- { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
- { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
- { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
- { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
- /* ??? Doesn't dwarf use this? */
-/*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
- {BFD_RELOC_SPARC_10, R_SPARC_10},
- {BFD_RELOC_SPARC_11, R_SPARC_11},
- {BFD_RELOC_SPARC_64, R_SPARC_64},
- {BFD_RELOC_SPARC_OLO10, R_SPARC_OLO10},
- {BFD_RELOC_SPARC_HH22, R_SPARC_HH22},
- {BFD_RELOC_SPARC_HM10, R_SPARC_HM10},
- {BFD_RELOC_SPARC_LM22, R_SPARC_LM22},
- {BFD_RELOC_SPARC_PC_HH22, R_SPARC_PC_HH22},
- {BFD_RELOC_SPARC_PC_HM10, R_SPARC_PC_HM10},
- {BFD_RELOC_SPARC_PC_LM22, R_SPARC_PC_LM22},
- {BFD_RELOC_SPARC_WDISP16, R_SPARC_WDISP16},
- {BFD_RELOC_SPARC_WDISP19, R_SPARC_WDISP19},
- {BFD_RELOC_SPARC_GLOB_JMP, R_SPARC_GLOB_JMP},
- {BFD_RELOC_SPARC_7, R_SPARC_7},
- {BFD_RELOC_SPARC_5, R_SPARC_5},
- {BFD_RELOC_SPARC_6, R_SPARC_6},
-};
-
-static reloc_howto_type *
-elf32_sparc_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- unsigned int i;
- for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
- {
- if (sparc_reloc_map[i].bfd_reloc_val == code)
- return &_bfd_sparc_elf_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
- }
- return 0;
-}
-
-/* We need to use ELF32_R_TYPE so we have our own copy of this function,
- and elf64-sparc.c has its own copy. */
-
-static void
-elf_info_to_howto (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf_Internal_Rela *dst;
-{
- BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_SPARC_max);
- cache_ptr->howto = &_bfd_sparc_elf_howto_table[ELF32_R_TYPE(dst->r_info)];
-}
-
-/* For unsupported relocs. */
-
-static bfd_reloc_status_type
-sparc_elf_notsupported_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- return bfd_reloc_notsupported;
-}
-
-/* Handle the WDISP16 reloc. */
-
-static bfd_reloc_status_type
-sparc_elf_wdisp16_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_vma relocation;
- bfd_vma x;
-
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && (! reloc_entry->howto->partial_inplace
- || reloc_entry->addend == 0))
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- if (output_bfd != NULL)
- return bfd_reloc_continue;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- relocation = (symbol->value
- + symbol->section->output_section->vma
- + symbol->section->output_offset);
- relocation += reloc_entry->addend;
- relocation -= (input_section->output_section->vma
- + input_section->output_offset);
- relocation -= reloc_entry->address;
-
- x = bfd_get_32 (abfd, (char *) data + reloc_entry->address);
- x |= ((((relocation >> 2) & 0xc000) << 6)
- | ((relocation >> 2) & 0x3fff));
- bfd_put_32 (abfd, x, (char *) data + reloc_entry->address);
-
- if ((bfd_signed_vma) relocation < - 0x40000
- || (bfd_signed_vma) relocation > 0x3ffff)
- return bfd_reloc_overflow;
- else
- return bfd_reloc_ok;
-}
-
-/* Functions for the SPARC ELF linker. */
-
-/* The name of the dynamic interpreter. This is put in the .interp
- section. */
-
-#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
-
-/* The nop opcode we use. */
-
-#define SPARC_NOP 0x01000000
-
-/* The size in bytes of an entry in the procedure linkage table. */
-
-#define PLT_ENTRY_SIZE 12
-
-/* The first four entries in a procedure linkage table are reserved,
- and the initial contents are unimportant (we zero them out).
- Subsequent entries look like this. See the SVR4 ABI SPARC
- supplement to see how this works. */
-
-/* sethi %hi(.-.plt0),%g1. We fill in the address later. */
-#define PLT_ENTRY_WORD0 0x03000000
-/* b,a .plt0. We fill in the offset later. */
-#define PLT_ENTRY_WORD1 0x30800000
-/* nop. */
-#define PLT_ENTRY_WORD2 SPARC_NOP
-
-/* Look through the relocs for a section during the first phase, and
- allocate space in the global offset table or procedure linkage
- table. */
-
-static boolean
-elf32_sparc_check_relocs (abfd, info, sec, relocs)
- bfd *abfd;
- struct bfd_link_info *info;
- asection *sec;
- const Elf_Internal_Rela *relocs;
-{
- bfd *dynobj;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- bfd_vma *local_got_offsets;
- const Elf_Internal_Rela *rel;
- const Elf_Internal_Rela *rel_end;
- asection *sgot;
- asection *srelgot;
- asection *sreloc;
-
- if (info->relocateable)
- return true;
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (abfd);
- local_got_offsets = elf_local_got_offsets (abfd);
-
- sgot = NULL;
- srelgot = NULL;
- sreloc = NULL;
-
- rel_end = relocs + sec->reloc_count;
- for (rel = relocs; rel < rel_end; rel++)
- {
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
- if (r_symndx < symtab_hdr->sh_info)
- h = NULL;
- else
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_SPARC_GOT10:
- case R_SPARC_GOT13:
- case R_SPARC_GOT22:
- /* This symbol requires a global offset table entry. */
-
- if (dynobj == NULL)
- {
- /* Create the .got section. */
- elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! _bfd_elf_create_got_section (dynobj, info))
- return false;
- }
-
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- if (srelgot == NULL
- && (h != NULL || info->shared))
- {
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
- if (srelgot == NULL)
- {
- srelgot = bfd_make_section (dynobj, ".rela.got");
- if (srelgot == NULL
- || ! bfd_set_section_flags (dynobj, srelgot,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, srelgot, 2))
- return false;
- }
- }
-
- if (h != NULL)
- {
- if (h->got_offset != (bfd_vma) -1)
- {
- /* We have already allocated space in the .got. */
- break;
- }
- h->got_offset = sgot->_raw_size;
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- srelgot->_raw_size += sizeof (Elf32_External_Rela);
- }
- else
- {
- /* This is a global offset table entry for a local
- symbol. */
- if (local_got_offsets == NULL)
- {
- size_t size;
- register unsigned int i;
-
- size = symtab_hdr->sh_info * sizeof (bfd_vma);
- local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
- if (local_got_offsets == NULL)
- return false;
- elf_local_got_offsets (abfd) = local_got_offsets;
- for (i = 0; i < symtab_hdr->sh_info; i++)
- local_got_offsets[i] = (bfd_vma) -1;
- }
- if (local_got_offsets[r_symndx] != (bfd_vma) -1)
- {
- /* We have already allocated space in the .got. */
- break;
- }
- local_got_offsets[r_symndx] = sgot->_raw_size;
-
- if (info->shared)
- {
- /* If we are generating a shared object, we need to
- output a R_SPARC_RELATIVE reloc so that the
- dynamic linker can adjust this GOT entry. */
- srelgot->_raw_size += sizeof (Elf32_External_Rela);
- }
- }
-
- sgot->_raw_size += 4;
-
- break;
-
- case R_SPARC_WPLT30:
- /* This symbol requires a procedure linkage table entry. We
- actually build the entry in adjust_dynamic_symbol,
- because this might be a case of linking PIC code without
- linking in any dynamic objects, in which case we don't
- need to generate a procedure linkage table after all. */
-
- if (h == NULL)
- {
- /* It does not make sense to have a procedure linkage
- table entry for a local symbol. */
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! bfd_elf32_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
-
- break;
-
- case R_SPARC_PC10:
- case R_SPARC_PC22:
- if (h != NULL
- && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
- break;
- /* Fall through. */
- case R_SPARC_DISP8:
- case R_SPARC_DISP16:
- case R_SPARC_DISP32:
- case R_SPARC_WDISP30:
- case R_SPARC_WDISP22:
- case R_SPARC_WDISP19:
- case R_SPARC_WDISP16:
- if (h == NULL)
- break;
- /* Fall through. */
- case R_SPARC_8:
- case R_SPARC_16:
- case R_SPARC_32:
- case R_SPARC_HI22:
- case R_SPARC_22:
- case R_SPARC_13:
- case R_SPARC_LO10:
- case R_SPARC_UA32:
- if (info->shared
- && (sec->flags & SEC_ALLOC) != 0)
- {
- /* When creating a shared object, we must copy these
- relocs into the output file. We create a reloc
- section in dynobj and make room for the reloc. */
- if (sreloc == NULL)
- {
- const char *name;
-
- name = (bfd_elf_string_from_elf_section
- (abfd,
- elf_elfheader (abfd)->e_shstrndx,
- elf_section_data (sec)->rel_hdr.sh_name));
- if (name == NULL)
- return false;
-
- BFD_ASSERT (strncmp (name, ".rela", 5) == 0
- && strcmp (bfd_get_section_name (abfd, sec),
- name + 5) == 0);
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- if (sreloc == NULL)
- {
- sreloc = bfd_make_section (dynobj, name);
- if (sreloc == NULL
- || ! bfd_set_section_flags (dynobj, sreloc,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, sreloc, 2))
- return false;
- }
- }
-
- sreloc->_raw_size += sizeof (Elf32_External_Rela);
- }
-
- break;
-
- default:
- break;
- }
- }
-
- return true;
-}
-
-/* Adjust a symbol defined by a dynamic object and referenced by a
- regular object. The current definition is in some section of the
- dynamic object, but we're not including those sections. We have to
- change the definition to something the rest of the link can
- understand. */
-
-static boolean
-elf32_sparc_adjust_dynamic_symbol (info, h)
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
-{
- bfd *dynobj;
- asection *s;
- unsigned int power_of_two;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- /* Make sure we know what is going on here. */
- BFD_ASSERT (dynobj != NULL
- && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
- || h->weakdef != NULL
- || ((h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_REF_REGULAR) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)));
-
- /* If this is a function, put it in the procedure linkage table. We
- will fill in the contents of the procedure linkage table later
- (although we could actually do it here). */
- if (h->type == STT_FUNC
- || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
- {
- if (! elf_hash_table (info)->dynamic_sections_created)
- {
- /* This case can occur if we saw a WPLT30 reloc in an input
- file, but none of the input files were dynamic objects.
- In such a case, we don't actually need to build a
- procedure linkage table, and we can just do a WDISP30
- reloc instead. */
- BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
- return true;
- }
-
- s = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (s != NULL);
-
- /* The first four entries in .plt are reserved. */
- if (s->_raw_size == 0)
- s->_raw_size = 4 * PLT_ENTRY_SIZE;
-
- /* The procedure linkage table has a maximum size. */
- if (s->_raw_size >= 0x400000)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- /* If this symbol is not defined in a regular file, and we are
- not generating a shared library, then set the symbol to this
- location in the .plt. This is required to make function
- pointers compare as equal between the normal executable and
- the shared library. */
- if (! info->shared
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
- }
-
- h->plt_offset = s->_raw_size;
-
- /* Make room for this entry. */
- s->_raw_size += PLT_ENTRY_SIZE;
-
- /* We also need to make an entry in the .rela.plt section. */
-
- s = bfd_get_section_by_name (dynobj, ".rela.plt");
- BFD_ASSERT (s != NULL);
- s->_raw_size += sizeof (Elf32_External_Rela);
-
- return true;
- }
-
- /* If this is a weak symbol, and there is a real definition, the
- processor independent code will have arranged for us to see the
- real definition first, and we can just use the same value. */
- if (h->weakdef != NULL)
- {
- BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
- || h->weakdef->root.type == bfd_link_hash_defweak);
- h->root.u.def.section = h->weakdef->root.u.def.section;
- h->root.u.def.value = h->weakdef->root.u.def.value;
- return true;
- }
-
- /* This is a reference to a symbol defined by a dynamic object which
- is not a function. */
-
- /* If we are creating a shared library, we must presume that the
- only references to the symbol are via the global offset table.
- For such cases we need not do anything here; the relocations will
- be handled correctly by relocate_section. */
- if (info->shared)
- return true;
-
- /* We must allocate the symbol in our .dynbss section, which will
- become part of the .bss section of the executable. There will be
- an entry for this symbol in the .dynsym section. The dynamic
- object will contain position independent code, so all references
- from the dynamic object to this symbol will go through the global
- offset table. The dynamic linker will use the .dynsym entry to
- determine the address it must put in the global offset table, so
- both the dynamic object and the regular object will refer to the
- same memory location for the variable. */
-
- s = bfd_get_section_by_name (dynobj, ".dynbss");
- BFD_ASSERT (s != NULL);
-
- /* If the symbol is currently defined in the .bss section of the
- dynamic object, then it is OK to simply initialize it to zero.
- If the symbol is in some other section, we must generate a
- R_SPARC_COPY reloc to tell the dynamic linker to copy the initial
- value out of the dynamic object and into the runtime process
- image. We need to remember the offset into the .rel.bss section
- we are going to use. */
- if ((h->root.u.def.section->flags & SEC_LOAD) != 0)
- {
- asection *srel;
-
- srel = bfd_get_section_by_name (dynobj, ".rela.bss");
- BFD_ASSERT (srel != NULL);
- srel->_raw_size += sizeof (Elf32_External_Rela);
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
- }
-
- /* We need to figure out the alignment required for this symbol. I
- have no idea how ELF linkers handle this. */
- power_of_two = bfd_log2 (h->size);
- if (power_of_two > 3)
- power_of_two = 3;
-
- /* Apply the required alignment. */
- s->_raw_size = BFD_ALIGN (s->_raw_size,
- (bfd_size_type) (1 << power_of_two));
- if (power_of_two > bfd_get_section_alignment (dynobj, s))
- {
- if (! bfd_set_section_alignment (dynobj, s, power_of_two))
- return false;
- }
-
- /* Define the symbol as being at this point in the section. */
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
-
- /* Increment the section size to make room for the symbol. */
- s->_raw_size += h->size;
-
- return true;
-}
-
-/* Set the sizes of the dynamic sections. */
-
-static boolean
-elf32_sparc_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *s;
- boolean reltext;
- boolean relplt;
-
- dynobj = elf_hash_table (info)->dynobj;
- BFD_ASSERT (dynobj != NULL);
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Set the contents of the .interp section to the interpreter. */
- if (! info->shared)
- {
- s = bfd_get_section_by_name (dynobj, ".interp");
- BFD_ASSERT (s != NULL);
- s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
- s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
- }
-
- /* Make space for the trailing nop in .plt. */
- s = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (s != NULL);
- if (s->_raw_size > 0)
- s->_raw_size += 4;
- }
- else
- {
- /* We may have created entries in the .rela.got section.
- However, if we are not creating the dynamic sections, we will
- not actually use these entries. Reset the size of .rela.got,
- which will cause it to get stripped from the output file
- below. */
- s = bfd_get_section_by_name (dynobj, ".rela.got");
- if (s != NULL)
- s->_raw_size = 0;
- }
-
- /* The check_relocs and adjust_dynamic_symbol entry points have
- determined the sizes of the various dynamic sections. Allocate
- memory for them. */
- reltext = false;
- relplt = false;
- for (s = dynobj->sections; s != NULL; s = s->next)
- {
- const char *name;
- boolean strip;
-
- if ((s->flags & SEC_IN_MEMORY) == 0)
- continue;
-
- /* It's OK to base decisions on the section name, because none
- of the dynobj section names depend upon the input files. */
- name = bfd_get_section_name (dynobj, s);
-
- strip = false;
-
- if (strncmp (name, ".rela", 5) == 0)
- {
- if (s->_raw_size == 0)
- {
- /* If we don't need this section, strip it from the
- output file. This is to handle .rela.bss and
- .rel.plt. We must create it in
- create_dynamic_sections, because it must be created
- before the linker maps input sections to output
- sections. The linker does that before
- adjust_dynamic_symbol is called, and it is that
- function which decides whether anything needs to go
- into these sections. */
- strip = true;
- }
- else
- {
- asection *target;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL entry. */
- target = bfd_get_section_by_name (output_bfd, name + 5);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0)
- reltext = true;
-
- if (strcmp (name, ".rela.plt") == 0)
- relplt = true;
-
- /* We use the reloc_count field as a counter if we need
- to copy relocs into the output file. */
- s->reloc_count = 0;
- }
- }
- else if (strcmp (name, ".plt") != 0
- && strcmp (name, ".got") != 0)
- {
- /* It's not one of our sections, so don't allocate space. */
- continue;
- }
-
- if (strip)
- {
- asection **spp;
-
- for (spp = &s->output_section->owner->sections;
- *spp != s->output_section;
- spp = &(*spp)->next)
- ;
- *spp = s->output_section->next;
- --s->output_section->owner->section_count;
-
- continue;
- }
-
- /* Allocate memory for the section contents. */
- s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
- if (s->contents == NULL && s->_raw_size != 0)
- return false;
- }
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- /* Add some entries to the .dynamic section. We fill in the
- values later, in elf32_sparc_finish_dynamic_sections, but we
- must add the entries now so that we get the correct size for
- the .dynamic section. The DT_DEBUG entry is filled in by the
- dynamic linker and used by the debugger. */
- if (! info->shared)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
- return false;
- }
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
- return false;
-
- if (relplt)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
- return false;
- }
-
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
- return false;
-
- if (reltext)
- {
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
- return false;
- }
- }
-
- /* If we are generating a shared library, we generate a section
- symbol for each output section. These are local symbols, which
- means that they must come first in the dynamic symbol table.
- That means we must increment the dynamic symbol index of every
- other dynamic symbol. */
- if (info->shared)
- {
- int c, i;
-
- c = bfd_count_sections (output_bfd);
- elf_link_hash_traverse (elf_hash_table (info),
- elf32_sparc_adjust_dynindx,
- (PTR) &c);
- elf_hash_table (info)->dynsymcount += c;
-
- for (i = 1, s = output_bfd->sections; s != NULL; s = s->next, i++)
- {
- elf_section_data (s)->dynindx = i;
- /* These symbols will have no names, so we don't need to
- fiddle with dynstr_index. */
- }
- }
-
- return true;
-}
-
-/* Increment the index of a dynamic symbol by a given amount. Called
- via elf_link_hash_traverse. */
-
-static boolean
-elf32_sparc_adjust_dynindx (h, cparg)
- struct elf_link_hash_entry *h;
- PTR cparg;
-{
- int *cp = (int *) cparg;
-
- if (h->dynindx != -1)
- h->dynindx += *cp;
- return true;
-}
-
-/* Relocate a SPARC ELF section. */
-
-static boolean
-elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, local_syms, local_sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- Elf_Internal_Rela *relocs;
- Elf_Internal_Sym *local_syms;
- asection **local_sections;
-{
- bfd *dynobj;
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- bfd_vma *local_got_offsets;
- asection *sgot;
- asection *splt;
- asection *sreloc;
- Elf_Internal_Rela *rel;
- Elf_Internal_Rela *relend;
-
- dynobj = elf_hash_table (info)->dynobj;
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (input_bfd);
- local_got_offsets = elf_local_got_offsets (input_bfd);
-
- sgot = NULL;
- splt = NULL;
- sreloc = NULL;
-
- rel = relocs;
- relend = relocs + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- int r_type;
- reloc_howto_type *howto;
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
- asection *sec;
- bfd_vma relocation;
- bfd_reloc_status_type r;
-
- r_type = ELF32_R_TYPE (rel->r_info);
- if (r_type < 0 || r_type >= (int) R_SPARC_max)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- howto = _bfd_sparc_elf_howto_table + r_type;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
- h = NULL;
- sym = NULL;
- sec = NULL;
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- sec = local_sections[r_symndx];
- relocation = (sec->output_section->vma
- + sec->output_offset
- + sym->st_value);
- }
- else
- {
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- if ((r_type == R_SPARC_WPLT30
- && h->plt_offset != (bfd_vma) -1)
- || ((r_type == R_SPARC_GOT10
- || r_type == R_SPARC_GOT13
- || r_type == R_SPARC_GOT22)
- && elf_hash_table (info)->dynamic_sections_created
- && (! info->shared
- || ! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))
- || (info->shared
- && (! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)
- && (input_section->flags & SEC_ALLOC) != 0
- && (r_type == R_SPARC_8
- || r_type == R_SPARC_16
- || r_type == R_SPARC_32
- || r_type == R_SPARC_DISP8
- || r_type == R_SPARC_DISP16
- || r_type == R_SPARC_DISP32
- || r_type == R_SPARC_WDISP30
- || r_type == R_SPARC_WDISP22
- || r_type == R_SPARC_WDISP19
- || r_type == R_SPARC_WDISP16
- || r_type == R_SPARC_HI22
- || r_type == R_SPARC_22
- || r_type == R_SPARC_13
- || r_type == R_SPARC_LO10
- || r_type == R_SPARC_UA32
- || ((r_type == R_SPARC_PC10
- || r_type == R_SPARC_PC22)
- && strcmp (h->root.root.string,
- "_GLOBAL_OFFSET_TABLE_") != 0))))
- {
- /* In these cases, we don't need the relocation
- value. We check specially because in some
- obscure cases sec->output_section will be NULL. */
- relocation = 0;
- }
- else
- relocation = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else if (info->shared && !info->symbolic)
- relocation = 0;
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset)))
- return false;
- relocation = 0;
- }
- }
-
- switch (r_type)
- {
- case R_SPARC_GOT10:
- case R_SPARC_GOT13:
- case R_SPARC_GOT22:
- /* Relocation is to the entry for this symbol in the global
- offset table. */
- if (sgot == NULL)
- {
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- }
-
- if (h != NULL)
- {
- bfd_vma off;
-
- off = h->got_offset;
- BFD_ASSERT (off != (bfd_vma) -1);
-
- if (! elf_hash_table (info)->dynamic_sections_created
- || (info->shared
- && info->symbolic
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
- {
- /* This is actually a static link, or it is a
- -Bsymbolic link and the symbol is defined
- locally. We must initialize this entry in the
- global offset table. Since the offset must
- always be a multiple of 4, we use the least
- significant bit to record whether we have
- initialized it already.
-
- When doing a dynamic link, we create a .rela.got
- relocation entry to initialize the value. This
- is done in the finish_dynamic_symbol routine. */
- if ((off & 1) != 0)
- off &= ~1;
- else
- {
- bfd_put_32 (output_bfd, relocation,
- sgot->contents + off);
- h->got_offset |= 1;
- }
- }
-
- relocation = sgot->output_offset + off;
- }
- else
- {
- bfd_vma off;
-
- BFD_ASSERT (local_got_offsets != NULL
- && local_got_offsets[r_symndx] != (bfd_vma) -1);
-
- off = local_got_offsets[r_symndx];
-
- /* The offset must always be a multiple of 4. We use
- the least significant bit to record whether we have
- already processed this entry. */
- if ((off & 1) != 0)
- off &= ~1;
- else
- {
- bfd_put_32 (output_bfd, relocation, sgot->contents + off);
-
- if (info->shared)
- {
- asection *srelgot;
- Elf_Internal_Rela outrel;
-
- /* We need to generate a R_SPARC_RELATIVE reloc
- for the dynamic linker. */
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
- BFD_ASSERT (srelgot != NULL);
-
- outrel.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + off);
- outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
- outrel.r_addend = 0;
- bfd_elf32_swap_reloca_out (output_bfd, &outrel,
- (((Elf32_External_Rela *)
- srelgot->contents)
- + srelgot->reloc_count));
- ++srelgot->reloc_count;
- }
-
- local_got_offsets[r_symndx] |= 1;
- }
-
- relocation = sgot->output_offset + off;
- }
-
- break;
-
- case R_SPARC_WPLT30:
- /* Relocation is to the entry for this symbol in the
- procedure linkage table. */
- BFD_ASSERT (h != NULL);
-
- if (h->plt_offset == (bfd_vma) -1)
- {
- /* We didn't make a PLT entry for this symbol. This
- happens when statically linking PIC code, or when
- using -Bsymbolic. */
- break;
- }
-
- if (splt == NULL)
- {
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL);
- }
-
- relocation = (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset);
- break;
-
- case R_SPARC_PC10:
- case R_SPARC_PC22:
- if (h != NULL
- && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
- break;
- /* Fall through. */
- case R_SPARC_DISP8:
- case R_SPARC_DISP16:
- case R_SPARC_DISP32:
- case R_SPARC_WDISP30:
- case R_SPARC_WDISP22:
- case R_SPARC_WDISP19:
- case R_SPARC_WDISP16:
- if (h == NULL)
- break;
- /* Fall through. */
- case R_SPARC_8:
- case R_SPARC_16:
- case R_SPARC_32:
- case R_SPARC_HI22:
- case R_SPARC_22:
- case R_SPARC_13:
- case R_SPARC_LO10:
- case R_SPARC_UA32:
- if (info->shared
- && (input_section->flags & SEC_ALLOC) != 0)
- {
- Elf_Internal_Rela outrel;
-
- /* When generating a shared object, these relocations
- are copied into the output file to be resolved at run
- time. */
-
- if (sreloc == NULL)
- {
- const char *name;
-
- name = (bfd_elf_string_from_elf_section
- (input_bfd,
- elf_elfheader (input_bfd)->e_shstrndx,
- elf_section_data (input_section)->rel_hdr.sh_name));
- if (name == NULL)
- return false;
-
- BFD_ASSERT (strncmp (name, ".rela", 5) == 0
- && strcmp (bfd_get_section_name (input_bfd,
- input_section),
- name + 5) == 0);
-
- sreloc = bfd_get_section_by_name (dynobj, name);
- BFD_ASSERT (sreloc != NULL);
- }
-
- outrel.r_offset = (rel->r_offset
- + input_section->output_section->vma
- + input_section->output_offset);
- if (h != NULL
- && (! info->symbolic
- || (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0))
- {
- BFD_ASSERT (h->dynindx != -1);
- outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
- outrel.r_addend = rel->r_addend;
- }
- else
- {
- if (r_type == R_SPARC_32)
- {
- outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
- outrel.r_addend = relocation + rel->r_addend;
- }
- else
- {
- long indx;
-
- if (h == NULL)
- sec = local_sections[r_symndx];
- else
- {
- BFD_ASSERT (h->root.type == bfd_link_hash_defined
- || (h->root.type
- == bfd_link_hash_defweak));
- sec = h->root.u.def.section;
- }
- if (sec != NULL && bfd_is_abs_section (sec))
- indx = 0;
- else if (sec == NULL || sec->owner == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- else
- {
- asection *osec;
-
- osec = sec->output_section;
- indx = elf_section_data (osec)->dynindx;
- if (indx == 0)
- abort ();
- }
-
- outrel.r_info = ELF32_R_INFO (indx, r_type);
- outrel.r_addend = relocation + rel->r_addend;
- }
- }
-
- bfd_elf32_swap_reloca_out (output_bfd, &outrel,
- (((Elf32_External_Rela *)
- sreloc->contents)
- + sreloc->reloc_count));
- ++sreloc->reloc_count;
-
- /* This reloc will be computed at runtime, so there's no
- need to do anything now. */
- continue;
- }
-
- default:
- break;
- }
-
- if (r_type != R_SPARC_WDISP16)
- r = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents, rel->r_offset,
- relocation, rel->r_addend);
- else
- {
- bfd_vma x;
-
- relocation += rel->r_addend;
- relocation -= (input_section->output_section->vma
- + input_section->output_offset);
- relocation -= rel->r_offset;
-
- x = bfd_get_32 (input_bfd, contents + rel->r_offset);
- x |= ((((relocation >> 2) & 0xc000) << 6)
- | ((relocation >> 2) & 0x3fff));
- bfd_put_32 (input_bfd, x, contents + rel->r_offset);
-
- if ((bfd_signed_vma) relocation < - 0x40000
- || (bfd_signed_vma) relocation > 0x3ffff)
- r = bfd_reloc_overflow;
- else
- r = bfd_reloc_ok;
- }
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name);
- if (name == NULL)
- return false;
- if (*name == '\0')
- name = bfd_section_name (input_bfd, sec);
- }
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Finish up dynamic symbol handling. We set the contents of various
- dynamic sections here. */
-
-static boolean
-elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
-{
- bfd *dynobj;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- if (h->plt_offset != (bfd_vma) -1)
- {
- asection *splt;
- asection *srela;
- Elf_Internal_Rela rela;
-
- /* This symbol has an entry in the procedure linkage table. Set
- it up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- srela = bfd_get_section_by_name (dynobj, ".rela.plt");
- BFD_ASSERT (splt != NULL && srela != NULL);
-
- /* Fill in the entry in the procedure linkage table. */
- bfd_put_32 (output_bfd,
- PLT_ENTRY_WORD0 + h->plt_offset,
- splt->contents + h->plt_offset);
- bfd_put_32 (output_bfd,
- (PLT_ENTRY_WORD1
- + (((- (h->plt_offset + 4)) >> 2) & 0x3fffff)),
- splt->contents + h->plt_offset + 4);
- bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,
- splt->contents + h->plt_offset + 8);
-
- /* Fill in the entry in the .rela.plt section. */
- rela.r_offset = (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset);
- rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
- rela.r_addend = 0;
- bfd_elf32_swap_reloca_out (output_bfd, &rela,
- ((Elf32_External_Rela *) srela->contents
- + h->plt_offset / PLT_ENTRY_SIZE - 4));
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- {
- /* Mark the symbol as undefined, rather than as defined in
- the .plt section. Leave the value alone. */
- sym->st_shndx = SHN_UNDEF;
- }
- }
-
- if (h->got_offset != (bfd_vma) -1)
- {
- asection *sgot;
- asection *srela;
- Elf_Internal_Rela rela;
-
- /* This symbol has an entry in the global offset table. Set it
- up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- sgot = bfd_get_section_by_name (dynobj, ".got");
- srela = bfd_get_section_by_name (dynobj, ".rela.got");
- BFD_ASSERT (sgot != NULL && srela != NULL);
-
- rela.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + (h->got_offset &~ 1));
-
- /* If this is a -Bsymbolic link, and the symbol is defined
- locally, we just want to emit a RELATIVE reloc. The entry in
- the global offset table will already have been initialized in
- the relocate_section function. */
- if (info->shared
- && info->symbolic
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
- rela.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
- else
- {
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got_offset);
- rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_GLOB_DAT);
- }
-
- rela.r_addend = 0;
- bfd_elf32_swap_reloca_out (output_bfd, &rela,
- ((Elf32_External_Rela *) srela->contents
- + srela->reloc_count));
- ++srela->reloc_count;
- }
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
- {
- asection *s;
- Elf_Internal_Rela rela;
-
- /* This symbols needs a copy reloc. Set it up. */
-
- BFD_ASSERT (h->dynindx != -1);
-
- s = bfd_get_section_by_name (h->root.u.def.section->owner,
- ".rela.bss");
- BFD_ASSERT (s != NULL);
-
- rela.r_offset = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
- rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_COPY);
- rela.r_addend = 0;
- bfd_elf32_swap_reloca_out (output_bfd, &rela,
- ((Elf32_External_Rela *) s->contents
- + s->reloc_count));
- ++s->reloc_count;
- }
-
- /* Mark some specially defined symbols as absolute. */
- if (strcmp (h->root.root.string, "_DYNAMIC") == 0
- || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
- || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
- sym->st_shndx = SHN_ABS;
-
- return true;
-}
-
-/* Finish up the dynamic sections. */
-
-static boolean
-elf32_sparc_finish_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *sdyn;
- asection *sgot;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- asection *splt;
- Elf32_External_Dyn *dyncon, *dynconend;
-
- splt = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (splt != NULL && sdyn != NULL);
-
- dyncon = (Elf32_External_Dyn *) sdyn->contents;
- dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
- for (; dyncon < dynconend; dyncon++)
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- boolean size;
-
- bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
-
- switch (dyn.d_tag)
- {
- case DT_PLTGOT: name = ".plt"; size = false; break;
- case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
- case DT_JMPREL: name = ".rela.plt"; size = false; break;
- default: name = NULL; size = false; break;
- }
-
- if (name != NULL)
- {
- asection *s;
-
- s = bfd_get_section_by_name (output_bfd, name);
- if (s == NULL)
- dyn.d_un.d_val = 0;
- else
- {
- if (! size)
- dyn.d_un.d_ptr = s->vma;
- else
- {
- if (s->_cooked_size != 0)
- dyn.d_un.d_val = s->_cooked_size;
- else
- dyn.d_un.d_val = s->_raw_size;
- }
- }
- bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
- }
- }
-
- /* Clear the first four entries in the procedure linkage table,
- and put a nop in the last four bytes. */
- if (splt->_raw_size > 0)
- {
- memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE);
- bfd_put_32 (output_bfd, SPARC_NOP,
- splt->contents + splt->_raw_size - 4);
- }
-
- elf_section_data (splt->output_section)->this_hdr.sh_entsize =
- PLT_ENTRY_SIZE;
- }
-
- /* Set the first entry in the global offset table to the address of
- the dynamic section. */
- sgot = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (sgot != NULL);
- if (sgot->_raw_size > 0)
- {
- if (sdyn == NULL)
- bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
- else
- bfd_put_32 (output_bfd,
- sdyn->output_section->vma + sdyn->output_offset,
- sgot->contents);
- }
-
- elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
-
- if (info->shared)
- {
- asection *sdynsym;
- asection *s;
- Elf_Internal_Sym sym;
-
- /* Set up the section symbols for the output sections. */
-
- sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
- BFD_ASSERT (sdynsym != NULL);
-
- sym.st_size = 0;
- sym.st_name = 0;
- sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
- sym.st_other = 0;
-
- for (s = output_bfd->sections; s != NULL; s = s->next)
- {
- int indx;
-
- sym.st_value = s->vma;
-
- indx = elf_section_data (s)->this_idx;
- BFD_ASSERT (indx > 0);
- sym.st_shndx = indx;
-
- bfd_elf32_swap_symbol_out (output_bfd, &sym,
- (PTR) (((Elf32_External_Sym *)
- sdynsym->contents)
- + elf_section_data (s)->dynindx));
- }
-
- /* Set the sh_info field of the output .dynsym section to the
- index of the first global symbol. */
- elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
- bfd_count_sections (output_bfd) + 1;
- }
-
- return true;
-}
-
-/* Functions for dealing with the e_flags field.
-
- We don't define set_private_flags or copy_private_bfd_data because
- the only currently defined values are based on the bfd mach number,
- so we use the latter instead and defer setting e_flags until the
- file is written out. */
-
-/* Merge backend specific data from an object file to the output
- object file when linking. */
-
-static boolean
-elf32_sparc_merge_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- boolean error;
-
- /* This function is selected based on the input vector. We only
- want to copy information over if the output BFD also uses Elf
- format. */
- if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return true;
-
- error = false;
-
-#if 0
- /* ??? The native linker doesn't do this so we can't (otherwise gcc would
- have to know which linker is being used). Instead, the native linker
- bumps up the architecture level when it has to. However, I still think
- warnings like these are good, so it would be nice to have them turned on
- by some option. */
-
- /* If the output machine is normal sparc, we can't allow v9 input files. */
- if (bfd_get_mach (obfd) == bfd_mach_sparc
- && (bfd_get_mach (ibfd) == bfd_mach_sparc_v8plus
- || bfd_get_mach (ibfd) == bfd_mach_sparc_v8plusa))
- {
- error = true;
- (*_bfd_error_handler)
- ("%s: compiled for a v8plus system and target is v8",
- bfd_get_filename (ibfd));
- }
- /* If the output machine is v9, we can't allow v9+vis input files. */
- if (bfd_get_mach (obfd) == bfd_mach_sparc_v8plus
- && bfd_get_mach (ibfd) == bfd_mach_sparc_v8plusa)
- {
- error = true;
- (*_bfd_error_handler)
- ("%s: compiled for a v8plusa system and target is v8plus",
- bfd_get_filename (ibfd));
- }
-#else
- if (bfd_get_mach (ibfd) >= bfd_mach_sparc_v9)
- {
- error = true;
- (*_bfd_error_handler)
- ("%s: compiled for a 64 bit system and target is 32 bit",
- bfd_get_filename (ibfd));
- }
- else if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
- bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
-#endif
-
- if (error)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- return true;
-}
-
-/* Set the right machine number. */
-
-static boolean
-elf32_sparc_object_p (abfd)
- bfd *abfd;
-{
- if (elf_elfheader (abfd)->e_machine == EM_SPARC32PLUS)
- {
- if (elf_elfheader (abfd)->e_flags & EF_SPARC_SUN_US1)
- return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
- bfd_mach_sparc_v8plusa);
- else if (elf_elfheader (abfd)->e_flags & EF_SPARC_32PLUS)
- return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
- bfd_mach_sparc_v8plus);
- else
- return false;
- }
- else
- return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc);
-}
-
-/* The final processing done just before writing out the object file.
- We need to set the e_machine field appropriately. */
-
-static void
-elf32_sparc_final_write_processing (abfd, linker)
- bfd *abfd;
- boolean linker;
-{
- switch (bfd_get_mach (abfd))
- {
- case bfd_mach_sparc :
- break; /* nothing to do */
- case bfd_mach_sparc_v8plus :
- elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
- elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
- elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS;
- break;
- case bfd_mach_sparc_v8plusa :
- elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
- elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
- elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS | EF_SPARC_SUN_US1;
- break;
- default :
- abort ();
- }
-}
-
-#define TARGET_BIG_SYM bfd_elf32_sparc_vec
-#define TARGET_BIG_NAME "elf32-sparc"
-#define ELF_ARCH bfd_arch_sparc
-#define ELF_MACHINE_CODE EM_SPARC
-#define ELF_MACHINE_ALT1 EM_SPARC32PLUS
-#define ELF_MAXPAGESIZE 0x10000
-
-#define bfd_elf32_bfd_reloc_type_lookup elf32_sparc_reloc_type_lookup
-#define elf_backend_create_dynamic_sections \
- _bfd_elf_create_dynamic_sections
-#define elf_backend_check_relocs elf32_sparc_check_relocs
-#define elf_backend_adjust_dynamic_symbol \
- elf32_sparc_adjust_dynamic_symbol
-#define elf_backend_size_dynamic_sections \
- elf32_sparc_size_dynamic_sections
-#define elf_backend_relocate_section elf32_sparc_relocate_section
-#define elf_backend_finish_dynamic_symbol \
- elf32_sparc_finish_dynamic_symbol
-#define elf_backend_finish_dynamic_sections \
- elf32_sparc_finish_dynamic_sections
-#define bfd_elf32_bfd_merge_private_bfd_data \
- elf32_sparc_merge_private_bfd_data
-#define elf_backend_object_p elf32_sparc_object_p
-#define elf_backend_final_write_processing \
- elf32_sparc_final_write_processing
-#define elf_backend_want_got_plt 0
-#define elf_backend_plt_readonly 0
-#define elf_backend_want_plt_sym 1
-
-#include "elf32-target.h"
diff --git a/contrib/gdb/bfd/elf32.c b/contrib/gdb/bfd/elf32.c
deleted file mode 100644
index f222969..0000000
--- a/contrib/gdb/bfd/elf32.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ELF 32-bit executable support for BFD.
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define ARCH_SIZE 32
-
-
-#include "elfcode.h"
diff --git a/contrib/gdb/bfd/elf64-gen.c b/contrib/gdb/bfd/elf64-gen.c
deleted file mode 100644
index 5daf4ee..0000000
--- a/contrib/gdb/bfd/elf64-gen.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Generic support for 64-bit ELF
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-
-/* This does not include any relocations, but should be good enough
- for GDB to read the file. */
-
-#define TARGET_LITTLE_SYM bfd_elf64_little_generic_vec
-#define TARGET_LITTLE_NAME "elf64-little"
-#define TARGET_BIG_SYM bfd_elf64_big_generic_vec
-#define TARGET_BIG_NAME "elf64-big"
-#define ELF_ARCH bfd_arch_unknown
-#define ELF_MACHINE_CODE EM_NONE
-#define bfd_elf64_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
-#define elf_info_to_howto _bfd_elf_no_info_to_howto
-
-#include "elf64-target.h"
diff --git a/contrib/gdb/bfd/elf64-sparc.c b/contrib/gdb/bfd/elf64-sparc.c
deleted file mode 100644
index 5059b80..0000000
--- a/contrib/gdb/bfd/elf64-sparc.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/* SPARC-specific support for 64-bit ELF
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* We need a published ABI spec for this. Until one comes out, don't
- assume this'll remain unchanged forever. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-
-#define SPARC64_OLD_RELOCS
-#include "elf/sparc.h"
-
-static reloc_howto_type *sparc64_elf_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void elf_info_to_howto
- PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-
-static boolean sparc64_elf_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static boolean sparc64_elf_object_p PARAMS ((bfd *));
-
-/* The howto table and associated functions.
- ??? Some of the relocation values have changed. Until we're ready
- to upgrade, we have our own copy. At some point a non upward compatible
- change will be made at which point this table can be deleted and we'll
- use the one in elf32-sparc.c. */
-
-static bfd_reloc_status_type sparc_elf_wdisp16_reloc
- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-
-static reloc_howto_type sparc64_elf_howto_table[] =
-{
- HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
- HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_8", false,0,0x000000ff,true),
- HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_16", false,0,0x0000ffff,true),
- HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_32", false,0,0xffffffff,true),
- HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP8", false,0,0x000000ff,true),
- HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP16", false,0,0x0000ffff,true),
- HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP32", false,0,0x00ffffff,true),
- HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP30", false,0,0x3fffffff,true),
- HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HI22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_13", false,0,0x00001fff,true),
- HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LO10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_GOT13", false,0,0x00001fff,true),
- HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_PC10, 0,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_PC22, 10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PC22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_WPLT30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WPLT30", false,0,0x3fffffff,true),
- HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_COPY", false,0,0x00000000,true),
- HOWTO(R_SPARC_GLOB_DAT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
- HOWTO(R_SPARC_JMP_SLOT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_JMP_SLOT",false,0,0x00000000,true),
- HOWTO(R_SPARC_RELATIVE, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_RELATIVE",false,0,0x00000000,true),
- HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UA32", false,0,0x00000000,true),
-#if 0 /* not used yet */
- HOWTO(R_SPARC_PLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PLT32", false,0,0x00000000,true),
- HOWTO(R_SPARC_HIPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HIPLT22", false,0,0x00000000,true),
- HOWTO(R_SPARC_LOPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LOPLT10", false,0,0x00000000,true),
- HOWTO(R_SPARC_PCPLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT32", false,0,0x00000000,true),
- HOWTO(R_SPARC_PCPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT22", false,0,0x00000000,true),
- HOWTO(R_SPARC_PCPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT10", false,0,0x00000000,true),
-#endif
- HOWTO(R_SPARC_10, 0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_11, 0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_11", false,0,0x000007ff,true),
- HOWTO(R_SPARC_64, 0,4,00,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_64", false,0,~ (bfd_vma) 0, true),
- HOWTO(R_SPARC_OLO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_OLO10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_HH22, 42,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HH22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_HM10, 32,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HM10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_LM22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LM22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_PC_HH22, 42,2,22,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HH22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_PC_HM10, 32,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HM10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_PC_LM22, 10,2,22,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LM22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,complain_overflow_signed, sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true),
- HOWTO(R_SPARC_WDISP19, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP19", false,0,0x0007ffff,true),
- HOWTO(R_SPARC_GLOB_JMP, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
- HOWTO(R_SPARC_7, 0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_7", false,0,0x0000007f,true),
-#if 0 /* not used yet */
- HOWTO(R_SPARC_5, 0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_5", false,0,0x0000001f,true),
- HOWTO(R_SPARC_6, 0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_6", false,0,0x0000003f,true),
-#endif
-};
-
-struct elf_reloc_map {
- unsigned char bfd_reloc_val;
- unsigned char elf_reloc_val;
-};
-
-static CONST struct elf_reloc_map sparc_reloc_map[] =
-{
- { BFD_RELOC_NONE, R_SPARC_NONE, },
- { BFD_RELOC_16, R_SPARC_16, },
- { BFD_RELOC_8, R_SPARC_8 },
- { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
- /* ??? This might cause us to need separate functions in elf{32,64}-sparc.c
- (we could still have just one table), but is this reloc ever used? */
- { BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
- { BFD_RELOC_32, R_SPARC_32 },
- { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
- { BFD_RELOC_HI22, R_SPARC_HI22 },
- { BFD_RELOC_LO10, R_SPARC_LO10, },
- { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
- { BFD_RELOC_SPARC22, R_SPARC_22 },
- { BFD_RELOC_SPARC13, R_SPARC_13 },
- { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
- { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
- { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
- { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
- { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
- { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
- { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
- { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
- { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
- { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
- { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
- /* ??? Doesn't dwarf use this? */
-/*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
- {BFD_RELOC_SPARC_10, R_SPARC_10},
- {BFD_RELOC_SPARC_11, R_SPARC_11},
- {BFD_RELOC_SPARC_64, R_SPARC_64},
- {BFD_RELOC_SPARC_OLO10, R_SPARC_OLO10},
- {BFD_RELOC_SPARC_HH22, R_SPARC_HH22},
- {BFD_RELOC_SPARC_HM10, R_SPARC_HM10},
- {BFD_RELOC_SPARC_LM22, R_SPARC_LM22},
- {BFD_RELOC_SPARC_PC_HH22, R_SPARC_PC_HH22},
- {BFD_RELOC_SPARC_PC_HM10, R_SPARC_PC_HM10},
- {BFD_RELOC_SPARC_PC_LM22, R_SPARC_PC_LM22},
- {BFD_RELOC_SPARC_WDISP16, R_SPARC_WDISP16},
- {BFD_RELOC_SPARC_WDISP19, R_SPARC_WDISP19},
- {BFD_RELOC_SPARC_GLOB_JMP, R_SPARC_GLOB_JMP},
- {BFD_RELOC_SPARC_7, R_SPARC_7},
-#if 0 /* unused */
- {BFD_RELOC_SPARC_5, R_SPARC_5},
- {BFD_RELOC_SPARC_6, R_SPARC_6},
-#endif
-};
-
-static reloc_howto_type *
-sparc64_elf_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- unsigned int i;
- for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
- {
- if (sparc_reloc_map[i].bfd_reloc_val == code)
- return &sparc64_elf_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
- }
- return 0;
-}
-
-static void
-elf_info_to_howto (abfd, cache_ptr, dst)
- bfd *abfd;
- arelent *cache_ptr;
- Elf64_Internal_Rela *dst;
-{
- BFD_ASSERT (ELF64_R_TYPE (dst->r_info) < (unsigned int) R_SPARC_max);
- cache_ptr->howto = &sparc64_elf_howto_table[ELF64_R_TYPE (dst->r_info)];
-}
-
-/* Handle the WDISP16 reloc. */
-
-static bfd_reloc_status_type
-sparc_elf_wdisp16_reloc (abfd,
- reloc_entry,
- symbol,
- data,
- input_section,
- output_bfd,
- error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_vma relocation;
- bfd_vma x;
-
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && (! reloc_entry->howto->partial_inplace
- || reloc_entry->addend == 0))
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- if (output_bfd != NULL)
- return bfd_reloc_continue;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- relocation = (symbol->value
- + symbol->section->output_section->vma
- + symbol->section->output_offset);
- relocation += reloc_entry->addend;
- relocation -= (input_section->output_section->vma
- + input_section->output_offset);
- relocation -= reloc_entry->address;
-
- x = bfd_get_32 (abfd, (char *) data + reloc_entry->address);
- x |= ((((relocation >> 2) & 0xc000) << 6)
- | ((relocation >> 2) & 0x3fff));
- bfd_put_32 (abfd, x, (char *) data + reloc_entry->address);
-
- if ((bfd_signed_vma) relocation < - 0x40000
- || (bfd_signed_vma) relocation > 0x3ffff)
- return bfd_reloc_overflow;
- else
- return bfd_reloc_ok;
-}
-
-/* Relocate a SPARC64 ELF section. */
-
-static boolean
-sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
- contents, relocs, local_syms, local_sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- Elf_Internal_Rela *relocs;
- Elf_Internal_Sym *local_syms;
- asection **local_sections;
-{
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- Elf_Internal_Rela *rel;
- Elf_Internal_Rela *relend;
-
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (input_bfd);
-
- rel = relocs;
- relend = relocs + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- int r_type;
- reloc_howto_type *howto;
- long r_symndx;
- struct elf_link_hash_entry *h;
- Elf_Internal_Sym *sym;
- asection *sec;
- bfd_vma relocation;
- bfd_reloc_status_type r;
-
- r_type = ELF64_R_TYPE (rel->r_info);
- if (r_type < 0 || r_type >= (int) R_SPARC_max)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- howto = sparc64_elf_howto_table + r_type;
-
- r_symndx = ELF64_R_SYM (rel->r_info);
-
- if (info->relocateable)
- {
- /* This is a relocateable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- rel->r_addend += sec->output_offset + sym->st_value;
- }
- }
-
- continue;
- }
-
- /* This is a final link. */
- h = NULL;
- sym = NULL;
- sec = NULL;
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
- sec = local_sections[r_symndx];
- relocation = (sec->output_section->vma
- + sec->output_offset
- + sym->st_value);
- }
- else
- {
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- relocation = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset)))
- return false;
- relocation = 0;
- }
- }
-
- if (r_type != R_SPARC_WDISP16)
- r = _bfd_final_link_relocate (howto, input_bfd, input_section,
- contents, rel->r_offset,
- relocation, rel->r_addend);
- else
- {
- bfd_vma x;
-
- relocation += rel->r_addend;
- relocation -= (input_section->output_section->vma
- + input_section->output_offset);
- relocation -= rel->r_offset;
-
- x = bfd_get_32 (input_bfd, contents + rel->r_offset);
- x |= ((((relocation >> 2) & 0xc000) << 6)
- | ((relocation >> 2) & 0x3fff));
- bfd_put_32 (input_bfd, x, contents + rel->r_offset);
-
- if ((bfd_signed_vma) relocation < - 0x40000
- || (bfd_signed_vma) relocation > 0x3ffff)
- r = bfd_reloc_overflow;
- else
- r = bfd_reloc_ok;
- }
-
- if (r != bfd_reloc_ok)
- {
- switch (r)
- {
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- {
- const char *name;
-
- if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = (bfd_elf_string_from_elf_section
- (input_bfd,
- symtab_hdr->sh_link,
- sym->st_name));
- if (name == NULL)
- return false;
- if (*name == '\0')
- name = bfd_section_name (input_bfd, sec);
- }
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset)))
- return false;
- }
- break;
- }
- }
- }
-
- return true;
-}
-
-/* Set the right machine number for a SPARC64 ELF file. */
-
-static boolean
-sparc64_elf_object_p (abfd)
- bfd *abfd;
-{
- return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc_v9);
-}
-
-#define TARGET_BIG_SYM bfd_elf64_sparc_vec
-#define TARGET_BIG_NAME "elf64-sparc"
-#define ELF_ARCH bfd_arch_sparc
-#define ELF_MACHINE_CODE EM_SPARC64
-#define ELF_MAXPAGESIZE 0x100000
-
-#define bfd_elf64_bfd_reloc_type_lookup sparc64_elf_reloc_type_lookup
-#define elf_backend_relocate_section sparc64_elf_relocate_section
-#define elf_backend_object_p sparc64_elf_object_p
-
-#include "elf64-target.h"
diff --git a/contrib/gdb/bfd/elf64.c b/contrib/gdb/bfd/elf64.c
deleted file mode 100644
index 69fb5b5..0000000
--- a/contrib/gdb/bfd/elf64.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* ELF 64-bit executable support for BFD.
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define ARCH_SIZE 64
-
-#include "elfcode.h"
diff --git a/contrib/gdb/bfd/elfcode.h b/contrib/gdb/bfd/elfcode.h
deleted file mode 100644
index a6199f0..0000000
--- a/contrib/gdb/bfd/elfcode.h
+++ /dev/null
@@ -1,1406 +0,0 @@
-/* ELF executable support for BFD.
- Copyright 1991, 1992, 1993, 1994, 1995, 1996 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". Sufficient support for gdb.
-
- Rewritten by Mark Eichin @ Cygnus Support, from information
- published in "System V Application Binary Interface", chapters 4
- and 5, as well as the various "Processor Supplement" documents
- derived from it. Added support for assembler and other object file
- utilities. Further work done by Ken Raeburn (Cygnus Support), Michael
- Meissner (Open Software Foundation), and Peter Hoogenboom (University
- of Utah) to finish and extend this.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* 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)
-
- (2) The code in this file is compiled twice, once in 32-bit mode and
- once in 64-bit mode. More of it should be made size-independent
- and moved into elf.c.
-
- (3) ELF section symbols are handled rather sloppily now. This should
- be cleaned up, and ELF section symbols reconciled with BFD section
- symbols.
-
- (4) We need a published spec for 64-bit ELF. We've got some stuff here
- that we're using for SPARC V9 64-bit chips, but don't assume that
- it's cast in stone.
- */
-
-#include <string.h> /* For strrchr and friends */
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "elf-bfd.h"
-
-/* Renaming structures, typedefs, macros and functions to be size-specific. */
-#define Elf_External_Ehdr NAME(Elf,External_Ehdr)
-#define Elf_External_Sym NAME(Elf,External_Sym)
-#define Elf_External_Shdr NAME(Elf,External_Shdr)
-#define Elf_External_Phdr NAME(Elf,External_Phdr)
-#define Elf_External_Rel NAME(Elf,External_Rel)
-#define Elf_External_Rela NAME(Elf,External_Rela)
-#define Elf_External_Dyn NAME(Elf,External_Dyn)
-
-#define elf_core_file_failing_command NAME(bfd_elf,core_file_failing_command)
-#define elf_core_file_failing_signal NAME(bfd_elf,core_file_failing_signal)
-#define elf_core_file_matches_executable_p \
- NAME(bfd_elf,core_file_matches_executable_p)
-#define elf_object_p NAME(bfd_elf,object_p)
-#define elf_core_file_p NAME(bfd_elf,core_file_p)
-#define elf_get_symtab_upper_bound NAME(bfd_elf,get_symtab_upper_bound)
-#define elf_get_dynamic_symtab_upper_bound \
- NAME(bfd_elf,get_dynamic_symtab_upper_bound)
-#define elf_swap_reloc_in NAME(bfd_elf,swap_reloc_in)
-#define elf_swap_reloca_in NAME(bfd_elf,swap_reloca_in)
-#define elf_swap_reloc_out NAME(bfd_elf,swap_reloc_out)
-#define elf_swap_reloca_out NAME(bfd_elf,swap_reloca_out)
-#define elf_swap_symbol_in NAME(bfd_elf,swap_symbol_in)
-#define elf_swap_symbol_out NAME(bfd_elf,swap_symbol_out)
-#define elf_swap_phdr_in NAME(bfd_elf,swap_phdr_in)
-#define elf_swap_phdr_out NAME(bfd_elf,swap_phdr_out)
-#define elf_swap_dyn_in NAME(bfd_elf,swap_dyn_in)
-#define elf_swap_dyn_out NAME(bfd_elf,swap_dyn_out)
-#define elf_get_reloc_upper_bound NAME(bfd_elf,get_reloc_upper_bound)
-#define elf_canonicalize_reloc NAME(bfd_elf,canonicalize_reloc)
-#define elf_get_symtab NAME(bfd_elf,get_symtab)
-#define elf_canonicalize_dynamic_symtab \
- NAME(bfd_elf,canonicalize_dynamic_symtab)
-#define elf_make_empty_symbol NAME(bfd_elf,make_empty_symbol)
-#define elf_get_symbol_info NAME(bfd_elf,get_symbol_info)
-#define elf_get_lineno NAME(bfd_elf,get_lineno)
-#define elf_set_arch_mach NAME(bfd_elf,set_arch_mach)
-#define elf_find_nearest_line NAME(bfd_elf,find_nearest_line)
-#define elf_sizeof_headers NAME(bfd_elf,sizeof_headers)
-#define elf_set_section_contents NAME(bfd_elf,set_section_contents)
-#define elf_no_info_to_howto NAME(bfd_elf,no_info_to_howto)
-#define elf_no_info_to_howto_rel NAME(bfd_elf,no_info_to_howto_rel)
-#define elf_find_section NAME(bfd_elf,find_section)
-#define elf_bfd_link_add_symbols NAME(bfd_elf,bfd_link_add_symbols)
-#define elf_add_dynamic_entry NAME(bfd_elf,add_dynamic_entry)
-#define elf_link_create_dynamic_sections \
- NAME(bfd_elf,link_create_dynamic_sections)
-#define elf_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
-#define elf_bfd_final_link NAME(bfd_elf,bfd_final_link)
-#define elf_create_pointer_linker_section NAME(bfd_elf,create_pointer_linker_section)
-#define elf_finish_pointer_linker_section NAME(bfd_elf,finish_pointer_linker_section)
-
-#if ARCH_SIZE == 64
-#define ELF_R_INFO(X,Y) ELF64_R_INFO(X,Y)
-#define ELF_R_SYM(X) ELF64_R_SYM(X)
-#define ELF_R_TYPE(X) ELF64_R_TYPE(X)
-#define ELFCLASS ELFCLASS64
-#define FILE_ALIGN 8
-#define LOG_FILE_ALIGN 3
-#endif
-#if ARCH_SIZE == 32
-#define ELF_R_INFO(X,Y) ELF32_R_INFO(X,Y)
-#define ELF_R_SYM(X) ELF32_R_SYM(X)
-#define ELF_R_TYPE(X) ELF32_R_TYPE(X)
-#define ELFCLASS ELFCLASS32
-#define FILE_ALIGN 4
-#define LOG_FILE_ALIGN 2
-#endif
-
-/* Forward declarations of static functions */
-
-#define elf_stringtab_init _bfd_elf_stringtab_init
-
-extern struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
-#define section_from_elf_index bfd_section_from_elf_index
-extern boolean bfd_section_from_phdr PARAMS ((bfd *, Elf_Internal_Phdr *,
- int));
-
-static long elf_slurp_symbol_table PARAMS ((bfd *, asymbol **, boolean));
-
-static boolean elf_slurp_reloc_table PARAMS ((bfd *, asection *, asymbol **));
-
- int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *,
- struct symbol_cache_entry **));
-
-static boolean validate_reloc PARAMS ((bfd *, arelent *));
-static void write_relocs PARAMS ((bfd *, asection *, PTR));
-
- boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
-
-#ifdef DEBUG
-static void elf_debug_section PARAMS ((int, Elf_Internal_Shdr *));
-static void elf_debug_file PARAMS ((Elf_Internal_Ehdr *));
-static char *elf_symbol_flags PARAMS ((flagword));
-#endif
-
-/* Structure swapping routines */
-
-/* Should perhaps use put_offset, put_word, etc. For now, the two versions
- can be handled by explicitly specifying 32 bits or "the long type". */
-#if ARCH_SIZE == 64
-#define put_word bfd_h_put_64
-#define get_word bfd_h_get_64
-#endif
-#if ARCH_SIZE == 32
-#define put_word bfd_h_put_32
-#define get_word bfd_h_get_32
-#endif
-
-/* Translate an ELF symbol in external format into an ELF symbol in internal
- format. */
-
-void
-elf_swap_symbol_in (abfd, src, dst)
- bfd *abfd;
- Elf_External_Sym *src;
- Elf_Internal_Sym *dst;
-{
- dst->st_name = bfd_h_get_32 (abfd, (bfd_byte *) src->st_name);
- dst->st_value = get_word (abfd, (bfd_byte *) src->st_value);
- dst->st_size = get_word (abfd, (bfd_byte *) src->st_size);
- dst->st_info = bfd_h_get_8 (abfd, (bfd_byte *) src->st_info);
- dst->st_other = bfd_h_get_8 (abfd, (bfd_byte *) src->st_other);
- dst->st_shndx = bfd_h_get_16 (abfd, (bfd_byte *) src->st_shndx);
-}
-
-/* Translate an ELF symbol in internal format into an ELF symbol in external
- format. */
-
-void
-elf_swap_symbol_out (abfd, src, cdst)
- bfd *abfd;
- Elf_Internal_Sym *src;
- PTR cdst;
-{
- Elf_External_Sym *dst = (Elf_External_Sym *) cdst;
- bfd_h_put_32 (abfd, src->st_name, dst->st_name);
- put_word (abfd, src->st_value, dst->st_value);
- put_word (abfd, src->st_size, dst->st_size);
- bfd_h_put_8 (abfd, src->st_info, dst->st_info);
- bfd_h_put_8 (abfd, src->st_other, dst->st_other);
- bfd_h_put_16 (abfd, src->st_shndx, dst->st_shndx);
-}
-
-
-/* Translate an ELF file header in external format into an ELF file header in
- internal format. */
-
-static void
-elf_swap_ehdr_in (abfd, src, dst)
- bfd *abfd;
- Elf_External_Ehdr *src;
- Elf_Internal_Ehdr *dst;
-{
- memcpy (dst->e_ident, src->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 = get_word (abfd, (bfd_byte *) src->e_entry);
- dst->e_phoff = get_word (abfd, (bfd_byte *) src->e_phoff);
- dst->e_shoff = get_word (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 file header in internal format into an ELF file header in
- external format. */
-
-static void
-elf_swap_ehdr_out (abfd, src, dst)
- bfd *abfd;
- Elf_Internal_Ehdr *src;
- Elf_External_Ehdr *dst;
-{
- memcpy (dst->e_ident, src->e_ident, EI_NIDENT);
- /* note that all elements of dst are *arrays of unsigned char* already... */
- bfd_h_put_16 (abfd, src->e_type, dst->e_type);
- bfd_h_put_16 (abfd, src->e_machine, dst->e_machine);
- bfd_h_put_32 (abfd, src->e_version, dst->e_version);
- put_word (abfd, src->e_entry, dst->e_entry);
- put_word (abfd, src->e_phoff, dst->e_phoff);
- put_word (abfd, src->e_shoff, dst->e_shoff);
- bfd_h_put_32 (abfd, src->e_flags, dst->e_flags);
- bfd_h_put_16 (abfd, src->e_ehsize, dst->e_ehsize);
- bfd_h_put_16 (abfd, src->e_phentsize, dst->e_phentsize);
- bfd_h_put_16 (abfd, src->e_phnum, dst->e_phnum);
- bfd_h_put_16 (abfd, src->e_shentsize, dst->e_shentsize);
- bfd_h_put_16 (abfd, src->e_shnum, dst->e_shnum);
- bfd_h_put_16 (abfd, src->e_shstrndx, dst->e_shstrndx);
-}
-
-
-/* Translate an ELF section header table entry in external format into an
- ELF section header table entry in internal format. */
-
-static void
-elf_swap_shdr_in (abfd, src, dst)
- bfd *abfd;
- Elf_External_Shdr *src;
- 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 = get_word (abfd, (bfd_byte *) src->sh_flags);
- dst->sh_addr = get_word (abfd, (bfd_byte *) src->sh_addr);
- dst->sh_offset = get_word (abfd, (bfd_byte *) src->sh_offset);
- dst->sh_size = get_word (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 = get_word (abfd, (bfd_byte *) src->sh_addralign);
- dst->sh_entsize = get_word (abfd, (bfd_byte *) src->sh_entsize);
- dst->bfd_section = NULL;
- dst->contents = NULL;
-}
-
-/* Translate an ELF section header table entry in internal format into an
- ELF section header table entry in external format. */
-
-static void
-elf_swap_shdr_out (abfd, src, dst)
- bfd *abfd;
- Elf_Internal_Shdr *src;
- Elf_External_Shdr *dst;
-{
- /* note that all elements of dst are *arrays of unsigned char* already... */
- bfd_h_put_32 (abfd, src->sh_name, dst->sh_name);
- bfd_h_put_32 (abfd, src->sh_type, dst->sh_type);
- put_word (abfd, src->sh_flags, dst->sh_flags);
- put_word (abfd, src->sh_addr, dst->sh_addr);
- put_word (abfd, src->sh_offset, dst->sh_offset);
- put_word (abfd, src->sh_size, dst->sh_size);
- bfd_h_put_32 (abfd, src->sh_link, dst->sh_link);
- bfd_h_put_32 (abfd, src->sh_info, dst->sh_info);
- put_word (abfd, src->sh_addralign, dst->sh_addralign);
- put_word (abfd, src->sh_entsize, dst->sh_entsize);
-}
-
-
-/* Translate an ELF program header table entry in external format into an
- ELF program header table entry in internal format. */
-
-void
-elf_swap_phdr_in (abfd, src, dst)
- bfd *abfd;
- Elf_External_Phdr *src;
- Elf_Internal_Phdr *dst;
-{
- dst->p_type = bfd_h_get_32 (abfd, (bfd_byte *) src->p_type);
- dst->p_flags = bfd_h_get_32 (abfd, (bfd_byte *) src->p_flags);
- dst->p_offset = get_word (abfd, (bfd_byte *) src->p_offset);
- dst->p_vaddr = get_word (abfd, (bfd_byte *) src->p_vaddr);
- dst->p_paddr = get_word (abfd, (bfd_byte *) src->p_paddr);
- dst->p_filesz = get_word (abfd, (bfd_byte *) src->p_filesz);
- dst->p_memsz = get_word (abfd, (bfd_byte *) src->p_memsz);
- dst->p_align = get_word (abfd, (bfd_byte *) src->p_align);
-}
-
-void
-elf_swap_phdr_out (abfd, src, dst)
- bfd *abfd;
- Elf_Internal_Phdr *src;
- Elf_External_Phdr *dst;
-{
- /* note that all elements of dst are *arrays of unsigned char* already... */
- bfd_h_put_32 (abfd, src->p_type, dst->p_type);
- put_word (abfd, src->p_offset, dst->p_offset);
- put_word (abfd, src->p_vaddr, dst->p_vaddr);
- put_word (abfd, src->p_paddr, dst->p_paddr);
- put_word (abfd, src->p_filesz, dst->p_filesz);
- put_word (abfd, src->p_memsz, dst->p_memsz);
- bfd_h_put_32 (abfd, src->p_flags, dst->p_flags);
- put_word (abfd, src->p_align, dst->p_align);
-}
-
-/* Translate an ELF reloc from external format to internal format. */
-INLINE void
-elf_swap_reloc_in (abfd, src, dst)
- bfd *abfd;
- Elf_External_Rel *src;
- Elf_Internal_Rel *dst;
-{
- dst->r_offset = get_word (abfd, (bfd_byte *) src->r_offset);
- dst->r_info = get_word (abfd, (bfd_byte *) src->r_info);
-}
-
-INLINE void
-elf_swap_reloca_in (abfd, src, dst)
- bfd *abfd;
- Elf_External_Rela *src;
- Elf_Internal_Rela *dst;
-{
- dst->r_offset = get_word (abfd, (bfd_byte *) src->r_offset);
- dst->r_info = get_word (abfd, (bfd_byte *) src->r_info);
- dst->r_addend = get_word (abfd, (bfd_byte *) src->r_addend);
-}
-
-/* Translate an ELF reloc from internal format to external format. */
-INLINE void
-elf_swap_reloc_out (abfd, src, dst)
- bfd *abfd;
- Elf_Internal_Rel *src;
- Elf_External_Rel *dst;
-{
- put_word (abfd, src->r_offset, dst->r_offset);
- put_word (abfd, src->r_info, dst->r_info);
-}
-
-INLINE void
-elf_swap_reloca_out (abfd, src, dst)
- bfd *abfd;
- Elf_Internal_Rela *src;
- Elf_External_Rela *dst;
-{
- put_word (abfd, src->r_offset, dst->r_offset);
- put_word (abfd, src->r_info, dst->r_info);
- put_word (abfd, src->r_addend, dst->r_addend);
-}
-
-INLINE void
-elf_swap_dyn_in (abfd, p, dst)
- bfd *abfd;
- const PTR p;
- Elf_Internal_Dyn *dst;
-{
- const Elf_External_Dyn *src = (const Elf_External_Dyn *) p;
-
- dst->d_tag = get_word (abfd, src->d_tag);
- dst->d_un.d_val = get_word (abfd, src->d_un.d_val);
-}
-
-INLINE void
-elf_swap_dyn_out (abfd, src, dst)
- bfd *abfd;
- const Elf_Internal_Dyn *src;
- Elf_External_Dyn *dst;
-{
- put_word (abfd, src->d_tag, dst->d_tag);
- put_word (abfd, src->d_un.d_val, dst->d_un.d_val);
-}
-
-/* ELF .o/exec file reading */
-
-
-/* Begin processing a given object.
-
- First we validate the file by reading in the ELF header and checking
- the magic number. */
-
-static INLINE boolean
-elf_file_p (x_ehdrp)
- Elf_External_Ehdr *x_ehdrp;
-{
- return ((x_ehdrp->e_ident[EI_MAG0] == ELFMAG0)
- && (x_ehdrp->e_ident[EI_MAG1] == ELFMAG1)
- && (x_ehdrp->e_ident[EI_MAG2] == ELFMAG2)
- && (x_ehdrp->e_ident[EI_MAG3] == ELFMAG3));
-}
-
-/* Check to see if the file associated with ABFD matches the target vector
- that ABFD points to.
-
- Note that we may be called several times with the same ABFD, but different
- target vectors, most of which will not match. We have to avoid leaving
- any side effects in ABFD, or any data it points to (like tdata), if the
- file does not match the target vector. */
-
-const bfd_target *
-elf_object_p (abfd)
- bfd *abfd;
-{
- Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
- Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
- Elf_External_Shdr x_shdr; /* Section header table entry, external form */
- Elf_Internal_Shdr *i_shdrp = NULL; /* Section header table, internal form */
- unsigned int shindex;
- char *shstrtab; /* Internal copy of section header stringtab */
- struct elf_backend_data *ebd;
- struct elf_obj_tdata *preserved_tdata = elf_tdata (abfd);
- struct elf_obj_tdata *new_tdata = NULL;
-
- /* Read in the ELF header in external format. */
-
- if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
- {
- if (bfd_get_error () != bfd_error_system_call)
- goto got_wrong_format_error;
- else
- goto got_no_match;
- }
-
- /* 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 ((elf_file_p (&x_ehdr) == false) ||
- (x_ehdr.e_ident[EI_VERSION] != EV_CURRENT) ||
- (x_ehdr.e_ident[EI_CLASS] != ELFCLASS))
- goto got_wrong_format_error;
-
- /* Check that file's byte order matches xvec's */
- switch (x_ehdr.e_ident[EI_DATA])
- {
- case ELFDATA2MSB: /* Big-endian */
- if (! bfd_header_big_endian (abfd))
- goto got_wrong_format_error;
- break;
- case ELFDATA2LSB: /* Little-endian */
- if (! bfd_header_little_endian (abfd))
- goto got_wrong_format_error;
- break;
- case ELFDATANONE: /* No data encoding specified */
- default: /* Unknown data encoding specified */
- goto got_wrong_format_error;
- }
-
- /* Allocate an instance of the elf_obj_tdata structure and hook it up to
- the tdata pointer in the bfd. */
-
- new_tdata = ((struct elf_obj_tdata *)
- bfd_zalloc (abfd, sizeof (struct elf_obj_tdata)));
- if (new_tdata == NULL)
- goto got_no_match;
- elf_tdata (abfd) = new_tdata;
-
- /* Now that we know the byte order, swap in the rest of the header */
- i_ehdrp = elf_elfheader (abfd);
- elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
-#if DEBUG & 1
- elf_debug_file (i_ehdrp);
-#endif
-
- /* If there is no section header table, we're hosed. */
- if (i_ehdrp->e_shoff == 0)
- goto got_wrong_format_error;
-
- /* 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_ehdrp->e_shentsize != sizeof (x_shdr))
- goto got_wrong_format_error;
-
- ebd = get_elf_backend_data (abfd);
-
- /* Check that the ELF e_machine field matches what this particular
- BFD format expects. */
- if (ebd->elf_machine_code != i_ehdrp->e_machine
- && (ebd->elf_machine_alt1 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
- && (ebd->elf_machine_alt2 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
- {
- const bfd_target * const *target_ptr;
-
- if (ebd->elf_machine_code != EM_NONE)
- goto got_wrong_format_error;
-
- /* This is the generic ELF target. Let it match any ELF target
- for which we do not have a specific backend. */
- for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++)
- {
- struct elf_backend_data *back;
-
- if ((*target_ptr)->flavour != bfd_target_elf_flavour)
- continue;
- back = (struct elf_backend_data *) (*target_ptr)->backend_data;
- if (back->elf_machine_code == i_ehdrp->e_machine)
- {
- /* target_ptr is an ELF backend which matches this
- object file, so reject the generic ELF target. */
- goto got_wrong_format_error;
- }
- }
- }
-
- if (i_ehdrp->e_type == ET_EXEC)
- abfd->flags |= EXEC_P;
- else if (i_ehdrp->e_type == ET_DYN)
- abfd->flags |= DYNAMIC;
-
- if (i_ehdrp->e_phnum > 0)
- abfd->flags |= D_PAGED;
-
- if (! bfd_default_set_arch_mach (abfd, ebd->arch, 0))
- goto got_no_match;
-
- /* Remember the entry point specified in the ELF file header. */
- bfd_get_start_address (abfd) = i_ehdrp->e_entry;
-
- /* Allocate space for a copy of the section header table in
- internal form, seek to the section header table in the file,
- read it in, and convert it to internal form. */
- i_shdrp = ((Elf_Internal_Shdr *)
- bfd_alloc (abfd, sizeof (*i_shdrp) * i_ehdrp->e_shnum));
- elf_elfsections (abfd) = ((Elf_Internal_Shdr **)
- bfd_alloc (abfd,
- sizeof (i_shdrp) * i_ehdrp->e_shnum));
- if (!i_shdrp || !elf_elfsections (abfd))
- goto got_no_match;
- if (bfd_seek (abfd, i_ehdrp->e_shoff, SEEK_SET) != 0)
- goto got_no_match;
- for (shindex = 0; shindex < i_ehdrp->e_shnum; shindex++)
- {
- if (bfd_read ((PTR) & x_shdr, sizeof x_shdr, 1, abfd) != sizeof (x_shdr))
- goto got_no_match;
- elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
- elf_elfsections (abfd)[shindex] = i_shdrp + shindex;
- }
- if (i_ehdrp->e_shstrndx)
- {
- if (! bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx))
- goto got_no_match;
- }
-
- /* Read in the program headers. */
- if (i_ehdrp->e_phnum == 0)
- elf_tdata (abfd)->phdr = NULL;
- else
- {
- Elf_Internal_Phdr *i_phdr;
- unsigned int i;
-
- elf_tdata (abfd)->phdr = ((Elf_Internal_Phdr *)
- bfd_alloc (abfd,
- (i_ehdrp->e_phnum
- * sizeof (Elf_Internal_Phdr))));
- if (elf_tdata (abfd)->phdr == NULL)
- goto got_no_match;
- if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) != 0)
- goto got_no_match;
- i_phdr = elf_tdata (abfd)->phdr;
- for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
- {
- Elf_External_Phdr x_phdr;
-
- if (bfd_read ((PTR) &x_phdr, sizeof x_phdr, 1, abfd)
- != sizeof x_phdr)
- goto got_no_match;
- elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
- }
- }
-
- /* Read in the string table containing the names of the sections. We
- will need the base pointer to this table later. */
- /* We read this inline now, so that we don't have to go through
- bfd_section_from_shdr with it (since this particular strtab is
- used to find all of the ELF section names.) */
-
- shstrtab = bfd_elf_get_str_section (abfd, i_ehdrp->e_shstrndx);
- if (!shstrtab)
- goto got_no_match;
-
- /* 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_ehdrp->e_shnum; shindex++)
- {
- if (! bfd_section_from_shdr (abfd, shindex))
- goto got_no_match;
- }
-
- /* Let the backend double check the format and override global
- information. */
- if (ebd->elf_backend_object_p)
- {
- if ((*ebd->elf_backend_object_p) (abfd) == false)
- goto got_wrong_format_error;
- }
-
- return (abfd->xvec);
-
-got_wrong_format_error:
- bfd_set_error (bfd_error_wrong_format);
- goto got_no_match;
-got_no_match:
- if (new_tdata != NULL
- && new_tdata->elf_sect_ptr != NULL)
- bfd_release (abfd, new_tdata->elf_sect_ptr);
- if (i_shdrp != NULL)
- bfd_release (abfd, i_shdrp);
- if (new_tdata != NULL)
- bfd_release (abfd, new_tdata);
- elf_tdata (abfd) = preserved_tdata;
- return (NULL);
-}
-
-/* ELF .o/exec file writing */
-
-/* Try to convert a non-ELF reloc into an ELF one. */
-
-static boolean
-validate_reloc (abfd, areloc)
- bfd *abfd;
- arelent *areloc;
-{
- /* Check whether we really have an ELF howto. */
-
- if ((*areloc->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec)
- {
- bfd_reloc_code_real_type code;
- reloc_howto_type *howto;
-
- /* Alien reloc: Try to determine its type to replace it with an
- equivalent ELF reloc. */
-
- if (areloc->howto->pc_relative)
- {
- switch (areloc->howto->bitsize)
- {
- case 8:
- code = BFD_RELOC_8_PCREL;
- break;
- case 12:
- code = BFD_RELOC_12_PCREL;
- break;
- case 16:
- code = BFD_RELOC_16_PCREL;
- break;
- case 24:
- code = BFD_RELOC_24_PCREL;
- break;
- case 32:
- code = BFD_RELOC_32_PCREL;
- break;
- case 64:
- code = BFD_RELOC_64_PCREL;
- break;
- default:
- goto fail;
- }
-
- howto = bfd_reloc_type_lookup (abfd, code);
-
- if (areloc->howto->pcrel_offset != howto->pcrel_offset)
- {
- if (howto->pcrel_offset)
- areloc->addend += areloc->address;
- else
- areloc->addend -= areloc->address; /* addend is unsigned!! */
- }
- }
- else
- {
- switch (areloc->howto->bitsize)
- {
- case 8:
- code = BFD_RELOC_8;
- break;
- case 14:
- code = BFD_RELOC_14;
- break;
- case 16:
- code = BFD_RELOC_16;
- break;
- case 26:
- code = BFD_RELOC_26;
- break;
- case 32:
- code = BFD_RELOC_32;
- break;
- case 64:
- code = BFD_RELOC_64;
- break;
- default:
- goto fail;
- }
-
- howto = bfd_reloc_type_lookup (abfd, code);
- }
-
- if (howto)
- areloc->howto = howto;
- else
- goto fail;
- }
-
- return true;
-
- fail:
- (*_bfd_error_handler)
- ("%s: unsupported relocation type %s",
- bfd_get_filename (abfd), areloc->howto->name);
- bfd_set_error (bfd_error_bad_value);
- return false;
-}
-
-/* Write out the relocs. */
-
-static void
-write_relocs (abfd, sec, data)
- bfd *abfd;
- asection *sec;
- PTR data;
-{
- boolean *failedp = (boolean *) data;
- Elf_Internal_Shdr *rela_hdr;
- Elf_External_Rela *outbound_relocas;
- Elf_External_Rel *outbound_relocs;
- unsigned int idx;
- int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
- asymbol *last_sym = 0;
- int last_sym_idx = 0;
-
- /* If we have already failed, don't do anything. */
- if (*failedp)
- return;
-
- if ((sec->flags & SEC_RELOC) == 0)
- return;
-
- /* The linker backend writes the relocs out itself, and sets the
- reloc_count field to zero to inhibit writing them here. Also,
- sometimes the SEC_RELOC flag gets set even when there aren't any
- relocs. */
- if (sec->reloc_count == 0)
- return;
-
- rela_hdr = &elf_section_data (sec)->rel_hdr;
-
- rela_hdr->sh_size = rela_hdr->sh_entsize * sec->reloc_count;
- rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size);
- if (rela_hdr->contents == NULL)
- {
- *failedp = true;
- return;
- }
-
- /* orelocation has the data, reloc_count has the count... */
- if (use_rela_p)
- {
- outbound_relocas = (Elf_External_Rela *) rela_hdr->contents;
-
- for (idx = 0; idx < sec->reloc_count; idx++)
- {
- Elf_Internal_Rela dst_rela;
- Elf_External_Rela *src_rela;
- arelent *ptr;
- asymbol *sym;
- int n;
-
- ptr = sec->orelocation[idx];
- src_rela = outbound_relocas + idx;
-
- /* The address of an ELF reloc is section relative for an object
- file, and absolute for an executable file or shared library.
- The address of a BFD reloc is always section relative. */
- if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
- dst_rela.r_offset = ptr->address;
- else
- dst_rela.r_offset = ptr->address + sec->vma;
-
- sym = *ptr->sym_ptr_ptr;
- if (sym == last_sym)
- n = last_sym_idx;
- else
- {
- last_sym = sym;
- n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
- if (n < 0)
- {
- *failedp = true;
- return;
- }
- last_sym_idx = n;
- }
-
- if ((*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
- && ! validate_reloc (abfd, ptr))
- {
- *failedp = true;
- return;
- }
-
- dst_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
-
- dst_rela.r_addend = ptr->addend;
- elf_swap_reloca_out (abfd, &dst_rela, src_rela);
- }
- }
- else
- /* REL relocations */
- {
- outbound_relocs = (Elf_External_Rel *) rela_hdr->contents;
-
- for (idx = 0; idx < sec->reloc_count; idx++)
- {
- Elf_Internal_Rel dst_rel;
- Elf_External_Rel *src_rel;
- arelent *ptr;
- int n;
- asymbol *sym;
-
- ptr = sec->orelocation[idx];
- sym = *ptr->sym_ptr_ptr;
- src_rel = outbound_relocs + idx;
-
- /* The address of an ELF reloc is section relative for an object
- file, and absolute for an executable file or shared library.
- The address of a BFD reloc is always section relative. */
- if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
- dst_rel.r_offset = ptr->address;
- else
- dst_rel.r_offset = ptr->address + sec->vma;
-
- if (sym == last_sym)
- n = last_sym_idx;
- else
- {
- last_sym = sym;
- n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
- if (n < 0)
- {
- *failedp = true;
- return;
- }
- last_sym_idx = n;
- }
-
- if ((*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
- && ! validate_reloc (abfd, ptr))
- {
- *failedp = true;
- return;
- }
-
- dst_rel.r_info = ELF_R_INFO (n, ptr->howto->type);
-
- elf_swap_reloc_out (abfd, &dst_rel, src_rel);
- }
- }
-}
-
-static int
-write_out_phdrs (abfd, phdr, count)
- bfd *abfd;
- Elf_Internal_Phdr *phdr;
- int count;
-{
- while (count--)
- {
- Elf_External_Phdr extphdr;
- elf_swap_phdr_out (abfd, phdr, &extphdr);
- if (bfd_write (&extphdr, sizeof (Elf_External_Phdr), 1, abfd)
- != sizeof (Elf_External_Phdr))
- return -1;
- phdr++;
- }
- return 0;
-}
-
-static boolean
-write_shdrs_and_ehdr (abfd)
- bfd *abfd;
-{
- Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
- Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
- Elf_External_Shdr *x_shdrp; /* Section header table, external form */
- Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
- unsigned int count;
-
- i_ehdrp = elf_elfheader (abfd);
- i_shdrp = elf_elfsections (abfd);
-
- /* swap the header before spitting it out... */
-
-#if DEBUG & 1
- elf_debug_file (i_ehdrp);
-#endif
- elf_swap_ehdr_out (abfd, i_ehdrp, &x_ehdr);
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd)
- != sizeof (x_ehdr)))
- return false;
-
- /* at this point we've concocted all the ELF sections... */
- x_shdrp = (Elf_External_Shdr *)
- bfd_alloc (abfd, sizeof (*x_shdrp) * (i_ehdrp->e_shnum));
- if (!x_shdrp)
- return false;
-
- for (count = 0; count < i_ehdrp->e_shnum; count++)
- {
-#if DEBUG & 2
- elf_debug_section (count, i_shdrp[count]);
-#endif
- elf_swap_shdr_out (abfd, i_shdrp[count], x_shdrp + count);
- }
- if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0
- || (bfd_write ((PTR) x_shdrp, sizeof (*x_shdrp), i_ehdrp->e_shnum, abfd)
- != sizeof (*x_shdrp) * i_ehdrp->e_shnum))
- return false;
-
- /* need to dump the string table too... */
-
- return true;
-}
-
-static long
-elf_slurp_symbol_table (abfd, symptrs, dynamic)
- bfd *abfd;
- asymbol **symptrs; /* Buffer for generated bfd symbols */
- boolean dynamic;
-{
- Elf_Internal_Shdr *hdr;
- long symcount; /* Number of external ELF symbols */
- elf_symbol_type *sym; /* Pointer to current bfd symbol */
- elf_symbol_type *symbase; /* Buffer for generated bfd symbols */
- Elf_Internal_Sym i_sym;
- Elf_External_Sym *x_symp = NULL;
-
- /* Read each raw ELF symbol, converting from external ELF form to
- internal ELF form, and then using the information to create a
- canonical bfd symbol table entry.
-
- Note that we allocate the initial bfd canonical symbol buffer
- based on a one-to-one mapping of the ELF symbols to canonical
- symbols. We actually use all the ELF symbols, so there will be no
- space left over at the end. When we have all the symbols, we
- build the caller's pointer vector. */
-
- if (dynamic)
- hdr = &elf_tdata (abfd)->dynsymtab_hdr;
- else
- hdr = &elf_tdata (abfd)->symtab_hdr;
- if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
- return -1;
-
- symcount = hdr->sh_size / sizeof (Elf_External_Sym);
-
- if (symcount == 0)
- sym = symbase = NULL;
- else
- {
- long i;
-
- if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
- return -1;
-
- symbase = ((elf_symbol_type *)
- bfd_zalloc (abfd, symcount * sizeof (elf_symbol_type)));
- if (symbase == (elf_symbol_type *) NULL)
- return -1;
- sym = symbase;
-
- /* Temporarily allocate room for the raw ELF symbols. */
- x_symp = ((Elf_External_Sym *)
- bfd_malloc (symcount * sizeof (Elf_External_Sym)));
- if (x_symp == NULL && symcount != 0)
- goto error_return;
-
- if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd)
- != symcount * sizeof (Elf_External_Sym))
- goto error_return;
- /* Skip first symbol, which is a null dummy. */
- for (i = 1; i < symcount; i++)
- {
- elf_swap_symbol_in (abfd, x_symp + i, &i_sym);
- memcpy (&sym->internal_elf_sym, &i_sym, sizeof (Elf_Internal_Sym));
-#ifdef ELF_KEEP_EXTSYM
- memcpy (&sym->native_elf_sym, x_symp + i, sizeof (Elf_External_Sym));
-#endif
- sym->symbol.the_bfd = abfd;
-
- sym->symbol.name = bfd_elf_string_from_elf_section (abfd,
- hdr->sh_link,
- i_sym.st_name);
-
- sym->symbol.value = i_sym.st_value;
-
- if (i_sym.st_shndx > 0 && i_sym.st_shndx < SHN_LORESERVE)
- {
- sym->symbol.section = section_from_elf_index (abfd,
- i_sym.st_shndx);
- if (sym->symbol.section == NULL)
- {
- /* This symbol is in a section for which we did not
- create a BFD section. Just use bfd_abs_section,
- although it is wrong. FIXME. */
- sym->symbol.section = bfd_abs_section_ptr;
- }
- }
- else if (i_sym.st_shndx == SHN_ABS)
- {
- sym->symbol.section = bfd_abs_section_ptr;
- }
- else if (i_sym.st_shndx == SHN_COMMON)
- {
- sym->symbol.section = bfd_com_section_ptr;
- /* Elf puts the alignment into the `value' field, and
- the size into the `size' field. BFD wants to see the
- size in the value field, and doesn't care (at the
- moment) about the alignment. */
- sym->symbol.value = i_sym.st_size;
- }
- else if (i_sym.st_shndx == SHN_UNDEF)
- {
- sym->symbol.section = bfd_und_section_ptr;
- }
- else
- sym->symbol.section = bfd_abs_section_ptr;
-
- sym->symbol.value -= sym->symbol.section->vma;
-
- switch (ELF_ST_BIND (i_sym.st_info))
- {
- case STB_LOCAL:
- sym->symbol.flags |= BSF_LOCAL;
- break;
- case STB_GLOBAL:
- if (i_sym.st_shndx != SHN_UNDEF
- && i_sym.st_shndx != SHN_COMMON)
- sym->symbol.flags |= BSF_GLOBAL;
- break;
- case STB_WEAK:
- sym->symbol.flags |= BSF_WEAK;
- break;
- }
-
- switch (ELF_ST_TYPE (i_sym.st_info))
- {
- case STT_SECTION:
- sym->symbol.flags |= BSF_SECTION_SYM | BSF_DEBUGGING;
- break;
- case STT_FILE:
- sym->symbol.flags |= BSF_FILE | BSF_DEBUGGING;
- break;
- case STT_FUNC:
- sym->symbol.flags |= BSF_FUNCTION;
- break;
- case STT_OBJECT:
- sym->symbol.flags |= BSF_OBJECT;
- break;
- }
-
- if (dynamic)
- sym->symbol.flags |= BSF_DYNAMIC;
-
- /* Do some backend-specific processing on this symbol. */
- {
- struct elf_backend_data *ebd = get_elf_backend_data (abfd);
- if (ebd->elf_backend_symbol_processing)
- (*ebd->elf_backend_symbol_processing) (abfd, &sym->symbol);
- }
-
- sym++;
- }
- }
-
- /* Do some backend-specific processing on this symbol table. */
- {
- struct elf_backend_data *ebd = get_elf_backend_data (abfd);
- if (ebd->elf_backend_symbol_table_processing)
- (*ebd->elf_backend_symbol_table_processing) (abfd, symbase, symcount);
- }
-
- /* We rely on the zalloc to clear out the final symbol entry. */
-
- symcount = sym - symbase;
-
- /* Fill in the user's symbol pointer vector if needed. */
- if (symptrs)
- {
- long l = symcount;
-
- sym = symbase;
- while (l-- > 0)
- {
- *symptrs++ = &sym->symbol;
- sym++;
- }
- *symptrs = 0; /* Final null pointer */
- }
-
- if (x_symp != NULL)
- free (x_symp);
- return symcount;
-error_return:
- if (x_symp != NULL)
- free (x_symp);
- return -1;
-}
-
-/* Read in and swap the external relocs. */
-
-static boolean
-elf_slurp_reloc_table (abfd, asect, symbols)
- bfd *abfd;
- asection *asect;
- asymbol **symbols;
-{
- struct elf_backend_data * const ebd = get_elf_backend_data (abfd);
- struct bfd_elf_section_data * const d = elf_section_data (asect);
- PTR allocated = NULL;
- bfd_byte *native_relocs;
- arelent *relents;
- arelent *relent;
- unsigned int i;
- int entsize;
-
- if (asect->relocation != NULL
- || (asect->flags & SEC_RELOC) == 0
- || asect->reloc_count == 0)
- return true;
-
- BFD_ASSERT (asect->rel_filepos == d->rel_hdr.sh_offset
- && (asect->reloc_count
- == d->rel_hdr.sh_size / d->rel_hdr.sh_entsize));
-
- allocated = (PTR) bfd_malloc ((size_t) d->rel_hdr.sh_size);
- if (allocated == NULL)
- goto error_return;
-
- if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0
- || (bfd_read (allocated, 1, d->rel_hdr.sh_size, abfd)
- != d->rel_hdr.sh_size))
- goto error_return;
-
- native_relocs = (bfd_byte *) allocated;
-
- relents = ((arelent *)
- bfd_alloc (abfd, asect->reloc_count * sizeof (arelent)));
- if (relents == NULL)
- goto error_return;
-
- entsize = d->rel_hdr.sh_entsize;
- BFD_ASSERT (entsize == sizeof (Elf_External_Rel)
- || entsize == sizeof (Elf_External_Rela));
-
- for (i = 0, relent = relents;
- i < asect->reloc_count;
- i++, relent++, native_relocs += entsize)
- {
- Elf_Internal_Rela rela;
- Elf_Internal_Rel rel;
-
- if (entsize == sizeof (Elf_External_Rela))
- elf_swap_reloca_in (abfd, (Elf_External_Rela *) native_relocs, &rela);
- else
- {
- elf_swap_reloc_in (abfd, (Elf_External_Rel *) native_relocs, &rel);
- rela.r_offset = rel.r_offset;
- rela.r_info = rel.r_info;
- rela.r_addend = 0;
- }
-
- /* The address of an ELF reloc is section relative for an object
- file, and absolute for an executable file or shared library.
- The address of a BFD reloc is always section relative. */
- if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
- relent->address = rela.r_offset;
- else
- relent->address = rela.r_offset - asect->vma;
-
- if (ELF_R_SYM (rela.r_info) == 0)
- relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- else
- {
- asymbol **ps, *s;
-
- ps = symbols + ELF_R_SYM (rela.r_info) - 1;
- s = *ps;
-
- /* Canonicalize ELF section symbols. FIXME: Why? */
- if ((s->flags & BSF_SECTION_SYM) == 0)
- relent->sym_ptr_ptr = ps;
- else
- relent->sym_ptr_ptr = s->section->symbol_ptr_ptr;
- }
-
- relent->addend = rela.r_addend;
-
- if (entsize == sizeof (Elf_External_Rela))
- (*ebd->elf_info_to_howto) (abfd, relent, &rela);
- else
- (*ebd->elf_info_to_howto_rel) (abfd, relent, &rel);
- }
-
- asect->relocation = relents;
-
- if (allocated != NULL)
- free (allocated);
-
- return true;
-
- error_return:
- if (allocated != NULL)
- free (allocated);
- return false;
-}
-
-#ifdef DEBUG
-static void
-elf_debug_section (num, hdr)
- int num;
- Elf_Internal_Shdr *hdr;
-{
- fprintf (stderr, "\nSection#%d '%s' 0x%.8lx\n", num,
- hdr->bfd_section != NULL ? hdr->bfd_section->name : "",
- (long) hdr);
- fprintf (stderr,
- "sh_name = %ld\tsh_type = %ld\tsh_flags = %ld\n",
- (long) hdr->sh_name,
- (long) hdr->sh_type,
- (long) hdr->sh_flags);
- fprintf (stderr,
- "sh_addr = %ld\tsh_offset = %ld\tsh_size = %ld\n",
- (long) hdr->sh_addr,
- (long) hdr->sh_offset,
- (long) hdr->sh_size);
- fprintf (stderr,
- "sh_link = %ld\tsh_info = %ld\tsh_addralign = %ld\n",
- (long) hdr->sh_link,
- (long) hdr->sh_info,
- (long) hdr->sh_addralign);
- fprintf (stderr, "sh_entsize = %ld\n",
- (long) hdr->sh_entsize);
- fflush (stderr);
-}
-
-static void
-elf_debug_file (ehdrp)
- Elf_Internal_Ehdr *ehdrp;
-{
- fprintf (stderr, "e_entry = 0x%.8lx\n", (long) ehdrp->e_entry);
- fprintf (stderr, "e_phoff = %ld\n", (long) ehdrp->e_phoff);
- fprintf (stderr, "e_phnum = %ld\n", (long) ehdrp->e_phnum);
- fprintf (stderr, "e_phentsize = %ld\n", (long) ehdrp->e_phentsize);
- fprintf (stderr, "e_shoff = %ld\n", (long) ehdrp->e_shoff);
- fprintf (stderr, "e_shnum = %ld\n", (long) ehdrp->e_shnum);
- fprintf (stderr, "e_shentsize = %ld\n", (long) ehdrp->e_shentsize);
-}
-
-static char *
-elf_symbol_flags (flags)
- flagword flags;
-{
- static char buffer[1024];
-
- buffer[0] = '\0';
- if (flags & BSF_LOCAL)
- strcat (buffer, " local");
-
- if (flags & BSF_GLOBAL)
- strcat (buffer, " global");
-
- if (flags & BSF_DEBUGGING)
- strcat (buffer, " debug");
-
- if (flags & BSF_FUNCTION)
- strcat (buffer, " function");
-
- if (flags & BSF_KEEP)
- strcat (buffer, " keep");
-
- if (flags & BSF_KEEP_G)
- strcat (buffer, " keep_g");
-
- if (flags & BSF_WEAK)
- strcat (buffer, " weak");
-
- if (flags & BSF_SECTION_SYM)
- strcat (buffer, " section-sym");
-
- if (flags & BSF_OLD_COMMON)
- strcat (buffer, " old-common");
-
- if (flags & BSF_NOT_AT_END)
- strcat (buffer, " not-at-end");
-
- if (flags & BSF_CONSTRUCTOR)
- strcat (buffer, " constructor");
-
- if (flags & BSF_WARNING)
- strcat (buffer, " warning");
-
- if (flags & BSF_INDIRECT)
- strcat (buffer, " indirect");
-
- if (flags & BSF_FILE)
- strcat (buffer, " file");
-
- if (flags & DYNAMIC)
- strcat (buffer, " dynamic");
-
- if (flags & ~(BSF_LOCAL
- | BSF_GLOBAL
- | BSF_DEBUGGING
- | BSF_FUNCTION
- | BSF_KEEP
- | BSF_KEEP_G
- | BSF_WEAK
- | BSF_SECTION_SYM
- | BSF_OLD_COMMON
- | BSF_NOT_AT_END
- | BSF_CONSTRUCTOR
- | BSF_WARNING
- | BSF_INDIRECT
- | BSF_FILE
- | BSF_DYNAMIC))
- strcat (buffer, " unknown-bits");
-
- return buffer;
-}
-#endif
-
-#include "elfcore.h"
-#include "elflink.h"
-
-/* Size-dependent data and functions. */
-const struct elf_size_info NAME(_bfd_elf,size_info) = {
- sizeof (Elf_External_Ehdr),
- sizeof (Elf_External_Phdr),
- sizeof (Elf_External_Shdr),
- sizeof (Elf_External_Rel),
- sizeof (Elf_External_Rela),
- sizeof (Elf_External_Sym),
- sizeof (Elf_External_Dyn),
- sizeof (Elf_External_Note),
-
- ARCH_SIZE, FILE_ALIGN,
- ELFCLASS, EV_CURRENT,
- write_out_phdrs,
- write_shdrs_and_ehdr,
- write_relocs,
- elf_swap_symbol_out,
- elf_slurp_reloc_table,
- elf_slurp_symbol_table,
- elf_swap_dyn_in
-};
diff --git a/contrib/gdb/bfd/elfcore.h b/contrib/gdb/bfd/elfcore.h
deleted file mode 100644
index 8100627..0000000
--- a/contrib/gdb/bfd/elfcore.h
+++ /dev/null
@@ -1,475 +0,0 @@
-/* ELF core file support for BFD.
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* Core file support */
-
-#ifdef HAVE_SYS_PROCFS_H /* Some core file support requires host /proc files */
-#include <signal.h>
-#include <sys/procfs.h>
-#else
-#define bfd_prstatus(abfd, descdata, descsz, filepos) true
-#define bfd_fpregset(abfd, descdata, descsz, filepos) true
-#define bfd_prpsinfo(abfd, descdata, descsz, filepos) true
-#endif
-
-#ifdef HAVE_SYS_PROCFS_H
-
-static boolean
-bfd_prstatus (abfd, descdata, descsz, filepos)
- bfd *abfd;
- char *descdata;
- int descsz;
- long filepos;
-{
- asection *newsect;
- prstatus_t *status = (prstatus_t *) 0;
-
- if (descsz == sizeof (prstatus_t))
- {
- newsect = bfd_make_section (abfd, ".reg");
- if (newsect == NULL)
- return false;
- newsect->_raw_size = sizeof (status->pr_reg);
- newsect->filepos = filepos + (long) &status->pr_reg;
- newsect->flags = SEC_HAS_CONTENTS;
- newsect->alignment_power = 2;
- if ((core_prstatus (abfd) = bfd_alloc (abfd, descsz)) != NULL)
- {
- memcpy (core_prstatus (abfd), descdata, descsz);
- }
- }
- return true;
-}
-
-/* Stash a copy of the prpsinfo structure away for future use. */
-
-static boolean
-bfd_prpsinfo (abfd, descdata, descsz, filepos)
- bfd *abfd;
- char *descdata;
- int descsz;
- long filepos;
-{
- if (descsz == sizeof (prpsinfo_t))
- {
- if ((core_prpsinfo (abfd) = bfd_alloc (abfd, descsz)) == NULL)
- return false;
- memcpy (core_prpsinfo (abfd), descdata, descsz);
- }
- return true;
-}
-
-static boolean
-bfd_fpregset (abfd, descdata, descsz, filepos)
- bfd *abfd;
- char *descdata;
- int descsz;
- long filepos;
-{
- asection *newsect;
-
- newsect = bfd_make_section (abfd, ".reg2");
- if (newsect == NULL)
- return false;
- newsect->_raw_size = descsz;
- newsect->filepos = filepos;
- newsect->flags = SEC_HAS_CONTENTS;
- newsect->alignment_power = 2;
- return true;
-}
-
-#endif /* HAVE_SYS_PROCFS_H */
-
-/* Return a pointer to the args (including the command name) that were
- seen by the program that generated the core dump. Note that for
- some reason, a spurious space is tacked onto the end of the args
- in some (at least one anyway) implementations, so strip it off if
- it exists. */
-
-char *
-elf_core_file_failing_command (abfd)
- bfd *abfd;
-{
-#ifdef HAVE_SYS_PROCFS_H
- if (core_prpsinfo (abfd))
- {
- prpsinfo_t *p = core_prpsinfo (abfd);
- char *scan = p->pr_psargs;
- while (*scan++)
- {;
- }
- scan -= 2;
- if ((scan > p->pr_psargs) && (*scan == ' '))
- {
- *scan = '\000';
- }
- return p->pr_psargs;
- }
-#endif
- return NULL;
-}
-
-/* Return the number of the signal that caused the core dump. Presumably,
- since we have a core file, we got a signal of some kind, so don't bother
- checking the other process status fields, just return the signal number.
- */
-
-int
-elf_core_file_failing_signal (abfd)
- bfd *abfd;
-{
-#ifdef HAVE_SYS_PROCFS_H
- if (core_prstatus (abfd))
- {
- return ((prstatus_t *) (core_prstatus (abfd)))->pr_cursig;
- }
-#endif
- return -1;
-}
-
-/* Check to see if the core file could reasonably be expected to have
- come for the current executable file. Note that by default we return
- true unless we find something that indicates that there might be a
- problem.
- */
-
-boolean
-elf_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd;
- bfd *exec_bfd;
-{
-#ifdef HAVE_SYS_PROCFS_H
- char *corename;
- char *execname;
-#endif
-
- /* First, xvecs must match since both are ELF files for the same target. */
-
- if (core_bfd->xvec != exec_bfd->xvec)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
-
-#ifdef HAVE_SYS_PROCFS_H
-
- /* If no prpsinfo, just return true. Otherwise, grab the last component
- of the exec'd pathname from the prpsinfo. */
-
- if (core_prpsinfo (core_bfd))
- {
- corename = (((prpsinfo_t *) core_prpsinfo (core_bfd))->pr_fname);
- }
- else
- {
- return true;
- }
-
- /* Find the last component of the executable pathname. */
-
- if ((execname = strrchr (exec_bfd->filename, '/')) != NULL)
- {
- execname++;
- }
- else
- {
- execname = (char *) exec_bfd->filename;
- }
-
- /* See if they match */
-
- return strcmp (execname, corename) ? false : true;
-
-#else
-
- return true;
-
-#endif /* HAVE_SYS_PROCFS_H */
-}
-
-/* ELF core files contain a segment of type PT_NOTE, that holds much of
- the information that would normally be available from the /proc interface
- for the process, at the time the process dumped core. Currently this
- includes copies of the prstatus, prpsinfo, and fpregset structures.
-
- Since these structures are potentially machine dependent in size and
- ordering, bfd provides two levels of support for them. The first level,
- available on all machines since it does not require that the host
- have /proc support or the relevant include files, is to create a bfd
- section for each of the prstatus, prpsinfo, and fpregset structures,
- without any interpretation of their contents. With just this support,
- the bfd client will have to interpret the structures itself. Even with
- /proc support, it might want these full structures for it's own reasons.
-
- In the second level of support, where HAVE_SYS_PROCFS_H is defined,
- bfd will pick apart the structures to gather some additional
- information that clients may want, such as the general register
- set, the name of the exec'ed file and its arguments, the signal (if
- any) that caused the core dump, etc.
-
- */
-
-static boolean
-elf_corefile_note (abfd, hdr)
- bfd *abfd;
- Elf_Internal_Phdr *hdr;
-{
- Elf_External_Note *x_note_p; /* Elf note, external form */
- Elf_Internal_Note i_note; /* Elf note, internal form */
- char *buf = NULL; /* Entire note segment contents */
- char *namedata; /* Name portion of the note */
- char *descdata; /* Descriptor portion of the note */
- char *sectname; /* Name to use for new section */
- long filepos; /* File offset to descriptor data */
- asection *newsect;
-
- if (hdr->p_filesz > 0
- && (buf = (char *) bfd_malloc ((size_t) hdr->p_filesz)) != NULL
- && bfd_seek (abfd, hdr->p_offset, SEEK_SET) != -1
- && bfd_read ((PTR) buf, hdr->p_filesz, 1, abfd) == hdr->p_filesz)
- {
- x_note_p = (Elf_External_Note *) buf;
- while ((char *) x_note_p < (buf + hdr->p_filesz))
- {
- i_note.namesz = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->namesz);
- i_note.descsz = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->descsz);
- i_note.type = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->type);
- namedata = x_note_p->name;
- descdata = namedata + BFD_ALIGN (i_note.namesz, 4);
- filepos = hdr->p_offset + (descdata - buf);
- switch (i_note.type)
- {
- case NT_PRSTATUS:
- /* process descdata as prstatus info */
- if (! bfd_prstatus (abfd, descdata, i_note.descsz, filepos))
- return false;
- sectname = ".prstatus";
- break;
- case NT_FPREGSET:
- /* process descdata as fpregset info */
- if (! bfd_fpregset (abfd, descdata, i_note.descsz, filepos))
- return false;
- sectname = ".fpregset";
- break;
- case NT_PRPSINFO:
- /* process descdata as prpsinfo */
- if (! bfd_prpsinfo (abfd, descdata, i_note.descsz, filepos))
- return false;
- sectname = ".prpsinfo";
- break;
- default:
- /* Unknown descriptor, just ignore it. */
- sectname = NULL;
- break;
- }
- if (sectname != NULL)
- {
- newsect = bfd_make_section (abfd, sectname);
- if (newsect == NULL)
- return false;
- newsect->_raw_size = i_note.descsz;
- newsect->filepos = filepos;
- newsect->flags = SEC_ALLOC | SEC_HAS_CONTENTS;
- newsect->alignment_power = 2;
- }
- x_note_p = (Elf_External_Note *)
- (descdata + BFD_ALIGN (i_note.descsz, 4));
- }
- }
- if (buf != NULL)
- {
- free (buf);
- }
- else if (hdr->p_filesz > 0)
- {
- return false;
- }
- return true;
-
-}
-
-/* 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.
-
- The process status information (including the contents of the general
- register set) and the floating point register set are stored in a
- segment of type PT_NOTE. We handcraft a couple of extra bfd sections
- that allow standard bfd access to the general registers (.reg) and the
- floating point registers (.reg2).
-
- */
-
-const bfd_target *
-elf_core_file_p (abfd)
- bfd *abfd;
-{
- Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
- Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
- Elf_External_Phdr x_phdr; /* Program header table entry, external form */
- Elf_Internal_Phdr *i_phdrp; /* Program header table, internal form */
- unsigned int phindex;
- struct elf_backend_data *ebd;
-
- /* Read in the ELF header in external format. */
-
- if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- 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 (elf_file_p (&x_ehdr) == false)
- {
- wrong:
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* FIXME, Check EI_VERSION here ! */
-
- {
-#if ARCH_SIZE == 32
- int desired_address_size = ELFCLASS32;
-#endif
-#if ARCH_SIZE == 64
- int desired_address_size = ELFCLASS64;
-#endif
-
- if (x_ehdr.e_ident[EI_CLASS] != desired_address_size)
- goto wrong;
- }
-
- /* Switch xvec to match the specified byte order. */
- switch (x_ehdr.e_ident[EI_DATA])
- {
- case ELFDATA2MSB: /* Big-endian */
- if (! bfd_big_endian (abfd))
- goto wrong;
- break;
- case ELFDATA2LSB: /* Little-endian */
- if (! bfd_little_endian (abfd))
- goto wrong;
- break;
- case ELFDATANONE: /* No data encoding specified */
- default: /* Unknown data encoding specified */
- goto wrong;
- }
-
- /* Allocate an instance of the elf_obj_tdata structure and hook it up to
- the tdata pointer in the bfd. */
-
- elf_tdata (abfd) =
- (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
- if (elf_tdata (abfd) == NULL)
- return NULL;
-
- /* FIXME, `wrong' returns from this point onward, leak memory. */
-
- /* Now that we know the byte order, swap in the rest of the header */
- i_ehdrp = elf_elfheader (abfd);
- elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
-#if DEBUG & 1
- elf_debug_file (i_ehdrp);
-#endif
-
- ebd = get_elf_backend_data (abfd);
-
- /* Check that the ELF e_machine field matches what this particular
- BFD format expects. */
- if (ebd->elf_machine_code != i_ehdrp->e_machine
- && (ebd->elf_machine_alt1 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
- && (ebd->elf_machine_alt2 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
- {
- const bfd_target * const *target_ptr;
-
- if (ebd->elf_machine_code != EM_NONE)
- goto wrong;
-
- /* This is the generic ELF target. Let it match any ELF target
- for which we do not have a specific backend. */
- for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++)
- {
- struct elf_backend_data *back;
-
- if ((*target_ptr)->flavour != bfd_target_elf_flavour)
- continue;
- back = (struct elf_backend_data *) (*target_ptr)->backend_data;
- if (back->elf_machine_code == i_ehdrp->e_machine)
- {
- /* target_ptr is an ELF backend which matches this
- object file, so reject the generic ELF target. */
- goto wrong;
- }
- }
- }
-
- /* If there is no program header, or the type is not a core file, then
- we are hosed. */
- if (i_ehdrp->e_phoff == 0 || i_ehdrp->e_type != ET_CORE)
- goto wrong;
-
- /* Allocate space for a copy of the program header table in
- 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_ehdrp->e_phentsize != sizeof (x_phdr))
- goto wrong;
- i_phdrp = (Elf_Internal_Phdr *)
- bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
- if (!i_phdrp)
- return NULL;
- if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) == -1)
- return NULL;
- for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
- {
- if (bfd_read ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd)
- != sizeof (x_phdr))
- return NULL;
- elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex);
- }
-
- /* Once all of the program headers have been read and converted, we
- can start processing them. */
-
- for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
- {
- bfd_section_from_phdr (abfd, i_phdrp + phindex, phindex);
- if ((i_phdrp + phindex)->p_type == PT_NOTE)
- {
- if (! elf_corefile_note (abfd, i_phdrp + phindex))
- return NULL;
- }
- }
-
- /* Remember the entry point specified in the ELF file header. */
-
- bfd_get_start_address (abfd) = i_ehdrp->e_entry;
-
- return abfd->xvec;
-}
diff --git a/contrib/gdb/bfd/elflink.c b/contrib/gdb/bfd/elflink.c
deleted file mode 100644
index 7b204f7..0000000
--- a/contrib/gdb/bfd/elflink.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/* ELF linking support for BFD.
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#define ARCH_SIZE 0
-#include "elf-bfd.h"
-
-boolean
-_bfd_elf_create_got_section (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- flagword flags;
- register asection *s;
- struct elf_link_hash_entry *h;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- /* This function may be called more than once. */
- if (bfd_get_section_by_name (abfd, ".got") != NULL)
- return true;
-
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- s = bfd_make_section (abfd, ".got");
- if (s == NULL
- || !bfd_set_section_flags (abfd, s, flags)
- || !bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- if (bed->want_got_plt)
- {
- s = bfd_make_section (abfd, ".got.plt");
- if (s == NULL
- || !bfd_set_section_flags (abfd, s, flags)
- || !bfd_set_section_alignment (abfd, s, 2))
- return false;
- }
-
- /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
- (or .got.plt) section. We don't do this in the linker script
- because we don't want to define the symbol if we are not creating
- a global offset table. */
- h = NULL;
- if (!(_bfd_generic_link_add_one_symbol
- (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
- (const char *) NULL, false, get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_OBJECT;
-
- if (info->shared
- && ! _bfd_elf_link_record_dynamic_symbol (info, h))
- return false;
-
- /* The first three global offset table entries are reserved. */
- s->_raw_size += 3 * 4;
-
- return true;
-}
-
-
-/* Create dynamic sections when linking against a dynamic object. */
-
-boolean
-_bfd_elf_create_dynamic_sections (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- flagword flags;
- register asection *s;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
- .rel[a].bss sections. */
-
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- s = bfd_make_section (abfd, ".plt");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s,
- (flags | SEC_CODE
- | (bed->plt_readonly ? SEC_READONLY : 0)))
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- if (bed->want_plt_sym)
- {
- /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
- .plt section. */
- struct elf_link_hash_entry *h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
- (bfd_vma) 0, (const char *) NULL, false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_OBJECT;
-
- if (info->shared
- && ! _bfd_elf_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.plt" : ".rel.plt");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- if (! _bfd_elf_create_got_section (abfd, info))
- return false;
-
- /* The .dynbss section is a place to put symbols which are defined
- by dynamic objects, are referenced by regular objects, and are
- not functions. We must allocate space for them in the process
- image and use a R_*_COPY reloc to tell the dynamic linker to
- initialize them at run time. The linker script puts the .dynbss
- section into the .bss section of the final image. */
- s = bfd_make_section (abfd, ".dynbss");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
- return false;
-
- /* The .rel[a].bss section holds copy relocs. This section is not
- normally needed. We need to create it here, though, so that the
- linker will map it to an output section. We can't just create it
- only if we need it, because we will not know whether we need it
- until we have seen all the input files, and the first time the
- main linker code calls BFD after examining all the input files
- (size_dynamic_sections) the input sections have already been
- mapped to the output sections. If the section turns out not to
- be needed, we can discard it later. We will never need this
- section when generating a shared object, since they do not use
- copy relocs. */
- if (! info->shared)
- {
- s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.bss" : ".rel.bss");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
- }
-
- return true;
-}
-
-
-/* Record a new dynamic symbol. We record the dynamic symbols as we
- read the input files, since we need to have a list of all of them
- before we can determine the final sizes of the output sections.
- Note that we may actually call this function even though we are not
- going to output any dynamic symbols; in some cases we know that a
- symbol should be in the dynamic symbol table, but only if there is
- one. */
-
-boolean
-_bfd_elf_link_record_dynamic_symbol (info, h)
- struct bfd_link_info *info;
- struct elf_link_hash_entry *h;
-{
- if (h->dynindx == -1)
- {
- struct bfd_strtab_hash *dynstr;
-
- h->dynindx = elf_hash_table (info)->dynsymcount;
- ++elf_hash_table (info)->dynsymcount;
-
- dynstr = elf_hash_table (info)->dynstr;
- if (dynstr == NULL)
- {
- /* Create a strtab to hold the dynamic symbol names. */
- elf_hash_table (info)->dynstr = dynstr = _bfd_elf_stringtab_init ();
- if (dynstr == NULL)
- return false;
- }
-
- h->dynstr_index = ((unsigned long)
- _bfd_stringtab_add (dynstr, h->root.root.string,
- true, false));
- if (h->dynstr_index == (unsigned long) -1)
- return false;
- }
-
- return true;
-}
-
-/* Create a special linker section, or return a pointer to a linker section already created */
-
-elf_linker_section_t *
-_bfd_elf_create_linker_section (abfd, info, which, defaults)
- bfd *abfd;
- struct bfd_link_info *info;
- enum elf_linker_section_enum which;
- elf_linker_section_t *defaults;
-{
- bfd *dynobj = elf_hash_table (info)->dynobj;
- elf_linker_section_t *lsect;
-
- /* Record the first bfd section that needs the special section */
- if (!dynobj)
- dynobj = elf_hash_table (info)->dynobj = abfd;
-
- /* If this is the first time, create the section */
- lsect = elf_linker_section (dynobj, which);
- if (!lsect)
- {
- asection *s;
-
- lsect = (elf_linker_section_t *)
- bfd_alloc (dynobj, sizeof (elf_linker_section_t));
-
- *lsect = *defaults;
- elf_linker_section (dynobj, which) = lsect;
- lsect->which = which;
- lsect->hole_written_p = false;
-
- /* See if the sections already exist */
- lsect->section = s = bfd_get_section_by_name (dynobj, lsect->name);
- if (!s)
- {
- lsect->section = s = bfd_make_section (dynobj, lsect->name);
-
- if (s == NULL)
- return (elf_linker_section_t *)0;
-
- bfd_set_section_flags (dynobj, s, defaults->flags);
- bfd_set_section_alignment (dynobj, s, lsect->alignment);
- }
- else if (bfd_get_section_alignment (dynobj, s) < lsect->alignment)
- bfd_set_section_alignment (dynobj, s, lsect->alignment);
-
- s->_raw_size = align_power (s->_raw_size, lsect->alignment);
-
- /* Is there a hole we have to provide? If so check whether the segment is
- too big already */
- if (lsect->hole_size)
- {
- lsect->hole_offset = s->_raw_size;
- s->_raw_size += lsect->hole_size;
- if (lsect->hole_offset > lsect->max_hole_offset)
- {
- (*_bfd_error_handler) ("%s: Section %s is already to large to put hole of %ld bytes in",
- bfd_get_filename (abfd),
- lsect->name,
- (long)lsect->hole_size);
-
- bfd_set_error (bfd_error_bad_value);
- return (elf_linker_section_t *)0;
- }
- }
-
-#ifdef DEBUG
- fprintf (stderr, "Creating section %s, current size = %ld\n",
- lsect->name, (long)s->_raw_size);
-#endif
-
- if (lsect->sym_name)
- {
- struct elf_link_hash_entry *h = NULL;
-#ifdef DEBUG
- fprintf (stderr, "Adding %s to section %s\n",
- lsect->sym_name,
- lsect->name);
-#endif
- h = (struct elf_link_hash_entry *)
- bfd_link_hash_lookup (info->hash, lsect->sym_name, false, false, false);
-
- if ((h == NULL || h->root.type == bfd_link_hash_undefined)
- && !(_bfd_generic_link_add_one_symbol (info,
- abfd,
- lsect->sym_name,
- BSF_GLOBAL,
- s,
- ((lsect->hole_size)
- ? s->_raw_size - lsect->hole_size + lsect->sym_offset
- : lsect->sym_offset),
- (const char *) NULL,
- false,
- get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return (elf_linker_section_t *)0;
-
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_DYNAMIC;
- h->type = STT_OBJECT;
- lsect->sym_hash = h;
-
- if (info->shared
- && ! _bfd_elf_link_record_dynamic_symbol (info, h))
- return (elf_linker_section_t *)0;
- }
- }
-
- /* Find the related sections if they have been created */
- if (lsect->bss_name && !lsect->bss_section)
- lsect->bss_section = bfd_get_section_by_name (dynobj, lsect->bss_name);
-
- if (lsect->rel_name && !lsect->rel_section)
- lsect->rel_section = bfd_get_section_by_name (dynobj, lsect->rel_name);
-
- return lsect;
-}
-
-
-/* Find a linker generated pointer with a given addend and type. */
-
-elf_linker_section_pointers_t *
-_bfd_elf_find_pointer_linker_section (linker_pointers, addend, which)
- elf_linker_section_pointers_t *linker_pointers;
- bfd_signed_vma addend;
- elf_linker_section_enum_t which;
-{
- for ( ; linker_pointers != NULL; linker_pointers = linker_pointers->next)
- {
- if (which == linker_pointers->which && addend == linker_pointers->addend)
- return linker_pointers;
- }
-
- return (elf_linker_section_pointers_t *)0;
-}
-
-
-/* Make the .rela section corresponding to the generated linker section. */
-
-boolean
-_bfd_elf_make_linker_section_rela (dynobj, lsect, alignment)
- bfd *dynobj;
- elf_linker_section_t *lsect;
- int alignment;
-{
- if (lsect->rel_section)
- return true;
-
- lsect->rel_section = bfd_get_section_by_name (dynobj, lsect->rel_name);
- if (lsect->rel_section == NULL)
- {
- lsect->rel_section = bfd_make_section (dynobj, lsect->rel_name);
- if (lsect->rel_section == NULL
- || ! bfd_set_section_flags (dynobj,
- lsect->rel_section,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, lsect->rel_section, alignment))
- return false;
- }
-
- return true;
-}
-
diff --git a/contrib/gdb/bfd/elflink.h b/contrib/gdb/bfd/elflink.h
deleted file mode 100644
index 4ef3c8b..0000000
--- a/contrib/gdb/bfd/elflink.h
+++ /dev/null
@@ -1,3424 +0,0 @@
-/* ELF linker support.
- Copyright 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* ELF linker code. */
-
-static boolean elf_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean elf_link_add_archive_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static Elf_Internal_Rela *elf_link_read_relocs
- PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
-static boolean elf_export_symbol
- PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean elf_adjust_dynamic_symbol
- PARAMS ((struct elf_link_hash_entry *, PTR));
-
-/* This struct is used to pass information to routines called via
- elf_link_hash_traverse which must return failure. */
-
-struct elf_info_failed
-{
- boolean failed;
- struct bfd_link_info *info;
-};
-
-/* Given an ELF BFD, add symbols to the global hash table as
- appropriate. */
-
-boolean
-elf_bfd_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- return elf_link_add_object_symbols (abfd, info);
- case bfd_archive:
- return elf_link_add_archive_symbols (abfd, info);
- default:
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-}
-
-
-/* Add symbols from an ELF archive file to the linker hash table. We
- don't use _bfd_generic_link_add_archive_symbols because of a
- problem which arises on UnixWare. The UnixWare libc.so is an
- archive which includes an entry libc.so.1 which defines a bunch of
- symbols. The libc.so archive also includes a number of other
- object files, which also define symbols, some of which are the same
- as those defined in libc.so.1. Correct linking requires that we
- consider each object file in turn, and include it if it defines any
- symbols we need. _bfd_generic_link_add_archive_symbols does not do
- this; it looks through the list of undefined symbols, and includes
- any object file which defines them. When this algorithm is used on
- UnixWare, it winds up pulling in libc.so.1 early and defining a
- bunch of symbols. This means that some of the other objects in the
- archive are not included in the link, which is incorrect since they
- precede libc.so.1 in the archive.
-
- Fortunately, ELF archive handling is simpler than that done by
- _bfd_generic_link_add_archive_symbols, which has to allow for a.out
- oddities. In ELF, if we find a symbol in the archive map, and the
- symbol is currently undefined, we know that we must pull in that
- object file.
-
- Unfortunately, we do have to make multiple passes over the symbol
- table until nothing further is resolved. */
-
-static boolean
-elf_link_add_archive_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- symindex c;
- boolean *defined = NULL;
- boolean *included = NULL;
- carsym *symdefs;
- boolean loop;
-
- if (! bfd_has_map (abfd))
- {
- /* An empty archive is a special case. */
- if (bfd_openr_next_archived_file (abfd, (bfd *) NULL) == NULL)
- return true;
- bfd_set_error (bfd_error_no_armap);
- return false;
- }
-
- /* Keep track of all symbols we know to be already defined, and all
- files we know to be already included. This is to speed up the
- second and subsequent passes. */
- c = bfd_ardata (abfd)->symdef_count;
- if (c == 0)
- return true;
- defined = (boolean *) bfd_malloc (c * sizeof (boolean));
- included = (boolean *) bfd_malloc (c * sizeof (boolean));
- if (defined == (boolean *) NULL || included == (boolean *) NULL)
- goto error_return;
- memset (defined, 0, c * sizeof (boolean));
- memset (included, 0, c * sizeof (boolean));
-
- symdefs = bfd_ardata (abfd)->symdefs;
-
- do
- {
- file_ptr last;
- symindex i;
- carsym *symdef;
- carsym *symdefend;
-
- loop = false;
- last = -1;
-
- symdef = symdefs;
- symdefend = symdef + c;
- for (i = 0; symdef < symdefend; symdef++, i++)
- {
- struct elf_link_hash_entry *h;
- bfd *element;
- struct bfd_link_hash_entry *undefs_tail;
- symindex mark;
-
- if (defined[i] || included[i])
- continue;
- if (symdef->file_offset == last)
- {
- included[i] = true;
- continue;
- }
-
- h = elf_link_hash_lookup (elf_hash_table (info), symdef->name,
- false, false, false);
- if (h == (struct elf_link_hash_entry *) NULL)
- continue;
- if (h->root.type != bfd_link_hash_undefined)
- {
- if (h->root.type != bfd_link_hash_undefweak)
- defined[i] = true;
- continue;
- }
-
- /* We need to include this archive member. */
-
- element = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
- if (element == (bfd *) NULL)
- goto error_return;
-
- if (! bfd_check_format (element, bfd_object))
- goto error_return;
-
- /* Doublecheck that we have not included this object
- already--it should be impossible, but there may be
- something wrong with the archive. */
- if (element->archive_pass != 0)
- {
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
- element->archive_pass = 1;
-
- undefs_tail = info->hash->undefs_tail;
-
- if (! (*info->callbacks->add_archive_element) (info, element,
- symdef->name))
- goto error_return;
- if (! elf_link_add_object_symbols (element, info))
- goto error_return;
-
- /* If there are any new undefined symbols, we need to make
- another pass through the archive in order to see whether
- they can be defined. FIXME: This isn't perfect, because
- common symbols wind up on undefs_tail and because an
- undefined symbol which is defined later on in this pass
- does not require another pass. This isn't a bug, but it
- does make the code less efficient than it could be. */
- if (undefs_tail != info->hash->undefs_tail)
- loop = true;
-
- /* Look backward to mark all symbols from this object file
- which we have already seen in this pass. */
- mark = i;
- do
- {
- included[mark] = true;
- if (mark == 0)
- break;
- --mark;
- }
- while (symdefs[mark].file_offset == symdef->file_offset);
-
- /* We mark subsequent symbols from this object file as we go
- on through the loop. */
- last = symdef->file_offset;
- }
- }
- while (loop);
-
- free (defined);
- free (included);
-
- return true;
-
- error_return:
- if (defined != (boolean *) NULL)
- free (defined);
- if (included != (boolean *) NULL)
- free (included);
- return false;
-}
-
-/* Add symbols from an ELF object file to the linker hash table. */
-
-static boolean
-elf_link_add_object_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- boolean (*add_symbol_hook) PARAMS ((bfd *, struct bfd_link_info *,
- const Elf_Internal_Sym *,
- const char **, flagword *,
- asection **, bfd_vma *));
- boolean (*check_relocs) PARAMS ((bfd *, struct bfd_link_info *,
- asection *, const Elf_Internal_Rela *));
- boolean collect;
- Elf_Internal_Shdr *hdr;
- size_t symcount;
- size_t extsymcount;
- size_t extsymoff;
- Elf_External_Sym *buf = NULL;
- struct elf_link_hash_entry **sym_hash;
- boolean dynamic;
- Elf_External_Dyn *dynbuf = NULL;
- struct elf_link_hash_entry *weaks;
- Elf_External_Sym *esym;
- Elf_External_Sym *esymend;
-
- add_symbol_hook = get_elf_backend_data (abfd)->elf_add_symbol_hook;
- collect = get_elf_backend_data (abfd)->collect;
-
- /* As a GNU extension, any input sections which are named
- .gnu.warning.SYMBOL are treated as warning symbols for the given
- symbol. This differs from .gnu.warning sections, which generate
- warnings when they are included in an output file. */
- if (! info->shared)
- {
- asection *s;
-
- for (s = abfd->sections; s != NULL; s = s->next)
- {
- const char *name;
-
- name = bfd_get_section_name (abfd, s);
- if (strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0)
- {
- char *msg;
- bfd_size_type sz;
-
- sz = bfd_section_size (abfd, s);
- msg = (char *) bfd_alloc (abfd, sz);
- if (msg == NULL)
- goto error_return;
-
- if (! bfd_get_section_contents (abfd, s, msg, (file_ptr) 0, sz))
- goto error_return;
-
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd,
- name + sizeof ".gnu.warning." - 1,
- BSF_WARNING, s, (bfd_vma) 0, msg, false, collect,
- (struct bfd_link_hash_entry **) NULL)))
- goto error_return;
-
- if (! info->relocateable)
- {
- /* Clobber the section size so that the warning does
- not get copied into the output file. */
- s->_raw_size = 0;
- }
- }
- }
- }
-
- /* A stripped shared library might only have a dynamic symbol table,
- not a regular symbol table. In that case we can still go ahead
- and link using the dynamic symbol table. */
- if (elf_onesymtab (abfd) == 0
- && elf_dynsymtab (abfd) != 0)
- {
- elf_onesymtab (abfd) = elf_dynsymtab (abfd);
- elf_tdata (abfd)->symtab_hdr = elf_tdata (abfd)->dynsymtab_hdr;
- }
-
- hdr = &elf_tdata (abfd)->symtab_hdr;
- symcount = hdr->sh_size / sizeof (Elf_External_Sym);
-
- /* The sh_info field of the symtab header tells us where the
- external symbols start. We don't care about the local symbols at
- this point. */
- if (elf_bad_symtab (abfd))
- {
- extsymcount = symcount;
- extsymoff = 0;
- }
- else
- {
- extsymcount = symcount - hdr->sh_info;
- extsymoff = hdr->sh_info;
- }
-
- buf = ((Elf_External_Sym *)
- bfd_malloc (extsymcount * sizeof (Elf_External_Sym)));
- if (buf == NULL && extsymcount != 0)
- goto error_return;
-
- /* We store a pointer to the hash table entry for each external
- symbol. */
- sym_hash = ((struct elf_link_hash_entry **)
- bfd_alloc (abfd,
- extsymcount * sizeof (struct elf_link_hash_entry *)));
- if (sym_hash == NULL)
- goto error_return;
- elf_sym_hashes (abfd) = sym_hash;
-
- if (elf_elfheader (abfd)->e_type != ET_DYN)
- {
- dynamic = false;
-
- /* If we are creating a shared library, create all the dynamic
- sections immediately. We need to attach them to something,
- so we attach them to this BFD, provided it is the right
- format. FIXME: If there are no input BFD's of the same
- format as the output, we can't make a shared library. */
- if (info->shared
- && ! elf_hash_table (info)->dynamic_sections_created
- && abfd->xvec == info->hash->creator)
- {
- if (! elf_link_create_dynamic_sections (abfd, info))
- goto error_return;
- }
- }
- else
- {
- asection *s;
- boolean add_needed;
- const char *name;
- bfd_size_type oldsize;
- bfd_size_type strindex;
-
- dynamic = true;
-
- /* You can't use -r against a dynamic object. Also, there's no
- hope of using a dynamic object which does not exactly match
- the format of the output file. */
- if (info->relocateable
- || info->hash->creator != abfd->xvec)
- {
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
-
- /* Find the name to use in a DT_NEEDED entry that refers to this
- object. If the object has a DT_SONAME entry, we use it.
- Otherwise, if the generic linker stuck something in
- elf_dt_name, we use that. Otherwise, we just use the file
- name. If the generic linker put a null string into
- elf_dt_name, we don't make a DT_NEEDED entry at all, even if
- there is a DT_SONAME entry. */
- add_needed = true;
- name = bfd_get_filename (abfd);
- if (elf_dt_name (abfd) != NULL)
- {
- name = elf_dt_name (abfd);
- if (*name == '\0')
- add_needed = false;
- }
- s = bfd_get_section_by_name (abfd, ".dynamic");
- if (s != NULL)
- {
- Elf_External_Dyn *extdyn;
- Elf_External_Dyn *extdynend;
- int elfsec;
- unsigned long link;
-
- dynbuf = (Elf_External_Dyn *) bfd_malloc ((size_t) s->_raw_size);
- if (dynbuf == NULL)
- goto error_return;
-
- if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf,
- (file_ptr) 0, s->_raw_size))
- goto error_return;
-
- elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
- if (elfsec == -1)
- goto error_return;
- link = elf_elfsections (abfd)[elfsec]->sh_link;
-
- extdyn = dynbuf;
- extdynend = extdyn + s->_raw_size / sizeof (Elf_External_Dyn);
- for (; extdyn < extdynend; extdyn++)
- {
- Elf_Internal_Dyn dyn;
-
- elf_swap_dyn_in (abfd, extdyn, &dyn);
- if (dyn.d_tag == DT_SONAME)
- {
- name = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
- if (name == NULL)
- goto error_return;
- }
- if (dyn.d_tag == DT_NEEDED)
- {
- struct bfd_link_needed_list *n, **pn;
- char *fnm, *anm;
-
- n = ((struct bfd_link_needed_list *)
- bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
- fnm = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
- if (n == NULL || fnm == NULL)
- goto error_return;
- anm = bfd_alloc (abfd, strlen (fnm) + 1);
- if (anm == NULL)
- goto error_return;
- strcpy (anm, fnm);
- n->name = anm;
- n->by = abfd;
- n->next = NULL;
- for (pn = &elf_hash_table (info)->needed;
- *pn != NULL;
- pn = &(*pn)->next)
- ;
- *pn = n;
- }
- }
-
- free (dynbuf);
- dynbuf = NULL;
- }
-
- /* We do not want to include any of the sections in a dynamic
- object in the output file. We hack by simply clobbering the
- list of sections in the BFD. This could be handled more
- cleanly by, say, a new section flag; the existing
- SEC_NEVER_LOAD flag is not the one we want, because that one
- still implies that the section takes up space in the output
- file. */
- abfd->sections = NULL;
- abfd->section_count = 0;
-
- /* If this is the first dynamic object found in the link, create
- the special sections required for dynamic linking. */
- if (! elf_hash_table (info)->dynamic_sections_created)
- {
- if (! elf_link_create_dynamic_sections (abfd, info))
- goto error_return;
- }
-
- if (add_needed)
- {
- /* Add a DT_NEEDED entry for this dynamic object. */
- oldsize = _bfd_stringtab_size (elf_hash_table (info)->dynstr);
- strindex = _bfd_stringtab_add (elf_hash_table (info)->dynstr, name,
- true, false);
- if (strindex == (bfd_size_type) -1)
- goto error_return;
-
- if (oldsize == _bfd_stringtab_size (elf_hash_table (info)->dynstr))
- {
- asection *sdyn;
- Elf_External_Dyn *dyncon, *dynconend;
-
- /* The hash table size did not change, which means that
- the dynamic object name was already entered. If we
- have already included this dynamic object in the
- link, just ignore it. There is no reason to include
- a particular dynamic object more than once. */
- sdyn = bfd_get_section_by_name (elf_hash_table (info)->dynobj,
- ".dynamic");
- BFD_ASSERT (sdyn != NULL);
-
- dyncon = (Elf_External_Dyn *) sdyn->contents;
- dynconend = (Elf_External_Dyn *) (sdyn->contents +
- sdyn->_raw_size);
- for (; dyncon < dynconend; dyncon++)
- {
- Elf_Internal_Dyn dyn;
-
- elf_swap_dyn_in (elf_hash_table (info)->dynobj, dyncon,
- &dyn);
- if (dyn.d_tag == DT_NEEDED
- && dyn.d_un.d_val == strindex)
- {
- if (buf != NULL)
- free (buf);
- return true;
- }
- }
- }
-
- if (! elf_add_dynamic_entry (info, DT_NEEDED, strindex))
- goto error_return;
- }
-
- /* Save the SONAME, if there is one, because sometimes the
- linker emulation code will need to know it. */
- if (*name == '\0')
- name = bfd_get_filename (abfd);
- elf_dt_name (abfd) = name;
- }
-
- if (bfd_seek (abfd,
- hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym),
- SEEK_SET) != 0
- || (bfd_read ((PTR) buf, sizeof (Elf_External_Sym), extsymcount, abfd)
- != extsymcount * sizeof (Elf_External_Sym)))
- goto error_return;
-
- weaks = NULL;
-
- esymend = buf + extsymcount;
- for (esym = buf; esym < esymend; esym++, sym_hash++)
- {
- Elf_Internal_Sym sym;
- int bind;
- bfd_vma value;
- asection *sec;
- flagword flags;
- const char *name;
- struct elf_link_hash_entry *h;
- boolean definition;
- boolean size_change_ok, type_change_ok;
- boolean new_weakdef;
-
- elf_swap_symbol_in (abfd, esym, &sym);
-
- flags = BSF_NO_FLAGS;
- sec = NULL;
- value = sym.st_value;
- *sym_hash = NULL;
-
- bind = ELF_ST_BIND (sym.st_info);
- if (bind == STB_LOCAL)
- {
- /* This should be impossible, since ELF requires that all
- global symbols follow all local symbols, and that sh_info
- point to the first global symbol. Unfortunatealy, Irix 5
- screws this up. */
- continue;
- }
- else if (bind == STB_GLOBAL)
- {
- if (sym.st_shndx != SHN_UNDEF
- && sym.st_shndx != SHN_COMMON)
- flags = BSF_GLOBAL;
- else
- flags = 0;
- }
- else if (bind == STB_WEAK)
- flags = BSF_WEAK;
- else
- {
- /* Leave it up to the processor backend. */
- }
-
- if (sym.st_shndx == SHN_UNDEF)
- sec = bfd_und_section_ptr;
- else if (sym.st_shndx > 0 && sym.st_shndx < SHN_LORESERVE)
- {
- sec = section_from_elf_index (abfd, sym.st_shndx);
- if (sec != NULL)
- value -= sec->vma;
- else
- sec = bfd_abs_section_ptr;
- }
- else if (sym.st_shndx == SHN_ABS)
- sec = bfd_abs_section_ptr;
- else if (sym.st_shndx == SHN_COMMON)
- {
- sec = bfd_com_section_ptr;
- /* What ELF calls the size we call the value. What ELF
- calls the value we call the alignment. */
- value = sym.st_size;
- }
- else
- {
- /* Leave it up to the processor backend. */
- }
-
- name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, sym.st_name);
- if (name == (const char *) NULL)
- goto error_return;
-
- if (add_symbol_hook)
- {
- if (! (*add_symbol_hook) (abfd, info, &sym, &name, &flags, &sec,
- &value))
- goto error_return;
-
- /* The hook function sets the name to NULL if this symbol
- should be skipped for some reason. */
- if (name == (const char *) NULL)
- continue;
- }
-
- /* Sanity check that all possibilities were handled. */
- if (sec == (asection *) NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- if (bfd_is_und_section (sec)
- || bfd_is_com_section (sec))
- definition = false;
- else
- definition = true;
-
- size_change_ok = false;
- type_change_ok = get_elf_backend_data (abfd)->type_change_ok;
- if (info->hash->creator->flavour == bfd_target_elf_flavour)
- {
- /* We need to look up the symbol now in order to get some of
- the dynamic object handling right. We pass the hash
- table entry in to _bfd_generic_link_add_one_symbol so
- that it does not have to look it up again. */
- if (! bfd_is_und_section (sec))
- h = elf_link_hash_lookup (elf_hash_table (info), name,
- true, false, false);
- else
- h = ((struct elf_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (abfd, info, name, true,
- false, false));
- if (h == NULL)
- goto error_return;
- *sym_hash = h;
-
- if (h->root.type == bfd_link_hash_new)
- h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
-
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
- /* It's OK to change the type if it used to be a weak
- definition. */
- if (h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_undefweak)
- type_change_ok = true;
-
- /* It's OK to change the size if it used to be a weak
- definition, or if it used to be undefined, or if we will
- be overriding an old definition. */
- if (type_change_ok
- || h->root.type == bfd_link_hash_undefined)
- size_change_ok = true;
-
- /* If we are looking at a dynamic object, and this is a
- definition, we need to see if it has already been defined
- by some other object. If it has, we want to use the
- existing definition, and we do not want to report a
- multiple symbol definition error; we do this by
- clobbering sec to be bfd_und_section_ptr. */
- if (dynamic && definition)
- {
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || (h->root.type == bfd_link_hash_common
- && bind == STB_WEAK))
- {
- sec = bfd_und_section_ptr;
- definition = false;
- size_change_ok = true;
- }
- }
-
- /* Similarly, if we are not looking at a dynamic object, and
- we have a definition, we want to override any definition
- we may have from a dynamic object. Symbols from regular
- files always take precedence over symbols from dynamic
- objects, even if they are defined after the dynamic
- object in the link. */
- if (! dynamic
- && definition
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (bfd_get_flavour (h->root.u.def.section->owner)
- == bfd_target_elf_flavour)
- && (elf_elfheader (h->root.u.def.section->owner)->e_type
- == ET_DYN))
- {
- /* Change the hash table entry to undefined, and let
- _bfd_generic_link_add_one_symbol do the right thing
- with the new definition. */
- h->root.type = bfd_link_hash_undefined;
- h->root.u.undef.abfd = h->root.u.def.section->owner;
- size_change_ok = true;
- }
- }
-
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, name, flags, sec, value, (const char *) NULL,
- false, collect, (struct bfd_link_hash_entry **) sym_hash)))
- goto error_return;
-
- h = *sym_hash;
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- *sym_hash = h;
-
- new_weakdef = false;
- if (dynamic
- && definition
- && (flags & BSF_WEAK) != 0
- && ELF_ST_TYPE (sym.st_info) != STT_FUNC
- && info->hash->creator->flavour == bfd_target_elf_flavour
- && h->weakdef == NULL)
- {
- /* Keep a list of all weak defined non function symbols from
- a dynamic object, using the weakdef field. Later in this
- function we will set the weakdef field to the correct
- value. We only put non-function symbols from dynamic
- objects on this list, because that happens to be the only
- time we need to know the normal symbol corresponding to a
- weak symbol, and the information is time consuming to
- figure out. If the weakdef field is not already NULL,
- then this symbol was already defined by some previous
- dynamic object, and we will be using that previous
- definition anyhow. */
-
- h->weakdef = weaks;
- weaks = h;
- new_weakdef = true;
- }
-
- /* Get the alignment of a common symbol. */
- if (sym.st_shndx == SHN_COMMON
- && h->root.type == bfd_link_hash_common)
- h->root.u.c.p->alignment_power = bfd_log2 (sym.st_value);
-
- if (info->hash->creator->flavour == bfd_target_elf_flavour)
- {
- int old_flags;
- boolean dynsym;
- int new_flag;
-
- /* Remember the symbol size and type. */
- if (sym.st_size != 0
- && (definition || h->size == 0))
- {
- if (h->size != 0 && h->size != sym.st_size && ! size_change_ok)
- (*_bfd_error_handler)
- ("Warning: size of symbol `%s' changed from %lu to %lu in %s",
- name, (unsigned long) h->size, (unsigned long) sym.st_size,
- bfd_get_filename (abfd));
-
- h->size = sym.st_size;
- }
- if (ELF_ST_TYPE (sym.st_info) != STT_NOTYPE
- && (definition || h->type == STT_NOTYPE))
- {
- if (h->type != STT_NOTYPE
- && h->type != ELF_ST_TYPE (sym.st_info)
- && ! type_change_ok)
- (*_bfd_error_handler)
- ("Warning: type of symbol `%s' changed from %d to %d in %s",
- name, h->type, ELF_ST_TYPE (sym.st_info),
- bfd_get_filename (abfd));
-
- h->type = ELF_ST_TYPE (sym.st_info);
- }
-
- /* Set a flag in the hash table entry indicating the type of
- reference or definition we just found. Keep a count of
- the number of dynamic symbols we find. A dynamic symbol
- is one which is referenced or defined by both a regular
- object and a shared object, or one which is referenced or
- defined by more than one shared object. */
- old_flags = h->elf_link_hash_flags;
- dynsym = false;
- if (! dynamic)
- {
- if (! definition)
- new_flag = ELF_LINK_HASH_REF_REGULAR;
- else
- new_flag = ELF_LINK_HASH_DEF_REGULAR;
- if (info->shared
- || (old_flags & (ELF_LINK_HASH_DEF_DYNAMIC
- | ELF_LINK_HASH_REF_DYNAMIC)) != 0)
- dynsym = true;
- }
- else
- {
- if (! definition)
- new_flag = ELF_LINK_HASH_REF_DYNAMIC;
- else
- new_flag = ELF_LINK_HASH_DEF_DYNAMIC;
- if ((old_flags & new_flag) != 0
- || (old_flags & (ELF_LINK_HASH_DEF_REGULAR
- | ELF_LINK_HASH_REF_REGULAR)) != 0
- || (h->weakdef != NULL
- && (old_flags & (ELF_LINK_HASH_DEF_DYNAMIC
- | ELF_LINK_HASH_REF_DYNAMIC)) != 0))
- dynsym = true;
- }
-
- h->elf_link_hash_flags |= new_flag;
- if (dynsym && h->dynindx == -1)
- {
- if (! _bfd_elf_link_record_dynamic_symbol (info, h))
- goto error_return;
- if (h->weakdef != NULL
- && ! new_weakdef
- && h->weakdef->dynindx == -1)
- {
- if (! _bfd_elf_link_record_dynamic_symbol (info,
- h->weakdef))
- goto error_return;
- }
- }
- }
- }
-
- /* Now set the weakdefs field correctly for all the weak defined
- symbols we found. The only way to do this is to search all the
- symbols. Since we only need the information for non functions in
- dynamic objects, that's the only time we actually put anything on
- the list WEAKS. We need this information so that if a regular
- object refers to a symbol defined weakly in a dynamic object, the
- real symbol in the dynamic object is also put in the dynamic
- symbols; we also must arrange for both symbols to point to the
- same memory location. We could handle the general case of symbol
- aliasing, but a general symbol alias can only be generated in
- assembler code, handling it correctly would be very time
- consuming, and other ELF linkers don't handle general aliasing
- either. */
- while (weaks != NULL)
- {
- struct elf_link_hash_entry *hlook;
- asection *slook;
- bfd_vma vlook;
- struct elf_link_hash_entry **hpp;
- struct elf_link_hash_entry **hppend;
-
- hlook = weaks;
- weaks = hlook->weakdef;
- hlook->weakdef = NULL;
-
- BFD_ASSERT (hlook->root.type == bfd_link_hash_defined
- || hlook->root.type == bfd_link_hash_defweak
- || hlook->root.type == bfd_link_hash_common
- || hlook->root.type == bfd_link_hash_indirect);
- slook = hlook->root.u.def.section;
- vlook = hlook->root.u.def.value;
-
- hpp = elf_sym_hashes (abfd);
- hppend = hpp + extsymcount;
- for (; hpp < hppend; hpp++)
- {
- struct elf_link_hash_entry *h;
-
- h = *hpp;
- if (h != NULL && h != hlook
- && h->root.type == bfd_link_hash_defined
- && h->root.u.def.section == slook
- && h->root.u.def.value == vlook)
- {
- hlook->weakdef = h;
-
- /* If the weak definition is in the list of dynamic
- symbols, make sure the real definition is put there
- as well. */
- if (hlook->dynindx != -1
- && h->dynindx == -1)
- {
- if (! _bfd_elf_link_record_dynamic_symbol (info, h))
- goto error_return;
- }
-
- break;
- }
- }
- }
-
- if (buf != NULL)
- {
- free (buf);
- buf = NULL;
- }
-
- /* If this object is the same format as the output object, and it is
- not a shared library, then let the backend look through the
- relocs.
-
- This is required to build global offset table entries and to
- arrange for dynamic relocs. It is not required for the
- particular common case of linking non PIC code, even when linking
- against shared libraries, but unfortunately there is no way of
- knowing whether an object file has been compiled PIC or not.
- Looking through the relocs is not particularly time consuming.
- The problem is that we must either (1) keep the relocs in memory,
- which causes the linker to require additional runtime memory or
- (2) read the relocs twice from the input file, which wastes time.
- This would be a good case for using mmap.
-
- I have no idea how to handle linking PIC code into a file of a
- different format. It probably can't be done. */
- check_relocs = get_elf_backend_data (abfd)->check_relocs;
- if (! dynamic
- && abfd->xvec == info->hash->creator
- && check_relocs != NULL)
- {
- asection *o;
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- Elf_Internal_Rela *internal_relocs;
- boolean ok;
-
- if ((o->flags & SEC_RELOC) == 0
- || o->reloc_count == 0)
- continue;
-
- /* I believe we can ignore the relocs for any section which
- does not form part of the final process image, such as a
- debugging section. */
- if ((o->flags & SEC_ALLOC) == 0)
- continue;
-
- internal_relocs = elf_link_read_relocs (abfd, o, (PTR) NULL,
- (Elf_Internal_Rela *) NULL,
- info->keep_memory);
- if (internal_relocs == NULL)
- goto error_return;
-
- ok = (*check_relocs) (abfd, info, o, internal_relocs);
-
- if (! info->keep_memory)
- free (internal_relocs);
-
- if (! ok)
- goto error_return;
- }
- }
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- if (dynbuf != NULL)
- free (dynbuf);
- return false;
-}
-
-/* Create some sections which will be filled in with dynamic linking
- information. ABFD is an input file which requires dynamic sections
- to be created. The dynamic sections take up virtual memory space
- when the final executable is run, so we need to create them before
- addresses are assigned to the output sections. We work out the
- actual contents and size of these sections later. */
-
-boolean
-elf_link_create_dynamic_sections (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- flagword flags;
- register asection *s;
- struct elf_link_hash_entry *h;
- struct elf_backend_data *bed;
-
- if (elf_hash_table (info)->dynamic_sections_created)
- return true;
-
- /* Make sure that all dynamic sections use the same input BFD. */
- if (elf_hash_table (info)->dynobj == NULL)
- elf_hash_table (info)->dynobj = abfd;
- else
- abfd = elf_hash_table (info)->dynobj;
-
- /* Note that we set the SEC_IN_MEMORY flag for all of these
- sections. */
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- /* A dynamically linked executable has a .interp section, but a
- shared library does not. */
- if (! info->shared)
- {
- s = bfd_make_section (abfd, ".interp");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY))
- return false;
- }
-
- s = bfd_make_section (abfd, ".dynsym");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
- return false;
-
- s = bfd_make_section (abfd, ".dynstr");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY))
- return false;
-
- /* Create a strtab to hold the dynamic symbol names. */
- if (elf_hash_table (info)->dynstr == NULL)
- {
- elf_hash_table (info)->dynstr = elf_stringtab_init ();
- if (elf_hash_table (info)->dynstr == NULL)
- return false;
- }
-
- s = bfd_make_section (abfd, ".dynamic");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
- || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
- return false;
-
- /* The special symbol _DYNAMIC is always set to the start of the
- .dynamic section. This call occurs before we have processed the
- symbols for any dynamic object, so we don't have to worry about
- overriding a dynamic definition. We could set _DYNAMIC in a
- linker script, but we only want to define it if we are, in fact,
- creating a .dynamic section. We don't want to define it if there
- is no .dynamic section, since on some ELF platforms the start up
- code examines it to decide how to initialize the process. */
- h = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, "_DYNAMIC", BSF_GLOBAL, s, (bfd_vma) 0,
- (const char *) NULL, false, get_elf_backend_data (abfd)->collect,
- (struct bfd_link_hash_entry **) &h)))
- return false;
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_OBJECT;
-
- if (info->shared
- && ! _bfd_elf_link_record_dynamic_symbol (info, h))
- return false;
-
- s = bfd_make_section (abfd, ".hash");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, LOG_FILE_ALIGN))
- return false;
-
- /* Let the backend create the rest of the sections. This lets the
- backend set the right flags. The backend will normally create
- the .got and .plt sections. */
- bed = get_elf_backend_data (abfd);
- if (! (*bed->elf_backend_create_dynamic_sections) (abfd, info))
- return false;
-
- elf_hash_table (info)->dynamic_sections_created = true;
-
- return true;
-}
-
-/* Add an entry to the .dynamic table. */
-
-boolean
-elf_add_dynamic_entry (info, tag, val)
- struct bfd_link_info *info;
- bfd_vma tag;
- bfd_vma val;
-{
- Elf_Internal_Dyn dyn;
- bfd *dynobj;
- asection *s;
- size_t newsize;
- bfd_byte *newcontents;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- s = bfd_get_section_by_name (dynobj, ".dynamic");
- BFD_ASSERT (s != NULL);
-
- newsize = s->_raw_size + sizeof (Elf_External_Dyn);
- newcontents = (bfd_byte *) bfd_realloc (s->contents, newsize);
- if (newcontents == NULL)
- return false;
-
- dyn.d_tag = tag;
- dyn.d_un.d_val = val;
- elf_swap_dyn_out (dynobj, &dyn,
- (Elf_External_Dyn *) (newcontents + s->_raw_size));
-
- s->_raw_size = newsize;
- s->contents = newcontents;
-
- return true;
-}
-
-
-/* Read and swap the relocs for a section. They may have been cached.
- If the EXTERNAL_RELOCS and INTERNAL_RELOCS arguments are not NULL,
- they are used as buffers to read into. They are known to be large
- enough. If the INTERNAL_RELOCS relocs argument is NULL, the return
- value is allocated using either malloc or bfd_alloc, according to
- the KEEP_MEMORY argument. */
-
-static Elf_Internal_Rela *
-elf_link_read_relocs (abfd, o, external_relocs, internal_relocs, keep_memory)
- bfd *abfd;
- asection *o;
- PTR external_relocs;
- Elf_Internal_Rela *internal_relocs;
- boolean keep_memory;
-{
- Elf_Internal_Shdr *rel_hdr;
- PTR alloc1 = NULL;
- Elf_Internal_Rela *alloc2 = NULL;
-
- if (elf_section_data (o)->relocs != NULL)
- return elf_section_data (o)->relocs;
-
- if (o->reloc_count == 0)
- return NULL;
-
- rel_hdr = &elf_section_data (o)->rel_hdr;
-
- if (internal_relocs == NULL)
- {
- size_t size;
-
- size = o->reloc_count * sizeof (Elf_Internal_Rela);
- if (keep_memory)
- internal_relocs = (Elf_Internal_Rela *) bfd_alloc (abfd, size);
- else
- internal_relocs = alloc2 = (Elf_Internal_Rela *) bfd_malloc (size);
- if (internal_relocs == NULL)
- goto error_return;
- }
-
- if (external_relocs == NULL)
- {
- alloc1 = (PTR) bfd_malloc ((size_t) rel_hdr->sh_size);
- if (alloc1 == NULL)
- goto error_return;
- external_relocs = alloc1;
- }
-
- if ((bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0)
- || (bfd_read (external_relocs, 1, rel_hdr->sh_size, abfd)
- != rel_hdr->sh_size))
- goto error_return;
-
- /* Swap in the relocs. For convenience, we always produce an
- Elf_Internal_Rela array; if the relocs are Rel, we set the addend
- to 0. */
- if (rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
- {
- Elf_External_Rel *erel;
- Elf_External_Rel *erelend;
- Elf_Internal_Rela *irela;
-
- erel = (Elf_External_Rel *) external_relocs;
- erelend = erel + o->reloc_count;
- irela = internal_relocs;
- for (; erel < erelend; erel++, irela++)
- {
- Elf_Internal_Rel irel;
-
- elf_swap_reloc_in (abfd, erel, &irel);
- irela->r_offset = irel.r_offset;
- irela->r_info = irel.r_info;
- irela->r_addend = 0;
- }
- }
- else
- {
- Elf_External_Rela *erela;
- Elf_External_Rela *erelaend;
- Elf_Internal_Rela *irela;
-
- BFD_ASSERT (rel_hdr->sh_entsize == sizeof (Elf_External_Rela));
-
- erela = (Elf_External_Rela *) external_relocs;
- erelaend = erela + o->reloc_count;
- irela = internal_relocs;
- for (; erela < erelaend; erela++, irela++)
- elf_swap_reloca_in (abfd, erela, irela);
- }
-
- /* Cache the results for next time, if we can. */
- if (keep_memory)
- elf_section_data (o)->relocs = internal_relocs;
-
- if (alloc1 != NULL)
- free (alloc1);
-
- /* Don't free alloc2, since if it was allocated we are passing it
- back (under the name of internal_relocs). */
-
- return internal_relocs;
-
- error_return:
- if (alloc1 != NULL)
- free (alloc1);
- if (alloc2 != NULL)
- free (alloc2);
- return NULL;
-}
-
-
-/* Record an assignment to a symbol made by a linker script. We need
- this in case some dynamic object refers to this symbol. */
-
-/*ARGSUSED*/
-boolean
-NAME(bfd_elf,record_link_assignment) (output_bfd, info, name, provide)
- bfd *output_bfd;
- struct bfd_link_info *info;
- const char *name;
- boolean provide;
-{
- struct elf_link_hash_entry *h;
-
- if (info->hash->creator->flavour != bfd_target_elf_flavour)
- return true;
-
- h = elf_link_hash_lookup (elf_hash_table (info), name, true, true, false);
- if (h == NULL)
- return false;
-
- if (h->root.type == bfd_link_hash_new)
- h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
-
- /* If this symbol is being provided by the linker script, and it is
- currently defined by a dynamic object, but not by a regular
- object, then mark it as undefined so that the generic linker will
- force the correct value. */
- if (provide
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
- h->root.type = bfd_link_hash_undefined;
-
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- h->type = STT_OBJECT;
-
- if (((h->elf_link_hash_flags & (ELF_LINK_HASH_DEF_DYNAMIC
- | ELF_LINK_HASH_REF_DYNAMIC)) != 0
- || info->shared)
- && h->dynindx == -1)
- {
- if (! _bfd_elf_link_record_dynamic_symbol (info, h))
- return false;
-
- /* If this is a weak defined symbol, and we know a corresponding
- real symbol from the same dynamic object, make sure the real
- symbol is also made into a dynamic symbol. */
- if (h->weakdef != NULL
- && h->weakdef->dynindx == -1)
- {
- if (! _bfd_elf_link_record_dynamic_symbol (info, h->weakdef))
- return false;
- }
- }
-
- return true;
-}
-
-
-/* Array used to determine the number of hash table buckets to use
- based on the number of symbols there are. If there are fewer than
- 3 symbols we use 1 bucket, fewer than 17 symbols we use 3 buckets,
- fewer than 37 we use 17 buckets, and so forth. We never use more
- than 521 buckets. */
-
-static const size_t elf_buckets[] =
-{
- 1, 3, 17, 37, 67, 97, 131, 197, 263, 521, 0
-};
-
-/* Set up the sizes and contents of the ELF dynamic sections. This is
- called by the ELF linker emulation before_allocation routine. We
- must set the sizes of the sections before the linker sets the
- addresses of the various sections. */
-
-boolean
-NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
- export_dynamic, info, sinterpptr)
- bfd *output_bfd;
- const char *soname;
- const char *rpath;
- boolean export_dynamic;
- struct bfd_link_info *info;
- asection **sinterpptr;
-{
- bfd *dynobj;
- struct elf_backend_data *bed;
-
- *sinterpptr = NULL;
-
- if (info->hash->creator->flavour != bfd_target_elf_flavour)
- return true;
-
- dynobj = elf_hash_table (info)->dynobj;
-
- /* If there were no dynamic objects in the link, there is nothing to
- do here. */
- if (dynobj == NULL)
- return true;
-
- /* If we are supposed to export all symbols into the dynamic symbol
- table (this is not the normal case), then do so. */
- if (export_dynamic)
- {
- struct elf_info_failed eif;
-
- eif.failed = false;
- eif.info = info;
- elf_link_hash_traverse (elf_hash_table (info), elf_export_symbol,
- (PTR) &eif);
- if (eif.failed)
- return false;
- }
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- struct elf_info_failed eif;
- struct elf_link_hash_entry *h;
- bfd_size_type strsize;
-
- *sinterpptr = bfd_get_section_by_name (dynobj, ".interp");
- BFD_ASSERT (*sinterpptr != NULL || info->shared);
-
- if (soname != NULL)
- {
- bfd_size_type indx;
-
- indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr, soname,
- true, true);
- if (indx == (bfd_size_type) -1
- || ! elf_add_dynamic_entry (info, DT_SONAME, indx))
- return false;
- }
-
- if (info->symbolic)
- {
- if (! elf_add_dynamic_entry (info, DT_SYMBOLIC, 0))
- return false;
- }
-
- if (rpath != NULL)
- {
- bfd_size_type indx;
-
- indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr, rpath,
- true, true);
- if (indx == (bfd_size_type) -1
- || ! elf_add_dynamic_entry (info, DT_RPATH, indx))
- return false;
- }
-
- /* Find all symbols which were defined in a dynamic object and make
- the backend pick a reasonable value for them. */
- eif.failed = false;
- eif.info = info;
- elf_link_hash_traverse (elf_hash_table (info),
- elf_adjust_dynamic_symbol,
- (PTR) &eif);
- if (eif.failed)
- return false;
-
- /* Add some entries to the .dynamic section. We fill in some of the
- values later, in elf_bfd_final_link, but we must add the entries
- now so that we know the final size of the .dynamic section. */
- h = elf_link_hash_lookup (elf_hash_table (info), "_init", false,
- false, false);
- if (h != NULL
- && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR
- | ELF_LINK_HASH_DEF_REGULAR)) != 0)
- {
- if (! elf_add_dynamic_entry (info, DT_INIT, 0))
- return false;
- }
- h = elf_link_hash_lookup (elf_hash_table (info), "_fini", false,
- false, false);
- if (h != NULL
- && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR
- | ELF_LINK_HASH_DEF_REGULAR)) != 0)
- {
- if (! elf_add_dynamic_entry (info, DT_FINI, 0))
- return false;
- }
- strsize = _bfd_stringtab_size (elf_hash_table (info)->dynstr);
- if (! elf_add_dynamic_entry (info, DT_HASH, 0)
- || ! elf_add_dynamic_entry (info, DT_STRTAB, 0)
- || ! elf_add_dynamic_entry (info, DT_SYMTAB, 0)
- || ! elf_add_dynamic_entry (info, DT_STRSZ, strsize)
- || ! elf_add_dynamic_entry (info, DT_SYMENT,
- sizeof (Elf_External_Sym)))
- return false;
- }
-
- /* The backend must work out the sizes of all the other dynamic
- sections. */
- bed = get_elf_backend_data (output_bfd);
- if (! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info))
- return false;
-
- if (elf_hash_table (info)->dynamic_sections_created)
- {
- size_t dynsymcount;
- asection *s;
- size_t i;
- size_t bucketcount = 0;
- Elf_Internal_Sym isym;
-
- /* Set the size of the .dynsym and .hash sections. We counted
- the number of dynamic symbols in elf_link_add_object_symbols.
- We will build the contents of .dynsym and .hash when we build
- the final symbol table, because until then we do not know the
- correct value to give the symbols. We built the .dynstr
- section as we went along in elf_link_add_object_symbols. */
- dynsymcount = elf_hash_table (info)->dynsymcount;
- s = bfd_get_section_by_name (dynobj, ".dynsym");
- BFD_ASSERT (s != NULL);
- s->_raw_size = dynsymcount * sizeof (Elf_External_Sym);
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
- if (s->contents == NULL && s->_raw_size != 0)
- return false;
-
- /* The first entry in .dynsym is a dummy symbol. */
- isym.st_value = 0;
- isym.st_size = 0;
- isym.st_name = 0;
- isym.st_info = 0;
- isym.st_other = 0;
- isym.st_shndx = 0;
- elf_swap_symbol_out (output_bfd, &isym,
- (PTR) (Elf_External_Sym *) s->contents);
-
- for (i = 0; elf_buckets[i] != 0; i++)
- {
- bucketcount = elf_buckets[i];
- if (dynsymcount < elf_buckets[i + 1])
- break;
- }
-
- s = bfd_get_section_by_name (dynobj, ".hash");
- BFD_ASSERT (s != NULL);
- s->_raw_size = (2 + bucketcount + dynsymcount) * (ARCH_SIZE / 8);
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
- if (s->contents == NULL)
- return false;
- memset (s->contents, 0, (size_t) s->_raw_size);
-
- put_word (output_bfd, bucketcount, s->contents);
- put_word (output_bfd, dynsymcount, s->contents + (ARCH_SIZE / 8));
-
- elf_hash_table (info)->bucketcount = bucketcount;
-
- s = bfd_get_section_by_name (dynobj, ".dynstr");
- BFD_ASSERT (s != NULL);
- s->_raw_size = _bfd_stringtab_size (elf_hash_table (info)->dynstr);
-
- if (! elf_add_dynamic_entry (info, DT_NULL, 0))
- return false;
- }
-
- return true;
-}
-
-
-/* This routine is used to export all defined symbols into the dynamic
- symbol table. It is called via elf_link_hash_traverse. */
-
-static boolean
-elf_export_symbol (h, data)
- struct elf_link_hash_entry *h;
- PTR data;
-{
- struct elf_info_failed *eif = (struct elf_info_failed *) data;
-
- if (h->dynindx == -1
- && (h->elf_link_hash_flags
- & (ELF_LINK_HASH_DEF_REGULAR | ELF_LINK_HASH_REF_REGULAR)) != 0)
- {
- if (! _bfd_elf_link_record_dynamic_symbol (eif->info, h))
- {
- eif->failed = true;
- return false;
- }
- }
-
- return true;
-}
-
-
-/* Make the backend pick a good value for a dynamic symbol. This is
- called via elf_link_hash_traverse, and also calls itself
- recursively. */
-
-static boolean
-elf_adjust_dynamic_symbol (h, data)
- struct elf_link_hash_entry *h;
- PTR data;
-{
- struct elf_info_failed *eif = (struct elf_info_failed *) data;
- bfd *dynobj;
- struct elf_backend_data *bed;
-
- /* If this symbol was mentioned in a non-ELF file, try to set
- DEF_REGULAR and REF_REGULAR correctly. This is the only way to
- permit a non-ELF file to correctly refer to a symbol defined in
- an ELF dynamic object. */
- if ((h->elf_link_hash_flags & ELF_LINK_NON_ELF) != 0)
- {
- if (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak)
- h->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
- else
- {
- if (h->root.u.def.section->owner != NULL
- && (bfd_get_flavour (h->root.u.def.section->owner)
- == bfd_target_elf_flavour))
- h->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
- else
- h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
- }
-
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- || (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
- {
- if (! _bfd_elf_link_record_dynamic_symbol (eif->info, h))
- {
- eif->failed = true;
- return false;
- }
- }
- }
-
- /* If -Bsymbolic was used (which means to bind references to global
- symbols to the definition within the shared object), and this
- symbol was defined in a regular object, then it actually doesn't
- need a PLT entry. */
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
- && eif->info->shared
- && eif->info->symbolic
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
- h->elf_link_hash_flags &=~ ELF_LINK_HASH_NEEDS_PLT;
-
- /* If this symbol does not require a PLT entry, and it is not
- defined by a dynamic object, or is not referenced by a regular
- object, ignore it. We do have to handle a weak defined symbol,
- even if no regular object refers to it, if we decided to add it
- to the dynamic symbol table. FIXME: Do we normally need to worry
- about symbols which are defined by one dynamic object and
- referenced by another one? */
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) == 0
- && ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
- || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
- || ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0
- && (h->weakdef == NULL || h->weakdef->dynindx == -1))))
- return true;
-
- /* If we've already adjusted this symbol, don't do it again. This
- can happen via a recursive call. */
- if ((h->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
- return true;
-
- /* Don't look at this symbol again. Note that we must set this
- after checking the above conditions, because we may look at a
- symbol once, decide not to do anything, and then get called
- recursively later after REF_REGULAR is set below. */
- h->elf_link_hash_flags |= ELF_LINK_HASH_DYNAMIC_ADJUSTED;
-
- /* If this is a weak definition, and we know a real definition, and
- the real symbol is not itself defined by a regular object file,
- then get a good value for the real definition. We handle the
- real symbol first, for the convenience of the backend routine.
-
- Note that there is a confusing case here. If the real definition
- is defined by a regular object file, we don't get the real symbol
- from the dynamic object, but we do get the weak symbol. If the
- processor backend uses a COPY reloc, then if some routine in the
- dynamic object changes the real symbol, we will not see that
- change in the corresponding weak symbol. This is the way other
- ELF linkers work as well, and seems to be a result of the shared
- library model.
-
- I will clarify this issue. Most SVR4 shared libraries define the
- variable _timezone and define timezone as a weak synonym. The
- tzset call changes _timezone. If you write
- extern int timezone;
- int _timezone = 5;
- int main () { tzset (); printf ("%d %d\n", timezone, _timezone); }
- you might expect that, since timezone is a synonym for _timezone,
- the same number will print both times. However, if the processor
- backend uses a COPY reloc, then actually timezone will be copied
- into your process image, and, since you define _timezone
- yourself, _timezone will not. Thus timezone and _timezone will
- wind up at different memory locations. The tzset call will set
- _timezone, leaving timezone unchanged. */
-
- if (h->weakdef != NULL)
- {
- struct elf_link_hash_entry *weakdef;
-
- BFD_ASSERT (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak);
- weakdef = h->weakdef;
- BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined
- || weakdef->root.type == bfd_link_hash_defweak);
- BFD_ASSERT (weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC);
- if ((weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
- {
- /* This symbol is defined by a regular object file, so we
- will not do anything special. Clear weakdef for the
- convenience of the processor backend. */
- h->weakdef = NULL;
- }
- else
- {
- /* There is an implicit reference by a regular object file
- via the weak symbol. */
- weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
- if (! elf_adjust_dynamic_symbol (weakdef, (PTR) eif))
- return false;
- }
- }
-
- dynobj = elf_hash_table (eif->info)->dynobj;
- bed = get_elf_backend_data (dynobj);
- if (! (*bed->elf_backend_adjust_dynamic_symbol) (eif->info, h))
- {
- eif->failed = true;
- return false;
- }
-
- return true;
-}
-
-/* Final phase of ELF linker. */
-
-/* A structure we use to avoid passing large numbers of arguments. */
-
-struct elf_final_link_info
-{
- /* General link information. */
- struct bfd_link_info *info;
- /* Output BFD. */
- bfd *output_bfd;
- /* Symbol string table. */
- struct bfd_strtab_hash *symstrtab;
- /* .dynsym section. */
- asection *dynsym_sec;
- /* .hash section. */
- asection *hash_sec;
- /* Buffer large enough to hold contents of any section. */
- bfd_byte *contents;
- /* Buffer large enough to hold external relocs of any section. */
- PTR external_relocs;
- /* Buffer large enough to hold internal relocs of any section. */
- Elf_Internal_Rela *internal_relocs;
- /* Buffer large enough to hold external local symbols of any input
- BFD. */
- Elf_External_Sym *external_syms;
- /* Buffer large enough to hold internal local symbols of any input
- BFD. */
- Elf_Internal_Sym *internal_syms;
- /* Array large enough to hold a symbol index for each local symbol
- of any input BFD. */
- long *indices;
- /* Array large enough to hold a section pointer for each local
- symbol of any input BFD. */
- asection **sections;
- /* Buffer to hold swapped out symbols. */
- Elf_External_Sym *symbuf;
- /* Number of swapped out symbols in buffer. */
- size_t symbuf_count;
- /* Number of symbols which fit in symbuf. */
- size_t symbuf_size;
-};
-
-static boolean elf_link_output_sym
- PARAMS ((struct elf_final_link_info *, const char *,
- Elf_Internal_Sym *, asection *));
-static boolean elf_link_flush_output_syms
- PARAMS ((struct elf_final_link_info *));
-static boolean elf_link_output_extsym
- PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean elf_link_input_bfd
- PARAMS ((struct elf_final_link_info *, bfd *));
-static boolean elf_reloc_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-
-/* This struct is used to pass information to routines called via
- elf_link_hash_traverse which must return failure. */
-
-struct elf_finfo_failed
-{
- boolean failed;
- struct elf_final_link_info *finfo;
-};
-
-/* Do the final step of an ELF link. */
-
-boolean
-elf_bfd_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- boolean dynamic;
- bfd *dynobj;
- struct elf_final_link_info finfo;
- register asection *o;
- register struct bfd_link_order *p;
- register bfd *sub;
- size_t max_contents_size;
- size_t max_external_reloc_size;
- size_t max_internal_reloc_count;
- size_t max_sym_count;
- file_ptr off;
- Elf_Internal_Sym elfsym;
- unsigned int i;
- Elf_Internal_Shdr *symtab_hdr;
- Elf_Internal_Shdr *symstrtab_hdr;
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
- struct elf_finfo_failed eif;
-
- if (info->shared)
- abfd->flags |= DYNAMIC;
-
- dynamic = elf_hash_table (info)->dynamic_sections_created;
- dynobj = elf_hash_table (info)->dynobj;
-
- finfo.info = info;
- finfo.output_bfd = abfd;
- finfo.symstrtab = elf_stringtab_init ();
- if (finfo.symstrtab == NULL)
- return false;
- if (! dynamic)
- {
- finfo.dynsym_sec = NULL;
- finfo.hash_sec = NULL;
- }
- else
- {
- finfo.dynsym_sec = bfd_get_section_by_name (dynobj, ".dynsym");
- finfo.hash_sec = bfd_get_section_by_name (dynobj, ".hash");
- BFD_ASSERT (finfo.dynsym_sec != NULL && finfo.hash_sec != NULL);
- }
- finfo.contents = NULL;
- finfo.external_relocs = NULL;
- finfo.internal_relocs = NULL;
- finfo.external_syms = NULL;
- finfo.internal_syms = NULL;
- finfo.indices = NULL;
- finfo.sections = NULL;
- finfo.symbuf = NULL;
- finfo.symbuf_count = 0;
-
- /* Count up the number of relocations we will output for each output
- section, so that we know the sizes of the reloc sections. We
- also figure out some maximum sizes. */
- max_contents_size = 0;
- max_external_reloc_size = 0;
- max_internal_reloc_count = 0;
- max_sym_count = 0;
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- o->reloc_count = 0;
-
- for (p = o->link_order_head; p != NULL; p = p->next)
- {
- if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- ++o->reloc_count;
- else if (p->type == bfd_indirect_link_order)
- {
- asection *sec;
-
- sec = p->u.indirect.section;
-
- if (info->relocateable)
- o->reloc_count += sec->reloc_count;
-
- if (sec->_raw_size > max_contents_size)
- max_contents_size = sec->_raw_size;
- if (sec->_cooked_size > max_contents_size)
- max_contents_size = sec->_cooked_size;
-
- /* We are interested in just local symbols, not all
- symbols. */
- if (bfd_get_flavour (sec->owner) == bfd_target_elf_flavour)
- {
- size_t sym_count;
-
- if (elf_bad_symtab (sec->owner))
- sym_count = (elf_tdata (sec->owner)->symtab_hdr.sh_size
- / sizeof (Elf_External_Sym));
- else
- sym_count = elf_tdata (sec->owner)->symtab_hdr.sh_info;
-
- if (sym_count > max_sym_count)
- max_sym_count = sym_count;
-
- if ((sec->flags & SEC_RELOC) != 0)
- {
- size_t ext_size;
-
- ext_size = elf_section_data (sec)->rel_hdr.sh_size;
- if (ext_size > max_external_reloc_size)
- max_external_reloc_size = ext_size;
- if (sec->reloc_count > max_internal_reloc_count)
- max_internal_reloc_count = sec->reloc_count;
- }
- }
- }
- }
-
- if (o->reloc_count > 0)
- o->flags |= SEC_RELOC;
- else
- {
- /* Explicitly clear the SEC_RELOC flag. The linker tends to
- set it (this is probably a bug) and if it is set
- assign_section_numbers will create a reloc section. */
- o->flags &=~ SEC_RELOC;
- }
-
- /* If the SEC_ALLOC flag is not set, force the section VMA to
- zero. This is done in elf_fake_sections as well, but forcing
- the VMA to 0 here will ensure that relocs against these
- sections are handled correctly. */
- if ((o->flags & SEC_ALLOC) == 0)
- o->vma = 0;
- }
-
- /* Figure out the file positions for everything but the symbol table
- and the relocs. We set symcount to force assign_section_numbers
- to create a symbol table. */
- abfd->symcount = info->strip == strip_all ? 0 : 1;
- BFD_ASSERT (! abfd->output_has_begun);
- if (! _bfd_elf_compute_section_file_positions (abfd, info))
- goto error_return;
-
- /* That created the reloc sections. Set their sizes, and assign
- them file positions, and allocate some buffers. */
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if ((o->flags & SEC_RELOC) != 0)
- {
- Elf_Internal_Shdr *rel_hdr;
- register struct elf_link_hash_entry **p, **pend;
-
- rel_hdr = &elf_section_data (o)->rel_hdr;
-
- rel_hdr->sh_size = rel_hdr->sh_entsize * o->reloc_count;
-
- /* The contents field must last into write_object_contents,
- so we allocate it with bfd_alloc rather than malloc. */
- rel_hdr->contents = (PTR) bfd_alloc (abfd, rel_hdr->sh_size);
- if (rel_hdr->contents == NULL && rel_hdr->sh_size != 0)
- goto error_return;
-
- p = ((struct elf_link_hash_entry **)
- bfd_malloc (o->reloc_count
- * sizeof (struct elf_link_hash_entry *)));
- if (p == NULL && o->reloc_count != 0)
- goto error_return;
- elf_section_data (o)->rel_hashes = p;
- pend = p + o->reloc_count;
- for (; p < pend; p++)
- *p = NULL;
-
- /* Use the reloc_count field as an index when outputting the
- relocs. */
- o->reloc_count = 0;
- }
- }
-
- _bfd_elf_assign_file_positions_for_relocs (abfd);
-
- /* We have now assigned file positions for all the sections except
- .symtab and .strtab. We start the .symtab section at the current
- file position, and write directly to it. We build the .strtab
- section in memory. */
- abfd->symcount = 0;
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- /* sh_name is set in prep_headers. */
- symtab_hdr->sh_type = SHT_SYMTAB;
- symtab_hdr->sh_flags = 0;
- symtab_hdr->sh_addr = 0;
- symtab_hdr->sh_size = 0;
- symtab_hdr->sh_entsize = sizeof (Elf_External_Sym);
- /* sh_link is set in assign_section_numbers. */
- /* sh_info is set below. */
- /* sh_offset is set just below. */
- symtab_hdr->sh_addralign = 4; /* FIXME: system dependent? */
-
- off = elf_tdata (abfd)->next_file_pos;
- off = _bfd_elf_assign_file_position_for_section (symtab_hdr, off, true);
-
- /* Note that at this point elf_tdata (abfd)->next_file_pos is
- incorrect. We do not yet know the size of the .symtab section.
- We correct next_file_pos below, after we do know the size. */
-
- /* Allocate a buffer to hold swapped out symbols. This is to avoid
- continuously seeking to the right position in the file. */
- if (! info->keep_memory || max_sym_count < 20)
- finfo.symbuf_size = 20;
- else
- finfo.symbuf_size = max_sym_count;
- finfo.symbuf = ((Elf_External_Sym *)
- bfd_malloc (finfo.symbuf_size * sizeof (Elf_External_Sym)));
- if (finfo.symbuf == NULL)
- goto error_return;
-
- /* Start writing out the symbol table. The first symbol is always a
- dummy symbol. */
- if (info->strip != strip_all || info->relocateable)
- {
- elfsym.st_value = 0;
- elfsym.st_size = 0;
- elfsym.st_info = 0;
- elfsym.st_other = 0;
- elfsym.st_shndx = SHN_UNDEF;
- if (! elf_link_output_sym (&finfo, (const char *) NULL,
- &elfsym, bfd_und_section_ptr))
- goto error_return;
- }
-
-#if 0
- /* Some standard ELF linkers do this, but we don't because it causes
- bootstrap comparison failures. */
- /* Output a file symbol for the output file as the second symbol.
- We output this even if we are discarding local symbols, although
- I'm not sure if this is correct. */
- elfsym.st_value = 0;
- elfsym.st_size = 0;
- elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
- elfsym.st_other = 0;
- elfsym.st_shndx = SHN_ABS;
- if (! elf_link_output_sym (&finfo, bfd_get_filename (abfd),
- &elfsym, bfd_abs_section_ptr))
- goto error_return;
-#endif
-
- /* Output a symbol for each section. We output these even if we are
- discarding local symbols, since they are used for relocs. These
- symbols have no names. We store the index of each one in the
- index field of the section, so that we can find it again when
- outputting relocs. */
- if (info->strip != strip_all || info->relocateable)
- {
- elfsym.st_value = 0;
- elfsym.st_size = 0;
- elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
- elfsym.st_other = 0;
- for (i = 1; i < elf_elfheader (abfd)->e_shnum; i++)
- {
- o = section_from_elf_index (abfd, i);
- if (o != NULL)
- o->target_index = abfd->symcount;
- elfsym.st_shndx = i;
- if (! elf_link_output_sym (&finfo, (const char *) NULL,
- &elfsym, o))
- goto error_return;
- }
- }
-
- /* Allocate some memory to hold information read in from the input
- files. */
- finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
- finfo.external_relocs = (PTR) bfd_malloc (max_external_reloc_size);
- finfo.internal_relocs = ((Elf_Internal_Rela *)
- bfd_malloc (max_internal_reloc_count
- * sizeof (Elf_Internal_Rela)));
- finfo.external_syms = ((Elf_External_Sym *)
- bfd_malloc (max_sym_count
- * sizeof (Elf_External_Sym)));
- finfo.internal_syms = ((Elf_Internal_Sym *)
- bfd_malloc (max_sym_count
- * sizeof (Elf_Internal_Sym)));
- finfo.indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
- finfo.sections = ((asection **)
- bfd_malloc (max_sym_count * sizeof (asection *)));
- if ((finfo.contents == NULL && max_contents_size != 0)
- || (finfo.external_relocs == NULL && max_external_reloc_size != 0)
- || (finfo.internal_relocs == NULL && max_internal_reloc_count != 0)
- || (finfo.external_syms == NULL && max_sym_count != 0)
- || (finfo.internal_syms == NULL && max_sym_count != 0)
- || (finfo.indices == NULL && max_sym_count != 0)
- || (finfo.sections == NULL && max_sym_count != 0))
- goto error_return;
-
- /* Since ELF permits relocations to be against local symbols, we
- must have the local symbols available when we do the relocations.
- Since we would rather only read the local symbols once, and we
- would rather not keep them in memory, we handle all the
- relocations for a single input file at the same time.
-
- Unfortunately, there is no way to know the total number of local
- symbols until we have seen all of them, and the local symbol
- indices precede the global symbol indices. This means that when
- we are generating relocateable output, and we see a reloc against
- a global symbol, we can not know the symbol index until we have
- finished examining all the local symbols to see which ones we are
- going to output. To deal with this, we keep the relocations in
- memory, and don't output them until the end of the link. This is
- an unfortunate waste of memory, but I don't see a good way around
- it. Fortunately, it only happens when performing a relocateable
- link, which is not the common case. FIXME: If keep_memory is set
- we could write the relocs out and then read them again; I don't
- know how bad the memory loss will be. */
-
- for (sub = info->input_bfds; sub != NULL; sub = sub->next)
- sub->output_has_begun = false;
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- for (p = o->link_order_head; p != NULL; p = p->next)
- {
- if (p->type == bfd_indirect_link_order
- && (bfd_get_flavour (p->u.indirect.section->owner)
- == bfd_target_elf_flavour))
- {
- sub = p->u.indirect.section->owner;
- if (! sub->output_has_begun)
- {
- if (! elf_link_input_bfd (&finfo, sub))
- goto error_return;
- sub->output_has_begun = true;
- }
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- if (! elf_reloc_link_order (abfd, info, o, p))
- goto error_return;
- }
- else
- {
- if (! _bfd_default_link_order (abfd, info, o, p))
- goto error_return;
- }
- }
- }
-
- /* That wrote out all the local symbols. Finish up the symbol table
- with the global symbols. */
-
- /* The sh_info field records the index of the first non local
- symbol. */
- symtab_hdr->sh_info = abfd->symcount;
- if (dynamic)
- elf_section_data (finfo.dynsym_sec->output_section)->this_hdr.sh_info = 1;
-
- /* We get the global symbols from the hash table. */
- eif.failed = false;
- eif.finfo = &finfo;
- elf_link_hash_traverse (elf_hash_table (info), elf_link_output_extsym,
- (PTR) &eif);
- if (eif.failed)
- return false;
-
- /* Flush all symbols to the file. */
- if (! elf_link_flush_output_syms (&finfo))
- return false;
-
- /* Now we know the size of the symtab section. */
- off += symtab_hdr->sh_size;
-
- /* Finish up and write out the symbol string table (.strtab)
- section. */
- symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
- /* sh_name was set in prep_headers. */
- symstrtab_hdr->sh_type = SHT_STRTAB;
- symstrtab_hdr->sh_flags = 0;
- symstrtab_hdr->sh_addr = 0;
- symstrtab_hdr->sh_size = _bfd_stringtab_size (finfo.symstrtab);
- symstrtab_hdr->sh_entsize = 0;
- symstrtab_hdr->sh_link = 0;
- symstrtab_hdr->sh_info = 0;
- /* sh_offset is set just below. */
- symstrtab_hdr->sh_addralign = 1;
-
- off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, off, true);
- elf_tdata (abfd)->next_file_pos = off;
-
- if (abfd->symcount > 0)
- {
- if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0
- || ! _bfd_stringtab_emit (abfd, finfo.symstrtab))
- return false;
- }
-
- /* Adjust the relocs to have the correct symbol indices. */
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- struct elf_link_hash_entry **rel_hash;
- Elf_Internal_Shdr *rel_hdr;
-
- if ((o->flags & SEC_RELOC) == 0)
- continue;
-
- rel_hash = elf_section_data (o)->rel_hashes;
- rel_hdr = &elf_section_data (o)->rel_hdr;
- for (i = 0; i < o->reloc_count; i++, rel_hash++)
- {
- if (*rel_hash == NULL)
- continue;
-
- BFD_ASSERT ((*rel_hash)->indx >= 0);
-
- if (rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
- {
- Elf_External_Rel *erel;
- Elf_Internal_Rel irel;
-
- erel = (Elf_External_Rel *) rel_hdr->contents + i;
- elf_swap_reloc_in (abfd, erel, &irel);
- irel.r_info = ELF_R_INFO ((*rel_hash)->indx,
- ELF_R_TYPE (irel.r_info));
- elf_swap_reloc_out (abfd, &irel, erel);
- }
- else
- {
- Elf_External_Rela *erela;
- Elf_Internal_Rela irela;
-
- BFD_ASSERT (rel_hdr->sh_entsize
- == sizeof (Elf_External_Rela));
-
- erela = (Elf_External_Rela *) rel_hdr->contents + i;
- elf_swap_reloca_in (abfd, erela, &irela);
- irela.r_info = ELF_R_INFO ((*rel_hash)->indx,
- ELF_R_TYPE (irela.r_info));
- elf_swap_reloca_out (abfd, &irela, erela);
- }
- }
-
- /* Set the reloc_count field to 0 to prevent write_relocs from
- trying to swap the relocs out itself. */
- o->reloc_count = 0;
- }
-
- /* If we are linking against a dynamic object, or generating a
- shared library, finish up the dynamic linking information. */
- if (dynamic)
- {
- Elf_External_Dyn *dyncon, *dynconend;
-
- /* Fix up .dynamic entries. */
- o = bfd_get_section_by_name (dynobj, ".dynamic");
- BFD_ASSERT (o != NULL);
-
- dyncon = (Elf_External_Dyn *) o->contents;
- dynconend = (Elf_External_Dyn *) (o->contents + o->_raw_size);
- for (; dyncon < dynconend; dyncon++)
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- unsigned int type;
-
- elf_swap_dyn_in (dynobj, dyncon, &dyn);
-
- switch (dyn.d_tag)
- {
- default:
- break;
-
- /* SVR4 linkers seem to set DT_INIT and DT_FINI based on
- magic _init and _fini symbols. This is pretty ugly,
- but we are compatible. */
- case DT_INIT:
- name = "_init";
- goto get_sym;
- case DT_FINI:
- name = "_fini";
- get_sym:
- {
- struct elf_link_hash_entry *h;
-
- h = elf_link_hash_lookup (elf_hash_table (info), name,
- false, false, true);
- if (h != NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- dyn.d_un.d_val = h->root.u.def.value;
- o = h->root.u.def.section;
- if (o->output_section != NULL)
- dyn.d_un.d_val += (o->output_section->vma
- + o->output_offset);
- else
- {
- /* The symbol is imported from another shared
- library and does not apply to this one. */
- dyn.d_un.d_val = 0;
- }
-
- elf_swap_dyn_out (dynobj, &dyn, dyncon);
- }
- }
- break;
-
- case DT_HASH:
- name = ".hash";
- goto get_vma;
- case DT_STRTAB:
- name = ".dynstr";
- goto get_vma;
- case DT_SYMTAB:
- name = ".dynsym";
- get_vma:
- o = bfd_get_section_by_name (abfd, name);
- BFD_ASSERT (o != NULL);
- dyn.d_un.d_ptr = o->vma;
- elf_swap_dyn_out (dynobj, &dyn, dyncon);
- break;
-
- case DT_REL:
- case DT_RELA:
- case DT_RELSZ:
- case DT_RELASZ:
- if (dyn.d_tag == DT_REL || dyn.d_tag == DT_RELSZ)
- type = SHT_REL;
- else
- type = SHT_RELA;
- dyn.d_un.d_val = 0;
- for (i = 1; i < elf_elfheader (abfd)->e_shnum; i++)
- {
- Elf_Internal_Shdr *hdr;
-
- hdr = elf_elfsections (abfd)[i];
- if (hdr->sh_type == type
- && (hdr->sh_flags & SHF_ALLOC) != 0)
- {
- if (dyn.d_tag == DT_RELSZ || dyn.d_tag == DT_RELASZ)
- dyn.d_un.d_val += hdr->sh_size;
- else
- {
- if (dyn.d_un.d_val == 0
- || hdr->sh_addr < dyn.d_un.d_val)
- dyn.d_un.d_val = hdr->sh_addr;
- }
- }
- }
- elf_swap_dyn_out (dynobj, &dyn, dyncon);
- break;
- }
- }
- }
-
- /* If we have created any dynamic sections, then output them. */
- if (dynobj != NULL)
- {
- if (! (*bed->elf_backend_finish_dynamic_sections) (abfd, info))
- goto error_return;
-
- for (o = dynobj->sections; o != NULL; o = o->next)
- {
- if ((o->flags & SEC_HAS_CONTENTS) == 0
- || o->_raw_size == 0)
- continue;
- if ((o->flags & SEC_IN_MEMORY) == 0)
- {
- /* At this point, we are only interested in sections
- created by elf_link_create_dynamic_sections. FIXME:
- This test is fragile. */
- continue;
- }
- if ((elf_section_data (o->output_section)->this_hdr.sh_type
- != SHT_STRTAB)
- || strcmp (bfd_get_section_name (abfd, o), ".dynstr") != 0)
- {
- if (! bfd_set_section_contents (abfd, o->output_section,
- o->contents, o->output_offset,
- o->_raw_size))
- goto error_return;
- }
- else
- {
- file_ptr off;
-
- /* The contents of the .dynstr section are actually in a
- stringtab. */
- off = elf_section_data (o->output_section)->this_hdr.sh_offset;
- if (bfd_seek (abfd, off, SEEK_SET) != 0
- || ! _bfd_stringtab_emit (abfd,
- elf_hash_table (info)->dynstr))
- goto error_return;
- }
- }
- }
-
- if (finfo.symstrtab != NULL)
- _bfd_stringtab_free (finfo.symstrtab);
- if (finfo.contents != NULL)
- free (finfo.contents);
- if (finfo.external_relocs != NULL)
- free (finfo.external_relocs);
- if (finfo.internal_relocs != NULL)
- free (finfo.internal_relocs);
- if (finfo.external_syms != NULL)
- free (finfo.external_syms);
- if (finfo.internal_syms != NULL)
- free (finfo.internal_syms);
- if (finfo.indices != NULL)
- free (finfo.indices);
- if (finfo.sections != NULL)
- free (finfo.sections);
- if (finfo.symbuf != NULL)
- free (finfo.symbuf);
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if ((o->flags & SEC_RELOC) != 0
- && elf_section_data (o)->rel_hashes != NULL)
- free (elf_section_data (o)->rel_hashes);
- }
-
- elf_tdata (abfd)->linker = true;
-
- return true;
-
- error_return:
- if (finfo.symstrtab != NULL)
- _bfd_stringtab_free (finfo.symstrtab);
- if (finfo.contents != NULL)
- free (finfo.contents);
- if (finfo.external_relocs != NULL)
- free (finfo.external_relocs);
- if (finfo.internal_relocs != NULL)
- free (finfo.internal_relocs);
- if (finfo.external_syms != NULL)
- free (finfo.external_syms);
- if (finfo.internal_syms != NULL)
- free (finfo.internal_syms);
- if (finfo.indices != NULL)
- free (finfo.indices);
- if (finfo.sections != NULL)
- free (finfo.sections);
- if (finfo.symbuf != NULL)
- free (finfo.symbuf);
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if ((o->flags & SEC_RELOC) != 0
- && elf_section_data (o)->rel_hashes != NULL)
- free (elf_section_data (o)->rel_hashes);
- }
-
- return false;
-}
-
-/* Add a symbol to the output symbol table. */
-
-static boolean
-elf_link_output_sym (finfo, name, elfsym, input_sec)
- struct elf_final_link_info *finfo;
- const char *name;
- Elf_Internal_Sym *elfsym;
- asection *input_sec;
-{
- boolean (*output_symbol_hook) PARAMS ((bfd *,
- struct bfd_link_info *info,
- const char *,
- Elf_Internal_Sym *,
- asection *));
-
- output_symbol_hook = get_elf_backend_data (finfo->output_bfd)->
- elf_backend_link_output_symbol_hook;
- if (output_symbol_hook != NULL)
- {
- if (! ((*output_symbol_hook)
- (finfo->output_bfd, finfo->info, name, elfsym, input_sec)))
- return false;
- }
-
- if (name == (const char *) NULL || *name == '\0')
- elfsym->st_name = 0;
- else
- {
- elfsym->st_name = (unsigned long) _bfd_stringtab_add (finfo->symstrtab,
- name, true,
- false);
- if (elfsym->st_name == (unsigned long) -1)
- return false;
- }
-
- if (finfo->symbuf_count >= finfo->symbuf_size)
- {
- if (! elf_link_flush_output_syms (finfo))
- return false;
- }
-
- elf_swap_symbol_out (finfo->output_bfd, elfsym,
- (PTR) (finfo->symbuf + finfo->symbuf_count));
- ++finfo->symbuf_count;
-
- ++finfo->output_bfd->symcount;
-
- return true;
-}
-
-/* Flush the output symbols to the file. */
-
-static boolean
-elf_link_flush_output_syms (finfo)
- struct elf_final_link_info *finfo;
-{
- if (finfo->symbuf_count > 0)
- {
- Elf_Internal_Shdr *symtab;
-
- symtab = &elf_tdata (finfo->output_bfd)->symtab_hdr;
-
- if (bfd_seek (finfo->output_bfd, symtab->sh_offset + symtab->sh_size,
- SEEK_SET) != 0
- || (bfd_write ((PTR) finfo->symbuf, finfo->symbuf_count,
- sizeof (Elf_External_Sym), finfo->output_bfd)
- != finfo->symbuf_count * sizeof (Elf_External_Sym)))
- return false;
-
- symtab->sh_size += finfo->symbuf_count * sizeof (Elf_External_Sym);
-
- finfo->symbuf_count = 0;
- }
-
- return true;
-}
-
-/* Add an external symbol to the symbol table. This is called from
- the hash table traversal routine. */
-
-static boolean
-elf_link_output_extsym (h, data)
- struct elf_link_hash_entry *h;
- PTR data;
-{
- struct elf_finfo_failed *eif = (struct elf_finfo_failed *) data;
- struct elf_final_link_info *finfo = eif->finfo;
- boolean strip;
- Elf_Internal_Sym sym;
- asection *input_sec;
-
- /* If we are not creating a shared library, and this symbol is
- referenced by a shared library but is not defined anywhere, then
- warn that it is undefined. If we do not do this, the runtime
- linker will complain that the symbol is undefined when the
- program is run. We don't have to worry about symbols that are
- referenced by regular files, because we will already have issued
- warnings for them. */
- if (! finfo->info->relocateable
- && ! finfo->info->shared
- && h->root.type == bfd_link_hash_undefined
- && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0
- && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
- {
- if (! ((*finfo->info->callbacks->undefined_symbol)
- (finfo->info, h->root.root.string, h->root.u.undef.abfd,
- (asection *) NULL, 0)))
- {
- eif->failed = true;
- return false;
- }
- }
-
- /* We don't want to output symbols that have never been mentioned by
- a regular file, or that we have been told to strip. However, if
- h->indx is set to -2, the symbol is used by a reloc and we must
- output it. */
- if (h->indx == -2)
- strip = false;
- else if (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- || (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0)
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
- && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0)
- strip = true;
- else if (finfo->info->strip == strip_all
- || (finfo->info->strip == strip_some
- && bfd_hash_lookup (finfo->info->keep_hash,
- h->root.root.string,
- false, false) == NULL))
- strip = true;
- else
- strip = false;
-
- /* If we're stripping it, and it's not a dynamic symbol, there's
- nothing else to do. */
- if (strip && h->dynindx == -1)
- return true;
-
- sym.st_value = 0;
- sym.st_size = h->size;
- sym.st_other = 0;
- if (h->root.type == bfd_link_hash_undefweak
- || h->root.type == bfd_link_hash_defweak)
- sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
- else
- sym.st_info = ELF_ST_INFO (STB_GLOBAL, h->type);
-
- switch (h->root.type)
- {
- default:
- case bfd_link_hash_new:
- abort ();
- return false;
-
- case bfd_link_hash_undefined:
- input_sec = bfd_und_section_ptr;
- sym.st_shndx = SHN_UNDEF;
- break;
-
- case bfd_link_hash_undefweak:
- input_sec = bfd_und_section_ptr;
- sym.st_shndx = SHN_UNDEF;
- break;
-
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- {
- input_sec = h->root.u.def.section;
- if (input_sec->output_section != NULL)
- {
- sym.st_shndx =
- _bfd_elf_section_from_bfd_section (finfo->output_bfd,
- input_sec->output_section);
- if (sym.st_shndx == (unsigned short) -1)
- {
- eif->failed = true;
- return false;
- }
-
- /* ELF symbols in relocateable files are section relative,
- but in nonrelocateable files they are virtual
- addresses. */
- sym.st_value = h->root.u.def.value + input_sec->output_offset;
- if (! finfo->info->relocateable)
- sym.st_value += input_sec->output_section->vma;
- }
- else
- {
- BFD_ASSERT ((bfd_get_flavour (input_sec->owner)
- == bfd_target_elf_flavour)
- && elf_elfheader (input_sec->owner)->e_type == ET_DYN);
- sym.st_shndx = SHN_UNDEF;
- input_sec = bfd_und_section_ptr;
- }
- }
- break;
-
- case bfd_link_hash_common:
- input_sec = bfd_com_section_ptr;
- sym.st_shndx = SHN_COMMON;
- sym.st_value = 1 << h->root.u.c.p->alignment_power;
- break;
-
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* We can't represent these symbols in ELF. A warning symbol
- may have come from a .gnu.warning.SYMBOL section anyhow. We
- just put the target symbol in the hash table. If the target
- symbol does not really exist, don't do anything. */
- if (h->root.u.i.link->type == bfd_link_hash_new)
- return true;
- return (elf_link_output_extsym
- ((struct elf_link_hash_entry *) h->root.u.i.link, data));
- }
-
- /* If this symbol should be put in the .dynsym section, then put it
- there now. We have already know the symbol index. We also fill
- in the entry in the .hash section. */
- if (h->dynindx != -1
- && elf_hash_table (finfo->info)->dynamic_sections_created)
- {
- struct elf_backend_data *bed;
- size_t bucketcount;
- size_t bucket;
- bfd_byte *bucketpos;
- bfd_vma chain;
-
- sym.st_name = h->dynstr_index;
-
- /* Give the processor backend a chance to tweak the symbol
- value, and also to finish up anything that needs to be done
- for this symbol. */
- bed = get_elf_backend_data (finfo->output_bfd);
- if (! ((*bed->elf_backend_finish_dynamic_symbol)
- (finfo->output_bfd, finfo->info, h, &sym)))
- {
- eif->failed = true;
- return false;
- }
-
- elf_swap_symbol_out (finfo->output_bfd, &sym,
- (PTR) (((Elf_External_Sym *)
- finfo->dynsym_sec->contents)
- + h->dynindx));
-
- bucketcount = elf_hash_table (finfo->info)->bucketcount;
- bucket = (bfd_elf_hash ((const unsigned char *) h->root.root.string)
- % bucketcount);
- bucketpos = ((bfd_byte *) finfo->hash_sec->contents
- + (bucket + 2) * (ARCH_SIZE / 8));
- chain = get_word (finfo->output_bfd, bucketpos);
- put_word (finfo->output_bfd, h->dynindx, bucketpos);
- put_word (finfo->output_bfd, chain,
- ((bfd_byte *) finfo->hash_sec->contents
- + (bucketcount + 2 + h->dynindx) * (ARCH_SIZE / 8)));
- }
-
- /* If we're stripping it, then it was just a dynamic symbol, and
- there's nothing else to do. */
- if (strip)
- return true;
-
- h->indx = finfo->output_bfd->symcount;
-
- if (! elf_link_output_sym (finfo, h->root.root.string, &sym, input_sec))
- {
- eif->failed = true;
- return false;
- }
-
- return true;
-}
-
-/* Link an input file into the linker output file. This function
- handles all the sections and relocations of the input file at once.
- This is so that we only have to read the local symbols once, and
- don't have to keep them in memory. */
-
-static boolean
-elf_link_input_bfd (finfo, input_bfd)
- struct elf_final_link_info *finfo;
- bfd *input_bfd;
-{
- boolean (*relocate_section) PARAMS ((bfd *, struct bfd_link_info *,
- bfd *, asection *, bfd_byte *,
- Elf_Internal_Rela *,
- Elf_Internal_Sym *, asection **));
- bfd *output_bfd;
- Elf_Internal_Shdr *symtab_hdr;
- size_t locsymcount;
- size_t extsymoff;
- Elf_External_Sym *esym;
- Elf_External_Sym *esymend;
- Elf_Internal_Sym *isym;
- long *pindex;
- asection **ppsection;
- asection *o;
-
- output_bfd = finfo->output_bfd;
- relocate_section =
- get_elf_backend_data (output_bfd)->elf_backend_relocate_section;
-
- /* If this is a dynamic object, we don't want to do anything here:
- we don't want the local symbols, and we don't want the section
- contents. */
- if (elf_elfheader (input_bfd)->e_type == ET_DYN)
- return true;
-
- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- if (elf_bad_symtab (input_bfd))
- {
- locsymcount = symtab_hdr->sh_size / sizeof (Elf_External_Sym);
- extsymoff = 0;
- }
- else
- {
- locsymcount = symtab_hdr->sh_info;
- extsymoff = symtab_hdr->sh_info;
- }
-
- /* Read the local symbols. */
- if (locsymcount > 0
- && (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (finfo->external_syms, sizeof (Elf_External_Sym),
- locsymcount, input_bfd)
- != locsymcount * sizeof (Elf_External_Sym))))
- return false;
-
- /* Swap in the local symbols and write out the ones which we know
- are going into the output file. */
- esym = finfo->external_syms;
- esymend = esym + locsymcount;
- isym = finfo->internal_syms;
- pindex = finfo->indices;
- ppsection = finfo->sections;
- for (; esym < esymend; esym++, isym++, pindex++, ppsection++)
- {
- asection *isec;
- const char *name;
- Elf_Internal_Sym osym;
-
- elf_swap_symbol_in (input_bfd, esym, isym);
- *pindex = -1;
-
- if (elf_bad_symtab (input_bfd))
- {
- if (ELF_ST_BIND (isym->st_info) != STB_LOCAL)
- {
- *ppsection = NULL;
- continue;
- }
- }
-
- if (isym->st_shndx == SHN_UNDEF)
- isec = bfd_und_section_ptr;
- else if (isym->st_shndx > 0 && isym->st_shndx < SHN_LORESERVE)
- isec = section_from_elf_index (input_bfd, isym->st_shndx);
- else if (isym->st_shndx == SHN_ABS)
- isec = bfd_abs_section_ptr;
- else if (isym->st_shndx == SHN_COMMON)
- isec = bfd_com_section_ptr;
- else
- {
- /* Who knows? */
- isec = NULL;
- }
-
- *ppsection = isec;
-
- /* Don't output the first, undefined, symbol. */
- if (esym == finfo->external_syms)
- continue;
-
- /* If we are stripping all symbols, we don't want to output this
- one. */
- if (finfo->info->strip == strip_all)
- continue;
-
- /* We never output section symbols. Instead, we use the section
- symbol of the corresponding section in the output file. */
- if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
- continue;
-
- /* If we are discarding all local symbols, we don't want to
- output this one. If we are generating a relocateable output
- file, then some of the local symbols may be required by
- relocs; we output them below as we discover that they are
- needed. */
- if (finfo->info->discard == discard_all)
- continue;
-
- /* Get the name of the symbol. */
- name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link,
- isym->st_name);
- if (name == NULL)
- return false;
-
- /* See if we are discarding symbols with this name. */
- if ((finfo->info->strip == strip_some
- && (bfd_hash_lookup (finfo->info->keep_hash, name, false, false)
- == NULL))
- || (finfo->info->discard == discard_l
- && strncmp (name, finfo->info->lprefix,
- finfo->info->lprefix_len) == 0))
- continue;
-
- /* If we get here, we are going to output this symbol. */
-
- osym = *isym;
-
- /* Adjust the section index for the output file. */
- osym.st_shndx = _bfd_elf_section_from_bfd_section (output_bfd,
- isec->output_section);
- if (osym.st_shndx == (unsigned short) -1)
- return false;
-
- *pindex = output_bfd->symcount;
-
- /* ELF symbols in relocateable files are section relative, but
- in executable files they are virtual addresses. Note that
- this code assumes that all ELF sections have an associated
- BFD section with a reasonable value for output_offset; below
- we assume that they also have a reasonable value for
- output_section. Any special sections must be set up to meet
- these requirements. */
- osym.st_value += isec->output_offset;
- if (! finfo->info->relocateable)
- osym.st_value += isec->output_section->vma;
-
- if (! elf_link_output_sym (finfo, name, &osym, isec))
- return false;
- }
-
- /* Relocate the contents of each section. */
- for (o = input_bfd->sections; o != NULL; o = o->next)
- {
- if ((o->flags & SEC_HAS_CONTENTS) == 0)
- continue;
-
- if ((o->flags & SEC_IN_MEMORY) != 0
- && input_bfd == elf_hash_table (finfo->info)->dynobj)
- {
- /* Section was created by elf_link_create_dynamic_sections.
- FIXME: This test is fragile. */
- continue;
- }
-
- /* Read the contents of the section. */
- if (! bfd_get_section_contents (input_bfd, o, finfo->contents,
- (file_ptr) 0, o->_raw_size))
- return false;
-
- if ((o->flags & SEC_RELOC) != 0)
- {
- Elf_Internal_Rela *internal_relocs;
-
- /* Get the swapped relocs. */
- internal_relocs = elf_link_read_relocs (input_bfd, o,
- finfo->external_relocs,
- finfo->internal_relocs,
- false);
- if (internal_relocs == NULL
- && o->reloc_count > 0)
- return false;
-
- /* Relocate the section by invoking a back end routine.
-
- The back end routine is responsible for adjusting the
- section contents as necessary, and (if using Rela relocs
- and generating a relocateable output file) adjusting the
- reloc addend as necessary.
-
- The back end routine does not have to worry about setting
- the reloc address or the reloc symbol index.
-
- The back end routine is given a pointer to the swapped in
- internal symbols, and can access the hash table entries
- for the external symbols via elf_sym_hashes (input_bfd).
-
- When generating relocateable output, the back end routine
- must handle STB_LOCAL/STT_SECTION symbols specially. The
- output symbol is going to be a section symbol
- corresponding to the output section, which will require
- the addend to be adjusted. */
-
- if (! (*relocate_section) (output_bfd, finfo->info,
- input_bfd, o,
- finfo->contents,
- internal_relocs,
- finfo->internal_syms,
- finfo->sections))
- return false;
-
- if (finfo->info->relocateable)
- {
- Elf_Internal_Rela *irela;
- Elf_Internal_Rela *irelaend;
- struct elf_link_hash_entry **rel_hash;
- Elf_Internal_Shdr *input_rel_hdr;
- Elf_Internal_Shdr *output_rel_hdr;
-
- /* Adjust the reloc addresses and symbol indices. */
-
- irela = internal_relocs;
- irelaend = irela + o->reloc_count;
- rel_hash = (elf_section_data (o->output_section)->rel_hashes
- + o->output_section->reloc_count);
- for (; irela < irelaend; irela++, rel_hash++)
- {
- unsigned long r_symndx;
- Elf_Internal_Sym *isym;
- asection *sec;
-
- irela->r_offset += o->output_offset;
-
- r_symndx = ELF_R_SYM (irela->r_info);
-
- if (r_symndx == 0)
- continue;
-
- if (r_symndx >= locsymcount
- || (elf_bad_symtab (input_bfd)
- && finfo->sections[r_symndx] == NULL))
- {
- long indx;
-
- /* This is a reloc against a global symbol. We
- have not yet output all the local symbols, so
- we do not know the symbol index of any global
- symbol. We set the rel_hash entry for this
- reloc to point to the global hash table entry
- for this symbol. The symbol index is then
- set at the end of elf_bfd_final_link. */
- indx = r_symndx - extsymoff;
- *rel_hash = elf_sym_hashes (input_bfd)[indx];
-
- /* Setting the index to -2 tells
- elf_link_output_extsym that this symbol is
- used by a reloc. */
- BFD_ASSERT ((*rel_hash)->indx < 0);
- (*rel_hash)->indx = -2;
-
- continue;
- }
-
- /* This is a reloc against a local symbol. */
-
- *rel_hash = NULL;
- isym = finfo->internal_syms + r_symndx;
- sec = finfo->sections[r_symndx];
- if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
- {
- /* I suppose the backend ought to fill in the
- section of any STT_SECTION symbol against a
- processor specific section. */
- if (sec != NULL && bfd_is_abs_section (sec))
- r_symndx = 0;
- else if (sec == NULL || sec->owner == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- else
- {
- r_symndx = sec->output_section->target_index;
- BFD_ASSERT (r_symndx != 0);
- }
- }
- else
- {
- if (finfo->indices[r_symndx] == -1)
- {
- unsigned long link;
- const char *name;
- asection *osec;
-
- if (finfo->info->strip == strip_all)
- {
- /* You can't do ld -r -s. */
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- /* This symbol was skipped earlier, but
- since it is needed by a reloc, we
- must output it now. */
- link = symtab_hdr->sh_link;
- name = bfd_elf_string_from_elf_section (input_bfd,
- link,
- isym->st_name);
- if (name == NULL)
- return false;
-
- osec = sec->output_section;
- isym->st_shndx =
- _bfd_elf_section_from_bfd_section (output_bfd,
- osec);
- if (isym->st_shndx == (unsigned short) -1)
- return false;
-
- isym->st_value += sec->output_offset;
- if (! finfo->info->relocateable)
- isym->st_value += osec->vma;
-
- finfo->indices[r_symndx] = output_bfd->symcount;
-
- if (! elf_link_output_sym (finfo, name, isym, sec))
- return false;
- }
-
- r_symndx = finfo->indices[r_symndx];
- }
-
- irela->r_info = ELF_R_INFO (r_symndx,
- ELF_R_TYPE (irela->r_info));
- }
-
- /* Swap out the relocs. */
- input_rel_hdr = &elf_section_data (o)->rel_hdr;
- output_rel_hdr = &elf_section_data (o->output_section)->rel_hdr;
- BFD_ASSERT (output_rel_hdr->sh_entsize
- == input_rel_hdr->sh_entsize);
- irela = internal_relocs;
- irelaend = irela + o->reloc_count;
- if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
- {
- Elf_External_Rel *erel;
-
- erel = ((Elf_External_Rel *) output_rel_hdr->contents
- + o->output_section->reloc_count);
- for (; irela < irelaend; irela++, erel++)
- {
- Elf_Internal_Rel irel;
-
- irel.r_offset = irela->r_offset;
- irel.r_info = irela->r_info;
- BFD_ASSERT (irela->r_addend == 0);
- elf_swap_reloc_out (output_bfd, &irel, erel);
- }
- }
- else
- {
- Elf_External_Rela *erela;
-
- BFD_ASSERT (input_rel_hdr->sh_entsize
- == sizeof (Elf_External_Rela));
- erela = ((Elf_External_Rela *) output_rel_hdr->contents
- + o->output_section->reloc_count);
- for (; irela < irelaend; irela++, erela++)
- elf_swap_reloca_out (output_bfd, irela, erela);
- }
-
- o->output_section->reloc_count += o->reloc_count;
- }
- }
-
- /* Write out the modified section contents. */
- if (! bfd_set_section_contents (output_bfd, o->output_section,
- finfo->contents, o->output_offset,
- (o->_cooked_size != 0
- ? o->_cooked_size
- : o->_raw_size)))
- return false;
- }
-
- return true;
-}
-
-/* Generate a reloc when linking an ELF file. This is a reloc
- requested by the linker, and does come from any input file. This
- is used to build constructor and destructor tables when linking
- with -Ur. */
-
-static boolean
-elf_reloc_link_order (output_bfd, info, output_section, link_order)
- bfd *output_bfd;
- struct bfd_link_info *info;
- asection *output_section;
- struct bfd_link_order *link_order;
-{
- reloc_howto_type *howto;
- long indx;
- bfd_vma offset;
- bfd_vma addend;
- struct elf_link_hash_entry **rel_hash_ptr;
- Elf_Internal_Shdr *rel_hdr;
-
- howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
- if (howto == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- addend = link_order->u.reloc.p->addend;
-
- /* Figure out the symbol index. */
- rel_hash_ptr = (elf_section_data (output_section)->rel_hashes
- + output_section->reloc_count);
- if (link_order->type == bfd_section_reloc_link_order)
- {
- indx = link_order->u.reloc.p->u.section->target_index;
- BFD_ASSERT (indx != 0);
- *rel_hash_ptr = NULL;
- }
- else
- {
- struct elf_link_hash_entry *h;
-
- /* Treat a reloc against a defined symbol as though it were
- actually against the section. */
- h = ((struct elf_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (output_bfd, info,
- link_order->u.reloc.p->u.name,
- false, false, true));
- if (h != NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- {
- asection *section;
-
- section = h->root.u.def.section;
- indx = section->output_section->target_index;
- *rel_hash_ptr = NULL;
- /* It seems that we ought to add the symbol value to the
- addend here, but in practice it has already been added
- because it was passed to constructor_callback. */
- addend += section->output_section->vma + section->output_offset;
- }
- else if (h != NULL)
- {
- /* Setting the index to -2 tells elf_link_output_extsym that
- this symbol is used by a reloc. */
- h->indx = -2;
- *rel_hash_ptr = h;
- indx = 0;
- }
- else
- {
- if (! ((*info->callbacks->unattached_reloc)
- (info, link_order->u.reloc.p->u.name, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- return false;
- indx = 0;
- }
- }
-
- /* If this is an inplace reloc, we must write the addend into the
- object file. */
- if (howto->partial_inplace && addend != 0)
- {
- bfd_size_type size;
- bfd_reloc_status_type rstat;
- bfd_byte *buf;
- boolean ok;
-
- size = bfd_get_reloc_size (howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == (bfd_byte *) NULL)
- return false;
- rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
- switch (rstat)
- {
- case bfd_reloc_ok:
- break;
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- if (! ((*info->callbacks->reloc_overflow)
- (info,
- (link_order->type == bfd_section_reloc_link_order
- ? bfd_section_name (output_bfd,
- link_order->u.reloc.p->u.section)
- : link_order->u.reloc.p->u.name),
- howto->name, addend, (bfd *) NULL, (asection *) NULL,
- (bfd_vma) 0)))
- {
- free (buf);
- return false;
- }
- break;
- }
- ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
- (file_ptr) link_order->offset, size);
- free (buf);
- if (! ok)
- return false;
- }
-
- /* The address of a reloc is relative to the section in a
- relocateable file, and is a virtual address in an executable
- file. */
- offset = link_order->offset;
- if (! info->relocateable)
- offset += output_section->vma;
-
- rel_hdr = &elf_section_data (output_section)->rel_hdr;
-
- if (rel_hdr->sh_type == SHT_REL)
- {
- Elf_Internal_Rel irel;
- Elf_External_Rel *erel;
-
- irel.r_offset = offset;
- irel.r_info = ELF_R_INFO (indx, howto->type);
- erel = ((Elf_External_Rel *) rel_hdr->contents
- + output_section->reloc_count);
- elf_swap_reloc_out (output_bfd, &irel, erel);
- }
- else
- {
- Elf_Internal_Rela irela;
- Elf_External_Rela *erela;
-
- irela.r_offset = offset;
- irela.r_info = ELF_R_INFO (indx, howto->type);
- irela.r_addend = addend;
- erela = ((Elf_External_Rela *) rel_hdr->contents
- + output_section->reloc_count);
- elf_swap_reloca_out (output_bfd, &irela, erela);
- }
-
- ++output_section->reloc_count;
-
- return true;
-}
-
-
-/* Allocate a pointer to live in a linker created section. */
-
-boolean
-elf_create_pointer_linker_section (abfd, info, lsect, h, rel)
- bfd *abfd;
- struct bfd_link_info *info;
- elf_linker_section_t *lsect;
- struct elf_link_hash_entry *h;
- const Elf_Internal_Rela *rel;
-{
- elf_linker_section_pointers_t **ptr_linker_section_ptr = NULL;
- elf_linker_section_pointers_t *linker_section_ptr;
- unsigned long r_symndx = ELF_R_SYM (rel->r_info);;
-
- BFD_ASSERT (lsect != NULL);
-
- /* Is this a global symbol? */
- if (h != NULL)
- {
- /* Has this symbol already been allocated, if so, our work is done */
- if (_bfd_elf_find_pointer_linker_section (h->linker_section_pointer,
- rel->r_addend,
- lsect->which))
- return true;
-
- ptr_linker_section_ptr = &h->linker_section_pointer;
- /* Make sure this symbol is output as a dynamic symbol. */
- if (h->dynindx == -1)
- {
- if (! elf_link_record_dynamic_symbol (info, h))
- return false;
- }
-
- if (lsect->rel_section)
- lsect->rel_section->_raw_size += sizeof (Elf_External_Rela);
- }
-
- else /* Allocation of a pointer to a local symbol */
- {
- elf_linker_section_pointers_t **ptr = elf_local_ptr_offsets (abfd);
-
- /* Allocate a table to hold the local symbols if first time */
- if (!ptr)
- {
- int num_symbols = elf_tdata (abfd)->symtab_hdr.sh_info;
- register unsigned int i;
-
- ptr = (elf_linker_section_pointers_t **)
- bfd_alloc (abfd, num_symbols * sizeof (elf_linker_section_pointers_t *));
-
- if (!ptr)
- return false;
-
- elf_local_ptr_offsets (abfd) = ptr;
- for (i = 0; i < num_symbols; i++)
- ptr[i] = (elf_linker_section_pointers_t *)0;
- }
-
- /* Has this symbol already been allocated, if so, our work is done */
- if (_bfd_elf_find_pointer_linker_section (ptr[r_symndx],
- rel->r_addend,
- lsect->which))
- return true;
-
- ptr_linker_section_ptr = &ptr[r_symndx];
-
- if (info->shared)
- {
- /* If we are generating a shared object, we need to
- output a R_<xxx>_RELATIVE reloc so that the
- dynamic linker can adjust this GOT entry. */
- BFD_ASSERT (lsect->rel_section != NULL);
- lsect->rel_section->_raw_size += sizeof (Elf_External_Rela);
- }
- }
-
- /* Allocate space for a pointer in the linker section, and allocate a new pointer record
- from internal memory. */
- BFD_ASSERT (ptr_linker_section_ptr != NULL);
- linker_section_ptr = (elf_linker_section_pointers_t *)
- bfd_alloc (abfd, sizeof (elf_linker_section_pointers_t));
-
- if (!linker_section_ptr)
- return false;
-
- linker_section_ptr->next = *ptr_linker_section_ptr;
- linker_section_ptr->addend = rel->r_addend;
- linker_section_ptr->which = lsect->which;
- linker_section_ptr->written_address_p = false;
- *ptr_linker_section_ptr = linker_section_ptr;
-
- if (lsect->hole_size && lsect->hole_offset < lsect->max_hole_offset)
- {
- linker_section_ptr->offset = lsect->section->_raw_size - lsect->hole_size;
- lsect->hole_offset += ARCH_SIZE / 8;
- lsect->sym_offset += ARCH_SIZE / 8;
- if (lsect->sym_hash) /* Bump up symbol value if needed */
- lsect->sym_hash->root.u.def.value += ARCH_SIZE / 8;
- }
- else
- linker_section_ptr->offset = lsect->section->_raw_size;
-
- lsect->section->_raw_size += ARCH_SIZE / 8;
-
-#ifdef DEBUG
- fprintf (stderr, "Create pointer in linker section %s, offset = %ld, section size = %ld\n",
- lsect->name, (long)linker_section_ptr->offset, (long)lsect->section->_raw_size);
-#endif
-
- return true;
-}
-
-
-#if ARCH_SIZE==64
-#define bfd_put_ptr(BFD,VAL,ADDR) bfd_put_64 (BFD, VAL, ADDR)
-#endif
-#if ARCH_SIZE==32
-#define bfd_put_ptr(BFD,VAL,ADDR) bfd_put_32 (BFD, VAL, ADDR)
-#endif
-
-/* Fill in the address for a pointer generated in alinker section. */
-
-bfd_vma
-elf_finish_pointer_linker_section (output_bfd, input_bfd, info, lsect, h, relocation, rel, relative_reloc)
- bfd *output_bfd;
- bfd *input_bfd;
- struct bfd_link_info *info;
- elf_linker_section_t *lsect;
- struct elf_link_hash_entry *h;
- bfd_vma relocation;
- const Elf_Internal_Rela *rel;
- int relative_reloc;
-{
- elf_linker_section_pointers_t *linker_section_ptr;
-
- BFD_ASSERT (lsect != NULL);
-
- if (h != NULL) /* global symbol */
- {
- linker_section_ptr = _bfd_elf_find_pointer_linker_section (h->linker_section_pointer,
- rel->r_addend,
- lsect->which);
-
- BFD_ASSERT (linker_section_ptr != NULL);
-
- if (! elf_hash_table (info)->dynamic_sections_created
- || (info->shared
- && info->symbolic
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
- {
- /* This is actually a static link, or it is a
- -Bsymbolic link and the symbol is defined
- locally. We must initialize this entry in the
- global section.
-
- When doing a dynamic link, we create a .rela.<xxx>
- relocation entry to initialize the value. This
- is done in the finish_dynamic_symbol routine. */
- if (!linker_section_ptr->written_address_p)
- {
- linker_section_ptr->written_address_p = true;
- bfd_put_ptr (output_bfd, relocation + linker_section_ptr->addend,
- lsect->section->contents + linker_section_ptr->offset);
- }
- }
- }
- else /* local symbol */
- {
- unsigned long r_symndx = ELF_R_SYM (rel->r_info);
- BFD_ASSERT (elf_local_ptr_offsets (input_bfd) != NULL);
- BFD_ASSERT (elf_local_ptr_offsets (input_bfd)[r_symndx] != NULL);
- linker_section_ptr = _bfd_elf_find_pointer_linker_section (elf_local_ptr_offsets (input_bfd)[r_symndx],
- rel->r_addend,
- lsect->which);
-
- BFD_ASSERT (linker_section_ptr != NULL);
-
- /* Write out pointer if it hasn't been rewritten out before */
- if (!linker_section_ptr->written_address_p)
- {
- linker_section_ptr->written_address_p = true;
- bfd_put_ptr (output_bfd, relocation + linker_section_ptr->addend,
- lsect->section->contents + linker_section_ptr->offset);
-
- if (info->shared)
- {
- asection *srel = lsect->rel_section;
- Elf_Internal_Rela outrel;
-
- /* We need to generate a relative reloc for the dynamic linker. */
- if (!srel)
- lsect->rel_section = srel = bfd_get_section_by_name (elf_hash_table (info)->dynobj,
- lsect->rel_name);
-
- BFD_ASSERT (srel != NULL);
-
- outrel.r_offset = (lsect->section->output_section->vma
- + lsect->section->output_offset
- + linker_section_ptr->offset);
- outrel.r_info = ELF_R_INFO (0, relative_reloc);
- outrel.r_addend = 0;
- elf_swap_reloca_out (output_bfd, &outrel,
- (((Elf_External_Rela *)
- lsect->section->contents)
- + lsect->section->reloc_count));
- ++lsect->section->reloc_count;
- }
- }
- }
-
- relocation = (lsect->section->output_offset
- + linker_section_ptr->offset
- - lsect->hole_offset
- - lsect->sym_offset);
-
-#ifdef DEBUG
- fprintf (stderr, "Finish pointer in linker section %s, offset = %ld (0x%lx)\n",
- lsect->name, (long)relocation, (long)relocation);
-#endif
-
- /* Subtract out the addend, because it will get added back in by the normal
- processing. */
- return relocation - linker_section_ptr->addend;
-}
diff --git a/contrib/gdb/bfd/elfxx-target.h b/contrib/gdb/bfd/elfxx-target.h
deleted file mode 100644
index f2c0c32..0000000
--- a/contrib/gdb/bfd/elfxx-target.h
+++ /dev/null
@@ -1,450 +0,0 @@
-/* Target definitions for NN-bit ELF
- Copyright 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* 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 bfd_elfNN_close_and_cleanup _bfd_generic_close_and_cleanup
-#define bfd_elfNN_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#ifndef bfd_elfNN_get_section_contents
-#define bfd_elfNN_get_section_contents _bfd_generic_get_section_contents
-#endif
-
-#define bfd_elfNN_canonicalize_dynamic_symtab _bfd_elf_canonicalize_dynamic_symtab
-#define bfd_elfNN_canonicalize_reloc _bfd_elf_canonicalize_reloc
-#ifndef bfd_elfNN_find_nearest_line
-#define bfd_elfNN_find_nearest_line _bfd_elf_find_nearest_line
-#endif
-#define bfd_elfNN_read_minisymbols _bfd_elf_read_minisymbols
-#define bfd_elfNN_minisymbol_to_symbol _bfd_elf_minisymbol_to_symbol
-#define bfd_elfNN_get_dynamic_symtab_upper_bound _bfd_elf_get_dynamic_symtab_upper_bound
-#define bfd_elfNN_get_lineno _bfd_elf_get_lineno
-#define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound
-#define bfd_elfNN_get_symbol_info _bfd_elf_get_symbol_info
-#define bfd_elfNN_get_symtab _bfd_elf_get_symtab
-#define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
-#if 0 /* done in elf-bfd.h */
-#define bfd_elfNN_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
-#endif
-#define bfd_elfNN_make_empty_symbol _bfd_elf_make_empty_symbol
-#define bfd_elfNN_new_section_hook _bfd_elf_new_section_hook
-#define bfd_elfNN_set_arch_mach _bfd_elf_set_arch_mach
-#ifndef bfd_elfNN_set_section_contents
-#define bfd_elfNN_set_section_contents _bfd_elf_set_section_contents
-#endif
-#define bfd_elfNN_sizeof_headers _bfd_elf_sizeof_headers
-#define bfd_elfNN_write_object_contents _bfd_elf_write_object_contents
-
-#define bfd_elfNN_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-#ifndef elf_backend_want_got_plt
-#define elf_backend_want_got_plt 0
-#endif
-#ifndef elf_backend_plt_readonly
-#define elf_backend_plt_readonly 0
-#endif
-#ifndef elf_backend_want_plt_sym
-#define elf_backend_want_plt_sym 0
-#endif
-
-#define bfd_elfNN_bfd_debug_info_start bfd_void
-#define bfd_elfNN_bfd_debug_info_end bfd_void
-#define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
-
-#ifndef bfd_elfNN_bfd_get_relocated_section_contents
-#define bfd_elfNN_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#endif
-
-#define bfd_elfNN_bfd_relax_section bfd_generic_relax_section
-#define bfd_elfNN_bfd_make_debug_symbol \
- ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
-
-#ifndef bfd_elfNN_bfd_copy_private_symbol_data
-#define bfd_elfNN_bfd_copy_private_symbol_data \
- _bfd_elf_copy_private_symbol_data
-#endif
-
-#ifndef bfd_elfNN_bfd_copy_private_section_data
-#define bfd_elfNN_bfd_copy_private_section_data \
- _bfd_elf_copy_private_section_data
-#endif
-#ifndef bfd_elfNN_bfd_copy_private_bfd_data
-#define bfd_elfNN_bfd_copy_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
-#endif
-#ifndef bfd_elfNN_bfd_print_private_bfd_data
-#define bfd_elfNN_bfd_print_private_bfd_data \
- _bfd_elf_print_private_bfd_data
-#endif
-#ifndef bfd_elfNN_bfd_merge_private_bfd_data
-#define bfd_elfNN_bfd_merge_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
-#endif
-#ifndef bfd_elfNN_bfd_set_private_flags
-#define bfd_elfNN_bfd_set_private_flags \
- ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
-#endif
-#ifndef bfd_elfNN_bfd_is_local_label
-#define bfd_elfNN_bfd_is_local_label bfd_generic_is_local_label
-#endif
-
-#ifndef bfd_elfNN_get_dynamic_reloc_upper_bound
-#define bfd_elfNN_get_dynamic_reloc_upper_bound \
- _bfd_nodynamic_get_dynamic_reloc_upper_bound
-#endif
-#ifndef bfd_elfNN_canonicalize_dynamic_reloc
-#define bfd_elfNN_canonicalize_dynamic_reloc \
- _bfd_nodynamic_canonicalize_dynamic_reloc
-#endif
-
-#ifdef elf_backend_relocate_section
-#ifndef bfd_elfNN_bfd_link_hash_table_create
-#define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
-#endif
-#else /* ! defined (elf_backend_relocate_section) */
-/* If no backend relocate_section routine, use the generic linker. */
-#ifndef bfd_elfNN_bfd_link_hash_table_create
-#define bfd_elfNN_bfd_link_hash_table_create \
- _bfd_generic_link_hash_table_create
-#endif
-#ifndef bfd_elfNN_bfd_link_add_symbols
-#define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#endif
-#ifndef bfd_elfNN_bfd_final_link
-#define bfd_elfNN_bfd_final_link _bfd_generic_final_link
-#endif
-#endif /* ! defined (elf_backend_relocate_section) */
-#ifndef bfd_elfNN_bfd_link_split_section
-#define bfd_elfNN_bfd_link_split_section _bfd_generic_link_split_section
-#endif
-
-#ifndef elf_symbol_leading_char
-#define elf_symbol_leading_char 0
-#endif
-
-#ifndef elf_info_to_howto_rel
-#define elf_info_to_howto_rel 0
-#endif
-
-#ifndef ELF_MAXPAGESIZE
-#define ELF_MAXPAGESIZE 1
-#endif
-
-#ifndef elf_backend_collect
-#define elf_backend_collect false
-#endif
-#ifndef elf_backend_type_change_ok
-#define elf_backend_type_change_ok false
-#endif
-
-#ifndef elf_backend_sym_is_global
-#define elf_backend_sym_is_global 0
-#endif
-#ifndef elf_backend_object_p
-#define elf_backend_object_p 0
-#endif
-#ifndef elf_backend_symbol_processing
-#define elf_backend_symbol_processing 0
-#endif
-#ifndef elf_backend_symbol_table_processing
-#define elf_backend_symbol_table_processing 0
-#endif
-#ifndef elf_backend_section_processing
-#define elf_backend_section_processing 0
-#endif
-#ifndef elf_backend_section_from_shdr
-#define elf_backend_section_from_shdr 0
-#endif
-#ifndef elf_backend_fake_sections
-#define elf_backend_fake_sections 0
-#endif
-#ifndef elf_backend_section_from_bfd_section
-#define elf_backend_section_from_bfd_section 0
-#endif
-#ifndef elf_backend_add_symbol_hook
-#define elf_backend_add_symbol_hook 0
-#endif
-#ifndef elf_backend_link_output_symbol_hook
-#define elf_backend_link_output_symbol_hook 0
-#endif
-#ifndef elf_backend_create_dynamic_sections
-#define elf_backend_create_dynamic_sections 0
-#endif
-#ifndef elf_backend_check_relocs
-#define elf_backend_check_relocs 0
-#endif
-#ifndef elf_backend_adjust_dynamic_symbol
-#define elf_backend_adjust_dynamic_symbol 0
-#endif
-#ifndef elf_backend_size_dynamic_sections
-#define elf_backend_size_dynamic_sections 0
-#endif
-#ifndef elf_backend_relocate_section
-#define elf_backend_relocate_section 0
-#endif
-#ifndef elf_backend_finish_dynamic_symbol
-#define elf_backend_finish_dynamic_symbol 0
-#endif
-#ifndef elf_backend_finish_dynamic_sections
-#define elf_backend_finish_dynamic_sections 0
-#endif
-#ifndef elf_backend_begin_write_processing
-#define elf_backend_begin_write_processing 0
-#endif
-#ifndef elf_backend_final_write_processing
-#define elf_backend_final_write_processing 0
-#endif
-#ifndef elf_backend_additional_program_headers
-#define elf_backend_additional_program_headers 0
-#endif
-#ifndef elf_backend_modify_segment_map
-#define elf_backend_modify_segment_map 0
-#endif
-#ifndef elf_backend_ecoff_debug_swap
-#define elf_backend_ecoff_debug_swap 0
-#endif
-
-#ifndef ELF_MACHINE_ALT1
-#define ELF_MACHINE_ALT1 0
-#endif
-
-#ifndef ELF_MACHINE_ALT2
-#define ELF_MACHINE_ALT2 0
-#endif
-
-extern const struct elf_size_info _bfd_elfNN_size_info;
-
-static CONST struct elf_backend_data elfNN_bed =
-{
-#ifdef USE_REL
- 0, /* use_rela_p */
-#else
- 1, /* use_rela_p */
-#endif
- ELF_ARCH, /* arch */
- ELF_MACHINE_CODE, /* elf_machine_code */
- ELF_MAXPAGESIZE, /* maxpagesize */
- elf_backend_collect,
- elf_backend_type_change_ok,
- elf_info_to_howto,
- elf_info_to_howto_rel,
- elf_backend_sym_is_global,
- elf_backend_object_p,
- elf_backend_symbol_processing,
- elf_backend_symbol_table_processing,
- elf_backend_section_processing,
- elf_backend_section_from_shdr,
- elf_backend_fake_sections,
- elf_backend_section_from_bfd_section,
- elf_backend_add_symbol_hook,
- elf_backend_link_output_symbol_hook,
- elf_backend_create_dynamic_sections,
- elf_backend_check_relocs,
- elf_backend_adjust_dynamic_symbol,
- elf_backend_size_dynamic_sections,
- elf_backend_relocate_section,
- elf_backend_finish_dynamic_symbol,
- elf_backend_finish_dynamic_sections,
- elf_backend_begin_write_processing,
- elf_backend_final_write_processing,
- elf_backend_additional_program_headers,
- elf_backend_modify_segment_map,
- elf_backend_ecoff_debug_swap,
- ELF_MACHINE_ALT1,
- ELF_MACHINE_ALT2,
- &_bfd_elfNN_size_info,
- elf_backend_want_got_plt,
- elf_backend_plt_readonly,
- elf_backend_want_plt_sym
-};
-
-#ifdef TARGET_BIG_SYM
-const bfd_target TARGET_BIG_SYM =
-{
- /* name: identify kind of target */
- TARGET_BIG_NAME,
-
- /* flavour: general indication about file */
- bfd_target_elf_flavour,
-
- /* byteorder: data is big endian */
- BFD_ENDIAN_BIG,
-
- /* header_byteorder: header is also big endian */
- BFD_ENDIAN_BIG,
-
- /* object_flags: mask of all file flags */
- (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
- DYNAMIC | WP_TEXT | D_PAGED),
-
- /* section_flags: mask of all section flags */
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
- SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
-
- /* leading_symbol_char: is the first char of a user symbol
- predictable, and if so what is it */
- elf_symbol_leading_char,
-
- /* 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) */
- 14,
-
- /* Routines to byte-swap various sized integers from the data sections */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
-
- /* Routines to byte-swap various sized integers from the file headers */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
-
- /* bfd_check_format: check the format of a file being read */
- { _bfd_dummy_target, /* unknown format */
- bfd_elfNN_object_p, /* assembler/linker output (object file) */
- bfd_generic_archive_p, /* an archive */
- bfd_elfNN_core_file_p /* a core file */
- },
-
- /* bfd_set_format: set the format of a file being written */
- { bfd_false,
- bfd_elf_mkobject,
- _bfd_generic_mkarchive,
- bfd_false
- },
-
- /* bfd_write_contents: write cached information into a file being written */
- { bfd_false,
- bfd_elfNN_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
- BFD_JUMP_TABLE_COPY (bfd_elfNN),
- BFD_JUMP_TABLE_CORE (bfd_elfNN),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
- BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
- BFD_JUMP_TABLE_WRITE (bfd_elfNN),
- BFD_JUMP_TABLE_LINK (bfd_elfNN),
- BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
-
- /* backend_data: */
- (PTR) &elfNN_bed,
-};
-#endif
-
-#ifdef TARGET_LITTLE_SYM
-const bfd_target TARGET_LITTLE_SYM =
-{
- /* name: identify kind of target */
- TARGET_LITTLE_NAME,
-
- /* flavour: general indication about file */
- bfd_target_elf_flavour,
-
- /* byteorder: data is little endian */
- BFD_ENDIAN_LITTLE,
-
- /* header_byteorder: header is also little endian */
- BFD_ENDIAN_LITTLE,
-
- /* object_flags: mask of all file flags */
- (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
- DYNAMIC | WP_TEXT | D_PAGED),
-
- /* section_flags: mask of all section flags */
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
- SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_EXCLUDE | SEC_SORT_ENTRIES),
-
- /* leading_symbol_char: is the first char of a user symbol
- predictable, and if so what is it */
- elf_symbol_leading_char,
-
- /* 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) */
- 14,
-
- /* Routines to byte-swap various sized integers from the data sections */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16,
-
- /* Routines to byte-swap various sized integers from the file headers */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16,
-
- /* bfd_check_format: check the format of a file being read */
- { _bfd_dummy_target, /* unknown format */
- bfd_elfNN_object_p, /* assembler/linker output (object file) */
- bfd_generic_archive_p, /* an archive */
- bfd_elfNN_core_file_p /* a core file */
- },
-
- /* bfd_set_format: set the format of a file being written */
- { bfd_false,
- bfd_elf_mkobject,
- _bfd_generic_mkarchive,
- bfd_false
- },
-
- /* bfd_write_contents: write cached information into a file being written */
- { bfd_false,
- bfd_elfNN_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (bfd_elfNN),
- BFD_JUMP_TABLE_COPY (bfd_elfNN),
- BFD_JUMP_TABLE_CORE (bfd_elfNN),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (bfd_elfNN),
- BFD_JUMP_TABLE_RELOCS (bfd_elfNN),
- BFD_JUMP_TABLE_WRITE (bfd_elfNN),
- BFD_JUMP_TABLE_LINK (bfd_elfNN),
- BFD_JUMP_TABLE_DYNAMIC (bfd_elfNN),
-
- /* backend_data: */
- (PTR) &elfNN_bed,
-};
-#endif
diff --git a/contrib/gdb/bfd/filemode.c b/contrib/gdb/bfd/filemode.c
deleted file mode 100644
index fd790b3..0000000
--- a/contrib/gdb/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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-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/contrib/gdb/bfd/freebsd.h b/contrib/gdb/bfd/freebsd.h
index 7e1d69d..43d29a9 100644
--- a/contrib/gdb/bfd/freebsd.h
+++ b/contrib/gdb/bfd/freebsd.h
@@ -21,9 +21,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* FreeBSD ZMAGIC files never have the header in the text. */
#define N_HEADER_IN_TEXT(x) 0
-/* ZMAGIC files start at offset 0. Does not apply to QMAGIC files. */
-#define TEXT_START_ADDR 0
-
+/* A ZMAGIC file can start at almost any address if it is a kernel. */
+#define TEXT_START_ADDR dont use TEXT_START_ADDR
+
+/* The following definitions are essentially the same as the ones in
+ FreeBSD's <sys/imgact_aout.h>. They override gdb's versions, which
+ don't work for kernels. See ../include/aout/aout64.h. */
+#define N_TXTADDR(x) \
+ (N_GETMAGIC(x) == OMAGIC || N_GETMAGIC(x) == NMAGIC \
+ || N_GETMAGIC(x) == ZMAGIC \
+ ? ((x).a_entry < (x).a_text ? 0 : (x).a_entry & ~TARGET_PAGE_SIZE) \
+ : TARGET_PAGE_SIZE)
+#define N_TXTOFF(x) \
+ (N_GETMAGIC(x) == ZMAGIC ? TARGET_PAGE_SIZE \
+ : (N_GETMAGIC(x) == QMAGIC || N_GETMAGIC_NET(x) == ZMAGIC) ? 0 \
+ : sizeof(struct external_exec))
+#define N_TXTSIZE(x) ((x).a_text)
+
+#define N_GETMAGIC(exec) \
+ ((exec).a_info & 0xffff)
#define N_GETMAGIC_NET(exec) \
(ntohl ((exec).a_info) & 0xffff)
#define N_GETMID_NET(exec) \
diff --git a/contrib/gdb/bfd/gen-aout.c b/contrib/gdb/bfd/gen-aout.c
deleted file mode 100644
index d2224f7..0000000
--- a/contrib/gdb/bfd/gen-aout.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Generate parameters for an a.out system.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "/usr/include/a.out.h"
-#include <stdio.h>
-
-int
-main (argc, argv)
- int argc; char** argv;
-{
- struct exec my_exec;
- int page_size;
- char *target = "unknown", *arch = "unknown";
- FILE *file = fopen("gen-aout", "r");
-
- if (file == NULL) {
- fprintf(stderr, "Cannot open gen-aout!\n");
- return -1;
- }
- if (fread(&my_exec, sizeof(struct exec), 1, file) != 1) {
- fprintf(stderr, "Cannot read gen-aout!\n");
- return -1;
- }
-
- target = argv[1];
- if (target == NULL) {
- fprintf(stderr, "Usage: gen-aout target_name\n");
- exit (1);
- }
-
-#ifdef N_TXTOFF
- page_size = N_TXTOFF(my_exec);
- if (page_size == 0)
- printf("#define N_HEADER_IN_TEXT(x) 1\n");
- else
- printf("#define N_HEADER_IN_TEXT(x) 0\n");
-#endif
-
- printf("#define BYTES_IN_WORD %d\n", sizeof (int));
- if (my_exec.a_entry == 0) {
- printf("#define ENTRY_CAN_BE_ZERO\n");
- printf("#define N_SHARED_LIB(x) 0 /* Avoids warning */\n");
- }
- else {
- printf("/*#define ENTRY_CAN_BE_ZERO*/\n");
- printf("/*#define N_SHARED_LIB(x) 0*/\n");
- }
-
- printf("#define TEXT_START_ADDR %d\n", my_exec.a_entry);
-
-#ifdef PAGSIZ
- if (page_size == 0)
- page_size = PAGSIZ;
-#endif
- if (page_size != 0)
- printf("#define TARGET_PAGE_SIZE %d\n", page_size);
- else
- printf("/* #define TARGET_PAGE_SIZE ??? */\n");
- printf("#define SEGMENT_SIZE TARGET_PAGE_SIZE\n");
-
-#ifdef vax
- arch = "vax";
-#endif
-#ifdef m68k
- arch = "m68k";
-#endif
- if (arch[0] == '1')
- {
- fprintf (stderr, "warning: preprocessor substituted architecture name inside string;");
- fprintf (stderr, " fix DEFAULT_ARCH in the output file yourself\n");
- arch = "unknown";
- }
- printf("#define DEFAULT_ARCH bfd_arch_%s\n", arch);
-
- printf("\n#define MY(OP) CAT(%s_,OP)\n", target);
- printf("#define TARGETNAME \"a.out-%s\"\n\n", target);
-
- printf("#include \"bfd.h\"\n");
- printf("#include \"sysdep.h\"\n");
- printf("#include \"libbfd.h\"\n");
- printf("#include \"libaout.h\"\n");
- printf("\n#include \"aout-target.h\"\n");
-
- return 0;
-}
diff --git a/contrib/gdb/bfd/host-aout.c b/contrib/gdb/bfd/host-aout.c
deleted file mode 100644
index 99643dc..0000000
--- a/contrib/gdb/bfd/host-aout.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* BFD backend for local host's a.out binaries
- Copyright (C) 1990, 91, 92, 93, 94 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#define ARCH_SIZE 32
-
-/* When porting to a new system, you must supply:
-
- HOST_PAGE_SIZE (optional)
- HOST_SEGMENT_SIZE (optional -- defaults to page size)
- HOST_MACHINE_ARCH (optional)
- HOST_MACHINE_MACHINE (optional)
- HOST_TEXT_START_ADDR (optional)
- HOST_STACK_END_ADDR (not used, except by trad-core ???)
- HOST_BIG_ENDIAN_P (required -- define if big-endian)
-
- in the ./hosts/h-systemname.h file. */
-
-#ifdef TRAD_HEADER
-#include TRAD_HEADER
-#endif
-
-#ifdef HOST_PAGE_SIZE
-#define TARGET_PAGE_SIZE HOST_PAGE_SIZE
-#endif
-
-#ifdef HOST_SEGMENT_SIZE
-#define SEGMENT_SIZE HOST_SEGMENT_SIZE
-#else
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#endif
-
-#ifdef HOST_TEXT_START_ADDR
-#define TEXT_START_ADDR HOST_TEXT_START_ADDR
-#endif
-
-#ifdef HOST_STACK_END_ADDR
-#define STACK_END_ADDR HOST_STACK_END_ADDR
-#endif
-
-#ifdef HOST_BIG_ENDIAN_P
-#define TARGET_IS_BIG_ENDIAN_P
-#else
-#undef TARGET_IS_BIG_ENDIAN_P
-#endif
-
-#include "libaout.h" /* BFD a.out internal data structures */
-#include "aout/aout64.h"
-
-#ifdef HOST_MACHINE_ARCH
-#ifdef HOST_MACHINE_MACHINE
-#define SET_ARCH_MACH(abfd, execp) \
- bfd_default_set_arch_mach(abfd, HOST_MACHINE_ARCH, HOST_MACHINE_MACHINE)
-#else
-#define SET_ARCH_MACH(abfd, execp) \
- bfd_default_set_arch_mach(abfd, HOST_MACHINE_ARCH, 0)
-#endif
-#endif /* HOST_MACHINE_ARCH */
-
-#define MY(OP) CAT(host_aout_,OP)
-#define TARGETNAME "a.out"
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/hp300bsd.c b/contrib/gdb/bfd/hp300bsd.c
deleted file mode 100644
index 5767b18..0000000
--- a/contrib/gdb/bfd/hp300bsd.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD back-end for HP 9000/300 (68000-based) machines running BSD Unix.
- Copyright 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_IS_BIG_ENDIAN_P
-#define N_HEADER_IN_TEXT(x) 0
-#define BYTES_IN_WORD 4
-#define ENTRY_CAN_BE_ZERO
-#define N_SHARED_LIB(x) 0 /* Avoids warning */
-#define TEXT_START_ADDR 0
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define DEFAULT_ARCH bfd_arch_m68k
-
-#define MY(OP) CAT(hp300bsd_,OP)
-#define TARGETNAME "a.out-hp300bsd"
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/hp300hpux.c b/contrib/gdb/bfd/hp300hpux.c
deleted file mode 100644
index 1d1acab..0000000
--- a/contrib/gdb/bfd/hp300hpux.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/* BFD backend for hp-ux 9000/300
- Copyright (C) 1990, 1991, 1994, 1995 Free Software Foundation, Inc.
- Written by Glenn Engel.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-
- hpux native ------------> | |
- | hp300hpux bfd | ----------> hpux w/gnu ext
- hpux w/gnu extension ----> | |
-
-
- Support for the 9000/[34]00 has several limitations.
- 1. Shared libraries are not supported.
- 2. The output format from this bfd is not usable by native tools.
-
- The primary motivation for writing this bfd was to allow use of
- gdb and gcc for host based debugging and not to mimic the hp-ux tools
- in every detail. This leads to a significant simplification of the
- code and a leap in performance. The decision to not output hp native
- compatible objects was further strengthened by the fact that the richness
- of the gcc compiled objects could not be represented without loss of
- information. For example, while the hp format supports the concept of
- secondary symbols, it does not support indirect symbols. Another
- reason is to maintain backwards compatibility with older implementations
- of gcc on hpux which used 'hpxt' to translate .a and .o files into a
- format which could be readily understood by the gnu linker and gdb.
- This allows reading hp secondary symbols and converting them into
- indirect symbols but the reverse it not always possible.
-
- Another example of differences is that the hp format stores symbol offsets
- in the object code while the gnu utilities use a field in the
- relocation record for this. To support the hp native format, the object
- code would need to be patched with the offsets when producing .o files.
-
- The basic technique taken in this implementation is to #include the code
- from aoutx.h and aout-target.h with appropriate #defines to override
- code where a unique implementation is needed:
-
- {
- #define a bunch of stuff
- #include <aoutx.h>
-
- implement a bunch of functions
-
- #include "aout-target.h"
- }
-
- The hp symbol table is a bit different than other a.out targets. Instead
- of having an array of nlist items and an array of strings, hp's format
- has them mixed together in one structure. In addition, the strings are
- not null terminated. It looks something like this:
-
- nlist element 1
- string1
- nlist element 2
- string2
- ...
-
- The whole symbol table is read as one chunk and then we march thru it
- and convert it to canonical form. As we march thru the table, we copy
- the nlist data into the internal form and we compact the strings and null
- terminate them, using storage from the already allocated symbol table:
-
- string1
- null
- string2
- null
- */
-
-/* @@ Is this really so different from normal a.out that it needs to include
- aoutx.h? We should go through this file sometime and see what can be made
- more dependent on aout32.o and what might need to be broken off and accessed
- through the backend_data field. Or, maybe we really do need such a
- completely separate implementation. I don't have time to investigate this
- much further right now. [raeburn:19930428.2124EST] */
-/* @@ Also, note that there wind up being two versions of some routines, with
- different names, only one of which actually gets used. For example:
- slurp_symbol_table
- swap_std_reloc_in
- slurp_reloc_table
- get_symtab
- get_symtab_upper_bound
- canonicalize_reloc
- mkobject
- This should also be fixed. */
-
-#define TARGETNAME "a.out-hp300hpux"
-#define MY(OP) CAT(hp300hpux_,OP)
-
-#define external_exec hp300hpux_exec_bytes
-#define external_nlist hp300hpux_nlist_bytes
-
-#include "aout/hp300hpux.h"
-
-/* define these so we can compile unused routines in aoutx.h */
-#define e_strx e_shlib
-#define e_other e_length
-#define e_desc e_almod
-
-#define AR_PAD_CHAR '/'
-#define TARGET_IS_BIG_ENDIAN_P
-#define DEFAULT_ARCH bfd_arch_m68k
-
-#define MY_get_section_contents aout_32_get_section_contents
-#define MY_slurp_armap bfd_slurp_bsd_armap_f2
-
-/***********************************************/
-/* provide overrides for routines in this file */
-/***********************************************/
-/* these don't use MY because that causes problems within JUMP_TABLE
- (CAT winds up being expanded recursively, which ANSI C compilers
- will not do). */
-#define MY_get_symtab hp300hpux_get_symtab
-#define MY_get_symtab_upper_bound hp300hpux_get_symtab_upper_bound
-#define MY_canonicalize_reloc hp300hpux_canonicalize_reloc
-#define MY_write_object_contents hp300hpux_write_object_contents
-
-#define MY_read_minisymbols _bfd_generic_read_minisymbols
-#define MY_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define MY_final_link_callback unused
-#define MY_bfd_final_link _bfd_generic_final_link
-
-/* Until and unless we convert the slurp_reloc and slurp_symtab
- routines in this file, we can not use the default aout
- free_cached_info routine which assumes that the relocs and symtabs
- were allocated using malloc. */
-#define MY_bfd_free_cached_info bfd_true
-
-#define hp300hpux_write_syms aout_32_write_syms
-
-#define MY_callback MY(callback)
-
-#define MY_exec_hdr_flags 0x2
-
-#define NAME_swap_exec_header_in NAME(hp300hpux_32_,swap_exec_header_in)
-
-#define HP_SYMTYPE_UNDEFINED 0x00
-#define HP_SYMTYPE_ABSOLUTE 0x01
-#define HP_SYMTYPE_TEXT 0x02
-#define HP_SYMTYPE_DATA 0x03
-#define HP_SYMTYPE_BSS 0x04
-#define HP_SYMTYPE_COMMON 0x05
-
-#define HP_SYMTYPE_TYPE 0x0F
-#define HP_SYMTYPE_FILENAME 0x1F
-
-#define HP_SYMTYPE_ALIGN 0x10
-#define HP_SYMTYPE_EXTERNAL 0x20
-#define HP_SECONDARY_SYMBOL 0x40
-
-/* RELOCATION DEFINITIONS */
-#define HP_RSEGMENT_TEXT 0x00
-#define HP_RSEGMENT_DATA 0x01
-#define HP_RSEGMENT_BSS 0x02
-#define HP_RSEGMENT_EXTERNAL 0x03
-#define HP_RSEGMENT_PCREL 0x04
-#define HP_RSEGMENT_RDLT 0x05
-#define HP_RSEGMENT_RPLT 0x06
-#define HP_RSEGMENT_NOOP 0x3F
-
-#define HP_RLENGTH_BYTE 0x00
-#define HP_RLENGTH_WORD 0x01
-#define HP_RLENGTH_LONG 0x02
-#define HP_RLENGTH_ALIGN 0x03
-
-#define NAME(x,y) CAT3(hp300hpux,_32_,y)
-#define ARCH_SIZE 32
-
-/* aoutx.h requires definitions for BMAGIC and QMAGIC. */
-#define BMAGIC HPUX_DOT_O_MAGIC
-#define QMAGIC 0314
-
-#include "aoutx.h"
-
-/* Since the hpux symbol table has nlist elements interspersed with
- strings and we need to insert som strings for secondary symbols, we
- give ourselves a little extra padding up front to account for
- this. Note that for each non-secondary symbol we process, we gain
- 9 bytes of space for the discarded nlist element (one byte used for
- null). SYM_EXTRA_BYTES is the extra space. */
-#define SYM_EXTRA_BYTES 1024
-
-/* 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 const bfd_target *
-MY (callback) (abfd)
- bfd *abfd;
-{
- struct internal_exec *execp = exec_hdr (abfd);
-
- /* Calculate the file positions of the parts of a newly read aout header */
- obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp);
-
- /* The virtual memory addresses of the sections */
- obj_textsec (abfd)->vma = N_TXTADDR (*execp);
- obj_datasec (abfd)->vma = N_DATADDR (*execp);
- obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
-
- obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
- obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
- obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
-
- /* 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);
-
- /* Determine the architecture and machine type of the object file. */
-#ifdef SET_ARCH_MACH
- SET_ARCH_MACH (abfd, *execp);
-#else
- bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
-#endif
-
-
- if (obj_aout_subformat (abfd) == gnu_encap_format)
- {
- /* The file offsets of the relocation info */
- obj_textsec (abfd)->rel_filepos = N_GNU_TRELOFF (*execp);
- obj_datasec (abfd)->rel_filepos = N_GNU_DRELOFF (*execp);
-
- /* The file offsets of the string table and symbol table. */
- obj_sym_filepos (abfd) = N_GNU_SYMOFF (*execp);
- obj_str_filepos (abfd) = (obj_sym_filepos (abfd) + execp->a_syms);
-
- abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
- bfd_get_symcount (abfd) = execp->a_syms / 12;
- obj_symbol_entry_size (abfd) = 12;
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
- }
-
- return abfd->xvec;
-}
-
-extern boolean aout_32_write_syms PARAMS ((bfd * abfd));
-
-static boolean
-MY (write_object_contents) (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
- bfd_size_type text_size; /* dummy vars */
- file_ptr text_end;
-
- memset (&exec_bytes, 0, sizeof (exec_bytes));
-#if CHOOSE_RELOC_SIZE
- CHOOSE_RELOC_SIZE (abfd);
-#else
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-#endif
-
- if (adata (abfd).magic == undecided_magic)
- NAME (aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
- execp->a_syms = 0;
-
- 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));
-
- N_SET_MACHTYPE (*execp, 0xc);
- N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
-
- NAME (aout,swap_exec_header_out) (abfd, execp, &exec_bytes);
-
- /* update fields not covered by default swap_exec_header_out */
-
- /* this is really the sym table size but we store it in drelocs */
- bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
-
- if (bfd_seek (abfd, 0L, false) != 0
- || (bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE))
- return false;
-
- /* Write out the symbols, and then the relocs. We must write out
- the symbols first so that we know the symbol indices. */
-
- if (bfd_get_symcount (abfd) != 0)
- {
- /* Skip the relocs to where we want to put the symbols. */
- if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp) + execp->a_drsize,
- SEEK_SET) != 0)
- return false;
- }
-
- if (!MY (write_syms) (abfd))
- return false;
-
- if (bfd_get_symcount (abfd) != 0)
- {
- if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0)
- return false;
- if (!NAME (aout,squirt_out_relocs) (abfd, obj_textsec (abfd)))
- return false;
- if (bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false) != 0)
- return false;
- if (!NAME (aout,squirt_out_relocs) (abfd, obj_datasec (abfd)))
- return false;
- }
-
- return true;
-}
-
-/* convert the hp symbol type to be the same as aout64.h usage so we */
-/* can piggyback routines in aoutx.h. */
-
-static void
-convert_sym_type (sym_pointer, cache_ptr, abfd)
- struct external_nlist *sym_pointer;
- aout_symbol_type *cache_ptr;
- bfd *abfd;
-{
- int name_type;
- int new_type;
-
- name_type = (cache_ptr->type);
- new_type = 0;
-
- if ((name_type & HP_SYMTYPE_ALIGN) != 0)
- {
- /* iou_error ("aligned symbol encountered: %s", name);*/
- name_type = 0;
- }
-
- if (name_type == HP_SYMTYPE_FILENAME)
- new_type = N_FN;
- else
- {
- switch (name_type & HP_SYMTYPE_TYPE)
- {
- case HP_SYMTYPE_UNDEFINED:
- new_type = N_UNDF;
- break;
-
- case HP_SYMTYPE_ABSOLUTE:
- new_type = N_ABS;
- break;
-
- case HP_SYMTYPE_TEXT:
- new_type = N_TEXT;
- break;
-
- case HP_SYMTYPE_DATA:
- new_type = N_DATA;
- break;
-
- case HP_SYMTYPE_BSS:
- new_type = N_BSS;
- break;
-
- case HP_SYMTYPE_COMMON:
- new_type = N_COMM;
- break;
-
- default:
- abort ();
- break;
- }
- if (name_type & HP_SYMTYPE_EXTERNAL)
- new_type |= N_EXT;
-
- if (name_type & HP_SECONDARY_SYMBOL)
- {
- switch (new_type)
- {
- default:
- abort ();
- case N_UNDF | N_EXT:
- new_type = N_WEAKU;
- break;
- case N_ABS | N_EXT:
- new_type = N_WEAKA;
- break;
- case N_TEXT | N_EXT:
- new_type = N_WEAKT;
- break;
- case N_DATA | N_EXT:
- new_type = N_WEAKD;
- break;
- case N_BSS | N_EXT:
- new_type = N_WEAKB;
- break;
- }
- }
- }
- cache_ptr->type = new_type;
-
-}
-
-
-/*
-DESCRIPTION
- Swaps the information in an executable header taken from a raw
- byte stream memory image, into the internal exec_header
- structure.
-*/
-
-void
-NAME (aout,swap_exec_header_in) (abfd, raw_bytes, execp)
- bfd *abfd;
- struct external_exec *raw_bytes;
- struct internal_exec *execp;
-{
- struct external_exec *bytes = (struct external_exec *) raw_bytes;
-
- /* The internal_exec structure has some fields that are unused in this
- configuration (IE for i960), so ensure that all such uninitialized
- fields are zero'd out. There are places where two of these structs
- are memcmp'd, and thus the contents do matter. */
- memset (execp, 0, sizeof (struct internal_exec));
- /* 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);
-
- /***************************************************************/
- /* check the header to see if it was generated by a bfd output */
- /* this is detected rather bizarely by requiring a bunch of */
- /* header fields to be zero and an old unused field (now used) */
- /* to be set. */
- /***************************************************************/
- do
- {
- long syms;
- struct aout_data_struct *rawptr;
- if (bfd_h_get_32 (abfd, bytes->e_passize) != 0)
- break;
- if (bfd_h_get_32 (abfd, bytes->e_syms) != 0)
- break;
- if (bfd_h_get_32 (abfd, bytes->e_supsize) != 0)
- break;
-
- syms = bfd_h_get_32 (abfd, bytes->e_drelocs);
- if (syms == 0)
- break;
-
- /* OK, we've passed the test as best as we can determine */
- execp->a_syms = syms;
-
- /* allocate storage for where we will store this result */
- rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (*rawptr));
-
- if (rawptr == NULL)
- return;
- abfd->tdata.aout_data = rawptr;
- obj_aout_subformat (abfd) = gnu_encap_format;
- }
- while (0);
-}
-
-
-/* The hp symbol table is a bit different than other a.out targets. Instead
- of having an array of nlist items and an array of strings, hp's format
- has them mixed together in one structure. In addition, the strings are
- not null terminated. It looks something like this:
-
- nlist element 1
- string1
- nlist element 2
- string2
- ...
-
- The whole symbol table is read as one chunk and then we march thru it
- and convert it to canonical form. As we march thru the table, we copy
- the nlist data into the internal form and we compact the strings and null
- terminate them, using storage from the already allocated symbol table:
-
- string1
- null
- string2
- null
- ...
-*/
-
-boolean
-MY (slurp_symbol_table) (abfd)
- bfd *abfd;
-{
- bfd_size_type symbol_bytes;
- struct external_nlist *syms;
- struct external_nlist *sym_pointer;
- struct external_nlist *sym_end;
- char *strings;
- aout_symbol_type *cached;
- unsigned num_syms = 0;
-
- /* If there's no work to be done, don't do any */
- if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
- return true;
- symbol_bytes = exec_hdr (abfd)->a_syms;
-
- strings = (char *) bfd_alloc (abfd,
- symbol_bytes + SYM_EXTRA_BYTES);
- if (!strings)
- return false;
- syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
- {
- bfd_release (abfd, syms);
- return false;
- }
-
-
- sym_end = (struct external_nlist *) (((char *) syms) + symbol_bytes);
-
- /* first, march thru the table and figure out how many symbols there are */
- for (sym_pointer = syms; sym_pointer < sym_end; sym_pointer++, num_syms++)
- {
- /* skip over the embedded symbol. */
- sym_pointer = (struct external_nlist *) (((char *) sym_pointer) +
- sym_pointer->e_length[0]);
- }
-
- /* now that we know the symbol count, update the bfd header */
- bfd_get_symcount (abfd) = num_syms;
-
- cached = ((aout_symbol_type *)
- bfd_zalloc (abfd,
- bfd_get_symcount (abfd) * sizeof (aout_symbol_type)));
- if (cached == NULL && bfd_get_symcount (abfd) != 0)
- return false;
-
- /* as we march thru the hp symbol table, convert it into a list of
- null terminated strings to hold the symbol names. Make sure any
- assignment to the strings pointer is done after we're thru using
- the nlist so we don't overwrite anything important. */
-
- /* OK, now walk the new symtable, cacheing symbol properties */
- {
- aout_symbol_type *cache_ptr = cached;
- aout_symbol_type cache_save;
- /* Run through table and copy values */
- for (sym_pointer = syms, cache_ptr = cached;
- sym_pointer < sym_end; sym_pointer++, cache_ptr++)
- {
- unsigned int length;
- cache_ptr->symbol.the_bfd = abfd;
- cache_ptr->symbol.value = GET_SWORD (abfd, sym_pointer->e_value);
- cache_ptr->desc = bfd_get_16 (abfd, sym_pointer->e_almod);
- cache_ptr->type = bfd_get_8 (abfd, sym_pointer->e_type);
- cache_ptr->symbol.udata.p = NULL;
- length = bfd_get_8 (abfd, sym_pointer->e_length);
- cache_ptr->other = length; /* other not used, save length here */
-
- cache_save = *cache_ptr;
- convert_sym_type (sym_pointer, cache_ptr, abfd);
- if (!translate_from_native_sym_flags (abfd, cache_ptr))
- return false;
-
- /********************************************************/
- /* for hpux, the 'lenght' value indicates the length of */
- /* the symbol name which follows the nlist entry. */
- /********************************************************/
- if (length)
- {
- /**************************************************************/
- /* the hp string is not null terminated so we create a new one*/
- /* by copying the string to overlap the just vacated nlist */
- /* structure before it in memory. */
- /**************************************************************/
- cache_ptr->symbol.name = strings;
- memcpy (strings, sym_pointer + 1, length);
- strings[length] = '\0';
- strings += length + 1;
- }
- else
- cache_ptr->symbol.name = (char *) NULL;
-
- /* skip over the embedded symbol. */
- sym_pointer = (struct external_nlist *) (((char *) sym_pointer) +
- length);
- }
- }
-
- obj_aout_symbols (abfd) = cached;
-
- return true;
-}
-
-
-
-void
-MY (swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
- bfd *abfd;
- struct hp300hpux_reloc *bytes;
- arelent *cache_ptr;
- asymbol **symbols;
- bfd_size_type symcount;
-{
- int r_index;
- int r_extern = 0;
- unsigned int r_length;
- int r_pcrel = 0;
- struct aoutdata *su = &(abfd->tdata.aout_data->a);
-
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
- r_index = bfd_h_get_16 (abfd, bytes->r_index);
-
- switch (bytes->r_type[0])
- {
- case HP_RSEGMENT_TEXT:
- r_index = N_TEXT;
- break;
- case HP_RSEGMENT_DATA:
- r_index = N_DATA;
- break;
- case HP_RSEGMENT_BSS:
- r_index = N_BSS;
- break;
- case HP_RSEGMENT_EXTERNAL:
- r_extern = 1;
- break;
- case HP_RSEGMENT_PCREL:
- r_extern = 1;
- r_pcrel = 1;
- break;
- case HP_RSEGMENT_RDLT:
- break;
- case HP_RSEGMENT_RPLT:
- break;
- case HP_RSEGMENT_NOOP:
- break;
- default:
- abort ();
- break;
- }
-
- switch (bytes->r_length[0])
- {
- case HP_RLENGTH_BYTE:
- r_length = 0;
- break;
- case HP_RLENGTH_WORD:
- r_length = 1;
- break;
- case HP_RLENGTH_LONG:
- r_length = 2;
- break;
- default:
- abort ();
- break;
- }
-
- cache_ptr->howto = howto_table_std + r_length + 4 * r_pcrel;
- /* FIXME-soon: Roll baserel, jmptable, relative bits into howto setting */
-
- /* This macro uses the r_index value computed above */
- if (r_pcrel && r_extern)
- {
- /* The GNU linker assumes any offset from beginning of section */
- /* is already incorporated into the image while the HP linker */
- /* adds this in later. Add it in now... */
- MOVE_ADDRESS (-cache_ptr->address);
- }
- else
- {
- MOVE_ADDRESS (0);
- }
-}
-
-boolean
-MY (slurp_reloc_table) (abfd, asect, symbols)
- bfd *abfd;
- sec_ptr asect;
- asymbol **symbols;
-{
- unsigned int count;
- bfd_size_type reloc_size;
- PTR relocs;
- arelent *reloc_cache;
- size_t each_size;
- struct hp300hpux_reloc *rptr;
- unsigned int counter;
- arelent *cache_ptr;
-
- 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_set_error (bfd_error_invalid_operation);
- return false;
-
-doit:
- if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
- return false;
- 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 && count != 0)
- return false;
-
- relocs = (PTR) bfd_alloc (abfd, reloc_size);
- if (!relocs && reloc_size != 0)
- {
- bfd_release (abfd, reloc_cache);
- return false;
- }
-
- if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
- {
- bfd_release (abfd, relocs);
- bfd_release (abfd, reloc_cache);
- return false;
- }
-
- rptr = (struct hp300hpux_reloc *) relocs;
- counter = 0;
- cache_ptr = reloc_cache;
-
- for (; counter < count; counter++, rptr++, cache_ptr++)
- {
- MY (swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
- }
-
-
- bfd_release (abfd, relocs);
- asect->relocation = reloc_cache;
- asect->reloc_count = count;
- return true;
-}
-
-
-/************************************************************************/
-/* The following functions are identical to functions in aoutx.h except */
-/* they refer to MY(func) rather than NAME(aout,func) and they also */
-/* call aout_32 versions if the input file was generated by gcc */
-/************************************************************************/
-
-long aout_32_get_symtab PARAMS ((bfd * abfd, asymbol ** location));
-long aout_32_get_symtab_upper_bound PARAMS ((bfd * abfd));
-
-long aout_32_canonicalize_reloc PARAMS ((bfd * abfd, sec_ptr section,
- arelent ** relptr,
- asymbol ** symbols));
-
-long
-MY (get_symtab) (abfd, location)
- bfd *abfd;
- asymbol **location;
-{
- unsigned int counter = 0;
- aout_symbol_type *symbase;
-
- if (obj_aout_subformat (abfd) == gnu_encap_format)
- return aout_32_get_symtab (abfd, location);
-
- if (!MY (slurp_symbol_table) (abfd))
- return -1;
-
- for (symbase = obj_aout_symbols (abfd); counter++ < bfd_get_symcount (abfd);)
- *(location++) = (asymbol *) (symbase++);
- *location++ = 0;
- return bfd_get_symcount (abfd);
-}
-
-long
-MY (get_symtab_upper_bound) (abfd)
- bfd *abfd;
-{
- if (obj_aout_subformat (abfd) == gnu_encap_format)
- return aout_32_get_symtab_upper_bound (abfd);
- if (!MY (slurp_symbol_table) (abfd))
- return -1;
-
- return (bfd_get_symcount (abfd) + 1) * (sizeof (aout_symbol_type *));
-}
-
-
-
-
-long
-MY (canonicalize_reloc) (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr = section->relocation;
- unsigned int count;
- if (obj_aout_subformat (abfd) == gnu_encap_format)
- return aout_32_canonicalize_reloc (abfd, section, relptr, symbols);
-
- if (!(tblptr || MY (slurp_reloc_table) (abfd, section, symbols)))
- return -1;
-
- 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;
-
- for (count = 0; count++ < section->reloc_count;)
- {
- *relptr++ = tblptr++;
- }
- }
- *relptr = 0;
-
- return section->reloc_count;
-}
-
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/hppa_stubs.h b/contrib/gdb/bfd/hppa_stubs.h
deleted file mode 100644
index ee893e8..0000000
--- a/contrib/gdb/bfd/hppa_stubs.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* HPPA linker stub instructions */
-
-/* These are the instructions which the linker may insert into the
- code stream when building final executables to handle out-of-range
- calls and argument relocations. */
-
-#define LDO_M4_R31_R31 0x37ff3ff9 /* ldo -4(%r31),%r31 */
-#define LDIL_R1 0x20200000 /* ldil XXX,%r1 */
-#define BE_SR4_R1 0xe0202000 /* be XXX(%sr4,%r1) */
-#define COPY_R31_R2 0x081f0242 /* copy %r31,%r2 */
-#define BLE_SR4_R0 0xe4002000 /* ble XXX(%sr4,%r0) */
-#define BLE_SR4_R1 0xe4202000 /* ble XXX(%sr4,%r1) */
-#define BV_N_0_R31 0xebe0c002 /* bv,n 0(%r31) */
-#define STW_R31_M8R30 0x6bdf3ff1 /* stw %r31,-8(%r30) */
-#define LDW_M8R30_R31 0x4bdf3ff1 /* ldw -8(%r30),%r31 */
-#define STW_ARG_M16R30 0x6bc03fe1 /* stw %argX,-16(%r30) */
-#define LDW_M16R30_ARG 0x4bc03fe1 /* ldw -12(%r30),%argX */
-#define STW_ARG_M12R30 0x6bc03fe9 /* stw %argX,-16(%r30) */
-#define LDW_M12R30_ARG 0x4bc03fe9 /* ldw -12(%r30),%argX */
-#define FSTW_FARG_M16R30 0x27c11200 /* fstws %fargX,-16(%r30) */
-#define FLDW_M16R30_FARG 0x27c11000 /* fldws -16(%r30),%fargX */
-#define FSTD_FARG_M16R30 0x2fc11200 /* fstds %fargX,-16(%r30) */
-#define FLDD_M16R30_FARG 0x2fc11000 /* fldds -16(%r30),%fargX */
diff --git a/contrib/gdb/bfd/hppabsd-core.c b/contrib/gdb/bfd/hppabsd-core.c
deleted file mode 100644
index a76ecc5..0000000
--- a/contrib/gdb/bfd/hppabsd-core.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/* BFD back-end for HPPA BSD core files.
- Copyright 1993, 1994 Free Software Foundation, Inc.
-
- This file is part of BFD, the Binary File Descriptor library.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Written by the Center for Software Science at the University of Utah
- and by Cygnus Support.
-
- The core file structure for the Utah 4.3BSD and OSF1 ports on the
- PA is a mix between traditional cores and hpux cores -- just
- different enough that supporting this format would tend to add
- gross hacks to trad-core.c or hpux-core.c. So instead we keep any
- gross hacks isolated to this file. */
-
-
-/* This file can only be compiled on systems which use HPPA-BSD style
- core files.
-
- I would not expect this to be of use to any other host/target, but
- you never know. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#if defined (HOST_HPPABSD)
-
-#include "machine/vmparam.h"
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <machine/reg.h>
-#include <sys/user.h> /* After a.out.h */
-#include <sys/file.h>
-#include <errno.h>
-
-static asection *make_bfd_asection PARAMS ((bfd *, CONST char *,
- flagword, bfd_size_type,
- file_ptr, unsigned int));
-static asymbol *hppabsd_core_make_empty_symbol PARAMS ((bfd *));
-static const bfd_target *hppabsd_core_core_file_p PARAMS ((bfd *));
-static char *hppabsd_core_core_file_failing_command PARAMS ((bfd *));
-static int hppabsd_core_core_file_failing_signal PARAMS ((bfd *));
-static boolean hppabsd_core_core_file_matches_executable_p
- PARAMS ((bfd *, bfd *));
-static void swap_abort PARAMS ((void));
-
-/* These are stored in the bfd's tdata. */
-
-struct hppabsd_core_struct
- {
- int sig;
- char cmd[MAXCOMLEN + 1];
- asection *data_section;
- asection *stack_section;
- asection *reg_section;
- };
-
-#define core_hdr(bfd) ((bfd)->tdata.hppabsd_core_data)
-#define core_signal(bfd) (core_hdr(bfd)->sig)
-#define core_command(bfd) (core_hdr(bfd)->cmd)
-#define core_datasec(bfd) (core_hdr(bfd)->data_section)
-#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
-#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
-
-static asection *
-make_bfd_asection (abfd, name, flags, _raw_size, offset, alignment_power)
- bfd *abfd;
- CONST char *name;
- flagword flags;
- bfd_size_type _raw_size;
- file_ptr offset;
- unsigned int alignment_power;
-{
- asection *asect;
-
- asect = bfd_make_section (abfd, name);
- if (!asect)
- return NULL;
-
- asect->flags = flags;
- asect->_raw_size = _raw_size;
- asect->filepos = offset;
- asect->alignment_power = alignment_power;
-
- return asect;
-}
-
-static asymbol *
-hppabsd_core_make_empty_symbol (abfd)
- bfd *abfd;
-{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
- if (new)
- new->the_bfd = abfd;
- return new;
-}
-
-static const bfd_target *
-hppabsd_core_core_file_p (abfd)
- bfd *abfd;
-{
- int val;
- struct user u;
- struct hppabsd_core_struct *coredata;
- int clicksz;
-
- /* Try to read in the u-area. We will need information from this
- to know how to grok the rest of the core structures. */
- val = bfd_read ((void *) &u, 1, sizeof u, abfd);
- if (val != sizeof u)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* Get the page size out of the u structure. This will be different
- for PA 1.0 machines and PA 1.1 machines. Yuk! */
- clicksz = u.u_pcb.pcb_pgsz;
-
- /* clicksz must be a power of two >= 2k. */
- if (clicksz < 0x800
- || clicksz != (clicksz & -clicksz))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
-
- /* Sanity checks. Make sure the size of the core file matches the
- the size computed from information within the core itself. */
- {
- FILE *stream = bfd_cache_lookup (abfd);
- struct stat statbuf;
- if (stream == NULL || fstat (fileno (stream), &statbuf) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return NULL;
- }
- if (NBPG * (UPAGES + u.u_dsize + u.u_ssize) > statbuf.st_size)
- {
- bfd_set_error (bfd_error_file_truncated);
- return NULL;
- }
- if (clicksz * (UPAGES + u.u_dsize + u.u_ssize) < statbuf.st_size)
- {
- /* The file is too big. Maybe it's not a core file
- or we otherwise have bad values for u_dsize and u_ssize). */
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
- }
-
- /* OK, we believe you. You're a core file (sure, sure). */
-
- coredata = (struct hppabsd_core_struct *)
- bfd_zalloc (abfd, sizeof (struct hppabsd_core_struct));
- if (!coredata)
- return NULL;
-
- /* Make the core data and available via the tdata part of the BFD. */
- abfd->tdata.hppabsd_core_data = coredata;
-
- /* Create the sections. */
- core_stacksec (abfd) = make_bfd_asection (abfd, ".stack",
- SEC_ALLOC + SEC_HAS_CONTENTS,
- clicksz * u.u_ssize,
- NBPG * (USIZE + KSTAKSIZE)
- + clicksz * u.u_dsize, 2);
- core_stacksec (abfd)->vma = USRSTACK;
-
- core_datasec (abfd) = make_bfd_asection (abfd, ".data",
- SEC_ALLOC + SEC_LOAD
- + SEC_HAS_CONTENTS,
- clicksz * u.u_dsize,
- NBPG * (USIZE + KSTAKSIZE), 2);
- core_datasec (abfd)->vma = UDATASEG;
-
- core_regsec (abfd) = make_bfd_asection (abfd, ".reg",
- SEC_HAS_CONTENTS,
- KSTAKSIZE * NBPG,
- NBPG * USIZE, 2);
- core_regsec (abfd)->vma = 0;
-
- strncpy (core_command (abfd), u.u_comm, MAXCOMLEN + 1);
- core_signal (abfd) = u.u_code;
- return abfd->xvec;
-}
-
-static char *
-hppabsd_core_core_file_failing_command (abfd)
- bfd *abfd;
-{
- return core_command (abfd);
-}
-
-/* ARGSUSED */
-static int
-hppabsd_core_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return core_signal (abfd);
-}
-
-/* ARGSUSED */
-static boolean
-hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- /* There's no way to know this... */
- return true;
-}
-
-
-#define hppabsd_core_get_symtab_upper_bound \
- _bfd_nosymbols_get_symtab_upper_bound
-#define hppabsd_core_get_symtab _bfd_nosymbols_get_symtab
-#define hppabsd_core_print_symbol _bfd_nosymbols_print_symbol
-#define hppabsd_core_get_symbol_info _bfd_nosymbols_get_symbol_info
-#define hppabsd_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
-#define hppabsd_core_get_lineno _bfd_nosymbols_get_lineno
-#define hppabsd_core_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define hppabsd_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define hppabsd_core_read_minisymbols _bfd_nosymbols_read_minisymbols
-#define hppabsd_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
-
-/* If somebody calls any byte-swapping routines, shoot them. */
-static void
-swap_abort ()
-{
- /* This way doesn't require any declaration for ANSI to fuck up. */
- abort ();
-}
-
-#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
-#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
-#define NO_SIGNED_GET \
- ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-
-const bfd_target hppabsd_core_vec =
- {
- "hppabsd-core",
- bfd_target_unknown_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIAN_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* symbol prefix */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
-
- { /* bfd_check_format */
- _bfd_dummy_target, /* unknown format */
- _bfd_dummy_target, /* object file */
- _bfd_dummy_target, /* archive */
- hppabsd_core_core_file_p /* a core file */
- },
- { /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
- { /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (hppabsd_core),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (hppabsd_core),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0 /* backend_data */
-};
-#endif
diff --git a/contrib/gdb/bfd/hpux-core.c b/contrib/gdb/bfd/hpux-core.c
deleted file mode 100644
index 675a5f8..0000000
--- a/contrib/gdb/bfd/hpux-core.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/* BFD back-end for HP/UX core files.
- Copyright 1993, 1994 Free Software Foundation, Inc.
- Written by Stu Grossman, Cygnus Support.
- Converted to back-end form by Ian Lance Taylor, Cygnus SUpport
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file can only be compiled on systems which use HP/UX style
- core files. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#if defined (HOST_HPPAHPUX) || defined (HOST_HP300HPUX)
-
-/* FIXME: sys/core.h doesn't exist for HPUX version 7. HPUX version
- 5, 6, and 7 core files seem to be standard trad-core.c type core
- files; can we just use trad-core.c in addition to this file? */
-
-#include <sys/core.h>
-#include <sys/utsname.h>
-
-#endif /* HOST_HPPAHPUX */
-
-#ifdef HOST_HPPABSD
-
-/* Not a very swift place to put it, but that's where the BSD port
- puts them. */
-#include "/hpux/usr/include/sys/core.h"
-
-#endif /* HOST_HPPABSD */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <machine/reg.h>
-#include <sys/user.h> /* After a.out.h */
-#include <sys/file.h>
-#include <errno.h>
-
-/* These are stored in the bfd's tdata */
-
-struct hpux_core_struct
-{
- int sig;
- char cmd[MAXCOMLEN + 1];
-};
-
-#define core_hdr(bfd) ((bfd)->tdata.hpux_core_data)
-#define core_signal(bfd) (core_hdr(bfd)->sig)
-#define core_command(bfd) (core_hdr(bfd)->cmd)
-
-static asection *
-make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power)
- bfd *abfd;
- CONST char *name;
- flagword flags;
- bfd_size_type _raw_size;
- bfd_vma vma;
- unsigned int alignment_power;
-{
- asection *asect;
-
- asect = bfd_make_section_anyway (abfd, name);
- if (!asect)
- return NULL;
-
- asect->flags = flags;
- asect->_raw_size = _raw_size;
- asect->vma = vma;
- asect->filepos = bfd_tell (abfd);
- asect->alignment_power = alignment_power;
-
- return asect;
-}
-
-static asymbol *
-hpux_core_make_empty_symbol (abfd)
- bfd *abfd;
-{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
- if (new)
- new->the_bfd = abfd;
- return new;
-}
-
-static const bfd_target *
-hpux_core_core_file_p (abfd)
- bfd *abfd;
-{
- core_hdr (abfd) = (struct hpux_core_struct *)
- bfd_zalloc (abfd, sizeof (struct hpux_core_struct));
- if (!core_hdr (abfd))
- return NULL;
-
- while (1)
- {
- int val;
- struct corehead core_header;
-
- val = bfd_read ((void *) &core_header, 1, sizeof core_header, abfd);
- if (val <= 0)
- break;
- switch (core_header.type)
- {
- case CORE_KERNEL:
- case CORE_FORMAT:
- bfd_seek (abfd, core_header.len, SEEK_CUR); /* Just skip this */
- break;
- case CORE_EXEC:
- {
- struct proc_exec proc_exec;
- if (bfd_read ((void *) &proc_exec, 1, core_header.len, abfd)
- != core_header.len)
- break;
- strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1);
- }
- break;
- case CORE_PROC:
- {
- struct proc_info proc_info;
- if (!make_bfd_asection (abfd, ".reg",
- SEC_HAS_CONTENTS,
- core_header.len,
- (int) &proc_info - (int) & proc_info.hw_regs,
- 2))
- return NULL;
-
- if (bfd_read (&proc_info, 1, core_header.len, abfd)
- != core_header.len)
- break;
- core_signal (abfd) = proc_info.sig;
- }
- break;
-
- case CORE_DATA:
- case CORE_STACK:
- case CORE_TEXT:
- case CORE_MMF:
- case CORE_SHM:
- if (!make_bfd_asection (abfd, ".data",
- SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
- core_header.len, core_header.addr, 2))
- return NULL;
-
- bfd_seek (abfd, core_header.len, SEEK_CUR);
- break;
-
- default:
- /* Falling into here is an error and should prevent this
- target from matching. That way systems which use hpux
- cores along with other formats can still work. */
- return 0;
- }
- }
-
- /* OK, we believe you. You're a core file (sure, sure). */
-
- return abfd->xvec;
-}
-
-static char *
-hpux_core_core_file_failing_command (abfd)
- bfd *abfd;
-{
- return core_command (abfd);
-}
-
-/* ARGSUSED */
-static int
-hpux_core_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return core_signal (abfd);
-}
-
-/* ARGSUSED */
-static boolean
-hpux_core_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 */
-}
-
-#define hpux_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
-#define hpux_core_get_symtab _bfd_nosymbols_get_symtab
-#define hpux_core_print_symbol _bfd_nosymbols_print_symbol
-#define hpux_core_get_symbol_info _bfd_nosymbols_get_symbol_info
-#define hpux_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
-#define hpux_core_get_lineno _bfd_nosymbols_get_lineno
-#define hpux_core_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define hpux_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define hpux_core_read_minisymbols _bfd_nosymbols_read_minisymbols
-#define hpux_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
-
-/* 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 ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
-#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
-#define NO_SIGNED_GET \
- ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-
-const bfd_target hpux_core_vec =
- {
- "hpux-core",
- bfd_target_unknown_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIAN_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* symbol prefix */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
-
- { /* bfd_check_format */
- _bfd_dummy_target, /* unknown format */
- _bfd_dummy_target, /* object file */
- _bfd_dummy_target, /* archive */
- hpux_core_core_file_p /* a core file */
- },
- { /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
- { /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (hpux_core),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (hpux_core),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0 /* backend_data */
-};
diff --git a/contrib/gdb/bfd/i386dynix.c b/contrib/gdb/bfd/i386dynix.c
deleted file mode 100644
index ff50a14..0000000
--- a/contrib/gdb/bfd/i386dynix.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* BFD back-end for i386 a.out binaries under dynix.
- Copyright (C) 1994, 1995 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This BFD is currently only tested with gdb, writing object files
- may not work. */
-
-#define BYTES_IN_WORD 4
-
-#define TEXT_START_ADDR 4096
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-
-#include "aout/dynix3.h"
-
-#define DEFAULT_ARCH bfd_arch_i386
-#define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(i386dynix_,OP)
-#define TARGETNAME "a.out-i386-dynix"
-#define NAME(x,y) CAT3(i386dynix,_32_,y)
-#define ARCH_SIZE 32
-#define NAME_swap_exec_header_in NAME(i386dynix_32_,swap_exec_header_in)
-#define MY_get_section_contents aout_32_get_section_contents
-
-/* aoutx.h requires definitions for NMAGIC, BMAGIC and QMAGIC. */
-#define NMAGIC 0
-#define BMAGIC OMAGIC
-#define QMAGIC XMAGIC
-
-#include "aoutx.h"
-
-/* (Ab)use some fields in the internal exec header to be able to read
- executables that contain shared data. */
-
-#define a_shdata a_tload
-#define a_shdrsize a_dload
-
-void
-i386dynix_32_swap_exec_header_in (abfd, raw_bytes, execp)
- bfd *abfd;
- struct external_exec *raw_bytes;
- struct internal_exec *execp;
-{
- struct external_exec *bytes = (struct external_exec *)raw_bytes;
-
- /* The internal_exec structure has some fields that are unused in this
- configuration (IE for i960), so ensure that all such uninitialized
- fields are zero'd out. There are places where two of these structs
- are memcmp'd, and thus the contents do matter. */
- memset ((PTR) execp, 0, sizeof (struct internal_exec));
- /* 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_shdata = GET_WORD (abfd, bytes->e_shdata);
- execp->a_shdrsize = GET_WORD (abfd, bytes->e_shdrsize);
-}
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/i386linux.c b/contrib/gdb/bfd/i386linux.c
deleted file mode 100644
index a45f97c..0000000
--- a/contrib/gdb/bfd/i386linux.c
+++ /dev/null
@@ -1,762 +0,0 @@
-/* BFD back-end for linux flavored i386 a.out binaries.
- Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_PAGE_SIZE 4096
-#define ZMAGIC_DISK_BLOCK_SIZE 1024
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define TEXT_START_ADDR 0x0
-#define N_SHARED_LIB(x) 0
-#define BYTES_IN_WORD 4
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-#define DEFAULT_ARCH bfd_arch_i386
-#define MY(OP) CAT(i386linux_,OP)
-#define TARGETNAME "a.out-i386-linux"
-
-extern const bfd_target MY(vec);
-
-/* We always generate QMAGIC files in preference to ZMAGIC files. It
- would be possible to make this a linker option, if that ever
- becomes important. */
-
-static void MY_final_link_callback
- PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
-
-static boolean
-i386linux_bfd_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- obj_aout_subformat (abfd) = q_magic_format;
- return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
-}
-
-#define MY_bfd_final_link i386linux_bfd_final_link
-
-/* Set the machine type correctly. */
-
-static boolean
-i386linux_write_object_contents (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
- N_SET_MACHTYPE (*execp, M_386);
-
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
-
-#define MY_write_object_contents i386linux_write_object_contents
-
-/* Code to link against Linux a.out shared libraries. */
-
-/* See if a symbol name is a reference to the global offset table. */
-
-#ifndef GOT_REF_PREFIX
-#define GOT_REF_PREFIX "__GOT_"
-#endif
-
-#define IS_GOT_SYM(name) \
- (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0)
-
-/* See if a symbol name is a reference to the procedure linkage table. */
-
-#ifndef PLT_REF_PREFIX
-#define PLT_REF_PREFIX "__PLT_"
-#endif
-
-#define IS_PLT_SYM(name) \
- (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0)
-
-/* This string is used to generate specialized error messages. */
-
-#ifndef NEEDS_SHRLIB
-#define NEEDS_SHRLIB "__NEEDS_SHRLIB_"
-#endif
-
-/* This special symbol is a set vector that contains a list of
- pointers to fixup tables. It will be present in any dynamicly
- linked file. The linker generated fixup table should also be added
- to the list, and it should always appear in the second slot (the
- first one is a dummy with a magic number that is defined in
- crt0.o). */
-
-#ifndef SHARABLE_CONFLICTS
-#define SHARABLE_CONFLICTS "__SHARABLE_CONFLICTS__"
-#endif
-
-/* We keep a list of fixups. The terminology is a bit strange, but
- each fixup contains two 32 bit numbers. A regular fixup contains
- an address and a pointer, and at runtime we should store the
- address at the location pointed to by the pointer. A builtin fixup
- contains two pointers, and we should read the address using one
- pointer and store it at the location pointed to by the other
- pointer. Builtin fixups come into play when we have duplicate
- __GOT__ symbols for the same variable. The builtin fixup will copy
- the GOT pointer from one over into the other. */
-
-struct fixup
-{
- struct fixup *next;
- struct linux_link_hash_entry *h;
- bfd_vma value;
-
- /* Nonzero if this is a jump instruction that needs to be fixed,
- zero if this is just a pointer */
- char jump;
-
- char builtin;
-};
-
-/* We don't need a special hash table entry structure, but we do need
- to keep some information between linker passes, so we use a special
- hash table. */
-
-struct linux_link_hash_entry
-{
- struct aout_link_hash_entry root;
-};
-
-struct linux_link_hash_table
-{
- struct aout_link_hash_table root;
-
- /* First dynamic object found in link. */
- bfd *dynobj;
-
- /* Number of fixups. */
- size_t fixup_count;
-
- /* Number of builtin fixups. */
- size_t local_builtins;
-
- /* List of fixups. */
- struct fixup *fixup_list;
-};
-
-static struct bfd_hash_entry *linux_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *linux_link_hash_table_create
- PARAMS ((bfd *));
-static struct fixup *new_fixup
- PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
- bfd_vma, int));
-static boolean linux_link_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean linux_add_one_symbol
- PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
- bfd_vma, const char *, boolean, boolean,
- struct bfd_link_hash_entry **));
-static boolean linux_tally_symbols
- PARAMS ((struct linux_link_hash_entry *, PTR));
-static boolean linux_finish_dynamic_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Routine to create an entry in an Linux link hash table. */
-
-static struct bfd_hash_entry *
-linux_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct linux_link_hash_entry *) NULL)
- ret = ((struct linux_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
- if (ret == NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct linux_link_hash_entry *)
- NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != NULL)
- {
- /* Set local fields; there aren't any. */
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create a Linux link hash table. */
-
-static struct bfd_link_hash_table *
-linux_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct linux_link_hash_table *ret;
-
- ret = ((struct linux_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
- if (ret == (struct linux_link_hash_table *) NULL)
- return (struct bfd_link_hash_table *) NULL;
- if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
- linux_link_hash_newfunc))
- {
- free (ret);
- return (struct bfd_link_hash_table *) NULL;
- }
-
- ret->dynobj = NULL;
- ret->fixup_count = 0;
- ret->local_builtins = 0;
- ret->fixup_list = NULL;
-
- return &ret->root.root;
-}
-
-/* Look up an entry in a Linux link hash table. */
-
-#define linux_link_hash_lookup(table, string, create, copy, follow) \
- ((struct linux_link_hash_entry *) \
- aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
- (follow)))
-
-/* Traverse a Linux link hash table. */
-
-#define linux_link_hash_traverse(table, func, info) \
- (aout_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the Linux link hash table from the info structure. This is
- just a cast. */
-
-#define linux_hash_table(p) ((struct linux_link_hash_table *) ((p)->hash))
-
-/* Store the information for a new fixup. */
-
-static struct fixup *
-new_fixup (info, h, value, builtin)
- struct bfd_link_info *info;
- struct linux_link_hash_entry *h;
- bfd_vma value;
- int builtin;
-{
- struct fixup *f;
-
- f = (struct fixup *) bfd_hash_allocate (&info->hash->table,
- sizeof (struct fixup));
- if (f == NULL)
- return f;
- f->next = linux_hash_table (info)->fixup_list;
- linux_hash_table (info)->fixup_list = f;
- f->h = h;
- f->value = value;
- f->builtin = builtin;
- f->jump = 0;
- ++linux_hash_table (info)->fixup_count;
- return f;
-}
-
-/* We come here once we realize that we are going to link to a shared
- library. We need to create a special section that contains the
- fixup table, and we ultimately need to add a pointer to this into
- the set vector for SHARABLE_CONFLICTS. At this point we do not
- know the size of the section, but that's OK - we just need to
- create it for now. */
-
-static boolean
-linux_link_create_dynamic_sections (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- flagword flags;
- register asection *s;
-
- /* Note that we set the SEC_IN_MEMORY flag. */
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- /* We choose to use the name ".linux-dynamic" for the fixup table.
- Why not? */
- s = bfd_make_section (abfd, ".linux-dynamic");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
- s->_raw_size = 0;
- s->contents = 0;
-
- return true;
-}
-
-/* Function to add a single symbol to the linker hash table. This is
- a wrapper around _bfd_generic_link_add_one_symbol which handles the
- tweaking needed for dynamic linking support. */
-
-static boolean
-linux_add_one_symbol (info, abfd, name, flags, section, value, string,
- copy, collect, hashp)
- struct bfd_link_info *info;
- bfd *abfd;
- const char *name;
- flagword flags;
- asection *section;
- bfd_vma value;
- const char *string;
- boolean copy;
- boolean collect;
- struct bfd_link_hash_entry **hashp;
-{
- struct linux_link_hash_entry *h;
- boolean insert;
-
- /* Look up and see if we already have this symbol in the hash table.
- If we do, and the defining entry is from a shared library, we
- need to create the dynamic sections.
-
- FIXME: What if abfd->xvec != info->hash->creator? We may want to
- be able to link Linux a.out and ELF objects together, but serious
- confusion is possible. */
-
- insert = false;
-
- if (! info->relocateable
- && linux_hash_table (info)->dynobj == NULL
- && strcmp (name, SHARABLE_CONFLICTS) == 0
- && (flags & BSF_CONSTRUCTOR) != 0
- && abfd->xvec == info->hash->creator)
- {
- if (! linux_link_create_dynamic_sections (abfd, info))
- return false;
- linux_hash_table (info)->dynobj = abfd;
- insert = true;
- }
-
- if (bfd_is_abs_section (section)
- && abfd->xvec == info->hash->creator)
- {
- h = linux_link_hash_lookup (linux_hash_table (info), name, false,
- false, false);
- if (h != NULL
- && (h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak))
- {
- struct fixup *f;
-
- if (hashp != NULL)
- *hashp = (struct bfd_link_hash_entry *) h;
-
- f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
- if (f == NULL)
- return false;
- f->jump = IS_PLT_SYM (name);
-
- return true;
- }
- }
-
- /* Do the usual procedure for adding a symbol. */
- if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
- value, string, copy, collect,
- hashp))
- return false;
-
- /* Insert a pointer to our table in the set vector. The dynamic
- linker requires this information */
- if (insert)
- {
- asection *s;
-
- /* Here we do our special thing to add the pointer to the
- dynamic section in the SHARABLE_CONFLICTS set vector. */
- s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
- ".linux-dynamic");
- BFD_ASSERT (s != NULL);
-
- if (! (_bfd_generic_link_add_one_symbol
- (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
- BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
- return false;
- }
-
- return true;
-}
-
-/* We will crawl the hash table and come here for every global symbol.
- We will examine each entry and see if there are indications that we
- need to add a fixup. There are two possible cases - one is where
- you have duplicate definitions of PLT or GOT symbols - these will
- have already been caught and added as "builtin" fixups. If we find
- that the corresponding non PLT/GOT symbol is also present, we
- convert it to a regular fixup instead.
-
- This function is called via linux_link_hash_traverse. */
-
-static boolean
-linux_tally_symbols (h, data)
- struct linux_link_hash_entry *h;
- PTR data;
-{
- struct bfd_link_info *info = (struct bfd_link_info *) data;
- struct fixup *f, *f1;
- int is_plt;
- struct linux_link_hash_entry *h1, *h2;
- boolean exists;
-
- if (h->root.root.type == bfd_link_hash_undefined
- && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
- sizeof NEEDS_SHRLIB - 1) == 0)
- {
- const char *name;
- char *p;
- char *alloc = NULL;
-
- name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
- p = strrchr (name, '_');
- if (p != NULL)
- alloc = (char *) bfd_malloc (strlen (name) + 1);
-
- if (p == NULL || alloc == NULL)
- (*_bfd_error_handler) ("Output file requires shared library `%s'\n",
- name);
- else
- {
- strcpy (alloc, name);
- p = strrchr (alloc, '_');
- *p++ = '\0';
- (*_bfd_error_handler)
- ("Output file requires shared library `%s.so.%s'\n",
- alloc, p);
- free (alloc);
- }
-
- abort ();
- }
-
- /* If this symbol is not a PLT/GOT, we do not even need to look at it */
- is_plt = IS_PLT_SYM (h->root.root.root.string);
-
- if (is_plt || IS_GOT_SYM (h->root.root.root.string))
- {
- /* Look up this symbol twice. Once just as a regular lookup,
- and then again following all of the indirect links until we
- reach a real symbol. */
- h1 = linux_link_hash_lookup (linux_hash_table (info),
- (h->root.root.root.string
- + sizeof PLT_REF_PREFIX - 1),
- false, false, true);
- /* h2 does not follow indirect symbols. */
- h2 = linux_link_hash_lookup (linux_hash_table (info),
- (h->root.root.root.string
- + sizeof PLT_REF_PREFIX - 1),
- false, false, false);
-
- /* The real symbol must exist but if it is also an ABS symbol,
- there is no need to have a fixup. This is because they both
- came from the same library. If on the other hand, we had to
- use an indirect symbol to get to the real symbol, we add the
- fixup anyway, since there are cases where these symbols come
- from different shared libraries */
- if (h1 != NULL
- && (((h1->root.root.type == bfd_link_hash_defined
- || h1->root.root.type == bfd_link_hash_defweak)
- && ! bfd_is_abs_section (h1->root.root.u.def.section))
- || h2->root.root.type == bfd_link_hash_indirect))
- {
- /* See if there is a "builtin" fixup already present
- involving this symbol. If so, convert it to a regular
- fixup. In the end, this relaxes some of the requirements
- about the order of performing fixups. */
- exists = false;
- for (f1 = linux_hash_table (info)->fixup_list;
- f1 != NULL;
- f1 = f1->next)
- {
- if ((f1->h != h && f1->h != h1)
- || (! f1->builtin && ! f1->jump))
- continue;
- if (f1->h == h1)
- exists = true;
- if (! exists
- && bfd_is_abs_section (h->root.root.u.def.section))
- {
- f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
- f->jump = is_plt;
- }
- f1->h = h1;
- f1->jump = is_plt;
- f1->builtin = 0;
- exists = true;
- }
- if (! exists
- && bfd_is_abs_section (h->root.root.u.def.section))
- {
- f = new_fixup (info, h1, h->root.root.u.def.value, 0);
- if (f == NULL)
- {
- /* FIXME: No way to return error. */
- abort ();
- }
- f->jump = is_plt;
- }
- }
-
- /* Quick and dirty way of stripping these symbols from the
- symtab. */
- if (bfd_is_abs_section (h->root.root.u.def.section))
- h->root.written = true;
- }
-
- return true;
-}
-
-/* This is called to set the size of the .linux-dynamic section is.
- It is called by the Linux linker emulation before_allocation
- routine. We have finished reading all of the input files, and now
- we just scan the hash tables to find out how many additional fixups
- are required. */
-
-boolean
-bfd_i386linux_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- struct fixup *f;
- asection *s;
-
- if (output_bfd->xvec != &MY(vec))
- return true;
-
- /* First find the fixups... */
- linux_link_hash_traverse (linux_hash_table (info),
- linux_tally_symbols,
- (PTR) info);
-
- /* If there are builtin fixups, leave room for a marker. This is
- used by the dynamic linker so that it knows that all that follow
- are builtin fixups instead of regular fixups. */
- for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
- {
- if (f->builtin)
- {
- ++linux_hash_table (info)->fixup_count;
- ++linux_hash_table (info)->local_builtins;
- break;
- }
- }
-
- if (linux_hash_table (info)->dynobj == NULL)
- {
- if (linux_hash_table (info)->fixup_count > 0)
- abort ();
- return true;
- }
-
- /* Allocate memory for our fixup table. We will fill it in later. */
- s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
- ".linux-dynamic");
- if (s != NULL)
- {
- s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
- if (s->contents == NULL)
- return false;
- memset (s->contents, 0, (size_t) s->_raw_size);
- }
-
- return true;
-}
-
-/* We come here once we are ready to actually write the fixup table to
- the output file. Scan the fixup tables and so forth and generate
- the stuff we need. */
-
-static boolean
-linux_finish_dynamic_link (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- asection *s, *os, *is;
- bfd_byte *fixup_table;
- struct linux_link_hash_entry *h;
- struct fixup *f;
- unsigned int new_addr;
- int section_offset;
- unsigned int fixups_written;
-
- if (linux_hash_table (info)->dynobj == NULL)
- return true;
-
- s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
- ".linux-dynamic");
- BFD_ASSERT (s != NULL);
- os = s->output_section;
- fixups_written = 0;
-
-#ifdef LINUX_LINK_DEBUG
- printf ("Fixup table file offset: %x VMA: %x\n",
- os->filepos + s->output_offset,
- os->vma + s->output_offset);
-#endif
-
- fixup_table = s->contents;
- bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
- fixup_table += 4;
-
- /* Fill in fixup table. */
- for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
- {
- if (f->builtin)
- continue;
-
- if (f->h->root.root.type != bfd_link_hash_defined
- && f->h->root.root.type != bfd_link_hash_defweak)
- {
- (*_bfd_error_handler)
- ("Symbol %s not defined for fixups\n",
- f->h->root.root.root.string);
- continue;
- }
-
- is = f->h->root.root.u.def.section;
- section_offset = is->output_section->vma + is->output_offset;
- new_addr = f->h->root.root.u.def.value + section_offset;
-
-#ifdef LINUX_LINK_DEBUG
- printf ("Fixup(%d) %s: %x %x\n",f->jump, f->h->root.root.string,
- new_addr, f->value);
-#endif
-
- if (f->jump)
- {
- /* Relative address */
- new_addr = new_addr - (f->value + 5);
- bfd_put_32 (output_bfd, new_addr, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, f->value + 1, fixup_table);
- fixup_table += 4;
- }
- else
- {
- bfd_put_32 (output_bfd, new_addr, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, f->value, fixup_table);
- fixup_table += 4;
- }
- ++fixups_written;
- }
-
- if (linux_hash_table (info)->local_builtins != 0)
- {
- /* Special marker so we know to switch to the other type of fixup */
- bfd_put_32 (output_bfd, 0, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
- fixup_table += 4;
- ++fixups_written;
- for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
- {
- if (! f->builtin)
- continue;
-
- if (f->h->root.root.type != bfd_link_hash_defined
- && f->h->root.root.type != bfd_link_hash_defweak)
- {
- (*_bfd_error_handler)
- ("Symbol %s not defined for fixups\n",
- f->h->root.root.root.string);
- continue;
- }
-
- is = f->h->root.root.u.def.section;
- section_offset = is->output_section->vma + is->output_offset;
- new_addr = f->h->root.root.u.def.value + section_offset;
-
-#ifdef LINUX_LINK_DEBUG
- printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
- new_addr, f->value);
-#endif
-
- bfd_put_32 (output_bfd, new_addr, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, f->value, fixup_table);
- fixup_table += 4;
- ++fixups_written;
- }
- }
-
- if (linux_hash_table (info)->fixup_count != fixups_written)
- {
- (*_bfd_error_handler) ("Warning: fixup count mismatch\n");
- while (linux_hash_table (info)->fixup_count > fixups_written)
- {
- bfd_put_32 (output_bfd, 0, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
- fixup_table += 4;
- ++fixups_written;
- }
- }
-
- h = linux_link_hash_lookup (linux_hash_table (info),
- "__BUILTIN_FIXUPS__",
- false, false, false);
-
- if (h != NULL
- && (h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak))
- {
- is = h->root.root.u.def.section;
- section_offset = is->output_section->vma + is->output_offset;
- new_addr = h->root.root.u.def.value + section_offset;
-
-#ifdef LINUX_LINK_DEBUG
- printf ("Builtin fixup table at %x\n", new_addr);
-#endif
-
- bfd_put_32 (output_bfd, new_addr, fixup_table);
- }
- else
- bfd_put_32 (output_bfd, 0, fixup_table);
-
- if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
- return false;
-
- if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
- != s->_raw_size)
- return false;
-
- return true;
-}
-
-#define MY_bfd_link_hash_table_create linux_link_hash_table_create
-#define MY_add_one_symbol linux_add_one_symbol
-#define MY_finish_dynamic_link linux_finish_dynamic_link
-
-#define MY_zmagic_contiguous 1
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/i386lynx.c b/contrib/gdb/bfd/i386lynx.c
deleted file mode 100644
index 2381cff..0000000
--- a/contrib/gdb/bfd/i386lynx.c
+++ /dev/null
@@ -1,563 +0,0 @@
-/* BFD back-end for i386 a.out binaries under LynxOS.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-#define N_SHARED_LIB(x) 0
-
-#define TEXT_START_ADDR 0
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define DEFAULT_ARCH bfd_arch_i386
-
-#define MY(OP) CAT(i386lynx_aout_,OP)
-#define TARGETNAME "a.out-i386-lynx"
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#ifndef WRITE_HEADERS
-#define WRITE_HEADERS(abfd, execp) \
- { \
- bfd_size_type text_size; /* dummy vars */ \
- file_ptr text_end; \
- if (adata(abfd).magic == undecided_magic) \
- NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
- \
- 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); \
- \
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
- if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
- != EXEC_BYTES_SIZE) \
- return false; \
- /* Now write out reloc info, followed by syms and strings */ \
- \
- if (bfd_get_symcount (abfd) != 0) \
- { \
- if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \
- != 0) \
- return false; \
- \
- if (! NAME(aout,write_syms)(abfd)) return false; \
- \
- if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \
- != 0) \
- return false; \
- \
- if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
- return false; \
- if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \
- != 0) \
- return 0; \
- \
- if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
- return false; \
- } \
- }
-#endif
-
-#include "libaout.h"
-#include "aout/aout64.h"
-
-#ifdef LYNX_CORE
-
-char *lynx_core_file_failing_command ();
-int lynx_core_file_failing_signal ();
-boolean lynx_core_file_matches_executable_p ();
-const bfd_target *lynx_core_file_p ();
-
-#define MY_core_file_failing_command lynx_core_file_failing_command
-#define MY_core_file_failing_signal lynx_core_file_failing_signal
-#define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
-#define MY_core_file_p lynx_core_file_p
-
-#endif /* LYNX_CORE */
-
-
-#define KEEPIT flags
-
-extern reloc_howto_type aout_32_ext_howto_table[];
-extern reloc_howto_type aout_32_std_howto_table[];
-
-/* Standard reloc stuff */
-/* Output standard relocation information to a file in target byte order. */
-
-void
-NAME(lynx,swap_std_reloc_out) (abfd, g, natptr)
- bfd *abfd;
- arelent *g;
- struct reloc_std_external *natptr;
-{
- int r_index;
- asymbol *sym = *(g->sym_ptr_ptr);
- int r_extern;
- unsigned int r_length;
- int r_pcrel;
- int r_baserel, r_jmptable, r_relative;
- unsigned int r_addend;
- asection *output_section = sym->section->output_section;
-
- 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 + (*(g->sym_ptr_ptr))->section->output_section->vma;
-
- /* name was clobbered by aout_write_syms to be symbol index */
-
- /* If this relocation is relative to a symbol then set the
- r_index to the symbols index, and the r_extern bit.
-
- Absolute symbols can come in in two ways, either as an offset
- from the abs section, or as a symbol which has an abs value.
- check for that here
- */
-
-
- if (bfd_is_com_section (output_section)
- || bfd_is_abs_section (output_section)
- || bfd_is_und_section (output_section))
- {
- if (bfd_abs_section_ptr->symbol == sym)
- {
- /* Whoops, looked like an abs symbol, but is really an offset
- from the abs section */
- r_index = 0;
- r_extern = 0;
- }
- else
- {
- /* Fill in symbol */
- r_extern = 1;
- r_index = stoi ((*(g->sym_ptr_ptr))->KEEPIT);
-
- }
- }
- else
- {
- /* Just an ordinary section */
- r_extern = 0;
- r_index = output_section->target_index;
- }
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd))
- {
- 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
-NAME(lynx,swap_ext_reloc_out) (abfd, g, natptr)
- bfd *abfd;
- arelent *g;
- register struct reloc_ext_external *natptr;
-{
- int r_index;
- int r_extern;
- unsigned int r_type;
- unsigned int r_addend;
- asymbol *sym = *(g->sym_ptr_ptr);
- asection *output_section = sym->section->output_section;
-
- PUT_WORD (abfd, g->address, natptr->r_address);
-
- r_type = (unsigned int) g->howto->type;
-
- r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
-
-
- /* If this relocation is relative to a symbol then set the
- r_index to the symbols index, and the r_extern bit.
-
- Absolute symbols can come in in two ways, either as an offset
- from the abs section, or as a symbol which has an abs value.
- check for that here
- */
-
- if (bfd_is_com_section (output_section)
- || bfd_is_abs_section (output_section)
- || bfd_is_und_section (output_section))
- {
- if (bfd_abs_section_ptr->symbol == sym)
- {
- /* Whoops, looked like an abs symbol, but is really an offset
- from the abs section */
- r_index = 0;
- r_extern = 0;
- }
- else
- {
- r_extern = 1;
- r_index = stoi ((*(g->sym_ptr_ptr))->KEEPIT);
- }
- }
- else
- {
- /* Just an ordinary section */
- r_extern = 0;
- r_index = output_section->target_index;
- }
-
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd))
- {
- 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);
-}
-
-/* BFD deals internally with all things based from the section they're
- in. so, something in 10 bytes into a text section with a base of
- 50 would have a symbol (.text+10) and know .text vma was 50.
-
- Aout keeps all it's symbols based from zero, so the symbol would
- contain 60. This macro subs the base of each section from the value
- to give the true offset from the section */
-
-
-#define MOVE_ADDRESS(ad) \
- if (r_extern) { \
- /* undefined symbol */ \
- cache_ptr->sym_ptr_ptr = symbols + r_index; \
- cache_ptr->addend = ad; \
- } else { \
- /* defined, section relative. replace symbol with pointer to \
- symbol which points to section */ \
- switch (r_index) { \
- case N_TEXT: \
- case N_TEXT | N_EXT: \
- cache_ptr->sym_ptr_ptr = obj_textsec(abfd)->symbol_ptr_ptr; \
- cache_ptr->addend = ad - su->textsec->vma; \
- break; \
- case N_DATA: \
- case N_DATA | N_EXT: \
- cache_ptr->sym_ptr_ptr = obj_datasec(abfd)->symbol_ptr_ptr; \
- cache_ptr->addend = ad - su->datasec->vma; \
- break; \
- case N_BSS: \
- case N_BSS | N_EXT: \
- cache_ptr->sym_ptr_ptr = obj_bsssec(abfd)->symbol_ptr_ptr; \
- cache_ptr->addend = ad - su->bsssec->vma; \
- break; \
- default: \
- case N_ABS: \
- case N_ABS | N_EXT: \
- cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; \
- cache_ptr->addend = ad; \
- break; \
- } \
- } \
-
-void
-NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
- bfd *abfd;
- struct reloc_ext_external *bytes;
- arelent *cache_ptr;
- asymbol **symbols;
- bfd_size_type symcount;
-{
- int r_index;
- int r_extern;
- unsigned int r_type;
- struct aoutdata *su = &(abfd->tdata.aout_data->a);
-
- cache_ptr->address = (GET_SWORD (abfd, bytes->r_address));
-
- r_index = bytes->r_index[1];
- r_extern = (0 != (bytes->r_index[0] & RELOC_EXT_BITS_EXTERN_BIG));
- r_type = (bytes->r_index[0] & RELOC_EXT_BITS_TYPE_BIG)
- >> RELOC_EXT_BITS_TYPE_SH_BIG;
-
- cache_ptr->howto = aout_32_ext_howto_table + r_type;
- MOVE_ADDRESS (GET_SWORD (abfd, bytes->r_addend));
-}
-
-void
-NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
- bfd *abfd;
- struct reloc_std_external *bytes;
- arelent *cache_ptr;
- asymbol **symbols;
- bfd_size_type symcount;
-{
- int r_index;
- int r_extern;
- unsigned int r_length;
- int r_pcrel;
- int r_baserel, r_jmptable, r_relative;
- struct aoutdata *su = &(abfd->tdata.aout_data->a);
-
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
-
- r_index = bytes->r_index[1];
- r_extern = (0 != (bytes->r_index[0] & RELOC_STD_BITS_EXTERN_BIG));
- r_pcrel = (0 != (bytes->r_index[0] & RELOC_STD_BITS_PCREL_BIG));
- r_baserel = (0 != (bytes->r_index[0] & RELOC_STD_BITS_BASEREL_BIG));
- r_jmptable = (0 != (bytes->r_index[0] & RELOC_STD_BITS_JMPTABLE_BIG));
- r_relative = (0 != (bytes->r_index[0] & RELOC_STD_BITS_RELATIVE_BIG));
- r_length = (bytes->r_index[0] & RELOC_STD_BITS_LENGTH_BIG)
- >> RELOC_STD_BITS_LENGTH_SH_BIG;
-
- cache_ptr->howto = aout_32_std_howto_table + r_length + 4 * r_pcrel;
- /* FIXME-soon: Roll baserel, jmptable, relative bits into howto setting */
-
- MOVE_ADDRESS (0);
-}
-
-/* Reloc hackery */
-
-boolean
-NAME(lynx,slurp_reloc_table) (abfd, asect, symbols)
- bfd *abfd;
- sec_ptr asect;
- 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_set_error (bfd_error_invalid_operation);
- return false;
-
-doit:
- if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
- return false;
- each_size = obj_reloc_entry_size (abfd);
-
- count = reloc_size / each_size;
-
-
- reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
- if (!reloc_cache && count != 0)
- return false;
- memset (reloc_cache, 0, count * sizeof (arelent));
-
- relocs = (PTR) bfd_alloc (abfd, reloc_size);
- if (!relocs && reloc_size != 0)
- {
- free (reloc_cache);
- return false;
- }
-
- if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
- {
- bfd_release (abfd, relocs);
- free (reloc_cache);
- 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(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
- }
- }
- 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(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
- }
-
- }
-
- bfd_release (abfd, relocs);
- asect->relocation = reloc_cache;
- asect->reloc_count = count;
- return true;
-}
-
-
-
-/* Write out a relocation section into an object file. */
-
-boolean
-NAME(lynx,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)
- return false;
-
- generic = section->orelocation;
-
- if (each_size == RELOC_EXT_SIZE)
- {
- for (natptr = native;
- count != 0;
- --count, natptr += each_size, ++generic)
- NAME(lynx,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *) natptr);
- }
- else
- {
- for (natptr = native;
- count != 0;
- --count, natptr += each_size, ++generic)
- NAME(lynx,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 */
-long
-NAME(lynx,canonicalize_reloc) (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr = section->relocation;
- unsigned int count;
-
- if (!(tblptr || NAME(lynx,slurp_reloc_table) (abfd, section, symbols)))
- return -1;
-
- 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;
-
- for (count = 0; count++ < section->reloc_count;)
- {
- *relptr++ = tblptr++;
- }
- }
- *relptr = 0;
-
- return section->reloc_count;
-}
-
-#define MY_canonicalize_reloc NAME(lynx,canonicalize_reloc)
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/i386mach3.c b/contrib/gdb/bfd/i386mach3.c
deleted file mode 100644
index 72a28f3..0000000
--- a/contrib/gdb/bfd/i386mach3.c
+++ /dev/null
@@ -1,65 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This is for Mach 3, which uses a.out, not Mach-O. */
-
-/* There is no magic number or anything which lets us distinguish this target
- from i386aout or i386bsd. So this target is only useful if it is the
- default target. */
-
-#define TARGET_PAGE_SIZE 1
-#define SEGMENT_SIZE 0x1000
-#define TEXT_START_ADDR 0x10000
-#define ARCH 32
-#define BYTES_IN_WORD 4
-/* This macro is only relevant when N_MAGIC(x) == ZMAGIC. */
-#define N_HEADER_IN_TEXT(x) 1
-
-#define N_TXTSIZE(x) ((x).a_text)
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-#define DEFAULT_ARCH bfd_arch_i386
-#define MY(OP) CAT(i386mach3_,OP)
-#define TARGETNAME "a.out-mach3"
-
-static boolean MY(set_sizes)();
-#define MY_backend_data &MY(backend_data)
-static CONST struct aout_backend_data MY(backend_data) = {
- 0, /* zmagic contiguous */
- 1, /* text incl header */
- 0, /* exec_hdr_flags */
- 0, /* text vma? */
- MY(set_sizes),
- 1, /* exec header not counted */
- 0, /* add_dynamic_symbols */
- 0, /* add_one_symbol */
- 0, /* link_dynamic_object */
- 0, /* write_dynamic_symbol */
- 0, /* check_dynamic_reloc */
- 0 /* finish_dynamic_link */
-};
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/i386msdos.c b/contrib/gdb/bfd/i386msdos.c
deleted file mode 100644
index 24a456b..0000000
--- a/contrib/gdb/bfd/i386msdos.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/* BFD back-end for MS-DOS executables.
- Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by Bryan Ford of the University of Utah.
-
- Contributed by the Center for Software Science at the
- University of Utah (pa-gdb-bugs@cs.utah.edu).
-
- This file is part of BFD, the Binary File Descriptor library.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-
-#if 0
-struct exe_header
-{
- unsigned short magic;
- unsigned short bytes_in_last_page;
- unsigned short npages; /* number of 512-byte "pages" including this header */
- unsigned short nrelocs;
- unsigned short header_paras; /* number of 16-byte paragraphs in header */
- unsigned short reserved;
- unsigned short load_switch;
- unsigned short ss_ofs;
- unsigned short sp;
- unsigned short checksum;
- unsigned short ip;
- unsigned short cs_ofs;
- unsigned short reloc_ofs;
- unsigned short reserved2;
- unsigned short something1;
- unsigned short something2;
- unsigned short something3;
-};
-#endif
-
-#define EXE_MAGIC 0x5a4d
-#define EXE_LOAD_HIGH 0x0000
-#define EXE_LOAD_LOW 0xffff
-#define EXE_PAGE_SIZE 512
-
-
-static int
-msdos_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-static boolean
-msdos_write_object_contents (abfd)
- bfd *abfd;
-{
- static char hdr[EXE_PAGE_SIZE];
- file_ptr outfile_size = sizeof(hdr);
- bfd_vma high_vma = 0;
- asection *sec;
-
- /* Find the total size of the program on disk and in memory. */
- for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
- {
- if (bfd_get_section_size_before_reloc (sec) == 0)
- continue;
- if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
- {
- bfd_vma sec_vma = bfd_get_section_vma (abfd, sec)
- + bfd_get_section_size_before_reloc (sec);
- if (sec_vma > high_vma)
- high_vma = sec_vma;
- }
- if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
- {
- file_ptr sec_end = sizeof(hdr)
- + bfd_get_section_vma (abfd, sec)
- + bfd_get_section_size_before_reloc (sec);
- if (sec_end > outfile_size)
- outfile_size = sec_end;
- }
- }
-
- /* Make sure the program isn't too big. */
- if (high_vma > (bfd_vma)0xffff)
- {
- bfd_set_error(bfd_error_file_too_big);
- return false;
- }
-
- /* constants */
- bfd_h_put_16(abfd, EXE_MAGIC, &hdr[0]);
- bfd_h_put_16(abfd, EXE_PAGE_SIZE / 16, &hdr[8]);
- bfd_h_put_16(abfd, EXE_LOAD_LOW, &hdr[12]);
- bfd_h_put_16(abfd, 0x3e, &hdr[24]);
- bfd_h_put_16(abfd, 0x0001, &hdr[28]); /* XXX??? */
- bfd_h_put_16(abfd, 0x30fb, &hdr[30]); /* XXX??? */
- bfd_h_put_16(abfd, 0x726a, &hdr[32]); /* XXX??? */
-
- /* bytes in last page (0 = full page) */
- bfd_h_put_16(abfd, outfile_size & (EXE_PAGE_SIZE - 1), &hdr[2]);
-
- /* number of pages */
- bfd_h_put_16(abfd, (outfile_size + EXE_PAGE_SIZE - 1) / EXE_PAGE_SIZE,
- &hdr[4]);
-
- /* Set the initial stack pointer to the end of the bss.
- The program's crt0 code must relocate it to a real stack. */
- bfd_h_put_16(abfd, high_vma, &hdr[16]);
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_write (hdr, 1, sizeof(hdr), abfd) != sizeof(hdr))
- return false;
-
- return true;
-}
-
-static boolean
-msdos_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
-
- if (count == 0)
- return true;
-
- section->filepos = EXE_PAGE_SIZE + bfd_get_section_vma (abfd, section);
-
- if (bfd_get_section_flags (abfd, section) & SEC_LOAD)
- {
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
- return false;
- }
-
- return true;
-}
-
-
-
-#define msdos_mkobject aout_32_mkobject
-#define msdos_make_empty_symbol aout_32_make_empty_symbol
-#define msdos_bfd_reloc_type_lookup aout_32_reloc_type_lookup
-
-#define msdos_close_and_cleanup _bfd_generic_close_and_cleanup
-#define msdos_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define msdos_new_section_hook _bfd_generic_new_section_hook
-#define msdos_get_section_contents _bfd_generic_get_section_contents
-#define msdos_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-#define msdos_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define msdos_bfd_relax_section bfd_generic_relax_section
-#define msdos_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define msdos_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define msdos_bfd_final_link _bfd_generic_final_link
-#define msdos_bfd_link_split_section _bfd_generic_link_split_section
-#define msdos_set_arch_mach _bfd_generic_set_arch_mach
-
-#define msdos_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
-#define msdos_get_symtab _bfd_nosymbols_get_symtab
-#define msdos_print_symbol _bfd_nosymbols_print_symbol
-#define msdos_get_symbol_info _bfd_nosymbols_get_symbol_info
-#define msdos_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define msdos_get_lineno _bfd_nosymbols_get_lineno
-#define msdos_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
-#define msdos_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define msdos_read_minisymbols _bfd_nosymbols_read_minisymbols
-#define msdos_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
-
-#define msdos_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
-#define msdos_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
-#define msdos_32_bfd_link_split_section _bfd_generic_link_split_section
-
-const bfd_target i386msdos_vec =
-{
- "msdos", /* name */
- bfd_target_msdos_flavour,
- BFD_ENDIAN_LITTLE, /* target byte order */
- BFD_ENDIAN_LITTLE, /* target headers byte order */
- (EXEC_P), /* object flags */
- (SEC_CODE | SEC_DATA | SEC_HAS_CONTENTS
- | SEC_ALLOC | SEC_LOAD), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
-
- {
- _bfd_dummy_target,
- _bfd_dummy_target, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- msdos_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- msdos_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (msdos),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (msdos),
- BFD_JUMP_TABLE_RELOCS (msdos),
- BFD_JUMP_TABLE_WRITE (msdos),
- BFD_JUMP_TABLE_LINK (msdos),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
-
-
diff --git a/contrib/gdb/bfd/i386netbsd.c b/contrib/gdb/bfd/i386netbsd.c
deleted file mode 100644
index 32feaa7..0000000
--- a/contrib/gdb/bfd/i386netbsd.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* BFD back-end for NetBSD/386 a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-#undef TARGET_IS_BIG_ENDIAN_P
-
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-
-#define DEFAULT_ARCH bfd_arch_i386
-#define MACHTYPE_OK(mtype) ((mtype) == M_386_NETBSD || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(i386netbsd_,OP)
-/* This needs to start with a.out so GDB knows it is an a.out variant. */
-#define TARGETNAME "a.out-i386-netbsd"
-
-#include "netbsd.h"
diff --git a/contrib/gdb/bfd/i386os9k.c b/contrib/gdb/bfd/i386os9k.c
deleted file mode 100644
index fe1a021..0000000
--- a/contrib/gdb/bfd/i386os9k.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/* BFD back-end for os9000 i386 binaries.
- Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-#include "os9k.h"
-
-static const bfd_target *os9k_callback PARAMS ((bfd *));
-
-/* Swaps the information in an executable header taken from a raw byte
- stream memory image, into the internal exec_header structure. */
-boolean
-os9k_swap_exec_header_in (abfd, raw_bytes, execp)
- bfd *abfd;
- mh_com *raw_bytes;
- struct internal_exec *execp;
-{
- mh_com *bytes = (mh_com *) raw_bytes;
- unsigned int dload, dmemsize, dmemstart;
-
- /* Now fill in fields in the execp, from the bytes in the raw data. */
- execp->a_info = bfd_h_get_16 (abfd, bytes->m_sync);
- execp->a_syms = 0;
- execp->a_entry = bfd_h_get_32 (abfd, bytes->m_exec);
- execp->a_talign = 2;
- execp->a_dalign = 2;
- execp->a_balign = 2;
-
- dload = bfd_h_get_32 (abfd, bytes->m_idata);
- execp->a_data = dload + 8;
-
- if (bfd_seek (abfd, (file_ptr) dload, SEEK_SET) != 0
- || (bfd_read (&dmemstart, sizeof (dmemstart), 1, abfd)
- != sizeof (dmemstart))
- || (bfd_read (&dmemsize, sizeof (dmemsize), 1, abfd)
- != sizeof (dmemsize)))
- return false;
-
- execp->a_tload = 0;
- execp->a_dload = bfd_h_get_32 (abfd, (unsigned char *) &dmemstart);
- execp->a_text = dload - execp->a_tload;
- execp->a_data = bfd_h_get_32 (abfd, (unsigned char *) &dmemsize);
- execp->a_bss = bfd_h_get_32 (abfd, bytes->m_data) - execp->a_data;
-
- execp->a_trsize = 0;
- execp->a_drsize = 0;
-
- return true;
-}
-
-#if 0
-/* Swaps the information in an internal exec header structure into the
- supplied buffer ready for writing to disk. */
-
-PROTO (void, os9k_swap_exec_header_out,
- (bfd * abfd,
- struct internal_exec * execp,
- struct mh_com * raw_bytes));
-void
-os9k_swap_exec_header_out (abfd, execp, raw_bytes)
- bfd *abfd;
- struct internal_exec *execp;
- mh_com *raw_bytes;
-{
- mh_com *bytes = (mh_com *) 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);
- bfd_h_put_32 (abfd, execp->a_text, bytes->e_text);
- bfd_h_put_32 (abfd, execp->a_data, bytes->e_data);
- bfd_h_put_32 (abfd, execp->a_bss, bytes->e_bss);
- bfd_h_put_32 (abfd, execp->a_syms, bytes->e_syms);
- bfd_h_put_32 (abfd, execp->a_entry, bytes->e_entry);
- bfd_h_put_32 (abfd, execp->a_trsize, bytes->e_trsize);
- bfd_h_put_32 (abfd, execp->a_drsize, bytes->e_drsize);
- bfd_h_put_32 (abfd, execp->a_tload, bytes->e_tload);
- bfd_h_put_32 (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_relaxable[0] = execp->a_relaxable;
-}
-
-#endif /* 0 */
-
-static const bfd_target *
-os9k_object_p (abfd)
- bfd *abfd;
-{
- struct internal_exec anexec;
- mh_com exec_bytes;
-
- if (bfd_read ((PTR) & exec_bytes, MHCOM_BYTES_SIZE, 1, abfd)
- != MHCOM_BYTES_SIZE)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- anexec.a_info = bfd_h_get_16 (abfd, exec_bytes.m_sync);
- if (N_BADMAG (anexec))
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- if (! os9k_swap_exec_header_in (abfd, &exec_bytes, &anexec))
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
- return aout_32_some_aout_object_p (abfd, &anexec, os9k_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 const bfd_target *
-os9k_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_i386, 0);
-
- /* The positions of the string table and symbol table. */
- obj_str_filepos (abfd) = 0;
- obj_sym_filepos (abfd) = 0;
-
- /* 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;
-
- /* And reload the sizes, since the aout module zaps them */
- obj_textsec (abfd)->_raw_size = execp->a_text;
-
- bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */
- obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
-
- /* The file positions of the sections */
- obj_textsec (abfd)->filepos = execp->a_entry;
- obj_datasec (abfd)->filepos = execp->a_dload;
-
- /* The file positions of the relocation info ***
- obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
- obj_datasec (abfd)->rel_filepos = N_DROFF(*execp);
- */
-
- adata (abfd).page_size = 1; /* Not applicable. */
- adata (abfd).segment_size = 1;/* Not applicable. */
- adata (abfd).exec_bytes_size = MHCOM_BYTES_SIZE;
-
- return abfd->xvec;
-}
-
-#if 0
-struct bout_data_struct
-{
- struct aoutdata a;
- struct internal_exec e;
-};
-
-static boolean
-os9k_mkobject (abfd)
- bfd *abfd;
-{
- struct bout_data_struct *rawptr;
-
- rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
- if (rawptr == NULL)
- return false;
-
- abfd->tdata.bout_data = rawptr;
- exec_hdr (abfd) = &rawptr->e;
-
- obj_textsec (abfd) = (asection *) NULL;
- obj_datasec (abfd) = (asection *) NULL;
- obj_bsssec (abfd) = (asection *) NULL;
-
- return true;
-}
-
-static boolean
-os9k_write_object_contents (abfd)
- bfd *abfd;
-{
- struct external_exec swapped_hdr;
-
- if (! aout_32_make_sections (abfd))
- return false;
-
- exec_hdr (abfd)->a_info = BMAGIC;
-
- exec_hdr (abfd)->a_text = obj_textsec (abfd)->_raw_size;
- exec_hdr (abfd)->a_data = obj_datasec (abfd)->_raw_size;
- exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->_raw_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);
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) & swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE))
- return false;
-
- /* Now write out reloc info, followed by syms and strings */
- if (bfd_get_symcount (abfd) != 0)
- {
- if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*exec_hdr (abfd))), SEEK_SET)
- != 0)
- return false;
-
- if (!aout_32_write_syms (abfd))
- return false;
-
- if (bfd_seek (abfd, (file_ptr) (N_TROFF (*exec_hdr (abfd))), SEEK_SET)
- != 0)
- return false;
-
- if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd)))
- return false;
- if (bfd_seek (abfd, (file_ptr) (N_DROFF (*exec_hdr (abfd))), SEEK_SET)
- != 0)
- return false;
-
- if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd)))
- return false;
- }
- return true;
-}
-
-static boolean
-os9k_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 (! aout_32_make_sections (abfd))
- return false;
-
- obj_textsec (abfd)->filepos = sizeof (struct internal_exec);
- obj_datasec (abfd)->filepos = obj_textsec (abfd)->filepos
- + obj_textsec (abfd)->_raw_size;
-
- }
- /* regardless, once we know what we're doing, we might as well get going */
- if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
- return false;
-
- if (count != 0)
- {
- return (bfd_write ((PTR) location, 1, count, abfd) == count) ? true : false;
- }
- return true;
-}
-#endif /* 0 */
-
-static int
-os9k_sizeof_headers (ignore_abfd, ignore)
- bfd *ignore_abfd;
- boolean ignore;
-{
- return sizeof (struct internal_exec);
-}
-
-
-/***********************************************************************/
-
-#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
-
-#define aout_32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-
-#define aout_32_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-#define aout_32_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-#define os9k_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define os9k_bfd_relax_section bfd_generic_relax_section
-#define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define os9k_bfd_final_link _bfd_generic_final_link
-#define os9k_bfd_link_split_section _bfd_generic_link_split_section
-
-const bfd_target i386os9k_vec =
-{
- "i386os9k", /* name */
- bfd_target_os9k_flavour,
- BFD_ENDIAN_LITTLE, /* data byte order is little */
- BFD_ENDIAN_LITTLE, /* hdr byte order is little */
- (HAS_RELOC | EXEC_P | WP_TEXT), /* object flags */
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* section flags */
- 0, /* symbol leading char */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
-
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
- {_bfd_dummy_target, os9k_object_p, /* bfd_check_format */
- bfd_generic_archive_p, _bfd_dummy_target},
- {bfd_false, bfd_false, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, bfd_false, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (aout_32),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
- BFD_JUMP_TABLE_SYMBOLS (aout_32),
- BFD_JUMP_TABLE_RELOCS (aout_32),
- BFD_JUMP_TABLE_WRITE (aout_32),
- BFD_JUMP_TABLE_LINK (os9k),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0,
-};
diff --git a/contrib/gdb/bfd/ieee.c b/contrib/gdb/bfd/ieee.c
deleted file mode 100644
index 201f225..0000000
--- a/contrib/gdb/bfd/ieee.c
+++ /dev/null
@@ -1,3738 +0,0 @@
-/* BFD back-end for ieee-695 objects.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Steve Chamberlain of Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define KEEPMINUSPCININST 0
-
-/* 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"
-
-static boolean ieee_write_byte PARAMS ((bfd *, bfd_byte));
-static boolean ieee_write_2bytes PARAMS ((bfd *, int));
-static boolean ieee_write_int PARAMS ((bfd *, bfd_vma));
-static boolean ieee_write_id PARAMS ((bfd *, const char *));
-static boolean ieee_write_expression
- PARAMS ((bfd *, bfd_vma, asymbol *, boolean, unsigned int));
-static void ieee_write_int5 PARAMS ((bfd_byte *, bfd_vma));
-static boolean ieee_write_int5_out PARAMS ((bfd *, bfd_vma));
-static boolean ieee_write_section_part PARAMS ((bfd *));
-static boolean do_with_relocs PARAMS ((bfd *, asection *));
-static boolean do_as_repeat PARAMS ((bfd *, asection *));
-static boolean do_without_relocs PARAMS ((bfd *, asection *));
-static boolean ieee_write_external_part PARAMS ((bfd *));
-static boolean ieee_write_data_part PARAMS ((bfd *));
-static boolean ieee_write_debug_part PARAMS ((bfd *));
-static boolean ieee_write_me_part PARAMS ((bfd *));
-static boolean ieee_write_processor PARAMS ((bfd *));
-
-static boolean ieee_slurp_debug PARAMS ((bfd *));
-static boolean ieee_slurp_section_data PARAMS ((bfd *));
-
-/* Functions for writing to ieee files in the strange way that the
- standard requires. */
-
-static boolean
-ieee_write_byte (abfd, byte)
- bfd *abfd;
- bfd_byte byte;
-{
- if (bfd_write ((PTR) &byte, 1, 1, abfd) != 1)
- return false;
- return true;
-}
-
-static boolean
-ieee_write_2bytes (abfd, bytes)
- bfd *abfd;
- int bytes;
-{
- bfd_byte buffer[2];
-
- buffer[0] = bytes >> 8;
- buffer[1] = bytes & 0xff;
- if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2)
- return false;
- return true;
-}
-
-static boolean
-ieee_write_int (abfd, value)
- bfd *abfd;
- bfd_vma value;
-{
- if (value <= 127)
- {
- if (! ieee_write_byte (abfd, (bfd_byte) value))
- return false;
- }
- 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;
-
- if (! ieee_write_byte (abfd,
- (bfd_byte) ((int) ieee_number_repeat_start_enum
- + length)))
- return false;
- switch (length)
- {
- case 4:
- if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24)))
- return false;
- /* Fall through. */
- case 3:
- if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16)))
- return false;
- /* Fall through. */
- case 2:
- if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8)))
- return false;
- /* Fall through. */
- case 1:
- if (! ieee_write_byte (abfd, (bfd_byte) (value)))
- return false;
- }
- }
-
- return true;
-}
-
-static boolean
-ieee_write_id (abfd, id)
- bfd *abfd;
- const char *id;
-{
- size_t length = strlen (id);
-
- if (length <= 127)
- {
- if (! ieee_write_byte (abfd, (bfd_byte) length))
- return false;
- }
- else if (length < 255)
- {
- if (! ieee_write_byte (abfd, ieee_extension_length_1_enum)
- || ! ieee_write_byte (abfd, (bfd_byte) length))
- return false;
- }
- else if (length < 65535)
- {
- if (! ieee_write_byte (abfd, ieee_extension_length_2_enum)
- || ! ieee_write_2bytes (abfd, (int) length))
- return false;
- }
- else
- {
- (*_bfd_error_handler)
- ("%s: string too long (%d chars, max 65535)",
- bfd_get_filename (abfd), length);
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- if (bfd_write ((PTR) id, 1, length, abfd) != length)
- return false;
- return true;
-}
-
-/***************************************************************************
-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
-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
-bfd_get_string (ieee, string, length)
- common_header_type *ieee;
- char *string;
- size_t length;
-{
- size_t i;
- for (i = 0; i < length; i++)
- {
- string[i] = this_byte_and_next (ieee);
- }
-}
-
-static char *
-read_id (ieee)
- common_header_type *ieee;
-{
- size_t length;
- char *string;
- length = this_byte_and_next (ieee);
- if (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);
- if (!string)
- return NULL;
- bfd_get_string (ieee, string, length);
- string[length] = 0;
- return string;
-}
-
-static boolean
-ieee_write_expression (abfd, value, symbol, pcrel, index)
- bfd *abfd;
- bfd_vma value;
- asymbol *symbol;
- boolean pcrel;
- unsigned int index;
-{
- unsigned int term_count = 0;
-
- if (value != 0)
- {
- if (! ieee_write_int (abfd, value))
- return false;
- term_count++;
- }
-
- if (bfd_is_com_section (symbol->section)
- || bfd_is_und_section (symbol->section))
- {
- /* Def of a common symbol */
- if (! ieee_write_byte (abfd, ieee_variable_X_enum)
- || ! ieee_write_int (abfd, symbol->value))
- return false;
- term_count++;
- }
- else if (! bfd_is_abs_section (symbol->section))
- {
- /* Ref to defined symbol - */
-
- if (symbol->flags & BSF_GLOBAL)
- {
- if (! ieee_write_byte (abfd, ieee_variable_I_enum)
- || ! ieee_write_int (abfd, symbol->value))
- return false;
- term_count++;
- }
- else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM))
- {
- /* This is a reference to a defined local symbol. We can
- easily do a local as a section+offset. */
- if (! ieee_write_byte (abfd, ieee_variable_R_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (symbol->section->index
- + IEEE_SECTION_NUMBER_BASE)))
- return false;
- term_count++;
- if (symbol->value != 0)
- {
- if (! ieee_write_int (abfd, symbol->value))
- return false;
- term_count++;
- }
- }
- else
- {
- (*_bfd_error_handler)
- ("%s: unrecognized symbol `%s' flags 0x%x",
- bfd_get_filename (abfd), bfd_asymbol_name (symbol),
- symbol->flags);
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
- }
-
- if (pcrel)
- {
- /* subtract the pc from here by asking for PC of this section*/
- if (! ieee_write_byte (abfd, ieee_variable_P_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (index + IEEE_SECTION_NUMBER_BASE))
- || ! ieee_write_byte (abfd, ieee_function_minus_enum))
- return false;
- }
-
- /* Handle the degenerate case of a 0 address. */
- if (term_count == 0)
- {
- if (! ieee_write_int (abfd, 0))
- return false;
- }
-
- while (term_count > 1)
- {
- if (! ieee_write_byte (abfd, ieee_function_plus_enum))
- return false;
- term_count--;
- }
-
- return true;
-}
-
-/*****************************************************************************/
-
-/*
-writes any integer into the buffer supplied and always takes 5 bytes
-*/
-static void
-ieee_write_int5 (buffer, value)
- bfd_byte *buffer;
- 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 boolean
-ieee_write_int5_out (abfd, value)
- bfd *abfd;
- bfd_vma value;
-{
- bfd_byte b[5];
-
- ieee_write_int5 (b, value);
- if (bfd_write ((PTR) b, 1, 5, abfd) != 5)
- return false;
- return true;
-}
-
-static boolean
-parse_int (ieee, value_ptr)
- common_header_type *ieee;
- 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
-parse_i (ieee, ok)
- common_header_type *ieee;
- boolean *ok;
-{
- bfd_vma x;
- *ok = parse_int (ieee, &x);
- return x;
-}
-
-static bfd_vma
-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;
-
-
-#ifdef KEEPMINUSPCININST
-
-#define SRC_MASK(arg) arg
-#define PCREL_OFFSET false
-
-#else
-
-#define SRC_MASK(arg) 0
-#define PCREL_OFFSET true
-
-#endif
-
-static reloc_howto_type abs32_howto =
- HOWTO (1,
- 0,
- 2,
- 32,
- false,
- 0,
- complain_overflow_bitfield,
- 0,
- "abs32",
- true,
- 0xffffffff,
- 0xffffffff,
- false);
-
-static reloc_howto_type abs16_howto =
- HOWTO (1,
- 0,
- 1,
- 16,
- false,
- 0,
- complain_overflow_bitfield,
- 0,
- "abs16",
- true,
- 0x0000ffff,
- 0x0000ffff,
- false);
-
-static reloc_howto_type abs8_howto =
- HOWTO (1,
- 0,
- 0,
- 8,
- false,
- 0,
- complain_overflow_bitfield,
- 0,
- "abs8",
- true,
- 0x000000ff,
- 0x000000ff,
- false);
-
-static reloc_howto_type rel32_howto =
- HOWTO (1,
- 0,
- 2,
- 32,
- true,
- 0,
- complain_overflow_signed,
- 0,
- "rel32",
- true,
- SRC_MASK (0xffffffff),
- 0xffffffff,
- PCREL_OFFSET);
-
-static reloc_howto_type rel16_howto =
- HOWTO (1,
- 0,
- 1,
- 16,
- true,
- 0,
- complain_overflow_signed,
- 0,
- "rel16",
- true,
- SRC_MASK (0x0000ffff),
- 0x0000ffff,
- PCREL_OFFSET);
-
-static reloc_howto_type rel8_howto =
- HOWTO (1,
- 0,
- 0,
- 8,
- true,
- 0,
- complain_overflow_signed,
- 0,
- "rel8",
- true,
- SRC_MASK (0x000000ff),
- 0x000000ff,
- PCREL_OFFSET);
-
-static ieee_symbol_index_type NOSYMBOL = {0, 0};
-
-static void
-parse_expression (ieee, value, symbol, pcrel, extra, section)
- ieee_data_type *ieee;
- bfd_vma *value;
- ieee_symbol_index_type *symbol;
- boolean *pcrel;
- unsigned int *extra;
- asection **section;
-
-{
-#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, bfd_abs_section_ptr, 0);
- 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))]->_raw_size);
- break;
- case ieee_variable_I_enum:
- /* Push the address of variable n */
- {
- ieee_symbol_index_type sy;
- next_byte (&(ieee->h));
- sy.index = (int) must_parse_int (&(ieee->h));
- sy.letter = 'I';
-
- PUSH (sy, bfd_abs_section_ptr, 0);
- }
- break;
- 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, bfd_und_section_ptr, 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, value2 - value1);
- }
- 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,
- bfd_is_abs_section (section1) ? section2 : section1,
- 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, bfd_abs_section_ptr, 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 omitted
- 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);
- }
- {
- asection *dummy;
-
- POP (*symbol, dummy, *value);
- if (section)
- *section = dummy;
- }
-
- 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 char last_type; /* is the index for an X or a D */
-
-static ieee_symbol_type *
-get_symbol (abfd,
- ieee,
- last_symbol,
- symbol_count,
- pptr,
- max_index,
- this_type
-)
- bfd *abfd;
- ieee_data_type *ieee;
- ieee_symbol_type *last_symbol;
- unsigned int *symbol_count;
- ieee_symbol_type ***pptr;
- unsigned int *max_index;
- char this_type
- ;
-{
- /* Need a new symbol */
- unsigned int new_index = must_parse_int (&(ieee->h));
- if (new_index != last_index || this_type != last_type)
- {
- ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd,
- sizeof (ieee_symbol_type));
- if (!new_symbol)
- return NULL;
-
- 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;
- }
- last_type = this_type;
- new_symbol->symbol.section = bfd_abs_section_ptr;
- return new_symbol;
- }
- return last_symbol;
-}
-
-static boolean
-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, 'I');
- if (symbol == NULL)
- return false;
-
- symbol->symbol.the_bfd = abfd;
- symbol->symbol.name = read_id (&(ieee->h));
- symbol->symbol.udata.p = (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, 'D');
- if (symbol == NULL)
- return false;
-
- BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);
-
- symbol->symbol.the_bfd = abfd;
- symbol->symbol.name = read_id (&(ieee->h));
- symbol->symbol.udata.p = (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;
- switch (read_2bytes (ieee))
- {
- case ieee_attribute_record_enum:
- 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 8:
- case 19:
- parse_int (&ieee->h, &value);
- break;
- default:
- (*_bfd_error_handler)
- ("%s: unimplemented ATI record %u for symbol %u",
- bfd_get_filename (abfd), symbol_attribute_def,
- symbol_name_index);
- bfd_set_error (bfd_error_bad_value);
- return false;
- break;
- }
- break;
- case ieee_external_reference_info_record_enum:
- /* Skip over ATX record. */
- parse_int (&(ieee->h), &value);
- parse_int (&(ieee->h), &value);
- parse_int (&(ieee->h), &value);
- 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_ignore,
- &pcrel_ignore,
- &extra,
- &symbol->symbol.section);
-
- symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
-
- }
- 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.section = bfd_com_section_ptr;
- 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, 'X');
- if (symbol == NULL)
- return false;
-
- symbol->symbol.the_bfd = abfd;
- symbol->symbol.name = read_id (&(ieee->h));
- symbol->symbol.udata.p = (PTR) NULL;
- symbol->symbol.section = bfd_und_section_ptr;
- symbol->symbol.value = (bfd_vma) 0;
- symbol->symbol.flags = 0;
-
- 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;
-
- return true;
-}
-
-static boolean
-ieee_slurp_symbol_table (abfd)
- bfd *abfd;
-{
- if (IEEE_DATA (abfd)->read_symbols == false)
- {
- if (! ieee_slurp_external_symbols (abfd))
- return false;
- IEEE_DATA (abfd)->read_symbols = true;
- }
- return true;
-}
-
-long
-ieee_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- if (! ieee_slurp_symbol_table (abfd))
- return -1;
-
- 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 const bfd_target ieee_vec;
-
-long
-ieee_get_symtab (abfd, location)
- bfd *abfd;
- asymbol **location;
-{
- ieee_symbol_type *symp;
- static bfd dummy_bfd;
- static asymbol empty_symbol =
- /* the_bfd, name, value, attr, section */
- {&dummy_bfd, " ieee empty", (symvalue) 0, BSF_DEBUGGING, bfd_abs_section_ptr};
-
- if (abfd->symcount)
- {
- ieee_data_type *ieee = IEEE_DATA (abfd);
- dummy_bfd.xvec = &ieee_vec;
- if (! ieee_slurp_symbol_table (abfd))
- return -1;
-
- 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;
-
- }
- }
- if (abfd->symcount)
- {
- location[abfd->symcount] = (asymbol *) NULL;
- }
- return abfd->symcount;
-}
-
-static asection *
-get_section_entry (abfd, ieee, index)
- bfd *abfd;
- ieee_data_type *ieee;
- unsigned int index;
-{
- if (ieee->section_table[index] == (asection *) NULL)
- {
- char *tmp = bfd_alloc (abfd, 11);
- asection *section;
-
- if (!tmp)
- return NULL;
- sprintf (tmp, " fsec%4d", index);
- section = bfd_make_section (abfd, tmp);
- 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
-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;
- char *name;
-
- 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));
-
- /* Set minimal section attributes. Attributes are
- extended later, based on section contents. */
-
- switch (section_type[0])
- {
- case 0xC1:
- /* Normal attributes for absolute sections */
- section_type[1] = this_byte (&(ieee->h));
- section->flags = SEC_ALLOC;
- switch (section_type[1])
- {
- case 0xD3: /* AS Absolute section attributes */
- 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_CODE;
- break;
- case 0xC4:
- /* Normal data */
- next_byte (&(ieee->h));
- section->flags |= SEC_DATA;
- break;
- case 0xD2:
- next_byte (&(ieee->h));
- /* Normal rom data */
- section->flags |= SEC_ROM | SEC_DATA;
- break;
- default:
- break;
- }
- }
- break;
- case 0xC3: /* Named relocatable sections (type C) */
- section_type[1] = this_byte (&(ieee->h));
- section->flags = SEC_ALLOC;
- switch (section_type[1])
- {
- case 0xD0: /* Normal code (CP) */
- next_byte (&(ieee->h));
- section->flags |= SEC_CODE;
- break;
- case 0xC4: /* Normal data (CD) */
- next_byte (&(ieee->h));
- section->flags |= SEC_DATA;
- break;
- case 0xD2: /* Normal rom data (CR) */
- next_byte (&(ieee->h));
- section->flags |= SEC_ROM | SEC_DATA;
- break;
- default:
- break;
- }
- }
-
- /* Read section name, use it if non empty. */
- name = read_id (&ieee->h);
- if (name[0])
- section->name = name;
-
- /* Skip these fields, which we don't care about */
- {
- 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->_raw_size = must_parse_int (&(ieee->h));
- break;
- case ieee_physical_region_size_enum:
- section = ieee->section_table[must_parse_int (&(ieee->h))];
- section->_raw_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));
- section->lma = section->vma;
- 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));
- section->lma = section->vma;
- break;
- case ieee_section_offset_enum:
- (void) must_parse_int (&(ieee->h));
- (void) must_parse_int (&(ieee->h));
- break;
- default:
- return;
- }
- }
- break;
- default:
- return;
- }
- }
- }
-}
-
-/* Make a section for the debugging information, if any. We don't try
- to interpret the debugging information; we just point the section
- at the area in the file so that program which understand can dig it
- out. */
-
-static boolean
-ieee_slurp_debug (abfd)
- bfd *abfd;
-{
- ieee_data_type *ieee = IEEE_DATA (abfd);
- asection *sec;
-
- if (ieee->w.r.debug_information_part == 0)
- return true;
-
- sec = bfd_make_section (abfd, ".debug");
- if (sec == NULL)
- return false;
- sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS;
- sec->filepos = ieee->w.r.debug_information_part;
- sec->_raw_size = ieee->w.r.data_part - ieee->w.r.debug_information_part;
-
- return true;
-}
-
-/***********************************************************************
-* archive stuff
-*/
-
-const bfd_target *
-ieee_archive_p (abfd)
- bfd *abfd;
-{
- char *library;
- boolean loop;
- unsigned int i;
- unsigned char buffer[512];
- file_ptr buffer_offset = 0;
- ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
- ieee_ar_data_type *ieee;
- abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));
- if (!abfd->tdata.ieee_ar_data)
- return NULL;
- ieee = IEEE_AR_DATA (abfd);
-
- /* FIXME: Check return value. I'm not sure whether it needs to read
- the entire buffer or not. */
- 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)
- {
- abfd->tdata.ieee_ar_data = save;
- return (const bfd_target *) NULL;
- }
-
- next_byte (&(ieee->h));
- library = read_id (&(ieee->h));
- if (strcmp (library, "LIBRARY") != 0)
- {
- bfd_release (abfd, ieee);
- abfd->tdata.ieee_ar_data = save;
- return (const bfd_target *) NULL;
- }
- /* Throw away the filename */
- read_id (&(ieee->h));
-
- 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)
- {
- 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 ((size_t) ieee_pos (abfd) > sizeof (buffer) / 2)
- {
- /* Past half way, reseek and reprime */
- buffer_offset += ieee_pos (abfd);
- if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0)
- return NULL;
- /* FIXME: Check return value. I'm not sure whether it
- needs to read the entire buffer or not. */
- 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);
- if (!ieee->elements)
- return (const bfd_target *) NULL;
-
- /* Now scan the area again, and replace BB offsets with file */
- /* offsets */
-
- for (i = 2; i < ieee->element_count; i++)
- {
- if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
- return NULL;
- /* FIXME: Check return value. I'm not sure whether it needs to
- read the entire buffer or not. */
- 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));
- }
- }
-
-/* abfd->has_armap = ;*/
- return abfd->xvec;
-}
-
-static boolean
-ieee_mkobject (abfd)
- bfd *abfd;
-{
- abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, sizeof (ieee_data_type));
- return abfd->tdata.ieee_data ? true : false;
-}
-
-const bfd_target *
-ieee_object_p (abfd)
- bfd *abfd;
-{
- char *processor;
- unsigned int part;
- ieee_data_type *ieee;
- unsigned char buffer[300];
- ieee_data_type *save = IEEE_DATA (abfd);
-
- abfd->tdata.ieee_data = 0;
- ieee_mkobject (abfd);
-
- ieee = IEEE_DATA (abfd);
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto fail;
- /* Read the first few bytes in to see if it makes sense */
- /* FIXME: Check return value. I'm not sure whether it needs to read
- the entire buffer or not. */
- bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
-
- ieee->h.input_p = buffer;
- if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
- goto got_wrong_format;
-
- 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 got_wrong_format;
- ieee->mb.module_name = read_id (&(ieee->h));
- if (abfd->filename == (CONST char *) NULL)
- {
- abfd->filename = ieee->mb.module_name;
- }
- /* Determine the architecture and machine type of the object file.
- */
- {
- const bfd_arch_info_type *arch = bfd_scan_arch (processor);
- if (arch == 0)
- goto got_wrong_format;
- 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;
- }
-
- }
-
- if (ieee->w.r.external_part != 0)
- 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 =
- (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record + 1);
- if (!IEEE_DATA (abfd)->h.first_byte)
- goto fail;
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto fail;
- /* FIXME: Check return value. I'm not sure whether it needs to read
- the entire buffer or not. */
- bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1,
- ieee->w.r.me_record + 1, abfd);
-
- ieee_slurp_sections (abfd);
-
- if (! ieee_slurp_debug (abfd))
- goto fail;
-
- /* Parse section data to activate file and section flags implied by
- section contents. */
-
- if (! ieee_slurp_section_data (abfd))
- goto fail;
-
- return abfd->xvec;
-got_wrong_format:
- bfd_set_error (bfd_error_wrong_format);
-fail:
- (void) bfd_release (abfd, ieee);
- abfd->tdata.ieee_data = save;
- return (const bfd_target *) NULL;
-}
-
-void
-ieee_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
- if (symbol->name[0] == ' ')
- ret->name = "* empty table entry ";
- if (!symbol->section)
- ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
-}
-
-void
-ieee_print_symbol (ignore_abfd, afile, symbol, how)
- bfd *ignore_abfd;
- PTR afile;
- asymbol *symbol;
- 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,
- symbol->name);
- }
- }
- break;
- }
-}
-
-static boolean
-do_one (ieee, current_map, location_ptr, s, iterations)
- ieee_data_type *ieee;
- ieee_per_section_type *current_map;
- unsigned char *location_ptr;
- asection *s;
- int iterations;
-{
- 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;
- asection *section;
- ieee_reloc_type *r =
- (ieee_reloc_type *) bfd_alloc (ieee->h.abfd,
- sizeof (ieee_reloc_type));
- if (!r)
- return false;
-
- *(current_map->reloc_tail_ptr) = r;
- current_map->reloc_tail_ptr = &r->next;
- r->next = (ieee_reloc_type *) NULL;
- next_byte (&(ieee->h));
-/* abort();*/
- r->relent.sym_ptr_ptr = 0;
- parse_expression (ieee,
- &r->relent.addend,
- &r->symbol,
- &pcrel, &extra, &section);
- r->relent.address = current_map->pc;
- s->flags |= SEC_RELOC;
- s->owner->flags |= HAS_RELOC;
- s->reloc_count++;
- if (r->relent.sym_ptr_ptr == 0)
- {
- r->relent.sym_ptr_ptr = section->symbol_ptr_ptr;
- }
-
- 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 ();
- return false;
- }
- }
- 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;
- }
- }
- }
-
- /* Prevent more than the first load-item of an LR record
- from being repeated (MRI convention). */
- if (iterations != 1)
- loop = false;
- }
- }
- }
- return true;
-}
-
-/* Read in all the section data and relocation stuff too */
-static boolean
-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;
- if ((s->flags & SEC_DEBUGGING) != 0)
- continue;
- per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
- if (!per->data)
- return false;
- /*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];
- s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
- 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;
- 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,
- &symbol,
- &pcrel, &extra,
- 0);
- current_map->pc = value;
- BFD_ASSERT ((unsigned) (value - s->vma) <= s->_raw_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 false;
- }
- 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;
- unsigned char *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;
- if (!do_one (ieee, current_map, location_ptr, s,
- iterations))
- return false;
- iterations--;
- }
- }
- }
- break;
- case ieee_load_constant_bytes_enum:
- case ieee_load_with_relocation_enum:
- {
- if (!do_one (ieee, current_map, location_ptr, s, 1))
- return false;
- }
- }
- }
-}
-
-boolean
-ieee_new_section_hook (abfd, newsect)
- bfd *abfd;
- asection *newsect;
-{
- newsect->used_by_bfd = (PTR)
- bfd_alloc (abfd, sizeof (ieee_per_section_type));
- if (!newsect->used_by_bfd)
- return false;
- ieee_per_section (newsect)->data = (bfd_byte *) NULL;
- ieee_per_section (newsect)->section = newsect;
- return true;
-}
-
-long
-ieee_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- if ((asect->flags & SEC_DEBUGGING) != 0)
- return 0;
- if (! ieee_slurp_section_data (abfd))
- return -1;
- return (asect->reloc_count + 1) * sizeof (arelent *);
-}
-
-static boolean
-ieee_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;
- if ((section->flags & SEC_DEBUGGING) != 0)
- return _bfd_generic_get_section_contents (abfd, section, location,
- offset, count);
- ieee_slurp_section_data (abfd);
- (void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count);
- return true;
-}
-
-long
-ieee_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- 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);
-
- if ((section->flags & SEC_DEBUGGING) != 0)
- return 0;
-
- while (src != (ieee_reloc_type *) NULL)
- {
- /* Work out which symbol to attach it this reloc to */
- switch (src->symbol.letter)
- {
- case 'I':
- src->relent.sym_ptr_ptr =
- symbols + src->symbol.index + ieee->external_symbol_base_offset;
- break;
- case 'X':
- src->relent.sym_ptr_ptr =
- symbols + src->symbol.index + ieee->external_reference_base_offset;
- break;
- case 0:
- src->relent.sym_ptr_ptr =
- src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr;
- break;
- default:
-
- BFD_FAIL ();
- }
- *relptr++ = &src->relent;
- src = src->next;
- }
- *relptr = (arelent *) NULL;
- return section->reloc_count;
-}
-
-static int
-comp (ap, bp)
- CONST PTR ap;
- CONST PTR bp;
-{
- arelent *a = *((arelent **) ap);
- arelent *b = *((arelent **) bp);
- return a->address - b->address;
-}
-
-/* Write the section headers. */
-
-static boolean
-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)
- {
- if (! bfd_is_abs_section (s)
- && (s->flags & SEC_DEBUGGING) == 0)
- {
- if (! ieee_write_byte (abfd, ieee_section_type_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (s->index
- + IEEE_SECTION_NUMBER_BASE)))
- return false;
-
- if (abfd->flags & EXEC_P)
- {
- /* This image is executable, so output absolute sections */
- if (! ieee_write_byte (abfd, ieee_variable_A_enum)
- || ! ieee_write_byte (abfd, ieee_variable_S_enum))
- return false;
- }
- else
- {
- if (! ieee_write_byte (abfd, ieee_variable_C_enum))
- return false;
- }
-
- switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM))
- {
- case SEC_CODE | SEC_LOAD:
- case SEC_CODE:
- if (! ieee_write_byte (abfd, ieee_variable_P_enum))
- return false;
- break;
- case SEC_DATA:
- default:
- if (! ieee_write_byte (abfd, ieee_variable_D_enum))
- return false;
- break;
- case SEC_ROM:
- case SEC_ROM | SEC_DATA:
- case SEC_ROM | SEC_LOAD:
- case SEC_ROM | SEC_DATA | SEC_LOAD:
- if (! ieee_write_byte (abfd, ieee_variable_R_enum))
- return false;
- }
-
-
- if (! ieee_write_id (abfd, s->name))
- return false;
-#if 0
- ieee_write_int (abfd, 0); /* Parent */
- ieee_write_int (abfd, 0); /* Brother */
- ieee_write_int (abfd, 0); /* Context */
-#endif
- /* Alignment */
- if (! ieee_write_byte (abfd, ieee_section_alignment_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (s->index
- + IEEE_SECTION_NUMBER_BASE))
- || ! ieee_write_int (abfd, 1 << s->alignment_power))
- return false;
-
- /* Size */
- if (! ieee_write_2bytes (abfd, ieee_section_size_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (s->index
- + IEEE_SECTION_NUMBER_BASE))
- || ! ieee_write_int (abfd, s->_raw_size))
- return false;
- if (abfd->flags & EXEC_P)
- {
- /* Relocateable sections don't have asl records */
- /* Vma */
- if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum)
- || ! ieee_write_byte (abfd,
- ((bfd_byte)
- (s->index
- + IEEE_SECTION_NUMBER_BASE)))
- || ! ieee_write_int (abfd, s->vma))
- return false;
- }
- }
- }
-
- return true;
-}
-
-
-static boolean
-do_with_relocs (abfd, s)
- bfd *abfd;
- asection *s;
-{
- unsigned int number_of_maus_in_address =
- bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd);
- 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 */
- if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))
- || ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)))
- return false;
- if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0)
- {
- if (! ieee_write_int (abfd, s->vma))
- return false;
- }
- else
- {
- if (! ieee_write_expression (abfd, 0, s->symbol, 0, 0))
- return false;
- }
-
- if (relocs_to_go == 0)
- {
- /* If there aren't any relocations then output the load constant
- byte opcode rather than the load with relocation opcode */
-
- while (current_byte_index < s->_raw_size)
- {
- bfd_size_type run;
- unsigned int MAXRUN = 127;
- run = MAXRUN;
- if (run > s->_raw_size - current_byte_index)
- {
- run = s->_raw_size - current_byte_index;
- }
-
- if (run != 0)
- {
- if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum))
- return false;
- /* Output a stream of bytes */
- if (! ieee_write_int (abfd, run))
- return false;
- if (bfd_write ((PTR) (stream + current_byte_index),
- 1,
- run,
- abfd)
- != run)
- return false;
- current_byte_index += run;
- }
- }
- }
- else
- {
- if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum))
- return false;
-
- /* 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 = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
- if (!stream)
- return false;
- memset ((PTR) stream, 0, (size_t) s->_raw_size);
- }
- while (current_byte_index < s->_raw_size)
- {
- bfd_size_type run;
- unsigned int MAXRUN = 127;
- if (relocs_to_go)
- {
- run = (*p)->address - current_byte_index;
- if (run > MAXRUN)
- run = MAXRUN;
- }
- else
- {
- run = MAXRUN;
- }
- if (run > s->_raw_size - current_byte_index)
- {
- run = s->_raw_size - current_byte_index;
- }
-
- if (run != 0)
- {
- /* Output a stream of bytes */
- if (! ieee_write_int (abfd, run))
- return false;
- if (bfd_write ((PTR) (stream + current_byte_index),
- 1,
- run,
- abfd)
- != run)
- return false;
- 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_signed_vma ov;
-
-#if 0
- if (r->howto->pc_relative)
- {
- r->addend += current_byte_index;
- }
-#endif
-
- switch (r->howto->size)
- {
- case 2:
-
- ov = bfd_get_signed_32 (abfd,
- stream + current_byte_index);
- current_byte_index += 4;
- break;
- case 1:
- ov = bfd_get_signed_16 (abfd,
- stream + current_byte_index);
- current_byte_index += 2;
- break;
- case 0:
- ov = bfd_get_signed_8 (abfd,
- stream + current_byte_index);
- current_byte_index++;
- break;
- default:
- ov = 0;
- BFD_FAIL ();
- return false;
- }
-
- ov &= r->howto->src_mask;
-
- if (r->howto->pc_relative
- && ! r->howto->pcrel_offset)
- ov += r->address;
-
- if (! ieee_write_byte (abfd,
- ieee_function_either_open_b_enum))
- return false;
-
-/* abort();*/
-
- if (r->sym_ptr_ptr != (asymbol **) NULL)
- {
- if (! ieee_write_expression (abfd, r->addend + ov,
- *(r->sym_ptr_ptr),
- r->howto->pc_relative,
- s->index))
- return false;
- }
- else
- {
- if (! ieee_write_expression (abfd, r->addend + ov,
- (asymbol *) NULL,
- r->howto->pc_relative,
- s->index))
- return false;
- }
-
- if (number_of_maus_in_address
- != bfd_get_reloc_size (r->howto))
- {
- if (! ieee_write_int (abfd,
- bfd_get_reloc_size (r->howto)))
- return false;
- }
- if (! ieee_write_byte (abfd,
- ieee_function_either_close_b_enum))
- return false;
-
- relocs_to_go--;
- p++;
- }
-
- }
- }
- }
-
- return true;
-}
-
-/* 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 boolean
-do_as_repeat (abfd, s)
- bfd *abfd;
- asection *s;
-{
- if (s->_raw_size)
- {
- if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
- || ! ieee_write_byte (abfd,
- (bfd_byte) (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,
- (bfd_byte) (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->_raw_size)
- || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)
- || ! ieee_write_byte (abfd, 1)
- || ! ieee_write_byte (abfd, 0))
- return false;
- }
-
- return true;
-}
-
-static boolean
-do_without_relocs (abfd, s)
- bfd *abfd;
- asection *s;
-{
- bfd_byte *stream = ieee_per_section (s)->data;
-
- if (stream == 0 || ((s->flags & SEC_LOAD) == 0))
- {
- if (! do_as_repeat (abfd, s))
- return false;
- }
- else
- {
- unsigned int i;
- for (i = 0; i < s->_raw_size; i++)
- {
- if (stream[i] != 0)
- {
- if (! do_with_relocs (abfd, s))
- return false;
- return true;
- }
- }
- if (! do_as_repeat (abfd, s))
- return false;
- }
-
- return true;
-}
-
-
-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 ()
-{
- /* FIXME: Check return value. I'm not sure whether it needs to read
- the entire buffer or not. */
- bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd);
- input_ptr = input_ptr_start;
-}
-static void
-flush ()
-{
- if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start,
- output_bfd)
- != (bfd_size_type) (output_ptr - output_ptr_start))
- abort ();
- 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
-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
-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
-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
-relocate_debug (output, input)
- bfd *output;
- 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;
- /* FIXME: Check return value. I'm not sure whether it needs to read
- the entire buffer or not. */
- 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 boolean
-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)
- {
- asection *s;
-
- for (s = abfd->sections; s != NULL; s = s->next)
- if ((s->flags & SEC_DEBUGGING) != 0)
- break;
- if (s == NULL)
- {
- ieee->w.r.debug_information_part = 0;
- return true;
- }
-
- ieee->w.r.debug_information_part = here;
- if (bfd_write (s->contents, 1, s->_raw_size, abfd) != s->_raw_size)
- return false;
- }
- 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)
- {
- if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
- SEEK_SET)
- != 0)
- return false;
- 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 ();
- }
-
- return true;
-}
-
-/* Write the data in an ieee way. */
-
-static boolean
-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)
- {
- /* Skip sections that have no loadable contents (.bss,
- debugging, etc.) */
- if ((s->flags & SEC_LOAD) == 0)
- continue;
-
- /* Sort the reloc records so we can insert them in the correct
- places */
- if (s->reloc_count != 0)
- {
- if (! do_with_relocs (abfd, s))
- return false;
- }
- else
- {
- if (! do_without_relocs (abfd, s))
- return false;
- }
- }
-
- return true;
-}
-
-
-static boolean
-init_for_output (abfd)
- bfd *abfd;
-{
- asection *s;
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- if ((s->flags & SEC_DEBUGGING) != 0)
- continue;
- if (s->_raw_size != 0)
- {
- ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size));
- if (!ieee_per_section (s)->data)
- return false;
- }
- }
- return true;
-}
-
-/** 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
-ieee_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if ((section->flags & SEC_DEBUGGING) != 0)
- {
- if (section->contents == NULL)
- {
- section->contents = bfd_alloc (abfd, section->_raw_size);
- if (section->contents == NULL)
- return false;
- }
- /* bfd_set_section_contents has already checked that everything
- is within range. */
- memcpy (section->contents + offset, location, count);
- return true;
- }
-
- if (ieee_per_section (section)->data == (bfd_byte *) NULL)
- {
- if (!init_for_output (abfd))
- return false;
- }
- 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 boolean
-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 (bfd_is_und_section (p->section))
- {
- /* This must be a symbol reference .. */
- if (! ieee_write_byte (abfd, ieee_external_reference_enum)
- || ! ieee_write_int (abfd, reference_index)
- || ! ieee_write_id (abfd, p->name))
- return false;
- p->value = reference_index;
- reference_index++;
- }
- else if (bfd_is_com_section (p->section))
- {
- /* This is a weak reference */
- if (! 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))
- return false;
- p->value = reference_index;
- reference_index++;
- }
- else if (p->flags & BSF_GLOBAL)
- {
- /* This must be a symbol definition */
-
- if (! ieee_write_byte (abfd, ieee_external_symbol_enum)
- || ! ieee_write_int (abfd, public_index)
- || ! ieee_write_id (abfd, p->name)
- || ! ieee_write_2bytes (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 */
- return false;
-
- /* Write out the value */
- if (! ieee_write_2bytes (abfd, ieee_value_record_enum)
- || ! ieee_write_int (abfd, public_index))
- return false;
- if (! bfd_is_abs_section (p->section))
- {
- if (abfd->flags & EXEC_P)
- {
- /* If fully linked, then output all symbols
- relocated */
- if (! (ieee_write_int
- (abfd,
- (p->value
- + p->section->output_offset
- + p->section->output_section->vma))))
- return false;
- }
- else
- {
- if (! (ieee_write_expression
- (abfd,
- p->value + p->section->output_offset,
- p->section->output_section->symbol,
- false, 0)))
- return false;
- }
- }
- else
- {
- if (! ieee_write_expression (abfd,
- p->value,
- bfd_abs_section_ptr->symbol,
- false, 0))
- return false;
- }
- 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;
-
- return true;
-}
-
-
-static CONST unsigned 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 */
-};
-
-static CONST unsigned char envi[] =
-{
- 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 boolean
-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)
- {
- if (! 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))
- return false;
- }
- ieee->w.r.me_record = bfd_tell (abfd);
- if (! ieee_write_byte (abfd, ieee_module_end_enum))
- return false;
- return true;
-}
-
-/* Write out the IEEE processor ID. */
-
-static boolean
-ieee_write_processor (abfd)
- bfd *abfd;
-{
- const bfd_arch_info_type *arch;
-
- arch = bfd_get_arch_info (abfd);
- switch (arch->arch)
- {
- default:
- if (! ieee_write_id (abfd, bfd_printable_name (abfd)))
- return false;
- break;
-
- case bfd_arch_a29k:
- if (! ieee_write_id (abfd, "29000"))
- return false;
- break;
-
- case bfd_arch_h8300:
- if (! ieee_write_id (abfd, "H8/300"))
- return false;
- break;
-
- case bfd_arch_h8500:
- if (! ieee_write_id (abfd, "H8/500"))
- return false;
- break;
-
- case bfd_arch_i960:
- switch (arch->mach)
- {
- default:
- case bfd_mach_i960_core:
- case bfd_mach_i960_ka_sa:
- if (! ieee_write_id (abfd, "80960KA"))
- return false;
- break;
-
- case bfd_mach_i960_kb_sb:
- if (! ieee_write_id (abfd, "80960KB"))
- return false;
- break;
-
- case bfd_mach_i960_ca:
- if (! ieee_write_id (abfd, "80960CA"))
- return false;
- break;
-
- case bfd_mach_i960_mc:
- case bfd_mach_i960_xa:
- if (! ieee_write_id (abfd, "80960MC"))
- return false;
- break;
- }
- break;
-
- case bfd_arch_m68k:
- {
- char ab[20];
-
- sprintf (ab, "%lu", arch->mach);
- if (! ieee_write_id (abfd, ab))
- return false;
- }
- break;
- }
-
- return true;
-}
-
-boolean
-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 */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- return false;
-
- if (! ieee_write_byte (abfd, ieee_module_beginning_enum)
- || ! ieee_write_processor (abfd)
- || ! ieee_write_id (abfd, abfd->filename))
- return false;
-
- /* Fast forward over the variable bits */
- if (! ieee_write_byte (abfd, ieee_address_descriptor_enum))
- return false;
-
- /* Bits per MAU */
- if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd))))
- return false;
- /* MAU's per address */
- if (! ieee_write_byte (abfd,
- (bfd_byte) (bfd_arch_bits_per_address (abfd)
- / bfd_arch_bits_per_byte (abfd))))
- return false;
-
- old = bfd_tell (abfd);
- if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0)
- return false;
-
- ieee->w.r.extension_record = bfd_tell (abfd);
- if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten))
- return false;
- if (abfd->flags & EXEC_P)
- {
- if (! ieee_write_byte (abfd, 0x1)) /* Absolute */
- return false;
- }
- else
- {
- if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */
- return false;
- }
-
- ieee->w.r.environmental_record = bfd_tell (abfd);
- if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi))
- return false;
- output_bfd = abfd;
-
- flush ();
-
- if (! ieee_write_section_part (abfd))
- return false;
- /* First write the symbols. This changes their values into table
- indeces so we cant use it after this point. */
- if (! ieee_write_external_part (abfd))
- return false;
-
- /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
-
- /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
-
-
- /* Write any debugs we have been told about. */
- if (! ieee_write_debug_part (abfd))
- return false;
-
- /* Can only write the data once the symbols have been written, since
- the data contains relocation information which points to the
- symbols. */
- if (! ieee_write_data_part (abfd))
- return false;
-
- /* At the end we put the end! */
- if (! ieee_write_me_part (abfd))
- return false;
-
- /* Generate the header */
- if (bfd_seek (abfd, old, SEEK_SET) != 0)
- return false;
-
- for (i = 0; i < N_W_VARIABLES; i++)
- {
- if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum)
- || ! ieee_write_byte (abfd, (bfd_byte) i)
- || ! ieee_write_int5_out (abfd, ieee->w.offset[i]))
- return false;
- }
-
- 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 *
-ieee_make_empty_symbol (abfd)
- bfd *abfd;
-{
- ieee_symbol_type *new =
- (ieee_symbol_type *) bfd_zmalloc (sizeof (ieee_symbol_type));
- if (!new)
- return NULL;
- new->symbol.the_bfd = abfd;
- return &new->symbol;
-}
-
-static bfd *
-ieee_openr_next_archived_file (arch, prev)
- bfd *arch;
- 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_set_error (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 = abfd->my_archive->tdata.ieee_ar_data;
- if (ar == (ieee_ar_data_type *) NULL)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
- else if (ieee_object_p (abfd))
- {
- ieee_data_type *ieee = IEEE_DATA (abfd);
-
- buf->st_size = ieee->w.r.me_record + 1;
- buf->st_mode = 0644;
- return 0;
- }
- else
- return -1;
-}
-
-static int
-ieee_sizeof_headers (abfd, x)
- bfd *abfd;
- boolean x;
-{
- return 0;
-}
-
-
-/* The debug info routines are never used. */
-#if 0
-
-static void
-ieee_bfd_debug_info_start (abfd)
- bfd *abfd;
-{
-
-}
-
-static void
-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
-ieee_bfd_debug_info_accumulate (abfd, section)
- bfd *abfd;
- 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));
- if (!n)
- abort (); /* FIXME */
- 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;
- }
-}
-
-#endif
-
-#define ieee_close_and_cleanup _bfd_generic_close_and_cleanup
-#define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-
-#define ieee_slurp_armap bfd_true
-#define ieee_slurp_extended_name_table bfd_true
-#define ieee_construct_extended_name_table \
- ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
- bfd_true)
-#define ieee_truncate_arname bfd_dont_truncate_arname
-#define ieee_write_armap \
- ((boolean (*) \
- PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
- bfd_true)
-#define ieee_read_ar_hdr bfd_nullvoidptr
-#define ieee_update_armap_timestamp bfd_true
-#define ieee_get_elt_at_index _bfd_generic_get_elt_at_index
-
-#define ieee_bfd_is_local_label bfd_generic_is_local_label
-#define ieee_get_lineno _bfd_nosymbols_get_lineno
-#define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define ieee_read_minisymbols _bfd_generic_read_minisymbols
-#define ieee_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-#define ieee_set_arch_mach _bfd_generic_set_arch_mach
-
-#define ieee_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-#define ieee_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define ieee_bfd_relax_section bfd_generic_relax_section
-#define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define ieee_bfd_final_link _bfd_generic_final_link
-#define ieee_bfd_link_split_section _bfd_generic_link_split_section
-
-/*SUPPRESS 460 */
-const bfd_target ieee_vec =
-{
- "ieee", /* name */
- bfd_target_ieee_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
- | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target,
- 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,
- },
-
- BFD_JUMP_TABLE_GENERIC (ieee),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (ieee),
- BFD_JUMP_TABLE_SYMBOLS (ieee),
- BFD_JUMP_TABLE_RELOCS (ieee),
- BFD_JUMP_TABLE_WRITE (ieee),
- BFD_JUMP_TABLE_LINK (ieee),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/irix-core.c b/contrib/gdb/bfd/irix-core.c
deleted file mode 100644
index 3fd3977..0000000
--- a/contrib/gdb/bfd/irix-core.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/* BFD back-end for Irix core files.
- Copyright 1993, 1994 Free Software Foundation, Inc.
- Written by Stu Grossman, Cygnus Support.
- Converted to back-end form by Ian Lance Taylor, Cygnus Support
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file can only be compiled on systems which use Irix style core
- files (namely, Irix 4 and Irix 5, so far). */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#ifdef IRIX_CORE
-
-#include <core.out.h>
-
-struct sgi_core_struct
-{
- int sig;
- char cmd[CORE_NAMESIZE];
-};
-
-#define core_hdr(bfd) ((bfd)->tdata.sgi_core_data)
-#define core_signal(bfd) (core_hdr(bfd)->sig)
-#define core_command(bfd) (core_hdr(bfd)->cmd)
-
-static asection *
-make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
- bfd *abfd;
- CONST char *name;
- flagword flags;
- bfd_size_type _raw_size;
- bfd_vma vma;
- file_ptr filepos;
-{
- asection *asect;
-
- asect = bfd_make_section_anyway (abfd, name);
- if (!asect)
- return NULL;
-
- asect->flags = flags;
- asect->_raw_size = _raw_size;
- asect->vma = vma;
- asect->filepos = filepos;
- asect->alignment_power = 4;
-
- return asect;
-}
-
-static const bfd_target *
-irix_core_core_file_p (abfd)
- bfd *abfd;
-{
- int val;
- int i;
- char *secname;
- struct coreout coreout;
- struct idesc *idg, *idf, *ids;
-
- val = bfd_read ((PTR)&coreout, 1, sizeof coreout, abfd);
- if (val != sizeof coreout)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- if (coreout.c_magic != CORE_MAGIC
- || coreout.c_version != CORE_VERSION1)
- return 0;
-
- core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, sizeof (struct sgi_core_struct));
- if (!core_hdr (abfd))
- return NULL;
-
- strncpy (core_command (abfd), coreout.c_name, CORE_NAMESIZE);
- core_signal (abfd) = coreout.c_sigcause;
-
- if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
- return NULL;
-
- for (i = 0; i < coreout.c_nvmap; i++)
- {
- struct vmap vmap;
-
- val = bfd_read ((PTR)&vmap, 1, sizeof vmap, abfd);
- if (val != sizeof vmap)
- break;
-
- switch (vmap.v_type)
- {
- case VDATA:
- secname = ".data";
- break;
- case VSTACK:
- secname = ".stack";
- break;
-#ifdef VMAPFILE
- case VMAPFILE:
- secname = ".mapfile";
- break;
-#endif
- default:
- continue;
- }
-
- /* A file offset of zero means that the section is not contained
- in the corefile. */
- if (vmap.v_offset == 0)
- continue;
-
- if (!make_bfd_asection (abfd, secname,
- SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
- vmap.v_len,
- vmap.v_vaddr,
- vmap.v_offset,
- 2))
- return NULL;
- }
-
- /* Make sure that the regs are contiguous within the core file. */
-
- idg = &coreout.c_idesc[I_GPREGS];
- idf = &coreout.c_idesc[I_FPREGS];
- ids = &coreout.c_idesc[I_SPECREGS];
-
- if (idg->i_offset + idg->i_len != idf->i_offset
- || idf->i_offset + idf->i_len != ids->i_offset)
- return 0; /* Can't deal with non-contig regs */
-
- if (bfd_seek (abfd, idg->i_offset, SEEK_SET) != 0)
- return NULL;
-
- make_bfd_asection (abfd, ".reg",
- SEC_HAS_CONTENTS,
- idg->i_len + idf->i_len + ids->i_len,
- 0,
- idg->i_offset);
-
- /* OK, we believe you. You're a core file (sure, sure). */
-
- return abfd->xvec;
-}
-
-static char *
-irix_core_core_file_failing_command (abfd)
- bfd *abfd;
-{
- return core_command (abfd);
-}
-
-static int
-irix_core_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return core_signal (abfd);
-}
-
-static boolean
-irix_core_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- return true; /* XXX - FIXME */
-}
-
-static asymbol *
-irix_core_make_empty_symbol (abfd)
- bfd *abfd;
-{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
- if (new)
- new->the_bfd = abfd;
- return new;
-}
-
-#define irix_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
-#define irix_core_get_symtab _bfd_nosymbols_get_symtab
-#define irix_core_print_symbol _bfd_nosymbols_print_symbol
-#define irix_core_get_symbol_info _bfd_nosymbols_get_symbol_info
-#define irix_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
-#define irix_core_get_lineno _bfd_nosymbols_get_lineno
-#define irix_core_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define irix_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define irix_core_read_minisymbols _bfd_nosymbols_read_minisymbols
-#define irix_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
-
-/* 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 ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
-#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
-#define NO_SIGNED_GET \
- ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-
-const bfd_target irix_core_vec =
- {
- "irix-core",
- bfd_target_unknown_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIAN_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* symbol prefix */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
-
- { /* bfd_check_format */
- _bfd_dummy_target, /* unknown format */
- _bfd_dummy_target, /* object file */
- _bfd_dummy_target, /* archive */
- irix_core_core_file_p /* a core file */
- },
- { /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
- { /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (irix_core),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (irix_core),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0 /* backend_data */
-};
-
-#endif /* IRIX_CORE */
diff --git a/contrib/gdb/bfd/libbfd-in.h b/contrib/gdb/bfd/libbfd-in.h
deleted file mode 100644
index 14935eb..0000000
--- a/contrib/gdb/bfd/libbfd-in.h
+++ /dev/null
@@ -1,503 +0,0 @@
-/* libbfd.h -- Declarations used by bfd library *implementation*.
- (This include file is not for users of the library.)
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-** NOTE: libbfd.h is a GENERATED file. Don't change it; instead,
-** change libbfd-in.h or the other BFD source files processed to
-** generate this file.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* 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 BFD_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.any = (PTR) (v))
-
-/* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points
- to an instance of this structure. */
-
-struct bfd_in_memory
-{
- /* Size of buffer. */
- bfd_size_type size;
- /* Buffer holding contents of BFD. */
- bfd_byte *buffer;
-};
-
-/* 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 */
- /* when more compilers are standard C, this can be a time_t */
- long armap_timestamp; /* Timestamp value written into armap.
- This is used for BSD archives to check
- that the timestamp is recent enough
- for the BSD linker to not complain,
- just before we finish writing an
- archive. */
- file_ptr armap_datepos; /* Position within archive to seek to
- rewrite the date field. */
- PTR tdata; /* Backend specific information. */
-};
-
-#define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
-
-/* 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)
-
-extern PTR bfd_malloc PARAMS ((size_t));
-extern PTR bfd_realloc PARAMS ((PTR, size_t));
-extern PTR bfd_zmalloc PARAMS ((size_t));
-
-extern bfd_error_handler_type _bfd_error_handler;
-
-/* These routines allocate and free things on the BFD's obstack. */
-
-PTR bfd_alloc PARAMS ((bfd *abfd, size_t size));
-PTR bfd_zalloc PARAMS ((bfd *abfd, size_t size));
-void bfd_alloc_grow PARAMS ((bfd *abfd, PTR thing, size_t size));
-PTR bfd_alloc_finish PARAMS ((bfd *abfd));
-PTR bfd_alloc_by_size_t PARAMS ((bfd *abfd, size_t wanted));
-
-#define bfd_release(x,y) (void) obstack_free(&(x->memory),y)
-
-bfd * _bfd_create_empty_archive_element_shell PARAMS ((bfd *obfd));
-bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *arch_bfd, file_ptr index));
-boolean _bfd_add_bfd_to_archive_cache PARAMS ((bfd *, file_ptr, bfd *));
-boolean _bfd_generic_mkarchive PARAMS ((bfd *abfd));
-const bfd_target *bfd_generic_archive_p PARAMS ((bfd *abfd));
-boolean bfd_slurp_armap PARAMS ((bfd *abfd));
-boolean bfd_slurp_bsd_armap_f2 PARAMS ((bfd *abfd));
-#define bfd_slurp_bsd_armap bfd_slurp_armap
-#define bfd_slurp_coff_armap bfd_slurp_armap
-boolean _bfd_slurp_extended_name_table PARAMS ((bfd *abfd));
-extern boolean _bfd_construct_extended_name_table
- PARAMS ((bfd *, boolean, char **, bfd_size_type *));
-boolean _bfd_write_archive_contents PARAMS ((bfd *abfd));
-boolean _bfd_compute_and_write_armap PARAMS ((bfd *, unsigned int elength));
-bfd *_bfd_get_elt_at_filepos PARAMS ((bfd *archive, file_ptr filepos));
-extern bfd *_bfd_generic_get_elt_at_index PARAMS ((bfd *, symindex));
-bfd * _bfd_new_bfd PARAMS ((void));
-
-boolean bfd_false PARAMS ((bfd *ignore));
-boolean bfd_true PARAMS ((bfd *ignore));
-PTR bfd_nullvoidptr PARAMS ((bfd *ignore));
-int bfd_0 PARAMS ((bfd *ignore));
-unsigned int bfd_0u PARAMS ((bfd *ignore));
-long bfd_0l PARAMS ((bfd *ignore));
-long _bfd_n1 PARAMS ((bfd *ignore));
-void bfd_void PARAMS ((bfd *ignore));
-
-bfd *_bfd_new_bfd_contained_in PARAMS ((bfd *));
-const bfd_target *_bfd_dummy_target PARAMS ((bfd *abfd));
-
-void bfd_dont_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
- char *hdr));
-void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
- char *hdr));
-void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
- char *hdr));
-
-boolean bsd_write_armap PARAMS ((bfd *arch, unsigned int elength,
- struct orl *map, unsigned int orl_count, int stridx));
-
-boolean coff_write_armap PARAMS ((bfd *arch, unsigned int elength,
- struct orl *map, unsigned int orl_count, int stridx));
-
-extern PTR _bfd_generic_read_ar_hdr PARAMS ((bfd *));
-
-extern PTR _bfd_generic_read_ar_hdr_mag PARAMS ((bfd *, const char *));
-
-bfd * bfd_generic_openr_next_archived_file PARAMS ((bfd *archive,
- bfd *last_file));
-
-int bfd_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
-
-#define _bfd_read_ar_hdr(abfd) \
- BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd))
-
-/* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use
- BFD_JUMP_TABLE_GENERIC (_bfd_generic). */
-
-#define _bfd_generic_close_and_cleanup bfd_true
-#define _bfd_generic_bfd_free_cached_info bfd_true
-#define _bfd_generic_new_section_hook \
- ((boolean (*) PARAMS ((bfd *, asection *))) bfd_true)
-extern boolean _bfd_generic_get_section_contents
- PARAMS ((bfd *, asection *, PTR location, file_ptr offset,
- bfd_size_type count));
-extern boolean _bfd_generic_get_section_contents_in_window
- PARAMS ((bfd *, asection *, bfd_window *, file_ptr, bfd_size_type));
-
-/* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
- BFD_JUMP_TABLE_COPY (_bfd_generic). */
-
-#define _bfd_generic_bfd_copy_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
-#define _bfd_generic_bfd_merge_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
-#define _bfd_generic_bfd_set_private_flags \
- ((boolean (*) PARAMS ((bfd *, flagword))) bfd_true)
-#define _bfd_generic_bfd_copy_private_section_data \
- ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true)
-#define _bfd_generic_bfd_copy_private_symbol_data \
- ((boolean (*) PARAMS ((bfd *, asymbol *, bfd *, asymbol *))) bfd_true)
-#define _bfd_generic_bfd_print_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, PTR))) bfd_true)
-
-/* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file
- support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */
-
-extern char *_bfd_nocore_core_file_failing_command PARAMS ((bfd *));
-extern int _bfd_nocore_core_file_failing_signal PARAMS ((bfd *));
-extern boolean _bfd_nocore_core_file_matches_executable_p
- PARAMS ((bfd *, bfd *));
-
-/* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
- file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
-
-#define _bfd_noarchive_slurp_armap bfd_false
-#define _bfd_noarchive_slurp_extended_name_table bfd_false
-#define _bfd_noarchive_construct_extended_name_table \
- ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
- bfd_false)
-#define _bfd_noarchive_truncate_arname \
- ((void (*) PARAMS ((bfd *, const char *, char *))) bfd_void)
-#define _bfd_noarchive_write_armap \
- ((boolean (*) \
- PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
- bfd_false)
-#define _bfd_noarchive_read_ar_hdr bfd_nullvoidptr
-#define _bfd_noarchive_openr_next_archived_file \
- ((bfd *(*) PARAMS ((bfd *, bfd *))) bfd_nullvoidptr)
-#define _bfd_noarchive_get_elt_at_index \
- ((bfd *(*) PARAMS ((bfd *, symindex))) bfd_nullvoidptr)
-#define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define _bfd_noarchive_update_armap_timestamp bfd_false
-
-/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style
- archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */
-
-#define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap
-#define _bfd_archive_bsd_slurp_extended_name_table \
- _bfd_slurp_extended_name_table
-extern boolean _bfd_archive_bsd_construct_extended_name_table
- PARAMS ((bfd *, char **, bfd_size_type *, const char **));
-#define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
-#define _bfd_archive_bsd_write_armap bsd_write_armap
-#define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
-#define _bfd_archive_bsd_openr_next_archived_file \
- bfd_generic_openr_next_archived_file
-#define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index
-#define _bfd_archive_bsd_generic_stat_arch_elt \
- bfd_generic_stat_arch_elt
-extern boolean _bfd_archive_bsd_update_armap_timestamp PARAMS ((bfd *));
-
-/* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style
- archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */
-
-#define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap
-#define _bfd_archive_coff_slurp_extended_name_table \
- _bfd_slurp_extended_name_table
-extern boolean _bfd_archive_coff_construct_extended_name_table
- PARAMS ((bfd *, char **, bfd_size_type *, const char **));
-#define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
-#define _bfd_archive_coff_write_armap coff_write_armap
-#define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
-#define _bfd_archive_coff_openr_next_archived_file \
- bfd_generic_openr_next_archived_file
-#define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index
-#define _bfd_archive_coff_generic_stat_arch_elt \
- bfd_generic_stat_arch_elt
-#define _bfd_archive_coff_update_armap_timestamp bfd_true
-
-/* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol
- support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */
-
-#define _bfd_nosymbols_get_symtab_upper_bound _bfd_n1
-#define _bfd_nosymbols_get_symtab \
- ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
-#define _bfd_nosymbols_make_empty_symbol \
- ((asymbol *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
-#define _bfd_nosymbols_print_symbol \
- ((void (*) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type))) bfd_void)
-#define _bfd_nosymbols_get_symbol_info \
- ((void (*) PARAMS ((bfd *, asymbol *, symbol_info *))) bfd_void)
-#define _bfd_nosymbols_bfd_is_local_label \
- ((boolean (*) PARAMS ((bfd *, asymbol *))) bfd_false)
-#define _bfd_nosymbols_get_lineno \
- ((alent *(*) PARAMS ((bfd *, asymbol *))) bfd_nullvoidptr)
-#define _bfd_nosymbols_find_nearest_line \
- ((boolean (*) \
- PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, \
- const char **, unsigned int *))) \
- bfd_false)
-#define _bfd_nosymbols_bfd_make_debug_symbol \
- ((asymbol *(*) PARAMS ((bfd *, PTR, unsigned long))) bfd_nullvoidptr)
-#define _bfd_nosymbols_read_minisymbols \
- ((long (*) PARAMS ((bfd *, boolean, PTR *, unsigned int *))) _bfd_n1)
-#define _bfd_nosymbols_minisymbol_to_symbol \
- ((asymbol *(*) PARAMS ((bfd *, boolean, const PTR, asymbol *))) \
- bfd_nullvoidptr)
-
-/* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc
- support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */
-
-#define _bfd_norelocs_get_reloc_upper_bound \
- ((long (*) PARAMS ((bfd *, asection *))) _bfd_n1)
-#define _bfd_norelocs_canonicalize_reloc \
- ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) _bfd_n1)
-#define _bfd_norelocs_bfd_reloc_type_lookup \
- ((reloc_howto_type *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) \
- bfd_nullvoidptr)
-
-/* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not
- be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */
-
-#define _bfd_nowrite_set_arch_mach \
- ((boolean (*) PARAMS ((bfd *, enum bfd_architecture, unsigned long))) \
- bfd_false)
-#define _bfd_nowrite_set_section_contents \
- ((boolean (*) PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type))) \
- bfd_false)
-
-/* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use
- BFD_JUMP_TABLE_WRITE (_bfd_generic). */
-
-#define _bfd_generic_set_arch_mach bfd_default_set_arch_mach
-extern boolean _bfd_generic_set_section_contents
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-
-/* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not
- support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */
-
-#define _bfd_nolink_sizeof_headers ((int (*) PARAMS ((bfd *, boolean))) bfd_0)
-#define _bfd_nolink_bfd_get_relocated_section_contents \
- ((bfd_byte *(*) \
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, \
- bfd_byte *, boolean, asymbol **))) \
- bfd_nullvoidptr)
-#define _bfd_nolink_bfd_relax_section \
- ((boolean (*) \
- PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *))) \
- bfd_false)
-#define _bfd_nolink_bfd_link_hash_table_create \
- ((struct bfd_link_hash_table *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
-#define _bfd_nolink_bfd_link_add_symbols \
- ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
-#define _bfd_nolink_bfd_final_link \
- ((boolean (*) PARAMS ((bfd *, struct bfd_link_info *))) bfd_false)
-#define _bfd_nolink_bfd_link_split_section \
- ((boolean (*) PARAMS ((bfd *, struct sec *))) bfd_false)
-
-/* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not
- have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC
- (_bfd_nodynamic). */
-
-#define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_n1
-#define _bfd_nodynamic_canonicalize_dynamic_symtab \
- ((long (*) PARAMS ((bfd *, asymbol **))) _bfd_n1)
-#define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_n1
-#define _bfd_nodynamic_canonicalize_dynamic_reloc \
- ((long (*) PARAMS ((bfd *, arelent **, asymbol **))) _bfd_n1)
-
-/* Generic routine to determine of the given symbol is a local
- label. */
-extern boolean bfd_generic_is_local_label PARAMS ((bfd *, asymbol *));
-
-/* Generic minisymbol routines. */
-extern long _bfd_generic_read_minisymbols
- PARAMS ((bfd *, boolean, PTR *, unsigned int *));
-extern asymbol *_bfd_generic_minisymbol_to_symbol
- PARAMS ((bfd *, boolean, const PTR, asymbol *));
-
-/* Find the nearest line using .stab/.stabstr sections. */
-extern boolean _bfd_stab_section_find_nearest_line
- PARAMS ((bfd *, asymbol **, asection *, bfd_vma, boolean *, const char **,
- const char **, unsigned int *, PTR *));
-
-/* A routine to create entries for a bfd_link_hash_table. */
-extern struct bfd_hash_entry *_bfd_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string));
-
-/* Initialize a bfd_link_hash_table. */
-extern boolean _bfd_link_hash_table_init
- PARAMS ((struct bfd_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-
-/* Generic link hash table creation routine. */
-extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
- PARAMS ((bfd *));
-
-/* Generic add symbol routine. */
-extern boolean _bfd_generic_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Generic add symbol routine. This version is used by targets for
- which the linker must collect constructors and destructors by name,
- as the collect2 program does. */
-extern boolean _bfd_generic_link_add_symbols_collect
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Generic archive add symbol routine. */
-extern boolean _bfd_generic_link_add_archive_symbols
- PARAMS ((bfd *, struct bfd_link_info *,
- boolean (*checkfn) (bfd *, struct bfd_link_info *, boolean *)));
-
-/* Forward declaration to avoid prototype errors. */
-typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
-
-/* Generic routine to add a single symbol. */
-extern boolean _bfd_generic_link_add_one_symbol
- PARAMS ((struct bfd_link_info *, bfd *, const char *name, flagword,
- asection *, bfd_vma, const char *, boolean copy,
- boolean constructor, struct bfd_link_hash_entry **));
-
-/* Generic link routine. */
-extern boolean _bfd_generic_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-extern boolean _bfd_generic_link_split_section
- PARAMS ((bfd *, struct sec *));
-
-/* Generic reloc_link_order processing routine. */
-extern boolean _bfd_generic_reloc_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-
-/* Default link order processing routine. */
-extern boolean _bfd_default_link_order
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- struct bfd_link_order *));
-
-/* Count the number of reloc entries in a link order list. */
-extern unsigned int _bfd_count_link_order_relocs
- PARAMS ((struct bfd_link_order *));
-
-/* Final link relocation routine. */
-extern bfd_reloc_status_type _bfd_final_link_relocate
- PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
- bfd_vma address, bfd_vma value, bfd_vma addend));
-
-/* Relocate a particular location by a howto and a value. */
-extern bfd_reloc_status_type _bfd_relocate_contents
- PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
-
-/* Create a string table. */
-extern struct bfd_strtab_hash *_bfd_stringtab_init PARAMS ((void));
-
-/* Create an XCOFF .debug section style string table. */
-extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init PARAMS ((void));
-
-/* Free a string table. */
-extern void _bfd_stringtab_free PARAMS ((struct bfd_strtab_hash *));
-
-/* Get the size of a string table. */
-extern bfd_size_type _bfd_stringtab_size PARAMS ((struct bfd_strtab_hash *));
-
-/* Add a string to a string table. */
-extern bfd_size_type _bfd_stringtab_add
- PARAMS ((struct bfd_strtab_hash *, const char *, boolean hash,
- boolean copy));
-
-/* Write out a string table. */
-extern boolean _bfd_stringtab_emit PARAMS ((bfd *, struct bfd_strtab_hash *));
-
-/* 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)
-
-void bfd_assert PARAMS ((const char*,int));
-
-#define BFD_ASSERT(x) \
-{ if (!(x)) bfd_assert(__FILE__,__LINE__); }
-
-#define BFD_FAIL() \
-{ bfd_assert(__FILE__,__LINE__); }
-
-FILE * bfd_cache_lookup_worker PARAMS ((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
-
-/* List of supported target vectors, and the default vector (if
- bfd_default_vector[0] is NULL, there is no default). */
-extern const bfd_target * const bfd_target_vector[];
-extern const bfd_target * const bfd_default_vector[];
-
-/* Functions shared by the ECOFF and MIPS ELF backends, which have no
- other common header files. */
-
-#if defined(__STDC__) || defined(ALMOST_STDC)
-struct ecoff_find_line;
-#endif
-
-extern boolean _bfd_ecoff_locate_line
- PARAMS ((bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
- const struct ecoff_debug_swap * const, struct ecoff_find_line *,
- const char **, const char **, unsigned int *));
-extern boolean _bfd_ecoff_get_accumulated_pdr PARAMS ((PTR, bfd_byte *));
-extern boolean _bfd_ecoff_get_accumulated_sym PARAMS ((PTR, bfd_byte *));
-extern boolean _bfd_ecoff_get_accumulated_ss PARAMS ((PTR, bfd_byte *));
-
-extern bfd_vma _bfd_get_gp_value PARAMS ((bfd *));
-extern void _bfd_set_gp_value PARAMS ((bfd *, bfd_vma));
-
-/* And more follows */
-
diff --git a/contrib/gdb/bfd/libcoff-in.h b/contrib/gdb/bfd/libcoff-in.h
deleted file mode 100644
index 648ed80..0000000
--- a/contrib/gdb/bfd/libcoff-in.h
+++ /dev/null
@@ -1,482 +0,0 @@
-/* BFD COFF object file private structure.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-** NOTE: libcoff.h is a GENERATED file. Don't change it; instead,
-** change libcoff-in.h or coffcode.h.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfdlink.h"
-
-/* Object file tdata; access macros */
-
-#define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
-#define exec_hdr(bfd) (coff_data(bfd)->hdr)
-#define obj_pe(bfd) (coff_data(bfd)->pe)
-#define obj_symbols(bfd) (coff_data(bfd)->symbols)
-#define obj_sym_filepos(bfd) (coff_data(bfd)->sym_filepos)
-
-#define obj_relocbase(bfd) (coff_data(bfd)->relocbase)
-#define obj_raw_syments(bfd) (coff_data(bfd)->raw_syments)
-#define obj_raw_syment_count(bfd) (coff_data(bfd)->raw_syment_count)
-#define obj_convert(bfd) (coff_data(bfd)->conversion_table)
-#define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
-
-#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms)
-#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms)
-#define obj_coff_strings(bfd) (coff_data (bfd)->strings)
-#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings)
-#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes)
-
-#define obj_coff_local_toc_table(bfd) (coff_data(bfd)->local_toc_sym_map)
-
-/* `Tdata' information kept for COFF files. */
-
-typedef struct coff_tdata
-{
- struct coff_symbol_struct *symbols; /* symtab for input bfd */
- unsigned int *conversion_table;
- int conv_table_size;
- file_ptr sym_filepos;
-
- struct coff_ptr_struct *raw_syments;
- unsigned int raw_syment_count;
-
- /* These are only valid once writing has begun */
- long int relocbase;
-
- /* These members communicate important constants about the symbol table
- to GDB's symbol-reading code. These `constants' unfortunately vary
- from coff implementation to implementation... */
- unsigned local_n_btmask;
- unsigned local_n_btshft;
- unsigned local_n_tmask;
- unsigned local_n_tshift;
- unsigned local_symesz;
- unsigned local_auxesz;
- unsigned local_linesz;
-
- /* The unswapped external symbols. May be NULL. Read by
- _bfd_coff_get_external_symbols. */
- PTR external_syms;
- /* If this is true, the external_syms may not be freed. */
- boolean keep_syms;
-
- /* The string table. May be NULL. Read by
- _bfd_coff_read_string_table. */
- char *strings;
- /* If this is true, the strings may not be freed. */
- boolean keep_strings;
-
- /* is this a PE format coff file */
- int pe;
- /* Used by the COFF backend linker. */
- struct coff_link_hash_entry **sym_hashes;
-
- /* used by the pe linker for PowerPC */
- int *local_toc_sym_map;
-
- struct bfd_link_info *link_info;
-
- /* Used by coff_find_nearest_line. */
- PTR line_info;
-} coff_data_type;
-
-/* Tdata for pe image files. */
-typedef struct pe_tdata
-{
- coff_data_type coff;
- struct internal_extra_pe_aouthdr pe_opthdr;
- int dll;
- int has_reloc_section;
- boolean (*in_reloc_p) PARAMS((bfd *, reloc_howto_type *));
- flagword real_flags;
-} pe_data_type;
-
-#define pe_data(bfd) ((bfd)->tdata.pe_obj_data)
-
-/* Tdata for XCOFF files. */
-
-struct xcoff_tdata
-{
- /* Basic COFF information. */
- coff_data_type coff;
-
- /* True if a large a.out header should be generated. */
- boolean full_aouthdr;
-
- /* TOC value. */
- bfd_vma toc;
-
- /* Index of section holding TOC. */
- int sntoc;
-
- /* Index of section holding entry point. */
- int snentry;
-
- /* .text alignment from optional header. */
- int text_align_power;
-
- /* .data alignment from optional header. */
- int data_align_power;
-
- /* modtype from optional header. */
- short modtype;
-
- /* cputype from optional header. */
- short cputype;
-
- /* maxdata from optional header. */
- bfd_size_type maxdata;
-
- /* maxstack from optional header. */
- bfd_size_type maxstack;
-
- /* Used by the XCOFF backend linker. */
- asection **csects;
- unsigned long *debug_indices;
- unsigned int import_file_id;
-};
-
-#define xcoff_data(abfd) ((abfd)->tdata.xcoff_obj_data)
-
-/* 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 used_by_bfd field of a section may be set to a pointer to this
- structure. */
-
-struct coff_section_tdata
-{
- /* The relocs, swapped into COFF internal form. This may be NULL. */
- struct internal_reloc *relocs;
- /* If this is true, the relocs entry may not be freed. */
- boolean keep_relocs;
- /* The section contents. This may be NULL. */
- bfd_byte *contents;
- /* If this is true, the contents entry may not be freed. */
- boolean keep_contents;
- /* Information cached by coff_find_nearest_line. */
- bfd_vma offset;
- unsigned int i;
- const char *function;
- int line_base;
- /* Available for individual backends. */
- PTR tdata;
-};
-
-/* An accessor macro for the coff_section_tdata structure. */
-#define coff_section_data(abfd, sec) \
- ((struct coff_section_tdata *) (sec)->used_by_bfd)
-
-/* Tdata for sections in XCOFF files. This is used by the linker. */
-
-struct xcoff_section_tdata
-{
- /* Used for XCOFF csects created by the linker; points to the real
- XCOFF section which contains this csect. */
- asection *enclosing;
- /* The lineno_count field for the enclosing section, because we are
- going to clobber it there. */
- unsigned int lineno_count;
- /* The first and one past the last symbol indices for symbols used
- by this csect. */
- unsigned long first_symndx;
- unsigned long last_symndx;
-};
-
-/* An accessor macro the xcoff_section_tdata structure. */
-#define xcoff_section_data(abfd, sec) \
- ((struct xcoff_section_tdata *) coff_section_data ((abfd), (sec))->tdata)
-
-/* COFF linker hash table entries. */
-
-struct coff_link_hash_entry
-{
- struct bfd_link_hash_entry root;
-
- /* Symbol index in output file. Set to -1 initially. Set to -2 if
- there is a reloc against this symbol. */
- long indx;
-
- /* Symbol type. */
- unsigned short type;
-
- /* Symbol class. */
- unsigned char class;
-
- /* Number of auxiliary entries. */
- char numaux;
-
- /* BFD to take auxiliary entries from. */
- bfd *auxbfd;
-
- /* Pointer to array of auxiliary entries, if any. */
- union internal_auxent *aux;
-};
-
-/* COFF linker hash table. */
-
-struct coff_link_hash_table
-{
- struct bfd_link_hash_table root;
-};
-
-/* Look up an entry in a COFF linker hash table. */
-
-#define coff_link_hash_lookup(table, string, create, copy, follow) \
- ((struct coff_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), \
- (copy), (follow)))
-
-/* Traverse a COFF linker hash table. */
-
-#define coff_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the COFF linker hash table from a link_info structure. */
-
-#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
-
-/* Functions in coffgen.c. */
-extern const bfd_target *coff_object_p PARAMS ((bfd *));
-extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
-extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
-extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
-extern int coff_count_linenumbers PARAMS ((bfd *));
-extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
-extern boolean coff_renumber_symbols PARAMS ((bfd *, int *));
-extern void coff_mangle_symbols PARAMS ((bfd *));
-extern boolean coff_write_symbols PARAMS ((bfd *));
-extern boolean coff_write_linenumbers PARAMS ((bfd *));
-extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
-extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
-extern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *));
-extern const char *_bfd_coff_read_string_table PARAMS ((bfd *));
-extern boolean _bfd_coff_free_symbols PARAMS ((bfd *));
-extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
-extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
-extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
-extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
- bfd_print_symbol_type how));
-extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
- symbol_info *ret));
-extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
- unsigned long));
-extern boolean coff_find_nearest_line PARAMS ((bfd *,
- asection *,
- asymbol **,
- bfd_vma offset,
- CONST char **filename_ptr,
- CONST char **functionname_ptr,
- unsigned int *line_ptr));
-extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
-extern boolean bfd_coff_reloc16_relax_section
- PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
-extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
- PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *, boolean relocateable, asymbol **));
-extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
- struct bfd_link_info *,
- asection *));
-extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
- asection *input_section,
- bfd_vma val));
-
-/* Functions and types in cofflink.c. */
-
-#define STRING_SIZE_SIZE (4)
-
-/* We use a hash table to merge identical enum, struct, and union
- definitions in the linker. */
-
-/* Information we keep for a single element (an enum value, a
- structure or union field) in the debug merge hash table. */
-
-struct coff_debug_merge_element
-{
- /* Next element. */
- struct coff_debug_merge_element *next;
-
- /* Name. */
- const char *name;
-
- /* Type. */
- unsigned int type;
-
- /* Symbol index for complex type. */
- long tagndx;
-};
-
-/* A linked list of debug merge entries for a given name. */
-
-struct coff_debug_merge_type
-{
- /* Next type with the same name. */
- struct coff_debug_merge_type *next;
-
- /* Class of type. */
- int class;
-
- /* Symbol index where this type is defined. */
- long indx;
-
- /* List of elements. */
- struct coff_debug_merge_element *elements;
-};
-
-/* Information we store in the debug merge hash table. */
-
-struct coff_debug_merge_hash_entry
-{
- struct bfd_hash_entry root;
-
- /* A list of types with this name. */
- struct coff_debug_merge_type *types;
-};
-
-/* The debug merge hash table. */
-
-struct coff_debug_merge_hash_table
-{
- struct bfd_hash_table root;
-};
-
-/* Initialize a COFF debug merge hash table. */
-
-#define coff_debug_merge_hash_table_init(table) \
- (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc))
-
-/* Free a COFF debug merge hash table. */
-
-#define coff_debug_merge_hash_table_free(table) \
- (bfd_hash_table_free (&(table)->root))
-
-/* Look up an entry in a COFF debug merge hash table. */
-
-#define coff_debug_merge_hash_lookup(table, string, create, copy) \
- ((struct coff_debug_merge_hash_entry *) \
- bfd_hash_lookup (&(table)->root, (string), (create), (copy)))
-
-/* Information we keep for each section in the output file when doing
- a relocateable link. */
-
-struct coff_link_section_info
-{
- /* The relocs to be output. */
- struct internal_reloc *relocs;
- /* For each reloc against a global symbol whose index was not known
- when the reloc was handled, the global hash table entry. */
- struct coff_link_hash_entry **rel_hashes;
-};
-
-/* Information that we pass around while doing the final link step. */
-
-struct coff_final_link_info
-{
- /* General link information. */
- struct bfd_link_info *info;
- /* Output BFD. */
- bfd *output_bfd;
- /* Used to indicate failure in traversal routine. */
- boolean failed;
- /* Hash table for long symbol names. */
- struct bfd_strtab_hash *strtab;
- /* When doing a relocateable link, an array of information kept for
- each output section, indexed by the target_index field. */
- struct coff_link_section_info *section_info;
- /* Symbol index of last C_FILE symbol (-1 if none). */
- long last_file_index;
- /* Contents of last C_FILE symbol. */
- struct internal_syment last_file;
- /* Hash table used to merge debug information. */
- struct coff_debug_merge_hash_table debug_merge;
- /* Buffer large enough to hold swapped symbols of any input file. */
- struct internal_syment *internal_syms;
- /* Buffer large enough to hold sections of symbols of any input file. */
- asection **sec_ptrs;
- /* Buffer large enough to hold output indices of symbols of any
- input file. */
- long *sym_indices;
- /* Buffer large enough to hold output symbols for any input file. */
- bfd_byte *outsyms;
- /* Buffer large enough to hold external line numbers for any input
- section. */
- bfd_byte *linenos;
- /* Buffer large enough to hold any input section. */
- bfd_byte *contents;
- /* Buffer large enough to hold external relocs of any input section. */
- bfd_byte *external_relocs;
- /* Buffer large enough to hold swapped relocs of any input section. */
- struct internal_reloc *internal_relocs;
-};
-
-extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-extern boolean _bfd_coff_link_hash_table_init
- PARAMS ((struct coff_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
-extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
- PARAMS ((bfd *));
-extern const char *_bfd_coff_internal_syment_name
- PARAMS ((bfd *, const struct internal_syment *, char *));
-extern boolean _bfd_coff_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_coff_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-extern struct internal_reloc *_bfd_coff_read_internal_relocs
- PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean,
- struct internal_reloc *));
-extern boolean _bfd_coff_generic_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- struct internal_reloc *, struct internal_syment *, asection **));
-
-extern struct bfd_hash_entry *_bfd_coff_debug_merge_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-extern boolean _bfd_coff_write_global_sym
- PARAMS ((struct coff_link_hash_entry *, PTR));
-extern boolean _bfd_coff_link_input_bfd
- PARAMS ((struct coff_final_link_info *, bfd *));
-extern boolean _bfd_coff_reloc_link_order
- PARAMS ((bfd *, struct coff_final_link_info *, asection *,
- struct bfd_link_order *));
-
-
-#define coff_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-/* Functions in xcofflink.c. */
-
-extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
- PARAMS ((bfd *));
-extern boolean _bfd_xcoff_bfd_link_add_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_xcoff_bfd_final_link
- PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_ppc_xcoff_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- struct internal_reloc *, struct internal_syment *, asection **));
-
-/* And more taken from the source .. */
-
diff --git a/contrib/gdb/bfd/libhppa.h b/contrib/gdb/bfd/libhppa.h
deleted file mode 100644
index fa97b68..0000000
--- a/contrib/gdb/bfd/libhppa.h
+++ /dev/null
@@ -1,549 +0,0 @@
-/* HP PA-RISC SOM object file format: definitions internal to BFD.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
-
- Contributed by the Center for Software Science at the
- University of Utah (pa-gdb-bugs@cs.utah.edu).
-
- This file is part of BFD, the Binary File Descriptor library.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _HPPA_H
-#define _HPPA_H
-
-#define BYTES_IN_WORD 4
-#define PA_PAGESIZE 0x1000
-
-#ifndef INLINE
-#ifdef __GNUC__
-#define INLINE inline
-#else
-#define INLINE
-#endif /* GNU C? */
-#endif /* INLINE */
-
-/* The PA instruction set variants. */
-enum pa_arch {pa10 = 10, pa11 = 11, pa20 = 20};
-
-/* HP PA-RISC relocation types */
-
-enum hppa_reloc_field_selector_type
- {
- R_HPPA_FSEL = 0x0,
- R_HPPA_LSSEL = 0x1,
- R_HPPA_RSSEL = 0x2,
- R_HPPA_LSEL = 0x3,
- R_HPPA_RSEL = 0x4,
- R_HPPA_LDSEL = 0x5,
- R_HPPA_RDSEL = 0x6,
- R_HPPA_LRSEL = 0x7,
- R_HPPA_RRSEL = 0x8,
- R_HPPA_NSEL = 0x9,
- R_HPPA_NLSEL = 0xa,
- R_HPPA_NLRSEL = 0xb,
- R_HPPA_PSEL = 0xc,
- R_HPPA_LPSEL = 0xd,
- R_HPPA_RPSEL = 0xe,
- R_HPPA_TSEL = 0xf,
- R_HPPA_LTSEL = 0x10,
- R_HPPA_RTSEL = 0x11
- };
-
-/* /usr/include/reloc.h defines these to constants. We want to use
- them in enums, so #undef them before we start using them. We might
- be able to fix this another way by simply managing not to include
- /usr/include/reloc.h, but currently GDB picks up these defines
- somewhere. */
-#undef e_fsel
-#undef e_lssel
-#undef e_rssel
-#undef e_lsel
-#undef e_rsel
-#undef e_ldsel
-#undef e_rdsel
-#undef e_lrsel
-#undef e_rrsel
-#undef e_nsel
-#undef e_nlsel
-#undef e_nlrsel
-#undef e_psel
-#undef e_lpsel
-#undef e_rpsel
-#undef e_tsel
-#undef e_ltsel
-#undef e_rtsel
-#undef e_one
-#undef e_two
-#undef e_pcrel
-#undef e_con
-#undef e_plabel
-#undef e_abs
-
-/* for compatibility */
-enum hppa_reloc_field_selector_type_alt
- {
- e_fsel = R_HPPA_FSEL,
- e_lssel = R_HPPA_LSSEL,
- e_rssel = R_HPPA_RSSEL,
- e_lsel = R_HPPA_LSEL,
- e_rsel = R_HPPA_RSEL,
- e_ldsel = R_HPPA_LDSEL,
- e_rdsel = R_HPPA_RDSEL,
- e_lrsel = R_HPPA_LRSEL,
- e_rrsel = R_HPPA_RRSEL,
- e_nsel = R_HPPA_NSEL,
- e_nlsel = R_HPPA_NLSEL,
- e_nlrsel = R_HPPA_NLRSEL,
- e_psel = R_HPPA_PSEL,
- e_lpsel = R_HPPA_LPSEL,
- e_rpsel = R_HPPA_RPSEL,
- e_tsel = R_HPPA_TSEL,
- e_ltsel = R_HPPA_LTSEL,
- e_rtsel = R_HPPA_RTSEL
- };
-
-enum hppa_reloc_expr_type
- {
- R_HPPA_E_ONE = 0,
- R_HPPA_E_TWO = 1,
- R_HPPA_E_PCREL = 2,
- R_HPPA_E_CON = 3,
- R_HPPA_E_PLABEL = 7,
- R_HPPA_E_ABS = 18
- };
-
-/* for compatibility */
-enum hppa_reloc_expr_type_alt
- {
- e_one = R_HPPA_E_ONE,
- e_two = R_HPPA_E_TWO,
- e_pcrel = R_HPPA_E_PCREL,
- e_con = R_HPPA_E_CON,
- e_plabel = R_HPPA_E_PLABEL,
- e_abs = R_HPPA_E_ABS
- };
-
-
-/* Relocations for function calls must be accompanied by parameter
- relocation bits. These bits describe exactly where the caller has
- placed the function's arguments and where it expects to find a return
- value.
-
- Both ELF and SOM encode this information within the addend field
- of the call relocation. (Note this could break very badly if one
- was to make a call like bl foo + 0x12345678).
-
- The high order 10 bits contain parameter relocation information,
- the low order 22 bits contain the constant offset. */
-
-#define HPPA_R_ARG_RELOC(a) (((a) >> 22) & 0x3FF)
-#define HPPA_R_CONSTANT(a) ((((int)(a)) << 10) >> 10)
-#define HPPA_R_ADDEND(r,c) (((r) << 22) + ((c) & 0x3FFFFF))
-
-/* Some functions to manipulate PA instructions. */
-static INLINE unsigned int
-assemble_3 (x)
- unsigned int x;
-{
- return (((x & 1) << 2) | ((x & 6) >> 1)) & 7;
-}
-
-static INLINE void
-dis_assemble_3 (x, r)
- unsigned int x;
- unsigned int *r;
-{
- *r = (((x & 4) >> 2) | ((x & 3) << 1)) & 7;
-}
-
-static INLINE unsigned int
-assemble_12 (x, y)
- unsigned int x, y;
-{
- return (((y & 1) << 11) | ((x & 1) << 10) | ((x & 0x7fe) >> 1)) & 0xfff;
-}
-
-static INLINE void
-dis_assemble_12 (as12, x, y)
- unsigned int as12;
- unsigned int *x, *y;
-{
- *y = (as12 & 0x800) >> 11;
- *x = ((as12 & 0x3ff) << 1) | ((as12 & 0x400) >> 10);
-}
-
-static INLINE unsigned long
-assemble_17 (x, y, z)
- unsigned int x, y, z;
-{
- unsigned long temp;
-
- temp = ((z & 1) << 16) |
- ((x & 0x1f) << 11) |
- ((y & 1) << 10) |
- ((y & 0x7fe) >> 1);
- return temp & 0x1ffff;
-}
-
-static INLINE void
-dis_assemble_17 (as17, x, y, z)
- unsigned int as17;
- unsigned int *x, *y, *z;
-{
-
- *z = (as17 & 0x10000) >> 16;
- *x = (as17 & 0x0f800) >> 11;
- *y = (((as17 & 0x00400) >> 10) | ((as17 & 0x3ff) << 1)) & 0x7ff;
-}
-
-static INLINE unsigned long
-assemble_21 (x)
- unsigned int x;
-{
- unsigned long temp;
-
- temp = ((x & 1) << 20) |
- ((x & 0xffe) << 8) |
- ((x & 0xc000) >> 7) |
- ((x & 0x1f0000) >> 14) |
- ((x & 0x003000) >> 12);
- return temp & 0x1fffff;
-}
-
-static INLINE void
-dis_assemble_21 (as21, x)
- unsigned int as21, *x;
-{
- unsigned long temp;
-
-
- temp = (as21 & 0x100000) >> 20;
- temp |= (as21 & 0x0ffe00) >> 8;
- temp |= (as21 & 0x000180) << 7;
- temp |= (as21 & 0x00007c) << 14;
- temp |= (as21 & 0x000003) << 12;
- *x = temp;
-}
-
-static INLINE unsigned long
-sign_extend (x, len)
- unsigned int x, len;
-{
- return (int)(x >> (len - 1) ? (-1 << len) | x : x);
-}
-
-static INLINE unsigned int
-ones (n)
- int n;
-{
- unsigned int len_ones;
- int i;
-
- i = 0;
- len_ones = 0;
- while (i < n)
- {
- len_ones = (len_ones << 1) | 1;
- i++;
- }
-
- return len_ones;
-}
-
-static INLINE void
-sign_unext (x, len, result)
- unsigned int x, len;
- unsigned int *result;
-{
- unsigned int len_ones;
-
- len_ones = ones (len);
-
- *result = x & len_ones;
-}
-
-static INLINE unsigned long
-low_sign_extend (x, len)
- unsigned int x, len;
-{
- return (int)((x & 0x1 ? (-1 << (len - 1)) : 0) | x >> 1);
-}
-
-static INLINE void
-low_sign_unext (x, len, result)
- unsigned int x, len;
- unsigned int *result;
-{
- unsigned int temp;
- unsigned int sign;
- unsigned int rest;
- unsigned int one_bit_at_len;
- unsigned int len_ones;
-
- len_ones = ones (len);
- one_bit_at_len = 1 << (len - 1);
-
- sign_unext (x, len, &temp);
- sign = temp & one_bit_at_len;
- sign >>= (len - 1);
-
- rest = temp & (len_ones ^ one_bit_at_len);
- rest <<= 1;
-
- *result = rest | sign;
-}
-
-/* Handle field selectors for PA instructions. */
-
-static INLINE unsigned long
-hppa_field_adjust (value, constant_value, r_field)
- unsigned long value;
- unsigned long constant_value;
- unsigned short r_field;
-{
- switch (r_field)
- {
- case e_fsel: /* F : no change */
- case e_nsel: /* N : no change */
- value += constant_value;
- break;
-
- case e_lssel: /* LS : if (bit 21) then add 0x800
- arithmetic shift right 11 bits */
- value += constant_value;
- if (value & 0x00000400)
- value += 0x800;
- value = (value & 0xfffff800) >> 11;
- break;
-
- case e_rssel: /* RS : Sign extend from bit 21 */
- value += constant_value;
- if (value & 0x00000400)
- value |= 0xfffff800;
- else
- value &= 0x7ff;
- break;
-
- case e_lsel: /* L : Arithmetic shift right 11 bits */
- case e_nlsel: /* NL : Arithmetic shift right 11 bits */
- value += constant_value;
- value = (value & 0xfffff800) >> 11;
- break;
-
- case e_rsel: /* R : Set bits 0-20 to zero */
- value += constant_value;
- value = value & 0x7ff;
- break;
-
- case e_ldsel: /* LD : Add 0x800, arithmetic shift
- right 11 bits */
- value += constant_value;
- value += 0x800;
- value = (value & 0xfffff800) >> 11;
- break;
-
- case e_rdsel: /* RD : Set bits 0-20 to one */
- value += constant_value;
- value |= 0xfffff800;
- break;
-
- case e_lrsel: /* LR : L with "rounded" constant */
- case e_nlrsel: /* NLR : NL with "rounded" constant */
- value = value + ((constant_value + 0x1000) & 0xffffe000);
- value = (value & 0xfffff800) >> 11;
- break;
-
- case e_rrsel: /* RR : R with "rounded" constant */
- value = value + ((constant_value + 0x1000) & 0xffffe000);
- value = (value & 0x7ff) + constant_value - ((constant_value + 0x1000) & 0xffffe000);
- break;
-
- default:
- abort ();
- }
- return value;
-
-}
-
-/* PA-RISC OPCODES */
-#define get_opcode(insn) ((insn) & 0xfc000000) >> 26
-
-/* FIXME: this list is incomplete. It should also be an enumerated
- type rather than #defines. */
-
-#define LDO 0x0d
-#define LDB 0x10
-#define LDH 0x11
-#define LDW 0x12
-#define LDWM 0x13
-#define STB 0x18
-#define STH 0x19
-#define STW 0x1a
-#define STWM 0x1b
-#define COMICLR 0x24
-#define SUBI 0x25
-#define SUBIO 0x25
-#define ADDIT 0x2c
-#define ADDITO 0x2c
-#define ADDI 0x2d
-#define ADDIO 0x2d
-#define LDIL 0x08
-#define ADDIL 0x0a
-
-#define MOVB 0x32
-#define MOVIB 0x33
-#define COMBT 0x20
-#define COMBF 0x22
-#define COMIBT 0x21
-#define COMIBF 0x23
-#define ADDBT 0x28
-#define ADDBF 0x2a
-#define ADDIBT 0x29
-#define ADDIBF 0x2b
-#define BVB 0x30
-#define BB 0x31
-
-#define BL 0x3a
-#define BLE 0x39
-#define BE 0x38
-
-
-/* Given a machine instruction, return its format.
-
- FIXME: opcodes which do not map to a known format
- should return an error of some sort. */
-
-static INLINE char
-bfd_hppa_insn2fmt (insn)
- unsigned long insn;
-{
- char fmt = -1;
- unsigned char op = get_opcode (insn);
-
- switch (op)
- {
- case ADDI:
- case ADDIT:
- case SUBI:
- fmt = 11;
- break;
- case MOVB:
- case MOVIB:
- case COMBT:
- case COMBF:
- case COMIBT:
- case COMIBF:
- case ADDBT:
- case ADDBF:
- case ADDIBT:
- case ADDIBF:
- case BVB:
- case BB:
- fmt = 12;
- break;
- case LDO:
- case LDB:
- case LDH:
- case LDW:
- case LDWM:
- case STB:
- case STH:
- case STW:
- case STWM:
- fmt = 14;
- break;
- case BL:
- case BE:
- case BLE:
- fmt = 17;
- break;
- case LDIL:
- case ADDIL:
- fmt = 21;
- break;
- default:
- fmt = 32;
- break;
- }
- return fmt;
-}
-
-
-/* Insert VALUE into INSN using R_FORMAT to determine exactly what
- bits to change. */
-
-static INLINE unsigned long
-hppa_rebuild_insn (abfd, insn, value, r_format)
- bfd *abfd;
- unsigned long insn;
- unsigned long value;
- unsigned long r_format;
-{
- unsigned long const_part;
- unsigned long rebuilt_part;
-
- switch (r_format)
- {
- case 11:
- {
- unsigned w1, w;
-
- const_part = insn & 0xffffe002;
- dis_assemble_12 (value, &w1, &w);
- rebuilt_part = (w1 << 2) | w;
- return const_part | rebuilt_part;
- }
-
- case 12:
- {
- unsigned w1, w;
-
- const_part = insn & 0xffffe002;
- dis_assemble_12 (value, &w1, &w);
- rebuilt_part = (w1 << 2) | w;
- return const_part | rebuilt_part;
- }
-
- case 14:
- const_part = insn & 0xffffc000;
- low_sign_unext (value, 14, &rebuilt_part);
- return const_part | rebuilt_part;
-
- case 17:
- {
- unsigned w1, w2, w;
-
- const_part = insn & 0xffe0e002;
- dis_assemble_17 (value, &w1, &w2, &w);
- rebuilt_part = (w2 << 2) | (w1 << 16) | w;
- return const_part | rebuilt_part;
- }
-
- case 21:
- const_part = insn & 0xffe00000;
- dis_assemble_21 (value, &rebuilt_part);
- return const_part | rebuilt_part;
-
- case 32:
- const_part = 0;
- return value;
-
- default:
- abort ();
- }
- return insn;
-}
-
-#endif /* _HPPA_H */
diff --git a/contrib/gdb/bfd/libieee.h b/contrib/gdb/bfd/libieee.h
deleted file mode 100644
index c3729cb..0000000
--- a/contrib/gdb/bfd/libieee.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/* IEEE-695 object file formats: definitions internal to BFD.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
- Written by Cygnus Support. Mostly Steve Chamberlain'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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-typedef struct {
- unsigned int index:24;
- char letter;
-} ieee_symbol_index_type;
-
-typedef struct ct {
- bfd *this;
- struct ct *next;
-} bfd_chain_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))
-/* FIXME! There should be no limit to the number of sections! */
-#define NSECTIONS 20
-
-
-typedef struct {
- unsigned char *input_p;
- unsigned char *first_byte;
- bfd *abfd;
-} common_header_type ;
-
-typedef struct ieee_data_struct
-{
- common_header_type h;
- boolean read_symbols;
- boolean read_data;
- 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;
-
-
- boolean symbol_table_full;
-
-
-boolean done_debug;
-
-
-bfd_chain_type *chain_head;
-bfd_chain_type *chain_root;
-
-} ieee_data_type;
-
-typedef struct {
- file_ptr file_offset;
- bfd *abfd;
-} ieee_ar_obstack_type;
-
-typedef struct ieee_ar_data_struct
-{
- common_header_type h;
- ieee_ar_obstack_type *elements;
-
- unsigned int element_index ;
- unsigned int element_count;
-
-} ieee_ar_data_type;
-
-#define IEEE_DATA(abfd) ((abfd)->tdata.ieee_data)
-#define IEEE_AR_DATA(abfd) ((abfd)->tdata.ieee_ar_data)
-
-#define ptr(abfd) (ieee_data(abfd)->input_p)
diff --git a/contrib/gdb/bfd/libnlm.h b/contrib/gdb/bfd/libnlm.h
deleted file mode 100644
index 12d2e4e..0000000
--- a/contrib/gdb/bfd/libnlm.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/* BFD back-end data structures for NLM (NetWare Loadable Modules) files.
- Copyright (C) 1993 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _LIBNLM_H_
-#define _LIBNLM_H_ 1
-
-#ifdef ARCH_SIZE
-# define NLM_ARCH_SIZE ARCH_SIZE
-#endif
-#include "nlm/common.h"
-#include "nlm/internal.h"
-#include "nlm/external.h"
-
-/* A reloc for an imported NLM symbol. Normal relocs are associated
- with sections, and include a symbol. These relocs are associated
- with (undefined) symbols, and include a section. */
-
-struct nlm_relent
-{
- /* Section of reloc. */
- asection *section;
- /* Reloc info (sym_ptr_ptr field set only when canonicalized). */
- arelent reloc;
-};
-
-/* Information we keep for an NLM symbol. */
-
-typedef struct
-{
- /* BFD symbol. */
- asymbol symbol;
- /* Number of reloc entries for imported symbol. */
- bfd_size_type rcnt;
- /* Array of reloc information for imported symbol. */
- struct nlm_relent *relocs;
-} nlmNAME(symbol_type);
-
-extern boolean nlm_mkobject PARAMS ((bfd *));
-extern boolean nlm_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
- unsigned long));
-
-extern void nlmNAME(get_symbol_info)
- PARAMS ((bfd *, asymbol *, symbol_info *));
-extern long nlmNAME(get_symtab_upper_bound)
- PARAMS ((bfd *));
-extern long nlmNAME(get_symtab)
- PARAMS ((bfd *, asymbol **));
-extern asymbol *nlmNAME(make_empty_symbol)
- PARAMS ((bfd *));
-extern void nlmNAME(print_symbol)
- PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
-extern long nlmNAME(get_reloc_upper_bound)
- PARAMS ((bfd *, asection *));
-extern long nlmNAME(canonicalize_reloc)
- PARAMS ((bfd *, asection *, arelent **, asymbol **));
-extern const bfd_target *nlmNAME(object_p)
- PARAMS ((bfd *));
-extern boolean nlmNAME(set_arch_mach)
- PARAMS ((bfd *, enum bfd_architecture, unsigned long));
-extern boolean nlmNAME(set_section_contents)
- PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-extern boolean nlmNAME(write_object_contents)
- PARAMS ((bfd *));
-
-/* Some private data is stashed away for future use using the tdata pointer
- in the bfd structure. */
-
-struct nlm_obj_tdata
-{
- /* Actual data, but ref like ptr */
- Nlm_Internal_Fixed_Header nlm_fixed_hdr[1];
- Nlm_Internal_Variable_Header nlm_variable_hdr[1];
- Nlm_Internal_Version_Header nlm_version_hdr[1];
- Nlm_Internal_Copyright_Header nlm_copyright_hdr[1];
- Nlm_Internal_Extended_Header nlm_extended_hdr[1];
- Nlm_Internal_Custom_Header nlm_custom_hdr[1];
- Nlm_Internal_Cygnus_Ext_Header nlm_cygnus_ext_hdr[1];
- /* BFD NLM symbols. */
- nlmNAME(symbol_type) *nlm_symbols;
- /* Lowest text and data VMA values. */
- bfd_vma nlm_text_low;
- bfd_vma nlm_data_low;
- /* Caches for data read from object file. */
- arelent * nlm_reloc_fixups;
- asection ** nlm_reloc_fixup_secs;
- /* Backend specific information. This should probably be a pointer,
- but that would require yet another entry point to initialize the
- structure. */
- union
- {
- struct /* Alpha backend information. */
- {
- bfd_vma gp; /* GP value. */
- bfd_vma lita_address; /* .lita section address. */
- bfd_size_type lita_size; /* .lita section size. */
- }
- alpha_backend_data;
- }
- backend_data;
-};
-
-#define nlm_tdata(bfd) ((bfd) -> tdata.nlm_obj_data)
-#define nlm_fixed_header(bfd) (nlm_tdata(bfd) -> nlm_fixed_hdr)
-#define nlm_variable_header(bfd) (nlm_tdata(bfd) -> nlm_variable_hdr)
-#define nlm_version_header(bfd) (nlm_tdata(bfd) -> nlm_version_hdr)
-#define nlm_copyright_header(bfd) (nlm_tdata(bfd) -> nlm_copyright_hdr)
-#define nlm_extended_header(bfd) (nlm_tdata(bfd) -> nlm_extended_hdr)
-#define nlm_custom_header(bfd) (nlm_tdata(bfd) -> nlm_custom_hdr)
-#define nlm_cygnus_ext_header(bfd) (nlm_tdata(bfd) -> nlm_cygnus_ext_hdr)
-#define nlm_get_symbols(bfd) (nlm_tdata(bfd) -> nlm_symbols)
-#define nlm_set_symbols(bfd, p) (nlm_tdata(bfd) -> nlm_symbols = (p))
-#define nlm_set_text_low(bfd, i) (nlm_tdata(bfd) -> nlm_text_low = (i))
-#define nlm_get_text_low(bfd) (nlm_tdata(bfd) -> nlm_text_low)
-#define nlm_set_data_low(bfd, i) (nlm_tdata(bfd) -> nlm_data_low = (i))
-#define nlm_get_data_low(bfd) (nlm_tdata(bfd) -> nlm_data_low)
-#define nlm_relocation_fixups(bfd) (nlm_tdata(bfd) -> nlm_reloc_fixups)
-#define nlm_relocation_fixup_secs(bfd) (nlm_tdata(bfd)->nlm_reloc_fixup_secs)
-
-#define nlm_alpha_backend_data(bfd) \
- (&nlm_tdata (bfd)->backend_data.alpha_backend_data)
-
-/* This is used when writing out the external relocs. */
-
-struct reloc_and_sec
-{
- arelent *rel;
- asection *sec;
-};
-
-/* We store some function pointer in the backend structure. This lets
- different NLM targets share most of the same code, while providing
- slightly different code where necessary. */
-
-struct nlm_backend_data
-{
- /* Signature for this backend. */
- char signature[NLM_SIGNATURE_SIZE];
- /* Size of the fixed header. */
- bfd_size_type fixed_header_size;
- /* Size of optional prefix for this backend. Some backend may
- require this to be a function, but so far a constant is OK. This
- is for a prefix which precedes the standard NLM fixed header. */
- bfd_size_type optional_prefix_size;
- /* Architecture. */
- enum bfd_architecture arch;
- /* Machine. */
- long mach;
- /* Some NLM formats do not use the uninitialized data section, so
- all uninitialized data must be put into the regular data section
- instead. */
- boolean no_uninitialized_data;
- /* Some NLM formats have a prefix on the file. If this function is
- not NULL, it will be called by nlm_object_p. It should return
- true if this file could match this format, and it should leave
- the BFD such that a bfd_read will pick up the fixed header. */
- boolean (*nlm_backend_object_p) PARAMS ((bfd *));
- /* Write out the prefix. This function may be NULL. This must
- write out the same number of bytes as is in the field
- optional_prefix_size. */
- boolean (*nlm_write_prefix) PARAMS ((bfd *));
- /* Read a relocation fixup from abfd. The reloc information is
- machine specific. The second argument is the symbol if this is
- an import, or NULL if this is a reloc fixup. This function
- should set the third argument to the section which the reloc
- belongs in, and the fourth argument to the reloc itself; it does
- not need to fill in the sym_ptr_ptr field for a reloc against an
- import symbol. */
- boolean (*nlm_read_reloc) PARAMS ((bfd *, nlmNAME(symbol_type) *,
- asection **, arelent *));
- /* To make objcopy to an i386 NLM work, the i386 backend needs a
- chance to work over the relocs. This is a bit icky. */
- boolean (*nlm_mangle_relocs) PARAMS ((bfd *, asection *, PTR data,
- bfd_vma offset,
- bfd_size_type count));
- /* Read an import record from abfd. It would be nice if this
- were in a machine-dependent format, but it doesn't seem to be. */
- boolean (*nlm_read_import) PARAMS ((bfd *, nlmNAME(symbol_type) *));
- /* Write an import record to abfd. */
- boolean (*nlm_write_import) PARAMS ((bfd *, asection *, arelent *));
- /* Set the section for a public symbol. This may be NULL, in which
- case a default method will be used. */
- boolean (*nlm_set_public_section) PARAMS ((bfd *, nlmNAME(symbol_type) *));
- /* Get the offset to write out for a public symbol. This may be
- NULL, in which case a default method will be used. */
- bfd_vma (*nlm_get_public_offset) PARAMS ((bfd *, asymbol *));
- /* Swap the fixed header in and out */
- void (*nlm_swap_fhdr_in) PARAMS ((bfd *,
- PTR,
- Nlm_Internal_Fixed_Header *));
- void (*nlm_swap_fhdr_out) PARAMS ((bfd *,
- struct nlm_internal_fixed_header *,
- PTR));
- /* Write out an external reference. */
- boolean (*nlm_write_external) PARAMS ((bfd *, bfd_size_type,
- asymbol *,
- struct reloc_and_sec *));
- boolean (*nlm_write_export) PARAMS ((bfd *, asymbol *, bfd_vma));
-};
-
-#define nlm_backend(bfd) \
- ((struct nlm_backend_data *)((bfd) -> xvec -> backend_data))
-#define nlm_signature(bfd) \
- (nlm_backend(bfd) -> signature)
-#define nlm_fixed_header_size(bfd) \
- (nlm_backend(bfd) -> fixed_header_size)
-#define nlm_optional_prefix_size(bfd) \
- (nlm_backend(bfd) -> optional_prefix_size)
-#define nlm_architecture(bfd) \
- (nlm_backend(bfd) -> arch)
-#define nlm_machine(bfd) \
- (nlm_backend(bfd) -> mach)
-#define nlm_no_uninitialized_data(bfd) \
- (nlm_backend(bfd) -> no_uninitialized_data)
-#define nlm_backend_object_p_func(bfd) \
- (nlm_backend(bfd) -> nlm_backend_object_p)
-#define nlm_write_prefix_func(bfd) \
- (nlm_backend(bfd) -> nlm_write_prefix)
-#define nlm_read_reloc_func(bfd) \
- (nlm_backend(bfd) -> nlm_read_reloc)
-#define nlm_mangle_relocs_func(bfd) \
- (nlm_backend(bfd) -> nlm_mangle_relocs)
-#define nlm_read_import_func(bfd) \
- (nlm_backend(bfd) -> nlm_read_import)
-#define nlm_write_import_func(bfd) \
- (nlm_backend(bfd) -> nlm_write_import)
-#define nlm_set_public_section_func(bfd) \
- (nlm_backend(bfd) -> nlm_set_public_section)
-#define nlm_get_public_offset_func(bfd) \
- (nlm_backend(bfd) -> nlm_get_public_offset)
-#define nlm_swap_fixed_header_in_func(bfd) \
- (nlm_backend(bfd) -> nlm_swap_fhdr_in)
-#define nlm_swap_fixed_header_out_func(bfd) \
- (nlm_backend(bfd) -> nlm_swap_fhdr_out)
-#define nlm_write_external_func(bfd) \
- (nlm_backend(bfd) -> nlm_write_external)
-#define nlm_write_export_func(bfd) \
- (nlm_backend(bfd) -> nlm_write_export)
-
-/* The NLM code, data, and uninitialized sections have no names defined
- in the NLM, but bfd wants to give them names, so use the traditional
- UNIX names. */
-
-#define NLM_CODE_NAME ".text"
-#define NLM_INITIALIZED_DATA_NAME ".data"
-#define NLM_UNINITIALIZED_DATA_NAME ".bss"
-
-#endif /* _LIBNLM_H_ */
diff --git a/contrib/gdb/bfd/liboasys.h b/contrib/gdb/bfd/liboasys.h
deleted file mode 100644
index 2d15813..0000000
--- a/contrib/gdb/bfd/liboasys.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* BFD internal declarations for Oasys file format handling.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
- Scrawled 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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) ((abfd)->tdata.oasys_obj_data)
-#define OASYS_AR_DATA(abfd) ((abfd)->tdata.oasys_ar_data)
-
diff --git a/contrib/gdb/bfd/lynx-core.c b/contrib/gdb/bfd/lynx-core.c
deleted file mode 100644
index 2358177..0000000
--- a/contrib/gdb/bfd/lynx-core.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* BFD back end for Lynx core files
- Copyright 1993 Free Software Foundation, Inc.
- Written by Stu Grossman 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#ifdef LYNX_CORE
-
-#include <sys/conf.h>
-#include <sys/kernel.h>
-/* sys/kernel.h should define this, but doesn't always, sigh. */
-#ifndef __LYNXOS
-#define __LYNXOS
-#endif
-#include <sys/mem.h>
-#include <sys/signal.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/itimer.h>
-#include <sys/file.h>
-#include <sys/proc.h>
-
-/* These are stored in the bfd's tdata */
-
-struct lynx_core_struct
-{
- int sig;
- char cmd[PNMLEN + 1];
-};
-
-#define core_hdr(bfd) ((bfd)->tdata.lynx_core_data)
-#define core_signal(bfd) (core_hdr(bfd)->sig)
-#define core_command(bfd) (core_hdr(bfd)->cmd)
-
-/* Handle Lynx core dump file. */
-
-static asection *
-make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
- bfd *abfd;
- CONST char *name;
- flagword flags;
- bfd_size_type _raw_size;
- bfd_vma vma;
- file_ptr filepos;
-{
- asection *asect;
- char *newname;
-
- newname = bfd_alloc (abfd, strlen (name) + 1);
- if (!newname)
- return NULL;
-
- strcpy (newname, name);
-
- asect = bfd_make_section (abfd, newname);
- if (!asect)
- return NULL;
-
- asect->flags = flags;
- asect->_raw_size = _raw_size;
- asect->vma = vma;
- asect->filepos = filepos;
- asect->alignment_power = 2;
-
- return asect;
-}
-
-/* ARGSUSED */
-const bfd_target *
-lynx_core_file_p (abfd)
- bfd *abfd;
-{
- int val;
- int secnum;
- struct pssentry pss;
- size_t tcontext_size;
- core_st_t *threadp;
- int pagesize;
- asection *newsect;
-
- pagesize = getpagesize (); /* Serious cross-target issue here... This
- really needs to come from a system-specific
- header file. */
-
- /* Get the pss entry from the core file */
-
- if (bfd_seek (abfd, 0, SEEK_SET) != 0)
- return NULL;
-
- val = bfd_read ((void *)&pss, 1, sizeof pss, abfd);
- if (val != sizeof pss)
- {
- /* Too small to be a core file */
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- core_hdr (abfd) = (struct lynx_core_struct *)
- bfd_zalloc (abfd, sizeof (struct lynx_core_struct));
-
- if (!core_hdr (abfd))
- return NULL;
-
- strncpy (core_command (abfd), pss.pname, PNMLEN + 1);
-
- /* Compute the size of the thread contexts */
-
- tcontext_size = pss.threadcnt * sizeof (core_st_t);
-
- /* Allocate space for the thread contexts */
-
- threadp = (core_st_t *)bfd_alloc (abfd, tcontext_size);
- if (!threadp)
- return NULL;
-
- /* Save thread contexts */
-
- if (bfd_seek (abfd, pagesize, SEEK_SET) != 0)
- return NULL;
-
- val = bfd_read ((void *)threadp, pss.threadcnt, sizeof (core_st_t), abfd);
-
- if (val != tcontext_size)
- {
- /* Probably too small to be a core file */
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- core_signal (abfd) = threadp->currsig;
-
- newsect = make_bfd_asection (abfd, ".stack",
- SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
- pss.ssize,
- pss.slimit,
- pagesize + tcontext_size);
- if (!newsect)
- return NULL;
-
- newsect = make_bfd_asection (abfd, ".data",
- SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
- pss.data_len + pss.bss_len,
- pss.data_start,
- pagesize + tcontext_size + pss.ssize
-#if defined (SPARC) || defined (__SPARC__)
- /* SPARC Lynx seems to start dumping
- the .data section at a page
- boundary. It's OK to check a
- #define like SPARC here because this
- file can only be compiled on a Lynx
- host. */
- + pss.data_start % pagesize
-#endif
- );
- if (!newsect)
- return NULL;
-
-/* And, now for the .reg/XXX pseudo sections. Each thread has it's own
- .reg/XXX section, where XXX is the thread id (without leading zeros). The
- currently running thread (at the time of the core dump) also has an alias
- called `.reg' (just to keep GDB happy). Note that we use `.reg/XXX' as
- opposed to `.regXXX' because GDB expects that .reg2 will be the floating-
- point registers. */
-
- newsect = make_bfd_asection (abfd, ".reg",
- SEC_HAS_CONTENTS,
- sizeof (core_st_t),
- 0,
- pagesize);
- if (!newsect)
- return NULL;
-
- for (secnum = 0; secnum < pss.threadcnt; secnum++)
- {
- char secname[100];
-
- sprintf (secname, ".reg/%d", BUILDPID (0, threadp[secnum].tid));
- newsect = make_bfd_asection (abfd, secname,
- SEC_HAS_CONTENTS,
- sizeof (core_st_t),
- 0,
- pagesize + secnum * sizeof (core_st_t));
- if (!newsect)
- return NULL;
- }
-
- return abfd->xvec;
-}
-
-char *
-lynx_core_file_failing_command (abfd)
- bfd *abfd;
-{
- return core_command (abfd);
-}
-
-/* ARGSUSED */
-int
-lynx_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return core_signal (abfd);
-}
-
-/* ARGSUSED */
-boolean
-lynx_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 */
-}
-
-#endif /* LYNX_CORE */
diff --git a/contrib/gdb/bfd/m68k4knetbsd.c b/contrib/gdb/bfd/m68k4knetbsd.c
deleted file mode 100644
index c1ecb43..0000000
--- a/contrib/gdb/bfd/m68k4knetbsd.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* BFD back-end for NetBSD/m68k a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-#define TARGET_IS_BIG_ENDIAN_P
-
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE 4096
-
-#define DEFAULT_ARCH bfd_arch_m68k
-#define MACHTYPE_OK(mtype) \
- ((mtype) == M_68020 || (mtype) == M_68K_NETBSD || (mtype) == M_68K4K_NETBSD \
- || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(m68k4knetbsd_,OP)
-/* This needs to start with a.out so GDB knows it is an a.out variant. */
-#define TARGETNAME "a.out-m68k4k-netbsd"
-
-#include "netbsd.h"
diff --git a/contrib/gdb/bfd/m68klinux.c b/contrib/gdb/bfd/m68klinux.c
deleted file mode 100644
index 062165b..0000000
--- a/contrib/gdb/bfd/m68klinux.c
+++ /dev/null
@@ -1,767 +0,0 @@
-/* BFD back-end for linux flavored m68k a.out binaries.
- Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_PAGE_SIZE 4096
-#define ZMAGIC_DISK_BLOCK_SIZE 1024
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define TEXT_START_ADDR 0x0
-#define N_SHARED_LIB(x) 0
-#define BYTES_IN_WORD 4
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-#define TARGET_IS_BIG_ENDIAN_P
-#define DEFAULT_ARCH bfd_arch_m68k
-#define MY(OP) CAT(m68klinux_,OP)
-#define TARGETNAME "a.out-m68k-linux"
-
-extern const bfd_target MY(vec);
-
-/* We always generate QMAGIC files in preference to ZMAGIC files. It
- would be possible to make this a linker option, if that ever
- becomes important. */
-
-static void MY_final_link_callback
- PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
-
-static boolean
-m68klinux_bfd_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- obj_aout_subformat (abfd) = q_magic_format;
- return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
-}
-
-#define MY_bfd_final_link m68klinux_bfd_final_link
-
-/* Set the machine type correctly. */
-
-static boolean
-m68klinux_write_object_contents (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
- N_SET_MACHTYPE (*execp, M_68020);
-
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
-
-#define MY_write_object_contents m68klinux_write_object_contents
-
-/* Code to link against Linux a.out shared libraries. */
-
-/* See if a symbol name is a reference to the global offset table. */
-
-#ifndef GOT_REF_PREFIX
-#define GOT_REF_PREFIX "__GOT_"
-#endif
-
-#define IS_GOT_SYM(name) \
- (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0)
-
-/* See if a symbol name is a reference to the procedure linkage table. */
-
-#ifndef PLT_REF_PREFIX
-#define PLT_REF_PREFIX "__PLT_"
-#endif
-
-#define IS_PLT_SYM(name) \
- (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0)
-
-/* This string is used to generate specialized error messages. */
-
-#ifndef NEEDS_SHRLIB
-#define NEEDS_SHRLIB "__NEEDS_SHRLIB_"
-#endif
-
-/* This special symbol is a set vector that contains a list of
- pointers to fixup tables. It will be present in any dynamicly
- linked file. The linker generated fixup table should also be added
- to the list, and it should always appear in the second slot (the
- first one is a dummy with a magic number that is defined in
- crt0.o). */
-
-#ifndef SHARABLE_CONFLICTS
-#define SHARABLE_CONFLICTS "__SHARABLE_CONFLICTS__"
-#endif
-
-/* We keep a list of fixups. The terminology is a bit strange, but
- each fixup contains two 32 bit numbers. A regular fixup contains
- an address and a pointer, and at runtime we should store the
- address at the location pointed to by the pointer. A builtin fixup
- contains two pointers, and we should read the address using one
- pointer and store it at the location pointed to by the other
- pointer. Builtin fixups come into play when we have duplicate
- __GOT__ symbols for the same variable. The builtin fixup will copy
- the GOT pointer from one over into the other. */
-
-struct fixup
-{
- struct fixup *next;
- struct linux_link_hash_entry *h;
- bfd_vma value;
-
- /* Nonzero if this is a jump instruction that needs to be fixed,
- zero if this is just a pointer */
- char jump;
-
- char builtin;
-};
-
-/* We don't need a special hash table entry structure, but we do need
- to keep some information between linker passes, so we use a special
- hash table. */
-
-struct linux_link_hash_entry
-{
- struct aout_link_hash_entry root;
-};
-
-struct linux_link_hash_table
-{
- struct aout_link_hash_table root;
-
- /* First dynamic object found in link. */
- bfd *dynobj;
-
- /* Number of fixups. */
- size_t fixup_count;
-
- /* Number of builtin fixups. */
- size_t local_builtins;
-
- /* List of fixups. */
- struct fixup *fixup_list;
-};
-
-static struct bfd_hash_entry *linux_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *linux_link_hash_table_create
- PARAMS ((bfd *));
-static struct fixup *new_fixup
- PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
- bfd_vma, int));
-static boolean linux_link_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean linux_add_one_symbol
- PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
- bfd_vma, const char *, boolean, boolean,
- struct bfd_link_hash_entry **));
-static boolean linux_tally_symbols
- PARAMS ((struct linux_link_hash_entry *, PTR));
-static boolean linux_finish_dynamic_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-/* Routine to create an entry in an Linux link hash table. */
-
-static struct bfd_hash_entry *
-linux_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct linux_link_hash_entry *) NULL)
- ret = ((struct linux_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct linux_link_hash_entry)));
- if (ret == NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct linux_link_hash_entry *)
- NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != NULL)
- {
- /* Set local fields; there aren't any. */
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create a Linux link hash table. */
-
-static struct bfd_link_hash_table *
-linux_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct linux_link_hash_table *ret;
-
- ret = ((struct linux_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
- if (ret == (struct linux_link_hash_table *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return (struct bfd_link_hash_table *) NULL;
- }
- if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
- linux_link_hash_newfunc))
- {
- free (ret);
- return (struct bfd_link_hash_table *) NULL;
- }
-
- ret->dynobj = NULL;
- ret->fixup_count = 0;
- ret->local_builtins = 0;
- ret->fixup_list = NULL;
-
- return &ret->root.root;
-}
-
-/* Look up an entry in a Linux link hash table. */
-
-#define linux_link_hash_lookup(table, string, create, copy, follow) \
- ((struct linux_link_hash_entry *) \
- aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
- (follow)))
-
-/* Traverse a Linux link hash table. */
-
-#define linux_link_hash_traverse(table, func, info) \
- (aout_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the Linux link hash table from the info structure. This is
- just a cast. */
-
-#define linux_hash_table(p) ((struct linux_link_hash_table *) ((p)->hash))
-
-/* Store the information for a new fixup. */
-
-static struct fixup *
-new_fixup (info, h, value, builtin)
- struct bfd_link_info *info;
- struct linux_link_hash_entry *h;
- bfd_vma value;
- int builtin;
-{
- struct fixup *f;
-
- f = (struct fixup *) bfd_hash_allocate (&info->hash->table,
- sizeof (struct fixup));
- if (f == NULL)
- return f;
- f->next = linux_hash_table (info)->fixup_list;
- linux_hash_table (info)->fixup_list = f;
- f->h = h;
- f->value = value;
- f->builtin = builtin;
- f->jump = 0;
- ++linux_hash_table (info)->fixup_count;
- return f;
-}
-
-/* We come here once we realize that we are going to link to a shared
- library. We need to create a special section that contains the
- fixup table, and we ultimately need to add a pointer to this into
- the set vector for SHARABLE_CONFLICTS. At this point we do not
- know the size of the section, but that's OK - we just need to
- create it for now. */
-
-static boolean
-linux_link_create_dynamic_sections (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- flagword flags;
- register asection *s;
-
- /* Note that we set the SEC_IN_MEMORY flag. */
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- /* We choose to use the name ".linux-dynamic" for the fixup table.
- Why not? */
- s = bfd_make_section (abfd, ".linux-dynamic");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
- s->_raw_size = 0;
- s->contents = 0;
-
- return true;
-}
-
-/* Function to add a single symbol to the linker hash table. This is
- a wrapper around _bfd_generic_link_add_one_symbol which handles the
- tweaking needed for dynamic linking support. */
-
-static boolean
-linux_add_one_symbol (info, abfd, name, flags, section, value, string,
- copy, collect, hashp)
- struct bfd_link_info *info;
- bfd *abfd;
- const char *name;
- flagword flags;
- asection *section;
- bfd_vma value;
- const char *string;
- boolean copy;
- boolean collect;
- struct bfd_link_hash_entry **hashp;
-{
- struct linux_link_hash_entry *h;
- boolean insert;
-
- /* Look up and see if we already have this symbol in the hash table.
- If we do, and the defining entry is from a shared library, we
- need to create the dynamic sections.
-
- FIXME: What if abfd->xvec != info->hash->creator? We may want to
- be able to link Linux a.out and ELF objects together, but serious
- confusion is possible. */
-
- insert = false;
-
- if (! info->relocateable
- && linux_hash_table (info)->dynobj == NULL
- && strcmp (name, SHARABLE_CONFLICTS) == 0
- && (flags & BSF_CONSTRUCTOR) != 0
- && abfd->xvec == info->hash->creator)
- {
- if (! linux_link_create_dynamic_sections (abfd, info))
- return false;
- linux_hash_table (info)->dynobj = abfd;
- insert = true;
- }
-
- if (bfd_is_abs_section (section)
- && abfd->xvec == info->hash->creator)
- {
- h = linux_link_hash_lookup (linux_hash_table (info), name, false,
- false, false);
- if (h != NULL
- && (h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak))
- {
- struct fixup *f;
-
- if (hashp != NULL)
- *hashp = (struct bfd_link_hash_entry *) h;
-
- f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
- if (f == NULL)
- return false;
- f->jump = IS_PLT_SYM (name);
-
- return true;
- }
- }
-
- /* Do the usual procedure for adding a symbol. */
- if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
- value, string, copy, collect,
- hashp))
- return false;
-
- /* Insert a pointer to our table in the set vector. The dynamic
- linker requires this information */
- if (insert)
- {
- asection *s;
-
- /* Here we do our special thing to add the pointer to the
- dynamic section in the SHARABLE_CONFLICTS set vector. */
- s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
- ".linux-dynamic");
- BFD_ASSERT (s != NULL);
-
- if (! (_bfd_generic_link_add_one_symbol
- (info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
- BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
- return false;
- }
-
- return true;
-}
-
-/* We will crawl the hash table and come here for every global symbol.
- We will examine each entry and see if there are indications that we
- need to add a fixup. There are two possible cases - one is where
- you have duplicate definitions of PLT or GOT symbols - these will
- have already been caught and added as "builtin" fixups. If we find
- that the corresponding non PLT/GOT symbol is also present, we
- convert it to a regular fixup instead.
-
- This function is called via linux_link_hash_traverse. */
-
-static boolean
-linux_tally_symbols (h, data)
- struct linux_link_hash_entry *h;
- PTR data;
-{
- struct bfd_link_info *info = (struct bfd_link_info *) data;
- struct fixup *f, *f1;
- int is_plt;
- struct linux_link_hash_entry *h1, *h2;
- boolean exists;
-
- if (h->root.root.type == bfd_link_hash_undefined
- && strncmp (h->root.root.root.string, NEEDS_SHRLIB,
- sizeof NEEDS_SHRLIB - 1) == 0)
- {
- const char *name;
- char *p;
- char *alloc = NULL;
-
- name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
- p = strrchr (name, '_');
- if (p != NULL)
- alloc = (char *) bfd_malloc (strlen (name) + 1);
-
- if (p == NULL || alloc == NULL)
- (*_bfd_error_handler) ("Output file requires shared library `%s'\n",
- name);
- else
- {
- strcpy (alloc, name);
- p = strrchr (alloc, '_');
- *p++ = '\0';
- (*_bfd_error_handler)
- ("Output file requires shared library `%s.so.%s'\n",
- alloc, p);
- free (alloc);
- }
-
- abort ();
- }
-
- /* If this symbol is not a PLT/GOT, we do not even need to look at it */
- is_plt = IS_PLT_SYM (h->root.root.root.string);
-
- if (is_plt || IS_GOT_SYM (h->root.root.root.string))
- {
- /* Look up this symbol twice. Once just as a regular lookup,
- and then again following all of the indirect links until we
- reach a real symbol. */
- h1 = linux_link_hash_lookup (linux_hash_table (info),
- (h->root.root.root.string
- + sizeof PLT_REF_PREFIX - 1),
- false, false, true);
- /* h2 does not follow indirect symbols. */
- h2 = linux_link_hash_lookup (linux_hash_table (info),
- (h->root.root.root.string
- + sizeof PLT_REF_PREFIX - 1),
- false, false, false);
-
- /* The real symbol must exist but if it is also an ABS symbol,
- there is no need to have a fixup. This is because they both
- came from the same library. If on the other hand, we had to
- use an indirect symbol to get to the real symbol, we add the
- fixup anyway, since there are cases where these symbols come
- from different shared libraries */
- if (h1 != NULL
- && (((h1->root.root.type == bfd_link_hash_defined
- || h1->root.root.type == bfd_link_hash_defweak)
- && ! bfd_is_abs_section (h1->root.root.u.def.section))
- || h2->root.root.type == bfd_link_hash_indirect))
- {
- /* See if there is a "builtin" fixup already present
- involving this symbol. If so, convert it to a regular
- fixup. In the end, this relaxes some of the requirements
- about the order of performing fixups. */
- exists = false;
- for (f1 = linux_hash_table (info)->fixup_list;
- f1 != NULL;
- f1 = f1->next)
- {
- if ((f1->h != h && f1->h != h1)
- || (! f1->builtin && ! f1->jump))
- continue;
- if (f1->h == h1)
- exists = true;
- if (! exists
- && bfd_is_abs_section (h->root.root.u.def.section))
- {
- f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
- f->jump = is_plt;
- }
- f1->h = h1;
- f1->jump = is_plt;
- f1->builtin = 0;
- exists = true;
- }
- if (! exists
- && bfd_is_abs_section (h->root.root.u.def.section))
- {
- f = new_fixup (info, h1, h->root.root.u.def.value, 0);
- if (f == NULL)
- {
- /* FIXME: No way to return error. */
- abort ();
- }
- f->jump = is_plt;
- }
- }
-
- /* Quick and dirty way of stripping these symbols from the
- symtab. */
- if (bfd_is_abs_section (h->root.root.u.def.section))
- h->root.written = true;
- }
-
- return true;
-}
-
-/* This is called to set the size of the .linux-dynamic section is.
- It is called by the Linux linker emulation before_allocation
- routine. We have finished reading all of the input files, and now
- we just scan the hash tables to find out how many additional fixups
- are required. */
-
-boolean
-bfd_m68klinux_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- struct fixup *f;
- asection *s;
-
- if (output_bfd->xvec != &MY(vec))
- return true;
-
- /* First find the fixups... */
- linux_link_hash_traverse (linux_hash_table (info),
- linux_tally_symbols,
- (PTR) info);
-
- /* If there are builtin fixups, leave room for a marker. This is
- used by the dynamic linker so that it knows that all that follow
- are builtin fixups instead of regular fixups. */
- for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
- {
- if (f->builtin)
- {
- ++linux_hash_table (info)->fixup_count;
- ++linux_hash_table (info)->local_builtins;
- break;
- }
- }
-
- if (linux_hash_table (info)->dynobj == NULL)
- {
- if (linux_hash_table (info)->fixup_count > 0)
- abort ();
- return true;
- }
-
- /* Allocate memory for our fixup table. We will fill it in later. */
- s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
- ".linux-dynamic");
- if (s != NULL)
- {
- s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
- if (s->contents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- memset (s->contents, 0, (size_t) s->_raw_size);
- }
-
- return true;
-}
-
-/* We come here once we are ready to actually write the fixup table to
- the output file. Scan the fixup tables and so forth and generate
- the stuff we need. */
-
-static boolean
-linux_finish_dynamic_link (output_bfd, info)
- bfd *output_bfd;
- struct bfd_link_info *info;
-{
- asection *s, *os, *is;
- bfd_byte *fixup_table;
- struct linux_link_hash_entry *h;
- struct fixup *f;
- unsigned int new_addr;
- int section_offset;
- unsigned int fixups_written;
-
- if (linux_hash_table (info)->dynobj == NULL)
- return true;
-
- s = bfd_get_section_by_name (linux_hash_table (info)->dynobj,
- ".linux-dynamic");
- BFD_ASSERT (s != NULL);
- os = s->output_section;
- fixups_written = 0;
-
-#ifdef LINUX_LINK_DEBUG
- printf ("Fixup table file offset: %x VMA: %x\n",
- os->filepos + s->output_offset,
- os->vma + s->output_offset);
-#endif
-
- fixup_table = s->contents;
- bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
- fixup_table += 4;
-
- /* Fill in fixup table. */
- for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
- {
- if (f->builtin)
- continue;
-
- if (f->h->root.root.type != bfd_link_hash_defined
- && f->h->root.root.type != bfd_link_hash_defweak)
- {
- (*_bfd_error_handler)
- ("Symbol %s not defined for fixups\n",
- f->h->root.root.root.string);
- continue;
- }
-
- is = f->h->root.root.u.def.section;
- section_offset = is->output_section->vma + is->output_offset;
- new_addr = f->h->root.root.u.def.value + section_offset;
-
-#ifdef LINUX_LINK_DEBUG
- printf ("Fixup(%d) %s: %x %x\n",f->jump, f->h->root.root.string,
- new_addr, f->value);
-#endif
-
- if (f->jump)
- {
- bfd_put_32 (output_bfd, new_addr, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, f->value + 2, fixup_table);
- fixup_table += 4;
- }
- else
- {
- bfd_put_32 (output_bfd, new_addr, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, f->value, fixup_table);
- fixup_table += 4;
- }
- ++fixups_written;
- }
-
- if (linux_hash_table (info)->local_builtins != 0)
- {
- /* Special marker so we know to switch to the other type of fixup */
- bfd_put_32 (output_bfd, 0, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
- fixup_table += 4;
- ++fixups_written;
- for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
- {
- if (! f->builtin)
- continue;
-
- if (f->h->root.root.type != bfd_link_hash_defined
- && f->h->root.root.type != bfd_link_hash_defweak)
- {
- (*_bfd_error_handler)
- ("Symbol %s not defined for fixups\n",
- f->h->root.root.root.string);
- continue;
- }
-
- is = f->h->root.root.u.def.section;
- section_offset = is->output_section->vma + is->output_offset;
- new_addr = f->h->root.root.u.def.value + section_offset;
-
-#ifdef LINUX_LINK_DEBUG
- printf ("Fixup(B) %s: %x %x\n", f->h->root.root.string,
- new_addr, f->value);
-#endif
-
- bfd_put_32 (output_bfd, new_addr, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, f->value, fixup_table);
- fixup_table += 4;
- ++fixups_written;
- }
- }
-
- if (linux_hash_table (info)->fixup_count != fixups_written)
- {
- (*_bfd_error_handler) ("Warning: fixup count mismatch\n");
- while (linux_hash_table (info)->fixup_count > fixups_written)
- {
- bfd_put_32 (output_bfd, 0, fixup_table);
- fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
- fixup_table += 4;
- ++fixups_written;
- }
- }
-
- h = linux_link_hash_lookup (linux_hash_table (info),
- "__BUILTIN_FIXUPS__",
- false, false, false);
-
- if (h != NULL
- && (h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak))
- {
- is = h->root.root.u.def.section;
- section_offset = is->output_section->vma + is->output_offset;
- new_addr = h->root.root.u.def.value + section_offset;
-
-#ifdef LINUX_LINK_DEBUG
- printf ("Builtin fixup table at %x\n", new_addr);
-#endif
-
- bfd_put_32 (output_bfd, new_addr, fixup_table);
- }
- else
- bfd_put_32 (output_bfd, 0, fixup_table);
-
- if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
- return false;
-
- if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
- != s->_raw_size)
- return false;
-
- return true;
-}
-
-#define MY_bfd_link_hash_table_create linux_link_hash_table_create
-#define MY_add_one_symbol linux_add_one_symbol
-#define MY_finish_dynamic_link linux_finish_dynamic_link
-
-#define MY_zmagic_contiguous 1
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/m68klynx.c b/contrib/gdb/bfd/m68klynx.c
deleted file mode 100644
index 7acdfbc..0000000
--- a/contrib/gdb/bfd/m68klynx.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* BFD back-end for m68k binaries under LynxOS.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-#define N_SHARED_LIB(x) 0
-
-#define TEXT_START_ADDR 0
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define DEFAULT_ARCH bfd_arch_m68k
-
-#define MY(OP) CAT(m68klynx_aout_,OP)
-#define TARGETNAME "a.out-m68k-lynx"
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#include "libaout.h"
-#include "aout/aout64.h"
-
-#define TARGET_IS_BIG_ENDIAN_P
-
-#ifdef LYNX_CORE
-
-char *lynx_core_file_failing_command();
-int lynx_core_file_failing_signal();
-boolean lynx_core_file_matches_executable_p();
-const bfd_target *lynx_core_file_p();
-
-#define MY_core_file_failing_command lynx_core_file_failing_command
-#define MY_core_file_failing_signal lynx_core_file_failing_signal
-#define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
-#define MY_core_file_p lynx_core_file_p
-
-#endif /* LYNX_CORE */
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/m68knetbsd.c b/contrib/gdb/bfd/m68knetbsd.c
deleted file mode 100644
index 3bff530..0000000
--- a/contrib/gdb/bfd/m68knetbsd.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* BFD back-end for NetBSD/m68k a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-#define TARGET_IS_BIG_ENDIAN_P
-
-#define TARGET_PAGE_SIZE 8192
-#define SEGMENT_SIZE 8192
-
-#define DEFAULT_ARCH bfd_arch_m68k
-#define MACHTYPE_OK(mtype) \
- ((mtype) == M_68020 || (mtype) == M_68K_NETBSD || (mtype) == M_68K4K_NETBSD \
- || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(m68knetbsd_,OP)
-/* This needs to start with a.out so GDB knows it is an a.out variant. */
-#define TARGETNAME "a.out-m68k-netbsd"
-
-#include "netbsd.h"
diff --git a/contrib/gdb/bfd/m88kmach3.c b/contrib/gdb/bfd/m88kmach3.c
deleted file mode 100644
index 7a56408..0000000
--- a/contrib/gdb/bfd/m88kmach3.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD back-end for Motorola m88k a.out (Mach 3) binaries.
- Copyright (C) 1990, 1991, 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_PAGE_SIZE (4096*2)
-#define SEGMENT_SIZE 0x20000
-#define TEXT_START_ADDR 0
-#define BYTES_IN_WORD 4
-#define N_HEADER_IN_TEXT(x) 1 /* (N_MAGIG(x) == ZMAGIC) */
-#define N_SHARED_LIB(x) 0
-
-#define N_TXTSIZE(x) ((x).a_text)
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-
-#define DEFAULT_ARCH bfd_arch_m88k
-#define MY(OP) CAT(m88kmach3_,OP)
-#define TARGETNAME "a.out-m88k-mach3"
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/makefile.dos b/contrib/gdb/bfd/makefile.dos
deleted file mode 100644
index 8a22c6a..0000000
--- a/contrib/gdb/bfd/makefile.dos
+++ /dev/null
@@ -1,49 +0,0 @@
-CFLAGS=-O2
-
-.c.o :
- gcc $(CFLAGS) -I. -I../include -c $<
-
-all : libbfd.a
-
-targets.o : targets.c
- gcc $(CFLAGS) -I. -I../include -DSELECT_VECS=&go32coff_vec,&i386aout_vec -DDEFAULT_VECTOR=go32coff_vec -c $*.c
-
-archures.o : archures.c
- gcc $(CFLAGS) -I. -I../include -DSELECT_ARCHITECTURES=bfd_i386_arch -c $*.c
-
-OBJS = \
- libbfd.o \
- opncls.o \
- bfd.o \
- archive.o \
- targets.o \
- cache.o \
- archures.o \
- corefile.o \
- section.o \
- format.o \
- syms.o \
- reloc.o \
- init.o \
- coffgen.o \
- srec.o \
- hash.o \
- linker.o \
- ecoff.o \
- ecofflink.o \
- elf.o \
- aout32.o \
- stab-sym.o \
- i386aout.o \
- cpu-i386.o \
- coff-go32.o \
- cofflink.o \
- elf32.o \
- binary.o \
- tekhex.o \
- $E
-
-libbfd.a : $(OBJS)
- -rm libbfd.a
- ar rvs libbfd.a $(OBJS)
- ranlib libbfd.a
diff --git a/contrib/gdb/bfd/mipsbsd.c b/contrib/gdb/bfd/mipsbsd.c
deleted file mode 100644
index 801f360..0000000
--- a/contrib/gdb/bfd/mipsbsd.c
+++ /dev/null
@@ -1,467 +0,0 @@
-/* BFD backend for MIPS BSD (a.out) binaries.
- Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
- Written by Ralph Campbell.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-/* #define ENTRY_CAN_BE_ZERO */
-#define N_HEADER_IN_TEXT(x) 1
-#define N_SHARED_LIB(x) 0
-#define N_TXTADDR(x) \
- (N_MAGIC(x) != ZMAGIC ? (x).a_entry : /* object file or NMAGIC */\
- TEXT_START_ADDR + EXEC_BYTES_SIZE /* no padding */\
- )
-#define N_DATADDR(x) (N_TXTADDR(x)+N_TXTSIZE(x))
-#define TEXT_START_ADDR 4096
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define DEFAULT_ARCH bfd_arch_mips
-#define MACHTYPE_OK(mtype) ((mtype) == M_UNKNOWN \
- || (mtype) == M_MIPS1 || (mtype) == M_MIPS2)
-#define MY_symbol_leading_char '\0'
-
-#define MY(OP) CAT(mipsbsd_,OP)
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-
-#define SET_ARCH_MACH(ABFD, EXEC) \
- MY(set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
- MY(choose_reloc_size)(ABFD);
-void MY(set_arch_mach) PARAMS ((bfd *abfd, int machtype));
-static void MY(choose_reloc_size) PARAMS ((bfd *abfd));
-
-#define MY_write_object_contents MY(write_object_contents)
-static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
-
-/* We can't use MY(x) here because it leads to a recursive call to CAT
- when expanded inside JUMP_TABLE. */
-#define MY_bfd_reloc_type_lookup mipsbsd_reloc_howto_type_lookup
-#define MY_canonicalize_reloc mipsbsd_canonicalize_reloc
-
-#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define MY_final_link_callback unused
-#define MY_bfd_final_link _bfd_generic_final_link
-
-#define MY_backend_data &MY(backend_data)
-#define MY_BFD_TARGET
-
-#include "aout-target.h"
-
-void
-MY(set_arch_mach) (abfd, machtype)
- bfd *abfd;
- int machtype;
-{
- enum bfd_architecture arch;
- long machine;
-
- /* Determine the architecture and machine type of the object file. */
- switch (machtype) {
-
- case M_MIPS1:
- arch = bfd_arch_mips;
- machine = 3000;
- break;
-
- case M_MIPS2:
- arch = bfd_arch_mips;
- machine = 4000;
- break;
-
- default:
- arch = bfd_arch_obscure;
- machine = 0;
- break;
- }
- bfd_set_arch_mach(abfd, arch, machine);
-}
-
-/* Determine the size of a relocation entry, based on the architecture */
-static void
-MY(choose_reloc_size) (abfd)
- bfd *abfd;
-{
- switch (bfd_get_arch(abfd)) {
- case bfd_arch_sparc:
- case bfd_arch_a29k:
- case bfd_arch_mips:
- obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
- break;
- default:
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
- break;
- }
-}
-
-/* Write an object file in BSD a.out format.
- Section contents have already been written. We write the
- file header, symbols, and relocation. */
-
-static boolean
-MY(write_object_contents) (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
- /* 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;
- case bfd_arch_mips:
- switch (bfd_get_mach(abfd)) {
- case 4000:
- case 6000:
- N_SET_MACHTYPE(*execp, M_MIPS2);
- break;
- default:
- N_SET_MACHTYPE(*execp, M_MIPS1);
- break;
- }
- break;
- default:
- N_SET_MACHTYPE(*execp, M_UNKNOWN);
- }
-
- MY(choose_reloc_size)(abfd);
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
-
-/*
- * MIPS relocation types.
- */
-#define MIPS_RELOC_32 0
-#define MIPS_RELOC_JMP 1
-#define MIPS_RELOC_WDISP16 2
-#define MIPS_RELOC_HI16 3
-#define MIPS_RELOC_HI16_S 4
-#define MIPS_RELOC_LO16 5
-
-/*
- * This is only called when performing a BFD_RELOC_MIPS_JMP relocation.
- * The jump destination address is formed from the upper 4 bits of the
- * "current" program counter concatenated with the jump instruction's
- * 26 bit field and two trailing zeros.
- * If the destination address is not in the same segment as the "current"
- * program counter, then we need to signal an error.
- */
-static bfd_reloc_status_type
-mips_fix_jmp_addr (abfd,reloc_entry,symbol,data,input_section,output_bfd)
- bfd *abfd;
- arelent *reloc_entry;
- struct symbol_cache_entry *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
-{
- bfd_vma relocation, pc;
-
- /* If this is a partial relocation, just continue. */
- if (output_bfd != (bfd *)NULL)
- return bfd_reloc_continue;
-
- /* If this is an undefined symbol, return error */
- if (bfd_is_und_section (symbol->section)
- && (symbol->flags & BSF_WEAK) == 0)
- return bfd_reloc_undefined;
-
- /*
- * Work out which section the relocation is targetted at and the
- * initial relocation command value.
- */
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
-
- pc = input_section->output_section->vma + input_section->output_offset +
- reloc_entry->address + 4;
-
- if ((relocation & 0xF0000000) != (pc & 0xF0000000))
- return bfd_reloc_overflow;
-
- return bfd_reloc_continue;
-}
-
-/*
- * This is only called when performing a BFD_RELOC_HI16_S relocation.
- * We need to see if bit 15 is set in the result. If it is, we add
- * 0x10000 and continue normally. This will compensate for the sign extension
- * when the low bits are added at run time.
- */
-static bfd_reloc_status_type
-mips_fix_hi16_s PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-
-static bfd_reloc_status_type
-mips_fix_hi16_s (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_vma relocation;
-
- /* If this is a partial relocation, just continue. */
- if (output_bfd != (bfd *)NULL)
- return bfd_reloc_continue;
-
- /* If this is an undefined symbol, return error */
- if (bfd_is_und_section (symbol->section)
- && (symbol->flags & BSF_WEAK) == 0)
- return bfd_reloc_undefined;
-
- /*
- * Work out which section the relocation is targetted at and the
- * initial relocation command value.
- */
- if (bfd_is_com_section (symbol->section))
- relocation = 0;
- else
- relocation = symbol->value;
-
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
-
- if (relocation & 0x8000)
- reloc_entry->addend += 0x10000;
-
- return bfd_reloc_continue;
-}
-
-static reloc_howto_type mips_howto_table_ext[] = {
- {MIPS_RELOC_32, 0, 2, 32, false, 0, complain_overflow_bitfield, 0,
- "32", false, 0, 0xffffffff, false},
- {MIPS_RELOC_JMP, 2, 2, 26, false, 0, complain_overflow_dont,
- mips_fix_jmp_addr,
- "MIPS_JMP", false, 0, 0x03ffffff, false},
- {MIPS_RELOC_WDISP16, 2, 2, 16, true, 0, complain_overflow_signed, 0,
- "WDISP16", false, 0, 0x0000ffff, false},
- {MIPS_RELOC_HI16, 16, 2, 16, false, 0, complain_overflow_bitfield, 0,
- "HI16", false, 0, 0x0000ffff, false},
- {MIPS_RELOC_HI16_S, 16, 2, 16, false, 0, complain_overflow_bitfield,
- mips_fix_hi16_s,
- "HI16_S", false, 0, 0x0000ffff, false},
- {MIPS_RELOC_LO16, 0, 2, 16, false, 0, complain_overflow_dont, 0,
- "LO16", false, 0, 0x0000ffff, false},
-};
-
-static reloc_howto_type *
-MY(reloc_howto_type_lookup) (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
-
- if (bfd_get_arch (abfd) != bfd_arch_mips)
- return 0;
-
- switch (code)
- {
- case BFD_RELOC_CTOR:
- case BFD_RELOC_32:
- return (&mips_howto_table_ext[MIPS_RELOC_32]);
- case BFD_RELOC_MIPS_JMP:
- return (&mips_howto_table_ext[MIPS_RELOC_JMP]);
- case BFD_RELOC_16_PCREL_S2:
- return (&mips_howto_table_ext[MIPS_RELOC_WDISP16]);
- case BFD_RELOC_HI16:
- return (&mips_howto_table_ext[MIPS_RELOC_HI16]);
- case BFD_RELOC_HI16_S:
- return (&mips_howto_table_ext[MIPS_RELOC_HI16_S]);
- case BFD_RELOC_LO16:
- return (&mips_howto_table_ext[MIPS_RELOC_LO16]);
- default:
- return 0;
- }
-}
-
-/*
- * This is just like the standard aoutx.h version but we need to do our
- * own mapping of external reloc type values to howto entries.
- */
-long
-MY(canonicalize_reloc)(abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr = section->relocation;
- unsigned int count, c;
- extern reloc_howto_type NAME(aout,ext_howto_table)[];
-
- /* If we have already read in the relocation table, return the values. */
- 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;
- }
- *relptr = 0;
- return section->reloc_count;
- }
- if (tblptr && section->reloc_count) {
- for (count = 0; count++ < section->reloc_count;)
- *relptr++ = tblptr++;
- *relptr = 0;
- return section->reloc_count;
- }
-
- if (!NAME(aout,slurp_reloc_table)(abfd, section, symbols))
- return -1;
- tblptr = section->relocation;
-
- /* fix up howto entries */
- for (count = 0; count++ < section->reloc_count;)
- {
- c = tblptr->howto - NAME(aout,ext_howto_table);
- tblptr->howto = &mips_howto_table_ext[c];
-
- *relptr++ = tblptr++;
- }
- *relptr = 0;
- return section->reloc_count;
-}
-
-static CONST struct aout_backend_data MY(backend_data) = {
- 0, /* zmagic contiguous */
- 1, /* text incl header */
- 0, /* exec_hdr_flags */
- TARGET_PAGE_SIZE, /* text vma */
- MY_set_sizes,
- 0, /* text size includes exec header */
- 0, /* add_dynamic_symbols */
- 0, /* add_one_symbol */
- 0, /* link_dynamic_object */
- 0, /* write_dynamic_symbol */
- 0, /* check_dynamic_reloc */
- 0 /* finish_dynamic_link */
-};
-
-const bfd_target aout_mips_little_vec =
-{
- "a.out-mips-little", /* name */
- bfd_target_aout_flavour,
- BFD_ENDIAN_LITTLE, /* target byte order (little) */
- BFD_ENDIAN_LITTLE, /* target headers byte order (little) */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- MY_symbol_leading_char,
- ' ', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
- {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
- bfd_generic_archive_p, MY_core_file_p},
- {bfd_false, MY_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, MY_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (MY),
- BFD_JUMP_TABLE_COPY (MY),
- BFD_JUMP_TABLE_CORE (MY),
- BFD_JUMP_TABLE_ARCHIVE (MY),
- BFD_JUMP_TABLE_SYMBOLS (MY),
- BFD_JUMP_TABLE_RELOCS (MY),
- BFD_JUMP_TABLE_WRITE (MY),
- BFD_JUMP_TABLE_LINK (MY),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) MY_backend_data,
-};
-
-const bfd_target aout_mips_big_vec =
-{
- "a.out-mips-big", /* name */
- bfd_target_aout_flavour,
- BFD_ENDIAN_BIG, /* target byte order (big) */
- BFD_ENDIAN_BIG, /* target headers byte order (big) */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- MY_symbol_leading_char,
- ' ', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
- {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
- bfd_generic_archive_p, MY_core_file_p},
- {bfd_false, MY_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- {bfd_false, MY_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (MY),
- BFD_JUMP_TABLE_COPY (MY),
- BFD_JUMP_TABLE_CORE (MY),
- BFD_JUMP_TABLE_ARCHIVE (MY),
- BFD_JUMP_TABLE_SYMBOLS (MY),
- BFD_JUMP_TABLE_RELOCS (MY),
- BFD_JUMP_TABLE_WRITE (MY),
- BFD_JUMP_TABLE_LINK (MY),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) MY_backend_data,
-};
diff --git a/contrib/gdb/bfd/mpw-config.in b/contrib/gdb/bfd/mpw-config.in
deleted file mode 100644
index 9195d0e..0000000
--- a/contrib/gdb/bfd/mpw-config.in
+++ /dev/null
@@ -1,73 +0,0 @@
-# Configuration fragment for BFD.
-
-# This is almost always correct.
-
-Set selarchs "&bfd_{target_cpu}_arch"
-Set defvec ""
-Set selvecs ""
-
-If "{target_canonical}" =~ /m68k-apple-macos/
- Set BFD_BACKENDS '"{o}"coff-m68k.c.o "{o}"cofflink.c.o'
- Set defvec m68kcoff_vec
- Set selvecs '&m68kcoff_vec'
-
-Else If "{target_canonical}" =~ /powerpc-apple-macos/
- Set BFD_BACKENDS '"{o}"coff-pmac.c.o "{o}"xcofflink.c.o'
- Set defvec pmac_xcoff_vec
- Set selvecs '&pmac_xcoff_vec'
- Set selarchs "&bfd_powerpc_arch"
-
-Else If "{target_canonical}" =~ /i386-unknown-go32/
- Set BFD_BACKENDS '"{o}"coff-i386.c.o'
- Set defvec i386coff_vec
- Set selvecs '&i386coff_vec'
-
-Else If "{target_canonical}" =~ /mips-\Option-x-\Option-x/
- Set BFD_BACKENDS '"{o}"coff-mips.c.o "{o}"ecoff.c.o "{o}"ecofflink.c.o'
- Set defvec ecoff_big_vec
- Set selvecs '&ecoff_big_vec,&ecoff_little_vec'
-
-Else If "{target_canonical}" =~ /sh-hitachi-hms/
- Set BFD_BACKENDS '"{o}"coff-sh.c.o "{o}"cofflink.c.o'
- Set defvec shcoff_vec
- Set selvecs '&shcoff_vec,&shlcoff_vec'
-End If
-
-Set ta `echo {selarchs} | sed -e 's/&bfd_/{o}cpu-/g' -e 's/_arch/.c.o/g'`
-
-Set tdefaults "-d DEFAULT_VECTOR={defvec} -d SELECT_VECS={selvecs} -d SELECT_ARCHITECTURES={selarchs}"
-
-Echo '# From mpw-config.in' > "{o}"mk.tmp
-Echo 'WORDSIZE = 32' >> "{o}"mk.tmp
-Echo 'BFD_MACHINES = ' {ta} >> "{o}"mk.tmp
-Echo 'BFD_BACKENDS = ' {BFD_BACKENDS} >> "{o}"mk.tmp
-Echo 'TDEFAULTS = ' {tdefaults} >> "{o}"mk.tmp
-Echo 'HDEPFILES = ' >> "{o}"mk.tmp
-Echo 'TDEPFILES = ' >> "{o}"mk.tmp
-Echo '# End from mpw-config.in' >> "{o}"mk.tmp
-
-Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new
-Echo '#include "mpw.h"' >> "{o}"config.new
-
-MoveIfChange "{o}"config.new "{o}"config.h
-
-# We can only handle 32-bit targets right now.
-
-sed -e 's/@WORDSIZE@/32/' \Option-d
- -e "s/@VERSION@/`Catenate {srcdir}VERSION`/" \Option-d
- -e 's/@BFD_HOST_64BIT_LONG@/0/' \Option-d
- "{srcdir}"bfd-in2.h >"{o}"bfd.h-new
-
-MoveIfChange "{o}"bfd.h-new "{o}"bfd.h
-
-# Pre-expand some macros in coffswap.h, so MPW C doesn't choke.
-
-sed -e 's/^ PUT_AOUTHDR_TSIZE (/ bfd_h_put_32 (/' \Option-d
- -e 's/^ PUT_AOUTHDR_DSIZE (/ bfd_h_put_32 (/' \Option-d
- -e 's/^ PUT_AOUTHDR_BSIZE (/ bfd_h_put_32 (/' \Option-d
- -e 's/^ PUT_AOUTHDR_ENTRY (/ bfd_h_put_32 (/' \Option-d
- -e 's/^ PUT_AOUTHDR_TEXT_START (/ bfd_h_put_32 (/' \Option-d
- -e 's/^ PUT_AOUTHDR_DATA_START (/ bfd_h_put_32 (/' \Option-d
- "{srcdir}"coffswap.h >"{o}"coffswap.h-new
-
-MoveIfChange "{o}"coffswap.h-new "{o}"coffswap.h
diff --git a/contrib/gdb/bfd/mpw-make.sed b/contrib/gdb/bfd/mpw-make.sed
deleted file mode 100644
index a989ef0..0000000
--- a/contrib/gdb/bfd/mpw-make.sed
+++ /dev/null
@@ -1,70 +0,0 @@
-# Sed commands to finish translating the Unix BFD Makefile into MPW syntax.
-
-# Whack out unused host and target define bits.
-/HDEFINES/s/@HDEFINES@//
-/TDEFINES/s/@TDEFINES@//
-
-/INCDIR=/s/"{srcdir}":/"{topsrcdir}"/
-/^CSEARCH = .*$/s/$/ -i "{INCDIR}":mpw: -i ::extra-include:/
-
-/WORDSIZE/s/^WORDSIZE = /#WORDSIZE = /
-/BFD_MACHINES/s/^BFD_MACHINES = /#BFD_MACHINES = /
-/BFD_BACKENDS/s/^BFD_BACKENDS = /#BFD_BACKENDS = /
-/TDEFAULTS/s/^TDEFAULTS = /#TDEFAULTS = /
-
-# Remove extra, useless, "all".
-/^all \\Option-f _oldest/,/^$/d
-
-# Remove the Makefile rebuild rule.
-/^Makefile /,/--recheck/d
-
-# Don't do any recursive subdir stuff.
-/ subdir_do/s/{MAKE}/null-command/
-
-/BFD_H/s/^{BFD_H}/#{BFD_H}/
-
-# Point at include files that are always in the objdir.
-/bfd/s/"{s}"bfd\.h/"{o}"bfd.h/g
-/config/s/"{s}"config\.h/"{o}"config.h/g
-/elf32-target/s/"{s}"elf32-target\.h/"{o}"elf32-target.h/g
-/elf64-target/s/"{s}"elf64-target\.h/"{o}"elf64-target.h/g
-
-/"{s}"{INCDIR}/s/"{s}"{INCDIR}/"{INCDIR}"/g
-
-/dep/s/\.dep/__dep/g
-
-# Removing duplicates is cool but presently unnecessary,
-# so whack this out.
-/^ofiles \\Option-f/,/^$/d
-/ofiles/s/{OFILES} ofiles/{OFILES}/
-/echo ofiles = /d
-/cat ofiles/s/`cat ofiles`/{OFILES}/
-
-# No corefile support.
-/COREFILE/s/@COREFILE@//
-/COREFLAG/s/@COREFLAG@//
-
-# No PIC foolery in this environment.
-/@ALLLIBS@/s/@ALLLIBS@/{TARGETLIB}/
-/@PICLIST@/s/@PICLIST@//
-/@PICFLAG@/s/@PICFLAG@//
-/^{OFILES} \\Option-f stamp-picdir/,/^$/d
-
-# Remove the pic trickery from the default build rule.
-/^\.c\.o \\Option-f /,/End If/c\
-.c.o \\Option-f .c
-
-# MPW Make doesn't know about $<.
-/"{o}"targets.c.o \\Option-f "{s}"targets.c Makefile/,/^$/c\
-"{o}"targets.c.o \\Option-f "{s}"targets.c Makefile\
- {CC} {ALL_CFLAGS} {TDEFAULTS} "{s}"targets.c -o "{o}"targets.c.o
-
-/"{o}"archures.c.o \\Option-f "{s}"archures.c Makefile/,/^$/c\
-"{o}"archures.c.o \\Option-f "{s}"archures.c Makefile\
- {CC} {ALL_CFLAGS} {TDEFAULTS} "{s}"archures.c -o "{o}"archures.c.o
-
-# Remove the .h rebuilding rules, we don't currently have a doc subdir,
-# or a way to build the prototype-hacking tool that's in it.
-/^"{srcdir}"bfd-in2.h \\Option-f /,/^$/d
-/^"{srcdir}"libbfd.h \\Option-f /,/^$/d
-/^"{srcdir}"libcoff.h \\Option-f /,/^$/d
diff --git a/contrib/gdb/bfd/netbsd-core.c b/contrib/gdb/bfd/netbsd-core.c
deleted file mode 100644
index 4e82867..0000000
--- a/contrib/gdb/bfd/netbsd-core.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* BFD back end for NetBSD style core files
- Copyright 1988, 1989, 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
- Written by Paul Kranenburg, EUR
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/core.h>
-#include <errno.h>
-
-/*
- * FIXME: On NetBSD/sparc CORE_FPU_OFFSET should be (sizeof(struct trapframe))
- */
-
-struct netbsd_core_struct {
- struct core core;
-} *rawptr;
-
-/* forward declarations */
-
-static const bfd_target * netbsd_core_core_file_p PARAMS ((bfd *abfd));
-static char * netbsd_core_core_file_failing_command PARAMS ((bfd *abfd));
-static int netbsd_core_core_file_failing_signal PARAMS ((bfd *abfd));
-static boolean netbsd_core_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
-
-/* Handle NetBSD-style core dump file. */
-
-/* ARGSUSED */
-static const bfd_target *
-netbsd_core_core_file_p (abfd)
- bfd *abfd;
-
-{
- int i, val, offset;
- asection *asect, *asect2;
- struct core core;
- struct coreseg coreseg;
-
- val = bfd_read ((void *)&core, 1, sizeof core, abfd);
- if (val != sizeof core) {
- /* Too small to be a core file */
- bfd_set_error(bfd_error_wrong_format);
- return 0;
- }
-
- if (CORE_GETMAGIC(core) != COREMAGIC) {
- bfd_set_error(bfd_error_wrong_format);
- return 0;
- }
-
- rawptr = (struct netbsd_core_struct *)
- bfd_zalloc (abfd, sizeof (struct netbsd_core_struct));
- if (rawptr == NULL) {
- bfd_set_error(bfd_error_no_memory);
- return 0;
- }
-
- rawptr->core = core;
- abfd->tdata.netbsd_core_data = rawptr;
-
- offset = core.c_hdrsize;
- for (i = 0; i < core.c_nseg; i++) {
-
- if (bfd_seek (abfd, offset, SEEK_SET) != 0)
- goto punt;
-
- val = bfd_read ((void *)&coreseg, 1, sizeof coreseg, abfd);
- if (val != sizeof coreseg) {
- bfd_set_error(bfd_error_file_truncated);
- goto punt;
- }
- if (CORE_GETMAGIC(coreseg) != CORESEGMAGIC) {
- bfd_set_error(bfd_error_wrong_format);
- goto punt;
- }
-
- offset += core.c_seghdrsize;
-
- asect = (asection *) bfd_zalloc (abfd, sizeof(asection));
- if (asect == NULL) {
- bfd_set_error(bfd_error_no_memory);
- }
-
- asect->_raw_size = coreseg.c_size;
- asect->vma = coreseg.c_addr;
- asect->filepos = offset;
- asect->alignment_power = 2;
- asect->next = abfd->sections;
- abfd->sections = asect;
- abfd->section_count++;
- offset += coreseg.c_size;
-
- switch (CORE_GETFLAG(coreseg)) {
- case CORE_CPU:
- asect->name = ".reg";
- asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
-#ifdef CORE_FPU_OFFSET
- /* Hackish... */
- asect->_raw_size = CORE_FPU_OFFSET;
- asect2 = (asection *)bfd_zalloc (abfd,
- sizeof (asection));
- if (asect2 == NULL) {
- bfd_set_error(bfd_error_no_memory);
- goto punt;
- }
- asect2->_raw_size = coreseg.c_size - CORE_FPU_OFFSET;
- asect2->vma = 0;
- asect2->filepos = asect->filepos + CORE_FPU_OFFSET;
- asect2->alignment_power = 2;
- asect2->next = abfd->sections;
- asect2->name = ".reg2";
- asect2->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
- abfd->sections = asect2;
- abfd->section_count++;
-#endif
-
- break;
- case CORE_DATA:
- asect->name = ".data";
- asect->flags = SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS;
- break;
- case CORE_STACK:
- asect->name = ".stack";
- asect->flags = SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS;
- break;
- }
- }
-
- /* OK, we believe you. You're a core file (sure, sure). */
- return abfd->xvec;
-
-punt: {
- asection *anext;
- for (asect = abfd->sections; asect; asect = anext) {
- anext = asect->next;
- free((void *)asect);
- }
- }
- free ((void *)rawptr);
- abfd->tdata.netbsd_core_data = NULL;
- abfd->sections = NULL;
- abfd->section_count = 0;
- return 0;
-}
-
-static char*
-netbsd_core_core_file_failing_command (abfd)
- bfd *abfd;
-{
- /*return core_command (abfd);*/
- return abfd->tdata.netbsd_core_data->core.c_name;
-}
-
-/* ARGSUSED */
-static int
-netbsd_core_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- /*return core_signal (abfd);*/
- return abfd->tdata.netbsd_core_data->core.c_signo;
-}
-
-/* ARGSUSED */
-static boolean
-netbsd_core_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 netbsd_openr_next_archived_file bfd_generic_openr_next_archived_file
-#define netbsd_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define netbsd_slurp_armap bfd_false
-#define netbsd_slurp_extended_name_table bfd_true
-#define netbsd_write_armap (boolean (*) PARAMS \
- ((bfd *arch, unsigned int elength, struct orl *map, \
- unsigned int orl_count, int stridx))) bfd_false
-#define netbsd_truncate_arname bfd_dont_truncate_arname
-#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file
-
-#define netbsd_close_and_cleanup bfd_generic_close_and_cleanup
-#define netbsd_set_section_contents (boolean (*) PARAMS \
- ((bfd *abfd, asection *section, PTR data, file_ptr offset, \
- bfd_size_type count))) bfd_false
-#define netbsd_get_section_contents bfd_generic_get_section_contents
-#define netbsd_new_section_hook (boolean (*) PARAMS \
- ((bfd *, sec_ptr))) bfd_true
-#define netbsd_get_symtab_upper_bound bfd_0u
-#define netbsd_get_symtab (unsigned int (*) PARAMS \
- ((bfd *, struct symbol_cache_entry **))) bfd_0u
-#define netbsd_get_reloc_upper_bound (unsigned int (*) PARAMS \
- ((bfd *, sec_ptr))) bfd_0u
-#define netbsd_canonicalize_reloc (unsigned int (*) PARAMS \
- ((bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u
-#define netbsd_make_empty_symbol (struct symbol_cache_entry * \
- (*) PARAMS ((bfd *))) bfd_false
-#define netbsd_print_symbol (void (*) PARAMS \
- ((bfd *, PTR, struct symbol_cache_entry *, \
- bfd_print_symbol_type))) bfd_false
-#define netbsd_get_symbol_info (void (*) PARAMS \
- ((bfd *, struct symbol_cache_entry *, \
- symbol_info *))) bfd_false
-#define netbsd_get_lineno (alent * (*) PARAMS \
- ((bfd *, struct symbol_cache_entry *))) bfd_nullvoidptr
-#define netbsd_set_arch_mach (boolean (*) PARAMS \
- ((bfd *, enum bfd_architecture, unsigned long))) bfd_false
-#define netbsd_find_nearest_line (boolean (*) PARAMS \
- ((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 netbsd_sizeof_headers (int (*) PARAMS \
- ((bfd *, boolean))) bfd_0
-
-#define netbsd_bfd_debug_info_start bfd_void
-#define netbsd_bfd_debug_info_end bfd_void
-#define netbsd_bfd_debug_info_accumulate (void (*) PARAMS \
- ((bfd *, struct sec *))) bfd_void
-#define netbsd_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
-#define netbsd_bfd_relax_section bfd_generic_relax_section
-#define netbsd_bfd_seclet_link \
- ((boolean (*) PARAMS ((bfd *, PTR, boolean))) bfd_false)
-#define netbsd_bfd_reloc_type_lookup \
- ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
-#define netbsd_bfd_make_debug_symbol \
- ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
-
-/* If somebody calls any byte-swapping routines, shoot them. */
-static void
-swap_abort()
-{
- abort(); /* This way doesn't require any declaration for ANSI to fuck up */
-}
-#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
-#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
-#define NO_SIGNED_GET \
- ((bfd_signed_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
-
-const bfd_target netbsd_core_vec =
- {
- "netbsd-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 */
- 0, /* symbol prefix */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- 3, /* minimum alignment power */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
-
- { /* bfd_check_format */
- _bfd_dummy_target, /* unknown format */
- _bfd_dummy_target, /* object file */
- _bfd_dummy_target, /* archive */
- netbsd_core_core_file_p /* a core file */
- },
- { /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
- { /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (netbsd_core),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0 /* backend_data */
-};
diff --git a/contrib/gdb/bfd/netbsd.h b/contrib/gdb/bfd/netbsd.h
deleted file mode 100644
index dd73d37..0000000
--- a/contrib/gdb/bfd/netbsd.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* BFD back-end definitions used by all NetBSD targets.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-/* NetBSD fits its header into the start of its text segment */
-#define N_HEADER_IN_TEXT(x) 1
-#define TEXT_START_ADDR TARGET_PAGE_SIZE
-
-#define N_MACHTYPE(exec) \
- ((enum machine_type)(((exec).a_info >> 16) & 0x03ff))
-#define N_FLAGS(exec) \
- (((exec).a_info >> 26) & 0x3f)
-
-#define N_SET_INFO(exec, magic, type, flags) \
- ((exec).a_info = ((magic) & 0xffff) \
- | (((int)(type) & 0x3ff) << 16) \
- | (((flags) & 0x3f) << 24))
-#define N_SET_MACHTYPE(exec, machtype) \
- ((exec).a_info = \
- ((exec).a_info & 0xfb00ffff) | ((((int)(machtype))&0x3ff) << 16))
-#define N_SET_FLAGS(exec, flags) \
- ((exec).a_info = \
- ((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libaout.h"
-
-/* On NetBSD, the magic number is always in ntohl's "network" (big-endian)
- format. */
-#define SWAP_MAGIC(ext) bfd_getb32 (ext)
-
-
-#define MY_write_object_contents MY(write_object_contents)
-static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
-#define MY_text_includes_header 1
-
-#include "aout-target.h"
-
-/* Write an object file.
- Section contents have already been written. We write the
- file header, symbols, and relocation. */
-
-static boolean
-MY(write_object_contents) (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
-#if CHOOSE_RELOC_SIZE
- CHOOSE_RELOC_SIZE(abfd);
-#else
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-#endif
-
- /* Magic number, maestro, please! */
- switch (bfd_get_arch(abfd)) {
- case bfd_arch_m68k:
- if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
- N_SET_MACHTYPE(*execp, M_68K4K_NETBSD);
- else
- N_SET_MACHTYPE(*execp, M_68K_NETBSD);
- break;
- case bfd_arch_sparc:
- N_SET_MACHTYPE(*execp, M_SPARC_NETBSD);
- break;
- case bfd_arch_i386:
- N_SET_MACHTYPE(*execp, M_386_NETBSD);
- break;
- case bfd_arch_ns32k:
- N_SET_MACHTYPE(*execp, M_532_NETBSD);
- break;
- default:
- N_SET_MACHTYPE(*execp, M_UNKNOWN);
- break;
- }
-
- /* The NetBSD magic number is always big-endian */
-#ifndef TARGET_IS_BIG_ENDIAN_P
- /* XXX aren't there any macro to change byteorder of a word independent of
- the host's or target's endianesses? */
- execp->a_info
- = (execp->a_info & 0xff) << 24 | (execp->a_info & 0xff00) << 8
- | (execp->a_info & 0xff0000) >> 8 | (execp->a_info & 0xff000000) >> 24;
-#endif
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
diff --git a/contrib/gdb/bfd/newsos3.c b/contrib/gdb/bfd/newsos3.c
deleted file mode 100644
index 7ec7a75..0000000
--- a/contrib/gdb/bfd/newsos3.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* BFD back-end for NewsOS3 (Sony, 68k) binaries.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define TEXT_START_ADDR 0
-#define BYTES_IN_WORD 4
-#define MY(OP) CAT(newsos3_,OP)
-#define TARGETNAME "a.out-newsos3"
-#define ENTRY_CAN_BE_ZERO
-#define N_SHARED_LIB(x) 0 /* Avoids warning when compiled with -Wall. */
-#define DEFAULT_ARCH bfd_arch_m68k
-#define TARGET_IS_BIG_ENDIAN_P
-#define N_HEADER_IN_TEXT(x) 0
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/nlm-target.h b/contrib/gdb/bfd/nlm-target.h
deleted file mode 100644
index cdd3fa8..0000000
--- a/contrib/gdb/bfd/nlm-target.h
+++ /dev/null
@@ -1,228 +0,0 @@
-/* Target definitions for 32/64-bit NLM (NetWare Loadable Module)
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define nlm_core_file_p _bfd_dummy_target
-
-#define nlm_get_symtab_upper_bound nlmNAME(get_symtab_upper_bound)
-#define nlm_get_symtab nlmNAME(get_symtab)
-#define nlm_make_empty_symbol nlmNAME(make_empty_symbol)
-#define nlm_print_symbol nlmNAME(print_symbol)
-#define nlm_get_symbol_info nlmNAME(get_symbol_info)
-#define nlm_bfd_is_local_label bfd_generic_is_local_label
-#define nlm_get_lineno _bfd_nosymbols_get_lineno
-#define nlm_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define nlm_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define nlm_read_minisymbols _bfd_generic_read_minisymbols
-#define nlm_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define nlm_get_reloc_upper_bound nlmNAME(get_reloc_upper_bound)
-#define nlm_canonicalize_reloc nlmNAME(canonicalize_reloc)
-#define nlm_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
-
-#define nlm_set_section_contents nlmNAME(set_section_contents)
-
-#define nlm_sizeof_headers _bfd_nolink_sizeof_headers
-#define nlm_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define nlm_bfd_relax_section bfd_generic_relax_section
-#define nlm_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define nlm_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define nlm_bfd_final_link _bfd_generic_final_link
-#define nlm_bfd_link_split_section _bfd_generic_link_split_section
-
-/* 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. */
-
-
-#ifdef TARGET_BIG_SYM
-const bfd_target TARGET_BIG_SYM =
-{
- /* name: identify kind of target */
- TARGET_BIG_NAME,
-
- /* flavour: general indication about file */
- bfd_target_nlm_flavour,
-
- /* byteorder: data is big endian */
- BFD_ENDIAN_BIG,
-
- /* header_byteorder: header is also big endian */
- BFD_ENDIAN_BIG,
-
- /* object_flags: mask of all file flags */
- (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
- | WP_TEXT),
-
- /* section_flags: mask of all section flags */
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
- SEC_CODE | SEC_DATA),
-
- /* leading_symbol_char: is the first char of a user symbol
- predictable, and if so what is it */
- 0,
-
- /* ar_pad_char: pad character for filenames within an archive header
- FIXME: this really has nothing to do with NLM, 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 NLM, this is a characteristic
- of the archiver and should be independently tunable. This value is
- a WAG (wild a** guess) */
- 15,
-
- /* Routines to byte-swap various sized integers from the data sections */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
-
- /* Routines to byte-swap various sized integers from the file headers */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
-
- /* bfd_check_format: check the format of a file being read */
- { _bfd_dummy_target, /* unknown format */
- nlmNAME(object_p), /* assembler/linker output (object file) */
- bfd_generic_archive_p, /* an archive */
- nlm_core_file_p /* a core file */
- },
-
- /* bfd_set_format: set the format of a file being written */
- { bfd_false,
- nlm_mkobject,
- _bfd_generic_mkarchive,
- bfd_false
- },
-
- /* bfd_write_contents: write cached information into a file being written */
- { bfd_false,
- nlmNAME(write_object_contents),
- _bfd_write_archive_contents,
- bfd_false
- },
-
- /* Initialize a jump table with the standard macro. All names start with
- "nlm" */
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (nlm),
- BFD_JUMP_TABLE_RELOCS (nlm),
- BFD_JUMP_TABLE_WRITE (nlm),
- BFD_JUMP_TABLE_LINK (nlm),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- /* backend_data: */
- (PTR) TARGET_BACKEND_DATA
-};
-#endif
-
-#ifdef TARGET_LITTLE_SYM
-const bfd_target TARGET_LITTLE_SYM =
-{
- /* name: identify kind of target */
- TARGET_LITTLE_NAME,
-
- /* flavour: general indication about file */
- bfd_target_nlm_flavour,
-
- /* byteorder: data is little endian */
- BFD_ENDIAN_LITTLE,
-
- /* header_byteorder: header is also little endian */
- BFD_ENDIAN_LITTLE,
-
- /* object_flags: mask of all file flags */
- (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
- | WP_TEXT),
-
- /* section_flags: mask of all section flags */
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
- SEC_DATA),
-
- /* leading_symbol_char: is the first char of a user symbol
- predictable, and if so what is it */
- 0,
-
- /* ar_pad_char: pad character for filenames within an archive header
- FIXME: this really has nothing to do with NLM, 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 NLM, this is a characteristic
- of the archiver and should be independently tunable. This value is
- a WAG (wild a** guess) */
- 15,
-
- /* Routines to byte-swap various sized integers from the data sections */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16,
-
- /* Routines to byte-swap various sized integers from the file headers */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16,
-
- /* bfd_check_format: check the format of a file being read */
- { _bfd_dummy_target, /* unknown format */
- nlmNAME(object_p), /* assembler/linker output (object file) */
- bfd_generic_archive_p, /* an archive */
- nlm_core_file_p /* a core file */
- },
-
- /* bfd_set_format: set the format of a file being written */
- { bfd_false,
- nlm_mkobject,
- _bfd_generic_mkarchive,
- bfd_false
- },
-
- /* bfd_write_contents: write cached information into a file being written */
- { bfd_false,
- nlmNAME(write_object_contents),
- _bfd_write_archive_contents,
- bfd_false
- },
-
- /* Initialize a jump table with the standard macro. All names start with
- "nlm" */
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (nlm),
- BFD_JUMP_TABLE_RELOCS (nlm),
- BFD_JUMP_TABLE_WRITE (nlm),
- BFD_JUMP_TABLE_LINK (nlm),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- /* backend_data: */
- (PTR) TARGET_BACKEND_DATA
-};
-#endif
diff --git a/contrib/gdb/bfd/nlm.c b/contrib/gdb/bfd/nlm.c
deleted file mode 100644
index 89c6baa..0000000
--- a/contrib/gdb/bfd/nlm.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* NLM (NetWare Loadable Module) executable support for BFD.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libnlm.h"
-
-/* Make an NLM object. We just need to allocate the backend
- information. */
-
-boolean
-nlm_mkobject (abfd)
- bfd * abfd;
-{
- nlm_tdata (abfd) =
- (struct nlm_obj_tdata *) bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata));
- if (nlm_tdata (abfd) == NULL)
- return (false);
-
- if (nlm_architecture (abfd) != bfd_arch_unknown)
- bfd_default_set_arch_mach (abfd, nlm_architecture (abfd),
- nlm_machine (abfd));
-
- /* since everything is done at close time, do we need any initialization? */
- return (true);
-}
-
-/* Set the architecture and machine for an NLM object. */
-
-boolean
-nlm_set_arch_mach (abfd, arch, machine)
- bfd * abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- bfd_default_set_arch_mach (abfd, arch, machine);
- return arch == nlm_architecture (abfd);
-}
diff --git a/contrib/gdb/bfd/nlm32-alpha.c b/contrib/gdb/bfd/nlm32-alpha.c
deleted file mode 100644
index 24c8e51..0000000
--- a/contrib/gdb/bfd/nlm32-alpha.c
+++ /dev/null
@@ -1,892 +0,0 @@
-/* Support for 32-bit Alpha NLM (NetWare Loadable Module)
- Copyright (C) 1993 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file describes the 32 bit Alpha NLM format. You might think
- that an Alpha chip would use a 64 bit format, but, for some reason,
- it doesn't. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#define ARCH_SIZE 32
-
-#include "nlm/alpha-ext.h"
-#define Nlm_External_Fixed_Header Nlm32_alpha_External_Fixed_Header
-
-#include "libnlm.h"
-
-static boolean nlm_alpha_backend_object_p
- PARAMS ((bfd *));
-static boolean nlm_alpha_write_prefix
- PARAMS ((bfd *));
-static boolean nlm_alpha_read_reloc
- PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
-static boolean nlm_alpha_mangle_relocs
- PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
-static boolean nlm_alpha_read_import
- PARAMS ((bfd *, nlmNAME(symbol_type) *));
-static boolean nlm_alpha_write_import
- PARAMS ((bfd *, asection *, arelent *));
-static boolean nlm_alpha_set_public_section
- PARAMS ((bfd *, nlmNAME(symbol_type) *));
-static bfd_vma nlm_alpha_get_public_offset
- PARAMS ((bfd *, asymbol *));
-static boolean nlm_alpha_write_external
- PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
-
-/* Alpha NLM's have a prefix header before the standard NLM. This
- function reads it in, verifies the version, and seeks the bfd to
- the location before the regular NLM header. */
-
-static boolean
-nlm_alpha_backend_object_p (abfd)
- bfd *abfd;
-{
- struct nlm32_alpha_external_prefix_header s;
- bfd_size_type size;
-
- if (bfd_read ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
- return false;
-
- if (bfd_h_get_32 (abfd, s.magic) != NLM32_ALPHA_MAGIC)
- return false;
-
- /* FIXME: Should we check the format number? */
-
- /* Skip to the end of the header. */
- size = bfd_h_get_32 (abfd, s.size);
- if (bfd_seek (abfd, size, SEEK_SET) != 0)
- return false;
-
- return true;
-}
-
-/* Write out the prefix. */
-
-static boolean
-nlm_alpha_write_prefix (abfd)
- bfd *abfd;
-{
- struct nlm32_alpha_external_prefix_header s;
-
- memset (&s, 0, sizeof s);
- bfd_h_put_32 (abfd, (bfd_vma) NLM32_ALPHA_MAGIC, s.magic);
- bfd_h_put_32 (abfd, (bfd_vma) 2, s.format);
- bfd_h_put_32 (abfd, (bfd_vma) sizeof s, s.size);
- if (bfd_write ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
- return false;
- return true;
-}
-
-/* How to process the various reloc types. */
-
-static reloc_howto_type nlm32_alpha_howto_table[] =
-{
- /* Reloc type 0 is ignored by itself. However, it appears after a
- GPDISP reloc to identify the location where the low order 16 bits
- of the gp register are loaded. */
- HOWTO (ALPHA_R_IGNORE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "IGNORE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 32 bit reference to a symbol. */
- HOWTO (ALPHA_R_REFLONG, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "REFLONG", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 64 bit reference to a symbol. */
- HOWTO (ALPHA_R_REFQUAD, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "REFQUAD", /* name */
- true, /* partial_inplace */
- 0xffffffffffffffff, /* src_mask */
- 0xffffffffffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 32 bit GP relative offset. This is just like REFLONG except
- that when the value is used the value of the gp register will be
- added in. */
- HOWTO (ALPHA_R_GPREL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "GPREL32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Used for an instruction that refers to memory off the GP
- register. The offset is 16 bits of the 32 bit instruction. This
- reloc always seems to be against the .lita section. */
- HOWTO (ALPHA_R_LITERAL, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "LITERAL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* This reloc only appears immediately following a LITERAL reloc.
- It identifies a use of the literal. It seems that the linker can
- use this to eliminate a portion of the .lita section. The symbol
- index is special: 1 means the literal address is in the base
- register of a memory format instruction; 2 means the literal
- address is in the byte offset register of a byte-manipulation
- instruction; 3 means the literal address is in the target
- register of a jsr instruction. This does not actually do any
- relocation. */
- HOWTO (ALPHA_R_LITUSE, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "LITUSE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Load the gp register. This is always used for a ldah instruction
- which loads the upper 16 bits of the gp register. The next reloc
- will be an IGNORE reloc which identifies the location of the lda
- instruction which loads the lower 16 bits. The symbol index of
- the GPDISP instruction appears to actually be the number of bytes
- between the ldah and lda instructions. This gives two different
- ways to determine where the lda instruction is; I don't know why
- both are used. The value to use for the relocation is the
- difference between the GP value and the current location; the
- load will always be done against a register holding the current
- address. */
- HOWTO (ALPHA_R_GPDISP, /* type */
- 16, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "GPDISP", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- true), /* pcrel_offset */
-
- /* A 21 bit branch. The native assembler generates these for
- branches within the text segment, and also fills in the PC
- relative offset in the instruction. It seems to me that this
- reloc, unlike the others, is not partial_inplace. */
- HOWTO (ALPHA_R_BRADDR, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 21, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "BRADDR", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0x1fffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A hint for a jump to a register. */
- HOWTO (ALPHA_R_HINT, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 14, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "HINT", /* name */
- true, /* partial_inplace */
- 0x3fff, /* src_mask */
- 0x3fff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL16, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "SREL16", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "SREL32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* A 64 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL64, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "SREL64", /* name */
- true, /* partial_inplace */
- 0xffffffffffffffff, /* src_mask */
- 0xffffffffffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Push a value on the reloc evaluation stack. */
- HOWTO (ALPHA_R_OP_PUSH, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "OP_PUSH", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Store the value from the stack at the given address. Store it in
- a bitfield of size r_size starting at bit position r_offset. */
- HOWTO (ALPHA_R_OP_STORE, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "OP_STORE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffffffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Subtract the reloc address from the value on the top of the
- relocation stack. */
- HOWTO (ALPHA_R_OP_PSUB, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "OP_PSUB", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Shift the value on the top of the relocation stack right by the
- given value. */
- HOWTO (ALPHA_R_OP_PRSHIFT, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "OP_PRSHIFT", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Adjust the GP value for a new range in the object file. */
- HOWTO (ALPHA_R_GPVALUE, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "GPVALUE", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false) /* pcrel_offset */
-};
-
-static reloc_howto_type nlm32_alpha_nw_howto =
- HOWTO (ALPHA_R_NW_RELOC, /* type */
- 0, /* rightshift */
- 0, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- 0, /* special_function */
- "NW_RELOC", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false); /* pcrel_offset */
-
-/* Read an Alpha NLM reloc. This routine keeps some static data which
- it uses when handling local relocs. This only works correctly
- because all the local relocs are read at once. */
-
-static boolean
-nlm_alpha_read_reloc (abfd, sym, secp, rel)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
- asection **secp;
- arelent *rel;
-{
- static bfd_vma gp_value;
- static bfd_vma lita_address;
- struct nlm32_alpha_external_reloc ext;
- bfd_vma r_vaddr;
- long r_symndx;
- int r_type, r_extern, r_offset, r_size;
- asection *code_sec, *data_sec;
-
- /* Read the reloc from the file. */
- if (bfd_read (&ext, sizeof ext, 1, abfd) != sizeof ext)
- return false;
-
- /* Swap in the reloc information. */
- r_vaddr = bfd_h_get_64 (abfd, (bfd_byte *) ext.r_vaddr);
- r_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext.r_symndx);
-
- BFD_ASSERT (bfd_little_endian (abfd));
-
- r_type = ((ext.r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
- >> RELOC_BITS0_TYPE_SH_LITTLE);
- r_extern = (ext.r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
- r_offset = ((ext.r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
- >> RELOC_BITS1_OFFSET_SH_LITTLE);
- /* Ignore the reserved bits. */
- r_size = ((ext.r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
- >> RELOC_BITS3_SIZE_SH_LITTLE);
-
- /* Fill in the BFD arelent structure. */
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- if (r_extern)
- {
- /* External relocations are only used for imports. */
- BFD_ASSERT (sym != NULL);
- /* We don't need to set sym_ptr_ptr for this case. It is set in
- nlm_canonicalize_reloc. */
- rel->sym_ptr_ptr = NULL;
- rel->addend = 0;
- }
- else
- {
- /* Internal relocations are only used for local relocation
- fixups. If they are not NW_RELOC or GPDISP or IGNORE, they
- must be against .text or .data. */
- BFD_ASSERT (r_type == ALPHA_R_NW_RELOC || sym == NULL);
- if (r_type == ALPHA_R_NW_RELOC
- || r_type == ALPHA_R_GPDISP
- || r_type == ALPHA_R_IGNORE)
- {
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rel->addend = 0;
- }
- else if (r_symndx == ALPHA_RELOC_SECTION_TEXT)
- {
- rel->sym_ptr_ptr = code_sec->symbol_ptr_ptr;
- BFD_ASSERT (bfd_get_section_vma (abfd, code_sec) == 0);
- rel->addend = 0;
- }
- else if (r_symndx == ALPHA_RELOC_SECTION_DATA)
- {
- rel->sym_ptr_ptr = data_sec->symbol_ptr_ptr;
- rel->addend = - bfd_get_section_vma (abfd, data_sec);
- }
- else
- {
- BFD_ASSERT (0);
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rel->addend = 0;
- }
- }
-
- /* We use the address to determine whether the reloc is in the .text
- or .data section. R_NW_RELOC relocs don't really have a section,
- so we put them in .text. */
- if (r_type == ALPHA_R_NW_RELOC
- || r_vaddr < bfd_section_size (abfd, code_sec))
- {
- *secp = code_sec;
- rel->address = r_vaddr;
- }
- else
- {
- *secp = data_sec;
- rel->address = r_vaddr - bfd_section_size (abfd, code_sec);
- }
-
- /* We must adjust the addend based on the type. */
- BFD_ASSERT ((r_type >= 0 && r_type <= ALPHA_R_GPVALUE)
- || r_type == ALPHA_R_NW_RELOC);
-
- switch (r_type)
- {
- case ALPHA_R_BRADDR:
- case ALPHA_R_SREL16:
- case ALPHA_R_SREL32:
- case ALPHA_R_SREL64:
- /* The PC relative relocs do not seem to use the section VMA as
- a negative addend. */
- rel->addend = 0;
- break;
-
- case ALPHA_R_GPREL32:
- /* Copy the gp value for this object file into the addend, to
- ensure that we are not confused by the linker. */
- if (! r_extern)
- rel->addend += gp_value;
- break;
-
- case ALPHA_R_LITERAL:
- BFD_ASSERT (! r_extern);
- rel->addend += lita_address;
- break;
-
- case ALPHA_R_LITUSE:
- case ALPHA_R_GPDISP:
- /* The LITUSE and GPDISP relocs do not use a symbol, or an
- addend, but they do use a special code. Put this code in the
- addend field. */
- rel->addend = r_symndx;
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- break;
-
- case ALPHA_R_OP_STORE:
- /* The STORE reloc needs the size and offset fields. We store
- them in the addend. */
- BFD_ASSERT (r_offset < 256 && r_size < 256);
- rel->addend = (r_offset << 8) + r_size;
- break;
-
- case ALPHA_R_OP_PUSH:
- case ALPHA_R_OP_PSUB:
- case ALPHA_R_OP_PRSHIFT:
- /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
- address. I believe that the address supplied is really an
- addend. */
- rel->addend = r_vaddr;
- break;
-
- case ALPHA_R_GPVALUE:
- /* Record the new gp value. */
- gp_value += r_symndx;
- rel->addend = gp_value;
- break;
-
- case ALPHA_R_IGNORE:
- /* If the type is ALPHA_R_IGNORE, make sure this is a reference
- to the absolute section so that the reloc is ignored. For
- some reason the address of this reloc type is not adjusted by
- the section vma. We record the gp value for this object file
- here, for convenience when doing the GPDISP relocation. */
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rel->address = r_vaddr;
- rel->addend = gp_value;
- break;
-
- case ALPHA_R_NW_RELOC:
- /* If this is SETGP, we set the addend to 0. Otherwise we set
- the addend to the size of the .lita section (this is
- r_symndx) plus 1. We have already set the address of the
- reloc to r_vaddr. */
- if (r_size == ALPHA_R_NW_RELOC_SETGP)
- {
- gp_value = r_vaddr;
- rel->addend = 0;
- }
- else if (r_size == ALPHA_R_NW_RELOC_LITA)
- {
- lita_address = r_vaddr;
- rel->addend = r_symndx + 1;
- }
- else
- BFD_ASSERT (0);
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- break;
-
- default:
- break;
- }
-
- if (r_type == ALPHA_R_NW_RELOC)
- rel->howto = &nlm32_alpha_nw_howto;
- else
- rel->howto = &nlm32_alpha_howto_table[r_type];
-
- return true;
-}
-
-/* Mangle Alpha NLM relocs for output. */
-
-static boolean
-nlm_alpha_mangle_relocs (abfd, sec, data, offset, count)
- bfd *abfd;
- asection *sec;
- PTR data;
- bfd_vma offset;
- bfd_size_type count;
-{
- return true;
-}
-
-/* Read an ALPHA NLM import record */
-
-static boolean
-nlm_alpha_read_import (abfd, sym)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
-{
- struct nlm_relent *nlm_relocs; /* relocation records for symbol */
- bfd_size_type rcount; /* number of relocs */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
- unsigned char symlength; /* length of symbol name */
- char *name;
-
- if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
- != sizeof (symlength))
- return false;
- sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, symlength + 1);
- if (name == NULL)
- return false;
- if (bfd_read (name, symlength, 1, abfd) != symlength)
- return false;
- name[symlength] = '\0';
- sym -> symbol.name = name;
- sym -> symbol.flags = 0;
- sym -> symbol.value = 0;
- sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return false;
- rcount = bfd_h_get_32 (abfd, temp);
- nlm_relocs = ((struct nlm_relent *)
- bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
- if (!nlm_relocs)
- return false;
- sym -> relocs = nlm_relocs;
- sym -> rcnt = 0;
- while (sym -> rcnt < rcount)
- {
- asection *section;
-
- if (nlm_alpha_read_reloc (abfd, sym, &section,
- &nlm_relocs -> reloc)
- == false)
- return false;
- nlm_relocs -> section = section;
- nlm_relocs++;
- sym -> rcnt++;
- }
-
- return true;
-}
-
-/* Write an Alpha NLM reloc. */
-
-static boolean
-nlm_alpha_write_import (abfd, sec, rel)
- bfd *abfd;
- asection *sec;
- arelent *rel;
-{
- asymbol *sym;
- bfd_vma r_vaddr;
- long r_symndx;
- int r_type, r_extern, r_offset, r_size;
- struct nlm32_alpha_external_reloc ext;
-
- sym = *rel->sym_ptr_ptr;
-
- /* Get values for the relocation fields. */
- r_type = rel->howto->type;
- if (r_type != ALPHA_R_NW_RELOC)
- {
- r_vaddr = bfd_get_section_vma (abfd, sec) + rel->address;
- if ((sec->flags & SEC_CODE) == 0)
- r_vaddr += bfd_section_size (abfd,
- bfd_get_section_by_name (abfd,
- NLM_CODE_NAME));
- if (bfd_is_und_section (bfd_get_section (sym)))
- {
- r_extern = 1;
- r_symndx = 0;
- }
- else
- {
- r_extern = 0;
- if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
- r_symndx = ALPHA_RELOC_SECTION_TEXT;
- else
- r_symndx = ALPHA_RELOC_SECTION_DATA;
- }
- r_offset = 0;
- r_size = 0;
-
- switch (r_type)
- {
- case ALPHA_R_LITUSE:
- case ALPHA_R_GPDISP:
- r_symndx = rel->addend;
- break;
-
- case ALPHA_R_OP_STORE:
- r_size = rel->addend & 0xff;
- r_offset = (rel->addend >> 8) & 0xff;
- break;
-
- case ALPHA_R_OP_PUSH:
- case ALPHA_R_OP_PSUB:
- case ALPHA_R_OP_PRSHIFT:
- r_vaddr = rel->addend;
- break;
-
- case ALPHA_R_IGNORE:
- r_vaddr = rel->address;
- break;
-
- default:
- break;
- }
- }
- else
- {
- /* r_type == ALPHA_R_NW_RELOC */
- r_vaddr = rel->address;
- if (rel->addend == 0)
- {
- r_symndx = 0;
- r_size = ALPHA_R_NW_RELOC_SETGP;
- }
- else
- {
- r_symndx = rel->addend - 1;
- r_size = ALPHA_R_NW_RELOC_LITA;
- }
- r_extern = 0;
- r_offset = 0;
- }
-
- /* Swap out the relocation fields. */
- bfd_h_put_64 (abfd, r_vaddr, (bfd_byte *) ext.r_vaddr);
- bfd_h_put_32 (abfd, r_symndx, (bfd_byte *) ext.r_symndx);
-
- BFD_ASSERT (bfd_little_endian (abfd));
-
- ext.r_bits[0] = ((r_type << RELOC_BITS0_TYPE_SH_LITTLE)
- & RELOC_BITS0_TYPE_LITTLE);
- ext.r_bits[1] = ((r_extern ? RELOC_BITS1_EXTERN_LITTLE : 0)
- | ((r_offset << RELOC_BITS1_OFFSET_SH_LITTLE)
- & RELOC_BITS1_OFFSET_LITTLE));
- ext.r_bits[2] = 0;
- ext.r_bits[3] = ((r_size << RELOC_BITS3_SIZE_SH_LITTLE)
- & RELOC_BITS3_SIZE_LITTLE);
-
- /* Write out the relocation. */
- if (bfd_write (&ext, sizeof ext, 1, abfd) != sizeof ext)
- return false;
-
- return true;
-}
-
-/* Alpha NetWare does not use the high bit to determine whether a
- public symbol is in the code segment or the data segment. Instead,
- it just uses the address. The set_public_section and
- get_public_offset routines override the default code which uses the
- high bit. */
-
-/* Set the section for a public symbol. */
-
-static boolean
-nlm_alpha_set_public_section (abfd, sym)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
-{
- asection *code_sec, *data_sec;
-
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- if (sym->symbol.value < bfd_section_size (abfd, code_sec))
- {
- sym->symbol.section = code_sec;
- sym->symbol.flags |= BSF_FUNCTION;
- }
- else
- {
- sym->symbol.section = data_sec;
- sym->symbol.value -= bfd_section_size (abfd, code_sec);
- /* The data segment had better be aligned. */
- BFD_ASSERT ((bfd_section_size (abfd, code_sec) & 0xf) == 0);
- }
- return true;
-}
-
-/* Get the offset to write out for a public symbol. */
-
-static bfd_vma
-nlm_alpha_get_public_offset (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- return bfd_asymbol_value (sym);
-}
-
-/* Write an Alpha NLM external symbol. */
-
-static boolean
-nlm_alpha_write_external (abfd, count, sym, relocs)
- bfd *abfd;
- bfd_size_type count;
- asymbol *sym;
- struct reloc_and_sec *relocs;
-{
- int i;
- bfd_byte len;
- unsigned char temp[NLM_TARGET_LONG_SIZE];
- arelent r;
-
- len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
- return false;
-
- bfd_put_32 (abfd, count + 2, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return false;
-
- /* The first two relocs for each external symbol are the .lita
- address and the GP value. */
- r.sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- r.howto = &nlm32_alpha_nw_howto;
-
- r.address = nlm_alpha_backend_data (abfd)->lita_address;
- r.addend = nlm_alpha_backend_data (abfd)->lita_size + 1;
- if (nlm_alpha_write_import (abfd, (asection *) NULL, &r) == false)
- return false;
-
- r.address = nlm_alpha_backend_data (abfd)->gp;
- r.addend = 0;
- if (nlm_alpha_write_import (abfd, (asection *) NULL, &r) == false)
- return false;
-
- for (i = 0; i < count; i++)
- {
- if (nlm_alpha_write_import (abfd, relocs[i].sec,
- relocs[i].rel) == false)
- return false;
- }
-
- return true;
-}
-
-#include "nlmswap.h"
-
-static const struct nlm_backend_data nlm32_alpha_backend =
-{
- "NetWare Alpha Module \032",
- sizeof (Nlm32_alpha_External_Fixed_Header),
- sizeof (struct nlm32_alpha_external_prefix_header),
- bfd_arch_alpha,
- 0,
- true, /* no uninitialized data permitted by Alpha NetWare. */
- nlm_alpha_backend_object_p,
- nlm_alpha_write_prefix,
- nlm_alpha_read_reloc,
- nlm_alpha_mangle_relocs,
- nlm_alpha_read_import,
- nlm_alpha_write_import,
- nlm_alpha_set_public_section,
- nlm_alpha_get_public_offset,
- nlm_swap_fixed_header_in,
- nlm_swap_fixed_header_out,
- nlm_alpha_write_external,
- 0, /* write_export */
-};
-
-#define TARGET_LITTLE_NAME "nlm32-alpha"
-#define TARGET_LITTLE_SYM nlmNAME(alpha_vec)
-#define TARGET_BACKEND_DATA &nlm32_alpha_backend
-
-#include "nlm-target.h"
diff --git a/contrib/gdb/bfd/nlm32-i386.c b/contrib/gdb/bfd/nlm32-i386.c
deleted file mode 100644
index f16c74d..0000000
--- a/contrib/gdb/bfd/nlm32-i386.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/* Support for 32-bit i386 NLM (NetWare Loadable Module)
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#define ARCH_SIZE 32
-
-#include "nlm/i386-ext.h"
-#define Nlm_External_Fixed_Header Nlm32_i386_External_Fixed_Header
-
-#include "libnlm.h"
-
-static boolean nlm_i386_read_reloc
- PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
-static boolean nlm_i386_write_import
- PARAMS ((bfd *, asection *, arelent *));
-static boolean nlm_i386_mangle_relocs
- PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
-static boolean nlm_i386_read_import
- PARAMS ((bfd *, nlmNAME(symbol_type) *));
-static boolean nlm_i386_write_external
- PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
-
-/* Adjust the reloc location by an absolute value. */
-
-static reloc_howto_type nlm_i386_abs_howto =
- HOWTO (0, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false); /* pcrel_offset */
-
-/* Adjust the reloc location by a PC relative displacement. */
-
-static reloc_howto_type nlm_i386_pcrel_howto =
- HOWTO (1, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "DISP32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- true); /* pcrel_offset */
-
-/* Read a NetWare i386 reloc. */
-
-static boolean
-nlm_i386_read_reloc (abfd, sym, secp, rel)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
- asection **secp;
- arelent *rel;
-{
- bfd_byte temp[4];
- bfd_vma val;
- const char *name;
-
- if (bfd_read (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return false;
-
- val = bfd_get_32 (abfd, temp);
-
- /* The value is an offset into either the code or data segment.
- This is the location which needs to be adjusted.
-
- If this is a relocation fixup rather than an imported symbol (the
- sym argument is NULL) then the high bit is 0 if the location
- needs to be adjusted by the address of the data segment, or 1 if
- the location needs to be adjusted by the address of the code
- segment. If this is an imported symbol, then the high bit is 0
- if the location is 0 if the location should be adjusted by the
- offset to the symbol, or 1 if the location should adjusted by the
- absolute value of the symbol.
-
- The second most significant bit is 0 if the value is an offset
- into the data segment, or 1 if the value is an offset into the
- code segment.
-
- All this translates fairly easily into a BFD reloc. */
-
- if (sym == NULL)
- {
- if ((val & NLM_HIBIT) == 0)
- name = NLM_INITIALIZED_DATA_NAME;
- else
- {
- name = NLM_CODE_NAME;
- val &=~ NLM_HIBIT;
- }
- rel->sym_ptr_ptr = bfd_get_section_by_name (abfd, name)->symbol_ptr_ptr;
- rel->howto = &nlm_i386_abs_howto;
- }
- else
- {
- /* In this case we do not need to set the sym_ptr_ptr field. */
- rel->sym_ptr_ptr = NULL;
- if ((val & NLM_HIBIT) == 0)
- rel->howto = &nlm_i386_pcrel_howto;
- else
- {
- rel->howto = &nlm_i386_abs_howto;
- val &=~ NLM_HIBIT;
- }
- }
-
- if ((val & (NLM_HIBIT >> 1)) == 0)
- *secp = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- else
- {
- *secp = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- val &=~ (NLM_HIBIT >> 1);
- }
-
- rel->address = val;
- rel->addend = 0;
-
- return true;
-}
-
-/* Write a NetWare i386 reloc. */
-
-static boolean
-nlm_i386_write_import (abfd, sec, rel)
- bfd *abfd;
- asection *sec;
- arelent *rel;
-{
- asymbol *sym;
- bfd_vma val;
- bfd_byte temp[4];
-
- /* NetWare only supports two kinds of relocs. We should check
- special_function here, as well, but at the moment coff-i386
- relocs uses a special_function which does not affect what we do
- here. */
- if (rel->addend != 0
- || rel->howto == NULL
- || rel->howto->rightshift != 0
- || rel->howto->size != 2
- || rel->howto->bitsize != 32
- || rel->howto->bitpos != 0
- || rel->howto->src_mask != 0xffffffff
- || rel->howto->dst_mask != 0xffffffff)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- sym = *rel->sym_ptr_ptr;
-
- /* The value we write out is the offset into the appropriate
- segment. This offset is the section vma, adjusted by the vma of
- the lowest section in that segment, plus the address of the
- relocation. */
- val = bfd_get_section_vma (abfd, sec) + rel->address;
-
- /* The second most significant bit is 0 if the value is an offset
- into the data segment, or 1 if the value is an offset into the
- code segment. */
- if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
- {
- val -= nlm_get_text_low (abfd);
- val |= NLM_HIBIT >> 1;
- }
- else
- val -= nlm_get_data_low (abfd);
-
- if (! bfd_is_und_section (bfd_get_section (sym)))
- {
- /* NetWare only supports absolute internal relocs. */
- if (rel->howto->pc_relative)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- /* The high bit is 1 if the reloc is against the code section, 0
- if against the data section. */
- if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
- val |= NLM_HIBIT;
- }
- else
- {
- /* The high bit is 1 if this is an absolute reloc, 0 if it is PC
- relative. */
- if (! rel->howto->pc_relative)
- val |= NLM_HIBIT;
- else
- {
- /* PC relative relocs on NetWare must be pcrel_offset. */
- if (! rel->howto->pcrel_offset)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
- }
- }
-
- bfd_put_32 (abfd, val, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return false;
-
- return true;
-}
-
-/* I want to be able to use objcopy to turn a i386 a.out or COFF file
- into a NetWare i386 module. That means that the relocs from the
- source file have to be mapped into relocs that apply to the target
- file. This function is called by nlm_set_section_contents to give
- it a chance to rework the relocs.
-
- This is actually a fairly general concept. However, this is not a
- general implementation. */
-
-static boolean
-nlm_i386_mangle_relocs (abfd, sec, data, offset, count)
- bfd *abfd;
- asection *sec;
- PTR data;
- bfd_vma offset;
- bfd_size_type count;
-{
- arelent **rel_ptr_ptr, **rel_end;
-
- rel_ptr_ptr = sec->orelocation;
- rel_end = rel_ptr_ptr + sec->reloc_count;
- for (; rel_ptr_ptr < rel_end; rel_ptr_ptr++)
- {
- arelent *rel;
- asymbol *sym;
- bfd_vma addend;
-
- rel = *rel_ptr_ptr;
- sym = *rel->sym_ptr_ptr;
-
- /* Note that no serious harm will ensue if we fail to change a
- reloc. We will wind up failing in nlm_i386_write_import. */
-
- /* Make sure this reloc is within the data we have. We only 4
- byte relocs here, so we insist on having 4 bytes. */
- if (rel->address < offset
- || rel->address + 4 > offset + count)
- continue;
-
- /* NetWare doesn't support reloc addends, so we get rid of them
- here by simply adding them into the object data. We handle
- the symbol value, if any, the same way. */
- addend = rel->addend + sym->value;
-
- /* The value of a symbol is the offset into the section. If the
- symbol is in the .bss segment, we need to include the size of
- the data segment in the offset as well. Fortunately, we know
- that at this point the size of the data section is in the NLM
- header. */
- if (((bfd_get_section_flags (abfd, bfd_get_section (sym))
- & SEC_LOAD) == 0)
- && ((bfd_get_section_flags (abfd, bfd_get_section (sym))
- & SEC_ALLOC) != 0))
- addend += nlm_fixed_header (abfd)->dataImageSize;
-
- if (addend != 0
- && rel->howto != NULL
- && rel->howto->rightshift == 0
- && rel->howto->size == 2
- && rel->howto->bitsize == 32
- && rel->howto->bitpos == 0
- && rel->howto->src_mask == 0xffffffff
- && rel->howto->dst_mask == 0xffffffff)
- {
- bfd_vma val;
-
- val = bfd_get_32 (abfd, (bfd_byte *) data + rel->address - offset);
- val += addend;
- bfd_put_32 (abfd, val, (bfd_byte *) data + rel->address - offset);
- rel->addend = 0;
- }
-
- /* NetWare uses a reloc with pcrel_offset set. We adjust
- pc_relative relocs accordingly. We are going to change the
- howto field, so we can only do this if the current one is
- compatible. We should check special_function here, but at
- the moment coff-i386 uses a special_function which does not
- affect what we are doing here. */
- if (rel->howto != NULL
- && rel->howto->pc_relative
- && ! rel->howto->pcrel_offset
- && rel->howto->rightshift == 0
- && rel->howto->size == 2
- && rel->howto->bitsize == 32
- && rel->howto->bitpos == 0
- && rel->howto->src_mask == 0xffffffff
- && rel->howto->dst_mask == 0xffffffff)
- {
- bfd_vma val;
-
- /* When pcrel_offset is not set, it means that the negative
- of the address of the memory location is stored in the
- memory location. We must add it back in. */
- val = bfd_get_32 (abfd, (bfd_byte *) data + rel->address - offset);
- val += rel->address;
- bfd_put_32 (abfd, val, (bfd_byte *) data + rel->address - offset);
-
- rel->howto = &nlm_i386_pcrel_howto;
- }
- }
-
- return true;
-}
-
-/* Read a NetWare i386 import record */
-static boolean
-nlm_i386_read_import (abfd, sym)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
-{
- struct nlm_relent *nlm_relocs; /* relocation records for symbol */
- bfd_size_type rcount; /* number of relocs */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
- unsigned char symlength; /* length of symbol name */
- char *name;
-
- if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
- != sizeof (symlength))
- return false;
- sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, symlength + 1);
- if (name == NULL)
- return false;
- if (bfd_read (name, symlength, 1, abfd) != symlength)
- return false;
- name[symlength] = '\0';
- sym -> symbol.name = name;
- sym -> symbol.flags = 0;
- sym -> symbol.value = 0;
- sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return false;
- rcount = bfd_h_get_32 (abfd, temp);
- nlm_relocs = ((struct nlm_relent *)
- bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
- if (!nlm_relocs)
- return false;
- sym -> relocs = nlm_relocs;
- sym -> rcnt = 0;
- while (sym -> rcnt < rcount)
- {
- asection *section;
-
- if (nlm_i386_read_reloc (abfd, sym, &section,
- &nlm_relocs -> reloc)
- == false)
- return false;
- nlm_relocs -> section = section;
- nlm_relocs++;
- sym -> rcnt++;
- }
- return true;
-}
-
-/* Write out an external reference. */
-
-static boolean
-nlm_i386_write_external (abfd, count, sym, relocs)
- bfd *abfd;
- bfd_size_type count;
- asymbol *sym;
- struct reloc_and_sec *relocs;
-{
- unsigned int i;
- bfd_byte len;
- unsigned char temp[NLM_TARGET_LONG_SIZE];
-
- len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
- return false;
-
- bfd_put_32 (abfd, count, temp);
- if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
- return false;
-
- for (i = 0; i < count; i++)
- {
- if (nlm_i386_write_import (abfd, relocs[i].sec,
- relocs[i].rel) == false)
- return false;
- }
-
- return true;
-}
-
-#include "nlmswap.h"
-
-static const struct nlm_backend_data nlm32_i386_backend =
-{
- "NetWare Loadable Module\032",
- sizeof (Nlm32_i386_External_Fixed_Header),
- 0, /* optional_prefix_size */
- bfd_arch_i386,
- 0,
- false,
- 0, /* backend_object_p */
- 0, /* write_prefix_func */
- nlm_i386_read_reloc,
- nlm_i386_mangle_relocs,
- nlm_i386_read_import,
- nlm_i386_write_import,
- 0, /* set_public_section */
- 0, /* get_public_offset */
- nlm_swap_fixed_header_in,
- nlm_swap_fixed_header_out,
- nlm_i386_write_external,
- 0, /* write_export */
-};
-
-#define TARGET_LITTLE_NAME "nlm32-i386"
-#define TARGET_LITTLE_SYM nlmNAME(i386_vec)
-#define TARGET_BACKEND_DATA &nlm32_i386_backend
-
-#include "nlm-target.h"
diff --git a/contrib/gdb/bfd/nlm32-ppc.c b/contrib/gdb/bfd/nlm32-ppc.c
deleted file mode 100644
index ecf2de8..0000000
--- a/contrib/gdb/bfd/nlm32-ppc.c
+++ /dev/null
@@ -1,1045 +0,0 @@
-/* Support for 32-bit PowerPC NLM (NetWare Loadable Module)
- Copyright (C) 1994, 1995 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-/* The format of a PowerPC NLM changed. Define OLDFORMAT to get the
- old format. */
-
-#define ARCH_SIZE 32
-
-#include "nlm/ppc-ext.h"
-#define Nlm_External_Fixed_Header Nlm32_powerpc_External_Fixed_Header
-
-#include "libnlm.h"
-
-#ifdef OLDFORMAT
-static boolean nlm_powerpc_backend_object_p
- PARAMS ((bfd *));
-static boolean nlm_powerpc_write_prefix
- PARAMS ((bfd *));
-#endif
-
-static boolean nlm_powerpc_read_reloc
- PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
-static boolean nlm_powerpc_mangle_relocs
- PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
-static boolean nlm_powerpc_read_import
- PARAMS ((bfd *, nlmNAME(symbol_type) *));
-
-#ifdef OLDFORMAT
-static boolean nlm_powerpc_write_reloc
- PARAMS ((bfd *, asection *, arelent *, int));
-#endif
-
-static boolean nlm_powerpc_write_import
- PARAMS ((bfd *, asection *, arelent *));
-static boolean nlm_powerpc_write_external
- PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
-
-#ifndef OLDFORMAT
-static boolean nlm_powerpc_set_public_section
- PARAMS ((bfd *, nlmNAME(symbol_type) *));
-static bfd_vma nlm_powerpc_get_public_offset
- PARAMS ((bfd *, asymbol *));
-#endif
-
-#ifdef OLDFORMAT
-
-/* The prefix header is only used in the old format. */
-
-/* PowerPC NLM's have a prefix header before the standard NLM. This
- function reads it in, verifies the version, and seeks the bfd to
- the location before the regular NLM header. */
-
-static boolean
-nlm_powerpc_backend_object_p (abfd)
- bfd *abfd;
-{
- struct nlm32_powerpc_external_prefix_header s;
-
- if (bfd_read ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
- return false;
-
- if (memcmp (s.signature, NLM32_POWERPC_SIGNATURE, sizeof s.signature) != 0
- || bfd_h_get_32 (abfd, s.headerVersion) != NLM32_POWERPC_HEADER_VERSION)
- return false;
-
- return true;
-}
-
-/* Write out the prefix. */
-
-static boolean
-nlm_powerpc_write_prefix (abfd)
- bfd *abfd;
-{
- struct nlm32_powerpc_external_prefix_header s;
-
- memset (&s, 0, sizeof s);
- memcpy (s.signature, NLM32_POWERPC_SIGNATURE, sizeof s.signature);
- bfd_h_put_32 (abfd, (bfd_vma) NLM32_POWERPC_HEADER_VERSION, s.headerVersion);
- bfd_h_put_32 (abfd, (bfd_vma) 0, s.origins);
-
- /* FIXME: What should we do about the date? */
-
- if (bfd_write ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
- return false;
-
- return true;
-}
-
-#endif /* OLDFORMAT */
-
-#ifndef OLDFORMAT
-
-/* There is only one type of reloc in a PowerPC NLM. */
-
-static reloc_howto_type nlm_powerpc_howto =
- HOWTO (0, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "32", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false); /* pcrel_offset */
-
-/* Read a PowerPC NLM reloc. */
-
-static boolean
-nlm_powerpc_read_reloc (abfd, sym, secp, rel)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
- asection **secp;
- arelent *rel;
-{
- bfd_byte temp[4];
- bfd_vma val;
- const char *name;
-
- if (bfd_read (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return false;
-
- val = bfd_get_32 (abfd, temp);
-
- /* The value is a word offset into either the code or data segment.
- This is the location which needs to be adjusted.
-
- The high bit is 0 if the value is an offset into the data
- segment, or 1 if the value is an offset into the text segment.
-
- If this is a relocation fixup rather than an imported symbol (the
- sym argument is NULL), then the second most significant bit is 0
- if the address of the data segment should be added to the
- location addressed by the value, or 1 if the address of the text
- segment should be added.
-
- If this is an imported symbol, the second most significant bit is
- not used and must be 0. */
-
- if ((val & NLM_HIBIT) == 0)
- name = NLM_INITIALIZED_DATA_NAME;
- else
- {
- name = NLM_CODE_NAME;
- val &=~ NLM_HIBIT;
- }
- *secp = bfd_get_section_by_name (abfd, name);
-
- if (sym == NULL)
- {
- if ((val & (NLM_HIBIT >> 1)) == 0)
- name = NLM_INITIALIZED_DATA_NAME;
- else
- {
- name = NLM_CODE_NAME;
- val &=~ (NLM_HIBIT >> 1);
- }
- rel->sym_ptr_ptr = bfd_get_section_by_name (abfd, name)->symbol_ptr_ptr;
- }
-
- rel->howto = &nlm_powerpc_howto;
-
- rel->address = val << 2;
- rel->addend = 0;
-
- return true;
-}
-
-#else /* OLDFORMAT */
-
-/* This reloc handling is only applicable to the old format. */
-
-/* How to process the various reloc types. PowerPC NLMs use XCOFF
- reloc types, and I have just copied the XCOFF reloc table here. */
-
-static reloc_howto_type nlm_powerpc_howto_table[] =
-{
- /* Standard 32 bit relocation. */
- HOWTO (0, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_POS", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit relocation, but store negative value. */
- HOWTO (1, /* type */
- 0, /* rightshift */
- -2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_NEG", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 32 bit PC relative relocation. */
- HOWTO (2, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_REL", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* 16 bit TOC relative relocation. */
- HOWTO (3, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_TOC", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* I don't really know what this is. */
- HOWTO (4, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RTB", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* External TOC relative symbol. */
- HOWTO (5, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_GL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Local TOC relative symbol. */
- HOWTO (6, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TCL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- { 7 },
-
- /* Non modifiable absolute branch. */
- HOWTO (8, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_BA", /* name */
- true, /* partial_inplace */
- 0x3fffffc, /* src_mask */
- 0x3fffffc, /* dst_mask */
- false), /* pcrel_offset */
-
- { 9 },
-
- /* Non modifiable relative branch. */
- HOWTO (0xa, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_BR", /* name */
- true, /* partial_inplace */
- 0x3fffffc, /* src_mask */
- 0x3fffffc, /* dst_mask */
- false), /* pcrel_offset */
-
- { 0xb },
-
- /* Indirect load. */
- HOWTO (0xc, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Load address. */
- HOWTO (0xd, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RLA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- { 0xe },
-
- /* Non-relocating reference. */
- HOWTO (0xf, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_REF", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
-
- { 0x10 },
- { 0x11 },
-
- /* TOC relative indirect load. */
- HOWTO (0x12, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TRL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* TOC relative load address. */
- HOWTO (0x13, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TRLA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable relative branch. */
- HOWTO (0x14, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RRTBI", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable absolute branch. */
- HOWTO (0x15, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RRTBA", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable call absolute indirect. */
- HOWTO (0x16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_CAI", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable call relative. */
- HOWTO (0x17, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_REL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable branch absolute. */
- HOWTO (0x18, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable branch absolute. */
- HOWTO (0x19, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBAC", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable branch relative. */
- HOWTO (0x1a, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_REL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable branch absolute. */
- HOWTO (0x1b, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_REL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false) /* pcrel_offset */
-};
-
-#define HOWTO_COUNT (sizeof nlm_powerpc_howto_table \
- / sizeof nlm_powerpc_howto_table[0])
-
-/* Read a PowerPC NLM reloc. */
-
-static boolean
-nlm_powerpc_read_reloc (abfd, sym, secp, rel)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
- asection **secp;
- arelent *rel;
-{
- struct nlm32_powerpc_external_reloc ext;
- bfd_vma l_vaddr;
- unsigned long l_symndx;
- int l_rtype;
- int l_rsecnm;
- asection *code_sec, *data_sec, *bss_sec;
-
- /* Read the reloc from the file. */
- if (bfd_read (&ext, sizeof ext, 1, abfd) != sizeof ext)
- return false;
-
- /* Swap in the fields. */
- l_vaddr = bfd_h_get_32 (abfd, ext.l_vaddr);
- l_symndx = bfd_h_get_32 (abfd, ext.l_symndx);
- l_rtype = bfd_h_get_16 (abfd, ext.l_rtype);
- l_rsecnm = bfd_h_get_16 (abfd, ext.l_rsecnm);
-
- /* Get the sections now, for convenience. */
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
-
- /* Work out the arelent fields. */
- if (sym != NULL)
- {
- /* This is an import. sym_ptr_ptr is filled in by
- nlm_canonicalize_reloc. */
- rel->sym_ptr_ptr = NULL;
- }
- else
- {
- asection *sec;
-
- if (l_symndx == 0)
- sec = code_sec;
- else if (l_symndx == 1)
- sec = data_sec;
- else if (l_symndx == 2)
- sec = bss_sec;
- else
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- rel->sym_ptr_ptr = sec->symbol_ptr_ptr;
- }
-
- rel->addend = 0;
-
- BFD_ASSERT ((l_rtype & 0xff) < HOWTO_COUNT);
-
- rel->howto = nlm_powerpc_howto_table + (l_rtype & 0xff);
-
- BFD_ASSERT (rel->howto->name != NULL
- && ((l_rtype & 0x8000) != 0
- ? (rel->howto->complain_on_overflow
- == complain_overflow_signed)
- : (rel->howto->complain_on_overflow
- == complain_overflow_bitfield))
- && ((l_rtype >> 8) & 0x1f) == rel->howto->bitsize - 1);
-
- if (l_rsecnm == 0)
- *secp = code_sec;
- else if (l_rsecnm == 1)
- {
- *secp = data_sec;
- l_vaddr -= bfd_section_size (abfd, code_sec);
- }
- else
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- rel->address = l_vaddr;
-
- return true;
-}
-
-#endif /* OLDFORMAT */
-
-/* Mangle PowerPC NLM relocs for output. */
-
-static boolean
-nlm_powerpc_mangle_relocs (abfd, sec, data, offset, count)
- bfd *abfd;
- asection *sec;
- PTR data;
- bfd_vma offset;
- bfd_size_type count;
-{
- return true;
-}
-
-/* Read a PowerPC NLM import record */
-
-static boolean
-nlm_powerpc_read_import (abfd, sym)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
-{
- struct nlm_relent *nlm_relocs; /* relocation records for symbol */
- bfd_size_type rcount; /* number of relocs */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
- unsigned char symlength; /* length of symbol name */
- char *name;
-
- if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
- != sizeof (symlength))
- return (false);
- sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, symlength + 1);
- if (name == NULL)
- return false;
- if (bfd_read (name, symlength, 1, abfd) != symlength)
- return (false);
- name[symlength] = '\0';
- sym -> symbol.name = name;
- sym -> symbol.flags = 0;
- sym -> symbol.value = 0;
- sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
- rcount = bfd_h_get_32 (abfd, temp);
- nlm_relocs = ((struct nlm_relent *)
- bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
- if (nlm_relocs == (struct nlm_relent *) NULL)
- return false;
- sym -> relocs = nlm_relocs;
- sym -> rcnt = 0;
- while (sym -> rcnt < rcount)
- {
- asection *section;
-
- if (nlm_powerpc_read_reloc (abfd, sym, &section,
- &nlm_relocs -> reloc)
- == false)
- return false;
- nlm_relocs -> section = section;
- nlm_relocs++;
- sym -> rcnt++;
- }
- return true;
-}
-
-#ifndef OLDFORMAT
-
-/* Write a PowerPC NLM reloc. */
-
-static boolean
-nlm_powerpc_write_import (abfd, sec, rel)
- bfd *abfd;
- asection *sec;
- arelent *rel;
-{
- asymbol *sym;
- bfd_vma val;
- bfd_byte temp[4];
-
- /* PowerPC NetWare only supports one kind of reloc. */
- if (rel->addend != 0
- || rel->howto == NULL
- || rel->howto->rightshift != 0
- || rel->howto->size != 2
- || rel->howto->bitsize != 32
- || rel->howto->bitpos != 0
- || rel->howto->pc_relative
- || (rel->howto->src_mask != 0xffffffff && rel->addend != 0)
- || rel->howto->dst_mask != 0xffffffff)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- sym = *rel->sym_ptr_ptr;
-
- /* The value we write out is the offset into the appropriate
- segment, rightshifted by two. This offset is the section vma,
- adjusted by the vma of the lowest section in that segment, plus
- the address of the relocation. */
- val = bfd_get_section_vma (abfd, sec) + rel->address;
- if ((val & 3) != 0)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- val >>= 2;
-
- /* The high bit is 0 if the reloc is in the data section, or 1 if
- the reloc is in the code section. */
- if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
- val -= nlm_get_data_low (abfd);
- else
- {
- val -= nlm_get_text_low (abfd);
- val |= NLM_HIBIT;
- }
-
- if (! bfd_is_und_section (bfd_get_section (sym)))
- {
- /* This is an internal relocation fixup. The second most
- significant bit is 0 if this is a reloc against the data
- segment, or 1 if it is a reloc against the text segment. */
- if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
- val |= NLM_HIBIT >> 1;
- }
-
- bfd_put_32 (abfd, val, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return false;
-
- return true;
-}
-
-#else /* OLDFORMAT */
-
-/* This is used for the reloc handling in the old format. */
-
-/* Write a PowerPC NLM reloc. */
-
-static boolean
-nlm_powerpc_write_reloc (abfd, sec, rel, indx)
- bfd *abfd;
- asection *sec;
- arelent *rel;
- int indx;
-{
- struct nlm32_powerpc_external_reloc ext;
- asection *code_sec, *data_sec, *bss_sec;
- asymbol *sym;
- asection *symsec;
- unsigned long l_symndx;
- int l_rtype;
- int l_rsecnm;
- reloc_howto_type *howto;
- bfd_size_type address;
-
- /* Get the sections now, for convenience. */
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
-
- sym = *rel->sym_ptr_ptr;
- symsec = bfd_get_section (sym);
- if (indx != -1)
- {
- BFD_ASSERT (bfd_is_und_section (symsec));
- l_symndx = indx + 3;
- }
- else
- {
- if (symsec == code_sec)
- l_symndx = 0;
- else if (symsec == data_sec)
- l_symndx = 1;
- else if (symsec == bss_sec)
- l_symndx = 2;
- else
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- }
-
- bfd_h_put_32 (abfd, (bfd_vma) l_symndx, ext.l_symndx);
-
- for (howto = nlm_powerpc_howto_table;
- howto < nlm_powerpc_howto_table + HOWTO_COUNT;
- howto++)
- {
- if (howto->rightshift == rel->howto->rightshift
- && howto->size == rel->howto->size
- && howto->bitsize == rel->howto->bitsize
- && howto->pc_relative == rel->howto->pc_relative
- && howto->bitpos == rel->howto->bitpos
- && (howto->partial_inplace == rel->howto->partial_inplace
- || (! rel->howto->partial_inplace
- && rel->addend == 0))
- && (howto->src_mask == rel->howto->src_mask
- || (rel->howto->src_mask == 0
- && rel->addend == 0))
- && howto->dst_mask == rel->howto->dst_mask
- && howto->pcrel_offset == rel->howto->pcrel_offset)
- break;
- }
- if (howto >= nlm_powerpc_howto_table + HOWTO_COUNT)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- l_rtype = howto->type;
- if (howto->complain_on_overflow == complain_overflow_signed)
- l_rtype |= 0x8000;
- l_rtype |= (howto->bitsize - 1) << 8;
- bfd_h_put_16 (abfd, (bfd_vma) l_rtype, ext.l_rtype);
-
- address = rel->address;
-
- if (sec == code_sec)
- l_rsecnm = 0;
- else if (sec == data_sec)
- {
- l_rsecnm = 1;
- address += bfd_section_size (abfd, code_sec);
- }
- else
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- bfd_h_put_16 (abfd, (bfd_vma) l_rsecnm, ext.l_rsecnm);
- bfd_h_put_32 (abfd, (bfd_vma) address, ext.l_vaddr);
-
- if (bfd_write (&ext, sizeof ext, 1, abfd) != sizeof ext)
- return false;
-
- return true;
-}
-
-/* Write a PowerPC NLM import. */
-
-static boolean
-nlm_powerpc_write_import (abfd, sec, rel)
- bfd *abfd;
- asection *sec;
- arelent *rel;
-{
- return nlm_powerpc_write_reloc (abfd, sec, rel, -1);
-}
-
-#endif /* OLDFORMAT */
-
-/* Write a PowerPC NLM external symbol. This routine keeps a static
- count of the symbol index. FIXME: I don't know if this is
- necessary, and the index never gets reset. */
-
-static boolean
-nlm_powerpc_write_external (abfd, count, sym, relocs)
- bfd *abfd;
- bfd_size_type count;
- asymbol *sym;
- struct reloc_and_sec *relocs;
-{
- unsigned int i;
- bfd_byte len;
- unsigned char temp[NLM_TARGET_LONG_SIZE];
-#ifdef OLDFORMAT
- static int indx;
-#endif
-
- len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
- return false;
-
- bfd_put_32 (abfd, count, temp);
- if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
- return false;
-
- for (i = 0; i < count; i++)
- {
-#ifndef OLDFORMAT
- if (! nlm_powerpc_write_import (abfd, relocs[i].sec, relocs[i].rel))
- return false;
-#else
- if (! nlm_powerpc_write_reloc (abfd, relocs[i].sec,
- relocs[i].rel, indx))
- return false;
-#endif
- }
-
-#ifdef OLDFORMAT
- ++indx;
-#endif
-
- return true;
-}
-
-#ifndef OLDFORMAT
-
-/* PowerPC Netware uses a word offset, not a byte offset, for public
- symbols. */
-
-/* Set the section for a public symbol. */
-
-static boolean
-nlm_powerpc_set_public_section (abfd, sym)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
-{
- if (sym->symbol.value & NLM_HIBIT)
- {
- sym->symbol.value &= ~NLM_HIBIT;
- sym->symbol.flags |= BSF_FUNCTION;
- sym->symbol.section =
- bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- }
- else
- {
- sym->symbol.section =
- bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- }
-
- sym->symbol.value <<= 2;
-
- return true;
-}
-
-/* Get the offset to write out for a public symbol. */
-
-static bfd_vma
-nlm_powerpc_get_public_offset (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- bfd_vma offset;
- asection *sec;
-
- offset = bfd_asymbol_value (sym);
- sec = bfd_get_section (sym);
- if (sec->flags & SEC_CODE)
- {
- offset -= nlm_get_text_low (abfd);
- offset |= NLM_HIBIT;
- }
- else if (sec->flags & (SEC_DATA | SEC_ALLOC))
- {
- /* SEC_ALLOC is for the .bss section. */
- offset -= nlm_get_data_low (abfd);
- }
- else
- {
- /* We can't handle an exported symbol that is not in the code or
- data segment. */
- bfd_set_error (bfd_error_invalid_operation);
- /* FIXME: No way to return error. */
- abort ();
- }
-
- return offset;
-}
-
-#endif /* ! defined (OLDFORMAT) */
-
-#include "nlmswap.h"
-
-static const struct nlm_backend_data nlm32_powerpc_backend =
-{
- "NetWare PowerPC Module \032",
- sizeof (Nlm32_powerpc_External_Fixed_Header),
-#ifndef OLDFORMAT
- 0, /* optional_prefix_size */
-#else
- sizeof (struct nlm32_powerpc_external_prefix_header),
-#endif
- bfd_arch_powerpc,
- 0,
- false,
-#ifndef OLDFORMAT
- 0, /* backend_object_p */
- 0, /* write_prefix */
-#else
- nlm_powerpc_backend_object_p,
- nlm_powerpc_write_prefix,
-#endif
- nlm_powerpc_read_reloc,
- nlm_powerpc_mangle_relocs,
- nlm_powerpc_read_import,
- nlm_powerpc_write_import,
-#ifndef OLDFORMAT
- nlm_powerpc_set_public_section,
- nlm_powerpc_get_public_offset,
-#else
- 0, /* set_public_section */
- 0, /* get_public_offset */
-#endif
- nlm_swap_fixed_header_in,
- nlm_swap_fixed_header_out,
- nlm_powerpc_write_external,
- 0, /* write_export */
-};
-
-#define TARGET_BIG_NAME "nlm32-powerpc"
-#define TARGET_BIG_SYM nlmNAME(powerpc_vec)
-#define TARGET_BACKEND_DATA &nlm32_powerpc_backend
-
-#include "nlm-target.h"
diff --git a/contrib/gdb/bfd/nlm32-sparc.c b/contrib/gdb/bfd/nlm32-sparc.c
deleted file mode 100644
index 5963adb..0000000
--- a/contrib/gdb/bfd/nlm32-sparc.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/* Support for 32-bit SPARC NLM (NetWare Loadable Module)
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#define ARCH_SIZE 32
-
-#include "nlm/sparc32-ext.h"
-#define Nlm_External_Fixed_Header Nlm32_sparc_External_Fixed_Header
-
-#include "libnlm.h"
-
-static boolean nlm_sparc_read_reloc
- PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
-static boolean nlm_sparc_write_reloc
- PARAMS ((bfd *, asection *, arelent *));
-static boolean nlm_sparc_mangle_relocs
- PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
-static boolean nlm_sparc_read_import
- PARAMS ((bfd *, nlmNAME(symbol_type) *));
-static boolean nlm_sparc_write_import
- PARAMS ((bfd *, asection *, arelent *));
-static boolean nlm_sparc_write_external
- PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
-
-enum reloc_type
- {
- R_SPARC_NONE = 0,
- R_SPARC_8, R_SPARC_16, R_SPARC_32,
- R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
- R_SPARC_WDISP30, R_SPARC_WDISP22,
- R_SPARC_HI22, R_SPARC_22,
- R_SPARC_13, R_SPARC_LO10,
- R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
- R_SPARC_PC10, R_SPARC_PC22,
- R_SPARC_WPLT30,
- R_SPARC_COPY,
- R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
- R_SPARC_RELATIVE,
- R_SPARC_UA32,
- R_SPARC_max
- };
-
-#if 0
-static CONST char *CONST reloc_type_names[] =
-{
- "R_SPARC_NONE",
- "R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
- "R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
- "R_SPARC_WDISP30", "R_SPARC_WDISP22",
- "R_SPARC_HI22", "R_SPARC_22",
- "R_SPARC_13", "R_SPARC_LO10",
- "R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
- "R_SPARC_PC10", "R_SPARC_PC22",
- "R_SPARC_WPLT30",
- "R_SPARC_COPY",
- "R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
- "R_SPARC_RELATIVE",
- "R_SPARC_UA32",
-};
-#endif
-
-static reloc_howto_type nlm32_sparc_howto_table[] =
-{
- HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, 0,"R_SPARC_NONE", false,0,0x00000000,true),
- HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,0,"R_SPARC_8", false,0,0x000000ff,true),
- HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,0,"R_SPARC_16", false,0,0x0000ffff,true),
- HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,0,"R_SPARC_32", false,0,0xffffffff,true),
- HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, 0,"R_SPARC_DISP8", false,0,0x000000ff,true),
- HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, 0,"R_SPARC_DISP16", false,0,0x0000ffff,true),
- HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, 0,"R_SPARC_DISP32", false,0,0x00ffffff,true),
- HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, 0,"R_SPARC_WDISP30", false,0,0x3fffffff,true),
- HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, 0,"R_SPARC_WDISP22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, 0,"R_SPARC_HI22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,0,"R_SPARC_22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,0,"R_SPARC_13", false,0,0x00001fff,true),
- HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, 0,"R_SPARC_LO10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_bitfield,0,"R_SPARC_GOT10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_bitfield,0,"R_SPARC_GOT13", false,0,0x00001fff,true),
- HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_bitfield,0,"R_SPARC_GOT22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_PC10, 0,2,10,false,0,complain_overflow_bitfield,0,"R_SPARC_PC10", false,0,0x000003ff,true),
- HOWTO(R_SPARC_PC22, 0,2,22,false,0,complain_overflow_bitfield,0,"R_SPARC_PC22", false,0,0x003fffff,true),
- HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_WPLT30", false,0,0x00000000,true),
- HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_COPY", false,0,0x00000000,true),
- HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_GLOB_DAT",false,0,0x00000000,true),
- HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_JMP_SLOT",false,0,0x00000000,true),
- HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_RELATIVE",false,0,0x00000000,true),
- HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_UA32", false,0,0x00000000,true),
-};
-
-/* Read a NetWare sparc reloc. */
-
-struct nlm32_sparc_reloc_ext {
- unsigned char offset[4];
- unsigned char addend[4];
- unsigned char type[1];
- unsigned char pad1[3];
-};
-
-static boolean
-nlm_sparc_read_reloc (abfd, sym, secp, rel)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
- asection **secp;
- arelent *rel;
-{
- bfd_vma val, addend;
- unsigned int index;
- unsigned int type;
- struct nlm32_sparc_reloc_ext tmp_reloc;
- asection *code_sec, *data_sec;
-
- if (bfd_read (&tmp_reloc, 12, 1, abfd) != 12)
- return false;
-
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
-
- *secp = code_sec;
-
- val = bfd_get_32 (abfd, tmp_reloc.offset);
- addend = bfd_get_32 (abfd, tmp_reloc.addend);
- type = bfd_get_8 (abfd, tmp_reloc.type);
-
- rel->address = val;
- rel->addend = addend;
- rel->howto = NULL;
-
- for (index = 0;
- index < sizeof(nlm32_sparc_howto_table) / sizeof(reloc_howto_type);
- index++)
- if (nlm32_sparc_howto_table[index].type == type) {
- rel->howto = &nlm32_sparc_howto_table[index];
- break;
- }
-
-#ifdef DEBUG
- fprintf (stderr, "%s: address = %08lx, addend = %08lx, type = %d, howto = %08lx\n",
- __FUNCTION__, rel->address, rel->addend, type, rel->howto);
-#endif
- return true;
-
-}
-
-/* Write a NetWare sparc reloc. */
-
-static boolean
-nlm_sparc_write_reloc (abfd, sec, rel)
- bfd *abfd;
- asection *sec;
- arelent *rel;
-{
- bfd_vma val;
- struct nlm32_sparc_reloc_ext tmp_reloc;
- unsigned int index;
- int type = -1;
- reloc_howto_type *tmp;
-
-
- for (index = 0;
- index < sizeof (nlm32_sparc_howto_table) / sizeof(reloc_howto_type);
- index++) {
- tmp = &nlm32_sparc_howto_table[index];
-
- if (tmp->rightshift == rel->howto->rightshift
- && tmp->size == rel->howto->size
- && tmp->bitsize == rel->howto->bitsize
- && tmp->pc_relative == rel->howto->pc_relative
- && tmp->bitpos == rel->howto->bitpos
- && tmp->src_mask == rel->howto->src_mask
- && tmp->dst_mask == rel->howto->dst_mask) {
- type = tmp->type;
- break;
- }
- }
- if (type == -1)
- abort();
-
- /*
- * Netware wants a list of relocs for each address.
- * Format is:
- * long offset
- * long addend
- * char type
- * That should be it.
- */
-
- /* The value we write out is the offset into the appropriate
- segment. This offset is the section vma, adjusted by the vma of
- the lowest section in that segment, plus the address of the
- relocation. */
-#if 0
- val = bfd_get_section_vma (abfd, (*rel->sym_ptr_ptr)->section) + rel->address;
-#else
- val = bfd_get_section_vma (abfd, sec) + rel->address;
-#endif
-
-#ifdef DEBUG
- fprintf (stderr, "%s: val = %08lx, addend = %08lx, type = %d\n",
- __FUNCTION__, val, rel->addend, rel->howto->type);
-#endif
- bfd_put_32 (abfd, val, tmp_reloc.offset);
- bfd_put_32 (abfd, rel->addend, tmp_reloc.addend);
- bfd_put_8 (abfd, (short)(rel->howto->type), tmp_reloc.type);
-
- if (bfd_write (&tmp_reloc, 12, 1, abfd) != 12)
- return false;
-
- return true;
-}
-
-/* Mangle relocs for SPARC NetWare. We can just use the standard
- SPARC relocs. */
-
-static boolean
-nlm_sparc_mangle_relocs (abfd, sec, data, offset, count)
- bfd *abfd;
- asection *sec;
- PTR data;
- bfd_vma offset;
- bfd_size_type count;
-{
- return true;
-}
-
-/* Read a NetWare sparc import record */
-static boolean
-nlm_sparc_read_import (abfd, sym)
- bfd *abfd;
- nlmNAME(symbol_type) *sym;
-{
- struct nlm_relent *nlm_relocs; /* relocation records for symbol */
- bfd_size_type rcount; /* number of relocs */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
- unsigned char symlength; /* length of symbol name */
- char *name;
-
- /*
- * First, read in the number of relocation
- * entries for this symbol
- */
- if (bfd_read ((PTR) temp, 4, 1, abfd) != 4)
- return false;
-
- rcount = bfd_get_32 (abfd, temp);
-
- /*
- * Next, read in the length of the symbol
- */
-
- if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
- != sizeof (symlength))
- return false;
- sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, symlength + 1);
- if (name == NULL)
- return false;
-
- /*
- * Then read in the symbol
- */
-
- if (bfd_read (name, symlength, 1, abfd) != symlength)
- return false;
- name[symlength] = '\0';
- sym -> symbol.name = name;
- sym -> symbol.flags = 0;
- sym -> symbol.value = 0;
- sym -> symbol.section = bfd_und_section_ptr;
-
- /*
- * Next, start reading in the relocs.
- */
-
- nlm_relocs = ((struct nlm_relent *)
- bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
- if (!nlm_relocs)
- return false;
- sym -> relocs = nlm_relocs;
- sym -> rcnt = 0;
- while (sym -> rcnt < rcount)
- {
- asection *section;
-
- if (nlm_sparc_read_reloc (abfd, sym, &section,
- &nlm_relocs -> reloc)
- == false)
- return false;
- nlm_relocs -> section = section;
- nlm_relocs++;
- sym -> rcnt++;
- }
- return true;
-}
-
-static boolean
-nlm_sparc_write_import (abfd, sec, rel)
- bfd *abfd;
- asection *sec;
- arelent *rel;
-{
- char temp[4];
- asection *code, *data, *bss, *symsec;
- bfd_vma base;
-
- code = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- bss = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
- symsec = (*rel->sym_ptr_ptr)->section;
-
- if (symsec == code) {
- base = 0;
- } else if (symsec == data) {
- base = bfd_section_size (abfd, code);
- } else if (symsec == bss) {
- base = bfd_section_size (abfd, code) + bfd_section_size (abfd, data);
- } else
- base = 0;
-
-#ifdef DEBUG
- fprintf (stderr, "%s: <%x, 1>\n\t",
- __FUNCTION__, base + (*rel->sym_ptr_ptr)->value);
-#endif
- bfd_put_32 (abfd, base + (*rel->sym_ptr_ptr)->value, temp);
- if (bfd_write ((PTR)temp, 4, 1, abfd) != 4)
- return false;
- bfd_put_32 (abfd, 1, temp);
- if (bfd_write ((PTR)temp, 4, 1, abfd) != 4)
- return false;
- if (nlm_sparc_write_reloc (abfd, sec, rel) == false)
- return false;
- return true;
-}
-
-/* Write out an external reference. */
-
-static boolean
-nlm_sparc_write_external (abfd, count, sym, relocs)
- bfd *abfd;
- bfd_size_type count;
- asymbol *sym;
- struct reloc_and_sec *relocs;
-{
- unsigned int i;
- bfd_byte len;
- unsigned char temp[NLM_TARGET_LONG_SIZE];
-
- bfd_put_32 (abfd, count, temp);
- if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
- return false;
-
- len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
- return false;
-
- for (i = 0; i < count; i++)
- {
- if (nlm_sparc_write_reloc (abfd, relocs[i].sec,
- relocs[i].rel) == false)
- return false;
- }
-
- return true;
-}
-
-static boolean
-nlm_sparc_write_export (abfd, sym, value)
- bfd *abfd;
- asymbol *sym;
- bfd_vma value;
-{
- bfd_byte len;
- bfd_byte temp[4];
-
-#ifdef DEBUG
- fprintf (stderr, "%s: <%x, %d, %s>\n",
- __FUNCTION__, value, strlen (sym->name), sym->name);
-#endif
- bfd_put_32 (abfd, value, temp);
- len = strlen (sym->name);
-
- if (bfd_write (temp, 4, 1, abfd) != 4
- || bfd_write (&len, 1, 1, abfd) != 1
- || bfd_write (sym->name, len, 1, abfd) != len)
- return false;
-
- return true;
-}
-
-#undef nlm_swap_fixed_header_in
-#undef nlm_swap_fixed_header_out
-
-#include "nlmswap.h"
-
-static const struct nlm_backend_data nlm32_sparc_backend =
-{
- "NetWare SPARC Module \032",
- sizeof (Nlm32_sparc_External_Fixed_Header),
- 0, /* optional_prefix_size */
- bfd_arch_sparc,
- 0,
- false,
- 0, /* backend_object_p */
- 0, /* write_prefix_func */
- nlm_sparc_read_reloc,
- nlm_sparc_mangle_relocs,
- nlm_sparc_read_import,
- nlm_sparc_write_import,
- 0, /* set_public_section */
- 0, /* get_public_offset */
- nlm_swap_fixed_header_in,
- nlm_swap_fixed_header_out,
- nlm_sparc_write_external,
- nlm_sparc_write_export
-};
-
-#define TARGET_BIG_NAME "nlm32-sparc"
-#define TARGET_BIG_SYM nlmNAME(sparc_vec)
-#define TARGET_BACKEND_DATA &nlm32_sparc_backend
-
-#include "nlm-target.h"
diff --git a/contrib/gdb/bfd/nlm32.c b/contrib/gdb/bfd/nlm32.c
deleted file mode 100644
index 4730e4f..0000000
--- a/contrib/gdb/bfd/nlm32.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* NLM (NetWare Loadable Module) 32-bit executable support for BFD.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define ARCH_SIZE 32
-#include "nlmcode.h"
diff --git a/contrib/gdb/bfd/nlm64.c b/contrib/gdb/bfd/nlm64.c
deleted file mode 100644
index 5dcd96a..0000000
--- a/contrib/gdb/bfd/nlm64.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* NLM (NetWare Loadable Module) 64-bit executable support for BFD.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define ARCH_SIZE 64
-#include "nlmcode.h"
diff --git a/contrib/gdb/bfd/nlmcode.h b/contrib/gdb/bfd/nlmcode.h
deleted file mode 100644
index 7f828b4..0000000
--- a/contrib/gdb/bfd/nlmcode.h
+++ /dev/null
@@ -1,2057 +0,0 @@
-/* NLM (NetWare Loadable Module) executable support for BFD.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
- Written by Fred Fish @ Cygnus Support, using ELF support as the
- template.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <string.h> /* For strrchr and friends */
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libnlm.h"
-
-/* The functions in this file do not use the names they appear to use.
- This file is actually compiled multiple times, once for each size
- of NLM target we are using. At each size we use a different name,
- constructed by the macro nlmNAME. For example, the function which
- is named nlm_symbol_type below is actually named nlm32_symbol_type
- in the final executable. */
-
-#define Nlm_External_Fixed_Header NlmNAME(External_Fixed_Header)
-#define Nlm_External_Version_Header NlmNAME(External_Version_Header)
-#define Nlm_External_Copyright_Header NlmNAME(External_Copyright_Header)
-#define Nlm_External_Extended_Header NlmNAME(External_Extended_Header)
-#define Nlm_External_Custom_Header NlmNAME(External_Custom_Header)
-#define Nlm_External_Cygnus_Ext_Header NlmNAME(External_Cygnus_Ext_Header)
-
-#define nlm_symbol_type nlmNAME(symbol_type)
-#define nlm_get_symtab_upper_bound nlmNAME(get_symtab_upper_bound)
-#define nlm_get_symtab nlmNAME(get_symtab)
-#define nlm_make_empty_symbol nlmNAME(make_empty_symbol)
-#define nlm_print_symbol nlmNAME(print_symbol)
-#define nlm_get_symbol_info nlmNAME(get_symbol_info)
-#define nlm_get_reloc_upper_bound nlmNAME(get_reloc_upper_bound)
-#define nlm_canonicalize_reloc nlmNAME(canonicalize_reloc)
-#define nlm_object_p nlmNAME(object_p)
-#define nlm_set_section_contents nlmNAME(set_section_contents)
-#define nlm_write_object_contents nlmNAME(write_object_contents)
-
-#define nlm_swap_fixed_header_in(abfd,src,dst) \
- (nlm_swap_fixed_header_in_func(abfd))(abfd,src,dst)
-#define nlm_swap_fixed_header_out(abfd,src,dst) \
- (nlm_swap_fixed_header_out_func(abfd))(abfd,src,dst)
-
-/* Forward declarations of static functions */
-
-static boolean add_bfd_section
- PARAMS ((bfd *, char *, file_ptr, bfd_size_type, flagword));
-static boolean nlm_swap_variable_header_in
- PARAMS ((bfd *));
-static boolean nlm_swap_variable_header_out
- PARAMS ((bfd *));
-static boolean find_nonzero
- PARAMS ((PTR, size_t));
-static boolean nlm_swap_auxiliary_headers_in
- PARAMS ((bfd *));
-static boolean nlm_swap_auxiliary_headers_out
- PARAMS ((bfd *));
-static boolean nlm_slurp_symbol_table
- PARAMS ((bfd *));
-static boolean nlm_slurp_reloc_fixups
- PARAMS ((bfd *));
-static boolean nlm_compute_section_file_positions
- PARAMS ((bfd *));
-static int nlm_external_reloc_compare
- PARAMS ((const void *, const void *));
-
-/* Should perhaps use put_offset, put_word, etc. For now, the two versions
- can be handled by explicitly specifying 32 bits or "the long type". */
-#if ARCH_SIZE == 64
-#define put_word bfd_h_put_64
-#define get_word bfd_h_get_64
-#endif
-#if ARCH_SIZE == 32
-#define put_word bfd_h_put_32
-#define get_word bfd_h_get_32
-#endif
-
-const bfd_target *
-nlm_object_p (abfd)
- bfd *abfd;
-{
- struct nlm_obj_tdata *preserved_tdata = nlm_tdata (abfd);
- boolean (*backend_object_p) PARAMS ((bfd *));
- PTR x_fxdhdr = NULL;
- Nlm_Internal_Fixed_Header *i_fxdhdrp;
- struct nlm_obj_tdata *new_tdata = NULL;
- const char *signature;
- enum bfd_architecture arch;
-
- /* Some NLM formats have a prefix before the standard NLM fixed
- header. */
- backend_object_p = nlm_backend_object_p_func (abfd);
- if (backend_object_p)
- {
- if (!(*backend_object_p) (abfd))
- goto got_wrong_format_error;
- }
-
- /* Read in the fixed length portion of the NLM header in external format. */
-
- x_fxdhdr = (PTR) bfd_malloc ((size_t) nlm_fixed_header_size (abfd));
- if (x_fxdhdr == NULL)
- goto got_no_match;
-
- if (bfd_read ((PTR) x_fxdhdr, nlm_fixed_header_size (abfd), 1, abfd) !=
- nlm_fixed_header_size (abfd))
- {
- if (bfd_get_error () != bfd_error_system_call)
- goto got_wrong_format_error;
- else
- goto got_no_match;
- }
-
- /* Allocate an instance of the nlm_obj_tdata structure and hook it up to
- the tdata pointer in the bfd. */
-
- new_tdata = ((struct nlm_obj_tdata *)
- bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata)));
- if (new_tdata == NULL)
- goto got_no_match;
-
- nlm_tdata (abfd) = new_tdata;
-
- i_fxdhdrp = nlm_fixed_header (abfd);
- nlm_swap_fixed_header_in (abfd, x_fxdhdr, i_fxdhdrp);
- free (x_fxdhdr);
- x_fxdhdr = NULL;
-
- /* Check to see if we have an NLM file for this backend by matching
- the NLM signature. */
-
- signature = nlm_signature (abfd);
- if (signature != NULL
- && *signature != '\0'
- && strncmp ((char *) i_fxdhdrp->signature, signature,
- NLM_SIGNATURE_SIZE) != 0)
- goto got_wrong_format_error;
-
- /* There's no supported way to discover the endianess of an NLM, so test for
- a sane version number after doing byte swapping appropriate for this
- XVEC. (Hack alert!) */
-
- if (i_fxdhdrp->version > 0xFFFF)
- goto got_wrong_format_error;
-
- /* There's no supported way to check for 32 bit versus 64 bit addresses,
- so ignore this distinction for now. (FIXME) */
-
- /* Swap in the rest of the required header. */
- if (!nlm_swap_variable_header_in (abfd))
- {
- if (bfd_get_error () != bfd_error_system_call)
- goto got_wrong_format_error;
- else
- goto got_no_match;
- }
-
- /* Add the sections supplied by all NLM's, and then read in the
- auxiliary headers. Reading the auxiliary headers may create
- additional sections described in the cygnus_ext header.
- From this point on we assume that we have an NLM, and do not
- treat errors as indicating the wrong format. */
-
- if (!add_bfd_section (abfd, NLM_CODE_NAME,
- i_fxdhdrp->codeImageOffset,
- i_fxdhdrp->codeImageSize,
- (SEC_CODE | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_RELOC))
- || !add_bfd_section (abfd, NLM_INITIALIZED_DATA_NAME,
- i_fxdhdrp->dataImageOffset,
- i_fxdhdrp->dataImageSize,
- (SEC_DATA | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_RELOC))
- || !add_bfd_section (abfd, NLM_UNINITIALIZED_DATA_NAME,
- (file_ptr) 0,
- i_fxdhdrp->uninitializedDataSize,
- SEC_ALLOC))
- goto got_no_match;
-
- if (!nlm_swap_auxiliary_headers_in (abfd))
- goto got_no_match;
-
- if (nlm_fixed_header (abfd)->numberOfRelocationFixups != 0
- || nlm_fixed_header (abfd)->numberOfExternalReferences != 0)
- abfd->flags |= HAS_RELOC;
- if (nlm_fixed_header (abfd)->numberOfPublics != 0
- || nlm_fixed_header (abfd)->numberOfDebugRecords != 0
- || nlm_fixed_header (abfd)->numberOfExternalReferences != 0)
- abfd->flags |= HAS_SYMS;
-
- arch = nlm_architecture (abfd);
- if (arch != bfd_arch_unknown)
- bfd_default_set_arch_mach (abfd, arch, (unsigned long) 0);
-
- abfd->flags |= EXEC_P;
- bfd_get_start_address (abfd) = nlm_fixed_header (abfd)->codeStartOffset;
-
- return (abfd->xvec);
-
-got_wrong_format_error:
- bfd_set_error (bfd_error_wrong_format);
-got_no_match:
- nlm_tdata (abfd) = preserved_tdata;
- if (new_tdata != NULL)
- bfd_release (abfd, new_tdata);
- if (x_fxdhdr != NULL)
- free (x_fxdhdr);
- return (NULL);
-}
-
-/* Add a section to the bfd. */
-
-static boolean
-add_bfd_section (abfd, name, offset, size, flags)
- bfd *abfd;
- char *name;
- file_ptr offset;
- bfd_size_type size;
- flagword flags;
-{
- asection *newsect;
-
- newsect = bfd_make_section (abfd, name);
- if (newsect == NULL)
- {
- return (false);
- }
- newsect->vma = 0; /* NLM's are relocatable. */
- newsect->_raw_size = size;
- newsect->filepos = offset;
- newsect->flags = flags;
- newsect->alignment_power = bfd_log2 (0); /* FIXME */
- return (true);
-}
-
-/* Read and swap in the variable length header. All the fields must
- exist in the NLM, and must exist in the order they are read here. */
-
-static boolean
-nlm_swap_variable_header_in (abfd)
- bfd *abfd;
-{
- unsigned char temp[NLM_TARGET_LONG_SIZE];
-
- /* Read the description length and text members. */
-
- if (bfd_read ((PTR) & nlm_variable_header (abfd)->descriptionLength,
- sizeof (nlm_variable_header (abfd)->descriptionLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->descriptionLength))
- return (false);
- if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText,
- nlm_variable_header (abfd)->descriptionLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
- return (false);
-
- /* Read and convert the stackSize field. */
-
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
- nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp);
-
- /* Read and convert the reserved field. */
-
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
- nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp);
-
- /* Read the oldThreadName field. This field is a fixed length string. */
-
- if (bfd_read ((PTR) nlm_variable_header (abfd)->oldThreadName,
- sizeof (nlm_variable_header (abfd)->oldThreadName),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->oldThreadName))
- return (false);
-
- /* Read the screen name length and text members. */
-
- if (bfd_read ((PTR) & nlm_variable_header (abfd)->screenNameLength,
- sizeof (nlm_variable_header (abfd)->screenNameLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->screenNameLength))
- return (false);
- if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName,
- nlm_variable_header (abfd)->screenNameLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
- return (false);
-
- /* Read the thread name length and text members. */
-
- if (bfd_read ((PTR) & nlm_variable_header (abfd)->threadNameLength,
- sizeof (nlm_variable_header (abfd)->threadNameLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->threadNameLength))
- return (false);
- if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName,
- nlm_variable_header (abfd)->threadNameLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
- return (false);
- return (true);
-}
-
-/* Swap and write out the variable length header. All the fields must
- exist in the NLM, and must exist in this order. */
-
-static boolean
-nlm_swap_variable_header_out (abfd)
- bfd *abfd;
-{
- unsigned char temp[NLM_TARGET_LONG_SIZE];
-
- /* Write the description length and text members. */
-
- if (bfd_write ((PTR) & nlm_variable_header (abfd)->descriptionLength,
- sizeof (nlm_variable_header (abfd)->descriptionLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->descriptionLength))
- return (false);
- if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText,
- nlm_variable_header (abfd)->descriptionLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
- return (false);
-
- /* Convert and write the stackSize field. */
-
- put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize,
- (bfd_byte *) temp);
- if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
-
- /* Convert and write the reserved field. */
-
- put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved,
- (bfd_byte *) temp);
- if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
-
- /* Write the oldThreadName field. This field is a fixed length string. */
-
- if (bfd_write ((PTR) nlm_variable_header (abfd)->oldThreadName,
- sizeof (nlm_variable_header (abfd)->oldThreadName),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->oldThreadName))
- return (false);
-
- /* Write the screen name length and text members. */
-
- if (bfd_write ((PTR) & nlm_variable_header (abfd)->screenNameLength,
- sizeof (nlm_variable_header (abfd)->screenNameLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->screenNameLength))
- return (false);
- if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName,
- nlm_variable_header (abfd)->screenNameLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
- return (false);
-
- /* Write the thread name length and text members. */
-
- if (bfd_write ((PTR) & nlm_variable_header (abfd)->threadNameLength,
- sizeof (nlm_variable_header (abfd)->threadNameLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->threadNameLength))
- return (false);
- if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName,
- nlm_variable_header (abfd)->threadNameLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
- return (false);
- return (true);
-}
-
-/* Read and swap in the contents of all the auxiliary headers. Because of
- the braindead design, we have to do strcmps on strings of indeterminate
- length to figure out what each auxiliary header is. Even worse, we have
- no way of knowing how many auxiliary headers there are or where the end
- of the auxiliary headers are, except by finding something that doesn't
- look like a known auxiliary header. This means that the first new type
- of auxiliary header added will break all existing tools that don't
- recognize it. */
-
-static boolean
-nlm_swap_auxiliary_headers_in (abfd)
- bfd *abfd;
-{
- char tempstr[16];
- long position;
-
- for (;;)
- {
- position = bfd_tell (abfd);
- if (bfd_read ((PTR) tempstr, sizeof (tempstr), 1, abfd) !=
- sizeof (tempstr))
- return (false);
- if (bfd_seek (abfd, position, SEEK_SET) == -1)
- return (false);
- if (strncmp (tempstr, "VeRsIoN#", 8) == 0)
- {
- Nlm_External_Version_Header thdr;
- if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- return (false);
- memcpy (nlm_version_header (abfd)->stamp, thdr.stamp,
- sizeof (thdr.stamp));
- nlm_version_header (abfd)->majorVersion =
- get_word (abfd, (bfd_byte *) thdr.majorVersion);
- nlm_version_header (abfd)->minorVersion =
- get_word (abfd, (bfd_byte *) thdr.minorVersion);
- nlm_version_header (abfd)->revision =
- get_word (abfd, (bfd_byte *) thdr.revision);
- nlm_version_header (abfd)->year =
- get_word (abfd, (bfd_byte *) thdr.year);
- nlm_version_header (abfd)->month =
- get_word (abfd, (bfd_byte *) thdr.month);
- nlm_version_header (abfd)->day =
- get_word (abfd, (bfd_byte *) thdr.day);
- }
- else if (strncmp (tempstr, "MeSsAgEs", 8) == 0)
- {
- Nlm_External_Extended_Header thdr;
- if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- return (false);
- memcpy (nlm_extended_header (abfd)->stamp, thdr.stamp,
- sizeof (thdr.stamp));
- nlm_extended_header (abfd)->languageID =
- get_word (abfd, (bfd_byte *) thdr.languageID);
- nlm_extended_header (abfd)->messageFileOffset =
- get_word (abfd, (bfd_byte *) thdr.messageFileOffset);
- nlm_extended_header (abfd)->messageFileLength =
- get_word (abfd, (bfd_byte *) thdr.messageFileLength);
- nlm_extended_header (abfd)->messageCount =
- get_word (abfd, (bfd_byte *) thdr.messageCount);
- nlm_extended_header (abfd)->helpFileOffset =
- get_word (abfd, (bfd_byte *) thdr.helpFileOffset);
- nlm_extended_header (abfd)->helpFileLength =
- get_word (abfd, (bfd_byte *) thdr.helpFileLength);
- nlm_extended_header (abfd)->RPCDataOffset =
- get_word (abfd, (bfd_byte *) thdr.RPCDataOffset);
- nlm_extended_header (abfd)->RPCDataLength =
- get_word (abfd, (bfd_byte *) thdr.RPCDataLength);
- nlm_extended_header (abfd)->sharedCodeOffset =
- get_word (abfd, (bfd_byte *) thdr.sharedCodeOffset);
- nlm_extended_header (abfd)->sharedCodeLength =
- get_word (abfd, (bfd_byte *) thdr.sharedCodeLength);
- nlm_extended_header (abfd)->sharedDataOffset =
- get_word (abfd, (bfd_byte *) thdr.sharedDataOffset);
- nlm_extended_header (abfd)->sharedDataLength =
- get_word (abfd, (bfd_byte *) thdr.sharedDataLength);
- nlm_extended_header (abfd)->sharedRelocationFixupOffset =
- get_word (abfd, (bfd_byte *) thdr.sharedRelocationFixupOffset);
- nlm_extended_header (abfd)->sharedRelocationFixupCount =
- get_word (abfd, (bfd_byte *) thdr.sharedRelocationFixupCount);
- nlm_extended_header (abfd)->sharedExternalReferenceOffset =
- get_word (abfd, (bfd_byte *) thdr.sharedExternalReferenceOffset);
- nlm_extended_header (abfd)->sharedExternalReferenceCount =
- get_word (abfd, (bfd_byte *) thdr.sharedExternalReferenceCount);
- nlm_extended_header (abfd)->sharedPublicsOffset =
- get_word (abfd, (bfd_byte *) thdr.sharedPublicsOffset);
- nlm_extended_header (abfd)->sharedPublicsCount =
- get_word (abfd, (bfd_byte *) thdr.sharedPublicsCount);
- nlm_extended_header (abfd)->sharedDebugRecordOffset =
- get_word (abfd, (bfd_byte *) thdr.sharedDebugRecordOffset);
- nlm_extended_header (abfd)->sharedDebugRecordCount =
- get_word (abfd, (bfd_byte *) thdr.sharedDebugRecordCount);
- nlm_extended_header (abfd)->SharedInitializationOffset =
- get_word (abfd, (bfd_byte *) thdr.sharedInitializationOffset);
- nlm_extended_header (abfd)->SharedExitProcedureOffset =
- get_word (abfd, (bfd_byte *) thdr.SharedExitProcedureOffset);
- nlm_extended_header (abfd)->productID =
- get_word (abfd, (bfd_byte *) thdr.productID);
- nlm_extended_header (abfd)->reserved0 =
- get_word (abfd, (bfd_byte *) thdr.reserved0);
- nlm_extended_header (abfd)->reserved1 =
- get_word (abfd, (bfd_byte *) thdr.reserved1);
- nlm_extended_header (abfd)->reserved2 =
- get_word (abfd, (bfd_byte *) thdr.reserved2);
- nlm_extended_header (abfd)->reserved3 =
- get_word (abfd, (bfd_byte *) thdr.reserved3);
- nlm_extended_header (abfd)->reserved4 =
- get_word (abfd, (bfd_byte *) thdr.reserved4);
- nlm_extended_header (abfd)->reserved5 =
- get_word (abfd, (bfd_byte *) thdr.reserved5);
- }
- else if (strncmp (tempstr, "CoPyRiGhT=", 10) == 0)
- {
- if (bfd_read ((PTR) nlm_copyright_header (abfd)->stamp,
- sizeof (nlm_copyright_header (abfd)->stamp),
- 1, abfd)
- != sizeof (nlm_copyright_header (abfd)->stamp))
- return (false);
- if (bfd_read ((PTR) & (nlm_copyright_header (abfd)
- ->copyrightMessageLength),
- 1, 1, abfd) != 1)
- return (false);
- /* The copyright message is a variable length string. */
- if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
- nlm_copyright_header (abfd)->copyrightMessageLength + 1,
- 1, abfd) !=
- ((bfd_size_type)
- nlm_copyright_header (abfd)->copyrightMessageLength + 1))
- return (false);
- }
- else if (strncmp (tempstr, "CuStHeAd", 8) == 0)
- {
- Nlm_External_Custom_Header thdr;
- bfd_size_type hdrLength;
- file_ptr dataOffset;
- bfd_size_type dataLength;
- char dataStamp[8];
- PTR hdr;
-
- /* Read the stamp ("CuStHeAd"). */
- if (bfd_read ((PTR) thdr.stamp, 1, sizeof (thdr.stamp), abfd)
- != sizeof (thdr.stamp))
- return false;
- /* Read the length of this custom header. */
- if (bfd_read ((PTR) thdr.length, 1, sizeof (thdr.length), abfd)
- != sizeof (thdr.length))
- return false;
- hdrLength = get_word (abfd, (bfd_byte *) thdr.length);
- /* Read further fields if we have them. */
- if (hdrLength < NLM_TARGET_LONG_SIZE)
- dataOffset = 0;
- else
- {
- if (bfd_read ((PTR) thdr.dataOffset, 1,
- sizeof (thdr.dataOffset), abfd)
- != sizeof (thdr.dataOffset))
- return false;
- dataOffset = get_word (abfd, (bfd_byte *) thdr.dataOffset);
- }
- if (hdrLength < 2 * NLM_TARGET_LONG_SIZE)
- dataLength = 0;
- else
- {
- if (bfd_read ((PTR) thdr.dataLength, 1,
- sizeof (thdr.dataLength), abfd)
- != sizeof (thdr.dataLength))
- return false;
- dataLength = get_word (abfd, (bfd_byte *) thdr.dataLength);
- }
- if (hdrLength < 2 * NLM_TARGET_LONG_SIZE + 8)
- memset (dataStamp, 0, sizeof (dataStamp));
- else
- {
- if (bfd_read ((PTR) dataStamp, 1, sizeof (dataStamp), abfd)
- != sizeof (dataStamp))
- return false;
- }
-
- /* Read the rest of the header, if any. */
- if (hdrLength <= 2 * NLM_TARGET_LONG_SIZE + 8)
- {
- hdr = NULL;
- hdrLength = 0;
- }
- else
- {
- hdrLength -= 2 * NLM_TARGET_LONG_SIZE + 8;
- hdr = bfd_alloc (abfd, hdrLength);
- if (hdr == NULL)
- return false;
- if (bfd_read (hdr, 1, hdrLength, abfd) != hdrLength)
- return false;
- }
-
- /* If we have found a Cygnus header, process it. Otherwise,
- just save the associated data without trying to interpret
- it. */
- if (strncmp (dataStamp, "CyGnUsEx", 8) == 0)
- {
- file_ptr pos;
- bfd_byte *contents;
- bfd_byte *p, *pend;
-
- BFD_ASSERT (hdrLength == 0 && hdr == NULL);
-
- pos = bfd_tell (abfd);
- if (bfd_seek (abfd, dataOffset, SEEK_SET) != 0)
- return false;
- contents = (bfd_byte *) bfd_alloc (abfd, dataLength);
- if (contents == NULL)
- return false;
- if (bfd_read (contents, 1, dataLength, abfd) != dataLength)
- return false;
- if (bfd_seek (abfd, pos, SEEK_SET) != 0)
- return false;
-
- memcpy (nlm_cygnus_ext_header (abfd), "CyGnUsEx", 8);
- nlm_cygnus_ext_header (abfd)->offset = dataOffset;
- nlm_cygnus_ext_header (abfd)->length = dataLength;
-
- /* This data this header points to provides a list of
- the sections which were in the original object file
- which was converted to become an NLM. We locate
- those sections and add them to the BFD. Note that
- this is likely to create a second .text, .data and
- .bss section; retrieving the sections by name will
- get the actual NLM sections, which is what we want to
- happen. The sections from the original file, which
- may be subsets of the NLM section, can only be found
- using bfd_map_over_sections. */
- p = contents;
- pend = p + dataLength;
- while (p < pend)
- {
- char *name;
- size_t l;
- file_ptr filepos;
- bfd_size_type size;
- asection *newsec;
-
- /* The format of this information is
- null terminated section name
- zeroes to adjust to 4 byte boundary
- 4 byte section data file pointer
- 4 byte section size
- */
-
- name = (char *) p;
- l = strlen (name) + 1;
- l = (l + 3) &~ 3;
- p += l;
- filepos = bfd_h_get_32 (abfd, p);
- p += 4;
- size = bfd_h_get_32 (abfd, p);
- p += 4;
-
- newsec = bfd_make_section_anyway (abfd, name);
- if (newsec == (asection *) NULL)
- return false;
- newsec->_raw_size = size;
- if (filepos != 0)
- {
- newsec->filepos = filepos;
- newsec->flags |= SEC_HAS_CONTENTS;
- }
- }
- }
- else
- {
- memcpy (nlm_custom_header (abfd)->stamp, thdr.stamp,
- sizeof (thdr.stamp));
- nlm_custom_header (abfd)->hdrLength = hdrLength;
- nlm_custom_header (abfd)->dataOffset = dataOffset;
- nlm_custom_header (abfd)->dataLength = dataLength;
- memcpy (nlm_custom_header (abfd)->dataStamp, dataStamp,
- sizeof (dataStamp));
- nlm_custom_header (abfd)->hdr = hdr;
- }
- }
- else
- {
- break;
- }
- }
- return (true);
-}
-
-/* Return whether there is a non-zero byte in a memory block. */
-
-static boolean
-find_nonzero (buf, size)
- PTR buf;
- size_t size;
-{
- char *p = (char *) buf;
-
- while (size-- != 0)
- if (*p++ != 0)
- return true;
- return false;
-}
-
-/* Swap out the contents of the auxiliary headers. We create those
- auxiliary headers which have been set non-zero. We do not require
- the caller to set up the stamp fields. */
-
-static boolean
-nlm_swap_auxiliary_headers_out (abfd)
- bfd *abfd;
-{
- /* Write out the version header if there is one. */
- if (find_nonzero ((PTR) nlm_version_header (abfd),
- sizeof (Nlm_Internal_Version_Header)))
- {
- Nlm_External_Version_Header thdr;
-
- memcpy (thdr.stamp, "VeRsIoN#", 8);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->majorVersion,
- (bfd_byte *) thdr.majorVersion);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->minorVersion,
- (bfd_byte *) thdr.minorVersion);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->revision,
- (bfd_byte *) thdr.revision);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->year,
- (bfd_byte *) thdr.year);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->month,
- (bfd_byte *) thdr.month);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->day,
- (bfd_byte *) thdr.day);
- if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- return false;
- }
-
- /* Write out the extended header if there is one. */
- if (find_nonzero ((PTR) nlm_extended_header (abfd),
- sizeof (Nlm_Internal_Extended_Header)))
- {
- Nlm_External_Extended_Header thdr;
-
- memcpy (thdr.stamp, "MeSsAgEs", 8);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->languageID,
- (bfd_byte *) thdr.languageID);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->messageFileOffset,
- (bfd_byte *) thdr.messageFileOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->messageFileLength,
- (bfd_byte *) thdr.messageFileLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->messageCount,
- (bfd_byte *) thdr.messageCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->helpFileOffset,
- (bfd_byte *) thdr.helpFileOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->helpFileLength,
- (bfd_byte *) thdr.helpFileLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->RPCDataOffset,
- (bfd_byte *) thdr.RPCDataOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->RPCDataLength,
- (bfd_byte *) thdr.RPCDataLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedCodeOffset,
- (bfd_byte *) thdr.sharedCodeOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedCodeLength,
- (bfd_byte *) thdr.sharedCodeLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedDataOffset,
- (bfd_byte *) thdr.sharedDataOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedDataLength,
- (bfd_byte *) thdr.sharedDataLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedRelocationFixupOffset,
- (bfd_byte *) thdr.sharedRelocationFixupOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedRelocationFixupCount,
- (bfd_byte *) thdr.sharedRelocationFixupCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedExternalReferenceOffset,
- (bfd_byte *) thdr.sharedExternalReferenceOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedExternalReferenceCount,
- (bfd_byte *) thdr.sharedExternalReferenceCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedPublicsOffset,
- (bfd_byte *) thdr.sharedPublicsOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedPublicsCount,
- (bfd_byte *) thdr.sharedPublicsCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedDebugRecordOffset,
- (bfd_byte *) thdr.sharedDebugRecordOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedDebugRecordCount,
- (bfd_byte *) thdr.sharedDebugRecordCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->SharedInitializationOffset,
- (bfd_byte *) thdr.sharedInitializationOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->SharedExitProcedureOffset,
- (bfd_byte *) thdr.SharedExitProcedureOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->productID,
- (bfd_byte *) thdr.productID);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved0,
- (bfd_byte *) thdr.reserved0);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved1,
- (bfd_byte *) thdr.reserved1);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved2,
- (bfd_byte *) thdr.reserved2);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved3,
- (bfd_byte *) thdr.reserved3);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved4,
- (bfd_byte *) thdr.reserved4);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved5,
- (bfd_byte *) thdr.reserved5);
- if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- return false;
- }
-
-
- /* Write out the copyright header if there is one. */
- if (find_nonzero ((PTR) nlm_copyright_header (abfd),
- sizeof (Nlm_Internal_Copyright_Header)))
- {
- Nlm_External_Copyright_Header thdr;
-
- memcpy (thdr.stamp, "CoPyRiGhT=", 10);
- if (bfd_write ((PTR) thdr.stamp, sizeof (thdr.stamp), 1, abfd)
- != sizeof (thdr.stamp))
- return false;
- thdr.copyrightMessageLength[0] =
- nlm_copyright_header (abfd)->copyrightMessageLength;
- if (bfd_write ((PTR) thdr.copyrightMessageLength, 1, 1, abfd) != 1)
- return false;
- /* The copyright message is a variable length string. */
- if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
- nlm_copyright_header (abfd)->copyrightMessageLength + 1,
- 1, abfd) !=
- ((bfd_size_type)
- nlm_copyright_header (abfd)->copyrightMessageLength + 1))
- return false;
- }
-
- /* Write out the custom header if there is one. */
- if (find_nonzero ((PTR) nlm_custom_header (abfd),
- sizeof (Nlm_Internal_Custom_Header)))
- {
- Nlm_External_Custom_Header thdr;
- boolean ds;
- bfd_size_type hdrLength;
-
- ds = find_nonzero ((PTR) nlm_custom_header (abfd)->dataStamp,
- sizeof (nlm_custom_header (abfd)->dataStamp));
- memcpy (thdr.stamp, "CuStHeAd", 8);
- hdrLength = (2 * NLM_TARGET_LONG_SIZE + (ds ? 8 : 0)
- + nlm_custom_header (abfd)->hdrLength);
- put_word (abfd, hdrLength, thdr.length);
- put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->dataOffset,
- thdr.dataOffset);
- put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->dataLength,
- thdr.dataLength);
- if (! ds)
- {
- BFD_ASSERT (nlm_custom_header (abfd)->hdrLength == 0);
- if (bfd_write ((PTR) &thdr, 1,
- sizeof (thdr) - sizeof (thdr.dataStamp), abfd)
- != sizeof (thdr) - sizeof (thdr.dataStamp))
- return false;
- }
- else
- {
- memcpy (thdr.dataStamp, nlm_custom_header (abfd)->dataStamp,
- sizeof (thdr.dataStamp));
- if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- return false;
- if (bfd_write (nlm_custom_header (abfd)->hdr, 1,
- nlm_custom_header (abfd)->hdrLength, abfd)
- != nlm_custom_header (abfd)->hdrLength)
- return false;
- }
- }
-
- /* Write out the Cygnus debugging header if there is one. */
- if (find_nonzero ((PTR) nlm_cygnus_ext_header (abfd),
- sizeof (Nlm_Internal_Cygnus_Ext_Header)))
- {
- Nlm_External_Custom_Header thdr;
-
- memcpy (thdr.stamp, "CuStHeAd", 8);
- put_word (abfd, (bfd_vma) 2 * NLM_TARGET_LONG_SIZE + 8,
- (bfd_byte *) thdr.length);
- put_word (abfd, (bfd_vma) nlm_cygnus_ext_header (abfd)->offset,
- (bfd_byte *) thdr.dataOffset);
- put_word (abfd, (bfd_vma) nlm_cygnus_ext_header (abfd)->length,
- (bfd_byte *) thdr.dataLength);
- memcpy (thdr.dataStamp, "CyGnUsEx", 8);
- if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- return false;
- }
-
- return true;
-}
-
-/* We read the NLM's public symbols and use it to generate a bfd symbol
- table (hey, it's better than nothing) on a one-for-one basis. Thus
- use the number of public symbols as the number of bfd symbols we will
- have once we actually get around to reading them in.
-
- Return the number of bytes required to hold the symtab vector, based on
- the count plus 1, since we will NULL terminate the vector allocated based
- on this size. */
-
-long
-nlm_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */
- long symcount;
- long symtab_size = 0;
-
- i_fxdhdrp = nlm_fixed_header (abfd);
- symcount = (i_fxdhdrp->numberOfPublics
- + i_fxdhdrp->numberOfDebugRecords
- + i_fxdhdrp->numberOfExternalReferences);
- symtab_size = (symcount + 1) * (sizeof (asymbol));
- return (symtab_size);
-}
-
-/* Note that bfd_get_symcount is guaranteed to be zero if slurping the
- symbol table fails. */
-
-long
-nlm_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- nlm_symbol_type *symbase;
- bfd_size_type counter = 0;
-
- if (nlm_slurp_symbol_table (abfd) == false)
- return -1;
- symbase = nlm_get_symbols (abfd);
- while (counter < bfd_get_symcount (abfd))
- {
- *alocation++ = &symbase->symbol;
- symbase++;
- counter++;
- }
- *alocation = (asymbol *) NULL;
- return bfd_get_symcount (abfd);
-}
-
-/* Make an NLM symbol. There is nothing special to do here. */
-
-asymbol *
-nlm_make_empty_symbol (abfd)
- bfd *abfd;
-{
- nlm_symbol_type *new;
-
- new = (nlm_symbol_type *) bfd_zalloc (abfd, sizeof (nlm_symbol_type));
- if (new)
- new->symbol.the_bfd = abfd;
- return &new->symbol;
-}
-
-/* Get symbol information. */
-
-void
-nlm_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-/* Print symbol information. */
-
-void
-nlm_print_symbol (abfd, afile, symbol, how)
- bfd *abfd;
- PTR afile;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) afile;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- case bfd_print_symbol_more:
- if (symbol->name)
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_all:
- bfd_print_symbol_vandf ((PTR) file, symbol);
- fprintf (file, " %-5s", symbol->section->name);
- if (symbol->name)
- fprintf (file, " %s", symbol->name);
- break;
- }
-}
-
-/* Slurp in nlm symbol table.
-
- In the external (in-file) form, NLM export records are variable length,
- with the following form:
-
- 1 byte length of the symbol name (N)
- N bytes the symbol name
- 4 bytes the symbol offset from start of it's section
-
- We also read in the debugging symbols and import records. Import
- records are treated as undefined symbols. As we read the import
- records we also read in the associated reloc information, which is
- attached to the symbol.
-
- The bfd symbols are copied to SYMPTRS.
-
- When we return, the bfd symcount is either zero or contains the correct
- number of symbols.
-*/
-
-static boolean
-nlm_slurp_symbol_table (abfd)
- bfd *abfd;
-{
- Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */
- bfd_size_type totsymcount; /* Number of NLM symbols */
- bfd_size_type symcount; /* Counter of NLM symbols */
- nlm_symbol_type *sym; /* Pointer to current bfd symbol */
- unsigned char symlength; /* Symbol length read into here */
- unsigned char symtype; /* Type of debugging symbol */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Symbol offsets read into here */
- boolean (*read_import_func) PARAMS ((bfd *, nlm_symbol_type *));
- boolean (*set_public_section_func) PARAMS ((bfd *, nlm_symbol_type *));
-
- if (nlm_get_symbols (abfd) != NULL)
- return (true);
-
- /* Read each raw NLM symbol, using the information to create a canonical bfd
- symbol table entry.
-
- Note that we allocate the initial bfd canonical symbol buffer based on a
- one-to-one mapping of the NLM symbols to canonical symbols. We actually
- use all the NLM symbols, so there will be no space left over at the end.
- When we have all the symbols, we build the caller's pointer vector. */
-
- abfd->symcount = 0;
- i_fxdhdrp = nlm_fixed_header (abfd);
- totsymcount = (i_fxdhdrp->numberOfPublics
- + i_fxdhdrp->numberOfDebugRecords
- + i_fxdhdrp->numberOfExternalReferences);
- if (totsymcount == 0)
- {
- return (true);
- }
-
- if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) == -1)
- return (false);
-
- sym = ((nlm_symbol_type *)
- bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type)));
- if (!sym)
- return false;
- nlm_set_symbols (abfd, sym);
-
- /* We use the bfd's symcount directly as the control count, so that early
- termination of the loop leaves the symcount correct for the symbols that
- were read. */
-
- set_public_section_func = nlm_set_public_section_func (abfd);
- symcount = i_fxdhdrp->numberOfPublics;
- while (abfd->symcount < symcount)
- {
- if (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
- != sizeof (symlength))
- return (false);
- sym->symbol.the_bfd = abfd;
- sym->symbol.name = bfd_alloc (abfd, symlength + 1);
- if (!sym->symbol.name)
- return false;
- if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
- != symlength)
- return (false);
- /* Cast away const. */
- ((char *) (sym->symbol.name))[symlength] = '\0';
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
- sym->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
- sym->symbol.value = get_word (abfd, temp);
- if (set_public_section_func)
- {
- /* Most backends can use the code below, but unfortunately
- some use a different scheme. */
- if ((*set_public_section_func) (abfd, sym) == false)
- return false;
- }
- else
- {
- if (sym->symbol.value & NLM_HIBIT)
- {
- sym->symbol.value &= ~NLM_HIBIT;
- sym->symbol.flags |= BSF_FUNCTION;
- sym->symbol.section =
- bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- }
- else
- {
- sym->symbol.section =
- bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- }
- }
- sym->rcnt = 0;
- abfd->symcount++;
- sym++;
- }
-
- /* Read the debugging records. */
-
- if (i_fxdhdrp->numberOfDebugRecords > 0)
- {
- if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) == -1)
- return (false);
-
- symcount += i_fxdhdrp->numberOfDebugRecords;
- while (abfd->symcount < symcount)
- {
- if ((bfd_read ((PTR) & symtype, sizeof (symtype), 1, abfd)
- != sizeof (symtype))
- || bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)
- || (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
- != sizeof (symlength)))
- return false;
- sym->symbol.the_bfd = abfd;
- sym->symbol.name = bfd_alloc (abfd, symlength + 1);
- if (!sym->symbol.name)
- return false;
- if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
- != symlength)
- return (false);
- /* Cast away const. */
- ((char *) (sym->symbol.name))[symlength] = '\0';
- sym->symbol.flags = BSF_LOCAL;
- sym->symbol.value = get_word (abfd, temp);
- if (symtype == 0)
- {
- sym->symbol.section =
- bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- }
- else if (symtype == 1)
- {
- sym->symbol.flags |= BSF_FUNCTION;
- sym->symbol.section =
- bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- }
- else
- {
- sym->symbol.section = bfd_abs_section_ptr;
- }
- sym->rcnt = 0;
- abfd->symcount++;
- sym++;
- }
- }
-
- /* Read in the import records. We can only do this if we know how
- to read relocs for this target. */
-
- read_import_func = nlm_read_import_func (abfd);
- if (read_import_func != NULL)
- {
- if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET)
- == -1)
- return (false);
-
- symcount += i_fxdhdrp->numberOfExternalReferences;
- while (abfd->symcount < symcount)
- {
- if ((*read_import_func) (abfd, sym) == false)
- return false;
- sym++;
- abfd->symcount++;
- }
- }
-
- return (true);
-}
-
-/* Get the relocs for an NLM file. There are two types of relocs.
- Imports are relocs against symbols defined in other NLM files. We
- treat these as relocs against global symbols. Relocation fixups
- are internal relocs.
-
- The actual format used to store the relocs is machine specific. */
-
-/* Read in the relocation fixup information. This is stored in
- nlm_relocation_fixups, an array of arelent structures, and
- nlm_relocation_fixup_secs, an array of section pointers. The
- section pointers are needed because the relocs are not sorted by
- section. */
-
-static boolean
-nlm_slurp_reloc_fixups (abfd)
- bfd *abfd;
-{
- boolean (*read_func) PARAMS ((bfd *, nlm_symbol_type *, asection **,
- arelent *));
- bfd_size_type count;
- arelent *rels;
- asection **secs;
-
- if (nlm_relocation_fixups (abfd) != NULL)
- return true;
- read_func = nlm_read_reloc_func (abfd);
- if (read_func == NULL)
- return true;
-
- if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset,
- SEEK_SET) != 0)
- return false;
-
- count = nlm_fixed_header (abfd)->numberOfRelocationFixups;
- rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent));
- secs = (asection **) bfd_alloc (abfd, count * sizeof (asection *));
- if ((rels == NULL || secs == NULL) && count != 0)
- return false;
- nlm_relocation_fixups (abfd) = rels;
- nlm_relocation_fixup_secs (abfd) = secs;
-
- /* We have to read piece by piece, because we don't know how large
- the machine specific reloc information is. */
- while (count-- != 0)
- {
- if ((*read_func) (abfd, (nlm_symbol_type *) NULL, secs, rels) == false)
- {
- nlm_relocation_fixups (abfd) = NULL;
- nlm_relocation_fixup_secs (abfd) = NULL;
- return false;
- }
- ++secs;
- ++rels;
- }
-
- return true;
-}
-
-/* Get the number of relocs. This really just returns an upper bound,
- since it does not attempt to distinguish them based on the section.
- That will be handled when they are actually read. */
-
-long
-nlm_get_reloc_upper_bound (abfd, sec)
- bfd *abfd;
- asection *sec;
-{
- nlm_symbol_type *syms;
- bfd_size_type count;
- unsigned int ret;
-
- /* If we don't know how to read relocs, just return 0. */
- if (nlm_read_reloc_func (abfd) == NULL)
- return -1;
- /* Make sure we have either the code or the data section. */
- if ((bfd_get_section_flags (abfd, sec) & (SEC_CODE | SEC_DATA)) == 0)
- return 0;
-
- syms = nlm_get_symbols (abfd);
- if (syms == NULL)
- {
- if (nlm_slurp_symbol_table (abfd) == false)
- return -1;
- syms = nlm_get_symbols (abfd);
- }
-
- ret = nlm_fixed_header (abfd)->numberOfRelocationFixups;
-
- count = bfd_get_symcount (abfd);
- while (count-- != 0)
- {
- ret += syms->rcnt;
- ++syms;
- }
-
- return (ret + 1) * sizeof (arelent *);
-}
-
-/* Get the relocs themselves. */
-
-long
-nlm_canonicalize_reloc (abfd, sec, relptr, symbols)
- bfd *abfd;
- asection *sec;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *rels;
- asection **secs;
- bfd_size_type count, i;
- unsigned int ret;
-
- /* Get the relocation fixups. */
- rels = nlm_relocation_fixups (abfd);
- if (rels == NULL)
- {
- if (nlm_slurp_reloc_fixups (abfd) == false)
- return -1;
- rels = nlm_relocation_fixups (abfd);
- }
- secs = nlm_relocation_fixup_secs (abfd);
-
- ret = 0;
- count = nlm_fixed_header (abfd)->numberOfRelocationFixups;
- for (i = 0; i < count; i++, rels++, secs++)
- {
- if (*secs == sec)
- {
- *relptr++ = rels;
- ++ret;
- }
- }
-
- /* Get the import symbols. */
- count = bfd_get_symcount (abfd);
- for (i = 0; i < count; i++, symbols++)
- {
- asymbol *sym;
-
- sym = *symbols;
- if (bfd_asymbol_flavour (sym) == bfd_target_nlm_flavour)
- {
- nlm_symbol_type *nlm_sym;
- bfd_size_type j;
-
- nlm_sym = (nlm_symbol_type *) sym;
- for (j = 0; j < nlm_sym->rcnt; j++)
- {
- if (nlm_sym->relocs[j].section == sec)
- {
- *relptr = &nlm_sym->relocs[j].reloc;
- (*relptr)->sym_ptr_ptr = symbols;
- ++relptr;
- ++ret;
- }
- }
- }
- }
-
- *relptr = NULL;
-
- return ret;
-}
-
-/* Compute the section file positions for an NLM file. All variable
- length data in the file headers must be set before this function is
- called. If the variable length data is changed later, the
- resulting object file will be incorrect. Unfortunately, there is
- no way to check this.
-
- This routine also sets the Size and Offset fields in the fixed
- header.
-
- It also looks over the symbols and moves any common symbols into
- the .bss section; NLM has no way to represent a common symbol.
- This approach means that either the symbols must already have been
- set at this point, or there must be no common symbols. We need to
- move the symbols at this point so that mangle_relocs can see the
- final values. */
-
-static boolean
-nlm_compute_section_file_positions (abfd)
- bfd *abfd;
-{
- file_ptr sofar;
- asection *sec;
- bfd_vma text, data, bss;
- bfd_vma text_low, data_low;
- unsigned int text_align, data_align, other_align;
- file_ptr text_ptr, data_ptr, other_ptr;
- asection *bss_sec;
- asymbol **sym_ptr_ptr;
-
- if (abfd->output_has_begun == true)
- return true;
-
- /* Make sure we have a section to hold uninitialized data. */
- bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
- if (bss_sec == NULL)
- {
- if (!add_bfd_section (abfd, NLM_UNINITIALIZED_DATA_NAME,
- (file_ptr) 0, (bfd_size_type) 0,
- SEC_ALLOC))
- return false;
- bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
- }
-
- abfd->output_has_begun = true;
-
- /* The fixed header. */
- sofar = nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd);
-
- /* The variable header. */
- sofar += (sizeof (nlm_variable_header (abfd)->descriptionLength)
- + nlm_variable_header (abfd)->descriptionLength + 1
- + NLM_TARGET_LONG_SIZE /* stackSize */
- + NLM_TARGET_LONG_SIZE /* reserved */
- + sizeof (nlm_variable_header (abfd)->oldThreadName)
- + sizeof (nlm_variable_header (abfd)->screenNameLength)
- + nlm_variable_header (abfd)->screenNameLength + 1
- + sizeof (nlm_variable_header (abfd)->threadNameLength)
- + nlm_variable_header (abfd)->threadNameLength + 1);
-
- /* The auxiliary headers. */
- if (find_nonzero ((PTR) nlm_version_header (abfd),
- sizeof (Nlm_Internal_Version_Header)))
- sofar += sizeof (Nlm_External_Version_Header);
- if (find_nonzero ((PTR) nlm_extended_header (abfd),
- sizeof (Nlm_Internal_Extended_Header)))
- sofar += sizeof (Nlm_External_Extended_Header);
- if (find_nonzero ((PTR) nlm_copyright_header (abfd),
- sizeof (Nlm_Internal_Copyright_Header)))
- sofar += (sizeof (Nlm_External_Copyright_Header)
- + nlm_copyright_header (abfd)->copyrightMessageLength + 1);
- if (find_nonzero ((PTR) nlm_custom_header (abfd),
- sizeof (Nlm_Internal_Custom_Header)))
- sofar += (sizeof (Nlm_External_Custom_Header)
- + nlm_custom_header (abfd)->hdrLength);
- if (find_nonzero ((PTR) nlm_cygnus_ext_header (abfd),
- sizeof (Nlm_Internal_Cygnus_Ext_Header)))
- sofar += sizeof (Nlm_External_Custom_Header);
-
- /* Compute the section file positions in two passes. First get the
- sizes of the text and data sections, and then set the file
- positions. This code aligns the sections in the file using the
- same alignment restrictions that apply to the sections in memory;
- this may not be necessary. */
- text = 0;
- text_low = (bfd_vma) - 1;
- text_align = 0;
- data = 0;
- data_low = (bfd_vma) - 1;
- data_align = 0;
- bss = 0;
- other_align = 0;
- for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
- {
- flagword f;
-
- sec->_raw_size = BFD_ALIGN (sec->_raw_size, 1 << sec->alignment_power);
-
- f = bfd_get_section_flags (abfd, sec);
- if (f & SEC_CODE)
- {
- text += sec->_raw_size;
- if (bfd_get_section_vma (abfd, sec) < text_low)
- text_low = bfd_get_section_vma (abfd, sec);
- if (sec->alignment_power > text_align)
- text_align = sec->alignment_power;
- }
- else if (f & SEC_DATA)
- {
- data += sec->_raw_size;
- if (bfd_get_section_vma (abfd, sec) < data_low)
- data_low = bfd_get_section_vma (abfd, sec);
- if (sec->alignment_power > data_align)
- data_align = sec->alignment_power;
- }
- else if (f & SEC_HAS_CONTENTS)
- {
- if (sec->alignment_power > other_align)
- other_align = sec->alignment_power;
- }
- else if (f & SEC_ALLOC)
- bss += sec->_raw_size;
- }
-
- nlm_set_text_low (abfd, text_low);
- nlm_set_data_low (abfd, data_low);
-
- if (nlm_no_uninitialized_data (abfd))
- {
- /* This NetWare format does not use uninitialized data. We must
- increase the size of the data section. We will never wind up
- writing those file locations, so they will remain zero. */
- data += bss;
- bss = 0;
- }
-
- text_ptr = BFD_ALIGN (sofar, 1 << text_align);
- data_ptr = BFD_ALIGN (text_ptr + text, 1 << data_align);
- other_ptr = BFD_ALIGN (data_ptr + data, 1 << other_align);
-
- /* Fill in some fields in the header for which we now have the
- information. */
- nlm_fixed_header (abfd)->codeImageOffset = text_ptr;
- nlm_fixed_header (abfd)->codeImageSize = text;
- nlm_fixed_header (abfd)->dataImageOffset = data_ptr;
- nlm_fixed_header (abfd)->dataImageSize = data;
- nlm_fixed_header (abfd)->uninitializedDataSize = bss;
-
- for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
- {
- flagword f;
-
- f = bfd_get_section_flags (abfd, sec);
-
- if (f & SEC_CODE)
- {
- sec->filepos = text_ptr;
- text_ptr += sec->_raw_size;
- }
- else if (f & SEC_DATA)
- {
- sec->filepos = data_ptr;
- data_ptr += sec->_raw_size;
- }
- else if (f & SEC_HAS_CONTENTS)
- {
- sec->filepos = other_ptr;
- other_ptr += sec->_raw_size;
- }
- }
-
- nlm_fixed_header (abfd)->relocationFixupOffset = other_ptr;
-
- /* Move all common symbols into the .bss section. */
-
- sym_ptr_ptr = bfd_get_outsymbols (abfd);
- if (sym_ptr_ptr != NULL)
- {
- asymbol **sym_end;
- bfd_vma add;
-
- sym_end = sym_ptr_ptr + bfd_get_symcount (abfd);
- add = 0;
- for (; sym_ptr_ptr < sym_end; sym_ptr_ptr++)
- {
- asymbol *sym;
- bfd_vma size;
-
- sym = *sym_ptr_ptr;
-
- if (!bfd_is_com_section (bfd_get_section (sym)))
- continue;
-
- /* Put the common symbol in the .bss section, and increase
- the size of the .bss section by the size of the common
- symbol (which is the old value of the symbol). */
- sym->section = bss_sec;
- size = sym->value;
- sym->value = bss_sec->_raw_size + add;
- add += size;
- add = BFD_ALIGN (add, 1 << bss_sec->alignment_power);
- }
- if (add != 0)
- {
- if (nlm_no_uninitialized_data (abfd))
- {
- /* We could handle this case, but so far it hasn't been
- necessary. */
- abort ();
- }
- nlm_fixed_header (abfd)->uninitializedDataSize += add;
- bss_sec->_raw_size += add;
- }
- }
-
- return true;
-}
-
-/* Set the contents of a section. To do this we need to know where
- the section is going to be located in the output file. That means
- that the sizes of all the sections must be set, and all the
- variable size header information must be known. */
-
-boolean
-nlm_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (abfd->output_has_begun == false
- && nlm_compute_section_file_positions (abfd) == false)
- return false;
-
- if (count == 0)
- return true;
-
- /* i386 NetWare has a very restricted set of relocs. In order for
- objcopy to work, the NLM i386 backend needs a chance to rework
- the section contents so that its set of relocs will work. If all
- the relocs are already acceptable, this will not do anything. */
- if (section->reloc_count != 0)
- {
- boolean (*mangle_relocs_func) PARAMS ((bfd *, asection *, PTR,
- bfd_vma, bfd_size_type));
-
- mangle_relocs_func = nlm_mangle_relocs_func (abfd);
- if (mangle_relocs_func != NULL)
- {
- if (!(*mangle_relocs_func) (abfd, section, location,
- (bfd_vma) offset, count))
- return false;
- }
- }
-
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
- return false;
-
- return true;
-}
-
-/* We need to sort a list of relocs associated with sections when we
- write out the external relocs. */
-
-static int
-nlm_external_reloc_compare (p1, p2)
- const void *p1;
- const void *p2;
-{
- const struct reloc_and_sec *r1 = (const struct reloc_and_sec *) p1;
- const struct reloc_and_sec *r2 = (const struct reloc_and_sec *) p2;
- int cmp;
-
- cmp = strcmp ((*r1->rel->sym_ptr_ptr)->name,
- (*r2->rel->sym_ptr_ptr)->name);
- if (cmp != 0)
- return cmp;
-
- /* We sort by address within symbol to make the sort more stable and
- increase the chances that different hosts will generate bit for
- bit equivalent results. */
- return (int) (r1->rel->address - r2->rel->address);
-}
-
-/* Write out an NLM file. We write out the information in this order:
- fixed header
- variable header
- auxiliary headers
- code sections
- data sections
- other sections (custom data, messages, help, shared NLM, RPC,
- module dependencies)
- relocation fixups
- external references (imports)
- public symbols (exports)
- debugging records
- This is similar to the order used by the NetWare tools; the
- difference is that NetWare puts the sections other than code, data
- and custom data at the end of the NLM. It is convenient for us to
- know where the sections are going to be before worrying about the
- size of the other information.
-
- By the time this function is called, all the section data should
- have been output using set_section_contents. Note that custom
- data, the message file, the help file, the shared NLM file, the RPC
- data, and the module dependencies are all considered to be
- sections; the caller is responsible for filling in the offset and
- length fields in the NLM headers. The relocation fixups and
- imports are both obtained from the list of relocs attached to each
- section. The exports and debugging records are obtained from the
- list of outsymbols. */
-
-boolean
-nlm_write_object_contents (abfd)
- bfd *abfd;
-{
- asection *sec;
- boolean (*write_import_func) PARAMS ((bfd *, asection *, arelent *));
- bfd_size_type external_reloc_count, internal_reloc_count, i, c;
- struct reloc_and_sec *external_relocs;
- asymbol **sym_ptr_ptr;
- file_ptr last;
- boolean (*write_prefix_func) PARAMS ((bfd *));
- unsigned char *fixed_header = NULL;
-
- fixed_header = ((unsigned char *)
- bfd_malloc ((size_t) nlm_fixed_header_size (abfd)));
- if (fixed_header == NULL)
- goto error_return;
-
- if (abfd->output_has_begun == false
- && nlm_compute_section_file_positions (abfd) == false)
- goto error_return;
-
- /* Write out the variable length headers. */
- if (bfd_seek (abfd,
- nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd),
- SEEK_SET) != 0)
- goto error_return;
- if (nlm_swap_variable_header_out (abfd) == false
- || nlm_swap_auxiliary_headers_out (abfd) == false)
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
-
- /* A weak check on whether the section file positions were
- reasonable. */
- if (bfd_tell (abfd) > nlm_fixed_header (abfd)->codeImageOffset)
- {
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
-
- /* Advance to the relocs. */
- if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset,
- SEEK_SET) != 0)
- goto error_return;
-
- /* The format of the relocation entries is dependent upon the
- particular target. We use an external routine to write the reloc
- out. */
- write_import_func = nlm_write_import_func (abfd);
-
- /* Write out the internal relocation fixups. While we're looping
- over the relocs, we also count the external relocs, which is
- needed when they are written out below. */
- internal_reloc_count = 0;
- external_reloc_count = 0;
- for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
- {
- arelent **rel_ptr_ptr, **rel_end;
-
- if (sec->reloc_count == 0)
- continue;
-
- /* We can only represent relocs within a code or data
- section. We ignore them for a debugging section. */
- if ((bfd_get_section_flags (abfd, sec) & (SEC_CODE | SEC_DATA)) == 0)
- continue;
-
- /* We need to know how to write out imports */
- if (write_import_func == NULL)
- {
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
-
- rel_ptr_ptr = sec->orelocation;
- rel_end = rel_ptr_ptr + sec->reloc_count;
- for (; rel_ptr_ptr < rel_end; rel_ptr_ptr++)
- {
- arelent *rel;
- asymbol *sym;
-
- rel = *rel_ptr_ptr;
- sym = *rel->sym_ptr_ptr;
-
- if (! bfd_is_und_section (bfd_get_section (sym)))
- {
- ++internal_reloc_count;
- if ((*write_import_func) (abfd, sec, rel) == false)
- goto error_return;
- }
- else
- ++external_reloc_count;
- }
- }
- nlm_fixed_header (abfd)->numberOfRelocationFixups = internal_reloc_count;
-
- /* Write out the imports (relocs against external symbols). These
- are output as a symbol name followed by all the relocs for that
- symbol, so we must first gather together all the relocs against
- external symbols and sort them. */
- external_relocs =
- (struct reloc_and_sec *) bfd_alloc (abfd,
- (external_reloc_count
- * sizeof (struct reloc_and_sec)));
- if (external_relocs == (struct reloc_and_sec *) NULL)
- goto error_return;
- i = 0;
- for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
- {
- arelent **rel_ptr_ptr, **rel_end;
-
- if (sec->reloc_count == 0)
- continue;
-
- rel_ptr_ptr = sec->orelocation;
- rel_end = rel_ptr_ptr + sec->reloc_count;
- for (; rel_ptr_ptr < rel_end; rel_ptr_ptr++)
- {
- arelent *rel;
- asymbol *sym;
-
- rel = *rel_ptr_ptr;
- sym = *rel->sym_ptr_ptr;
-
- if (! bfd_is_und_section (bfd_get_section (sym)))
- continue;
-
- external_relocs[i].rel = rel;
- external_relocs[i].sec = sec;
- ++i;
- }
- }
-
- BFD_ASSERT (i == external_reloc_count);
-
- /* Sort the external relocs by name. */
- qsort ((PTR) external_relocs, (size_t) external_reloc_count,
- sizeof (struct reloc_and_sec), nlm_external_reloc_compare);
-
- /* Write out the external relocs. */
- nlm_fixed_header (abfd)->externalReferencesOffset = bfd_tell (abfd);
- c = 0;
- i = 0;
- while (i < external_reloc_count)
- {
- arelent *rel;
- asymbol *sym;
- bfd_size_type j, cnt;
-
- ++c;
-
- rel = external_relocs[i].rel;
- sym = *rel->sym_ptr_ptr;
-
- cnt = 0;
- for (j = i;
- (j < external_reloc_count
- && *external_relocs[j].rel->sym_ptr_ptr == sym);
- j++)
- ++cnt;
-
- if ((*nlm_write_external_func (abfd)) (abfd, cnt, sym,
- &external_relocs[i])
- == false)
- goto error_return;
-
- i += cnt;
- }
-
- nlm_fixed_header (abfd)->numberOfExternalReferences = c;
-
- /* Write out the public symbols (exports). */
- sym_ptr_ptr = bfd_get_outsymbols (abfd);
- if (sym_ptr_ptr != (asymbol **) NULL)
- {
- bfd_vma (*get_public_offset_func) PARAMS ((bfd *, asymbol *));
- boolean (*write_export_func) PARAMS ((bfd *, asymbol *, bfd_vma));
-
- asymbol **sym_end;
-
- nlm_fixed_header (abfd)->publicsOffset = bfd_tell (abfd);
- get_public_offset_func = nlm_get_public_offset_func (abfd);
- write_export_func = nlm_write_export_func (abfd);
- c = 0;
- sym_end = sym_ptr_ptr + bfd_get_symcount (abfd);
- for (; sym_ptr_ptr < sym_end; sym_ptr_ptr++)
- {
- asymbol *sym;
- bfd_byte len;
- bfd_vma offset;
- bfd_byte temp[NLM_TARGET_LONG_SIZE];
-
- sym = *sym_ptr_ptr;
-
- if ((sym->flags & (BSF_EXPORT | BSF_GLOBAL)) == 0
- || bfd_is_und_section (bfd_get_section (sym)))
- continue;
-
- ++c;
-
- if (get_public_offset_func)
- {
- /* Most backends can use the code below, but
- unfortunately some use a different scheme. */
- offset = (*get_public_offset_func) (abfd, sym);
- }
- else
- {
- offset = bfd_asymbol_value (sym);
- sec = sym->section;
- if (sec->flags & SEC_CODE)
- {
- offset -= nlm_get_text_low (abfd);
- offset |= NLM_HIBIT;
- }
- else if (sec->flags & (SEC_DATA | SEC_ALLOC))
- {
- /* SEC_ALLOC is for the .bss section. */
- offset -= nlm_get_data_low (abfd);
- }
- else
- {
- /* We can't handle an exported symbol that is not in
- the code or data segment. */
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
- }
-
- if (write_export_func)
- {
- if ((*write_export_func) (abfd, sym, offset) == false)
- goto error_return;
- }
- else
- {
- len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
- != sizeof (bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
- goto error_return;
-
- put_word (abfd, offset, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- goto error_return;
- }
- }
- nlm_fixed_header (abfd)->numberOfPublics = c;
-
- /* Write out the debugging records. The NLM conversion program
- wants to be able to inhibit this, so as a special hack if
- debugInfoOffset is set to -1 we don't write any debugging
- information. This can not be handled by fiddling with the
- symbol table, because exported symbols appear in both the
- exported symbol list and the debugging information. */
- if (nlm_fixed_header (abfd)->debugInfoOffset == (file_ptr) - 1)
- {
- nlm_fixed_header (abfd)->debugInfoOffset = 0;
- nlm_fixed_header (abfd)->numberOfDebugRecords = 0;
- }
- else
- {
- nlm_fixed_header (abfd)->debugInfoOffset = bfd_tell (abfd);
- c = 0;
- sym_ptr_ptr = bfd_get_outsymbols (abfd);
- sym_end = sym_ptr_ptr + bfd_get_symcount (abfd);
- for (; sym_ptr_ptr < sym_end; sym_ptr_ptr++)
- {
- asymbol *sym;
- bfd_byte type, len;
- bfd_vma offset;
- bfd_byte temp[NLM_TARGET_LONG_SIZE];
-
- sym = *sym_ptr_ptr;
-
- /* The NLM notion of a debugging symbol is actually what
- BFD calls a local or global symbol. What BFD calls a
- debugging symbol NLM does not understand at all. */
- if ((sym->flags & (BSF_LOCAL | BSF_GLOBAL | BSF_EXPORT)) == 0
- || (sym->flags & BSF_DEBUGGING) != 0
- || bfd_is_und_section (bfd_get_section (sym)))
- continue;
-
- ++c;
-
- offset = bfd_asymbol_value (sym);
- sec = sym->section;
- if (sec->flags & SEC_CODE)
- {
- offset -= nlm_get_text_low (abfd);
- type = 1;
- }
- else if (sec->flags & (SEC_DATA | SEC_ALLOC))
- {
- /* SEC_ALLOC is for the .bss section. */
- offset -= nlm_get_data_low (abfd);
- type = 0;
- }
- else
- type = 2;
-
- /* The type is 0 for data, 1 for code, 2 for absolute. */
- if (bfd_write (&type, sizeof (bfd_byte), 1, abfd)
- != sizeof (bfd_byte))
- goto error_return;
-
- put_word (abfd, offset, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- goto error_return;
-
- len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
- != sizeof (bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
- goto error_return;
- }
- nlm_fixed_header (abfd)->numberOfDebugRecords = c;
- }
- }
-
- /* NLMLINK fills in offset values even if there is no data, so we do
- the same. */
- last = bfd_tell (abfd);
- if (nlm_fixed_header (abfd)->codeImageOffset == 0)
- nlm_fixed_header (abfd)->codeImageOffset = last;
- if (nlm_fixed_header (abfd)->dataImageOffset == 0)
- nlm_fixed_header (abfd)->dataImageOffset = last;
- if (nlm_fixed_header (abfd)->customDataOffset == 0)
- nlm_fixed_header (abfd)->customDataOffset = last;
- if (nlm_fixed_header (abfd)->moduleDependencyOffset == 0)
- nlm_fixed_header (abfd)->moduleDependencyOffset = last;
- if (nlm_fixed_header (abfd)->relocationFixupOffset == 0)
- nlm_fixed_header (abfd)->relocationFixupOffset = last;
- if (nlm_fixed_header (abfd)->externalReferencesOffset == 0)
- nlm_fixed_header (abfd)->externalReferencesOffset = last;
- if (nlm_fixed_header (abfd)->publicsOffset == 0)
- nlm_fixed_header (abfd)->publicsOffset = last;
- if (nlm_fixed_header (abfd)->debugInfoOffset == 0)
- nlm_fixed_header (abfd)->debugInfoOffset = last;
-
- /* At this point everything has been written out except the fixed
- header. */
- memcpy (nlm_fixed_header (abfd)->signature, nlm_signature (abfd),
- NLM_SIGNATURE_SIZE);
- nlm_fixed_header (abfd)->version = NLM_HEADER_VERSION;
- nlm_fixed_header (abfd)->codeStartOffset =
- (bfd_get_start_address (abfd)
- - nlm_get_text_low (abfd));
-
- /* We have no convenient way for the caller to pass in the exit
- procedure or the check unload procedure, so the caller must set
- the values in the header to the values of the symbols. */
- nlm_fixed_header (abfd)->exitProcedureOffset -= nlm_get_text_low (abfd);
- if (nlm_fixed_header (abfd)->checkUnloadProcedureOffset != 0)
- nlm_fixed_header (abfd)->checkUnloadProcedureOffset -=
- nlm_get_text_low (abfd);
-
- if (bfd_seek (abfd, 0, SEEK_SET) != 0)
- goto error_return;
-
- write_prefix_func = nlm_write_prefix_func (abfd);
- if (write_prefix_func)
- {
- if ((*write_prefix_func) (abfd) == false)
- goto error_return;
- }
-
- BFD_ASSERT ((bfd_size_type) bfd_tell (abfd)
- == nlm_optional_prefix_size (abfd));
-
- nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header);
- if (bfd_write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd)
- != nlm_fixed_header_size (abfd))
- goto error_return;
-
- if (fixed_header != NULL)
- free (fixed_header);
- return true;
-
-error_return:
- if (fixed_header != NULL)
- free (fixed_header);
- return false;
-}
diff --git a/contrib/gdb/bfd/nlmswap.h b/contrib/gdb/bfd/nlmswap.h
deleted file mode 100644
index 5a9ce72..0000000
--- a/contrib/gdb/bfd/nlmswap.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/* NLM (NetWare Loadable Module) swapping routines for BFD.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
- Written by Fred Fish @ Cygnus Support, using ELF support as the
- template.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Although this is a header file, it defines functions. It is
- included by NLM backends to define swapping functions that vary
- from one NLM to another. The backend code must arrange for
- Nlm_External_xxxx to be defined appropriately, and can then include
- this file to get the swapping routines.
-
- At the moment this is only needed for one structure, the fixed NLM
- file header. */
-
-static void nlm_swap_fixed_header_in PARAMS ((bfd *, PTR,
- Nlm_Internal_Fixed_Header *));
-static void nlm_swap_fixed_header_out PARAMS ((bfd *,
- Nlm_Internal_Fixed_Header *,
- PTR));
-
-/* Translate an NLM fixed length file header in external format into an NLM
- file header in internal format. */
-
-static void
-nlm_swap_fixed_header_in (abfd, realsrc, dst)
- bfd *abfd;
- PTR realsrc;
- Nlm_Internal_Fixed_Header *dst;
-{
- Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header *) realsrc;
- memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
- memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
- dst->version =
- bfd_h_get_32 (abfd, (bfd_byte *) src->version);
- dst->codeImageOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->codeImageOffset);
- dst->codeImageSize =
- bfd_h_get_32 (abfd, (bfd_byte *) src->codeImageSize);
- dst->dataImageOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->dataImageOffset);
- dst->dataImageSize =
- bfd_h_get_32 (abfd, (bfd_byte *) src->dataImageSize);
- dst->uninitializedDataSize =
- bfd_h_get_32 (abfd, (bfd_byte *) src->uninitializedDataSize);
- dst->customDataOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->customDataOffset);
- dst->customDataSize =
- bfd_h_get_32 (abfd, (bfd_byte *) src->customDataSize);
- dst->moduleDependencyOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->moduleDependencyOffset);
- dst->numberOfModuleDependencies =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfModuleDependencies);
- dst->relocationFixupOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->relocationFixupOffset);
- dst->numberOfRelocationFixups =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfRelocationFixups);
- dst->externalReferencesOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->externalReferencesOffset);
- dst->numberOfExternalReferences =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfExternalReferences);
- dst->publicsOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->publicsOffset);
- dst->numberOfPublics =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfPublics);
- dst->debugInfoOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->debugInfoOffset);
- dst->numberOfDebugRecords =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfDebugRecords);
- dst->codeStartOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->codeStartOffset);
- dst->exitProcedureOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->exitProcedureOffset);
- dst->checkUnloadProcedureOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->checkUnloadProcedureOffset);
- dst->moduleType =
- bfd_h_get_32 (abfd, (bfd_byte *) src->moduleType);
- dst->flags =
- bfd_h_get_32 (abfd, (bfd_byte *) src->flags);
-}
-
-/* Translate an NLM fixed length file header in internal format into
- an NLM file header in external format. */
-
-static void
-nlm_swap_fixed_header_out (abfd, src, realdst)
- bfd *abfd;
- Nlm_Internal_Fixed_Header *src;
- PTR realdst;
-{
- Nlm_External_Fixed_Header *dst = (Nlm_External_Fixed_Header *) realdst;
- memset (dst, 0, sizeof *dst);
- memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
- memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
- bfd_h_put_32 (abfd, (bfd_vma) src->version,
- (bfd_byte *) dst->version);
- bfd_h_put_32 (abfd, (bfd_vma) src->codeImageOffset,
- (bfd_byte *) dst->codeImageOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->codeImageSize,
- (bfd_byte *) dst->codeImageSize);
- bfd_h_put_32 (abfd, (bfd_vma) src->dataImageOffset,
- (bfd_byte *) dst->dataImageOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->dataImageSize,
- (bfd_byte *) dst->dataImageSize);
- bfd_h_put_32 (abfd, (bfd_vma) src->uninitializedDataSize,
- (bfd_byte *) dst->uninitializedDataSize);
- bfd_h_put_32 (abfd, (bfd_vma) src->customDataOffset,
- (bfd_byte *) dst->customDataOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->customDataSize,
- (bfd_byte *) dst->customDataSize);
- bfd_h_put_32 (abfd, (bfd_vma) src->moduleDependencyOffset,
- (bfd_byte *) dst->moduleDependencyOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfModuleDependencies,
- (bfd_byte *) dst->numberOfModuleDependencies);
- bfd_h_put_32 (abfd, (bfd_vma) src->relocationFixupOffset,
- (bfd_byte *) dst->relocationFixupOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfRelocationFixups,
- (bfd_byte *) dst->numberOfRelocationFixups);
- bfd_h_put_32 (abfd, (bfd_vma) src->externalReferencesOffset,
- (bfd_byte *) dst->externalReferencesOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfExternalReferences,
- (bfd_byte *) dst->numberOfExternalReferences);
- bfd_h_put_32 (abfd, (bfd_vma) src->publicsOffset,
- (bfd_byte *) dst->publicsOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfPublics,
- (bfd_byte *) dst->numberOfPublics);
- bfd_h_put_32 (abfd, (bfd_vma) src->debugInfoOffset,
- (bfd_byte *) dst->debugInfoOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfDebugRecords,
- (bfd_byte *) dst->numberOfDebugRecords);
- bfd_h_put_32 (abfd, (bfd_vma) src->codeStartOffset,
- (bfd_byte *) dst->codeStartOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->exitProcedureOffset,
- (bfd_byte *) dst->exitProcedureOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->checkUnloadProcedureOffset,
- (bfd_byte *) dst->checkUnloadProcedureOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->moduleType,
- (bfd_byte *) dst->moduleType);
- bfd_h_put_32 (abfd, (bfd_vma) src->flags,
- (bfd_byte *) dst->flags);
-}
diff --git a/contrib/gdb/bfd/ns32knetbsd.c b/contrib/gdb/bfd/ns32knetbsd.c
deleted file mode 100644
index 3e3f08a..0000000
--- a/contrib/gdb/bfd/ns32knetbsd.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* BFD back-end for NetBSD/ns32k a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-#undef TARGET_IS_BIG_ENDIAN_P
-
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE 4096
-
-#define DEFAULT_ARCH bfd_arch_ns32k
-#define MACHTYPE_OK(mtype) ((mtype) == M_532_NETBSD || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(pc532netbsd_,OP)
-
-#define NAME(x,y) CAT3(ns32kaout,_32_,y)
-
-/* This needs to start with a.out so GDB knows it is an a.out variant. */
-#define TARGETNAME "a.out-ns32k-netbsd"
-
-#define ns32kaout_32_get_section_contents aout_32_get_section_contents
-
-#define MY_text_includes_header 1
-
-/* We can`t use the MYNS macro here for cpp reasons too subtle
- * for me -- IWD
- */
-#define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
-
-#include "bfd.h" /* To ensure following declaration is OK */
-
-CONST struct reloc_howto_struct *
-MY_bfd_reloc_type_lookup
- PARAMS((bfd *abfd AND
- bfd_reloc_code_real_type code));
-
-
-#include "netbsd.h"
diff --git a/contrib/gdb/bfd/oasys.c b/contrib/gdb/bfd/oasys.c
deleted file mode 100644
index c721472..0000000
--- a/contrib/gdb/bfd/oasys.c
+++ /dev/null
@@ -1,1533 +0,0 @@
-/* BFD back-end for oasys objects.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define UNDERSCORE_HACK 1
-#include "bfd.h"
-#include "sysdep.h"
-#include <ctype.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
-
-static boolean oasys_read_record PARAMS ((bfd *,
- oasys_record_union_type *));
-static boolean oasys_write_sections PARAMS ((bfd *));
-static boolean oasys_write_record PARAMS ((bfd *,
- oasys_record_enum_type,
- oasys_record_union_type *,
- size_t));
-static boolean oasys_write_syms PARAMS ((bfd *));
-static boolean oasys_write_header PARAMS ((bfd *));
-static boolean oasys_write_end PARAMS ((bfd *));
-static boolean oasys_write_data PARAMS ((bfd *));
-
-/* Read in all the section data and relocation stuff too */
-PROTO (static boolean, oasys_slurp_section_data, (bfd * CONST abfd));
-
-static boolean
-oasys_read_record (abfd, record)
- bfd *abfd;
- oasys_record_union_type *record;
-{
- if (bfd_read ((PTR) record, 1, sizeof (record->header), abfd)
- != sizeof (record->header))
- return false;
-
- if ((size_t) record->header.length <= (size_t) sizeof (record->header))
- return true;
- if (bfd_read ((PTR) (((char *) record) + sizeof (record->header)),
- 1, record->header.length - sizeof (record->header),
- abfd)
- != record->header.length - sizeof (record->header))
- return false;
- return true;
-}
-static size_t
-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
-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
- if (!data->symbols || !data->strings)
- return false;
-
- dest_defined = data->symbols + abfd->symcount - 1;
-
- string_ptr = data->strings;
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- return false;
- while (loop)
- {
-
- if (! oasys_read_record (abfd, &record))
- return false;
- 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 == (int) 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 = bfd_abs_section_ptr;
- dest->flags = 0;
-
- break;
- case RELOCATION_TYPE_REL:
- dest = dest_defined--;
- dest->section =
- OASYS_DATA (abfd)->sections[record.symbol.relb &
- RELOCATION_SECT_BITS];
- if (record.header.type == (int) 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, record.symbol.refno);
- dest->section = bfd_und_section_ptr;
- break;
- case RELOCATION_TYPE_COM:
- dest = dest_defined--;
- dest->name = string_ptr;
- dest->the_bfd = abfd;
-
- dest->section = bfd_com_section_ptr;
-
- break;
- default:
- dest = dest_defined--;
- BFD_ASSERT (0);
- break;
- }
- dest->name = string_ptr;
- dest->the_bfd = abfd;
- dest->udata.p = (PTR) NULL;
- dest->value = bfd_h_get_32 (abfd, record.symbol.value);
-
-#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 long
-oasys_get_symtab_upper_bound (abfd)
- bfd *CONST abfd;
-{
- if (! oasys_slurp_symbol_table (abfd))
- return -1;
-
- return (abfd->symcount + 1) * (sizeof (oasys_symbol_type *));
-}
-
-/*
-*/
-
-extern const bfd_target oasys_vec;
-
-long
-oasys_get_symtab (abfd, location)
- bfd *abfd;
- asymbol **location;
-{
- asymbol *symbase;
- unsigned int counter;
- if (oasys_slurp_symbol_table (abfd) == false)
- {
- return -1;
- }
- symbase = OASYS_DATA (abfd)->symbols;
- for (counter = 0; counter < abfd->symcount; counter++)
- {
- *(location++) = symbase++;
- }
- *location = 0;
- return abfd->symcount;
-}
-
-/***********************************************************************
-* archive stuff
-*/
-
-static const bfd_target *
-oasys_archive_p (abfd)
- bfd *abfd;
-{
- oasys_archive_header_type header;
- oasys_extarchive_header_type header_ext;
- unsigned int i;
- file_ptr filepos;
-
- if (bfd_seek (abfd, (file_ptr) 0, false) != 0
- || (bfd_read ((PTR) & header_ext, 1, sizeof (header_ext), abfd)
- != sizeof (header_ext)))
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- header.version = bfd_h_get_32 (abfd, header_ext.version);
- header.mod_count = bfd_h_get_32 (abfd, header_ext.mod_count);
- header.mod_tbl_offset = bfd_h_get_32 (abfd, header_ext.mod_tbl_offset);
- header.sym_tbl_size = bfd_h_get_32 (abfd, header_ext.sym_tbl_size);
- header.sym_count = bfd_h_get_32 (abfd, header_ext.sym_count);
- header.sym_tbl_offset = bfd_h_get_32 (abfd, header_ext.sym_tbl_offset);
- header.xref_count = bfd_h_get_32 (abfd, header_ext.xref_count);
- header.xref_lst_offset = bfd_h_get_32 (abfd, 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 (const bfd_target *) NULL;
-
- /*
- That all worked, let's 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;
-
- if (!ar || !module)
- return NULL;
-
- abfd->tdata.oasys_ar_data = ar;
- ar->module = module;
- ar->module_count = header.mod_count;
-
- filepos = header.mod_tbl_offset;
- for (i = 0; i < header.mod_count; i++)
- {
- if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
- return NULL;
-
- /* There are two ways of specifying the archive header */
-
- if (0)
- {
- oasys_extmodule_table_type_a_type record_ext;
- if (bfd_read ((PTR) & record_ext, 1, sizeof (record_ext), abfd)
- != sizeof (record_ext))
- return NULL;
-
- record.mod_size = bfd_h_get_32 (abfd, record_ext.mod_size);
- record.file_offset = bfd_h_get_32 (abfd, record_ext.file_offset);
-
- record.dep_count = bfd_h_get_32 (abfd, record_ext.dep_count);
- record.depee_count = bfd_h_get_32 (abfd, record_ext.depee_count);
- record.sect_count = bfd_h_get_32 (abfd, record_ext.sect_count);
-
- module[i].name = bfd_alloc (abfd, 33);
- if (!module[i].name)
- return NULL;
-
- 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;
- if (bfd_read ((PTR) & record_ext, 1, sizeof (record_ext), abfd)
- != sizeof (record_ext))
- return NULL;
-
- record.mod_size = bfd_h_get_32 (abfd, record_ext.mod_size);
- record.file_offset = bfd_h_get_32 (abfd, record_ext.file_offset);
-
- record.dep_count = bfd_h_get_32 (abfd, record_ext.dep_count);
- record.depee_count = bfd_h_get_32 (abfd, record_ext.depee_count);
- record.sect_count = bfd_h_get_32 (abfd, record_ext.sect_count);
- record.module_name_size = bfd_h_get_32 (abfd, record_ext.mod_name_length);
-
- module[i].name = bfd_alloc (abfd, record.module_name_size + 1);
- if (!module[i].name)
- return NULL;
- if (bfd_read ((PTR) module[i].name, 1, record.module_name_size,
- abfd)
- != record.module_name_size)
- return NULL;
- 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
-oasys_mkobject (abfd)
- bfd *abfd;
-{
-
- abfd->tdata.oasys_obj_data = (oasys_data_type *) bfd_alloc (abfd, sizeof (oasys_data_type));
- return abfd->tdata.oasys_obj_data ? true : false;
-}
-
-#define MAX_SECS 16
-static const bfd_target *
-oasys_object_p (abfd)
- bfd *abfd;
-{
- oasys_data_type *oasys;
- oasys_data_type *save = OASYS_DATA (abfd);
- boolean loop = true;
- boolean had_usefull = false;
-
- abfd->tdata.oasys_obj_data = 0;
- oasys_mkobject (abfd);
- oasys = OASYS_DATA (abfd);
- memset ((PTR) oasys->sections, 0xff, sizeof (oasys->sections));
-
- /* Point to the start of the file */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto fail;
- 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;
- if (! oasys_read_record (abfd, &record))
- goto fail;
- 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);
- if (!buffer)
- goto fail;
- 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->_raw_size = bfd_h_get_32 (abfd, record.section.value);
- s->vma = bfd_h_get_32 (abfd, record.section.vma);
- 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
- */
- bfd_default_set_arch_mach (abfd, bfd_arch_m68k, 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);
- abfd->tdata.oasys_obj_data = save;
- return (const bfd_target *) NULL;
-}
-
-
-static void
-oasys_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
- if (!symbol->section)
- ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
-}
-
-static void
-oasys_print_symbol (ignore_abfd, afile, symbol, how)
- bfd *ignore_abfd;
- PTR afile;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) afile;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- case bfd_print_symbol_more:
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_all:
- {
- CONST char *section_name = symbol->section == (asection *) NULL ?
- (CONST char *) "*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, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO (0, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs32", true, 0xffffffff, 0xffffffff, false),
- HOWTO (0, 0, 1, 16, true, 0, complain_overflow_signed, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO (0, 0, 2, 32, true, 0, complain_overflow_signed, 0, "pcrel32", true, 0xffffffff, 0xffffffff, false)
-};
-
-/* Read in all the section data and relocation stuff too */
-static boolean
-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;
-
- if (bfd_seek (abfd, data->first_data_record, SEEK_SET) != 0)
- return false;
- while (loop)
- {
- if (! oasys_read_record (abfd, &record))
- return false;
- switch (record.header.type)
- {
- case oasys_record_is_header_enum:
- break;
- case oasys_record_is_data_enum:
- {
-
- bfd_byte *src = record.data.data;
- bfd_byte *end_src = ((bfd_byte *) & record) + record.header.length;
- bfd_byte *dst_ptr;
- bfd_byte *dst_base_ptr;
- unsigned int relbit;
- 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->_raw_size);
- if (!per->data)
- return false;
- 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)
- {
- unsigned char mod_byte = *src++;
- size_t 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)
- {
- unsigned char 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));
- if (!r)
- return false;
- *(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 */
- abort ();
-#if 0
- r->relent.section =
- data->sections[reloc &
- RELOCATION_SECT_BITS];
-
- r->relent.addend = -
- r->relent.section->vma;
-#endif
- 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));
- if (!r)
- return false;
- *(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 */
- abort ();
-
-#if 0
- r->relent.section = (asection
- *) NULL;
-#endif
- 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;
-
-}
-
-static boolean
-oasys_new_section_hook (abfd, newsect)
- bfd *abfd;
- asection *newsect;
-{
- newsect->used_by_bfd = (PTR)
- bfd_alloc (abfd, sizeof (oasys_per_section_type));
- if (!newsect->used_by_bfd)
- return false;
- 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 long
-oasys_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- if (! oasys_slurp_section_data (abfd))
- return -1;
- return (asect->reloc_count + 1) * sizeof (arelent *);
-}
-
-static boolean
-oasys_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- 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;
-}
-
-
-long
-oasys_canonicalize_reloc (ignore_abfd, section, relptr, symbols)
- bfd *ignore_abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- unsigned int reloc_count = 0;
- oasys_reloc_type *src = (oasys_reloc_type *) (section->relocation);
- while (src != (oasys_reloc_type *) NULL)
- {
- abort ();
-
-#if 0
- if (src->relent.section == (asection *) NULL)
- {
- src->relent.sym_ptr_ptr = symbols + src->symbol;
- }
-#endif
-
- *relptr++ = &src->relent;
- src = src->next;
- reloc_count++;
- }
- *relptr = (arelent *) NULL;
- return section->reloc_count = reloc_count;
-}
-
-
-
-
-/* Writing */
-
-
-/* Calculate the checksum and write one record */
-static boolean
-oasys_write_record (abfd, type, record, size)
- bfd *abfd;
- oasys_record_enum_type type;
- oasys_record_union_type *record;
- size_t size;
-{
- int checksum;
- size_t i;
- unsigned char *ptr;
-
- record->header.length = size;
- record->header.type = (int) type;
- record->header.check_sum = 0;
- record->header.fill = 0;
- ptr = (unsigned char *) &record->pad[0];
- checksum = 0;
- for (i = 0; i < size; i++)
- {
- checksum += *ptr++;
- }
- record->header.check_sum = 0xff & (-checksum);
- if (bfd_write ((PTR) record, 1, size, abfd) != size)
- return false;
- return true;
-}
-
-
-/* Write out all the symbols */
-static boolean
-oasys_write_syms (abfd)
- bfd *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 (bfd_is_com_section (g->section))
- {
- symbol.relb = RELOCATION_TYPE_COM;
- bfd_h_put_16 (abfd, index, symbol.refno);
- index++;
- }
- else if (bfd_is_abs_section (g->section))
- {
- symbol.relb = RELOCATION_TYPE_ABS;
- bfd_h_put_16 (abfd, 0, symbol.refno);
-
- }
- else if (bfd_is_und_section (g->section))
- {
- symbol.relb = RELOCATION_TYPE_UND;
- bfd_h_put_16 (abfd, index, symbol.refno);
- /* 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, symbol.refno);
- }
-#ifdef UNDERSCORE_HACK
- if (src[l] == '_')
- dst[l++] = '.';
-#endif
- while (src[l])
- {
- dst[l] = src[l];
- l++;
- }
-
- bfd_h_put_32 (abfd, g->value, symbol.value);
-
-
- if (g->flags & BSF_LOCAL)
- {
- if (! oasys_write_record (abfd,
- oasys_record_is_local_enum,
- (oasys_record_union_type *) & symbol,
- offsetof (oasys_symbol_record_type,
- name[0]) + l))
- return false;
- }
- else
- {
- if (! oasys_write_record (abfd,
- oasys_record_is_symbol_enum,
- (oasys_record_union_type *) & symbol,
- offsetof (oasys_symbol_record_type,
- name[0]) + l))
- return false;
- }
- g->value = index - 1;
- }
-
- return true;
-}
-
-
- /* Write a section header for each section */
-static boolean
-oasys_write_sections (abfd)
- bfd *abfd;
-{
- asection *s;
- static oasys_section_record_type out;
-
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- if (!isdigit (s->name[0]))
- {
- (*_bfd_error_handler)
- ("%s: can not represent section `%s' in oasys",
- bfd_get_filename (abfd), s->name);
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
- out.relb = RELOCATION_TYPE_REL | s->target_index;
- bfd_h_put_32 (abfd, s->_cooked_size, out.value);
- bfd_h_put_32 (abfd, s->vma, out.vma);
-
- if (! oasys_write_record (abfd,
- oasys_record_is_section_enum,
- (oasys_record_union_type *) & out,
- sizeof (out)))
- return false;
- }
- return true;
-}
-
-static boolean
-oasys_write_header (abfd)
- bfd *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;
- if (! oasys_write_record (abfd,
- oasys_record_is_header_enum,
- (oasys_record_union_type *) & r,
- offsetof (oasys_header_record_type,
- description[0])))
- return false;
-
- return true;
-}
-
-static boolean
-oasys_write_end (abfd)
- bfd *abfd;
-{
- oasys_end_record_type end;
- unsigned char null = 0;
- end.relb = RELOCATION_TYPE_ABS;
- bfd_h_put_32 (abfd, abfd->start_address, end.entry);
- bfd_h_put_16 (abfd, 0, end.fill);
- end.zero = 0;
- if (! oasys_write_record (abfd,
- oasys_record_is_end_enum,
- (oasys_record_union_type *) & end,
- sizeof (end)))
- return false;
- if (bfd_write ((PTR) & null, 1, 1, abfd) != 1)
- return false;
- return true;
-}
-
-static int
-comp (ap, bp)
- CONST PTR ap;
- CONST PTR bp;
-{
- arelent *a = *((arelent **) ap);
- arelent *b = *((arelent **) bp);
- return a->address - b->address;
-}
-
-/*
- Writing data..
-
-*/
-static boolean
-oasys_write_data (abfd)
- bfd *abfd;
-{
- asection *s;
- for (s = abfd->sections; s != (asection *) NULL; s = s->next)
- {
- if (s->flags & SEC_LOAD)
- {
- bfd_byte *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->_cooked_size)
- {
- /* Scan forwards by eight bytes or however much is left and see if
- there are any relocations going on */
- bfd_byte *mod = &processed_data.data[0];
- bfd_byte *dst = &processed_data.data[1];
-
- unsigned int i = 0;
- *mod = 0;
-
-
- bfd_h_put_32 (abfd, s->vma + current_byte_index,
- processed_data.addr);
-
- /* Don't start a relocation unless you're sure you can finish it
- within the same data record. The worst case relocation is a
- 4-byte relocatable value which is split across two modification
- bytes (1 relocation byte + 2 symbol reference bytes + 2 data +
- 1 modification byte + 2 data = 8 bytes total). That's where
- the magic number 8 comes from.
- */
- while (current_byte_index < s->_raw_size && dst <=
- &processed_data.data[sizeof (processed_data.data) - 8])
- {
-
-
- 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)
- {
- unsigned char rel_byte;
-
- p++;
- relocs_to_go--;
-
- *mod |= (1 << i);
- if (how->pc_relative)
- {
- rel_byte = RELOCATION_PCREL_BIT;
-
- /* 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 |= RELOCATION_32BIT_BIT;
- }
-
- /* Is this a section relative relocation, or a symbol
- relative relocation ? */
- abort ();
-
-#if 0
- 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
-#endif
- {
- 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;
- }
- }
-#define ADVANCE { if (++i >= 8) { i = 0; mod = dst++; *mod = 0; } current_byte_index++; }
- /* relocations never occur from an unloadable section,
- so we can assume that raw_data is not NULL
- */
- *dst++ = *raw_data++;
- ADVANCE
- * dst++ = *raw_data++;
- ADVANCE
- if (how->size == 2)
- {
- *dst++ = *raw_data++;
- ADVANCE
- * dst++ = *raw_data++;
- ADVANCE
- }
- continue;
- }
- }
- /* If this is coming from an unloadable section then copy
- zeros */
- if (raw_data == NULL)
- {
- *dst++ = 0;
- }
- else
- {
- *dst++ = *raw_data++;
- }
- ADVANCE
- }
-
- /* Don't write a useless null modification byte */
- if (dst == mod + 1)
- {
- --dst;
- }
-
- if (! oasys_write_record (abfd,
- oasys_record_is_data_enum,
- ((oasys_record_union_type *)
- & processed_data),
- dst - (bfd_byte *) & processed_data))
- return false;
- }
- }
- }
-
- return true;
-}
-
-static boolean
-oasys_write_object_contents (abfd)
- bfd *abfd;
-{
- if (! oasys_write_header (abfd))
- return false;
- if (! oasys_write_syms (abfd))
- return false;
- if (! oasys_write_sections (abfd))
- return false;
- if (! oasys_write_data (abfd))
- return false;
- if (! oasys_write_end (abfd))
- return false;
- 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
-oasys_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- 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->_cooked_size));
- if (!oasys_per_section (section)->data)
- return false;
- }
- (void) memcpy ((PTR) (oasys_per_section (section)->data + offset),
- location,
- (size_t) 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 *
-oasys_make_empty_symbol (abfd)
- bfd *abfd;
-{
-
- oasys_symbol_type *new =
- (oasys_symbol_type *) bfd_zalloc (abfd, sizeof (oasys_symbol_type));
- if (!new)
- return NULL;
- 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_set_error (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
-oasys_generic_stat_arch_elt (abfd, buf)
- bfd *abfd;
- struct stat *buf;
-{
- oasys_module_info_type *mod = (oasys_module_info_type *) abfd->arelt_data;
- if (mod == (oasys_module_info_type *) NULL)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return -1;
- }
- else
- {
- buf->st_size = mod->size;
- buf->st_mode = 0666;
- return 0;
- }
-}
-
-static int
-oasys_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-#define oasys_close_and_cleanup _bfd_generic_close_and_cleanup
-#define oasys_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-
-#define oasys_slurp_armap bfd_true
-#define oasys_slurp_extended_name_table bfd_true
-#define oasys_construct_extended_name_table \
- ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
- bfd_true)
-#define oasys_truncate_arname bfd_dont_truncate_arname
-#define oasys_write_armap \
- ((boolean (*) \
- PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
- bfd_true)
-#define oasys_read_ar_hdr bfd_nullvoidptr
-#define oasys_get_elt_at_index _bfd_generic_get_elt_at_index
-#define oasys_update_armap_timestamp bfd_true
-
-#define oasys_bfd_is_local_label bfd_generic_is_local_label
-#define oasys_get_lineno _bfd_nosymbols_get_lineno
-#define oasys_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define oasys_read_minisymbols _bfd_generic_read_minisymbols
-#define oasys_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define oasys_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-#define oasys_set_arch_mach bfd_default_set_arch_mach
-
-#define oasys_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-#define oasys_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define oasys_bfd_relax_section bfd_generic_relax_section
-#define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define oasys_bfd_final_link _bfd_generic_final_link
-#define oasys_bfd_link_split_section _bfd_generic_link_split_section
-
-/*SUPPRESS 460 */
-const bfd_target oasys_vec =
-{
- "oasys", /* name */
- bfd_target_oasys_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIAN_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
- | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target,
- 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,
- },
-
- BFD_JUMP_TABLE_GENERIC (oasys),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (oasys),
- BFD_JUMP_TABLE_SYMBOLS (oasys),
- BFD_JUMP_TABLE_RELOCS (oasys),
- BFD_JUMP_TABLE_WRITE (oasys),
- BFD_JUMP_TABLE_LINK (oasys),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/osf-core.c b/contrib/gdb/bfd/osf-core.c
deleted file mode 100644
index 6d1df9b..0000000
--- a/contrib/gdb/bfd/osf-core.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* BFD back-end for OSF/1 core files.
- Copyright 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file can only be compiled on systems which use OSF/1 style
- core files. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/user.h>
-#include <sys/core.h>
-
-/* forward declarations */
-
-static asection *
-make_bfd_asection PARAMS ((bfd *, CONST char *, flagword, bfd_size_type,
- bfd_vma, file_ptr));
-static asymbol *
-osf_core_make_empty_symbol PARAMS ((bfd *));
-static const bfd_target *
-osf_core_core_file_p PARAMS ((bfd *));
-static char *
-osf_core_core_file_failing_command PARAMS ((bfd *));
-static int
-osf_core_core_file_failing_signal PARAMS ((bfd *));
-static boolean
-osf_core_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
-static void
-swap_abort PARAMS ((void));
-
-/* These are stored in the bfd's tdata */
-
-struct osf_core_struct
-{
- int sig;
- char cmd[MAXCOMLEN + 1];
-};
-
-#define core_hdr(bfd) ((bfd)->tdata.osf_core_data)
-#define core_signal(bfd) (core_hdr(bfd)->sig)
-#define core_command(bfd) (core_hdr(bfd)->cmd)
-
-static asection *
-make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
- bfd *abfd;
- CONST char *name;
- flagword flags;
- bfd_size_type _raw_size;
- bfd_vma vma;
- file_ptr filepos;
-{
- asection *asect;
-
- asect = bfd_make_section_anyway (abfd, name);
- if (!asect)
- return NULL;
-
- asect->flags = flags;
- asect->_raw_size = _raw_size;
- asect->vma = vma;
- asect->filepos = filepos;
- asect->alignment_power = 8;
-
- return asect;
-}
-
-static asymbol *
-osf_core_make_empty_symbol (abfd)
- bfd *abfd;
-{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
- if (new)
- new->the_bfd = abfd;
- return new;
-}
-
-static const bfd_target *
-osf_core_core_file_p (abfd)
- bfd *abfd;
-{
- int val;
- int i;
- char *secname;
- struct core_filehdr core_header;
-
- val = bfd_read ((PTR)&core_header, 1, sizeof core_header, abfd);
- if (val != sizeof core_header)
- return NULL;
-
- if (strncmp (core_header.magic, "Core", 4) != 0)
- return NULL;
-
- core_hdr (abfd) = (struct osf_core_struct *)
- bfd_zalloc (abfd, sizeof (struct osf_core_struct));
- if (!core_hdr (abfd))
- return NULL;
-
- strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1);
- core_signal (abfd) = core_header.signo;
-
- for (i = 0; i < core_header.nscns; i++)
- {
- struct core_scnhdr core_scnhdr;
- flagword flags;
-
- val = bfd_read ((PTR)&core_scnhdr, 1, sizeof core_scnhdr, abfd);
- if (val != sizeof core_scnhdr)
- break;
-
- /* Skip empty sections. */
- if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0)
- continue;
-
- switch (core_scnhdr.scntype)
- {
- case SCNRGN:
- secname = ".data";
- flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
- break;
- case SCNSTACK:
- secname = ".stack";
- flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
- break;
- case SCNREGS:
- secname = ".reg";
- flags = SEC_HAS_CONTENTS;
- break;
- default:
- (*_bfd_error_handler) ("Unhandled OSF/1 core file section type %d\n",
- core_scnhdr.scntype);
- continue;
- }
-
- if (!make_bfd_asection (abfd, secname, flags,
- (bfd_size_type) core_scnhdr.size,
- (bfd_vma) core_scnhdr.vaddr,
- (file_ptr) core_scnhdr.scnptr))
- return NULL;
- }
-
- /* OK, we believe you. You're a core file (sure, sure). */
-
- return abfd->xvec;
-}
-
-static char *
-osf_core_core_file_failing_command (abfd)
- bfd *abfd;
-{
- return core_command (abfd);
-}
-
-/* ARGSUSED */
-static int
-osf_core_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return core_signal (abfd);
-}
-
-/* ARGSUSED */
-static boolean
-osf_core_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 */
-}
-
-#define osf_core_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
-#define osf_core_get_symtab _bfd_nosymbols_get_symtab
-#define osf_core_print_symbol _bfd_nosymbols_print_symbol
-#define osf_core_get_symbol_info _bfd_nosymbols_get_symbol_info
-#define osf_core_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
-#define osf_core_get_lineno _bfd_nosymbols_get_lineno
-#define osf_core_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define osf_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define osf_core_read_minisymbols _bfd_nosymbols_read_minisymbols
-#define osf_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
-
-/* If somebody calls any byte-swapping routines, shoot them. */
-static void
-swap_abort()
-{
- abort(); /* This way doesn't require any declaration for ANSI to fuck up */
-}
-#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
-#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
-#define NO_SIGNED_GET \
- ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-
-const bfd_target osf_core_vec =
- {
- "osf-core",
- bfd_target_unknown_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIAN_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* symbol prefix */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
-
- { /* bfd_check_format */
- _bfd_dummy_target, /* unknown format */
- _bfd_dummy_target, /* object file */
- _bfd_dummy_target, /* archive */
- osf_core_core_file_p /* a core file */
- },
- { /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
- { /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (osf_core),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (osf_core),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0 /* backend_data */
-};
diff --git a/contrib/gdb/bfd/pc532-mach.c b/contrib/gdb/bfd/pc532-mach.c
deleted file mode 100644
index 73f4ac4..0000000
--- a/contrib/gdb/bfd/pc532-mach.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* BFD back-end for Mach3/532 a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Written by Ian Dall
- * 19-Apr-94
- *
- * Formerly part of aout-pc532-mach.c. Split out to allow more
- * flexibility with multiple formats.
- *
- */
-/* This architecture has N_TXTOFF and N_TXTADDR defined as if
- * N_HEADER_IN_TEXT, but the a_text entry (text size) does not include the
- * space for the header. So we have N_HEADER_IN_TEXT defined to
- * 1 and specially define our own N_TXTSIZE
- */
-
-#define N_HEADER_IN_TEXT(x) 1
-#define N_TXTSIZE(x) ((x).a_text)
-
-
-#define TEXT_START_ADDR 0x10000 /* from old ld */
-#define TARGET_PAGE_SIZE 0x1000 /* from old ld, 032 & 532 are really 512/4k */
-
-/* Use a_entry of 0 to distinguish object files from OMAGIC executables */
-#define N_TXTADDR(x) \
- (N_MAGIC(x) == OMAGIC ? \
- ((x).a_entry < TEXT_START_ADDR? 0: TEXT_START_ADDR): \
- (N_MAGIC(x) == NMAGIC? TEXT_START_ADDR: \
- TEXT_START_ADDR + EXEC_BYTES_SIZE))
-
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-
-#define N_SHARED_LIB(x) 0
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define DEFAULT_ARCH bfd_arch_ns32k
-
-#define MY(OP) CAT(pc532machaout_,OP)
-
-/* Must be the same as aout-ns32k.c */
-#define NAME(x,y) CAT3(ns32kaout,_32_,y)
-
-#define TARGETNAME "a.out-pc532-mach"
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libaout.h"
-#include "libbfd.h"
-#include "aout/aout64.h"
-
-/* We can`t use the MYNS macro here for cpp reasons too subtle for me -- IWD */
-
-#define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
-
-/* libaout doesn't use NAME for these ... */
-
-#define MY_get_section_contents aout_32_get_section_contents
-
-#define MY_text_includes_header 1
-
-#define MY_exec_header_not_counted 1
-
-#define MYNSX(OP) CAT(ns32kaout_,OP)
-reloc_howto_type *
-MYNSX(bfd_reloc_type_lookup)
- PARAMS((bfd *abfd AND
- bfd_reloc_code_real_type code));
-
-boolean
-MYNSX(write_object_contents)
- PARAMS((bfd *abfd));
-
-static boolean
-MY(write_object_contents) (abfd)
-bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
-#if CHOOSE_RELOC_SIZE
- CHOOSE_RELOC_SIZE(abfd);
-#else
- obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
-#endif
-
- BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_ns32k);
- switch (bfd_get_mach (abfd))
- {
- case 32032:
- N_SET_MACHTYPE (*execp, M_NS32032);
- break;
- case 32532:
- default:
- N_SET_MACHTYPE (*execp, M_NS32532);
- break;
- }
- N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
-
- WRITE_HEADERS(abfd, execp);
-
- return true;
-}
-
-#define MY_write_object_contents MY(write_object_contents)
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/pe-arm.c b/contrib/gdb/bfd/pe-arm.c
deleted file mode 100644
index fa97e2e..0000000
--- a/contrib/gdb/bfd/pe-arm.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* BFD back-end for ARM PECOFF files.
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#define TARGET_LITTLE_SYM armpe_little_vec
-#define TARGET_LITTLE_NAME "pe-arm-little"
-#define TARGET_BIG_SYM armpe_big_vec
-#define TARGET_BIG_NAME "pe-arm-big"
-
-#define COFF_OBJ_WITH_PE
-#define COFF_WITH_PE
-#define PCRELOFFSET true
-
-#include "coff-arm.c"
diff --git a/contrib/gdb/bfd/pe-i386.c b/contrib/gdb/bfd/pe-i386.c
deleted file mode 100644
index 878993e..0000000
--- a/contrib/gdb/bfd/pe-i386.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* BFD back-end for Intel 386 PECOFF files.
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-
-
-#define TARGET_SYM i386pe_vec
-#define TARGET_NAME "pe-i386"
-#define COFF_OBJ_WITH_PE
-#define COFF_WITH_PE
-#define PCRELOFFSET true
-#define TARGET_UNDERSCORE '_'
-#include "coff-i386.c"
diff --git a/contrib/gdb/bfd/pe-ppc.c b/contrib/gdb/bfd/pe-ppc.c
deleted file mode 100644
index 67fdda0..0000000
--- a/contrib/gdb/bfd/pe-ppc.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* BFD back-end for Intel 386 PECOFF files.
- Copyright 1995 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. */
-
-#include "bfd.h"
-#include "sysdep.h"
-
-
-#define E_FILENMLEN 18
-
-#define PPC
-
-#define TARGET_LITTLE_SYM bfd_powerpcle_pe_vec
-#define TARGET_LITTLE_NAME "pe-powerpcle"
-
-#define TARGET_BIG_SYM bfd_powerpc_pe_vec
-#define TARGET_BIG_NAME "pe-powerpc"
-
-#define COFF_OBJ_WITH_PE
-#define COFF_WITH_PE
-
-/* FIXME: verify PCRELOFFSET is always false */
-
-#include "coff-ppc.c"
diff --git a/contrib/gdb/bfd/pei-arm.c b/contrib/gdb/bfd/pei-arm.c
deleted file mode 100644
index fd9d398..0000000
--- a/contrib/gdb/bfd/pei-arm.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* BFD back-end for arm PE IMAGE COFF files.
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#define TARGET_LITTLE_SYM armpei_little_vec
-#define TARGET_LITTLE_NAME "pei-arm-little"
-#define TARGET_BIG_SYM armpei_big_vec
-#define TARGET_BIG_NAME "pei-arm-big"
-
-#define IMAGE_BASE NT_IMAGE_BASE
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define PCRELOFFSET true
-
-#include "coff-arm.c"
diff --git a/contrib/gdb/bfd/pei-i386.c b/contrib/gdb/bfd/pei-i386.c
deleted file mode 100644
index 8754e7c..0000000
--- a/contrib/gdb/bfd/pei-i386.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* BFD back-end for Intel 386 PE IMAGE COFF files.
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#define TARGET_SYM i386pei_vec
-#define TARGET_NAME "pei-i386"
-#define IMAGE_BASE NT_IMAGE_BASE
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define PCRELOFFSET true
-#define TARGET_UNDERSCORE '_'
-#include "coff-i386.c"
-
-
-
diff --git a/contrib/gdb/bfd/pei-ppc.c b/contrib/gdb/bfd/pei-ppc.c
deleted file mode 100644
index fc8f89f..0000000
--- a/contrib/gdb/bfd/pei-ppc.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* BFD back-end for Intel 386 PE IMAGE COFF files.
- Copyright 1995 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. */
-
-#include "bfd.h"
-#include "sysdep.h"
-
-/* setting up for a PE environment stolen directly from the i386 structure */
-#define E_FILNMLEN 18 /* # characters in a file name */
-
-#define PPC
-
-#define TARGET_LITTLE_SYM bfd_powerpcle_pei_vec
-#define TARGET_LITTLE_NAME "pei-powerpcle"
-
-#define TARGET_BIG_SYM bfd_powerpc_pei_vec
-#define TARGET_BIG_NAME "pei-powerpc"
-
-#define IMAGE_BASE NT_IMAGE_BASE
-
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-
-/* FIXME: Verify PCRELOFFSET is always false */
-
-#include "coff-ppc.c"
-
-
-
diff --git a/contrib/gdb/bfd/peicode.h b/contrib/gdb/bfd/peicode.h
deleted file mode 100644
index a7a4746..0000000
--- a/contrib/gdb/bfd/peicode.h
+++ /dev/null
@@ -1,1861 +0,0 @@
-/* Support for the generic parts of most COFF variants, for BFD.
- Copyright 1995 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-Most of this hacked by Steve Chamberlain,
- sac@cygnus.com
-*/
-
-
-
-#define coff_bfd_print_private_bfd_data pe_print_private_bfd_data
-#define coff_mkobject pe_mkobject
-#define coff_mkobject_hook pe_mkobject_hook
-
-#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) bfd_h_put_32(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) bfd_h_put_32(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_LINENO_LNNO
-#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
-#endif
-
-/* The f_symptr field in the filehdr is sometimes 64 bits. */
-#ifndef GET_FILEHDR_SYMPTR
-#define GET_FILEHDR_SYMPTR bfd_h_get_32
-#endif
-#ifndef PUT_FILEHDR_SYMPTR
-#define PUT_FILEHDR_SYMPTR bfd_h_put_32
-#endif
-
-/* Some fields in the aouthdr are sometimes 64 bits. */
-#ifndef GET_AOUTHDR_TSIZE
-#define GET_AOUTHDR_TSIZE bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_TSIZE
-#define PUT_AOUTHDR_TSIZE bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_DSIZE
-#define GET_AOUTHDR_DSIZE bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_DSIZE
-#define PUT_AOUTHDR_DSIZE bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_BSIZE
-#define GET_AOUTHDR_BSIZE bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_BSIZE
-#define PUT_AOUTHDR_BSIZE bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_ENTRY
-#define GET_AOUTHDR_ENTRY bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_ENTRY
-#define PUT_AOUTHDR_ENTRY bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_TEXT_START
-#define GET_AOUTHDR_TEXT_START bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_TEXT_START
-#define PUT_AOUTHDR_TEXT_START bfd_h_put_32
-#endif
-#ifndef GET_AOUTHDR_DATA_START
-#define GET_AOUTHDR_DATA_START bfd_h_get_32
-#endif
-#ifndef PUT_AOUTHDR_DATA_START
-#define PUT_AOUTHDR_DATA_START bfd_h_put_32
-#endif
-
-/* Some fields in the scnhdr are sometimes 64 bits. */
-#ifndef GET_SCNHDR_PADDR
-#define GET_SCNHDR_PADDR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_PADDR
-#define PUT_SCNHDR_PADDR bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_VADDR
-#define GET_SCNHDR_VADDR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_VADDR
-#define PUT_SCNHDR_VADDR bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_SIZE
-#define GET_SCNHDR_SIZE bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_SIZE
-#define PUT_SCNHDR_SIZE bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_SCNPTR
-#define GET_SCNHDR_SCNPTR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_SCNPTR
-#define PUT_SCNHDR_SCNPTR bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_RELPTR
-#define GET_SCNHDR_RELPTR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_RELPTR
-#define PUT_SCNHDR_RELPTR bfd_h_put_32
-#endif
-#ifndef GET_SCNHDR_LNNOPTR
-#define GET_SCNHDR_LNNOPTR bfd_h_get_32
-#endif
-#ifndef PUT_SCNHDR_LNNOPTR
-#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
-#endif
-
-
-
-/**********************************************************************/
-
-static void
-coff_swap_reloc_in (abfd, src, dst)
- bfd *abfd;
- PTR src;
- PTR dst;
-{
- RELOC *reloc_src = (RELOC *) src;
- struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
-
- reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
- reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
-
- reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
-
-#ifdef SWAP_IN_RELOC_OFFSET
- reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
- (bfd_byte *) reloc_src->r_offset);
-#endif
-}
-
-
-static unsigned int
-coff_swap_reloc_out (abfd, src, dst)
- bfd *abfd;
- PTR src;
- 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);
-
-#ifdef SWAP_OUT_RELOC_OFFSET
- SWAP_OUT_RELOC_OFFSET(abfd,
- reloc_src->r_offset,
- (bfd_byte *) reloc_dst->r_offset);
-#endif
-#ifdef SWAP_OUT_RELOC_EXTRA
- SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
-#endif
- return sizeof(struct external_reloc);
-}
-
-
-static void
-coff_swap_filehdr_in (abfd, src, dst)
- bfd *abfd;
- PTR src;
- PTR dst;
-{
- FILHDR *filehdr_src = (FILHDR *) src;
- struct internal_filehdr *filehdr_dst = (struct internal_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_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
- filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
- filehdr_dst->f_symptr = bfd_h_get_32 (abfd, (bfd_byte *) filehdr_src->f_symptr);
-
- /* Other people's tools sometimes generate headers
- with an nsyms but a zero symptr. */
- if (filehdr_dst->f_nsyms && filehdr_dst->f_symptr)
- {
- filehdr_dst->f_flags |= HAS_SYMS;
- }
- else
- {
- filehdr_dst->f_symptr = 0;
- filehdr_dst->f_nsyms = 0;
- filehdr_dst->f_flags &= ~HAS_SYMS;
- }
-
- filehdr_dst->f_opthdr = bfd_h_get_16(abfd,
- (bfd_byte *)filehdr_src-> f_opthdr);
-}
-
-#ifdef COFF_IMAGE_WITH_PE
-
-static unsigned int
-coff_swap_filehdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
-{
- int idx;
- struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
- FILHDR *filehdr_out = (FILHDR *)out;
-
- if (pe_data (abfd)->has_reloc_section)
- filehdr_in->f_flags &= ~F_RELFLG;
-
- if (pe_data (abfd)->dll)
- filehdr_in->f_flags |= F_DLL;
-
- filehdr_in->pe.e_magic = DOSMAGIC;
- filehdr_in->pe.e_cblp = 0x90;
- filehdr_in->pe.e_cp = 0x3;
- filehdr_in->pe.e_crlc = 0x0;
- filehdr_in->pe.e_cparhdr = 0x4;
- filehdr_in->pe.e_minalloc = 0x0;
- filehdr_in->pe.e_maxalloc = 0xffff;
- filehdr_in->pe.e_ss = 0x0;
- filehdr_in->pe.e_sp = 0xb8;
- filehdr_in->pe.e_csum = 0x0;
- filehdr_in->pe.e_ip = 0x0;
- filehdr_in->pe.e_cs = 0x0;
- filehdr_in->pe.e_lfarlc = 0x40;
- filehdr_in->pe.e_ovno = 0x0;
-
- for (idx=0; idx < 4; idx++)
- filehdr_in->pe.e_res[idx] = 0x0;
-
- filehdr_in->pe.e_oemid = 0x0;
- filehdr_in->pe.e_oeminfo = 0x0;
-
- for (idx=0; idx < 10; idx++)
- filehdr_in->pe.e_res2[idx] = 0x0;
-
- filehdr_in->pe.e_lfanew = 0x80;
-
- /* this next collection of data are mostly just characters. It appears
- to be constant within the headers put on NT exes */
- filehdr_in->pe.dos_message[0] = 0x0eba1f0e;
- filehdr_in->pe.dos_message[1] = 0xcd09b400;
- filehdr_in->pe.dos_message[2] = 0x4c01b821;
- filehdr_in->pe.dos_message[3] = 0x685421cd;
- filehdr_in->pe.dos_message[4] = 0x70207369;
- filehdr_in->pe.dos_message[5] = 0x72676f72;
- filehdr_in->pe.dos_message[6] = 0x63206d61;
- filehdr_in->pe.dos_message[7] = 0x6f6e6e61;
- filehdr_in->pe.dos_message[8] = 0x65622074;
- filehdr_in->pe.dos_message[9] = 0x6e757220;
- filehdr_in->pe.dos_message[10] = 0x206e6920;
- filehdr_in->pe.dos_message[11] = 0x20534f44;
- filehdr_in->pe.dos_message[12] = 0x65646f6d;
- filehdr_in->pe.dos_message[13] = 0x0a0d0d2e;
- filehdr_in->pe.dos_message[14] = 0x24;
- filehdr_in->pe.dos_message[15] = 0x0;
- filehdr_in->pe.nt_signature = NT_SIGNATURE;
-
-
-
- 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, time (0), (bfd_byte *) filehdr_out->f_timdat);
- PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) 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);
-
- /* put in extra dos header stuff. This data remains essentially
- constant, it just has to be tacked on to the beginning of all exes
- for NT */
- bfd_h_put_16(abfd, filehdr_in->pe.e_magic, (bfd_byte *) filehdr_out->e_magic);
- bfd_h_put_16(abfd, filehdr_in->pe.e_cblp, (bfd_byte *) filehdr_out->e_cblp);
- bfd_h_put_16(abfd, filehdr_in->pe.e_cp, (bfd_byte *) filehdr_out->e_cp);
- bfd_h_put_16(abfd, filehdr_in->pe.e_crlc, (bfd_byte *) filehdr_out->e_crlc);
- bfd_h_put_16(abfd, filehdr_in->pe.e_cparhdr,
- (bfd_byte *) filehdr_out->e_cparhdr);
- bfd_h_put_16(abfd, filehdr_in->pe.e_minalloc,
- (bfd_byte *) filehdr_out->e_minalloc);
- bfd_h_put_16(abfd, filehdr_in->pe.e_maxalloc,
- (bfd_byte *) filehdr_out->e_maxalloc);
- bfd_h_put_16(abfd, filehdr_in->pe.e_ss, (bfd_byte *) filehdr_out->e_ss);
- bfd_h_put_16(abfd, filehdr_in->pe.e_sp, (bfd_byte *) filehdr_out->e_sp);
- bfd_h_put_16(abfd, filehdr_in->pe.e_csum, (bfd_byte *) filehdr_out->e_csum);
- bfd_h_put_16(abfd, filehdr_in->pe.e_ip, (bfd_byte *) filehdr_out->e_ip);
- bfd_h_put_16(abfd, filehdr_in->pe.e_cs, (bfd_byte *) filehdr_out->e_cs);
- bfd_h_put_16(abfd, filehdr_in->pe.e_lfarlc, (bfd_byte *) filehdr_out->e_lfarlc);
- bfd_h_put_16(abfd, filehdr_in->pe.e_ovno, (bfd_byte *) filehdr_out->e_ovno);
- {
- int idx;
- for (idx=0; idx < 4; idx++)
- bfd_h_put_16(abfd, filehdr_in->pe.e_res[idx],
- (bfd_byte *) filehdr_out->e_res[idx]);
- }
- bfd_h_put_16(abfd, filehdr_in->pe.e_oemid, (bfd_byte *) filehdr_out->e_oemid);
- bfd_h_put_16(abfd, filehdr_in->pe.e_oeminfo,
- (bfd_byte *) filehdr_out->e_oeminfo);
- {
- int idx;
- for (idx=0; idx < 10; idx++)
- bfd_h_put_16(abfd, filehdr_in->pe.e_res2[idx],
- (bfd_byte *) filehdr_out->e_res2[idx]);
- }
- bfd_h_put_32(abfd, filehdr_in->pe.e_lfanew, (bfd_byte *) filehdr_out->e_lfanew);
-
- {
- int idx;
- for (idx=0; idx < 16; idx++)
- bfd_h_put_32(abfd, filehdr_in->pe.dos_message[idx],
- (bfd_byte *) filehdr_out->dos_message[idx]);
- }
-
- /* also put in the NT signature */
- bfd_h_put_32(abfd, filehdr_in->pe.nt_signature,
- (bfd_byte *) filehdr_out->nt_signature);
-
-
-
-
- return sizeof(FILHDR);
-}
-#else
-
-static unsigned int
-coff_swap_filehdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- 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);
- PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) 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);
-}
-
-#endif
-
-
-static void
-coff_swap_sym_in (abfd, ext1, in1)
- bfd *abfd;
- PTR ext1;
- 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);
-
- /* The section symbols for the .idata$ sections have class 68, which MS
- documentation indicates is a section symbol. The problem is that the
- value field in the symbol is simply a copy of the .idata section's flags
- rather than something useful. When these symbols are encountered, change
- the value to 0 and the section number to 1 so that they will be handled
- somewhat correctly in the bfd code. */
- if (in->n_sclass == 0x68) {
- in->n_value = 0x0;
- in->n_scnum = 1;
- /* I have tried setting the class to 3 and using the following to set
- the section number. This will put the address of the pointer to the
- string kernel32.dll at addresses 0 and 0x10 off start of idata section
- which is not correct */
- /* if (strcmp (in->_n._n_name, ".idata$4") == 0) */
- /* in->n_scnum = 3; */
- /* else */
- /* in->n_scnum = 2; */
- }
-
-#ifdef coff_swap_sym_in_hook
- coff_swap_sym_in_hook(abfd, ext1, in1);
-#endif
-}
-
-static unsigned int
-coff_swap_sym_out (abfd, inp, extp)
- bfd *abfd;
- PTR inp;
- 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
-coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
- bfd *abfd;
- PTR ext1;
- int type;
- int class;
- int indx;
- int numaux;
- 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
- }
- return;
-
-
- 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);
- return;
- }
- break;
- }
-
- 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 (class == C_BLOCK || ISFCN (type) || ISTAG (class))
- {
- 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);
- }
- else
- {
-#if DIMNUM != E_DIMNUM
- #error we need to cope with truncating or extending DIMNUM
-#endif
- 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]);
- }
-
- 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
-coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
- bfd *abfd;
- PTR inp;
- int type;
- int class;
- int indx;
- int numaux;
- PTR extp;
-{
- union internal_auxent *in = (union internal_auxent *)inp;
- AUXENT *ext = (AUXENT *)extp;
-
- memset((PTR)ext, 0, AUXESZ);
- switch (class) {
- case C_FILE:
- if (in->x_file.x_fname[0] == 0) {
- bfd_h_put_32(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
- bfd_h_put_32(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
- }
- return sizeof (AUXENT);
-
-
- 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);
- return sizeof (AUXENT);
- }
- break;
- }
-
- bfd_h_put_32(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
-#ifndef NO_TVNDX
- bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
-#endif
-
- if (class == C_BLOCK || ISFCN (type) || ISTAG (class))
- {
- 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 DIMNUM != E_DIMNUM
- #error we need to cope with truncating or extending DIMNUM
-#endif
- 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]);
- }
-
- if (ISFCN (type))
- bfd_h_put_32 (abfd, in->x_sym.x_misc.x_fsize,
- (bfd_byte *) ext->x_sym.x_misc.x_fsize);
- else
- {
- 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);
- }
-
- return sizeof(AUXENT);
-}
-
-
-static void
-coff_swap_lineno_in (abfd, ext1, in1)
- bfd *abfd;
- PTR ext1;
- 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
-coff_swap_lineno_out (abfd, inp, outp)
- bfd *abfd;
- PTR inp;
- PTR outp;
-{
- struct internal_lineno *in = (struct internal_lineno *)inp;
- struct external_lineno *ext = (struct external_lineno *)outp;
- bfd_h_put_32(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);
-}
-
-
-
-static void
-coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
- bfd *abfd;
- PTR aouthdr_ext1;
- PTR aouthdr_int1;
-{
- struct internal_extra_pe_aouthdr *a;
- PEAOUTHDR *src = (PEAOUTHDR *)(aouthdr_ext1);
- 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 =
- GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
- aouthdr_int->dsize =
- GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
- aouthdr_int->bsize =
- GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
- aouthdr_int->entry =
- GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
- aouthdr_int->text_start =
- GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
- aouthdr_int->data_start =
- GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
-
- a = &aouthdr_int->pe;
- a->ImageBase = bfd_h_get_32 (abfd, src->ImageBase);
- a->SectionAlignment = bfd_h_get_32 (abfd, src->SectionAlignment);
- a->FileAlignment = bfd_h_get_32 (abfd, src->FileAlignment);
- a->MajorOperatingSystemVersion =
- bfd_h_get_16 (abfd, src->MajorOperatingSystemVersion);
- a->MinorOperatingSystemVersion =
- bfd_h_get_16 (abfd, src->MinorOperatingSystemVersion);
- a->MajorImageVersion = bfd_h_get_16 (abfd, src->MajorImageVersion);
- a->MinorImageVersion = bfd_h_get_16 (abfd, src->MinorImageVersion);
- a->MajorSubsystemVersion = bfd_h_get_16 (abfd, src->MajorSubsystemVersion);
- a->MinorSubsystemVersion = bfd_h_get_16 (abfd, src->MinorSubsystemVersion);
- a->Reserved1 = bfd_h_get_32 (abfd, src->Reserved1);
- a->SizeOfImage = bfd_h_get_32 (abfd, src->SizeOfImage);
- a->SizeOfHeaders = bfd_h_get_32 (abfd, src->SizeOfHeaders);
- a->CheckSum = bfd_h_get_32 (abfd, src->CheckSum);
- a->Subsystem = bfd_h_get_16 (abfd, src->Subsystem);
- a->DllCharacteristics = bfd_h_get_16 (abfd, src->DllCharacteristics);
- a->SizeOfStackReserve = bfd_h_get_32 (abfd, src->SizeOfStackReserve);
- a->SizeOfStackCommit = bfd_h_get_32 (abfd, src->SizeOfStackCommit);
- a->SizeOfHeapReserve = bfd_h_get_32 (abfd, src->SizeOfHeapReserve);
- a->SizeOfHeapCommit = bfd_h_get_32 (abfd, src->SizeOfHeapCommit);
- a->LoaderFlags = bfd_h_get_32 (abfd, src->LoaderFlags);
- a->NumberOfRvaAndSizes = bfd_h_get_32 (abfd, src->NumberOfRvaAndSizes);
-
- {
- int idx;
- for (idx=0; idx < 16; idx++)
- {
- a->DataDirectory[idx].VirtualAddress =
- bfd_h_get_32 (abfd, src->DataDirectory[idx][0]);
- a->DataDirectory[idx].Size =
- bfd_h_get_32 (abfd, src->DataDirectory[idx][1]);
- }
- }
-
- if (aouthdr_int->entry)
- aouthdr_int->entry += a->ImageBase;
- if (aouthdr_int->tsize)
- aouthdr_int->text_start += a->ImageBase;
- if (aouthdr_int->dsize)
- aouthdr_int->data_start += a->ImageBase;
-}
-
-
-static void add_data_entry (abfd, aout, idx, name, base)
- bfd *abfd;
- struct internal_extra_pe_aouthdr *aout;
- int idx;
- char *name;
- bfd_vma base;
-{
- asection *sec = bfd_get_section_by_name (abfd, name);
-
- /* add import directory information if it exists */
- if (sec != NULL)
- {
- aout->DataDirectory[idx].VirtualAddress = sec->vma - base;
- aout->DataDirectory[idx].Size = sec->_cooked_size;
- sec->flags |= SEC_DATA;
- }
-}
-
-static unsigned int
-coff_swap_aouthdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
-{
- struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
- struct internal_extra_pe_aouthdr *extra = &pe_data (abfd)->pe_opthdr;
- PEAOUTHDR *aouthdr_out = (PEAOUTHDR *)out;
-
- bfd_vma sa = extra->SectionAlignment;
- bfd_vma fa = extra->FileAlignment;
- bfd_vma ib = extra->ImageBase ;
-
- if (aouthdr_in->tsize)
- aouthdr_in->text_start -= ib;
- if (aouthdr_in->dsize)
- aouthdr_in->data_start -= ib;
- if (aouthdr_in->entry)
- aouthdr_in->entry -= ib;
-
-#define FA(x) (((x) + fa -1 ) & (- fa))
-#define SA(x) (((x) + sa -1 ) & (- sa))
-
- /* We like to have the sizes aligned */
-
- aouthdr_in->bsize = FA (aouthdr_in->bsize);
-
-
- extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
-
- /* first null out all data directory entries .. */
- memset (extra->DataDirectory, sizeof (extra->DataDirectory), 0);
-
- add_data_entry (abfd, extra, 0, ".edata", ib);
- add_data_entry (abfd, extra, 1, ".idata", ib);
- add_data_entry (abfd, extra, 2, ".rsrc" ,ib);
-
-#ifdef POWERPC_LE_PE
- /* FIXME: do other PE platforms use this? */
- add_data_entry (abfd, extra, 3, ".pdata" ,ib);
-#endif
-
- add_data_entry (abfd, extra, 5, ".reloc", ib);
-
-#ifdef POWERPC_LE_PE
- /* On the PPC NT system, this field is set up as follows. It is
- not an "officially" reserved field, so it currently has no title.
- first_thunk_address is idata$5, and the thunk_size is the size
- of the idata$5 chunk of the idata section.
- */
- extra->DataDirectory[12].VirtualAddress = first_thunk_address;
- extra->DataDirectory[12].Size = thunk_size;
-
- /* On the PPC NT system, the size of the directory entry is not the
- size of the entire section. It's actually offset to the end of
- the idata$3 component of the idata section. This is the size of
- the entire import table. (also known as the start of idata$4)
- */
- extra->DataDirectory[1].Size = import_table_size;
-#endif
-
- {
- asection *sec;
- bfd_vma dsize= 0;
- bfd_vma isize = SA(abfd->sections->filepos);
- bfd_vma tsize= 0;
-
- for (sec = abfd->sections; sec; sec = sec->next)
- {
- int rounded = FA(sec->_raw_size);
-
- if (strcmp(sec->name,".junk") == 0)
- {
- continue;
- }
-
- if (sec->flags & SEC_DATA)
- dsize += rounded;
- if (sec->flags & SEC_CODE)
- tsize += rounded;
- isize += SA(rounded);
- }
-
- aouthdr_in->dsize = dsize;
- aouthdr_in->tsize = tsize;
- extra->SizeOfImage = isize;
- }
-
- extra->SizeOfHeaders = abfd->sections->filepos;
- bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->standard.magic);
-
-#ifdef POWERPC_LE_PE
- /* this little piece of magic sets the "linker version" field to 2.60 */
- bfd_h_put_16(abfd, 2 + 60 * 256, (bfd_byte *) aouthdr_out->standard.vstamp);
-#else
- /* this little piece of magic sets the "linker version" field to 2.55 */
- bfd_h_put_16(abfd, 2 + 55 * 256, (bfd_byte *) aouthdr_out->standard.vstamp);
-#endif
-
- PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->standard.tsize);
- PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->standard.dsize);
- PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->standard.bsize);
- PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->standard.entry);
- PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
- (bfd_byte *) aouthdr_out->standard.text_start);
-
- PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
- (bfd_byte *) aouthdr_out->standard.data_start);
-
-
- bfd_h_put_32 (abfd, extra->ImageBase,
- (bfd_byte *) aouthdr_out->ImageBase);
- bfd_h_put_32 (abfd, extra->SectionAlignment,
- (bfd_byte *) aouthdr_out->SectionAlignment);
- bfd_h_put_32 (abfd, extra->FileAlignment,
- (bfd_byte *) aouthdr_out->FileAlignment);
- bfd_h_put_16 (abfd, extra->MajorOperatingSystemVersion,
- (bfd_byte *) aouthdr_out->MajorOperatingSystemVersion);
- bfd_h_put_16 (abfd, extra->MinorOperatingSystemVersion,
- (bfd_byte *) aouthdr_out->MinorOperatingSystemVersion);
- bfd_h_put_16 (abfd, extra->MajorImageVersion,
- (bfd_byte *) aouthdr_out->MajorImageVersion);
- bfd_h_put_16 (abfd, extra->MinorImageVersion,
- (bfd_byte *) aouthdr_out->MinorImageVersion);
- bfd_h_put_16 (abfd, extra->MajorSubsystemVersion,
- (bfd_byte *) aouthdr_out->MajorSubsystemVersion);
- bfd_h_put_16 (abfd, extra->MinorSubsystemVersion,
- (bfd_byte *) aouthdr_out->MinorSubsystemVersion);
- bfd_h_put_32 (abfd, extra->Reserved1,
- (bfd_byte *) aouthdr_out->Reserved1);
- bfd_h_put_32 (abfd, extra->SizeOfImage,
- (bfd_byte *) aouthdr_out->SizeOfImage);
- bfd_h_put_32 (abfd, extra->SizeOfHeaders,
- (bfd_byte *) aouthdr_out->SizeOfHeaders);
- bfd_h_put_32 (abfd, extra->CheckSum,
- (bfd_byte *) aouthdr_out->CheckSum);
- bfd_h_put_16 (abfd, extra->Subsystem,
- (bfd_byte *) aouthdr_out->Subsystem);
- bfd_h_put_16 (abfd, extra->DllCharacteristics,
- (bfd_byte *) aouthdr_out->DllCharacteristics);
- bfd_h_put_32 (abfd, extra->SizeOfStackReserve,
- (bfd_byte *) aouthdr_out->SizeOfStackReserve);
- bfd_h_put_32 (abfd, extra->SizeOfStackCommit,
- (bfd_byte *) aouthdr_out->SizeOfStackCommit);
- bfd_h_put_32 (abfd, extra->SizeOfHeapReserve,
- (bfd_byte *) aouthdr_out->SizeOfHeapReserve);
- bfd_h_put_32 (abfd, extra->SizeOfHeapCommit,
- (bfd_byte *) aouthdr_out->SizeOfHeapCommit);
- bfd_h_put_32 (abfd, extra->LoaderFlags,
- (bfd_byte *) aouthdr_out->LoaderFlags);
- bfd_h_put_32 (abfd, extra->NumberOfRvaAndSizes,
- (bfd_byte *) aouthdr_out->NumberOfRvaAndSizes);
- {
- int idx;
- for (idx=0; idx < 16; idx++)
- {
- bfd_h_put_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
- (bfd_byte *) aouthdr_out->DataDirectory[idx][0]);
- bfd_h_put_32 (abfd, extra->DataDirectory[idx].Size,
- (bfd_byte *) aouthdr_out->DataDirectory[idx][1]);
- }
- }
-
- return sizeof(AOUTHDR);
-}
-
-static void
- coff_swap_scnhdr_in (abfd, ext, in)
- bfd *abfd;
- PTR ext;
- PTR in;
-{
- SCNHDR *scnhdr_ext = (SCNHDR *) ext;
- struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
-
- memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
- scnhdr_int->s_vaddr =
- GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
- scnhdr_int->s_paddr =
- GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
- scnhdr_int->s_size =
- GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
- scnhdr_int->s_scnptr =
- GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
- scnhdr_int->s_relptr =
- GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
- scnhdr_int->s_lnnoptr =
- GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
- scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
-
- 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);
-
- if (scnhdr_int->s_vaddr != 0)
- {
- scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase;
- }
- if (strcmp (scnhdr_int->s_name, _BSS) == 0)
- {
- scnhdr_int->s_size = scnhdr_int->s_paddr;
- scnhdr_int->s_paddr = 0;
- }
-}
-
-static unsigned int
-coff_swap_scnhdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
-{
- struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
- SCNHDR *scnhdr_ext = (SCNHDR *)out;
- unsigned int ret = sizeof (SCNHDR);
- bfd_vma ps;
- bfd_vma ss;
-
- memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
-
- PUT_SCNHDR_VADDR (abfd,
- (scnhdr_int->s_vaddr
- - pe_data(abfd)->pe_opthdr.ImageBase),
- (bfd_byte *) scnhdr_ext->s_vaddr);
-
- /* NT wants the size data to be rounded up to the next NT_FILE_ALIGNMENT
- value except for the BSS section, its s_size should be 0 */
-
-
- if (strcmp (scnhdr_int->s_name, _BSS) == 0)
- {
- ps = scnhdr_int->s_size;
- ss = 0;
- }
- else
- {
- ps = scnhdr_int->s_paddr;
- ss = scnhdr_int->s_size;
- }
-
- PUT_SCNHDR_SIZE (abfd, ss,
- (bfd_byte *) scnhdr_ext->s_size);
-
-
- PUT_SCNHDR_PADDR (abfd, ps, (bfd_byte *) scnhdr_ext->s_paddr);
-
- PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
- (bfd_byte *) scnhdr_ext->s_scnptr);
- PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
- (bfd_byte *) scnhdr_ext->s_relptr);
- PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
- (bfd_byte *) scnhdr_ext->s_lnnoptr);
-
- /* Extra flags must be set when dealing with NT. All sections should also
- have the IMAGE_SCN_MEM_READ (0x40000000) flag set. In addition, the
- .text section must have IMAGE_SCN_MEM_EXECUTE (0x20000000) and the data
- sections (.idata, .data, .bss, .CRT) must have IMAGE_SCN_MEM_WRITE set
- (this is especially important when dealing with the .idata section since
- the addresses for routines from .dlls must be overwritten). If .reloc
- section data is ever generated, we must add IMAGE_SCN_MEM_DISCARDABLE
- (0x02000000). Also, the resource data should also be read and
- writable. */
-
- /* FIXME: alignment is also encoded in this field, at least on ppc (krk) */
- /* FIXME: even worse, I don't see how to get the original alignment field*/
- /* back... */
-
- {
- int flags = scnhdr_int->s_flags;
- if (strcmp (scnhdr_int->s_name, ".data") == 0 ||
- strcmp (scnhdr_int->s_name, ".CRT") == 0 ||
- strcmp (scnhdr_int->s_name, ".rsrc") == 0 ||
- strcmp (scnhdr_int->s_name, ".bss") == 0)
- flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE;
- else if (strcmp (scnhdr_int->s_name, ".text") == 0)
- flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_EXECUTE;
- else if (strcmp (scnhdr_int->s_name, ".reloc") == 0)
- flags = SEC_DATA| IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE;
- else if (strcmp (scnhdr_int->s_name, ".idata") == 0)
- flags = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | SEC_DATA;
- else if (strcmp (scnhdr_int->s_name, ".rdata") == 0
- || strcmp (scnhdr_int->s_name, ".edata") == 0)
- flags = IMAGE_SCN_MEM_READ | SEC_DATA;
- /* ppc-nt additions */
- else if (strcmp (scnhdr_int->s_name, ".pdata") == 0)
- flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES |
- IMAGE_SCN_MEM_READ ;
- /* Remember this field is a max of 8 chars, so the null is _not_ there
- for an 8 character name like ".reldata". (yep. Stupid bug) */
- else if (strncmp (scnhdr_int->s_name, ".reldata", strlen(".reldata")) == 0)
- flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_8BYTES |
- IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE ;
- else if (strcmp (scnhdr_int->s_name, ".ydata") == 0)
- flags = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_8BYTES |
- IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE ;
- else if (strcmp (scnhdr_int->s_name, ".drectve") == 0)
- flags = IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE ;
- /* end of ppc-nt additions */
-#ifdef POWERPC_LE_PE
- else if (strncmp (scnhdr_int->s_name, ".stabstr", strlen(".stabstr")) == 0)
- {
- flags = IMAGE_SCN_LNK_INFO;
- }
- else if (strcmp (scnhdr_int->s_name, ".stab") == 0)
- {
- flags = IMAGE_SCN_LNK_INFO;
- }
-#endif
-
- bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
- }
-
- if (scnhdr_int->s_nlnno <= 0xffff)
- bfd_h_put_16(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
- else
- {
- (*_bfd_error_handler) ("%s: line number overflow: 0x%lx > 0xffff",
- bfd_get_filename (abfd),
- scnhdr_int->s_nlnno);
- bfd_set_error (bfd_error_file_truncated);
- bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
- ret = 0;
- }
- if (scnhdr_int->s_nreloc <= 0xffff)
- bfd_h_put_16(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
- else
- {
- (*_bfd_error_handler) ("%s: reloc overflow: 0x%lx > 0xffff",
- bfd_get_filename (abfd),
- scnhdr_int->s_nreloc);
- bfd_set_error (bfd_error_file_truncated);
- bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
- ret = 0;
- }
- return ret;
-}
-
-static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
-{
- "Export Directory [.edata]",
- "Import Directory [parts of .idata]",
- "Resource Directory [.rsrc]",
- "Exception Directory [.pdata]",
- "Security Directory",
- "Base Relocation Directory [.reloc]",
- "Debug Directory",
- "Description Directory",
- "Special Directory",
- "Thread Storage Directory [.tls]",
- "Load Configuration Directory",
- "Bound Import Directory",
- "Import Address Table Directory",
- "Reserved",
- "Reserved",
- "Reserved"
-};
-
-/**********************************************************************/
-static boolean
-pe_print_idata(abfd, vfile)
- bfd*abfd;
- void *vfile;
-{
- FILE *file = vfile;
- bfd_byte *data = 0;
- asection *section = bfd_get_section_by_name (abfd, ".idata");
-
-#ifdef POWERPC_LE_PE
- asection *rel_section = bfd_get_section_by_name (abfd, ".reldata");
-#endif
-
- bfd_size_type datasize = 0;
- bfd_size_type i;
- bfd_size_type start, stop;
- int onaline = 20;
- bfd_vma addr_value;
- bfd_vma loadable_toc_address;
- bfd_vma toc_address;
- bfd_vma start_address;
-
- pe_data_type *pe = pe_data (abfd);
- struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
-
- if (section == 0)
- return true;
-
-#ifdef POWERPC_LE_PE
- if (rel_section != 0 && bfd_section_size (abfd, rel_section) != 0)
- {
- /* The toc address can be found by taking the starting address,
- which on the PPC locates a function descriptor. The descriptor
- consists of the function code starting address followed by the
- address of the toc. The starting address we get from the bfd,
- and the descriptor is supposed to be in the .reldata section.
- */
-
- bfd_byte *data = 0;
- int offset;
- data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd,
- rel_section));
- if (data == NULL && bfd_section_size (abfd, rel_section) != 0)
- return false;
-
- datasize = bfd_section_size (abfd, rel_section);
-
- bfd_get_section_contents (abfd,
- rel_section,
- (PTR) data, 0,
- bfd_section_size (abfd, rel_section));
-
- offset = abfd->start_address - rel_section->vma;
-
- start_address = bfd_get_32(abfd, data+offset);
- loadable_toc_address = bfd_get_32(abfd, data+offset+4);
- toc_address = loadable_toc_address - 32768;
-
- fprintf(file,
- "\nFunction descriptor located at the start address: %04lx\n",
- (unsigned long int) (abfd->start_address));
- fprintf (file,
- "\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n",
- start_address, loadable_toc_address, toc_address);
- }
- else
- {
- loadable_toc_address = 0;
- toc_address = 0;
- start_address = 0;
- }
-#endif
-
- fprintf(file,
- "\nThe Import Tables (interpreted .idata section contents)\n");
- fprintf(file,
- " vma: Hint Time Forward DLL First\n");
- fprintf(file,
- " Table Stamp Chain Name Thunk\n");
-
- if (bfd_section_size (abfd, section) == 0)
- return true;
-
- data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
- datasize = bfd_section_size (abfd, section);
- if (data == NULL && datasize != 0)
- return false;
-
- bfd_get_section_contents (abfd,
- section,
- (PTR) data, 0,
- bfd_section_size (abfd, section));
-
- start = 0;
-
- stop = bfd_section_size (abfd, section);
-
- for (i = start; i < stop; i += onaline)
- {
- bfd_vma hint_addr;
- bfd_vma time_stamp;
- bfd_vma forward_chain;
- bfd_vma dll_name;
- bfd_vma first_thunk;
- int idx;
- int j;
- char *dll;
- int adj = extra->ImageBase - section->vma;
-
- fprintf (file,
- " %04lx\t",
- (unsigned long int) (i + section->vma));
-
- if (i+20 > stop)
- {
- /* check stuff */
- ;
- }
-
- hint_addr = bfd_get_32(abfd, data+i);
- time_stamp = bfd_get_32(abfd, data+i+4);
- forward_chain = bfd_get_32(abfd, data+i+8);
- dll_name = bfd_get_32(abfd, data+i+12);
- first_thunk = bfd_get_32(abfd, data+i+16);
-
- fprintf(file, "%08lx %08lx %08lx %08lx %08lx\n",
- hint_addr,
- time_stamp,
- forward_chain,
- dll_name,
- first_thunk);
-
- if (hint_addr ==0)
- {
- break;
- }
-
- /* the image base is present in the section->vma */
- dll = data + dll_name + adj;
- fprintf(file, "\n\tDLL Name: %s\n", dll);
- fprintf(file, "\tvma: Ordinal Member-Name\n");
-
- idx = hint_addr + adj;
-
- for (j=0;j<stop;j+=4)
- {
- int ordinal;
- char *member_name;
- bfd_vma member = bfd_get_32(abfd, data + idx + j);
- if (member == 0)
- break;
- ordinal = bfd_get_16(abfd,
- data + member + adj);
- member_name = data + member + adj + 2;
- fprintf(file, "\t%04lx\t %4d %s\n",
- member, ordinal, member_name);
- }
-
- if (hint_addr != first_thunk)
- {
- int differ = 0;
- int idx2;
-
- idx2 = first_thunk + adj;
-
- for (j=0;j<stop;j+=4)
- {
- int ordinal;
- char *member_name;
- bfd_vma hint_member = bfd_get_32(abfd, data + idx + j);
- bfd_vma iat_member = bfd_get_32(abfd, data + idx2 + j);
- if (hint_member != iat_member)
- {
- if (differ == 0)
- {
- fprintf(file,
- "\tThe Import Address Table (difference found)\n");
- fprintf(file, "\tvma: Ordinal Member-Name\n");
- differ = 1;
- }
- if (iat_member == 0)
- {
- fprintf(file,
- "\t>>> Ran out of IAT members!\n");
- }
- else
- {
- ordinal = bfd_get_16(abfd,
- data + iat_member + adj);
- member_name = data + iat_member + adj + 2;
- fprintf(file, "\t%04lx\t %4d %s\n",
- iat_member, ordinal, member_name);
- }
- break;
- }
- if (hint_member == 0)
- break;
- }
- if (differ == 0)
- {
- fprintf(file,
- "\tThe Import Address Table is identical\n");
- }
- }
-
- fprintf(file, "\n");
-
- }
-
- free (data);
-}
-
-static boolean
-pe_print_edata(abfd, vfile)
- bfd*abfd;
- void *vfile;
-{
- FILE *file = vfile;
- bfd_byte *data = 0;
- asection *section = bfd_get_section_by_name (abfd, ".edata");
-
- bfd_size_type datasize = 0;
- bfd_size_type i;
-
- int adj;
- struct EDT_type
- {
- long export_flags; /* reserved - should be zero */
- long time_stamp;
- short major_ver;
- short minor_ver;
- bfd_vma name; /* rva - relative to image base */
- long base; /* ordinal base */
- long num_functions; /* Number in the export address table */
- long num_names; /* Number in the name pointer table */
- bfd_vma eat_addr; /* rva to the export address table */
- bfd_vma npt_addr; /* rva to the Export Name Pointer Table */
- bfd_vma ot_addr; /* rva to the Ordinal Table */
- } edt;
-
- pe_data_type *pe = pe_data (abfd);
- struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr;
-
- if (section == 0)
- return true;
-
- data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd,
- section));
- datasize = bfd_section_size (abfd, section);
-
- if (data == NULL && datasize != 0)
- return false;
-
- bfd_get_section_contents (abfd,
- section,
- (PTR) data, 0,
- bfd_section_size (abfd, section));
-
- /* Go get Export Directory Table */
- edt.export_flags = bfd_get_32(abfd, data+0);
- edt.time_stamp = bfd_get_32(abfd, data+4);
- edt.major_ver = bfd_get_16(abfd, data+8);
- edt.minor_ver = bfd_get_16(abfd, data+10);
- edt.name = bfd_get_32(abfd, data+12);
- edt.base = bfd_get_32(abfd, data+16);
- edt.num_functions = bfd_get_32(abfd, data+20);
- edt.num_names = bfd_get_32(abfd, data+24);
- edt.eat_addr = bfd_get_32(abfd, data+28);
- edt.npt_addr = bfd_get_32(abfd, data+32);
- edt.ot_addr = bfd_get_32(abfd, data+36);
-
- adj = extra->ImageBase - section->vma;
-
-
- /* Dump the EDT first first */
- fprintf(file,
- "\nThe Export Tables (interpreted .edata section contents)\n\n");
-
- fprintf(file,
- "Export Flags \t\t\t%x\n",edt.export_flags);
-
- fprintf(file,
- "Time/Date stamp \t\t%x\n",edt.time_stamp);
-
- fprintf(file,
- "Major/Minor \t\t\t%d/%d\n", edt.major_ver, edt.minor_ver);
-
- fprintf(file,
- "Name \t\t\t\t%x %s\n", edt.name, data + edt.name + adj);
-
- fprintf(file,
- "Ordinal Base \t\t\t%d\n", edt.base);
-
- fprintf(file,
- "Number in:\n");
-
- fprintf(file,
- "\tExport Address Table \t\t%x\n", edt.num_functions);
-
- fprintf(file,
- "\t[Name Pointer/Ordinal] Table\t%d\n", edt.num_names);
-
- fprintf(file,
- "Table Addresses\n");
-
- fprintf(file,
- "\tExport Address Table \t\t%x\n",
- edt.eat_addr);
-
- fprintf(file,
- "\tName Pointer Table \t\t%x\n",
- edt.npt_addr);
-
- fprintf(file,
- "\tOrdinal Table \t\t\t%x\n",
- edt.ot_addr);
-
-
- /* The next table to find si the Export Address Table. It's basically
- a list of pointers that either locate a function in this dll, or
- forward the call to another dll. Something like:
- typedef union
- {
- long export_rva;
- long forwarder_rva;
- } export_address_table_entry;
- */
-
- fprintf(file,
- "\nExport Address Table -- Ordinal Base %d\n",
- edt.base);
-
- for (i = 0; i < edt.num_functions; ++i)
- {
- bfd_vma eat_member = bfd_get_32(abfd,
- data + edt.eat_addr + (i*4) + adj);
- bfd_vma eat_actual = extra->ImageBase + eat_member;
- bfd_vma edata_start = bfd_get_section_vma(abfd,section);
- bfd_vma edata_end = edata_start + bfd_section_size (abfd, section);
-
-
- if (eat_member == 0)
- continue;
-
- if (edata_start < eat_actual && eat_actual < edata_end)
- {
- /* this rva is to a name (forwarding function) in our section */
- /* Should locate a function descriptor */
- fprintf(file,
- "\t[%4d] +base[%4d] %04lx %s -- %s\n",
- i, i+edt.base, eat_member, "Forwarder RVA",
- data + eat_member + adj);
- }
- else
- {
- /* Should locate a function descriptor in the reldata section */
- fprintf(file,
- "\t[%4d] +base[%4d] %04lx %s\n",
- i, i+edt.base, eat_member, "Export RVA");
- }
- }
-
- /* The Export Name Pointer Table is paired with the Export Ordinal Table */
- /* Dump them in parallel for clarity */
- fprintf(file,
- "\n[Ordinal/Name Pointer] Table\n");
-
- for (i = 0; i < edt.num_names; ++i)
- {
- bfd_vma name_ptr = bfd_get_32(abfd,
- data +
- edt.npt_addr
- + (i*4) + adj);
-
- char *name = data + name_ptr + adj;
-
- bfd_vma ord = bfd_get_16(abfd,
- data +
- edt.ot_addr
- + (i*2) + adj);
- fprintf(file,
- "\t[%4d] %s\n", ord, name);
-
- }
-
- free (data);
-}
-
-static boolean
-pe_print_pdata(abfd, vfile)
- bfd*abfd;
- void *vfile;
-{
- FILE *file = vfile;
- bfd_byte *data = 0;
- asection *section = bfd_get_section_by_name (abfd, ".pdata");
- bfd_size_type datasize = 0;
- bfd_size_type i;
- bfd_size_type start, stop;
- int onaline = 20;
- bfd_vma addr_value;
-
- if (section == 0)
- return true;
-
- fprintf(file,
- "\nThe Function Table (interpreted .pdata section contents)\n");
- fprintf(file,
- " vma:\t\tBegin End EH EH PrologEnd\n");
- fprintf(file,
- " \t\tAddress Address Handler Data Address\n");
-
- if (bfd_section_size (abfd, section) == 0)
- return true;
-
- data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
- datasize = bfd_section_size (abfd, section);
- if (data == NULL && datasize != 0)
- return false;
-
- bfd_get_section_contents (abfd,
- section,
- (PTR) data, 0,
- bfd_section_size (abfd, section));
-
- start = 0;
-
- stop = bfd_section_size (abfd, section);
-
- for (i = start; i < stop; i += onaline)
- {
- bfd_vma begin_addr;
- bfd_vma end_addr;
- bfd_vma eh_handler;
- bfd_vma eh_data;
- bfd_vma prolog_end_addr;
-
- if (i+20 > stop)
- break;
-
- begin_addr = bfd_get_32(abfd, data+i);
- end_addr = bfd_get_32(abfd, data+i+4);
- eh_handler = bfd_get_32(abfd, data+i+8);
- eh_data = bfd_get_32(abfd, data+i+12);
- prolog_end_addr = bfd_get_32(abfd, data+i+16);
-
- if (begin_addr == 0 && end_addr == 0 && eh_handler == 0
- && eh_data == 0 && prolog_end_addr == 0)
- {
- /* We are probably into the padding of the
- section now */
- break;
- }
-
- fprintf (file,
- " %08lx\t",
- (unsigned long int) (i + section->vma));
-
- fprintf(file, "%08lx %08lx %08lx %08lx %08lx",
- begin_addr,
- end_addr,
- eh_handler,
- eh_data,
- prolog_end_addr);
-
-#ifdef POWERPC_LE_PE
- if (eh_handler == 0 && eh_data != 0)
- {
- /* Special bits here, although the meaning may */
- /* be a little mysterious. The only one I know */
- /* for sure is 0x03. */
- /* Code Significance */
- /* 0x00 None */
- /* 0x01 Register Save Millicode */
- /* 0x02 Register Restore Millicode */
- /* 0x03 Glue Code Sequence */
- switch (eh_data)
- {
- case 0x01:
- fprintf(file, " Register save millicode");
- break;
- case 0x02:
- fprintf(file, " Register restore millicode");
- break;
- case 0x03:
- fprintf(file, " Glue code sequence");
- break;
- default:
- break;
- }
- }
-#endif
- fprintf(file, "\n");
- }
-
- free (data);
-}
-
-static const char *tbl[6] =
-{
-"ABSOLUTE",
-"HIGH",
-"LOW",
-"HIGHLOW",
-"HIGHADJ",
-"unknown"
-};
-
-static boolean
-pe_print_reloc(abfd, vfile)
- bfd*abfd;
- void *vfile;
-{
- FILE *file = vfile;
- bfd_byte *data = 0;
- asection *section = bfd_get_section_by_name (abfd, ".reloc");
- bfd_size_type datasize = 0;
- bfd_size_type i;
- bfd_size_type start, stop;
- int onaline = 20;
- bfd_vma addr_value;
-
- if (section == 0)
- return true;
-
- if (bfd_section_size (abfd, section) == 0)
- return true;
-
- fprintf(file,
- "\n\nPE File Base Relocations (interpreted .reloc"
- " section contents)\n");
-
- data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
- datasize = bfd_section_size (abfd, section);
- if (data == NULL && datasize != 0)
- return false;
-
- bfd_get_section_contents (abfd,
- section,
- (PTR) data, 0,
- bfd_section_size (abfd, section));
-
- start = 0;
-
- stop = bfd_section_size (abfd, section);
-
- for (i = start; i < stop;)
- {
- int j;
- bfd_vma virtual_address;
- long number, size;
-
- /* The .reloc section is a sequence of blocks, with a header consisting
- of two 32 bit quantities, followed by a number of 16 bit entries */
-
- virtual_address = bfd_get_32(abfd, data+i);
- size = bfd_get_32(abfd, data+i+4);
- number = (size - 8) / 2;
-
- if (size == 0)
- {
- break;
- }
-
- fprintf (file,
- "\nVirtual Address: %08lx Chunk size %d (0x%x) "
- "Number of fixups %d\n",
- virtual_address, size, size, number);
-
- for (j = 0; j < number; ++j)
- {
- unsigned short e = bfd_get_16(abfd, data + i + 8 + j*2);
- int t = (e & 0xF000) >> 12;
- int off = e & 0x0FFF;
-
- if (t > 5)
- abort();
-
- fprintf(file,
- "\treloc %4d offset %4x [%4x] %s\n",
- j, off, off+virtual_address, tbl[t]);
-
- }
- i += size;
- }
-
- free (data);
-}
-
-static boolean
-pe_print_private_bfd_data (abfd, vfile)
- bfd *abfd;
- PTR vfile;
-{
- FILE *file = (FILE *) vfile;
- int j;
- pe_data_type *pe = pe_data (abfd);
- struct internal_extra_pe_aouthdr *i = &pe->pe_opthdr;
-
- fprintf (file,"\nImageBase\t\t");
- fprintf_vma (file, i->ImageBase);
- fprintf (file,"\nSectionAlignment\t");
- fprintf_vma (file, i->SectionAlignment);
- fprintf (file,"\nFileAlignment\t\t");
- fprintf_vma (file, i->FileAlignment);
- fprintf (file,"\nMajorOSystemVersion\t%d\n", i->MajorOperatingSystemVersion);
- fprintf (file,"MinorOSystemVersion\t%d\n", i->MinorOperatingSystemVersion);
- fprintf (file,"MajorImageVersion\t%d\n", i->MajorImageVersion);
- fprintf (file,"MinorImageVersion\t%d\n", i->MinorImageVersion);
- fprintf (file,"MajorSubsystemVersion\t%d\n", i->MajorSubsystemVersion);
- fprintf (file,"MinorSubsystemVersion\t%d\n", i->MinorSubsystemVersion);
- fprintf (file,"Reserved1\t\t%08lx\n", i->Reserved1);
- fprintf (file,"SizeOfImage\t\t%08lx\n", i->SizeOfImage);
- fprintf (file,"SizeOfHeaders\t\t%08lx\n", i->SizeOfHeaders);
- fprintf (file,"CheckSum\t\t%08lx\n", i->CheckSum);
- fprintf (file,"Subsystem\t\t%08x\n", i->Subsystem);
- fprintf (file,"DllCharacteristics\t%08x\n", i->DllCharacteristics);
- fprintf (file,"SizeOfStackReserve\t");
- fprintf_vma (file, i->SizeOfStackReserve);
- fprintf (file,"\nSizeOfStackCommit\t");
- fprintf_vma (file, i->SizeOfStackCommit);
- fprintf (file,"\nSizeOfHeapReserve\t");
- fprintf_vma (file, i->SizeOfHeapReserve);
- fprintf (file,"\nSizeOfHeapCommit\t");
- fprintf_vma (file, i->SizeOfHeapCommit);
- fprintf (file,"\nLoaderFlags\t\t%08lx\n", i->LoaderFlags);
- fprintf (file,"NumberOfRvaAndSizes\t%08lx\n", i->NumberOfRvaAndSizes);
-
- fprintf (file,"\nThe Data Directory\n");
- for (j = 0; j < IMAGE_NUMBEROF_DIRECTORY_ENTRIES; j++)
- {
- fprintf (file, "Entry %1x ", j);
- fprintf_vma (file, i->DataDirectory[j].VirtualAddress);
- fprintf (file, " %08lx ", i->DataDirectory[j].Size);
- fprintf (file, "%s\n", dir_names[j]);
- }
-
- pe_print_idata(abfd, vfile);
- pe_print_edata(abfd, vfile);
- pe_print_pdata(abfd, vfile);
- pe_print_reloc(abfd, vfile);
-
- return true;
-}
-
-static boolean
-pe_mkobject (abfd)
- bfd * abfd;
-{
- pe_data_type *pe;
- abfd->tdata.pe_obj_data =
- (struct pe_tdata *) bfd_zalloc (abfd, sizeof (pe_data_type));
-
- if (abfd->tdata.pe_obj_data == 0)
- return false;
-
- pe = pe_data (abfd);
-
- pe->coff.pe = 1;
- pe->in_reloc_p = in_reloc_p;
- return true;
-}
-
-/* Create the COFF backend specific information. */
-static PTR
-pe_mkobject_hook (abfd, filehdr, aouthdr)
- bfd * abfd;
- PTR filehdr;
- PTR aouthdr;
-{
- struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
- pe_data_type *pe;
-
- if (pe_mkobject (abfd) == false)
- return NULL;
-
- pe = pe_data (abfd);
- pe->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 among coff implementations... */
- pe->coff.local_n_btmask = N_BTMASK;
- pe->coff.local_n_btshft = N_BTSHFT;
- pe->coff.local_n_tmask = N_TMASK;
- pe->coff.local_n_tshift = N_TSHIFT;
- pe->coff.local_symesz = SYMESZ;
- pe->coff.local_auxesz = AUXESZ;
- pe->coff.local_linesz = LINESZ;
-
- obj_raw_syment_count (abfd) =
- obj_conv_table_size (abfd) =
- internal_f->f_nsyms;
-
- pe->real_flags = internal_f->f_flags;
-
-#ifdef COFF_IMAGE_WITH_PE
- if (aouthdr)
- {
- pe->pe_opthdr = ((struct internal_aouthdr *)aouthdr)->pe;
- }
-#endif
-
- return (PTR) pe;
-}
-
-
-
-/* Copy any private info we understand from the input bfd
- to the output bfd. */
-
-#define coff_bfd_copy_private_bfd_data pe_bfd_copy_private_bfd_data
-
-static boolean
-pe_bfd_copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd, *obfd;
-{
- /* One day we may try to grok other private data. */
- if (ibfd->xvec->flavour != bfd_target_coff_flavour
- || obfd->xvec->flavour != bfd_target_coff_flavour)
- return true;
-
- pe_data(obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
-
- return true;
-}
diff --git a/contrib/gdb/bfd/ptrace-core.c b/contrib/gdb/bfd/ptrace-core.c
deleted file mode 100644
index e356457..0000000
--- a/contrib/gdb/bfd/ptrace-core.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* BFD backend for core files which use the ptrace_user structure
- Copyright 1993, 1994 Free Software Foundation, Inc.
- The structure of this file is based on trad-core.c written by John Gilmore
- of Cygnus Support.
- Modified to work with the ptrace_user structure by Kevin A. Buettner.
- (Longterm it may be better to merge this file with trad-core.c)
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifdef PTRACE_CORE
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/ptrace.h>
-
-
-struct trad_core_struct
- {
- asection *data_section;
- asection *stack_section;
- asection *reg_section;
- struct ptrace_user u;
- };
-
-#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
-#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
-#define core_stacksec(bfd) ((bfd)->tdata.trad_core_data->stack_section)
-#define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section)
-
-/* forward declarations */
-
-const bfd_target *ptrace_unix_core_file_p PARAMS ((bfd *abfd));
-char * ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd));
-int ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd));
-boolean ptrace_unix_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
-
-/* ARGSUSED */
-const bfd_target *
-ptrace_unix_core_file_p (abfd)
- bfd *abfd;
-
-{
- int val;
- struct ptrace_user u;
- struct trad_core_struct *rawptr;
-
- val = bfd_read ((void *)&u, 1, sizeof u, abfd);
- if (val != sizeof u || u.pt_magic != _BCS_PTRACE_MAGIC
- || u.pt_rev != _BCS_PTRACE_REV)
- {
- /* Too small to be a core file */
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- /* 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 trad_core_struct *)
- bfd_zalloc (abfd, sizeof (struct trad_core_struct));
-
- if (rawptr == NULL)
- return 0;
-
- abfd->tdata.trad_core_data = rawptr;
-
- rawptr->u = u; /*Copy the uarea into the tdata part of the bfd */
-
- /* Create the sections. This is raunchy, but bfd_close wants to free
- them separately. */
-
- core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_stacksec (abfd) == NULL)
- return NULL;
- core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_datasec (abfd) == NULL)
- return NULL;
- core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (core_regsec (abfd) == NULL)
- return NULL;
-
- core_stacksec (abfd)->name = ".stack";
- core_datasec (abfd)->name = ".data";
- core_regsec (abfd)->name = ".reg";
-
- /* FIXME: Need to worry about shared memory, library data, and library
- text. I don't think that any of these things are supported on the
- system on which I am developing this for though. */
-
-
- 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_HAS_CONTENTS;
-
- core_datasec (abfd)->_raw_size = u.pt_dsize;
- core_stacksec (abfd)->_raw_size = u.pt_ssize;
- core_regsec (abfd)->_raw_size = sizeof(u);
-
- core_datasec (abfd)->vma = u.pt_o_data_start;
- core_stacksec (abfd)->vma = USRSTACK - u.pt_ssize;
- core_regsec (abfd)->vma = 0 - sizeof(u); /* see trad-core.c */
-
- core_datasec (abfd)->filepos = (int) u.pt_dataptr;
- core_stacksec (abfd)->filepos = (int) (u.pt_dataptr + u.pt_dsize);
- core_regsec (abfd)->filepos = 0; /* Register segment is ptrace_user */
-
- /* 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 *
-ptrace_unix_core_file_failing_command (abfd)
- bfd *abfd;
-{
- char *com = abfd->tdata.trad_core_data->u.pt_comm;
- if (*com)
- return com;
- else
- return 0;
-}
-
-/* ARGSUSED */
-int
-ptrace_unix_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return abfd->tdata.trad_core_data->u.pt_sigframe.sig_num;
-}
-
-/* ARGSUSED */
-boolean
-ptrace_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- /* FIXME: Use pt_timdat field of the ptrace_user structure to match
- the date of the executable */
- return true;
-}
-
-/* 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 ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
-#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
-#define NO_SIGNED_GET \
- ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
-
-const bfd_target ptrace_core_vec =
- {
- "trad-core",
- bfd_target_unknown_flavour,
- BFD_ENDIAN_UNKNOWN, /* target byte order */
- BFD_ENDIAN_UNKNOWN, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* symbol prefix */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit hdrs */
- NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit hdrs */
-
- { /* bfd_check_format */
- _bfd_dummy_target, /* unknown format */
- _bfd_dummy_target, /* object file */
- _bfd_dummy_target, /* archive */
- ptrace_unix_core_file_p /* a core file */
- },
- { /* bfd_set_format */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
- { /* bfd_write_contents */
- bfd_false, bfd_false,
- bfd_false, bfd_false
- },
-
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (ptrace_unix),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
- BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
- BFD_JUMP_TABLE_WRITE (_bfd_generic),
- BFD_JUMP_TABLE_LINK (_bfd_nolink),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0 /* backend_data */
-};
-
-#endif /* PTRACE_CORE */
diff --git a/contrib/gdb/bfd/reloc16.c b/contrib/gdb/bfd/reloc16.c
deleted file mode 100644
index e88d50f..0000000
--- a/contrib/gdb/bfd/reloc16.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/* 8 and 16 bit COFF relocation functions, for BFD.
- Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
-Most of this hacked by Steve Chamberlain,
- sac@cygnus.com
-*/
-
-/* These routines are used by coff-h8300 and coff-z8k to do
- relocation.
-
- FIXME: This code should be rewritten to support the new COFF
- linker. Basically, they need to deal with COFF relocs rather than
- BFD generic relocs. They should store the relocs in some location
- where coff_link_input_bfd can find them (and coff_link_input_bfd
- should be changed to use this location rather than rereading the
- file) (unless info->keep_memory is false, in which case they should
- free up the relocs after dealing with them). */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "obstack.h"
-#include "libbfd.h"
-#include "bfdlink.h"
-#include "genlink.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-bfd_vma
-bfd_coff_reloc16_get_value (reloc, link_info, input_section)
- arelent *reloc;
- struct bfd_link_info *link_info;
- asection *input_section;
-{
- bfd_vma value;
- asymbol *symbol = *(reloc->sym_ptr_ptr);
- /* A symbol holds a pointer to a section, and an offset from the
- base of the section. To relocate, we find where the section will
- live in the output and add that in */
-
- if (bfd_is_und_section (symbol->section))
- {
- struct bfd_link_hash_entry *h;
-
- /* The symbol is undefined in this BFD. Look it up in the
- global linker hash table. FIXME: This should be changed when
- we convert this stuff to use a specific final_link function
- and change the interface to bfd_relax_section to not require
- the generic symbols. */
- h = bfd_wrapped_link_hash_lookup (input_section->owner, link_info,
- bfd_asymbol_name (symbol),
- false, false, true);
- if (h != (struct bfd_link_hash_entry *) NULL
- && (h->type == bfd_link_hash_defined
- || h->type == bfd_link_hash_defweak))
- value = (h->u.def.value
- + h->u.def.section->output_section->vma
- + h->u.def.section->output_offset);
- else if (h != (struct bfd_link_hash_entry *) NULL
- && h->type == bfd_link_hash_common)
- value = h->u.c.size;
- else
- {
- if (! ((*link_info->callbacks->undefined_symbol)
- (link_info, bfd_asymbol_name (symbol),
- input_section->owner, input_section, reloc->address)))
- abort ();
- value = 0;
- }
- }
- else
- {
- value = symbol->value +
- symbol->section->output_offset +
- symbol->section->output_section->vma;
- }
-
- /* Add the value contained in the relocation */
- value += reloc->addend;
-
- return value;
-}
-
-void
-bfd_perform_slip(abfd, slip, input_section, value)
- bfd *abfd;
- unsigned int slip;
- asection *input_section;
- bfd_vma value;
-{
- asymbol **s;
-
- s = _bfd_generic_link_get_symbols (abfd);
- BFD_ASSERT (s != (asymbol **) NULL);
-
- /* Find all symbols past this point, and make them know
- what's happened */
- while (*s)
- {
- asymbol *p = *s;
- if (p->section == input_section)
- {
- /* This was pointing into this section, so mangle it */
- if (p->value > value)
- {
- p->value -= slip;
- if (p->udata.p != NULL)
- {
- struct generic_link_hash_entry *h;
-
- h = (struct generic_link_hash_entry *) p->udata.p;
- BFD_ASSERT (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak);
- h->root.u.def.value -= slip;
- BFD_ASSERT (h->root.u.def.value == p->value);
- }
- }
- }
- s++;
- }
-}
-
-boolean
-bfd_coff_reloc16_relax_section (abfd, i, link_info, again)
- bfd *abfd;
- asection *i;
- struct bfd_link_info *link_info;
- boolean *again;
-{
- /* Get enough memory to hold the stuff */
- bfd *input_bfd = i->owner;
- asection *input_section = i;
- int shrink = 0 ;
- long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
- arelent **reloc_vector = NULL;
- long reloc_count;
-
- /* We only run this relaxation once. It might work to run it more
- often, but it hasn't been tested. */
- *again = false;
-
- if (reloc_size < 0)
- return false;
-
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
- if (!reloc_vector && reloc_size > 0)
- return false;
-
- /* Get the relocs and think about them */
- reloc_count =
- bfd_canonicalize_reloc (input_bfd, input_section, reloc_vector,
- _bfd_generic_link_get_symbols (input_bfd));
- if (reloc_count < 0)
- {
- free (reloc_vector);
- return false;
- }
-
- if (reloc_count > 0)
- {
- arelent **parent;
- for (parent = reloc_vector; *parent; parent++)
- {
- shrink = bfd_coff_reloc16_estimate (abfd, input_section,
- *parent, shrink, link_info);
- }
- }
-
- input_section->_cooked_size -= shrink;
- free((char *)reloc_vector);
- return true;
-}
-
-bfd_byte *
-bfd_coff_reloc16_get_relocated_section_contents(in_abfd,
- link_info,
- link_order,
- data,
- relocateable,
- symbols)
- bfd *in_abfd;
- struct bfd_link_info *link_info;
- struct bfd_link_order *link_order;
- bfd_byte *data;
- boolean relocateable;
- asymbol **symbols;
-{
- /* Get enough memory to hold the stuff */
- bfd *input_bfd = link_order->u.indirect.section->owner;
- asection *input_section = link_order->u.indirect.section;
- long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
- arelent **reloc_vector;
- long reloc_count;
-
- if (reloc_size < 0)
- return NULL;
-
- /* If producing relocateable output, don't bother to relax. */
- if (relocateable)
- return bfd_generic_get_relocated_section_contents (in_abfd, link_info,
- link_order,
- data, relocateable,
- symbols);
-
- /* read in the section */
- if (! bfd_get_section_contents(input_bfd,
- input_section,
- data,
- 0,
- input_section->_raw_size))
- return NULL;
-
-
- reloc_vector = (arelent **) bfd_malloc((size_t) reloc_size);
- if (!reloc_vector && reloc_size != 0)
- return NULL;
-
- reloc_count = bfd_canonicalize_reloc (input_bfd,
- input_section,
- reloc_vector,
- symbols);
- if (reloc_count < 0)
- {
- free (reloc_vector);
- return NULL;
- }
-
- if (reloc_count > 0)
- {
- arelent **parent = reloc_vector;
- arelent *reloc ;
- unsigned int dst_address = 0;
- unsigned int src_address = 0;
- unsigned int run;
- unsigned int idx;
-
- /* Find how long a run we can do */
- while (dst_address < link_order->size)
- {
- reloc = *parent;
- if (reloc)
- {
- /* Note that the relaxing didn't tie up the addresses in the
- relocation, so we use the original address to work out the
- run of non-relocated data */
- run = reloc->address - src_address;
- parent++;
- }
- else
- {
- run = link_order->size - dst_address;
- }
- /* Copy the bytes */
- for (idx = 0; idx < run; idx++)
- {
- data[dst_address++] = data[src_address++];
- }
-
- /* Now do the relocation */
-
- if (reloc)
- {
- bfd_coff_reloc16_extra_cases (input_bfd, link_info, link_order,
- reloc, data, &src_address,
- &dst_address);
- }
- }
- }
- free((char *)reloc_vector);
- return data;
-}
-
diff --git a/contrib/gdb/bfd/riscix.c b/contrib/gdb/bfd/riscix.c
deleted file mode 100644
index 21a86d5..0000000
--- a/contrib/gdb/bfd/riscix.c
+++ /dev/null
@@ -1,644 +0,0 @@
-/* BFD back-end for RISC iX (Acorn, arm) binaries.
- Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
- Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-/* RISC iX overloads the MAGIC field to indicate more than just the usual
- [ZNO]MAGIC values. Also included are squeezing information and
- shared library usage. */
-
-/* The following come from the man page. */
-#define SHLIBLEN 60
-
-#define MF_IMPURE 00200
-#define MF_SQUEEZED 01000
-#define MF_USES_SL 02000
-#define MF_IS_SL 04000
-
-/* Common combinations. */
-#define IMAGIC (MF_IMPURE|ZMAGIC) /* Demand load (impure text) */
-#define SPOMAGIC (MF_USES_SL|OMAGIC) /* OMAGIC with large header */
- /* -- may contain a ref to a */
- /* shared lib required by the */
- /* object. */
-#define SLOMAGIC (MF_IS_SL|OMAGIC) /* A reference to a shared library */
- /* The text portion of the object */
- /* contains "overflow text" from */
- /* the shared library to be linked */
- /* in with an object */
-#define QMAGIC (MF_SQUEEZED|ZMAGIC) /* Sqeezed demand paged. */
- /* NOTE: This interpretation of */
- /* QMAGIC seems to be at variance */
- /* With that used on other */
- /* architectures. */
-#define SPZMAGIC (MF_USES_SL|ZMAGIC) /* program which uses sl */
-#define SPQMAGIC (MF_USES_SL|QMAGIC) /* sqeezed ditto */
-#define SLZMAGIC (MF_IS_SL|ZMAGIC) /* shared lib part of prog */
-#define SLPZMAGIC (MF_USES_SL|SLZMAGIC) /* sl which uses another */
-
-#define N_SHARED_LIB(x) ((x).a_info & MF_USES_SL)
-
-/* Only a pure OMAGIC file has the minimal header */
-#define N_TXTOFF(x) \
- ((x).a_info == OMAGIC ? 32 \
- : (N_MAGIC(x) == ZMAGIC) ? TARGET_PAGE_SIZE \
- : 999)
-
-#define N_TXTADDR(x) \
- (N_MAGIC(x) != ZMAGIC ? 0 /* object file or NMAGIC */ \
- /* Programs with shared libs are loaded at the first page after all the \
- text segments of the shared library programs. Without looking this \
- up we can't know exactly what the address will be. A reasonable guess \
- is that a_entry will be in the first page of the executable. */ \
- : N_SHARED_LIB(x) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) \
- : TEXT_START_ADDR)
-
-#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)
-
-#define TEXT_START_ADDR 32768
-#define TARGET_PAGE_SIZE 32768
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define DEFAULT_ARCH bfd_arch_arm
-
-#define MY(OP) CAT(riscix_,OP)
-#define TARGETNAME "a.out-riscix"
-#define N_BADMAG(x) ((((x).a_info & ~007200) != ZMAGIC) && \
- (((x).a_info & ~006000) != OMAGIC) && \
- ((x).a_info != NMAGIC))
-#define N_MAGIC(x) ((x).a_info & ~07200)
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "assert.h"
-
-#define WRITE_HEADERS(abfd, execp) \
- { \
- bfd_size_type text_size; /* dummy vars */ \
- file_ptr text_end; \
- if (adata(abfd).magic == undecided_magic) \
- NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
- \
- 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); \
- \
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
- if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
- != EXEC_BYTES_SIZE) \
- return false; \
- /* Now write out reloc info, followed by syms and strings */ \
- \
- if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
- && bfd_get_symcount (abfd) != 0) \
- { \
- if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0) \
- return false; \
- \
- if (! NAME(aout,write_syms)(abfd)) return false; \
- \
- if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0) \
- return false; \
- \
- if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd))) \
- return false; \
- if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0) \
- return false; \
- \
- if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
- return false; \
- } \
- }
-
-#include "libaout.h"
-#include "aout/aout64.h"
-
-static bfd_reloc_status_type
-riscix_fix_pcrel_26_done PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-
-static bfd_reloc_status_type
-riscix_fix_pcrel_26 PARAMS ((bfd *, arelent *, asymbol *, PTR,
- asection *, bfd *, char **));
-
-static reloc_howto_type riscix_std_reloc_howto[] = {
- /* type rs size bsz pcrel bitpos ovrf sf name part_inpl readmask setmask pcdone */
- HOWTO( 0, 0, 0, 8, false, 0, complain_overflow_bitfield,0,"8", true, 0x000000ff,0x000000ff, false),
- HOWTO( 1, 0, 1, 16, false, 0, complain_overflow_bitfield,0,"16", true, 0x0000ffff,0x0000ffff, false),
- HOWTO( 2, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"32", true, 0xffffffff,0xffffffff, false),
- HOWTO( 3, 2, 3, 26, true, 0, complain_overflow_signed, riscix_fix_pcrel_26 , "ARM26", true, 0x00ffffff,0x00ffffff, false),
- HOWTO( 4, 0, 0, 8, true, 0, complain_overflow_signed, 0,"DISP8", true, 0x000000ff,0x000000ff, true),
- HOWTO( 5, 0, 1, 16, true, 0, complain_overflow_signed, 0,"DISP16", true, 0x0000ffff,0x0000ffff, true),
- HOWTO( 6, 0, 2, 32, true, 0, complain_overflow_signed, 0,"DISP32", true, 0xffffffff,0xffffffff, true),
- HOWTO( 7, 2, 3, 26, false, 0, complain_overflow_signed, riscix_fix_pcrel_26_done, "ARM26D",true,0x00ffffff,0x00ffffff, false),
- {-1},
- HOWTO( 9, 0, -1, 16, false, 0, complain_overflow_bitfield,0,"NEG16", true, 0x0000ffff,0x0000ffff, false),
- HOWTO( 10, 0, -2, 32, false, 0, complain_overflow_bitfield,0,"NEG32", true, 0xffffffff,0xffffffff, false)
-};
-
-#define RISCIX_TABLE_SIZE \
- (sizeof (riscix_std_reloc_howto) / sizeof (reloc_howto_type))
-
-
-static bfd_reloc_status_type
-riscix_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- /* This is dead simple at present. */
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_type
-riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- bfd_vma relocation;
- bfd_size_type addr = reloc_entry->address;
- long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
- bfd_reloc_status_type flag = bfd_reloc_ok;
-
- /* If this is an undefined symbol, return error */
- if (symbol->section == &bfd_und_section
- && (symbol->flags & BSF_WEAK) == 0)
- return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
-
- /* If the sections are different, and we are doing a partial relocation,
- just ignore it for now. */
- if (symbol->section->name != input_section->name
- && output_bfd != (bfd *)NULL)
- return bfd_reloc_continue;
-
- relocation = (target & 0x00ffffff) << 2;
- relocation = (relocation ^ 0x02000000) - 0x02000000; /* Sign extend */
- relocation += symbol->value;
- relocation += symbol->section->output_section->vma;
- relocation += symbol->section->output_offset;
- relocation += reloc_entry->addend;
- relocation -= input_section->output_section->vma;
- relocation -= input_section->output_offset;
- relocation -= addr;
- if (relocation & 3)
- return bfd_reloc_overflow;
-
- /* Check for overflow */
- if (relocation & 0x02000000)
- {
- if ((relocation & ~0x03ffffff) != ~0x03ffffff)
- flag = bfd_reloc_overflow;
- }
- else if (relocation & ~0x03ffffff)
- flag = bfd_reloc_overflow;
-
- target &= ~0x00ffffff;
- target |= (relocation >> 2) & 0x00ffffff;
- bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
-
- /* Now the ARM magic... Change the reloc type so that it is marked as done.
- Strictly this is only necessary if we are doing a partial relocation. */
- reloc_entry->howto = &riscix_std_reloc_howto[7];
-
- return flag;
-}
-
-reloc_howto_type *
-DEFUN(riscix_reloc_type_lookup,(abfd,code),
- bfd *abfd AND
- bfd_reloc_code_real_type code)
-{
-#define ASTD(i,j) case i: return &riscix_std_reloc_howto[j]
- if (code == BFD_RELOC_CTOR)
- switch (bfd_get_arch_info (abfd)->bits_per_address)
- {
- case 32:
- code = BFD_RELOC_32;
- break;
- default: return (reloc_howto_type *) NULL;
- }
-
- switch (code)
- {
- ASTD (BFD_RELOC_16, 1);
- ASTD (BFD_RELOC_32, 2);
- ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3);
- ASTD (BFD_RELOC_8_PCREL, 4);
- ASTD (BFD_RELOC_16_PCREL, 5);
- ASTD (BFD_RELOC_32_PCREL, 6);
- default: return (reloc_howto_type *) NULL;
- }
-}
-
-#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define MY_bfd_final_link _bfd_generic_final_link
-
-#define MY_bfd_reloc_type_lookup riscix_reloc_type_lookup
-#define MY_canonicalize_reloc riscix_canonicalize_reloc
-#define MY_object_p riscix_object_p
-
-static const bfd_target *riscix_callback PARAMS ((bfd *));
-
-void
-riscix_swap_std_reloc_out (abfd, g, natptr)
- bfd *abfd;
- arelent *g;
- struct reloc_std_external *natptr;
-{
- int r_index;
- asymbol *sym = *(g->sym_ptr_ptr);
- int r_extern;
- int r_length;
- int r_pcrel;
- int r_neg = 0; /* Negative relocs use the BASEREL bit. */
- asection *output_section = sym->section->output_section;
-
- PUT_WORD(abfd, g->address, natptr->r_address);
-
- r_length = g->howto->size ; /* Size as a power of two */
- if (r_length < 0)
- {
- r_length = -r_length;
- r_neg = 1;
- }
-
- r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */
-
- /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the
- relocation has been done already (Only for the 26-bit one I think)???!!!
- */
-
- if (r_length == 3)
- r_pcrel = r_pcrel ? 0 : 1;
-
-
-#if 0
- /* For a standard reloc, the addend is in the object file. */
- r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;
-#endif
-
- /* name was clobbered by aout_write_syms to be symbol index */
-
- /* If this relocation is relative to a symbol then set the
- r_index to the symbols index, and the r_extern bit.
-
- Absolute symbols can come in in two ways, either as an offset
- from the abs section, or as a symbol which has an abs value.
- check for that here
- */
-
- if (bfd_is_com_section (output_section)
- || output_section == &bfd_abs_section
- || output_section == &bfd_und_section)
- {
- if (bfd_abs_section.symbol == sym)
- {
- /* Whoops, looked like an abs symbol, but is really an offset
- from the abs section */
- r_index = 0;
- r_extern = 0;
- }
- else
- {
- /* Fill in symbol */
- r_extern = 1;
- r_index = stoi((*(g->sym_ptr_ptr))->flags);
- }
- }
- else
- {
- /* Just an ordinary section */
- r_extern = 0;
- r_index = output_section->target_index;
- }
-
- /* now the fun stuff */
- if (bfd_header_big_endian (abfd))
- {
- 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_neg ? RELOC_STD_BITS_BASEREL_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_neg ? RELOC_STD_BITS_BASEREL_LITTLE: 0)
- | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE));
- }
-}
-
-boolean
-riscix_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)
- return false;
-
- generic = section->orelocation;
-
- for (natptr = native;
- count != 0;
- --count, natptr += each_size, ++generic)
- riscix_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 just like the standard aoutx.h version but we need to do our
- * own mapping of external reloc type values to howto entries.
- */
-long
-MY(canonicalize_reloc)(abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr = section->relocation;
- unsigned int count, c;
- extern reloc_howto_type NAME(aout,std_howto_table)[];
-
- /* If we have already read in the relocation table, return the values. */
- 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;
- }
- *relptr = 0;
- return section->reloc_count;
- }
- if (tblptr && section->reloc_count) {
- for (count = 0; count++ < section->reloc_count;)
- *relptr++ = tblptr++;
- *relptr = 0;
- return section->reloc_count;
- }
-
- if (!NAME(aout,slurp_reloc_table)(abfd, section, symbols))
- return -1;
- tblptr = section->relocation;
-
- /* fix up howto entries */
- for (count = 0; count++ < section->reloc_count;)
- {
- c = tblptr->howto - NAME(aout,std_howto_table);
- assert (c < RISCIX_TABLE_SIZE);
- tblptr->howto = &riscix_std_reloc_howto[c];
-
- *relptr++ = tblptr++;
- }
- *relptr = 0;
- return section->reloc_count;
-}
-
-/* This is the same as NAME(aout,some_aout_object_p), but has different
- expansions of the macro definitions. */
-
-const bfd_target *
-riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p)
- bfd *abfd;
- struct internal_exec *execp;
- const bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
-{
- struct aout_data_struct *rawptr, *oldrawptr;
- const bfd_target *result;
-
- rawptr = ((struct aout_data_struct *)
- bfd_zalloc (abfd, sizeof (struct aout_data_struct )));
-
- if (rawptr == NULL)
- return 0;
-
- oldrawptr = abfd->tdata.aout_data;
- abfd->tdata.aout_data = rawptr;
-
- /* Copy the contents of the old tdata struct.
- In particular, we want the subformat, since for hpux it was set in
- hp300hpux.c:swap_exec_header_in and will be used in
- hp300hpux.c:callback. */
- if (oldrawptr != NULL)
- *abfd->tdata.aout_data = *oldrawptr;
-
- abfd->tdata.aout_data->a.hdr = &rawptr->e;
- *(abfd->tdata.aout_data->a.hdr) = *execp; /* Copy in the internal_exec
- struct */
- execp = abfd->tdata.aout_data->a.hdr;
-
- /* Set the file flags */
- abfd->flags = NO_FLAGS;
- if (execp->a_drsize || execp->a_trsize)
- abfd->flags |= HAS_RELOC;
- /* Setting of EXEC_P has been deferred to the bottom of this function */
- if (execp->a_syms)
- abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
- if (N_DYNAMIC(*execp))
- abfd->flags |= DYNAMIC;
-
-
- if ((execp->a_info & MF_SQUEEZED) != 0) /* Squeezed files aren't supported
- (yet)! */
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
- else if ((execp->a_info & MF_IS_SL) != 0) /* Nor are shared libraries */
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
- else if (N_MAGIC (*execp) == ZMAGIC)
- {
- abfd->flags |= D_PAGED | WP_TEXT;
- adata (abfd).magic = z_magic;
- }
- else if (N_MAGIC (*execp) == NMAGIC)
- {
- abfd->flags |= WP_TEXT;
- adata (abfd).magic = n_magic;
- }
- else if (N_MAGIC (*execp) == OMAGIC)
- adata (abfd).magic = o_magic;
- else
- {
- /* Should have been checked with N_BADMAG before this routine
- was called. */
- abort ();
- }
-
- 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);
-
- /* 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;
-
- obj_aout_external_syms (abfd) = NULL;
- obj_aout_external_strings (abfd) = NULL;
- obj_aout_sym_hashes (abfd) = NULL;
-
- if (! NAME(aout,make_sections) (abfd))
- return NULL;
-
- obj_datasec (abfd)->_raw_size = execp->a_data;
- obj_bsssec (abfd)->_raw_size = execp->a_bss;
-
- obj_textsec (abfd)->flags =
- (execp->a_trsize != 0
- ? (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_RELOC)
- : (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS));
- obj_datasec (abfd)->flags =
- (execp->a_drsize != 0
- ? (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS | SEC_RELOC)
- : (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS));
- obj_bsssec (abfd)->flags = SEC_ALLOC;
-
- result = (*callback_to_real_object_p)(abfd);
-
-#if defined(MACH) || defined(STAT_FOR_EXEC)
- /* The original heuristic doesn't work in some important cases. The
- * a.out file has no information about the text start address. For
- * files (like kernels) linked to non-standard addresses (ld -Ttext
- * nnn) the entry point may not be between the default text start
- * (obj_textsec(abfd)->vma) and (obj_textsec(abfd)->vma) + text size
- * This is not just a mach issue. Many kernels are loaded at non
- * standard addresses.
- */
- {
- struct stat stat_buf;
- if (abfd->iostream != NULL
- && (abfd->flags & BFD_IN_MEMORY) == 0
- && (fstat(fileno((FILE *) (abfd->iostream)), &stat_buf) == 0)
- && ((stat_buf.st_mode & 0111) != 0))
- abfd->flags |= EXEC_P;
- }
-#else /* ! MACH */
- /* Now that the segment addresses have been worked out, take a better
- guess at whether the file is executable. If the entry point
- is within the text segment, assume it is. (This makes files
- executable even if their entry point address is 0, as long as
- their text starts at zero.)
-
- At some point we should probably break down and stat the file and
- declare it executable if (one of) its 'x' bits are on... */
- if ((execp->a_entry >= obj_textsec(abfd)->vma) &&
- (execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))
- abfd->flags |= EXEC_P;
-#endif /* MACH */
- if (result)
- {
- }
- else
- {
- free (rawptr);
- abfd->tdata.aout_data = oldrawptr;
- }
- return result;
-}
-
-
-static const bfd_target *
-MY(object_p) (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes; /* Raw exec header from file */
- struct internal_exec exec; /* Cleaned-up exec header */
- const bfd_target *target;
-
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
-
- if (N_BADMAG (exec)) return 0;
-#ifdef MACHTYPE_OK
- if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) return 0;
-#endif
-
- NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
-
- target = riscix_some_aout_object_p (abfd, &exec, MY(callback));
-
- return target;
-}
-
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/rs6000-core.c b/contrib/gdb/bfd/rs6000-core.c
deleted file mode 100644
index 4889f72..0000000
--- a/contrib/gdb/bfd/rs6000-core.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/* IBM RS/6000 "XCOFF" back-end for BFD.
- Copyright (C) 1990, 1991, 1995 Free Software Foundation, Inc.
- FIXME: Can someone provide a transliteration of this name into ASCII?
- Using the following chars caused a compiler warning on HIUX (so I replaced
- them with octal escapes), and isn't useful without an understanding of what
- character set it is.
- Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This port currently only handles reading object files, except when
- compiled on an RS/6000 host. -- no archive support, no core files.
- In all cases, it does not support writing.
-
- FIXMEmgo comments are left from Metin Ozisik's original port.
-
- This is in a separate file from coff-rs6000.c, because it includes
- system include files that conflict with coff/rs6000.h.
- */
-
-/* Internalcoff.h and coffcode.h modify themselves based on this flag. */
-#define RS6000COFF_C 1
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#ifdef AIX_CORE
-
-/* AOUTHDR is defined by the above. We need another defn of it, from the
- system include files. Punt the old one and get us a new name for the
- typedef in the system include files. */
-#ifdef AOUTHDR
-#undef AOUTHDR
-#endif
-#define AOUTHDR second_AOUTHDR
-
-#undef SCNHDR
-
-
-/* ------------------------------------------------------------------------ */
-/* Support for core file stuff.. */
-/* ------------------------------------------------------------------------ */
-
-#include <sys/user.h>
-#include <sys/ldr.h>
-#include <sys/core.h>
-
-
-/* Number of special purpose registers supported by gdb. 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 core_hdr(bfd) (((Rs6kCorData*)(bfd->tdata.any))->hdr)
-#define core_datasec(bfd) (((Rs6kCorData*)(bfd->tdata.any))->data_section)
-#define core_stacksec(bfd) (((Rs6kCorData*)(bfd->tdata.any))->stack_section)
-#define core_regsec(bfd) (((Rs6kCorData*)(bfd->tdata.any))->reg_section)
-#define core_reg2sec(bfd) (((Rs6kCorData*)(bfd->tdata.any))->reg2_section)
-
-/* AIX 4.1 Changed the names and locations of a few items in the core file,
- this seems to be the quickest easiet way to deal with it.
-
- Note however that encoding magic addresses (STACK_END_ADDR) is going
- to be _very_ fragile. But I don't see any easy way to get that info
- right now. */
-#ifdef CORE_VERSION_1
-#define CORE_DATA_SIZE_FIELD c_u.U_dsize
-#define CORE_COMM_FIELD c_u.U_comm
-#define SAVE_FIELD c_mst
-#define STACK_END_ADDR 0x2ff23000
-#else
-#define CORE_DATA_SIZE_FIELD c_u.u_dsize
-#define CORE_COMM_FIELD c_u.u_comm
-#define SAVE_FIELD c_u.u_save
-#define STACK_END_ADDR 0x2ff80000
-#endif
-
-/* These are stored in the bfd's tdata */
-typedef struct {
- struct core_dump hdr; /* core file header */
- asection *data_section,
- *stack_section,
- *reg_section, /* section for GPRs and special registers. */
- *reg2_section; /* section for FPRs. */
-
- /* This tells us where everything is mapped (shared libraries and so on).
- GDB needs it. */
- asection *ldinfo_section;
-#define core_ldinfosec(bfd) (((Rs6kCorData *)(bfd->tdata.any))->ldinfo_section)
-} Rs6kCorData;
-
-
-/* Decide if a given bfd represents a `core' file or not. There really is no
- magic number or anything like, in rs6000coff. */
-
-const 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);
- if (fd < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return NULL;
- }
-
- if (fstat (fd, &statbuf) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- close (fd);
- return NULL;
- }
- if (read (fd, &coredata, sizeof (struct core_dump))
- != sizeof (struct core_dump))
- {
- bfd_set_error (bfd_error_wrong_format);
- close (fd);
- return NULL;
- }
-
- if (close (fd) < 0)
- {
- bfd_set_error (bfd_error_system_call);
- return NULL;
- }
-
- /* If the core file ulimit is too small, the system will first
- omit the data segment, then omit the stack, then decline to
- dump core altogether (as far as I know UBLOCK_VALID and LE_VALID
- are always set) (this is based on experimentation on AIX 3.2).
- Now, the thing is that GDB users will be surprised
- if segments just silently don't appear (well, maybe they would
- think to check "info files", I don't know), but we have no way of
- returning warnings (as opposed to errors).
-
- For the data segment, we have no choice but to keep going if it's
- not there, since the default behavior is not to dump it (regardless
- of the ulimit, it's based on SA_FULLDUMP). But for the stack segment,
- if it's not there, we refuse to have anything to do with this core
- file. The usefulness of a core dump without a stack segment is pretty
- limited anyway. */
-
- if (!(coredata.c_flag & UBLOCK_VALID)
- || !(coredata.c_flag & LE_VALID))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- if ((coredata.c_flag & CORE_TRUNC)
- || !(coredata.c_flag & USTACK_VALID))
- {
- bfd_set_error (bfd_error_file_truncated);
- return NULL;
- }
-
- /* Don't check the core file size for a full core, AIX 4.1 includes
- additional shared library sections in a full core. */
- if (!(coredata.c_flag & FULL_CORE)
- && ((bfd_vma)coredata.c_stack + coredata.c_size) != statbuf.st_size)
- {
- /* If the size is wrong, it means we're misinterpreting something. */
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* Sanity check on the c_tab field. */
- if ((u_long) coredata.c_tab < sizeof coredata ||
- (u_long) coredata.c_tab >= statbuf.st_size ||
- (long) coredata.c_tab >= (long)coredata.c_stack)
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* maybe you should alloc space for the whole core chunk over here!! FIXMEmgo */
- tmpptr = (char*)bfd_zalloc (abfd, sizeof (Rs6kCorData));
- if (!tmpptr)
- return NULL;
-
- set_tdata (abfd, tmpptr);
-
- /* Copy core file header. */
- core_hdr (abfd) = coredata;
-
- /* .stack section. */
- if ((core_stacksec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
- == NULL)
- return NULL;
- core_stacksec (abfd)->name = ".stack";
- core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
- core_stacksec (abfd)->_raw_size = coredata.c_size;
- core_stacksec (abfd)->vma = STACK_END_ADDR - coredata.c_size;
- core_stacksec (abfd)->filepos = (int)coredata.c_stack; /*???? */
-
- /* .reg section for GPRs and special registers. */
- if ((core_regsec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
- == NULL)
- return NULL;
- core_regsec (abfd)->name = ".reg";
- core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
- core_regsec (abfd)->_raw_size = (32 + NUM_OF_SPEC_REGS) * 4;
- core_regsec (abfd)->vma = 0; /* not used?? */
- core_regsec (abfd)->filepos =
- (char*)&coredata.SAVE_FIELD - (char*)&coredata;
-
- /* .reg2 section for FPRs (floating point registers). */
- if ((core_reg2sec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
- == NULL)
- return NULL;
- core_reg2sec (abfd)->name = ".reg2";
- core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
- core_reg2sec (abfd)->_raw_size = 8 * 32; /* 32 FPRs. */
- core_reg2sec (abfd)->vma = 0; /* not used?? */
- core_reg2sec (abfd)->filepos =
- (char*)&coredata.SAVE_FIELD.fpr[0] - (char*)&coredata;
-
- if ((core_ldinfosec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
- == NULL)
- return NULL;
- core_ldinfosec (abfd)->name = ".ldinfo";
- core_ldinfosec (abfd)->flags = SEC_HAS_CONTENTS;
- /* To actually find out how long this section is in this particular
- core dump would require going down the whole list of struct ld_info's.
- See if we can just fake it. */
- core_ldinfosec (abfd)->_raw_size = 0x7fffffff;
- /* Not relevant for ldinfo section. */
- core_ldinfosec (abfd)->vma = 0;
- core_ldinfosec (abfd)->filepos = (file_ptr) coredata.c_tab;
-
- /* set up section chain here. */
- abfd->section_count = 4;
- abfd->sections = core_stacksec (abfd);
- core_stacksec (abfd)->next = core_regsec(abfd);
- core_regsec (abfd)->next = core_reg2sec (abfd);
- core_reg2sec (abfd)->next = core_ldinfosec (abfd);
- core_ldinfosec (abfd)->next = NULL;
-
- if (coredata.c_flag & FULL_CORE)
- {
- asection *sec = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (sec == NULL)
- return NULL;
- sec->name = ".data";
- sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
- sec->_raw_size = coredata.CORE_DATA_SIZE_FIELD;
- sec->vma = CDATA_ADDR (coredata.CORE_DATA_SIZE_FIELD);
- sec->filepos = (int)coredata.c_stack + coredata.c_size;
-
- sec->next = abfd->sections;
- abfd->sections = sec;
- ++abfd->section_count;
- }
-
- return abfd->xvec; /* this is garbage for now. */
-}
-
-
-
-/* return `true' if given core is from the given executable.. */
-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];
- const char *str1, *str2;
-
- /* Use bfd_xxx routines, rather than O/S primitives, do error checking!!
- FIXMEmgo */
- /* Actually should be able to use bfd_get_section_contents now that
- we have a .ldinfo section. */
- fd = fopen (core_bfd->filename, FOPEN_RB);
-
- 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);
-
- 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) == 0;
-}
-
-char *
-rs6000coff_core_file_failing_command (abfd)
- bfd *abfd;
-{
- char *com = core_hdr (abfd).CORE_COMM_FIELD;
- if (*com)
- return com;
- else
- return 0;
-}
-
-int
-rs6000coff_core_file_failing_signal (abfd)
- bfd *abfd;
-{
- return core_hdr (abfd).c_signo;
-}
-
-
-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)))
- (*_bfd_error_handler)
- ("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, sizeof (mstatus.gpr), 1, 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, 4 * NUM_OF_SPEC_REGS, 1, 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 /* AIX_CORE */
diff --git a/contrib/gdb/bfd/som.c b/contrib/gdb/bfd/som.c
deleted file mode 100644
index dd03d99..0000000
--- a/contrib/gdb/bfd/som.c
+++ /dev/null
@@ -1,5999 +0,0 @@
-/* bfd back-end for HP PA-RISC SOM objects.
- Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996
- Free Software Foundation, Inc.
-
- Contributed by the Center for Software Science at the
- University of Utah (pa-gdb-bugs@cs.utah.edu).
-
- This file is part of BFD, the Binary File Descriptor library.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-
-#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
-
-#include "libbfd.h"
-#include "som.h"
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <signal.h>
-#include <machine/reg.h>
-#include <sys/file.h>
-#include <errno.h>
-
-/* Magic not defined in standard HP-UX header files until 8.0 */
-
-#ifndef CPU_PA_RISC1_0
-#define CPU_PA_RISC1_0 0x20B
-#endif /* CPU_PA_RISC1_0 */
-
-#ifndef CPU_PA_RISC1_1
-#define CPU_PA_RISC1_1 0x210
-#endif /* CPU_PA_RISC1_1 */
-
-#ifndef _PA_RISC1_0_ID
-#define _PA_RISC1_0_ID CPU_PA_RISC1_0
-#endif /* _PA_RISC1_0_ID */
-
-#ifndef _PA_RISC1_1_ID
-#define _PA_RISC1_1_ID CPU_PA_RISC1_1
-#endif /* _PA_RISC1_1_ID */
-
-#ifndef _PA_RISC_MAXID
-#define _PA_RISC_MAXID 0x2FF
-#endif /* _PA_RISC_MAXID */
-
-#ifndef _PA_RISC_ID
-#define _PA_RISC_ID(__m_num) \
- (((__m_num) == _PA_RISC1_0_ID) || \
- ((__m_num) >= _PA_RISC1_1_ID && (__m_num) <= _PA_RISC_MAXID))
-#endif /* _PA_RISC_ID */
-
-
-/* HIUX in it's infinite stupidity changed the names for several "well
- known" constants. Work around such braindamage. Try the HPUX version
- first, then the HIUX version, and finally provide a default. */
-#ifdef HPUX_AUX_ID
-#define EXEC_AUX_ID HPUX_AUX_ID
-#endif
-
-#if !defined (EXEC_AUX_ID) && defined (HIUX_AUX_ID)
-#define EXEC_AUX_ID HIUX_AUX_ID
-#endif
-
-#ifndef EXEC_AUX_ID
-#define EXEC_AUX_ID 0
-#endif
-
-/* Size (in chars) of the temporary buffers used during fixup and string
- table writes. */
-
-#define SOM_TMP_BUFSIZE 8192
-
-/* Size of the hash table in archives. */
-#define SOM_LST_HASH_SIZE 31
-
-/* Max number of SOMs to be found in an archive. */
-#define SOM_LST_MODULE_LIMIT 1024
-
-/* Generic alignment macro. */
-#define SOM_ALIGN(val, alignment) \
- (((val) + (alignment) - 1) & ~((alignment) - 1))
-
-/* SOM allows any one of the four previous relocations to be reused
- with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP
- relocations are always a single byte, using a R_PREV_FIXUP instead
- of some multi-byte relocation makes object files smaller.
-
- Note one side effect of using a R_PREV_FIXUP is the relocation that
- is being repeated moves to the front of the queue. */
-struct reloc_queue
- {
- unsigned char *reloc;
- unsigned int size;
- } reloc_queue[4];
-
-/* This fully describes the symbol types which may be attached to
- an EXPORT or IMPORT directive. Only SOM uses this formation
- (ELF has no need for it). */
-typedef enum
-{
- SYMBOL_TYPE_UNKNOWN,
- SYMBOL_TYPE_ABSOLUTE,
- SYMBOL_TYPE_CODE,
- SYMBOL_TYPE_DATA,
- SYMBOL_TYPE_ENTRY,
- SYMBOL_TYPE_MILLICODE,
- SYMBOL_TYPE_PLABEL,
- SYMBOL_TYPE_PRI_PROG,
- SYMBOL_TYPE_SEC_PROG,
-} pa_symbol_type;
-
-struct section_to_type
-{
- char *section;
- char type;
-};
-
-/* Assorted symbol information that needs to be derived from the BFD symbol
- and/or the BFD backend private symbol data. */
-struct som_misc_symbol_info
-{
- unsigned int symbol_type;
- unsigned int symbol_scope;
- unsigned int arg_reloc;
- unsigned int symbol_info;
- unsigned int symbol_value;
-};
-
-/* Forward declarations */
-
-static boolean som_mkobject PARAMS ((bfd *));
-static const bfd_target * som_object_setup PARAMS ((bfd *,
- struct header *,
- struct som_exec_auxhdr *));
-static boolean setup_sections PARAMS ((bfd *, struct header *));
-static const bfd_target * som_object_p PARAMS ((bfd *));
-static boolean som_write_object_contents PARAMS ((bfd *));
-static boolean som_slurp_string_table PARAMS ((bfd *));
-static unsigned int som_slurp_symbol_table PARAMS ((bfd *));
-static long som_get_symtab_upper_bound PARAMS ((bfd *));
-static long som_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
- arelent **, asymbol **));
-static long som_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
-static unsigned int som_set_reloc_info PARAMS ((unsigned char *, unsigned int,
- arelent *, asection *,
- asymbol **, boolean));
-static boolean som_slurp_reloc_table PARAMS ((bfd *, asection *,
- asymbol **, boolean));
-static long som_get_symtab PARAMS ((bfd *, asymbol **));
-static asymbol * som_make_empty_symbol PARAMS ((bfd *));
-static void som_print_symbol PARAMS ((bfd *, PTR,
- asymbol *, bfd_print_symbol_type));
-static boolean som_new_section_hook PARAMS ((bfd *, asection *));
-static boolean som_bfd_copy_private_symbol_data PARAMS ((bfd *, asymbol *,
- bfd *, asymbol *));
-static boolean som_bfd_copy_private_section_data PARAMS ((bfd *, asection *,
- bfd *, asection *));
-static boolean som_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-#define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
-#define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
-static boolean som_bfd_is_local_label PARAMS ((bfd *, asymbol *));
-static boolean som_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr, bfd_size_type));
-static boolean som_get_section_contents PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr, bfd_size_type));
-static boolean som_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
- unsigned long));
-static boolean som_find_nearest_line PARAMS ((bfd *, asection *,
- asymbol **, bfd_vma,
- CONST char **,
- CONST char **,
- unsigned int *));
-static void som_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
-static asection * bfd_section_from_som_symbol PARAMS ((bfd *,
- struct symbol_dictionary_record *));
-static int log2 PARAMS ((unsigned int));
-static bfd_reloc_status_type hppa_som_reloc PARAMS ((bfd *, arelent *,
- asymbol *, PTR,
- asection *, bfd *,
- char **));
-static void som_initialize_reloc_queue PARAMS ((struct reloc_queue *));
-static void som_reloc_queue_insert PARAMS ((unsigned char *, unsigned int,
- struct reloc_queue *));
-static void som_reloc_queue_fix PARAMS ((struct reloc_queue *, unsigned int));
-static int som_reloc_queue_find PARAMS ((unsigned char *, unsigned int,
- struct reloc_queue *));
-static unsigned char * try_prev_fixup PARAMS ((bfd *, int *, unsigned char *,
- unsigned int,
- struct reloc_queue *));
-
-static unsigned char * som_reloc_skip PARAMS ((bfd *, unsigned int,
- unsigned char *, unsigned int *,
- struct reloc_queue *));
-static unsigned char * som_reloc_addend PARAMS ((bfd *, int, unsigned char *,
- unsigned int *,
- struct reloc_queue *));
-static unsigned char * som_reloc_call PARAMS ((bfd *, unsigned char *,
- unsigned int *,
- arelent *, int,
- struct reloc_queue *));
-static unsigned long som_count_spaces PARAMS ((bfd *));
-static unsigned long som_count_subspaces PARAMS ((bfd *));
-static int compare_syms PARAMS ((const void *, const void *));
-static int compare_subspaces PARAMS ((const void *, const void *));
-static unsigned long som_compute_checksum PARAMS ((bfd *));
-static boolean som_prep_headers PARAMS ((bfd *));
-static int som_sizeof_headers PARAMS ((bfd *, boolean));
-static boolean som_finish_writing PARAMS ((bfd *));
-static boolean som_build_and_write_symbol_table PARAMS ((bfd *));
-static void som_prep_for_fixups PARAMS ((bfd *, asymbol **, unsigned long));
-static boolean som_write_fixups PARAMS ((bfd *, unsigned long, unsigned int *));
-static boolean som_write_space_strings PARAMS ((bfd *, unsigned long,
- unsigned int *));
-static boolean som_write_symbol_strings PARAMS ((bfd *, unsigned long,
- asymbol **, unsigned int,
- unsigned *));
-static boolean som_begin_writing PARAMS ((bfd *));
-static reloc_howto_type * som_bfd_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-static char som_section_type PARAMS ((const char *));
-static int som_decode_symclass PARAMS ((asymbol *));
-static boolean som_bfd_count_ar_symbols PARAMS ((bfd *, struct lst_header *,
- symindex *));
-
-static boolean som_bfd_fill_in_ar_symbols PARAMS ((bfd *, struct lst_header *,
- carsym **syms));
-static boolean som_slurp_armap PARAMS ((bfd *));
-static boolean som_write_armap PARAMS ((bfd *, unsigned int, struct orl *,
- unsigned int, int));
-static void som_bfd_derive_misc_symbol_info PARAMS ((bfd *, asymbol *,
- struct som_misc_symbol_info *));
-static boolean som_bfd_prep_for_ar_write PARAMS ((bfd *, unsigned int *,
- unsigned int *));
-static unsigned int som_bfd_ar_symbol_hash PARAMS ((asymbol *));
-static boolean som_bfd_ar_write_symbol_stuff PARAMS ((bfd *, unsigned int,
- unsigned int,
- struct lst_header));
-static CONST char *normalize PARAMS ((CONST char *file));
-static boolean som_is_space PARAMS ((asection *));
-static boolean som_is_subspace PARAMS ((asection *));
-static boolean som_is_container PARAMS ((asection *, asection *));
-static boolean som_bfd_free_cached_info PARAMS ((bfd *));
-static boolean som_bfd_link_split_section PARAMS ((bfd *, asection *));
-
-/* Map SOM section names to POSIX/BSD single-character symbol types.
-
- This table includes all the standard subspaces as defined in the
- current "PRO ABI for PA-RISC Systems", $UNWIND$ which for
- some reason was left out, and sections specific to embedded stabs. */
-
-static const struct section_to_type stt[] = {
- {"$TEXT$", 't'},
- {"$SHLIB_INFO$", 't'},
- {"$MILLICODE$", 't'},
- {"$LIT$", 't'},
- {"$CODE$", 't'},
- {"$UNWIND_START$", 't'},
- {"$UNWIND$", 't'},
- {"$PRIVATE$", 'd'},
- {"$PLT$", 'd'},
- {"$SHLIB_DATA$", 'd'},
- {"$DATA$", 'd'},
- {"$SHORTDATA$", 'g'},
- {"$DLT$", 'd'},
- {"$GLOBAL$", 'g'},
- {"$SHORTBSS$", 's'},
- {"$BSS$", 'b'},
- {"$GDB_STRINGS$", 'N'},
- {"$GDB_SYMBOLS$", 'N'},
- {0, 0}
-};
-
-/* About the relocation formatting table...
-
- There are 256 entries in the table, one for each possible
- relocation opcode available in SOM. We index the table by
- the relocation opcode. The names and operations are those
- defined by a.out_800 (4).
-
- Right now this table is only used to count and perform minimal
- processing on relocation streams so that they can be internalized
- into BFD and symbolically printed by utilities. To make actual use
- of them would be much more difficult, BFD's concept of relocations
- is far too simple to handle SOM relocations. The basic assumption
- that a relocation can be completely processed independent of other
- relocations before an object file is written is invalid for SOM.
-
- The SOM relocations are meant to be processed as a stream, they
- specify copying of data from the input section to the output section
- while possibly modifying the data in some manner. They also can
- specify that a variable number of zeros or uninitialized data be
- inserted on in the output segment at the current offset. Some
- relocations specify that some previous relocation be re-applied at
- the current location in the input/output sections. And finally a number
- of relocations have effects on other sections (R_ENTRY, R_EXIT,
- R_UNWIND_AUX and a variety of others). There isn't even enough room
- in the BFD relocation data structure to store enough information to
- perform all the relocations.
-
- Each entry in the table has three fields.
-
- The first entry is an index into this "class" of relocations. This
- index can then be used as a variable within the relocation itself.
-
- The second field is a format string which actually controls processing
- of the relocation. It uses a simple postfix machine to do calculations
- based on variables/constants found in the string and the relocation
- stream.
-
- The third field specifys whether or not this relocation may use
- a constant (V) from the previous R_DATA_OVERRIDE rather than a constant
- stored in the instruction.
-
- Variables:
-
- L = input space byte count
- D = index into class of relocations
- M = output space byte count
- N = statement number (unused?)
- O = stack operation
- R = parameter relocation bits
- S = symbol index
- T = first 32 bits of stack unwind information
- U = second 32 bits of stack unwind information
- V = a literal constant (usually used in the next relocation)
- P = a previous relocation
-
- Lower case letters (starting with 'b') refer to following
- bytes in the relocation stream. 'b' is the next 1 byte,
- c is the next 2 bytes, d is the next 3 bytes, etc...
- This is the variable part of the relocation entries that
- makes our life a living hell.
-
- numerical constants are also used in the format string. Note
- the constants are represented in decimal.
-
- '+', "*" and "=" represents the obvious postfix operators.
- '<' represents a left shift.
-
- Stack Operations:
-
- Parameter Relocation Bits:
-
- Unwind Entries:
-
- Previous Relocations: The index field represents which in the queue
- of 4 previous fixups should be re-applied.
-
- Literal Constants: These are generally used to represent addend
- parts of relocations when these constants are not stored in the
- fields of the instructions themselves. For example the instruction
- addil foo-$global$-0x1234 would use an override for "0x1234" rather
- than storing it into the addil itself. */
-
-struct fixup_format
-{
- int D;
- char *format;
-};
-
-static const struct fixup_format som_fixup_formats[256] =
-{
- /* R_NO_RELOCATION */
- 0, "LD1+4*=", /* 0x00 */
- 1, "LD1+4*=", /* 0x01 */
- 2, "LD1+4*=", /* 0x02 */
- 3, "LD1+4*=", /* 0x03 */
- 4, "LD1+4*=", /* 0x04 */
- 5, "LD1+4*=", /* 0x05 */
- 6, "LD1+4*=", /* 0x06 */
- 7, "LD1+4*=", /* 0x07 */
- 8, "LD1+4*=", /* 0x08 */
- 9, "LD1+4*=", /* 0x09 */
- 10, "LD1+4*=", /* 0x0a */
- 11, "LD1+4*=", /* 0x0b */
- 12, "LD1+4*=", /* 0x0c */
- 13, "LD1+4*=", /* 0x0d */
- 14, "LD1+4*=", /* 0x0e */
- 15, "LD1+4*=", /* 0x0f */
- 16, "LD1+4*=", /* 0x10 */
- 17, "LD1+4*=", /* 0x11 */
- 18, "LD1+4*=", /* 0x12 */
- 19, "LD1+4*=", /* 0x13 */
- 20, "LD1+4*=", /* 0x14 */
- 21, "LD1+4*=", /* 0x15 */
- 22, "LD1+4*=", /* 0x16 */
- 23, "LD1+4*=", /* 0x17 */
- 0, "LD8<b+1+4*=", /* 0x18 */
- 1, "LD8<b+1+4*=", /* 0x19 */
- 2, "LD8<b+1+4*=", /* 0x1a */
- 3, "LD8<b+1+4*=", /* 0x1b */
- 0, "LD16<c+1+4*=", /* 0x1c */
- 1, "LD16<c+1+4*=", /* 0x1d */
- 2, "LD16<c+1+4*=", /* 0x1e */
- 0, "Ld1+=", /* 0x1f */
- /* R_ZEROES */
- 0, "Lb1+4*=", /* 0x20 */
- 1, "Ld1+=", /* 0x21 */
- /* R_UNINIT */
- 0, "Lb1+4*=", /* 0x22 */
- 1, "Ld1+=", /* 0x23 */
- /* R_RELOCATION */
- 0, "L4=", /* 0x24 */
- /* R_DATA_ONE_SYMBOL */
- 0, "L4=Sb=", /* 0x25 */
- 1, "L4=Sd=", /* 0x26 */
- /* R_DATA_PLEBEL */
- 0, "L4=Sb=", /* 0x27 */
- 1, "L4=Sd=", /* 0x28 */
- /* R_SPACE_REF */
- 0, "L4=", /* 0x29 */
- /* R_REPEATED_INIT */
- 0, "L4=Mb1+4*=", /* 0x2a */
- 1, "Lb4*=Mb1+L*=", /* 0x2b */
- 2, "Lb4*=Md1+4*=", /* 0x2c */
- 3, "Ld1+=Me1+=", /* 0x2d */
- /* R_SHORT_PCREL_MODE */
- 0, "", /* 0x2e */
- /* R_LONG_PCREL_MODE */
- 0, "", /* 0x2f */
- /* R_PCREL_CALL */
- 0, "L4=RD=Sb=", /* 0x30 */
- 1, "L4=RD=Sb=", /* 0x31 */
- 2, "L4=RD=Sb=", /* 0x32 */
- 3, "L4=RD=Sb=", /* 0x33 */
- 4, "L4=RD=Sb=", /* 0x34 */
- 5, "L4=RD=Sb=", /* 0x35 */
- 6, "L4=RD=Sb=", /* 0x36 */
- 7, "L4=RD=Sb=", /* 0x37 */
- 8, "L4=RD=Sb=", /* 0x38 */
- 9, "L4=RD=Sb=", /* 0x39 */
- 0, "L4=RD8<b+=Sb=",/* 0x3a */
- 1, "L4=RD8<b+=Sb=",/* 0x3b */
- 0, "L4=RD8<b+=Sd=",/* 0x3c */
- 1, "L4=RD8<b+=Sd=",/* 0x3d */
- /* R_RESERVED */
- 0, "", /* 0x3e */
- 0, "", /* 0x3f */
- /* R_ABS_CALL */
- 0, "L4=RD=Sb=", /* 0x40 */
- 1, "L4=RD=Sb=", /* 0x41 */
- 2, "L4=RD=Sb=", /* 0x42 */
- 3, "L4=RD=Sb=", /* 0x43 */
- 4, "L4=RD=Sb=", /* 0x44 */
- 5, "L4=RD=Sb=", /* 0x45 */
- 6, "L4=RD=Sb=", /* 0x46 */
- 7, "L4=RD=Sb=", /* 0x47 */
- 8, "L4=RD=Sb=", /* 0x48 */
- 9, "L4=RD=Sb=", /* 0x49 */
- 0, "L4=RD8<b+=Sb=",/* 0x4a */
- 1, "L4=RD8<b+=Sb=",/* 0x4b */
- 0, "L4=RD8<b+=Sd=",/* 0x4c */
- 1, "L4=RD8<b+=Sd=",/* 0x4d */
- /* R_RESERVED */
- 0, "", /* 0x4e */
- 0, "", /* 0x4f */
- /* R_DP_RELATIVE */
- 0, "L4=SD=", /* 0x50 */
- 1, "L4=SD=", /* 0x51 */
- 2, "L4=SD=", /* 0x52 */
- 3, "L4=SD=", /* 0x53 */
- 4, "L4=SD=", /* 0x54 */
- 5, "L4=SD=", /* 0x55 */
- 6, "L4=SD=", /* 0x56 */
- 7, "L4=SD=", /* 0x57 */
- 8, "L4=SD=", /* 0x58 */
- 9, "L4=SD=", /* 0x59 */
- 10, "L4=SD=", /* 0x5a */
- 11, "L4=SD=", /* 0x5b */
- 12, "L4=SD=", /* 0x5c */
- 13, "L4=SD=", /* 0x5d */
- 14, "L4=SD=", /* 0x5e */
- 15, "L4=SD=", /* 0x5f */
- 16, "L4=SD=", /* 0x60 */
- 17, "L4=SD=", /* 0x61 */
- 18, "L4=SD=", /* 0x62 */
- 19, "L4=SD=", /* 0x63 */
- 20, "L4=SD=", /* 0x64 */
- 21, "L4=SD=", /* 0x65 */
- 22, "L4=SD=", /* 0x66 */
- 23, "L4=SD=", /* 0x67 */
- 24, "L4=SD=", /* 0x68 */
- 25, "L4=SD=", /* 0x69 */
- 26, "L4=SD=", /* 0x6a */
- 27, "L4=SD=", /* 0x6b */
- 28, "L4=SD=", /* 0x6c */
- 29, "L4=SD=", /* 0x6d */
- 30, "L4=SD=", /* 0x6e */
- 31, "L4=SD=", /* 0x6f */
- 32, "L4=Sb=", /* 0x70 */
- 33, "L4=Sd=", /* 0x71 */
- /* R_RESERVED */
- 0, "", /* 0x72 */
- 0, "", /* 0x73 */
- 0, "", /* 0x74 */
- 0, "", /* 0x75 */
- 0, "", /* 0x76 */
- 0, "", /* 0x77 */
- /* R_DLT_REL */
- 0, "L4=Sb=", /* 0x78 */
- 1, "L4=Sd=", /* 0x79 */
- /* R_RESERVED */
- 0, "", /* 0x7a */
- 0, "", /* 0x7b */
- 0, "", /* 0x7c */
- 0, "", /* 0x7d */
- 0, "", /* 0x7e */
- 0, "", /* 0x7f */
- /* R_CODE_ONE_SYMBOL */
- 0, "L4=SD=", /* 0x80 */
- 1, "L4=SD=", /* 0x81 */
- 2, "L4=SD=", /* 0x82 */
- 3, "L4=SD=", /* 0x83 */
- 4, "L4=SD=", /* 0x84 */
- 5, "L4=SD=", /* 0x85 */
- 6, "L4=SD=", /* 0x86 */
- 7, "L4=SD=", /* 0x87 */
- 8, "L4=SD=", /* 0x88 */
- 9, "L4=SD=", /* 0x89 */
- 10, "L4=SD=", /* 0x8q */
- 11, "L4=SD=", /* 0x8b */
- 12, "L4=SD=", /* 0x8c */
- 13, "L4=SD=", /* 0x8d */
- 14, "L4=SD=", /* 0x8e */
- 15, "L4=SD=", /* 0x8f */
- 16, "L4=SD=", /* 0x90 */
- 17, "L4=SD=", /* 0x91 */
- 18, "L4=SD=", /* 0x92 */
- 19, "L4=SD=", /* 0x93 */
- 20, "L4=SD=", /* 0x94 */
- 21, "L4=SD=", /* 0x95 */
- 22, "L4=SD=", /* 0x96 */
- 23, "L4=SD=", /* 0x97 */
- 24, "L4=SD=", /* 0x98 */
- 25, "L4=SD=", /* 0x99 */
- 26, "L4=SD=", /* 0x9a */
- 27, "L4=SD=", /* 0x9b */
- 28, "L4=SD=", /* 0x9c */
- 29, "L4=SD=", /* 0x9d */
- 30, "L4=SD=", /* 0x9e */
- 31, "L4=SD=", /* 0x9f */
- 32, "L4=Sb=", /* 0xa0 */
- 33, "L4=Sd=", /* 0xa1 */
- /* R_RESERVED */
- 0, "", /* 0xa2 */
- 0, "", /* 0xa3 */
- 0, "", /* 0xa4 */
- 0, "", /* 0xa5 */
- 0, "", /* 0xa6 */
- 0, "", /* 0xa7 */
- 0, "", /* 0xa8 */
- 0, "", /* 0xa9 */
- 0, "", /* 0xaa */
- 0, "", /* 0xab */
- 0, "", /* 0xac */
- 0, "", /* 0xad */
- /* R_MILLI_REL */
- 0, "L4=Sb=", /* 0xae */
- 1, "L4=Sd=", /* 0xaf */
- /* R_CODE_PLABEL */
- 0, "L4=Sb=", /* 0xb0 */
- 1, "L4=Sd=", /* 0xb1 */
- /* R_BREAKPOINT */
- 0, "L4=", /* 0xb2 */
- /* R_ENTRY */
- 0, "Te=Ue=", /* 0xb3 */
- 1, "Uf=", /* 0xb4 */
- /* R_ALT_ENTRY */
- 0, "", /* 0xb5 */
- /* R_EXIT */
- 0, "", /* 0xb6 */
- /* R_BEGIN_TRY */
- 0, "", /* 0xb7 */
- /* R_END_TRY */
- 0, "R0=", /* 0xb8 */
- 1, "Rb4*=", /* 0xb9 */
- 2, "Rd4*=", /* 0xba */
- /* R_BEGIN_BRTAB */
- 0, "", /* 0xbb */
- /* R_END_BRTAB */
- 0, "", /* 0xbc */
- /* R_STATEMENT */
- 0, "Nb=", /* 0xbd */
- 1, "Nc=", /* 0xbe */
- 2, "Nd=", /* 0xbf */
- /* R_DATA_EXPR */
- 0, "L4=", /* 0xc0 */
- /* R_CODE_EXPR */
- 0, "L4=", /* 0xc1 */
- /* R_FSEL */
- 0, "", /* 0xc2 */
- /* R_LSEL */
- 0, "", /* 0xc3 */
- /* R_RSEL */
- 0, "", /* 0xc4 */
- /* R_N_MODE */
- 0, "", /* 0xc5 */
- /* R_S_MODE */
- 0, "", /* 0xc6 */
- /* R_D_MODE */
- 0, "", /* 0xc7 */
- /* R_R_MODE */
- 0, "", /* 0xc8 */
- /* R_DATA_OVERRIDE */
- 0, "V0=", /* 0xc9 */
- 1, "Vb=", /* 0xca */
- 2, "Vc=", /* 0xcb */
- 3, "Vd=", /* 0xcc */
- 4, "Ve=", /* 0xcd */
- /* R_TRANSLATED */
- 0, "", /* 0xce */
- /* R_RESERVED */
- 0, "", /* 0xcf */
- /* R_COMP1 */
- 0, "Ob=", /* 0xd0 */
- /* R_COMP2 */
- 0, "Ob=Sd=", /* 0xd1 */
- /* R_COMP3 */
- 0, "Ob=Ve=", /* 0xd2 */
- /* R_PREV_FIXUP */
- 0, "P", /* 0xd3 */
- 1, "P", /* 0xd4 */
- 2, "P", /* 0xd5 */
- 3, "P", /* 0xd6 */
- /* R_SEC_STMT */
- 0, "", /* 0xd7 */
- /* R_N0SEL */
- 0, "", /* 0xd8 */
- /* R_N1SEL */
- 0, "", /* 0xd9 */
- /* R_LINETAB */
- 0, "", /* 0xda */
- /* R_LINETAB_ESC */
- 0, "", /* 0xdb */
- /* R_LTP_OVERRIDE */
- 0, "", /* 0xdc */
- /* R_COMMENT */
- 0, "", /* 0xdd */
- /* R_RESERVED */
- 0, "", /* 0xde */
- 0, "", /* 0xdf */
- 0, "", /* 0xe0 */
- 0, "", /* 0xe1 */
- 0, "", /* 0xe2 */
- 0, "", /* 0xe3 */
- 0, "", /* 0xe4 */
- 0, "", /* 0xe5 */
- 0, "", /* 0xe6 */
- 0, "", /* 0xe7 */
- 0, "", /* 0xe8 */
- 0, "", /* 0xe9 */
- 0, "", /* 0xea */
- 0, "", /* 0xeb */
- 0, "", /* 0xec */
- 0, "", /* 0xed */
- 0, "", /* 0xee */
- 0, "", /* 0xef */
- 0, "", /* 0xf0 */
- 0, "", /* 0xf1 */
- 0, "", /* 0xf2 */
- 0, "", /* 0xf3 */
- 0, "", /* 0xf4 */
- 0, "", /* 0xf5 */
- 0, "", /* 0xf6 */
- 0, "", /* 0xf7 */
- 0, "", /* 0xf8 */
- 0, "", /* 0xf9 */
- 0, "", /* 0xfa */
- 0, "", /* 0xfb */
- 0, "", /* 0xfc */
- 0, "", /* 0xfd */
- 0, "", /* 0xfe */
- 0, "", /* 0xff */
-};
-
-static const int comp1_opcodes[] =
-{
- 0x00,
- 0x40,
- 0x41,
- 0x42,
- 0x43,
- 0x44,
- 0x45,
- 0x46,
- 0x47,
- 0x48,
- 0x49,
- 0x4a,
- 0x4b,
- 0x60,
- 0x80,
- 0xa0,
- 0xc0,
- -1
-};
-
-static const int comp2_opcodes[] =
-{
- 0x00,
- 0x80,
- 0x82,
- 0xc0,
- -1
-};
-
-static const int comp3_opcodes[] =
-{
- 0x00,
- 0x02,
- -1
-};
-
-/* These apparently are not in older versions of hpux reloc.h (hpux7). */
-#ifndef R_DLT_REL
-#define R_DLT_REL 0x78
-#endif
-
-#ifndef R_AUX_UNWIND
-#define R_AUX_UNWIND 0xcf
-#endif
-
-#ifndef R_SEC_STMT
-#define R_SEC_STMT 0xd7
-#endif
-
-/* And these first appeared in hpux10. */
-#ifndef R_SHORT_PCREL_MODE
-#define R_SHORT_PCREL_MODE 0x3e
-#endif
-
-#ifndef R_LONG_PCREL_MODE
-#define R_LONG_PCREL_MODE 0x3f
-#endif
-
-#ifndef R_N0SEL
-#define R_N0SEL 0xd8
-#endif
-
-#ifndef R_N1SEL
-#define R_N1SEL 0xd9
-#endif
-
-#ifndef R_LINETAB
-#define R_LINETAB 0xda
-#endif
-
-#ifndef R_LINETAB_ESC
-#define R_LINETAB_ESC 0xdb
-#endif
-
-#ifndef R_LTP_OVERRIDE
-#define R_LTP_OVERRIDE 0xdc
-#endif
-
-#ifndef R_COMMENT
-#define R_COMMENT 0xdd
-#endif
-
-static reloc_howto_type som_hppa_howto_table[] =
-{
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_NO_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_NO_RELOCATION"},
- {R_ZEROES, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ZEROES"},
- {R_ZEROES, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ZEROES"},
- {R_UNINIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_UNINIT"},
- {R_UNINIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_UNINIT"},
- {R_RELOCATION, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RELOCATION"},
- {R_DATA_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_ONE_SYMBOL"},
- {R_DATA_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_ONE_SYMBOL"},
- {R_DATA_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_PLABEL"},
- {R_DATA_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_PLABEL"},
- {R_SPACE_REF, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SPACE_REF"},
- {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
- {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
- {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
- {R_REPEATED_INIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "REPEATED_INIT"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_PCREL_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PCREL_CALL"},
- {R_SHORT_PCREL_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SHORT_PCREL_MODE"},
- {R_LONG_PCREL_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LONG_PCREL_MODE"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_ABS_CALL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ABS_CALL"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_DP_RELATIVE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DP_RELATIVE"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_DLT_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DLT_REL"},
- {R_DLT_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DLT_REL"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_CODE_ONE_SYMBOL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_ONE_SYMBOL"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_MILLI_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_MILLI_REL"},
- {R_MILLI_REL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_MILLI_REL"},
- {R_CODE_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_PLABEL"},
- {R_CODE_PLABEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_PLABEL"},
- {R_BREAKPOINT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BREAKPOINT"},
- {R_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ENTRY"},
- {R_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ENTRY"},
- {R_ALT_ENTRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_ALT_ENTRY"},
- {R_EXIT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_EXIT"},
- {R_BEGIN_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BEGIN_TRY"},
- {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"},
- {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"},
- {R_END_TRY, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_TRY"},
- {R_BEGIN_BRTAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_BEGIN_BRTAB"},
- {R_END_BRTAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_END_BRTAB"},
- {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
- {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
- {R_STATEMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_STATEMENT"},
- {R_DATA_EXPR, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_EXPR"},
- {R_CODE_EXPR, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_CODE_EXPR"},
- {R_FSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_FSEL"},
- {R_LSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LSEL"},
- {R_RSEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RSEL"},
- {R_N_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_N_MODE"},
- {R_S_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_S_MODE"},
- {R_D_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_D_MODE"},
- {R_R_MODE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_R_MODE"},
- {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
- {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
- {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
- {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
- {R_DATA_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_DATA_OVERRIDE"},
- {R_TRANSLATED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_TRANSLATED"},
- {R_AUX_UNWIND, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_AUX_UNWIND"},
- {R_COMP1, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP1"},
- {R_COMP2, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP2"},
- {R_COMP3, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMP3"},
- {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
- {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
- {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
- {R_PREV_FIXUP, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_PREV_FIXUP"},
- {R_SEC_STMT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_SEC_STMT"},
- {R_N0SEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_N0SEL"},
- {R_N1SEL, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_N1SEL"},
- {R_LINETAB, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LINETAB"},
- {R_LINETAB_ESC, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LINETAB_ESC"},
- {R_LTP_OVERRIDE, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_LTP_OVERRIDE"},
- {R_COMMENT, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_COMMENT"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
- {R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}};
-
-/* Initialize the SOM relocation queue. By definition the queue holds
- the last four multibyte fixups. */
-
-static void
-som_initialize_reloc_queue (queue)
- struct reloc_queue *queue;
-{
- queue[0].reloc = NULL;
- queue[0].size = 0;
- queue[1].reloc = NULL;
- queue[1].size = 0;
- queue[2].reloc = NULL;
- queue[2].size = 0;
- queue[3].reloc = NULL;
- queue[3].size = 0;
-}
-
-/* Insert a new relocation into the relocation queue. */
-
-static void
-som_reloc_queue_insert (p, size, queue)
- unsigned char *p;
- unsigned int size;
- struct reloc_queue *queue;
-{
- queue[3].reloc = queue[2].reloc;
- queue[3].size = queue[2].size;
- queue[2].reloc = queue[1].reloc;
- queue[2].size = queue[1].size;
- queue[1].reloc = queue[0].reloc;
- queue[1].size = queue[0].size;
- queue[0].reloc = p;
- queue[0].size = size;
-}
-
-/* When an entry in the relocation queue is reused, the entry moves
- to the front of the queue. */
-
-static void
-som_reloc_queue_fix (queue, index)
- struct reloc_queue *queue;
- unsigned int index;
-{
- if (index == 0)
- return;
-
- if (index == 1)
- {
- unsigned char *tmp1 = queue[0].reloc;
- unsigned int tmp2 = queue[0].size;
- queue[0].reloc = queue[1].reloc;
- queue[0].size = queue[1].size;
- queue[1].reloc = tmp1;
- queue[1].size = tmp2;
- return;
- }
-
- if (index == 2)
- {
- unsigned char *tmp1 = queue[0].reloc;
- unsigned int tmp2 = queue[0].size;
- queue[0].reloc = queue[2].reloc;
- queue[0].size = queue[2].size;
- queue[2].reloc = queue[1].reloc;
- queue[2].size = queue[1].size;
- queue[1].reloc = tmp1;
- queue[1].size = tmp2;
- return;
- }
-
- if (index == 3)
- {
- unsigned char *tmp1 = queue[0].reloc;
- unsigned int tmp2 = queue[0].size;
- queue[0].reloc = queue[3].reloc;
- queue[0].size = queue[3].size;
- queue[3].reloc = queue[2].reloc;
- queue[3].size = queue[2].size;
- queue[2].reloc = queue[1].reloc;
- queue[2].size = queue[1].size;
- queue[1].reloc = tmp1;
- queue[1].size = tmp2;
- return;
- }
- abort();
-}
-
-/* Search for a particular relocation in the relocation queue. */
-
-static int
-som_reloc_queue_find (p, size, queue)
- unsigned char *p;
- unsigned int size;
- struct reloc_queue *queue;
-{
- if (queue[0].reloc && !memcmp (p, queue[0].reloc, size)
- && size == queue[0].size)
- return 0;
- if (queue[1].reloc && !memcmp (p, queue[1].reloc, size)
- && size == queue[1].size)
- return 1;
- if (queue[2].reloc && !memcmp (p, queue[2].reloc, size)
- && size == queue[2].size)
- return 2;
- if (queue[3].reloc && !memcmp (p, queue[3].reloc, size)
- && size == queue[3].size)
- return 3;
- return -1;
-}
-
-static unsigned char *
-try_prev_fixup (abfd, subspace_reloc_sizep, p, size, queue)
- bfd *abfd;
- int *subspace_reloc_sizep;
- unsigned char *p;
- unsigned int size;
- struct reloc_queue *queue;
-{
- int queue_index = som_reloc_queue_find (p, size, queue);
-
- if (queue_index != -1)
- {
- /* Found this in a previous fixup. Undo the fixup we
- just built and use R_PREV_FIXUP instead. We saved
- a total of size - 1 bytes in the fixup stream. */
- bfd_put_8 (abfd, R_PREV_FIXUP + queue_index, p);
- p += 1;
- *subspace_reloc_sizep += 1;
- som_reloc_queue_fix (queue, queue_index);
- }
- else
- {
- som_reloc_queue_insert (p, size, queue);
- *subspace_reloc_sizep += size;
- p += size;
- }
- return p;
-}
-
-/* Emit the proper R_NO_RELOCATION fixups to map the next SKIP
- bytes without any relocation. Update the size of the subspace
- relocation stream via SUBSPACE_RELOC_SIZE_P; also return the
- current pointer into the relocation stream. */
-
-static unsigned char *
-som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue)
- bfd *abfd;
- unsigned int skip;
- unsigned char *p;
- unsigned int *subspace_reloc_sizep;
- struct reloc_queue *queue;
-{
- /* Use a 4 byte R_NO_RELOCATION entry with a maximal value
- then R_PREV_FIXUPs to get the difference down to a
- reasonable size. */
- if (skip >= 0x1000000)
- {
- skip -= 0x1000000;
- bfd_put_8 (abfd, R_NO_RELOCATION + 31, p);
- bfd_put_8 (abfd, 0xff, p + 1);
- bfd_put_16 (abfd, 0xffff, p + 2);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
- while (skip >= 0x1000000)
- {
- skip -= 0x1000000;
- bfd_put_8 (abfd, R_PREV_FIXUP, p);
- p++;
- *subspace_reloc_sizep += 1;
- /* No need to adjust queue here since we are repeating the
- most recent fixup. */
- }
- }
-
- /* The difference must be less than 0x1000000. Use one
- more R_NO_RELOCATION entry to get to the right difference. */
- if ((skip & 3) == 0 && skip <= 0xc0000 && skip > 0)
- {
- /* Difference can be handled in a simple single-byte
- R_NO_RELOCATION entry. */
- if (skip <= 0x60)
- {
- bfd_put_8 (abfd, R_NO_RELOCATION + (skip >> 2) - 1, p);
- *subspace_reloc_sizep += 1;
- p++;
- }
- /* Handle it with a two byte R_NO_RELOCATION entry. */
- else if (skip <= 0x1000)
- {
- bfd_put_8 (abfd, R_NO_RELOCATION + 24 + (((skip >> 2) - 1) >> 8), p);
- bfd_put_8 (abfd, (skip >> 2) - 1, p + 1);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue);
- }
- /* Handle it with a three byte R_NO_RELOCATION entry. */
- else
- {
- bfd_put_8 (abfd, R_NO_RELOCATION + 28 + (((skip >> 2) - 1) >> 16), p);
- bfd_put_16 (abfd, (skip >> 2) - 1, p + 1);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
- }
- }
- /* Ugh. Punt and use a 4 byte entry. */
- else if (skip > 0)
- {
- bfd_put_8 (abfd, R_NO_RELOCATION + 31, p);
- bfd_put_8 (abfd, (skip - 1) >> 16, p + 1);
- bfd_put_16 (abfd, skip - 1, p + 2);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
- }
- return p;
-}
-
-/* Emit the proper R_DATA_OVERRIDE fixups to handle a nonzero addend
- from a BFD relocation. Update the size of the subspace relocation
- stream via SUBSPACE_RELOC_SIZE_P; also return the current pointer
- into the relocation stream. */
-
-static unsigned char *
-som_reloc_addend (abfd, addend, p, subspace_reloc_sizep, queue)
- bfd *abfd;
- int addend;
- unsigned char *p;
- unsigned int *subspace_reloc_sizep;
- struct reloc_queue *queue;
-{
- if ((unsigned)(addend) + 0x80 < 0x100)
- {
- bfd_put_8 (abfd, R_DATA_OVERRIDE + 1, p);
- bfd_put_8 (abfd, addend, p + 1);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue);
- }
- else if ((unsigned) (addend) + 0x8000 < 0x10000)
- {
- bfd_put_8 (abfd, R_DATA_OVERRIDE + 2, p);
- bfd_put_16 (abfd, addend, p + 1);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
- }
- else if ((unsigned) (addend) + 0x800000 < 0x1000000)
- {
- bfd_put_8 (abfd, R_DATA_OVERRIDE + 3, p);
- bfd_put_8 (abfd, addend >> 16, p + 1);
- bfd_put_16 (abfd, addend, p + 2);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
- }
- else
- {
- bfd_put_8 (abfd, R_DATA_OVERRIDE + 4, p);
- bfd_put_32 (abfd, addend, p + 1);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 5, queue);
- }
- return p;
-}
-
-/* Handle a single function call relocation. */
-
-static unsigned char *
-som_reloc_call (abfd, p, subspace_reloc_sizep, bfd_reloc, sym_num, queue)
- bfd *abfd;
- unsigned char *p;
- unsigned int *subspace_reloc_sizep;
- arelent *bfd_reloc;
- int sym_num;
- struct reloc_queue *queue;
-{
- int arg_bits = HPPA_R_ARG_RELOC (bfd_reloc->addend);
- int rtn_bits = arg_bits & 0x3;
- int type, done = 0;
-
- /* You'll never believe all this is necessary to handle relocations
- for function calls. Having to compute and pack the argument
- relocation bits is the real nightmare.
-
- If you're interested in how this works, just forget it. You really
- do not want to know about this braindamage. */
-
- /* First see if this can be done with a "simple" relocation. Simple
- relocations have a symbol number < 0x100 and have simple encodings
- of argument relocations. */
-
- if (sym_num < 0x100)
- {
- switch (arg_bits)
- {
- case 0:
- case 1:
- type = 0;
- break;
- case 1 << 8:
- case 1 << 8 | 1:
- type = 1;
- break;
- case 1 << 8 | 1 << 6:
- case 1 << 8 | 1 << 6 | 1:
- type = 2;
- break;
- case 1 << 8 | 1 << 6 | 1 << 4:
- case 1 << 8 | 1 << 6 | 1 << 4 | 1:
- type = 3;
- break;
- case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2:
- case 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2 | 1:
- type = 4;
- break;
- default:
- /* Not one of the easy encodings. This will have to be
- handled by the more complex code below. */
- type = -1;
- break;
- }
- if (type != -1)
- {
- /* Account for the return value too. */
- if (rtn_bits)
- type += 5;
-
- /* Emit a 2 byte relocation. Then see if it can be handled
- with a relocation which is already in the relocation queue. */
- bfd_put_8 (abfd, bfd_reloc->howto->type + type, p);
- bfd_put_8 (abfd, sym_num, p + 1);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue);
- done = 1;
- }
- }
-
- /* If this could not be handled with a simple relocation, then do a hard
- one. Hard relocations occur if the symbol number was too high or if
- the encoding of argument relocation bits is too complex. */
- if (! done)
- {
- /* Don't ask about these magic sequences. I took them straight
- from gas-1.36 which took them from the a.out man page. */
- type = rtn_bits;
- if ((arg_bits >> 6 & 0xf) == 0xe)
- type += 9 * 40;
- else
- type += (3 * (arg_bits >> 8 & 3) + (arg_bits >> 6 & 3)) * 40;
- if ((arg_bits >> 2 & 0xf) == 0xe)
- type += 9 * 4;
- else
- type += (3 * (arg_bits >> 4 & 3) + (arg_bits >> 2 & 3)) * 4;
-
- /* Output the first two bytes of the relocation. These describe
- the length of the relocation and encoding style. */
- bfd_put_8 (abfd, bfd_reloc->howto->type + 10
- + 2 * (sym_num >= 0x100) + (type >= 0x100),
- p);
- bfd_put_8 (abfd, type, p + 1);
-
- /* Now output the symbol index and see if this bizarre relocation
- just happened to be in the relocation queue. */
- if (sym_num < 0x100)
- {
- bfd_put_8 (abfd, sym_num, p + 2);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
- }
- else
- {
- bfd_put_8 (abfd, sym_num >> 16, p + 2);
- bfd_put_16 (abfd, sym_num, p + 3);
- p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 5, queue);
- }
- }
- return p;
-}
-
-
-/* Return the logarithm of X, base 2, considering X unsigned.
- Abort -1 if X is not a power or two or is zero. */
-
-static int
-log2 (x)
- unsigned int x;
-{
- int log = 0;
-
- /* Test for 0 or a power of 2. */
- if (x == 0 || x != (x & -x))
- return -1;
-
- while ((x >>= 1) != 0)
- log++;
- return log;
-}
-
-static bfd_reloc_status_type
-hppa_som_reloc (abfd, reloc_entry, symbol_in, data,
- input_section, output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol_in;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message;
-{
- if (output_bfd)
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
- return bfd_reloc_ok;
-}
-
-/* Given a generic HPPA relocation type, the instruction format,
- and a field selector, return one or more appropriate SOM relocations. */
-
-int **
-hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
- bfd *abfd;
- int base_type;
- int format;
- enum hppa_reloc_field_selector_type_alt field;
- int sym_diff;
-{
- int *final_type, **final_types;
-
- final_types = (int **) bfd_alloc_by_size_t (abfd, sizeof (int *) * 6);
- final_type = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types || !final_type)
- return NULL;
-
- /* The field selector may require additional relocations to be
- generated. It's impossible to know at this moment if additional
- relocations will be needed, so we make them. The code to actually
- write the relocation/fixup stream is responsible for removing
- any redundant relocations. */
- switch (field)
- {
- case e_fsel:
- case e_psel:
- case e_lpsel:
- case e_rpsel:
- final_types[0] = final_type;
- final_types[1] = NULL;
- final_types[2] = NULL;
- *final_type = base_type;
- break;
-
- case e_tsel:
- case e_ltsel:
- case e_rtsel:
- final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0])
- return NULL;
- if (field == e_tsel)
- *final_types[0] = R_FSEL;
- else if (field == e_ltsel)
- *final_types[0] = R_LSEL;
- else
- *final_types[0] = R_RSEL;
- final_types[1] = final_type;
- final_types[2] = NULL;
- *final_type = base_type;
- break;
-
- case e_lssel:
- case e_rssel:
- final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0])
- return NULL;
- *final_types[0] = R_S_MODE;
- final_types[1] = final_type;
- final_types[2] = NULL;
- *final_type = base_type;
- break;
-
- case e_lsel:
- case e_rsel:
- final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0])
- return NULL;
- *final_types[0] = R_N_MODE;
- final_types[1] = final_type;
- final_types[2] = NULL;
- *final_type = base_type;
- break;
-
- case e_ldsel:
- case e_rdsel:
- final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0])
- return NULL;
- *final_types[0] = R_D_MODE;
- final_types[1] = final_type;
- final_types[2] = NULL;
- *final_type = base_type;
- break;
-
- case e_lrsel:
- case e_rrsel:
- final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0])
- return NULL;
- *final_types[0] = R_R_MODE;
- final_types[1] = final_type;
- final_types[2] = NULL;
- *final_type = base_type;
- break;
-
- case e_nsel:
- final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0])
- return NULL;
- *final_types[0] = R_N1SEL;
- final_types[1] = final_type;
- final_types[2] = NULL;
- *final_type = base_type;
- break;
-
- case e_nlsel:
- case e_nlrsel:
- final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0])
- return NULL;
- *final_types[0] = R_N0SEL;
- final_types[1] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[1])
- return NULL;
- if (field == e_nlsel)
- *final_types[1] = R_N_MODE;
- else
- *final_types[1] = R_R_MODE;
- final_types[2] = final_type;
- final_types[3] = NULL;
- *final_type = base_type;
- break;
- }
-
- switch (base_type)
- {
- case R_HPPA:
- /* The difference of two symbols needs *very* special handling. */
- if (sym_diff)
- {
- final_types[0] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
- final_types[1] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
- final_types[2] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
- final_types[3] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0] || !final_types[1] || !final_types[2])
- return NULL;
- if (field == e_fsel)
- *final_types[0] = R_FSEL;
- else if (field == e_rsel)
- *final_types[0] = R_RSEL;
- else if (field == e_lsel)
- *final_types[0] = R_LSEL;
- *final_types[1] = R_COMP2;
- *final_types[2] = R_COMP2;
- *final_types[3] = R_COMP1;
- final_types[4] = final_type;
- *final_types[4] = R_CODE_EXPR;
- final_types[5] = NULL;
- break;
- }
- /* PLABELs get their own relocation type. */
- else if (field == e_psel
- || field == e_lpsel
- || field == e_rpsel)
- {
- /* A PLABEL relocation that has a size of 32 bits must
- be a R_DATA_PLABEL. All others are R_CODE_PLABELs. */
- if (format == 32)
- *final_type = R_DATA_PLABEL;
- else
- *final_type = R_CODE_PLABEL;
- }
- /* PIC stuff. */
- else if (field == e_tsel
- || field == e_ltsel
- || field == e_rtsel)
- *final_type = R_DLT_REL;
- /* A relocation in the data space is always a full 32bits. */
- else if (format == 32)
- *final_type = R_DATA_ONE_SYMBOL;
-
- break;
-
- case R_HPPA_GOTOFF:
- /* More PLABEL special cases. */
- if (field == e_psel
- || field == e_lpsel
- || field == e_rpsel)
- *final_type = R_DATA_PLABEL;
- break;
-
- case R_HPPA_COMPLEX:
- /* The difference of two symbols needs *very* special handling. */
- if (sym_diff)
- {
- final_types[0] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
- final_types[1] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
- final_types[2] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
- final_types[3] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
- if (!final_types[0] || !final_types[1] || !final_types[2])
- return NULL;
- if (field == e_fsel)
- *final_types[0] = R_FSEL;
- else if (field == e_rsel)
- *final_types[0] = R_RSEL;
- else if (field == e_lsel)
- *final_types[0] = R_LSEL;
- *final_types[1] = R_COMP2;
- *final_types[2] = R_COMP2;
- *final_types[3] = R_COMP1;
- final_types[4] = final_type;
- *final_types[4] = R_CODE_EXPR;
- final_types[5] = NULL;
- break;
- }
- else
- break;
-
- case R_HPPA_NONE:
- case R_HPPA_ABS_CALL:
- case R_HPPA_PCREL_CALL:
- /* Right now we can default all these. */
- break;
- }
- return final_types;
-}
-
-/* Return the address of the correct entry in the PA SOM relocation
- howto table. */
-
-/*ARGSUSED*/
-static reloc_howto_type *
-som_bfd_reloc_type_lookup (abfd, code)
- bfd *abfd;
- bfd_reloc_code_real_type code;
-{
- if ((int) code < (int) R_NO_RELOCATION + 255)
- {
- BFD_ASSERT ((int) som_hppa_howto_table[(int) code].type == (int) code);
- return &som_hppa_howto_table[(int) code];
- }
-
- return (reloc_howto_type *) 0;
-}
-
-/* Perform some initialization for an object. Save results of this
- initialization in the BFD. */
-
-static const bfd_target *
-som_object_setup (abfd, file_hdrp, aux_hdrp)
- bfd *abfd;
- struct header *file_hdrp;
- struct som_exec_auxhdr *aux_hdrp;
-{
- asection *section;
- int found;
-
- /* som_mkobject will set bfd_error if som_mkobject fails. */
- if (som_mkobject (abfd) != true)
- return 0;
-
- /* Set BFD flags based on what information is available in the SOM. */
- abfd->flags = NO_FLAGS;
- if (file_hdrp->symbol_total)
- abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
-
- switch (file_hdrp->a_magic)
- {
- case DEMAND_MAGIC:
- abfd->flags |= (D_PAGED | WP_TEXT | EXEC_P);
- break;
- case SHARE_MAGIC:
- abfd->flags |= (WP_TEXT | EXEC_P);
- break;
- case EXEC_MAGIC:
- abfd->flags |= (EXEC_P);
- break;
- case RELOC_MAGIC:
- abfd->flags |= HAS_RELOC;
- break;
-#ifdef SHL_MAGIC
- case SHL_MAGIC:
-#endif
-#ifdef DL_MAGIC
- case DL_MAGIC:
-#endif
- abfd->flags |= DYNAMIC;
- break;
-
- default:
- break;
- }
-
- /* Allocate space to hold the saved exec header information. */
- obj_som_exec_data (abfd) = (struct som_exec_data *)
- bfd_zalloc (abfd, sizeof (struct som_exec_data ));
- if (obj_som_exec_data (abfd) == NULL)
- return NULL;
-
- /* The braindamaged OSF1 linker switched exec_flags and exec_entry!
-
- We used to identify OSF1 binaries based on NEW_VERSION_ID, but
- apparently the latest HPUX linker is using NEW_VERSION_ID now.
-
- It's about time, OSF has used the new id since at least 1992;
- HPUX didn't start till nearly 1995!.
-
- The new approach examines the entry field. If it's zero or not 4
- byte aligned then it's not a proper code address and we guess it's
- really the executable flags. */
- found = 0;
- for (section = abfd->sections; section; section = section->next)
- {
- if ((section->flags & SEC_CODE) == 0)
- continue;
- if (aux_hdrp->exec_entry >= section->vma
- && aux_hdrp->exec_entry < section->vma + section->_cooked_size)
- found = 1;
- }
- if (aux_hdrp->exec_entry == 0
- || (aux_hdrp->exec_entry & 0x3) != 0
- || ! found)
- {
- bfd_get_start_address (abfd) = aux_hdrp->exec_flags;
- obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_entry;
- }
- else
- {
- bfd_get_start_address (abfd) = aux_hdrp->exec_entry;
- obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_flags;
- }
-
- bfd_default_set_arch_mach (abfd, bfd_arch_hppa, pa10);
- bfd_get_symcount (abfd) = file_hdrp->symbol_total;
-
- /* Initialize the saved symbol table and string table to NULL.
- Save important offsets and sizes from the SOM header into
- the BFD. */
- obj_som_stringtab (abfd) = (char *) NULL;
- obj_som_symtab (abfd) = (som_symbol_type *) NULL;
- obj_som_sorted_syms (abfd) = NULL;
- obj_som_stringtab_size (abfd) = file_hdrp->symbol_strings_size;
- obj_som_sym_filepos (abfd) = file_hdrp->symbol_location;
- obj_som_str_filepos (abfd) = file_hdrp->symbol_strings_location;
- obj_som_reloc_filepos (abfd) = file_hdrp->fixup_request_location;
- obj_som_exec_data (abfd)->system_id = file_hdrp->system_id;
-
- return abfd->xvec;
-}
-
-/* Convert all of the space and subspace info into BFD sections. Each space
- contains a number of subspaces, which in turn describe the mapping between
- regions of the exec file, and the address space that the program runs in.
- BFD sections which correspond to spaces will overlap the sections for the
- associated subspaces. */
-
-static boolean
-setup_sections (abfd, file_hdr)
- bfd *abfd;
- struct header *file_hdr;
-{
- char *space_strings;
- unsigned int space_index, i;
- unsigned int total_subspaces = 0;
- asection **subspace_sections, *section;
-
- /* First, read in space names */
-
- space_strings = bfd_malloc (file_hdr->space_strings_size);
- if (!space_strings && file_hdr->space_strings_size != 0)
- goto error_return;
-
- if (bfd_seek (abfd, file_hdr->space_strings_location, SEEK_SET) < 0)
- goto error_return;
- if (bfd_read (space_strings, 1, file_hdr->space_strings_size, abfd)
- != file_hdr->space_strings_size)
- goto error_return;
-
- /* Loop over all of the space dictionaries, building up sections */
- for (space_index = 0; space_index < file_hdr->space_total; space_index++)
- {
- struct space_dictionary_record space;
- struct subspace_dictionary_record subspace, save_subspace;
- int subspace_index;
- asection *space_asect;
- char *newname;
-
- /* Read the space dictionary element */
- if (bfd_seek (abfd, file_hdr->space_location
- + space_index * sizeof space, SEEK_SET) < 0)
- goto error_return;
- if (bfd_read (&space, 1, sizeof space, abfd) != sizeof space)
- goto error_return;
-
- /* Setup the space name string */
- space.name.n_name = space.name.n_strx + space_strings;
-
- /* Make a section out of it */
- newname = bfd_alloc (abfd, strlen (space.name.n_name) + 1);
- if (!newname)
- goto error_return;
- strcpy (newname, space.name.n_name);
-
- space_asect = bfd_make_section_anyway (abfd, newname);
- if (!space_asect)
- goto error_return;
-
- if (space.is_loadable == 0)
- space_asect->flags |= SEC_DEBUGGING;
-
- /* Set up all the attributes for the space. */
- if (bfd_som_set_section_attributes (space_asect, space.is_defined,
- space.is_private, space.sort_key,
- space.space_number) == false)
- goto error_return;
-
- /* If the space has no subspaces, then we're done. */
- if (space.subspace_quantity == 0)
- continue;
-
- /* Now, read in the first subspace for this space */
- if (bfd_seek (abfd, file_hdr->subspace_location
- + space.subspace_index * sizeof subspace,
- SEEK_SET) < 0)
- goto error_return;
- if (bfd_read (&subspace, 1, sizeof subspace, abfd) != sizeof subspace)
- goto error_return;
- /* Seek back to the start of the subspaces for loop below */
- if (bfd_seek (abfd, file_hdr->subspace_location
- + space.subspace_index * sizeof subspace,
- SEEK_SET) < 0)
- goto error_return;
-
- /* Setup the start address and file loc from the first subspace record */
- space_asect->vma = subspace.subspace_start;
- space_asect->filepos = subspace.file_loc_init_value;
- space_asect->alignment_power = log2 (subspace.alignment);
- if (space_asect->alignment_power == -1)
- goto error_return;
-
- /* Initialize save_subspace so we can reliably determine if this
- loop placed any useful values into it. */
- memset (&save_subspace, 0, sizeof (struct subspace_dictionary_record));
-
- /* Loop over the rest of the subspaces, building up more sections */
- for (subspace_index = 0; subspace_index < space.subspace_quantity;
- subspace_index++)
- {
- asection *subspace_asect;
-
- /* Read in the next subspace */
- if (bfd_read (&subspace, 1, sizeof subspace, abfd)
- != sizeof subspace)
- goto error_return;
-
- /* Setup the subspace name string */
- subspace.name.n_name = subspace.name.n_strx + space_strings;
-
- newname = bfd_alloc (abfd, strlen (subspace.name.n_name) + 1);
- if (!newname)
- goto error_return;
- strcpy (newname, subspace.name.n_name);
-
- /* Make a section out of this subspace */
- subspace_asect = bfd_make_section_anyway (abfd, newname);
- if (!subspace_asect)
- goto error_return;
-
- /* Store private information about the section. */
- if (bfd_som_set_subsection_attributes (subspace_asect, space_asect,
- subspace.access_control_bits,
- subspace.sort_key,
- subspace.quadrant) == false)
- goto error_return;
-
- /* Keep an easy mapping between subspaces and sections.
- Note we do not necessarily read the subspaces in the
- same order in which they appear in the object file.
-
- So to make the target index come out correctly, we
- store the location of the subspace header in target
- index, then sort using the location of the subspace
- header as the key. Then we can assign correct
- subspace indices. */
- total_subspaces++;
- subspace_asect->target_index = bfd_tell (abfd) - sizeof (subspace);
-
- /* Set SEC_READONLY and SEC_CODE/SEC_DATA as specified
- by the access_control_bits in the subspace header. */
- switch (subspace.access_control_bits >> 4)
- {
- /* Readonly data. */
- case 0x0:
- subspace_asect->flags |= SEC_DATA | SEC_READONLY;
- break;
-
- /* Normal data. */
- case 0x1:
- subspace_asect->flags |= SEC_DATA;
- break;
-
- /* Readonly code and the gateways.
- Gateways have other attributes which do not map
- into anything BFD knows about. */
- case 0x2:
- case 0x4:
- case 0x5:
- case 0x6:
- case 0x7:
- subspace_asect->flags |= SEC_CODE | SEC_READONLY;
- break;
-
- /* dynamic (writable) code. */
- case 0x3:
- subspace_asect->flags |= SEC_CODE;
- break;
- }
-
- if (subspace.dup_common || subspace.is_common)
- subspace_asect->flags |= SEC_IS_COMMON;
- else if (subspace.subspace_length > 0)
- subspace_asect->flags |= SEC_HAS_CONTENTS;
-
- if (subspace.is_loadable)
- subspace_asect->flags |= SEC_ALLOC | SEC_LOAD;
- else
- subspace_asect->flags |= SEC_DEBUGGING;
-
- if (subspace.code_only)
- subspace_asect->flags |= SEC_CODE;
-
- /* Both file_loc_init_value and initialization_length will
- be zero for a BSS like subspace. */
- if (subspace.file_loc_init_value == 0
- && subspace.initialization_length == 0)
- subspace_asect->flags &= ~(SEC_DATA | SEC_LOAD | SEC_HAS_CONTENTS);
-
- /* This subspace has relocations.
- The fixup_request_quantity is a byte count for the number of
- entries in the relocation stream; it is not the actual number
- of relocations in the subspace. */
- if (subspace.fixup_request_quantity != 0)
- {
- subspace_asect->flags |= SEC_RELOC;
- subspace_asect->rel_filepos = subspace.fixup_request_index;
- som_section_data (subspace_asect)->reloc_size
- = subspace.fixup_request_quantity;
- /* We can not determine this yet. When we read in the
- relocation table the correct value will be filled in. */
- subspace_asect->reloc_count = -1;
- }
-
- /* Update save_subspace if appropriate. */
- if (subspace.file_loc_init_value > save_subspace.file_loc_init_value)
- save_subspace = subspace;
-
- subspace_asect->vma = subspace.subspace_start;
- subspace_asect->_cooked_size = subspace.subspace_length;
- subspace_asect->_raw_size = subspace.subspace_length;
- subspace_asect->filepos = subspace.file_loc_init_value;
- subspace_asect->alignment_power = log2 (subspace.alignment);
- if (subspace_asect->alignment_power == -1)
- goto error_return;
- }
-
- /* Yow! there is no subspace within the space which actually
- has initialized information in it; this should never happen
- as far as I know. */
- if (!save_subspace.file_loc_init_value)
- goto error_return;
-
- /* Setup the sizes for the space section based upon the info in the
- last subspace of the space. */
- space_asect->_cooked_size = save_subspace.subspace_start
- - space_asect->vma + save_subspace.subspace_length;
- space_asect->_raw_size = save_subspace.file_loc_init_value
- - space_asect->filepos + save_subspace.initialization_length;
- }
- /* Now that we've read in all the subspace records, we need to assign
- a target index to each subspace. */
- subspace_sections = (asection **) bfd_malloc (total_subspaces
- * sizeof (asection *));
- if (subspace_sections == NULL)
- goto error_return;
-
- for (i = 0, section = abfd->sections; section; section = section->next)
- {
- if (!som_is_subspace (section))
- continue;
-
- subspace_sections[i] = section;
- i++;
- }
- qsort (subspace_sections, total_subspaces,
- sizeof (asection *), compare_subspaces);
-
- /* subspace_sections is now sorted in the order in which the subspaces
- appear in the object file. Assign an index to each one now. */
- for (i = 0; i < total_subspaces; i++)
- subspace_sections[i]->target_index = i;
-
- if (space_strings != NULL)
- free (space_strings);
-
- if (subspace_sections != NULL)
- free (subspace_sections);
-
- return true;
-
- error_return:
- if (space_strings != NULL)
- free (space_strings);
-
- if (subspace_sections != NULL)
- free (subspace_sections);
- return false;
-}
-
-/* Read in a SOM object and make it into a BFD. */
-
-static const bfd_target *
-som_object_p (abfd)
- bfd *abfd;
-{
- struct header file_hdr;
- struct som_exec_auxhdr aux_hdr;
-
- if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- if (!_PA_RISC_ID (file_hdr.system_id))
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- switch (file_hdr.a_magic)
- {
- case RELOC_MAGIC:
- case EXEC_MAGIC:
- case SHARE_MAGIC:
- case DEMAND_MAGIC:
-#ifdef DL_MAGIC
- case DL_MAGIC:
-#endif
-#ifdef SHL_MAGIC
- case SHL_MAGIC:
-#endif
-#ifdef EXECLIBMAGIC
- case EXECLIBMAGIC:
-#endif
-#ifdef SHARED_MAGIC_CNX
- case SHARED_MAGIC_CNX:
-#endif
- break;
- default:
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- if (file_hdr.version_id != VERSION_ID
- && file_hdr.version_id != NEW_VERSION_ID)
- {
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
-
- /* If the aux_header_size field in the file header is zero, then this
- object is an incomplete executable (a .o file). Do not try to read
- a non-existant auxiliary header. */
- memset (&aux_hdr, 0, sizeof (struct som_exec_auxhdr));
- if (file_hdr.aux_header_size != 0)
- {
- if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
- {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
- }
-
- if (!setup_sections (abfd, &file_hdr))
- {
- /* setup_sections does not bubble up a bfd error code. */
- bfd_set_error (bfd_error_bad_value);
- return 0;
- }
-
- /* This appears to be a valid SOM object. Do some initialization. */
- return som_object_setup (abfd, &file_hdr, &aux_hdr);
-}
-
-/* Create a SOM object. */
-
-static boolean
-som_mkobject (abfd)
- bfd *abfd;
-{
- /* Allocate memory to hold backend information. */
- abfd->tdata.som_data = (struct som_data_struct *)
- bfd_zalloc (abfd, sizeof (struct som_data_struct));
- if (abfd->tdata.som_data == NULL)
- return false;
- return true;
-}
-
-/* Initialize some information in the file header. This routine makes
- not attempt at doing the right thing for a full executable; it
- is only meant to handle relocatable objects. */
-
-static boolean
-som_prep_headers (abfd)
- bfd *abfd;
-{
- struct header *file_hdr;
- asection *section;
-
- /* Make and attach a file header to the BFD. */
- file_hdr = (struct header *) bfd_zalloc (abfd, sizeof (struct header));
- if (file_hdr == NULL)
- return false;
- obj_som_file_hdr (abfd) = file_hdr;
-
- if (abfd->flags & (EXEC_P | DYNAMIC))
- {
-
- /* Make and attach an exec header to the BFD. */
- obj_som_exec_hdr (abfd) = (struct som_exec_auxhdr *)
- bfd_zalloc (abfd, sizeof (struct som_exec_auxhdr));
- if (obj_som_exec_hdr (abfd) == NULL)
- return false;
-
- if (abfd->flags & D_PAGED)
- file_hdr->a_magic = DEMAND_MAGIC;
- else if (abfd->flags & WP_TEXT)
- file_hdr->a_magic = SHARE_MAGIC;
-#ifdef SHL_MAGIC
- else if (abfd->flags & DYNAMIC)
- file_hdr->a_magic = SHL_MAGIC;
-#endif
- else
- file_hdr->a_magic = EXEC_MAGIC;
- }
- else
- file_hdr->a_magic = RELOC_MAGIC;
-
- /* Only new format SOM is supported. */
- file_hdr->version_id = NEW_VERSION_ID;
-
- /* These fields are optional, and embedding timestamps is not always
- a wise thing to do, it makes comparing objects during a multi-stage
- bootstrap difficult. */
- file_hdr->file_time.secs = 0;
- file_hdr->file_time.nanosecs = 0;
-
- file_hdr->entry_space = 0;
- file_hdr->entry_subspace = 0;
- file_hdr->entry_offset = 0;
- file_hdr->presumed_dp = 0;
-
- /* Now iterate over the sections translating information from
- BFD sections to SOM spaces/subspaces. */
-
- for (section = abfd->sections; section != NULL; section = section->next)
- {
- /* Ignore anything which has not been marked as a space or
- subspace. */
- if (!som_is_space (section) && !som_is_subspace (section))
- continue;
-
- if (som_is_space (section))
- {
- /* Allocate space for the space dictionary. */
- som_section_data (section)->space_dict
- = (struct space_dictionary_record *)
- bfd_zalloc (abfd, sizeof (struct space_dictionary_record));
- if (som_section_data (section)->space_dict == NULL)
- return false;
- /* Set space attributes. Note most attributes of SOM spaces
- are set based on the subspaces it contains. */
- som_section_data (section)->space_dict->loader_fix_index = -1;
- som_section_data (section)->space_dict->init_pointer_index = -1;
-
- /* Set more attributes that were stuffed away in private data. */
- som_section_data (section)->space_dict->sort_key =
- som_section_data (section)->copy_data->sort_key;
- som_section_data (section)->space_dict->is_defined =
- som_section_data (section)->copy_data->is_defined;
- som_section_data (section)->space_dict->is_private =
- som_section_data (section)->copy_data->is_private;
- som_section_data (section)->space_dict->space_number =
- som_section_data (section)->copy_data->space_number;
- }
- else
- {
- /* Allocate space for the subspace dictionary. */
- som_section_data (section)->subspace_dict
- = (struct subspace_dictionary_record *)
- bfd_zalloc (abfd, sizeof (struct subspace_dictionary_record));
- if (som_section_data (section)->subspace_dict == NULL)
- return false;
-
- /* Set subspace attributes. Basic stuff is done here, additional
- attributes are filled in later as more information becomes
- available. */
- if (section->flags & SEC_IS_COMMON)
- {
- som_section_data (section)->subspace_dict->dup_common = 1;
- som_section_data (section)->subspace_dict->is_common = 1;
- }
-
- if (section->flags & SEC_ALLOC)
- som_section_data (section)->subspace_dict->is_loadable = 1;
-
- if (section->flags & SEC_CODE)
- som_section_data (section)->subspace_dict->code_only = 1;
-
- som_section_data (section)->subspace_dict->subspace_start =
- section->vma;
- som_section_data (section)->subspace_dict->subspace_length =
- bfd_section_size (abfd, section);
- som_section_data (section)->subspace_dict->initialization_length =
- bfd_section_size (abfd, section);
- som_section_data (section)->subspace_dict->alignment =
- 1 << section->alignment_power;
-
- /* Set more attributes that were stuffed away in private data. */
- som_section_data (section)->subspace_dict->sort_key =
- som_section_data (section)->copy_data->sort_key;
- som_section_data (section)->subspace_dict->access_control_bits =
- som_section_data (section)->copy_data->access_control_bits;
- som_section_data (section)->subspace_dict->quadrant =
- som_section_data (section)->copy_data->quadrant;
- }
- }
- return true;
-}
-
-/* Return true if the given section is a SOM space, false otherwise. */
-
-static boolean
-som_is_space (section)
- asection *section;
-{
- /* If no copy data is available, then it's neither a space nor a
- subspace. */
- if (som_section_data (section)->copy_data == NULL)
- return false;
-
- /* If the containing space isn't the same as the given section,
- then this isn't a space. */
- if (som_section_data (section)->copy_data->container != section
- && (som_section_data (section)->copy_data->container->output_section
- != section))
- return false;
-
- /* OK. Must be a space. */
- return true;
-}
-
-/* Return true if the given section is a SOM subspace, false otherwise. */
-
-static boolean
-som_is_subspace (section)
- asection *section;
-{
- /* If no copy data is available, then it's neither a space nor a
- subspace. */
- if (som_section_data (section)->copy_data == NULL)
- return false;
-
- /* If the containing space is the same as the given section,
- then this isn't a subspace. */
- if (som_section_data (section)->copy_data->container == section
- || (som_section_data (section)->copy_data->container->output_section
- == section))
- return false;
-
- /* OK. Must be a subspace. */
- return true;
-}
-
-/* Return true if the given space containins the given subspace. It
- is safe to assume space really is a space, and subspace really
- is a subspace. */
-
-static boolean
-som_is_container (space, subspace)
- asection *space, *subspace;
-{
- return (som_section_data (subspace)->copy_data->container == space
- || (som_section_data (subspace)->copy_data->container->output_section
- == space));
-}
-
-/* Count and return the number of spaces attached to the given BFD. */
-
-static unsigned long
-som_count_spaces (abfd)
- bfd *abfd;
-{
- int count = 0;
- asection *section;
-
- for (section = abfd->sections; section != NULL; section = section->next)
- count += som_is_space (section);
-
- return count;
-}
-
-/* Count the number of subspaces attached to the given BFD. */
-
-static unsigned long
-som_count_subspaces (abfd)
- bfd *abfd;
-{
- int count = 0;
- asection *section;
-
- for (section = abfd->sections; section != NULL; section = section->next)
- count += som_is_subspace (section);
-
- return count;
-}
-
-/* Return -1, 0, 1 indicating the relative ordering of sym1 and sym2.
-
- We desire symbols to be ordered starting with the symbol with the
- highest relocation count down to the symbol with the lowest relocation
- count. Doing so compacts the relocation stream. */
-
-static int
-compare_syms (arg1, arg2)
- const PTR arg1;
- const PTR arg2;
-
-{
- asymbol **sym1 = (asymbol **) arg1;
- asymbol **sym2 = (asymbol **) arg2;
- unsigned int count1, count2;
-
- /* Get relocation count for each symbol. Note that the count
- is stored in the udata pointer for section symbols! */
- if ((*sym1)->flags & BSF_SECTION_SYM)
- count1 = (*sym1)->udata.i;
- else
- count1 = som_symbol_data (*sym1)->reloc_count;
-
- if ((*sym2)->flags & BSF_SECTION_SYM)
- count2 = (*sym2)->udata.i;
- else
- count2 = som_symbol_data (*sym2)->reloc_count;
-
- /* Return the appropriate value. */
- if (count1 < count2)
- return 1;
- else if (count1 > count2)
- return -1;
- return 0;
-}
-
-/* Return -1, 0, 1 indicating the relative ordering of subspace1
- and subspace. */
-
-static int
-compare_subspaces (arg1, arg2)
- const PTR arg1;
- const PTR arg2;
-
-{
- asection **subspace1 = (asection **) arg1;
- asection **subspace2 = (asection **) arg2;
- unsigned int count1, count2;
-
- if ((*subspace1)->target_index < (*subspace2)->target_index)
- return -1;
- else if ((*subspace2)->target_index < (*subspace1)->target_index)
- return 1;
- else
- return 0;
-}
-
-/* Perform various work in preparation for emitting the fixup stream. */
-
-static void
-som_prep_for_fixups (abfd, syms, num_syms)
- bfd *abfd;
- asymbol **syms;
- unsigned long num_syms;
-{
- int i;
- asection *section;
- asymbol **sorted_syms;
-
- /* Most SOM relocations involving a symbol have a length which is
- dependent on the index of the symbol. So symbols which are
- used often in relocations should have a small index. */
-
- /* First initialize the counters for each symbol. */
- for (i = 0; i < num_syms; i++)
- {
- /* Handle a section symbol; these have no pointers back to the
- SOM symbol info. So we just use the udata field to hold the
- relocation count. */
- if (som_symbol_data (syms[i]) == NULL
- || syms[i]->flags & BSF_SECTION_SYM)
- {
- syms[i]->flags |= BSF_SECTION_SYM;
- syms[i]->udata.i = 0;
- }
- else
- som_symbol_data (syms[i])->reloc_count = 0;
- }
-
- /* Now that the counters are initialized, make a weighted count
- of how often a given symbol is used in a relocation. */
- for (section = abfd->sections; section != NULL; section = section->next)
- {
- int i;
-
- /* Does this section have any relocations? */
- if (section->reloc_count <= 0)
- continue;
-
- /* Walk through each relocation for this section. */
- for (i = 1; i < section->reloc_count; i++)
- {
- arelent *reloc = section->orelocation[i];
- int scale;
-
- /* A relocation against a symbol in the *ABS* section really
- does not have a symbol. Likewise if the symbol isn't associated
- with any section. */
- if (reloc->sym_ptr_ptr == NULL
- || bfd_is_abs_section ((*reloc->sym_ptr_ptr)->section))
- continue;
-
- /* Scaling to encourage symbols involved in R_DP_RELATIVE
- and R_CODE_ONE_SYMBOL relocations to come first. These
- two relocations have single byte versions if the symbol
- index is very small. */
- if (reloc->howto->type == R_DP_RELATIVE
- || reloc->howto->type == R_CODE_ONE_SYMBOL)
- scale = 2;
- else
- scale = 1;
-
- /* Handle section symbols by storing the count in the udata
- field. It will not be used and the count is very important
- for these symbols. */
- if ((*reloc->sym_ptr_ptr)->flags & BSF_SECTION_SYM)
- {
- (*reloc->sym_ptr_ptr)->udata.i =
- (*reloc->sym_ptr_ptr)->udata.i + scale;
- continue;
- }
-
- /* A normal symbol. Increment the count. */
- som_symbol_data (*reloc->sym_ptr_ptr)->reloc_count += scale;
- }
- }
-
- /* Sort a copy of the symbol table, rather than the canonical
- output symbol table. */
- sorted_syms = (asymbol **) bfd_zalloc (abfd, num_syms * sizeof (asymbol *));
- memcpy (sorted_syms, syms, num_syms * sizeof (asymbol *));
- qsort (sorted_syms, num_syms, sizeof (asymbol *), compare_syms);
- obj_som_sorted_syms (abfd) = sorted_syms;
-
- /* Compute the symbol indexes, they will be needed by the relocation
- code. */
- for (i = 0; i < num_syms; i++)
- {
- /* A section symbol. Again, there is no pointer to backend symbol
- information, so we reuse the udata field again. */
- if (sorted_syms[i]->flags & BSF_SECTION_SYM)
- sorted_syms[i]->udata.i = i;
- else
- som_symbol_data (sorted_syms[i])->index = i;
- }
-}
-
-static boolean
-som_write_fixups (abfd, current_offset, total_reloc_sizep)
- bfd *abfd;
- unsigned long current_offset;
- unsigned int *total_reloc_sizep;
-{
- unsigned int i, j;
- /* Chunk of memory that we can use as buffer space, then throw
- away. */
- unsigned char tmp_space[SOM_TMP_BUFSIZE];
- unsigned char *p;
- unsigned int total_reloc_size = 0;
- unsigned int subspace_reloc_size = 0;
- unsigned int num_spaces = obj_som_file_hdr (abfd)->space_total;
- asection *section = abfd->sections;
-
- memset (tmp_space, 0, SOM_TMP_BUFSIZE);
- p = tmp_space;
-
- /* All the fixups for a particular subspace are emitted in a single
- stream. All the subspaces for a particular space are emitted
- as a single stream.
-
- So, to get all the locations correct one must iterate through all the
- spaces, for each space iterate through its subspaces and output a
- fixups stream. */
- for (i = 0; i < num_spaces; i++)
- {
- asection *subsection;
-
- /* Find a space. */
- while (!som_is_space (section))
- section = section->next;
-
- /* Now iterate through each of its subspaces. */
- for (subsection = abfd->sections;
- subsection != NULL;
- subsection = subsection->next)
- {
- int reloc_offset, current_rounding_mode;
-
- /* Find a subspace of this space. */
- if (!som_is_subspace (subsection)
- || !som_is_container (section, subsection))
- continue;
-
- /* If this subspace does not have real data, then we are
- finised with it. */
- if ((subsection->flags & SEC_HAS_CONTENTS) == 0)
- {
- som_section_data (subsection)->subspace_dict->fixup_request_index
- = -1;
- continue;
- }
-
- /* This subspace has some relocations. Put the relocation stream
- index into the subspace record. */
- som_section_data (subsection)->subspace_dict->fixup_request_index
- = total_reloc_size;
-
- /* To make life easier start over with a clean slate for
- each subspace. Seek to the start of the relocation stream
- for this subspace in preparation for writing out its fixup
- stream. */
- if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) < 0)
- return false;
-
- /* Buffer space has already been allocated. Just perform some
- initialization here. */
- p = tmp_space;
- subspace_reloc_size = 0;
- reloc_offset = 0;
- som_initialize_reloc_queue (reloc_queue);
- current_rounding_mode = R_N_MODE;
-
- /* Translate each BFD relocation into one or more SOM
- relocations. */
- for (j = 0; j < subsection->reloc_count; j++)
- {
- arelent *bfd_reloc = subsection->orelocation[j];
- unsigned int skip;
- int sym_num;
-
- /* Get the symbol number. Remember it's stored in a
- special place for section symbols. */
- if ((*bfd_reloc->sym_ptr_ptr)->flags & BSF_SECTION_SYM)
- sym_num = (*bfd_reloc->sym_ptr_ptr)->udata.i;
- else
- sym_num = som_symbol_data (*bfd_reloc->sym_ptr_ptr)->index;
-
- /* If there is not enough room for the next couple relocations,
- then dump the current buffer contents now. Also reinitialize
- the relocation queue.
-
- No single BFD relocation could ever translate into more
- than 100 bytes of SOM relocations (20bytes is probably the
- upper limit, but leave lots of space for growth). */
- if (p - tmp_space + 100 > SOM_TMP_BUFSIZE)
- {
- if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
- != p - tmp_space)
- return false;
-
- p = tmp_space;
- som_initialize_reloc_queue (reloc_queue);
- }
-
- /* Emit R_NO_RELOCATION fixups to map any bytes which were
- skipped. */
- skip = bfd_reloc->address - reloc_offset;
- p = som_reloc_skip (abfd, skip, p,
- &subspace_reloc_size, reloc_queue);
-
- /* Update reloc_offset for the next iteration.
-
- Many relocations do not consume input bytes. They
- are markers, or set state necessary to perform some
- later relocation. */
- switch (bfd_reloc->howto->type)
- {
- /* This only needs to handle relocations that may be
- made by hppa_som_gen_reloc. */
- case R_ENTRY:
- case R_ALT_ENTRY:
- case R_EXIT:
- case R_N_MODE:
- case R_S_MODE:
- case R_D_MODE:
- case R_R_MODE:
- case R_FSEL:
- case R_LSEL:
- case R_RSEL:
- case R_COMP1:
- case R_COMP2:
- case R_BEGIN_BRTAB:
- case R_END_BRTAB:
- case R_N0SEL:
- case R_N1SEL:
- reloc_offset = bfd_reloc->address;
- break;
-
- default:
- reloc_offset = bfd_reloc->address + 4;
- break;
- }
-
- /* Now the actual relocation we care about. */
- switch (bfd_reloc->howto->type)
- {
- case R_PCREL_CALL:
- case R_ABS_CALL:
- p = som_reloc_call (abfd, p, &subspace_reloc_size,
- bfd_reloc, sym_num, reloc_queue);
- break;
-
- case R_CODE_ONE_SYMBOL:
- case R_DP_RELATIVE:
- /* Account for any addend. */
- if (bfd_reloc->addend)
- p = som_reloc_addend (abfd, bfd_reloc->addend, p,
- &subspace_reloc_size, reloc_queue);
-
- if (sym_num < 0x20)
- {
- bfd_put_8 (abfd, bfd_reloc->howto->type + sym_num, p);
- subspace_reloc_size += 1;
- p += 1;
- }
- else if (sym_num < 0x100)
- {
- bfd_put_8 (abfd, bfd_reloc->howto->type + 32, p);
- bfd_put_8 (abfd, sym_num, p + 1);
- p = try_prev_fixup (abfd, &subspace_reloc_size, p,
- 2, reloc_queue);
- }
- else if (sym_num < 0x10000000)
- {
- bfd_put_8 (abfd, bfd_reloc->howto->type + 33, p);
- bfd_put_8 (abfd, sym_num >> 16, p + 1);
- bfd_put_16 (abfd, sym_num, p + 2);
- p = try_prev_fixup (abfd, &subspace_reloc_size,
- p, 4, reloc_queue);
- }
- else
- abort ();
- break;
-
- case R_DATA_ONE_SYMBOL:
- case R_DATA_PLABEL:
- case R_CODE_PLABEL:
- case R_DLT_REL:
- /* Account for any addend using R_DATA_OVERRIDE. */
- if (bfd_reloc->howto->type != R_DATA_ONE_SYMBOL
- && bfd_reloc->addend)
- p = som_reloc_addend (abfd, bfd_reloc->addend, p,
- &subspace_reloc_size, reloc_queue);
-
- if (sym_num < 0x100)
- {
- bfd_put_8 (abfd, bfd_reloc->howto->type, p);
- bfd_put_8 (abfd, sym_num, p + 1);
- p = try_prev_fixup (abfd, &subspace_reloc_size, p,
- 2, reloc_queue);
- }
- else if (sym_num < 0x10000000)
- {
- bfd_put_8 (abfd, bfd_reloc->howto->type + 1, p);
- bfd_put_8 (abfd, sym_num >> 16, p + 1);
- bfd_put_16 (abfd, sym_num, p + 2);
- p = try_prev_fixup (abfd, &subspace_reloc_size,
- p, 4, reloc_queue);
- }
- else
- abort ();
- break;
-
- case R_ENTRY:
- {
- int tmp;
- arelent *tmp_reloc = NULL;
- bfd_put_8 (abfd, R_ENTRY, p);
-
- /* R_ENTRY relocations have 64 bits of associated
- data. Unfortunately the addend field of a bfd
- relocation is only 32 bits. So, we split up
- the 64bit unwind information and store part in
- the R_ENTRY relocation, and the rest in the R_EXIT
- relocation. */
- bfd_put_32 (abfd, bfd_reloc->addend, p + 1);
-
- /* Find the next R_EXIT relocation. */
- for (tmp = j; tmp < subsection->reloc_count; tmp++)
- {
- tmp_reloc = subsection->orelocation[tmp];
- if (tmp_reloc->howto->type == R_EXIT)
- break;
- }
-
- if (tmp == subsection->reloc_count)
- abort ();
-
- bfd_put_32 (abfd, tmp_reloc->addend, p + 5);
- p = try_prev_fixup (abfd, &subspace_reloc_size,
- p, 9, reloc_queue);
- break;
- }
-
- case R_N_MODE:
- case R_S_MODE:
- case R_D_MODE:
- case R_R_MODE:
- /* If this relocation requests the current rounding
- mode, then it is redundant. */
- if (bfd_reloc->howto->type != current_rounding_mode)
- {
- bfd_put_8 (abfd, bfd_reloc->howto->type, p);
- subspace_reloc_size += 1;
- p += 1;
- current_rounding_mode = bfd_reloc->howto->type;
- }
- break;
-
- case R_EXIT:
- case R_ALT_ENTRY:
- case R_FSEL:
- case R_LSEL:
- case R_RSEL:
- case R_BEGIN_BRTAB:
- case R_END_BRTAB:
- case R_N0SEL:
- case R_N1SEL:
- bfd_put_8 (abfd, bfd_reloc->howto->type, p);
- subspace_reloc_size += 1;
- p += 1;
- break;
-
- case R_COMP1:
- /* The only time we generate R_COMP1, R_COMP2 and
- R_CODE_EXPR relocs is for the difference of two
- symbols. Hence we can cheat here. */
- bfd_put_8 (abfd, bfd_reloc->howto->type, p);
- bfd_put_8 (abfd, 0x44, p + 1);
- p = try_prev_fixup (abfd, &subspace_reloc_size,
- p, 2, reloc_queue);
- break;
-
- case R_COMP2:
- /* The only time we generate R_COMP1, R_COMP2 and
- R_CODE_EXPR relocs is for the difference of two
- symbols. Hence we can cheat here. */
- bfd_put_8 (abfd, bfd_reloc->howto->type, p);
- bfd_put_8 (abfd, 0x80, p + 1);
- bfd_put_8 (abfd, sym_num >> 16, p + 2);
- bfd_put_16 (abfd, sym_num, p + 3);
- p = try_prev_fixup (abfd, &subspace_reloc_size,
- p, 5, reloc_queue);
- break;
-
- case R_CODE_EXPR:
- /* The only time we generate R_COMP1, R_COMP2 and
- R_CODE_EXPR relocs is for the difference of two
- symbols. Hence we can cheat here. */
- bfd_put_8 (abfd, bfd_reloc->howto->type, p);
- subspace_reloc_size += 1;
- p += 1;
- break;
-
- /* Put a "R_RESERVED" relocation in the stream if
- we hit something we do not understand. The linker
- will complain loudly if this ever happens. */
- default:
- bfd_put_8 (abfd, 0xff, p);
- subspace_reloc_size += 1;
- p += 1;
- break;
- }
- }
-
- /* Last BFD relocation for a subspace has been processed.
- Map the rest of the subspace with R_NO_RELOCATION fixups. */
- p = som_reloc_skip (abfd, bfd_section_size (abfd, subsection)
- - reloc_offset,
- p, &subspace_reloc_size, reloc_queue);
-
- /* Scribble out the relocations. */
- if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
- != p - tmp_space)
- return false;
- p = tmp_space;
-
- total_reloc_size += subspace_reloc_size;
- som_section_data (subsection)->subspace_dict->fixup_request_quantity
- = subspace_reloc_size;
- }
- section = section->next;
- }
- *total_reloc_sizep = total_reloc_size;
- return true;
-}
-
-/* Write out the space/subspace string table. */
-
-static boolean
-som_write_space_strings (abfd, current_offset, string_sizep)
- bfd *abfd;
- unsigned long current_offset;
- unsigned int *string_sizep;
-{
- /* Chunk of memory that we can use as buffer space, then throw
- away. */
- unsigned char tmp_space[SOM_TMP_BUFSIZE];
- unsigned char *p;
- unsigned int strings_size = 0;
- asection *section;
-
- memset (tmp_space, 0, SOM_TMP_BUFSIZE);
- p = tmp_space;
-
- /* Seek to the start of the space strings in preparation for writing
- them out. */
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
- return false;
-
- /* Walk through all the spaces and subspaces (order is not important)
- building up and writing string table entries for their names. */
- for (section = abfd->sections; section != NULL; section = section->next)
- {
- int length;
-
- /* Only work with space/subspaces; avoid any other sections
- which might have been made (.text for example). */
- if (!som_is_space (section) && !som_is_subspace (section))
- continue;
-
- /* Get the length of the space/subspace name. */
- length = strlen (section->name);
-
- /* If there is not enough room for the next entry, then dump the
- current buffer contents now. Each entry will take 4 bytes to
- hold the string length + the string itself + null terminator. */
- if (p - tmp_space + 5 + length > SOM_TMP_BUFSIZE)
- {
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
- != p - tmp_space)
- return false;
- /* Reset to beginning of the buffer space. */
- p = tmp_space;
- }
-
- /* First element in a string table entry is the length of the
- string. Alignment issues are already handled. */
- bfd_put_32 (abfd, length, p);
- p += 4;
- strings_size += 4;
-
- /* Record the index in the space/subspace records. */
- if (som_is_space (section))
- som_section_data (section)->space_dict->name.n_strx = strings_size;
- else
- som_section_data (section)->subspace_dict->name.n_strx = strings_size;
-
- /* Next comes the string itself + a null terminator. */
- strcpy (p, section->name);
- p += length + 1;
- strings_size += length + 1;
-
- /* Always align up to the next word boundary. */
- while (strings_size % 4)
- {
- bfd_put_8 (abfd, 0, p);
- p++;
- strings_size++;
- }
- }
-
- /* Done with the space/subspace strings. Write out any information
- contained in a partial block. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
- return false;
- *string_sizep = strings_size;
- return true;
-}
-
-/* Write out the symbol string table. */
-
-static boolean
-som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep)
- bfd *abfd;
- unsigned long current_offset;
- asymbol **syms;
- unsigned int num_syms;
- unsigned int *string_sizep;
-{
- unsigned int i;
-
- /* Chunk of memory that we can use as buffer space, then throw
- away. */
- unsigned char tmp_space[SOM_TMP_BUFSIZE];
- unsigned char *p;
- unsigned int strings_size = 0;
-
- memset (tmp_space, 0, SOM_TMP_BUFSIZE);
- p = tmp_space;
-
- /* Seek to the start of the space strings in preparation for writing
- them out. */
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
- return false;
-
- for (i = 0; i < num_syms; i++)
- {
- int length = strlen (syms[i]->name);
-
- /* If there is not enough room for the next entry, then dump the
- current buffer contents now. */
- if (p - tmp_space + 5 + length > SOM_TMP_BUFSIZE)
- {
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
- != p - tmp_space)
- return false;
- /* Reset to beginning of the buffer space. */
- p = tmp_space;
- }
-
- /* First element in a string table entry is the length of the
- string. This must always be 4 byte aligned. This is also
- an appropriate time to fill in the string index field in the
- symbol table entry. */
- bfd_put_32 (abfd, length, p);
- strings_size += 4;
- p += 4;
-
- /* Next comes the string itself + a null terminator. */
- strcpy (p, syms[i]->name);
-
- som_symbol_data(syms[i])->stringtab_offset = strings_size;
- p += length + 1;
- strings_size += length + 1;
-
- /* Always align up to the next word boundary. */
- while (strings_size % 4)
- {
- bfd_put_8 (abfd, 0, p);
- strings_size++;
- p++;
- }
- }
-
- /* Scribble out any partial block. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
- return false;
-
- *string_sizep = strings_size;
- return true;
-}
-
-/* Compute variable information to be placed in the SOM headers,
- space/subspace dictionaries, relocation streams, etc. Begin
- writing parts of the object file. */
-
-static boolean
-som_begin_writing (abfd)
- bfd *abfd;
-{
- unsigned long current_offset = 0;
- int strings_size = 0;
- unsigned int total_reloc_size = 0;
- unsigned long num_spaces, num_subspaces, i;
- asection *section;
- unsigned int total_subspaces = 0;
- struct som_exec_auxhdr *exec_header = NULL;
-
- /* The file header will always be first in an object file,
- everything else can be in random locations. To keep things
- "simple" BFD will lay out the object file in the manner suggested
- by the PRO ABI for PA-RISC Systems. */
-
- /* Before any output can really begin offsets for all the major
- portions of the object file must be computed. So, starting
- with the initial file header compute (and sometimes write)
- each portion of the object file. */
-
- /* Make room for the file header, it's contents are not complete
- yet, so it can not be written at this time. */
- current_offset += sizeof (struct header);
-
- /* Any auxiliary headers will follow the file header. Right now
- we support only the copyright and version headers. */
- obj_som_file_hdr (abfd)->aux_header_location = current_offset;
- obj_som_file_hdr (abfd)->aux_header_size = 0;
- if (abfd->flags & (EXEC_P | DYNAMIC))
- {
- /* Parts of the exec header will be filled in later, so
- delay writing the header itself. Fill in the defaults,
- and write it later. */
- current_offset += sizeof (struct som_exec_auxhdr);
- obj_som_file_hdr (abfd)->aux_header_size
- += sizeof (struct som_exec_auxhdr);
- exec_header = obj_som_exec_hdr (abfd);
- exec_header->som_auxhdr.type = EXEC_AUX_ID;
- exec_header->som_auxhdr.length = 40;
- }
- if (obj_som_version_hdr (abfd) != NULL)
- {
- unsigned int len;
-
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
- return false;
-
- /* Write the aux_id structure and the string length. */
- len = sizeof (struct aux_id) + sizeof (unsigned int);
- obj_som_file_hdr (abfd)->aux_header_size += len;
- current_offset += len;
- if (bfd_write ((PTR) obj_som_version_hdr (abfd), len, 1, abfd) != len)
- return false;
-
- /* Write the version string. */
- len = obj_som_version_hdr (abfd)->header_id.length - sizeof (int);
- obj_som_file_hdr (abfd)->aux_header_size += len;
- current_offset += len;
- if (bfd_write ((PTR) obj_som_version_hdr (abfd)->user_string,
- len, 1, abfd) != len)
- return false;
- }
-
- if (obj_som_copyright_hdr (abfd) != NULL)
- {
- unsigned int len;
-
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
- return false;
-
- /* Write the aux_id structure and the string length. */
- len = sizeof (struct aux_id) + sizeof (unsigned int);
- obj_som_file_hdr (abfd)->aux_header_size += len;
- current_offset += len;
- if (bfd_write ((PTR) obj_som_copyright_hdr (abfd), len, 1, abfd) != len)
- return false;
-
- /* Write the copyright string. */
- len = obj_som_copyright_hdr (abfd)->header_id.length - sizeof (int);
- obj_som_file_hdr (abfd)->aux_header_size += len;
- current_offset += len;
- if (bfd_write ((PTR) obj_som_copyright_hdr (abfd)->copyright,
- len, 1, abfd) != len)
- return false;
- }
-
- /* Next comes the initialization pointers; we have no initialization
- pointers, so current offset does not change. */
- obj_som_file_hdr (abfd)->init_array_location = current_offset;
- obj_som_file_hdr (abfd)->init_array_total = 0;
-
- /* Next are the space records. These are fixed length records.
-
- Count the number of spaces to determine how much room is needed
- in the object file for the space records.
-
- The names of the spaces are stored in a separate string table,
- and the index for each space into the string table is computed
- below. Therefore, it is not possible to write the space headers
- at this time. */
- num_spaces = som_count_spaces (abfd);
- obj_som_file_hdr (abfd)->space_location = current_offset;
- obj_som_file_hdr (abfd)->space_total = num_spaces;
- current_offset += num_spaces * sizeof (struct space_dictionary_record);
-
- /* Next are the subspace records. These are fixed length records.
-
- Count the number of subspaes to determine how much room is needed
- in the object file for the subspace records.
-
- A variety if fields in the subspace record are still unknown at
- this time (index into string table, fixup stream location/size, etc). */
- num_subspaces = som_count_subspaces (abfd);
- obj_som_file_hdr (abfd)->subspace_location = current_offset;
- obj_som_file_hdr (abfd)->subspace_total = num_subspaces;
- current_offset += num_subspaces * sizeof (struct subspace_dictionary_record);
-
- /* Next is the string table for the space/subspace names. We will
- build and write the string table on the fly. At the same time
- we will fill in the space/subspace name index fields. */
-
- /* The string table needs to be aligned on a word boundary. */
- if (current_offset % 4)
- current_offset += (4 - (current_offset % 4));
-
- /* Mark the offset of the space/subspace string table in the
- file header. */
- obj_som_file_hdr (abfd)->space_strings_location = current_offset;
-
- /* Scribble out the space strings. */
- if (som_write_space_strings (abfd, current_offset, &strings_size) == false)
- return false;
-
- /* Record total string table size in the header and update the
- current offset. */
- obj_som_file_hdr (abfd)->space_strings_size = strings_size;
- current_offset += strings_size;
-
- /* Next is the compiler records. We do not use these. */
- obj_som_file_hdr (abfd)->compiler_location = current_offset;
- obj_som_file_hdr (abfd)->compiler_total = 0;
-
- /* Now compute the file positions for the loadable subspaces, taking
- care to make sure everything stays properly aligned. */
-
- section = abfd->sections;
- for (i = 0; i < num_spaces; i++)
- {
- asection *subsection;
- int first_subspace;
- unsigned int subspace_offset = 0;
-
- /* Find a space. */
- while (!som_is_space (section))
- section = section->next;
-
- first_subspace = 1;
- /* Now look for all its subspaces. */
- for (subsection = abfd->sections;
- subsection != NULL;
- subsection = subsection->next)
- {
-
- if (!som_is_subspace (subsection)
- || !som_is_container (section, subsection)
- || (subsection->flags & SEC_ALLOC) == 0)
- continue;
-
- /* If this is the first subspace in the space, and we are
- building an executable, then take care to make sure all
- the alignments are correct and update the exec header. */
- if (first_subspace
- && (abfd->flags & (EXEC_P | DYNAMIC)))
- {
- /* Demand paged executables have each space aligned to a
- page boundary. Sharable executables (write-protected
- text) have just the private (aka data & bss) space aligned
- to a page boundary. Ugh. Not true for HPUX.
-
- The HPUX kernel requires the text to always be page aligned
- within the file regardless of the executable's type. */
- if (abfd->flags & (D_PAGED | DYNAMIC)
- || (subsection->flags & SEC_CODE)
- || ((abfd->flags & WP_TEXT)
- && (subsection->flags & SEC_DATA)))
- current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
-
- /* Update the exec header. */
- if (subsection->flags & SEC_CODE && exec_header->exec_tfile == 0)
- {
- exec_header->exec_tmem = section->vma;
- exec_header->exec_tfile = current_offset;
- }
- if (subsection->flags & SEC_DATA && exec_header->exec_dfile == 0)
- {
- exec_header->exec_dmem = section->vma;
- exec_header->exec_dfile = current_offset;
- }
-
- /* Keep track of exactly where we are within a particular
- space. This is necessary as the braindamaged HPUX
- loader will create holes between subspaces *and*
- subspace alignments are *NOT* preserved. What a crock. */
- subspace_offset = subsection->vma;
-
- /* Only do this for the first subspace within each space. */
- first_subspace = 0;
- }
- else if (abfd->flags & (EXEC_P | DYNAMIC))
- {
- /* The braindamaged HPUX loader may have created a hole
- between two subspaces. It is *not* sufficient to use
- the alignment specifications within the subspaces to
- account for these holes -- I've run into at least one
- case where the loader left one code subspace unaligned
- in a final executable.
-
- To combat this we keep a current offset within each space,
- and use the subspace vma fields to detect and preserve
- holes. What a crock!
-
- ps. This is not necessary for unloadable space/subspaces. */
- current_offset += subsection->vma - subspace_offset;
- if (subsection->flags & SEC_CODE)
- exec_header->exec_tsize += subsection->vma - subspace_offset;
- else
- exec_header->exec_dsize += subsection->vma - subspace_offset;
- subspace_offset += subsection->vma - subspace_offset;
- }
-
-
- subsection->target_index = total_subspaces++;
- /* This is real data to be loaded from the file. */
- if (subsection->flags & SEC_LOAD)
- {
- /* Update the size of the code & data. */
- if (abfd->flags & (EXEC_P | DYNAMIC)
- && subsection->flags & SEC_CODE)
- exec_header->exec_tsize += subsection->_cooked_size;
- else if (abfd->flags & (EXEC_P | DYNAMIC)
- && subsection->flags & SEC_DATA)
- exec_header->exec_dsize += subsection->_cooked_size;
- som_section_data (subsection)->subspace_dict->file_loc_init_value
- = current_offset;
- subsection->filepos = current_offset;
- current_offset += bfd_section_size (abfd, subsection);
- subspace_offset += bfd_section_size (abfd, subsection);
- }
- /* Looks like uninitialized data. */
- else
- {
- /* Update the size of the bss section. */
- if (abfd->flags & (EXEC_P | DYNAMIC))
- exec_header->exec_bsize += subsection->_cooked_size;
-
- som_section_data (subsection)->subspace_dict->file_loc_init_value
- = 0;
- som_section_data (subsection)->subspace_dict->
- initialization_length = 0;
- }
- }
- /* Goto the next section. */
- section = section->next;
- }
-
- /* Finally compute the file positions for unloadable subspaces.
- If building an executable, start the unloadable stuff on its
- own page. */
-
- if (abfd->flags & (EXEC_P | DYNAMIC))
- current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
-
- obj_som_file_hdr (abfd)->unloadable_sp_location = current_offset;
- section = abfd->sections;
- for (i = 0; i < num_spaces; i++)
- {
- asection *subsection;
-
- /* Find a space. */
- while (!som_is_space (section))
- section = section->next;
-
- if (abfd->flags & (EXEC_P | DYNAMIC))
- current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
-
- /* Now look for all its subspaces. */
- for (subsection = abfd->sections;
- subsection != NULL;
- subsection = subsection->next)
- {
-
- if (!som_is_subspace (subsection)
- || !som_is_container (section, subsection)
- || (subsection->flags & SEC_ALLOC) != 0)
- continue;
-
- subsection->target_index = total_subspaces++;
- /* This is real data to be loaded from the file. */
- if ((subsection->flags & SEC_LOAD) == 0)
- {
- som_section_data (subsection)->subspace_dict->file_loc_init_value
- = current_offset;
- subsection->filepos = current_offset;
- current_offset += bfd_section_size (abfd, subsection);
- }
- /* Looks like uninitialized data. */
- else
- {
- som_section_data (subsection)->subspace_dict->file_loc_init_value
- = 0;
- som_section_data (subsection)->subspace_dict->
- initialization_length = bfd_section_size (abfd, subsection);
- }
- }
- /* Goto the next section. */
- section = section->next;
- }
-
- /* If building an executable, then make sure to seek to and write
- one byte at the end of the file to make sure any necessary
- zeros are filled in. Ugh. */
- if (abfd->flags & (EXEC_P | DYNAMIC))
- current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
- if (bfd_seek (abfd, current_offset - 1, SEEK_SET) < 0)
- return false;
- if (bfd_write ((PTR) "", 1, 1, abfd) != 1)
- return false;
-
- obj_som_file_hdr (abfd)->unloadable_sp_size
- = current_offset - obj_som_file_hdr (abfd)->unloadable_sp_location;
-
- /* Loader fixups are not supported in any way shape or form. */
- obj_som_file_hdr (abfd)->loader_fixup_location = 0;
- obj_som_file_hdr (abfd)->loader_fixup_total = 0;
-
- /* Done. Store the total size of the SOM so far. */
- obj_som_file_hdr (abfd)->som_length = current_offset;
-
- return true;
-}
-
-/* Finally, scribble out the various headers to the disk. */
-
-static boolean
-som_finish_writing (abfd)
- bfd *abfd;
-{
- int num_spaces = som_count_spaces (abfd);
- asymbol **syms = bfd_get_outsymbols (abfd);
- int i, num_syms, strings_size;
- int subspace_index = 0;
- file_ptr location;
- asection *section;
- unsigned long current_offset;
- unsigned int total_reloc_size;
-
- /* Next is the symbol table. These are fixed length records.
-
- Count the number of symbols to determine how much room is needed
- in the object file for the symbol table.
-
- The names of the symbols are stored in a separate string table,
- and the index for each symbol name into the string table is computed
- below. Therefore, it is not possible to write the symbol table
- at this time.
-
- These used to be output before the subspace contents, but they
- were moved here to work around a stupid bug in the hpux linker
- (fixed in hpux10). */
- current_offset = obj_som_file_hdr (abfd)->som_length;
-
- /* Make sure we're on a word boundary. */
- if (current_offset % 4)
- current_offset += (4 - (current_offset % 4));
-
- num_syms = bfd_get_symcount (abfd);
- obj_som_file_hdr (abfd)->symbol_location = current_offset;
- obj_som_file_hdr (abfd)->symbol_total = num_syms;
- current_offset += num_syms * sizeof (struct symbol_dictionary_record);
-
- /* Next are the symbol strings.
- Align them to a word boundary. */
- if (current_offset % 4)
- current_offset += (4 - (current_offset % 4));
- obj_som_file_hdr (abfd)->symbol_strings_location = current_offset;
-
- /* Scribble out the symbol strings. */
- if (som_write_symbol_strings (abfd, current_offset, syms,
- num_syms, &strings_size)
- == false)
- return false;
-
- /* Record total string table size in header and update the
- current offset. */
- obj_som_file_hdr (abfd)->symbol_strings_size = strings_size;
- current_offset += strings_size;
-
- /* Do prep work before handling fixups. */
- som_prep_for_fixups (abfd,
- bfd_get_outsymbols (abfd),
- bfd_get_symcount (abfd));
-
- /* At the end of the file is the fixup stream which starts on a
- word boundary. */
- if (current_offset % 4)
- current_offset += (4 - (current_offset % 4));
- obj_som_file_hdr (abfd)->fixup_request_location = current_offset;
-
- /* Write the fixups and update fields in subspace headers which
- relate to the fixup stream. */
- if (som_write_fixups (abfd, current_offset, &total_reloc_size) == false)
- return false;
-
- /* Record the total size of the fixup stream in the file header. */
- obj_som_file_hdr (abfd)->fixup_request_total = total_reloc_size;
-
- /* Done. Store the total size of the SOM. */
- obj_som_file_hdr (abfd)->som_length = current_offset + total_reloc_size;
-
- /* Now that the symbol table information is complete, build and
- write the symbol table. */
- if (som_build_and_write_symbol_table (abfd) == false)
- return false;
-
- /* Subspaces are written first so that we can set up information
- about them in their containing spaces as the subspace is written. */
-
- /* Seek to the start of the subspace dictionary records. */
- location = obj_som_file_hdr (abfd)->subspace_location;
- if (bfd_seek (abfd, location, SEEK_SET) < 0)
- return false;
-
- section = abfd->sections;
- /* Now for each loadable space write out records for its subspaces. */
- for (i = 0; i < num_spaces; i++)
- {
- asection *subsection;
-
- /* Find a space. */
- while (!som_is_space (section))
- section = section->next;
-
- /* Now look for all its subspaces. */
- for (subsection = abfd->sections;
- subsection != NULL;
- subsection = subsection->next)
- {
-
- /* Skip any section which does not correspond to a space
- or subspace. Or does not have SEC_ALLOC set (and therefore
- has no real bits on the disk). */
- if (!som_is_subspace (subsection)
- || !som_is_container (section, subsection)
- || (subsection->flags & SEC_ALLOC) == 0)
- continue;
-
- /* If this is the first subspace for this space, then save
- the index of the subspace in its containing space. Also
- set "is_loadable" in the containing space. */
-
- if (som_section_data (section)->space_dict->subspace_quantity == 0)
- {
- som_section_data (section)->space_dict->is_loadable = 1;
- som_section_data (section)->space_dict->subspace_index
- = subspace_index;
- }
-
- /* Increment the number of subspaces seen and the number of
- subspaces contained within the current space. */
- subspace_index++;
- som_section_data (section)->space_dict->subspace_quantity++;
-
- /* Mark the index of the current space within the subspace's
- dictionary record. */
- som_section_data (subsection)->subspace_dict->space_index = i;
-
- /* Dump the current subspace header. */
- if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
- sizeof (struct subspace_dictionary_record), 1, abfd)
- != sizeof (struct subspace_dictionary_record))
- return false;
- }
- /* Goto the next section. */
- section = section->next;
- }
-
- /* Now repeat the process for unloadable subspaces. */
- section = abfd->sections;
- /* Now for each space write out records for its subspaces. */
- for (i = 0; i < num_spaces; i++)
- {
- asection *subsection;
-
- /* Find a space. */
- while (!som_is_space (section))
- section = section->next;
-
- /* Now look for all its subspaces. */
- for (subsection = abfd->sections;
- subsection != NULL;
- subsection = subsection->next)
- {
-
- /* Skip any section which does not correspond to a space or
- subspace, or which SEC_ALLOC set (and therefore handled
- in the loadable spaces/subspaces code above). */
-
- if (!som_is_subspace (subsection)
- || !som_is_container (section, subsection)
- || (subsection->flags & SEC_ALLOC) != 0)
- continue;
-
- /* If this is the first subspace for this space, then save
- the index of the subspace in its containing space. Clear
- "is_loadable". */
-
- if (som_section_data (section)->space_dict->subspace_quantity == 0)
- {
- som_section_data (section)->space_dict->is_loadable = 0;
- som_section_data (section)->space_dict->subspace_index
- = subspace_index;
- }
-
- /* Increment the number of subspaces seen and the number of
- subspaces contained within the current space. */
- som_section_data (section)->space_dict->subspace_quantity++;
- subspace_index++;
-
- /* Mark the index of the current space within the subspace's
- dictionary record. */
- som_section_data (subsection)->subspace_dict->space_index = i;
-
- /* Dump this subspace header. */
- if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
- sizeof (struct subspace_dictionary_record), 1, abfd)
- != sizeof (struct subspace_dictionary_record))
- return false;
- }
- /* Goto the next section. */
- section = section->next;
- }
-
- /* All the subspace dictiondary records are written, and all the
- fields are set up in the space dictionary records.
-
- Seek to the right location and start writing the space
- dictionary records. */
- location = obj_som_file_hdr (abfd)->space_location;
- if (bfd_seek (abfd, location, SEEK_SET) < 0)
- return false;
-
- section = abfd->sections;
- for (i = 0; i < num_spaces; i++)
- {
-
- /* Find a space. */
- while (!som_is_space (section))
- section = section->next;
-
- /* Dump its header */
- if (bfd_write ((PTR) som_section_data (section)->space_dict,
- sizeof (struct space_dictionary_record), 1, abfd)
- != sizeof (struct space_dictionary_record))
- return false;
-
- /* Goto the next section. */
- section = section->next;
- }
-
- /* Setting of the system_id has to happen very late now that copying of
- BFD private data happens *after* section contents are set. */
- if (abfd->flags & (EXEC_P | DYNAMIC))
- obj_som_file_hdr(abfd)->system_id = obj_som_exec_data (abfd)->system_id;
- else if (bfd_get_mach (abfd) == pa11)
- obj_som_file_hdr(abfd)->system_id = CPU_PA_RISC1_1;
- else
- obj_som_file_hdr(abfd)->system_id = CPU_PA_RISC1_0;
-
- /* Compute the checksum for the file header just before writing
- the header to disk. */
- obj_som_file_hdr (abfd)->checksum = som_compute_checksum (abfd);
-
- /* Only thing left to do is write out the file header. It is always
- at location zero. Seek there and write it. */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
- return false;
- if (bfd_write ((PTR) obj_som_file_hdr (abfd),
- sizeof (struct header), 1, abfd)
- != sizeof (struct header))
- return false;
-
- /* Now write the exec header. */
- if (abfd->flags & (EXEC_P | DYNAMIC))
- {
- long tmp;
- struct som_exec_auxhdr *exec_header;
-
- exec_header = obj_som_exec_hdr (abfd);
- exec_header->exec_entry = bfd_get_start_address (abfd);
- exec_header->exec_flags = obj_som_exec_data (abfd)->exec_flags;
-
- /* Oh joys. Ram some of the BSS data into the DATA section
- to be compatable with how the hp linker makes objects
- (saves memory space). */
- tmp = exec_header->exec_dsize;
- tmp = SOM_ALIGN (tmp, PA_PAGESIZE);
- exec_header->exec_bsize -= (tmp - exec_header->exec_dsize);
- if (exec_header->exec_bsize < 0)
- exec_header->exec_bsize = 0;
- exec_header->exec_dsize = tmp;
-
- if (bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location,
- SEEK_SET) < 0)
- return false;
-
- if (bfd_write ((PTR) exec_header, AUX_HDR_SIZE, 1, abfd)
- != AUX_HDR_SIZE)
- return false;
- }
- return true;
-}
-
-/* Compute and return the checksum for a SOM file header. */
-
-static unsigned long
-som_compute_checksum (abfd)
- bfd *abfd;
-{
- unsigned long checksum, count, i;
- unsigned long *buffer = (unsigned long *) obj_som_file_hdr (abfd);
-
- checksum = 0;
- count = sizeof (struct header) / sizeof (unsigned long);
- for (i = 0; i < count; i++)
- checksum ^= *(buffer + i);
-
- return checksum;
-}
-
-static void
-som_bfd_derive_misc_symbol_info (abfd, sym, info)
- bfd *abfd;
- asymbol *sym;
- struct som_misc_symbol_info *info;
-{
- /* Initialize. */
- memset (info, 0, sizeof (struct som_misc_symbol_info));
-
- /* The HP SOM linker requires detailed type information about
- all symbols (including undefined symbols!). Unfortunately,
- the type specified in an import/export statement does not
- always match what the linker wants. Severe braindamage. */
-
- /* Section symbols will not have a SOM symbol type assigned to
- them yet. Assign all section symbols type ST_DATA. */
- if (sym->flags & BSF_SECTION_SYM)
- info->symbol_type = ST_DATA;
- else
- {
- /* Common symbols must have scope SS_UNSAT and type
- ST_STORAGE or the linker will choke. */
- if (bfd_is_com_section (sym->section))
- {
- info->symbol_scope = SS_UNSAT;
- info->symbol_type = ST_STORAGE;
- }
-
- /* It is possible to have a symbol without an associated
- type. This happens if the user imported the symbol
- without a type and the symbol was never defined
- locally. If BSF_FUNCTION is set for this symbol, then
- assign it type ST_CODE (the HP linker requires undefined
- external functions to have type ST_CODE rather than ST_ENTRY). */
- else if ((som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN
- || som_symbol_data (sym)->som_type == SYMBOL_TYPE_CODE)
- && bfd_is_und_section (sym->section)
- && sym->flags & BSF_FUNCTION)
- info->symbol_type = ST_CODE;
-
- /* Handle function symbols which were defined in this file.
- They should have type ST_ENTRY. Also retrieve the argument
- relocation bits from the SOM backend information. */
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_ENTRY
- || (som_symbol_data (sym)->som_type == SYMBOL_TYPE_CODE
- && (sym->flags & BSF_FUNCTION))
- || (som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN
- && (sym->flags & BSF_FUNCTION)))
- {
- info->symbol_type = ST_ENTRY;
- info->arg_reloc = som_symbol_data (sym)->tc_data.hppa_arg_reloc;
- }
-
- /* If the type is unknown at this point, it should be ST_DATA or
- ST_CODE (function/ST_ENTRY symbols were handled as special
- cases above). */
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN)
- {
- if (sym->section->flags & SEC_CODE)
- info->symbol_type = ST_CODE;
- else
- info->symbol_type = ST_DATA;
- }
-
- /* From now on it's a very simple mapping. */
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_ABSOLUTE)
- info->symbol_type = ST_ABSOLUTE;
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_CODE)
- info->symbol_type = ST_CODE;
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_DATA)
- info->symbol_type = ST_DATA;
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_MILLICODE)
- info->symbol_type = ST_MILLICODE;
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_PLABEL)
- info->symbol_type = ST_PLABEL;
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_PRI_PROG)
- info->symbol_type = ST_PRI_PROG;
- else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_SEC_PROG)
- info->symbol_type = ST_SEC_PROG;
- }
-
- /* Now handle the symbol's scope. Exported data which is not
- in the common section has scope SS_UNIVERSAL. Note scope
- of common symbols was handled earlier! */
- if (bfd_is_und_section (sym->section))
- info->symbol_scope = SS_UNSAT;
- else if (sym->flags & BSF_EXPORT && ! bfd_is_com_section (sym->section))
- info->symbol_scope = SS_UNIVERSAL;
- /* Anything else which is not in the common section has scope
- SS_LOCAL. */
- else if (! bfd_is_com_section (sym->section))
- info->symbol_scope = SS_LOCAL;
-
- /* Now set the symbol_info field. It has no real meaning
- for undefined or common symbols, but the HP linker will
- choke if it's not set to some "reasonable" value. We
- use zero as a reasonable value. */
- if (bfd_is_com_section (sym->section)
- || bfd_is_und_section (sym->section)
- || bfd_is_abs_section (sym->section))
- info->symbol_info = 0;
- /* For all other symbols, the symbol_info field contains the
- subspace index of the space this symbol is contained in. */
- else
- info->symbol_info = sym->section->target_index;
-
- /* Set the symbol's value. */
- info->symbol_value = sym->value + sym->section->vma;
-}
-
-/* Build and write, in one big chunk, the entire symbol table for
- this BFD. */
-
-static boolean
-som_build_and_write_symbol_table (abfd)
- bfd *abfd;
-{
- unsigned int num_syms = bfd_get_symcount (abfd);
- file_ptr symtab_location = obj_som_file_hdr (abfd)->symbol_location;
- asymbol **bfd_syms = obj_som_sorted_syms (abfd);
- struct symbol_dictionary_record *som_symtab = NULL;
- int i, symtab_size;
-
- /* Compute total symbol table size and allocate a chunk of memory
- to hold the symbol table as we build it. */
- symtab_size = num_syms * sizeof (struct symbol_dictionary_record);
- som_symtab = (struct symbol_dictionary_record *) bfd_malloc (symtab_size);
- if (som_symtab == NULL && symtab_size != 0)
- goto error_return;
- memset (som_symtab, 0, symtab_size);
-
- /* Walk over each symbol. */
- for (i = 0; i < num_syms; i++)
- {
- struct som_misc_symbol_info info;
-
- /* This is really an index into the symbol strings table.
- By the time we get here, the index has already been
- computed and stored into the name field in the BFD symbol. */
- som_symtab[i].name.n_strx = som_symbol_data(bfd_syms[i])->stringtab_offset;
-
- /* Derive SOM information from the BFD symbol. */
- som_bfd_derive_misc_symbol_info (abfd, bfd_syms[i], &info);
-
- /* Now use it. */
- som_symtab[i].symbol_type = info.symbol_type;
- som_symtab[i].symbol_scope = info.symbol_scope;
- som_symtab[i].arg_reloc = info.arg_reloc;
- som_symtab[i].symbol_info = info.symbol_info;
- som_symtab[i].symbol_value = info.symbol_value;
- }
-
- /* Everything is ready, seek to the right location and
- scribble out the symbol table. */
- if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0)
- return false;
-
- if (bfd_write ((PTR) som_symtab, symtab_size, 1, abfd) != symtab_size)
- goto error_return;
-
- if (som_symtab != NULL)
- free (som_symtab);
- return true;
- error_return:
- if (som_symtab != NULL)
- free (som_symtab);
- return false;
-}
-
-/* Write an object in SOM format. */
-
-static boolean
-som_write_object_contents (abfd)
- bfd *abfd;
-{
- if (abfd->output_has_begun == false)
- {
- /* Set up fixed parts of the file, space, and subspace headers.
- Notify the world that output has begun. */
- som_prep_headers (abfd);
- abfd->output_has_begun = true;
- /* Start writing the object file. This include all the string
- tables, fixup streams, and other portions of the object file. */
- som_begin_writing (abfd);
- }
-
- return (som_finish_writing (abfd));
-}
-
-
-/* Read and save the string table associated with the given BFD. */
-
-static boolean
-som_slurp_string_table (abfd)
- bfd *abfd;
-{
- char *stringtab;
-
- /* Use the saved version if its available. */
- if (obj_som_stringtab (abfd) != NULL)
- return true;
-
- /* I don't think this can currently happen, and I'm not sure it should
- really be an error, but it's better than getting unpredictable results
- from the host's malloc when passed a size of zero. */
- if (obj_som_stringtab_size (abfd) == 0)
- {
- bfd_set_error (bfd_error_no_symbols);
- return false;
- }
-
- /* Allocate and read in the string table. */
- stringtab = bfd_malloc (obj_som_stringtab_size (abfd));
- if (stringtab == NULL)
- return false;
- memset (stringtab, 0, obj_som_stringtab_size (abfd));
-
- if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
- return false;
-
- if (bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd)
- != obj_som_stringtab_size (abfd))
- return false;
-
- /* Save our results and return success. */
- obj_som_stringtab (abfd) = stringtab;
- return true;
-}
-
-/* Return the amount of data (in bytes) required to hold the symbol
- table for this object. */
-
-static long
-som_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- if (!som_slurp_symbol_table (abfd))
- return -1;
-
- return (bfd_get_symcount (abfd) + 1) * (sizeof (asymbol *));
-}
-
-/* Convert from a SOM subspace index to a BFD section. */
-
-static asection *
-bfd_section_from_som_symbol (abfd, symbol)
- bfd *abfd;
- struct symbol_dictionary_record *symbol;
-{
- asection *section;
-
- /* The meaning of the symbol_info field changes for functions
- within executables. So only use the quick symbol_info mapping for
- incomplete objects and non-function symbols in executables. */
- if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0
- || (symbol->symbol_type != ST_ENTRY
- && symbol->symbol_type != ST_PRI_PROG
- && symbol->symbol_type != ST_SEC_PROG
- && symbol->symbol_type != ST_MILLICODE))
- {
- unsigned int index = symbol->symbol_info;
- for (section = abfd->sections; section != NULL; section = section->next)
- if (section->target_index == index && som_is_subspace (section))
- return section;
-
- /* Could be a symbol from an external library (such as an OMOS
- shared library). Don't abort. */
- return bfd_abs_section_ptr;
-
- }
- else
- {
- unsigned int value = symbol->symbol_value;
-
- /* For executables we will have to use the symbol's address and
- find out what section would contain that address. Yuk. */
- for (section = abfd->sections; section; section = section->next)
- {
- if (value >= section->vma
- && value <= section->vma + section->_cooked_size
- && som_is_subspace (section))
- return section;
- }
-
- /* Could be a symbol from an external library (such as an OMOS
- shared library). Don't abort. */
- return bfd_abs_section_ptr;
-
- }
-}
-
-/* Read and save the symbol table associated with the given BFD. */
-
-static unsigned int
-som_slurp_symbol_table (abfd)
- bfd *abfd;
-{
- int symbol_count = bfd_get_symcount (abfd);
- int symsize = sizeof (struct symbol_dictionary_record);
- char *stringtab;
- struct symbol_dictionary_record *buf = NULL, *bufp, *endbufp;
- som_symbol_type *sym, *symbase;
-
- /* Return saved value if it exists. */
- if (obj_som_symtab (abfd) != NULL)
- goto successful_return;
-
- /* Special case. This is *not* an error. */
- if (symbol_count == 0)
- goto successful_return;
-
- if (!som_slurp_string_table (abfd))
- goto error_return;
-
- stringtab = obj_som_stringtab (abfd);
-
- symbase = ((som_symbol_type *)
- bfd_malloc (symbol_count * sizeof (som_symbol_type)));
- if (symbase == NULL)
- goto error_return;
- memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
-
- /* Read in the external SOM representation. */
- buf = bfd_malloc (symbol_count * symsize);
- if (buf == NULL && symbol_count * symsize != 0)
- goto error_return;
- if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0)
- goto error_return;
- if (bfd_read (buf, symbol_count * symsize, 1, abfd)
- != symbol_count * symsize)
- goto error_return;
-
- /* Iterate over all the symbols and internalize them. */
- endbufp = buf + symbol_count;
- for (bufp = buf, sym = symbase; bufp < endbufp; ++bufp)
- {
-
- /* I don't think we care about these. */
- if (bufp->symbol_type == ST_SYM_EXT
- || bufp->symbol_type == ST_ARG_EXT)
- continue;
-
- /* Set some private data we care about. */
- if (bufp->symbol_type == ST_NULL)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_UNKNOWN;
- else if (bufp->symbol_type == ST_ABSOLUTE)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_ABSOLUTE;
- else if (bufp->symbol_type == ST_DATA)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_DATA;
- else if (bufp->symbol_type == ST_CODE)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_CODE;
- else if (bufp->symbol_type == ST_PRI_PROG)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_PRI_PROG;
- else if (bufp->symbol_type == ST_SEC_PROG)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_SEC_PROG;
- else if (bufp->symbol_type == ST_ENTRY)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_ENTRY;
- else if (bufp->symbol_type == ST_MILLICODE)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_MILLICODE;
- else if (bufp->symbol_type == ST_PLABEL)
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_PLABEL;
- else
- som_symbol_data (sym)->som_type = SYMBOL_TYPE_UNKNOWN;
- som_symbol_data (sym)->tc_data.hppa_arg_reloc = bufp->arg_reloc;
-
- /* Some reasonable defaults. */
- sym->symbol.the_bfd = abfd;
- sym->symbol.name = bufp->name.n_strx + stringtab;
- sym->symbol.value = bufp->symbol_value;
- sym->symbol.section = 0;
- sym->symbol.flags = 0;
-
- switch (bufp->symbol_type)
- {
- case ST_ENTRY:
- case ST_MILLICODE:
- sym->symbol.flags |= BSF_FUNCTION;
- sym->symbol.value &= ~0x3;
- break;
-
- case ST_STUB:
- case ST_CODE:
- case ST_PRI_PROG:
- case ST_SEC_PROG:
- sym->symbol.value &= ~0x3;
- /* If the symbol's scope is ST_UNSAT, then these are
- undefined function symbols. */
- if (bufp->symbol_scope == SS_UNSAT)
- sym->symbol.flags |= BSF_FUNCTION;
-
-
- default:
- break;
- }
-
- /* Handle scoping and section information. */
- switch (bufp->symbol_scope)
- {
- /* symbol_info field is undefined for SS_EXTERNAL and SS_UNSAT symbols,
- so the section associated with this symbol can't be known. */
- case SS_EXTERNAL:
- if (bufp->symbol_type != ST_STORAGE)
- sym->symbol.section = bfd_und_section_ptr;
- else
- sym->symbol.section = bfd_com_section_ptr;
- sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL);
- break;
-
- case SS_UNSAT:
- if (bufp->symbol_type != ST_STORAGE)
- sym->symbol.section = bfd_und_section_ptr;
- else
- sym->symbol.section = bfd_com_section_ptr;
- break;
-
- case SS_UNIVERSAL:
- sym->symbol.flags |= (BSF_EXPORT | BSF_GLOBAL);
- sym->symbol.section = bfd_section_from_som_symbol (abfd, bufp);
- sym->symbol.value -= sym->symbol.section->vma;
- break;
-
-#if 0
- /* SS_GLOBAL and SS_LOCAL are two names for the same thing.
- Sound dumb? It is. */
- case SS_GLOBAL:
-#endif
- case SS_LOCAL:
- sym->symbol.flags |= BSF_LOCAL;
- sym->symbol.section = bfd_section_from_som_symbol (abfd, bufp);
- sym->symbol.value -= sym->symbol.section->vma;
- break;
- }
-
- /* Mark section symbols and symbols used by the debugger.
- Note $START$ is a magic code symbol, NOT a section symbol. */
- if (sym->symbol.name[0] == '$'
- && sym->symbol.name[strlen (sym->symbol.name) - 1] == '$'
- && !strcmp (sym->symbol.name, sym->symbol.section->name))
- sym->symbol.flags |= BSF_SECTION_SYM;
- else if (!strncmp (sym->symbol.name, "L$0\002", 4))
- {
- sym->symbol.flags |= BSF_SECTION_SYM;
- sym->symbol.name = sym->symbol.section->name;
- }
- else if (!strncmp (sym->symbol.name, "L$0\001", 4))
- sym->symbol.flags |= BSF_DEBUGGING;
-
- /* Note increment at bottom of loop, since we skip some symbols
- we can not include it as part of the for statement. */
- sym++;
- }
-
- /* Save our results and return success. */
- obj_som_symtab (abfd) = symbase;
- successful_return:
- if (buf != NULL)
- free (buf);
- return (true);
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Canonicalize a SOM symbol table. Return the number of entries
- in the symbol table. */
-
-static long
-som_get_symtab (abfd, location)
- bfd *abfd;
- asymbol **location;
-{
- int i;
- som_symbol_type *symbase;
-
- if (!som_slurp_symbol_table (abfd))
- return -1;
-
- i = bfd_get_symcount (abfd);
- symbase = obj_som_symtab (abfd);
-
- for (; i > 0; i--, location++, symbase++)
- *location = &symbase->symbol;
-
- /* Final null pointer. */
- *location = 0;
- return (bfd_get_symcount (abfd));
-}
-
-/* Make a SOM symbol. There is nothing special to do here. */
-
-static asymbol *
-som_make_empty_symbol (abfd)
- bfd *abfd;
-{
- som_symbol_type *new =
- (som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type));
- if (new == NULL)
- return 0;
- new->symbol.the_bfd = abfd;
-
- return &new->symbol;
-}
-
-/* Print symbol information. */
-
-static void
-som_print_symbol (ignore_abfd, afile, symbol, how)
- bfd *ignore_abfd;
- PTR afile;
- asymbol *symbol;
- 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:
- fprintf (file, "som ");
- fprintf_vma (file, symbol->value);
- fprintf (file, " %lx", (long) symbol->flags);
- break;
- case bfd_print_symbol_all:
- {
- CONST char *section_name;
- section_name = symbol->section ? symbol->section->name : "(*none*)";
- bfd_print_symbol_vandf ((PTR) file, symbol);
- fprintf (file, " %s\t%s", section_name, symbol->name);
- break;
- }
- }
-}
-
-static boolean
-som_bfd_is_local_label (abfd, sym)
- bfd *abfd;
- asymbol *sym;
-{
- return (sym->name[0] == 'L' && sym->name[1] == '$');
-}
-
-/* Count or process variable-length SOM fixup records.
-
- To avoid code duplication we use this code both to compute the number
- of relocations requested by a stream, and to internalize the stream.
-
- When computing the number of relocations requested by a stream the
- variables rptr, section, and symbols have no meaning.
-
- Return the number of relocations requested by the fixup stream. When
- not just counting
-
- This needs at least two or three more passes to get it cleaned up. */
-
-static unsigned int
-som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count)
- unsigned char *fixup;
- unsigned int end;
- arelent *internal_relocs;
- asection *section;
- asymbol **symbols;
- boolean just_count;
-{
- unsigned int op, varname, deallocate_contents = 0;
- unsigned char *end_fixups = &fixup[end];
- const struct fixup_format *fp;
- char *cp;
- unsigned char *save_fixup;
- int variables[26], stack[20], c, v, count, prev_fixup, *sp, saved_unwind_bits;
- const int *subop;
- arelent *rptr= internal_relocs;
- unsigned int offset = 0;
-
-#define var(c) variables[(c) - 'A']
-#define push(v) (*sp++ = (v))
-#define pop() (*--sp)
-#define emptystack() (sp == stack)
-
- som_initialize_reloc_queue (reloc_queue);
- memset (variables, 0, sizeof (variables));
- memset (stack, 0, sizeof (stack));
- count = 0;
- prev_fixup = 0;
- saved_unwind_bits = 0;
- sp = stack;
-
- while (fixup < end_fixups)
- {
-
- /* Save pointer to the start of this fixup. We'll use
- it later to determine if it is necessary to put this fixup
- on the queue. */
- save_fixup = fixup;
-
- /* Get the fixup code and its associated format. */
- op = *fixup++;
- fp = &som_fixup_formats[op];
-
- /* Handle a request for a previous fixup. */
- if (*fp->format == 'P')
- {
- /* Get pointer to the beginning of the prev fixup, move
- the repeated fixup to the head of the queue. */
- fixup = reloc_queue[fp->D].reloc;
- som_reloc_queue_fix (reloc_queue, fp->D);
- prev_fixup = 1;
-
- /* Get the fixup code and its associated format. */
- op = *fixup++;
- fp = &som_fixup_formats[op];
- }
-
- /* If this fixup will be passed to BFD, set some reasonable defaults. */
- if (! just_count
- && som_hppa_howto_table[op].type != R_NO_RELOCATION
- && som_hppa_howto_table[op].type != R_DATA_OVERRIDE)
- {
- rptr->address = offset;
- rptr->howto = &som_hppa_howto_table[op];
- rptr->addend = 0;
- rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- }
-
- /* Set default input length to 0. Get the opcode class index
- into D. */
- var ('L') = 0;
- var ('D') = fp->D;
- var ('U') = saved_unwind_bits;
-
- /* Get the opcode format. */
- cp = fp->format;
-
- /* Process the format string. Parsing happens in two phases,
- parse RHS, then assign to LHS. Repeat until no more
- characters in the format string. */
- while (*cp)
- {
- /* The variable this pass is going to compute a value for. */
- varname = *cp++;
-
- /* Start processing RHS. Continue until a NULL or '=' is found. */
- do
- {
- c = *cp++;
-
- /* If this is a variable, push it on the stack. */
- if (isupper (c))
- push (var (c));
-
- /* If this is a lower case letter, then it represents
- additional data from the fixup stream to be pushed onto
- the stack. */
- else if (islower (c))
- {
- int bits = (c - 'a') * 8;
- for (v = 0; c > 'a'; --c)
- v = (v << 8) | *fixup++;
- if (varname == 'V')
- v = sign_extend (v, bits);
- push (v);
- }
-
- /* A decimal constant. Push it on the stack. */
- else if (isdigit (c))
- {
- v = c - '0';
- while (isdigit (*cp))
- v = (v * 10) + (*cp++ - '0');
- push (v);
- }
- else
-
- /* An operator. Pop two two values from the stack and
- use them as operands to the given operation. Push
- the result of the operation back on the stack. */
- switch (c)
- {
- case '+':
- v = pop ();
- v += pop ();
- push (v);
- break;
- case '*':
- v = pop ();
- v *= pop ();
- push (v);
- break;
- case '<':
- v = pop ();
- v = pop () << v;
- push (v);
- break;
- default:
- abort ();
- }
- }
- while (*cp && *cp != '=');
-
- /* Move over the equal operator. */
- cp++;
-
- /* Pop the RHS off the stack. */
- c = pop ();
-
- /* Perform the assignment. */
- var (varname) = c;
-
- /* Handle side effects. and special 'O' stack cases. */
- switch (varname)
- {
- /* Consume some bytes from the input space. */
- case 'L':
- offset += c;
- break;
- /* A symbol to use in the relocation. Make a note
- of this if we are not just counting. */
- case 'S':
- if (! just_count)
- rptr->sym_ptr_ptr = &symbols[c];
- break;
- /* Argument relocation bits for a function call. */
- case 'R':
- if (! just_count)
- {
- unsigned int tmp = var ('R');
- rptr->addend = 0;
-
- if ((som_hppa_howto_table[op].type == R_PCREL_CALL
- && R_PCREL_CALL + 10 > op)
- || (som_hppa_howto_table[op].type == R_ABS_CALL
- && R_ABS_CALL + 10 > op))
- {
- /* Simple encoding. */
- if (tmp > 4)
- {
- tmp -= 5;
- rptr->addend |= 1;
- }
- if (tmp == 4)
- rptr->addend |= 1 << 8 | 1 << 6 | 1 << 4 | 1 << 2;
- else if (tmp == 3)
- rptr->addend |= 1 << 8 | 1 << 6 | 1 << 4;
- else if (tmp == 2)
- rptr->addend |= 1 << 8 | 1 << 6;
- else if (tmp == 1)
- rptr->addend |= 1 << 8;
- }
- else
- {
- unsigned int tmp1, tmp2;
-
- /* First part is easy -- low order two bits are
- directly copied, then shifted away. */
- rptr->addend = tmp & 0x3;
- tmp >>= 2;
-
- /* Diving the result by 10 gives us the second
- part. If it is 9, then the first two words
- are a double precision paramater, else it is
- 3 * the first arg bits + the 2nd arg bits. */
- tmp1 = tmp / 10;
- tmp -= tmp1 * 10;
- if (tmp1 == 9)
- rptr->addend += (0xe << 6);
- else
- {
- /* Get the two pieces. */
- tmp2 = tmp1 / 3;
- tmp1 -= tmp2 * 3;
- /* Put them in the addend. */
- rptr->addend += (tmp2 << 8) + (tmp1 << 6);
- }
-
- /* What's left is the third part. It's unpacked
- just like the second. */
- if (tmp == 9)
- rptr->addend += (0xe << 2);
- else
- {
- tmp2 = tmp / 3;
- tmp -= tmp2 * 3;
- rptr->addend += (tmp2 << 4) + (tmp << 2);
- }
- }
- rptr->addend = HPPA_R_ADDEND (rptr->addend, 0);
- }
- break;
- /* Handle the linker expression stack. */
- case 'O':
- switch (op)
- {
- case R_COMP1:
- subop = comp1_opcodes;
- break;
- case R_COMP2:
- subop = comp2_opcodes;
- break;
- case R_COMP3:
- subop = comp3_opcodes;
- break;
- default:
- abort ();
- }
- while (*subop <= (unsigned char) c)
- ++subop;
- --subop;
- break;
- /* The lower 32unwind bits must be persistent. */
- case 'U':
- saved_unwind_bits = var ('U');
- break;
-
- default:
- break;
- }
- }
-
- /* If we used a previous fixup, clean up after it. */
- if (prev_fixup)
- {
- fixup = save_fixup + 1;
- prev_fixup = 0;
- }
- /* Queue it. */
- else if (fixup > save_fixup + 1)
- som_reloc_queue_insert (save_fixup, fixup - save_fixup, reloc_queue);
-
- /* We do not pass R_DATA_OVERRIDE or R_NO_RELOCATION
- fixups to BFD. */
- if (som_hppa_howto_table[op].type != R_DATA_OVERRIDE
- && som_hppa_howto_table[op].type != R_NO_RELOCATION)
- {
- /* Done with a single reloction. Loop back to the top. */
- if (! just_count)
- {
- if (som_hppa_howto_table[op].type == R_ENTRY)
- rptr->addend = var ('T');
- else if (som_hppa_howto_table[op].type == R_EXIT)
- rptr->addend = var ('U');
- else if (som_hppa_howto_table[op].type == R_PCREL_CALL
- || som_hppa_howto_table[op].type == R_ABS_CALL)
- ;
- else if (som_hppa_howto_table[op].type == R_DATA_ONE_SYMBOL)
- {
- unsigned addend = var ('V');
-
- /* Try what was specified in R_DATA_OVERRIDE first
- (if anything). Then the hard way using the
- section contents. */
- rptr->addend = var ('V');
-
- if (rptr->addend == 0 && !section->contents)
- {
- /* Got to read the damn contents first. We don't
- bother saving the contents (yet). Add it one
- day if the need arises. */
- section->contents = bfd_malloc (section->_raw_size);
- if (section->contents == NULL)
- return -1;
-
- deallocate_contents = 1;
- bfd_get_section_contents (section->owner,
- section,
- section->contents,
- 0,
- section->_raw_size);
- }
- else if (rptr->addend == 0)
- rptr->addend = bfd_get_32 (section->owner,
- (section->contents
- + offset - var ('L')));
-
- }
- else
- rptr->addend = var ('V');
- rptr++;
- }
- count++;
- /* Now that we've handled a "full" relocation, reset
- some state. */
- memset (variables, 0, sizeof (variables));
- memset (stack, 0, sizeof (stack));
- }
- }
- if (deallocate_contents)
- free (section->contents);
-
- return count;
-
-#undef var
-#undef push
-#undef pop
-#undef emptystack
-}
-
-/* Read in the relocs (aka fixups in SOM terms) for a section.
-
- som_get_reloc_upper_bound calls this routine with JUST_COUNT
- set to true to indicate it only needs a count of the number
- of actual relocations. */
-
-static boolean
-som_slurp_reloc_table (abfd, section, symbols, just_count)
- bfd *abfd;
- asection *section;
- asymbol **symbols;
- boolean just_count;
-{
- char *external_relocs;
- unsigned int fixup_stream_size;
- arelent *internal_relocs;
- unsigned int num_relocs;
-
- fixup_stream_size = som_section_data (section)->reloc_size;
- /* If there were no relocations, then there is nothing to do. */
- if (section->reloc_count == 0)
- return true;
-
- /* If reloc_count is -1, then the relocation stream has not been
- parsed. We must do so now to know how many relocations exist. */
- if (section->reloc_count == -1)
- {
- external_relocs = (char *) bfd_malloc (fixup_stream_size);
- if (external_relocs == (char *) NULL)
- return false;
- /* Read in the external forms. */
- if (bfd_seek (abfd,
- obj_som_reloc_filepos (abfd) + section->rel_filepos,
- SEEK_SET)
- != 0)
- return false;
- if (bfd_read (external_relocs, 1, fixup_stream_size, abfd)
- != fixup_stream_size)
- return false;
-
- /* Let callers know how many relocations found.
- also save the relocation stream as we will
- need it again. */
- section->reloc_count = som_set_reloc_info (external_relocs,
- fixup_stream_size,
- NULL, NULL, NULL, true);
-
- som_section_data (section)->reloc_stream = external_relocs;
- }
-
- /* If the caller only wanted a count, then return now. */
- if (just_count)
- return true;
-
- num_relocs = section->reloc_count;
- external_relocs = som_section_data (section)->reloc_stream;
- /* Return saved information about the relocations if it is available. */
- if (section->relocation != (arelent *) NULL)
- return true;
-
- internal_relocs = (arelent *)
- bfd_zalloc (abfd, (num_relocs * sizeof (arelent)));
- if (internal_relocs == (arelent *) NULL)
- return false;
-
- /* Process and internalize the relocations. */
- som_set_reloc_info (external_relocs, fixup_stream_size,
- internal_relocs, section, symbols, false);
-
- /* We're done with the external relocations. Free them. */
- free (external_relocs);
-
- /* Save our results and return success. */
- section->relocation = internal_relocs;
- return (true);
-}
-
-/* Return the number of bytes required to store the relocation
- information associated with the given section. */
-
-static long
-som_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- /* If section has relocations, then read in the relocation stream
- and parse it to determine how many relocations exist. */
- if (asect->flags & SEC_RELOC)
- {
- if (! som_slurp_reloc_table (abfd, asect, NULL, true))
- return -1;
- return (asect->reloc_count + 1) * sizeof (arelent *);
- }
- /* There are no relocations. */
- return 0;
-}
-
-/* Convert relocations from SOM (external) form into BFD internal
- form. Return the number of relocations. */
-
-static long
-som_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- arelent *tblptr;
- int count;
-
- if (som_slurp_reloc_table (abfd, section, symbols, false) == false)
- return -1;
-
- count = section->reloc_count;
- tblptr = section->relocation;
-
- while (count--)
- *relptr++ = tblptr++;
-
- *relptr = (arelent *) NULL;
- return section->reloc_count;
-}
-
-extern const bfd_target som_vec;
-
-/* A hook to set up object file dependent section information. */
-
-static boolean
-som_new_section_hook (abfd, newsect)
- bfd *abfd;
- asection *newsect;
-{
- newsect->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
- if (!newsect->used_by_bfd)
- return false;
- newsect->alignment_power = 3;
-
- /* We allow more than three sections internally */
- return true;
-}
-
-/* Copy any private info we understand from the input symbol
- to the output symbol. */
-
-static boolean
-som_bfd_copy_private_symbol_data (ibfd, isymbol, obfd, osymbol)
- bfd *ibfd;
- asymbol *isymbol;
- bfd *obfd;
- asymbol *osymbol;
-{
- struct som_symbol *input_symbol = (struct som_symbol *) isymbol;
- struct som_symbol *output_symbol = (struct som_symbol *) osymbol;
-
- /* One day we may try to grok other private data. */
- if (ibfd->xvec->flavour != bfd_target_som_flavour
- || obfd->xvec->flavour != bfd_target_som_flavour)
- return false;
-
- /* The only private information we need to copy is the argument relocation
- bits. */
- output_symbol->tc_data.hppa_arg_reloc = input_symbol->tc_data.hppa_arg_reloc;
-
- return true;
-}
-
-/* Copy any private info we understand from the input section
- to the output section. */
-static boolean
-som_bfd_copy_private_section_data (ibfd, isection, obfd, osection)
- bfd *ibfd;
- asection *isection;
- bfd *obfd;
- asection *osection;
-{
- /* One day we may try to grok other private data. */
- if (ibfd->xvec->flavour != bfd_target_som_flavour
- || obfd->xvec->flavour != bfd_target_som_flavour
- || (!som_is_space (isection) && !som_is_subspace (isection)))
- return true;
-
- som_section_data (osection)->copy_data
- = (struct som_copyable_section_data_struct *)
- bfd_zalloc (obfd, sizeof (struct som_copyable_section_data_struct));
- if (som_section_data (osection)->copy_data == NULL)
- return false;
-
- memcpy (som_section_data (osection)->copy_data,
- som_section_data (isection)->copy_data,
- sizeof (struct som_copyable_section_data_struct));
-
- /* Reparent if necessary. */
- if (som_section_data (osection)->copy_data->container)
- som_section_data (osection)->copy_data->container =
- som_section_data (osection)->copy_data->container->output_section;
-
- return true;
-}
-
-/* Copy any private info we understand from the input bfd
- to the output bfd. */
-
-static boolean
-som_bfd_copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd, *obfd;
-{
- /* One day we may try to grok other private data. */
- if (ibfd->xvec->flavour != bfd_target_som_flavour
- || obfd->xvec->flavour != bfd_target_som_flavour)
- return true;
-
- /* Allocate some memory to hold the data we need. */
- obj_som_exec_data (obfd) = (struct som_exec_data *)
- bfd_zalloc (obfd, sizeof (struct som_exec_data));
- if (obj_som_exec_data (obfd) == NULL)
- return false;
-
- /* Now copy the data. */
- memcpy (obj_som_exec_data (obfd), obj_som_exec_data (ibfd),
- sizeof (struct som_exec_data));
-
- return true;
-}
-
-/* Set backend info for sections which can not be described
- in the BFD data structures. */
-
-boolean
-bfd_som_set_section_attributes (section, defined, private, sort_key, spnum)
- asection *section;
- int defined;
- int private;
- unsigned int sort_key;
- int spnum;
-{
- /* Allocate memory to hold the magic information. */
- if (som_section_data (section)->copy_data == NULL)
- {
- som_section_data (section)->copy_data
- = (struct som_copyable_section_data_struct *)
- bfd_zalloc (section->owner,
- sizeof (struct som_copyable_section_data_struct));
- if (som_section_data (section)->copy_data == NULL)
- return false;
- }
- som_section_data (section)->copy_data->sort_key = sort_key;
- som_section_data (section)->copy_data->is_defined = defined;
- som_section_data (section)->copy_data->is_private = private;
- som_section_data (section)->copy_data->container = section;
- som_section_data (section)->copy_data->space_number = spnum;
- return true;
-}
-
-/* Set backend info for subsections which can not be described
- in the BFD data structures. */
-
-boolean
-bfd_som_set_subsection_attributes (section, container, access,
- sort_key, quadrant)
- asection *section;
- asection *container;
- int access;
- unsigned int sort_key;
- int quadrant;
-{
- /* Allocate memory to hold the magic information. */
- if (som_section_data (section)->copy_data == NULL)
- {
- som_section_data (section)->copy_data
- = (struct som_copyable_section_data_struct *)
- bfd_zalloc (section->owner,
- sizeof (struct som_copyable_section_data_struct));
- if (som_section_data (section)->copy_data == NULL)
- return false;
- }
- som_section_data (section)->copy_data->sort_key = sort_key;
- som_section_data (section)->copy_data->access_control_bits = access;
- som_section_data (section)->copy_data->quadrant = quadrant;
- som_section_data (section)->copy_data->container = container;
- return true;
-}
-
-/* Set the full SOM symbol type. SOM needs far more symbol information
- than any other object file format I'm aware of. It is mandatory
- to be able to know if a symbol is an entry point, millicode, data,
- code, absolute, storage request, or procedure label. If you get
- the symbol type wrong your program will not link. */
-
-void
-bfd_som_set_symbol_type (symbol, type)
- asymbol *symbol;
- unsigned int type;
-{
- som_symbol_data (symbol)->som_type = type;
-}
-
-/* Attach an auxiliary header to the BFD backend so that it may be
- written into the object file. */
-boolean
-bfd_som_attach_aux_hdr (abfd, type, string)
- bfd *abfd;
- int type;
- char *string;
-{
- if (type == VERSION_AUX_ID)
- {
- int len = strlen (string);
- int pad = 0;
-
- if (len % 4)
- pad = (4 - (len % 4));
- obj_som_version_hdr (abfd) = (struct user_string_aux_hdr *)
- bfd_zalloc (abfd, sizeof (struct aux_id)
- + sizeof (unsigned int) + len + pad);
- if (!obj_som_version_hdr (abfd))
- return false;
- obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
- obj_som_version_hdr (abfd)->header_id.length = len + pad;
- obj_som_version_hdr (abfd)->header_id.length += sizeof (int);
- obj_som_version_hdr (abfd)->string_length = len;
- strncpy (obj_som_version_hdr (abfd)->user_string, string, len);
- }
- else if (type == COPYRIGHT_AUX_ID)
- {
- int len = strlen (string);
- int pad = 0;
-
- if (len % 4)
- pad = (4 - (len % 4));
- obj_som_copyright_hdr (abfd) = (struct copyright_aux_hdr *)
- bfd_zalloc (abfd, sizeof (struct aux_id)
- + sizeof (unsigned int) + len + pad);
- if (!obj_som_copyright_hdr (abfd))
- return false;
- obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
- obj_som_copyright_hdr (abfd)->header_id.length = len + pad;
- obj_som_copyright_hdr (abfd)->header_id.length += sizeof (int);
- obj_som_copyright_hdr (abfd)->string_length = len;
- strcpy (obj_som_copyright_hdr (abfd)->copyright, string);
- }
- return true;
-}
-
-static boolean
-som_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (count == 0 || ((section->flags & SEC_HAS_CONTENTS) == 0))
- return true;
- if ((bfd_size_type)(offset+count) > section->_raw_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);
-}
-
-static boolean
-som_set_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (abfd->output_has_begun == false)
- {
- /* Set up fixed parts of the file, space, and subspace headers.
- Notify the world that output has begun. */
- som_prep_headers (abfd);
- abfd->output_has_begun = true;
- /* Start writing the object file. This include all the string
- tables, fixup streams, and other portions of the object file. */
- som_begin_writing (abfd);
- }
-
- /* Only write subspaces which have "real" contents (eg. the contents
- are not generated at run time by the OS). */
- if (!som_is_subspace (section)
- || ((section->flags & SEC_HAS_CONTENTS) == 0))
- return true;
-
- /* Seek to the proper offset within the object file and write the
- data. */
- offset += som_section_data (section)->subspace_dict->file_loc_init_value;
- if (bfd_seek (abfd, offset, SEEK_SET) == -1)
- return false;
-
- if (bfd_write ((PTR) location, 1, count, abfd) != count)
- return false;
- return true;
-}
-
-static boolean
-som_set_arch_mach (abfd, arch, machine)
- bfd *abfd;
- enum bfd_architecture arch;
- unsigned long machine;
-{
- /* Allow any architecture to be supported by the SOM backend */
- return bfd_default_set_arch_mach (abfd, arch, machine);
-}
-
-static boolean
-som_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
- functionname_ptr, line_ptr)
- bfd *abfd;
- asection *section;
- asymbol **symbols;
- bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
- unsigned int *line_ptr;
-{
- return (false);
-}
-
-static int
-som_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
-{
- (*_bfd_error_handler) ("som_sizeof_headers unimplemented");
- fflush (stderr);
- abort ();
- return (0);
-}
-
-/* Return the single-character symbol type corresponding to
- SOM section S, or '?' for an unknown SOM section. */
-
-static char
-som_section_type (s)
- const char *s;
-{
- const struct section_to_type *t;
-
- for (t = &stt[0]; t->section; t++)
- if (!strcmp (s, t->section))
- return t->type;
- return '?';
-}
-
-static int
-som_decode_symclass (symbol)
- asymbol *symbol;
-{
- char c;
-
- if (bfd_is_com_section (symbol->section))
- return 'C';
- if (bfd_is_und_section (symbol->section))
- return 'U';
- if (bfd_is_ind_section (symbol->section))
- return 'I';
- if (!(symbol->flags & (BSF_GLOBAL|BSF_LOCAL)))
- return '?';
-
- if (bfd_is_abs_section (symbol->section)
- || (som_symbol_data (symbol) != NULL
- && som_symbol_data (symbol)->som_type == SYMBOL_TYPE_ABSOLUTE))
- c = 'a';
- else if (symbol->section)
- c = som_section_type (symbol->section->name);
- else
- return '?';
- if (symbol->flags & BSF_GLOBAL)
- c = toupper (c);
- return c;
-}
-
-/* Return information about SOM symbol SYMBOL in RET. */
-
-static void
-som_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- ret->type = som_decode_symclass (symbol);
- if (ret->type != 'U')
- ret->value = symbol->value+symbol->section->vma;
- else
- ret->value = 0;
- ret->name = symbol->name;
-}
-
-/* Count the number of symbols in the archive symbol table. Necessary
- so that we can allocate space for all the carsyms at once. */
-
-static boolean
-som_bfd_count_ar_symbols (abfd, lst_header, count)
- bfd *abfd;
- struct lst_header *lst_header;
- symindex *count;
-{
- unsigned int i;
- unsigned int *hash_table = NULL;
- file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
-
- hash_table =
- (unsigned int *) bfd_malloc (lst_header->hash_size
- * sizeof (unsigned int));
- if (hash_table == NULL && lst_header->hash_size != 0)
- goto error_return;
-
- /* Don't forget to initialize the counter! */
- *count = 0;
-
- /* Read in the hash table. The has table is an array of 32bit file offsets
- which point to the hash chains. */
- if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
- != lst_header->hash_size * 4)
- goto error_return;
-
- /* Walk each chain counting the number of symbols found on that particular
- chain. */
- for (i = 0; i < lst_header->hash_size; i++)
- {
- struct lst_symbol_record lst_symbol;
-
- /* An empty chain has zero as it's file offset. */
- if (hash_table[i] == 0)
- continue;
-
- /* Seek to the first symbol in this hash chain. */
- if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
- goto error_return;
-
- /* Read in this symbol and update the counter. */
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
- goto error_return;
-
- (*count)++;
-
- /* Now iterate through the rest of the symbols on this chain. */
- while (lst_symbol.next_entry)
- {
-
- /* Seek to the next symbol. */
- if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
- < 0)
- goto error_return;
-
- /* Read the symbol in and update the counter. */
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
- goto error_return;
-
- (*count)++;
- }
- }
- if (hash_table != NULL)
- free (hash_table);
- return true;
-
- error_return:
- if (hash_table != NULL)
- free (hash_table);
- return false;
-}
-
-/* Fill in the canonical archive symbols (SYMS) from the archive described
- by ABFD and LST_HEADER. */
-
-static boolean
-som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
- bfd *abfd;
- struct lst_header *lst_header;
- carsym **syms;
-{
- unsigned int i, len;
- carsym *set = syms[0];
- unsigned int *hash_table = NULL;
- struct som_entry *som_dict = NULL;
- file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
-
- hash_table =
- (unsigned int *) bfd_malloc (lst_header->hash_size
- * sizeof (unsigned int));
- if (hash_table == NULL && lst_header->hash_size != 0)
- goto error_return;
-
- som_dict =
- (struct som_entry *) bfd_malloc (lst_header->module_count
- * sizeof (struct som_entry));
- if (som_dict == NULL && lst_header->module_count != 0)
- goto error_return;
-
- /* Read in the hash table. The has table is an array of 32bit file offsets
- which point to the hash chains. */
- if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
- != lst_header->hash_size * 4)
- goto error_return;
-
- /* Seek to and read in the SOM dictionary. We will need this to fill
- in the carsym's filepos field. */
- if (bfd_seek (abfd, lst_filepos + lst_header->dir_loc, SEEK_SET) < 0)
- goto error_return;
-
- if (bfd_read ((PTR) som_dict, lst_header->module_count,
- sizeof (struct som_entry), abfd)
- != lst_header->module_count * sizeof (struct som_entry))
- goto error_return;
-
- /* Walk each chain filling in the carsyms as we go along. */
- for (i = 0; i < lst_header->hash_size; i++)
- {
- struct lst_symbol_record lst_symbol;
-
- /* An empty chain has zero as it's file offset. */
- if (hash_table[i] == 0)
- continue;
-
- /* Seek to and read the first symbol on the chain. */
- if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
- goto error_return;
-
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
- goto error_return;
-
- /* Get the name of the symbol, first get the length which is stored
- as a 32bit integer just before the symbol.
-
- One might ask why we don't just read in the entire string table
- and index into it. Well, according to the SOM ABI the string
- index can point *anywhere* in the archive to save space, so just
- using the string table would not be safe. */
- if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
- + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
- goto error_return;
-
- if (bfd_read (&len, 1, 4, abfd) != 4)
- goto error_return;
-
- /* Allocate space for the name and null terminate it too. */
- set->name = bfd_zalloc (abfd, len + 1);
- if (!set->name)
- goto error_return;
- if (bfd_read (set->name, 1, len, abfd) != len)
- goto error_return;
-
- set->name[len] = 0;
-
- /* Fill in the file offset. Note that the "location" field points
- to the SOM itself, not the ar_hdr in front of it. */
- set->file_offset = som_dict[lst_symbol.som_index].location
- - sizeof (struct ar_hdr);
-
- /* Go to the next symbol. */
- set++;
-
- /* Iterate through the rest of the chain. */
- while (lst_symbol.next_entry)
- {
- /* Seek to the next symbol and read it in. */
- if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET) <0)
- goto error_return;
-
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
- goto error_return;
-
- /* Seek to the name length & string and read them in. */
- if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
- + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
- goto error_return;
-
- if (bfd_read (&len, 1, 4, abfd) != 4)
- goto error_return;
-
- /* Allocate space for the name and null terminate it too. */
- set->name = bfd_zalloc (abfd, len + 1);
- if (!set->name)
- goto error_return;
-
- if (bfd_read (set->name, 1, len, abfd) != len)
- goto error_return;
- set->name[len] = 0;
-
- /* Fill in the file offset. Note that the "location" field points
- to the SOM itself, not the ar_hdr in front of it. */
- set->file_offset = som_dict[lst_symbol.som_index].location
- - sizeof (struct ar_hdr);
-
- /* Go on to the next symbol. */
- set++;
- }
- }
- /* If we haven't died by now, then we successfully read the entire
- archive symbol table. */
- if (hash_table != NULL)
- free (hash_table);
- if (som_dict != NULL)
- free (som_dict);
- return true;
-
- error_return:
- if (hash_table != NULL)
- free (hash_table);
- if (som_dict != NULL)
- free (som_dict);
- return false;
-}
-
-/* Read in the LST from the archive. */
-static boolean
-som_slurp_armap (abfd)
- bfd *abfd;
-{
- struct lst_header lst_header;
- struct ar_hdr ar_header;
- unsigned int parsed_size;
- struct artdata *ardata = bfd_ardata (abfd);
- char nextname[17];
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
-
- /* Special cases. */
- if (i == 0)
- return true;
- if (i != 16)
- return false;
-
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) < 0)
- return false;
-
- /* For archives without .o files there is no symbol table. */
- if (strncmp (nextname, "/ ", 16))
- {
- bfd_has_map (abfd) = false;
- return true;
- }
-
- /* Read in and sanity check the archive header. */
- if (bfd_read ((PTR) &ar_header, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
- return false;
-
- if (strncmp (ar_header.ar_fmag, ARFMAG, 2))
- {
- bfd_set_error (bfd_error_malformed_archive);
- return false;
- }
-
- /* How big is the archive symbol table entry? */
- errno = 0;
- parsed_size = strtol (ar_header.ar_size, NULL, 10);
- if (errno != 0)
- {
- bfd_set_error (bfd_error_malformed_archive);
- return false;
- }
-
- /* Save off the file offset of the first real user data. */
- ardata->first_file_filepos = bfd_tell (abfd) + parsed_size;
-
- /* Read in the library symbol table. We'll make heavy use of this
- in just a minute. */
- if (bfd_read ((PTR) & lst_header, 1, sizeof (struct lst_header), abfd)
- != sizeof (struct lst_header))
- return false;
-
- /* Sanity check. */
- if (lst_header.a_magic != LIBMAGIC)
- {
- bfd_set_error (bfd_error_malformed_archive);
- return false;
- }
-
- /* Count the number of symbols in the library symbol table. */
- if (som_bfd_count_ar_symbols (abfd, &lst_header, &ardata->symdef_count)
- == false)
- return false;
-
- /* Get back to the start of the library symbol table. */
- if (bfd_seek (abfd, ardata->first_file_filepos - parsed_size
- + sizeof (struct lst_header), SEEK_SET) < 0)
- return false;
-
- /* Initializae the cache and allocate space for the library symbols. */
- ardata->cache = 0;
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * sizeof (carsym)));
- if (!ardata->symdefs)
- return false;
-
- /* Now fill in the canonical archive symbols. */
- if (som_bfd_fill_in_ar_symbols (abfd, &lst_header, &ardata->symdefs)
- == false)
- return false;
-
- /* Seek back to the "first" file in the archive. Note the "first"
- file may be the extended name table. */
- if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) < 0)
- return false;
-
- /* Notify the generic archive code that we have a symbol map. */
- bfd_has_map (abfd) = true;
- return true;
-}
-
-/* Begin preparing to write a SOM library symbol table.
-
- As part of the prep work we need to determine the number of symbols
- and the size of the associated string section. */
-
-static boolean
-som_bfd_prep_for_ar_write (abfd, num_syms, stringsize)
- bfd *abfd;
- unsigned int *num_syms, *stringsize;
-{
- bfd *curr_bfd = abfd->archive_head;
-
- /* Some initialization. */
- *num_syms = 0;
- *stringsize = 0;
-
- /* Iterate over each BFD within this archive. */
- while (curr_bfd != NULL)
- {
- unsigned int curr_count, i;
- som_symbol_type *sym;
-
- /* Don't bother for non-SOM objects. */
- if (curr_bfd->format != bfd_object
- || curr_bfd->xvec->flavour != bfd_target_som_flavour)
- {
- curr_bfd = curr_bfd->next;
- continue;
- }
-
- /* Make sure the symbol table has been read, then snag a pointer
- to it. It's a little slimey to grab the symbols via obj_som_symtab,
- but doing so avoids allocating lots of extra memory. */
- if (som_slurp_symbol_table (curr_bfd) == false)
- return false;
-
- sym = obj_som_symtab (curr_bfd);
- curr_count = bfd_get_symcount (curr_bfd);
-
- /* Examine each symbol to determine if it belongs in the
- library symbol table. */
- for (i = 0; i < curr_count; i++, sym++)
- {
- struct som_misc_symbol_info info;
-
- /* Derive SOM information from the BFD symbol. */
- som_bfd_derive_misc_symbol_info (curr_bfd, &sym->symbol, &info);
-
- /* Should we include this symbol? */
- if (info.symbol_type == ST_NULL
- || info.symbol_type == ST_SYM_EXT
- || info.symbol_type == ST_ARG_EXT)
- continue;
-
- /* Only global symbols and unsatisfied commons. */
- if (info.symbol_scope != SS_UNIVERSAL
- && info.symbol_type != ST_STORAGE)
- continue;
-
- /* Do no include undefined symbols. */
- if (bfd_is_und_section (sym->symbol.section))
- continue;
-
- /* Bump the various counters, being careful to honor
- alignment considerations in the string table. */
- (*num_syms)++;
- *stringsize = *stringsize + strlen (sym->symbol.name) + 5;
- while (*stringsize % 4)
- (*stringsize)++;
- }
-
- curr_bfd = curr_bfd->next;
- }
- return true;
-}
-
-/* Hash a symbol name based on the hashing algorithm presented in the
- SOM ABI. */
-static unsigned int
-som_bfd_ar_symbol_hash (symbol)
- asymbol *symbol;
-{
- unsigned int len = strlen (symbol->name);
-
- /* Names with length 1 are special. */
- if (len == 1)
- return 0x1000100 | (symbol->name[0] << 16) | symbol->name[0];
-
- return ((len & 0x7f) << 24) | (symbol->name[1] << 16)
- | (symbol->name[len-2] << 8) | symbol->name[len-1];
-}
-
-static CONST char *
-normalize (file)
- CONST char *file;
-{
- CONST char *filename = strrchr (file, '/');
-
- if (filename != NULL)
- filename++;
- else
- filename = file;
- return filename;
-}
-
-/* Do the bulk of the work required to write the SOM library
- symbol table. */
-
-static boolean
-som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
- bfd *abfd;
- unsigned int nsyms, string_size;
- struct lst_header lst;
-{
- file_ptr lst_filepos;
- char *strings = NULL, *p;
- struct lst_symbol_record *lst_syms = NULL, *curr_lst_sym;
- bfd *curr_bfd;
- unsigned int *hash_table = NULL;
- struct som_entry *som_dict = NULL;
- struct lst_symbol_record **last_hash_entry = NULL;
- unsigned int curr_som_offset, som_index, extended_name_length = 0;
- unsigned int maxname = abfd->xvec->ar_max_namelen;
-
- hash_table =
- (unsigned int *) bfd_malloc (lst.hash_size * sizeof (unsigned int));
- if (hash_table == NULL && lst.hash_size != 0)
- goto error_return;
- som_dict =
- (struct som_entry *) bfd_malloc (lst.module_count
- * sizeof (struct som_entry));
- if (som_dict == NULL && lst.module_count != 0)
- goto error_return;
-
- last_hash_entry =
- ((struct lst_symbol_record **)
- bfd_malloc (lst.hash_size * sizeof (struct lst_symbol_record *)));
- if (last_hash_entry == NULL && lst.hash_size != 0)
- goto error_return;
-
- /* Lots of fields are file positions relative to the start
- of the lst record. So save its location. */
- lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
-
- /* Some initialization. */
- memset (hash_table, 0, 4 * lst.hash_size);
- memset (som_dict, 0, lst.module_count * sizeof (struct som_entry));
- memset (last_hash_entry, 0,
- lst.hash_size * sizeof (struct lst_symbol_record *));
-
- /* Symbols have som_index fields, so we have to keep track of the
- index of each SOM in the archive.
-
- The SOM dictionary has (among other things) the absolute file
- position for the SOM which a particular dictionary entry
- describes. We have to compute that information as we iterate
- through the SOMs/symbols. */
- som_index = 0;
- curr_som_offset = 8 + 2 * sizeof (struct ar_hdr) + lst.file_end;
-
- /* Yow! We have to know the size of the extended name table
- too. */
- for (curr_bfd = abfd->archive_head;
- curr_bfd != NULL;
- curr_bfd = curr_bfd->next)
- {
- CONST char *normal = normalize (curr_bfd->filename);
- unsigned int thislen;
-
- if (!normal)
- return false;
- thislen = strlen (normal);
- if (thislen > maxname)
- extended_name_length += thislen + 1;
- }
-
- /* Make room for the archive header and the contents of the
- extended string table. */
- if (extended_name_length)
- curr_som_offset += extended_name_length + sizeof (struct ar_hdr);
-
- /* Make sure we're properly aligned. */
- curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
-
- /* FIXME should be done with buffers just like everything else... */
- lst_syms = bfd_malloc (nsyms * sizeof (struct lst_symbol_record));
- if (lst_syms == NULL && nsyms != 0)
- goto error_return;
- strings = bfd_malloc (string_size);
- if (strings == NULL && string_size != 0)
- goto error_return;
-
- p = strings;
- curr_lst_sym = lst_syms;
-
- curr_bfd = abfd->archive_head;
- while (curr_bfd != NULL)
- {
- unsigned int curr_count, i;
- som_symbol_type *sym;
-
- /* Don't bother for non-SOM objects. */
- if (curr_bfd->format != bfd_object
- || curr_bfd->xvec->flavour != bfd_target_som_flavour)
- {
- curr_bfd = curr_bfd->next;
- continue;
- }
-
- /* Make sure the symbol table has been read, then snag a pointer
- to it. It's a little slimey to grab the symbols via obj_som_symtab,
- but doing so avoids allocating lots of extra memory. */
- if (som_slurp_symbol_table (curr_bfd) == false)
- goto error_return;
-
- sym = obj_som_symtab (curr_bfd);
- curr_count = bfd_get_symcount (curr_bfd);
-
- for (i = 0; i < curr_count; i++, sym++)
- {
- struct som_misc_symbol_info info;
-
- /* Derive SOM information from the BFD symbol. */
- som_bfd_derive_misc_symbol_info (curr_bfd, &sym->symbol, &info);
-
- /* Should we include this symbol? */
- if (info.symbol_type == ST_NULL
- || info.symbol_type == ST_SYM_EXT
- || info.symbol_type == ST_ARG_EXT)
- continue;
-
- /* Only global symbols and unsatisfied commons. */
- if (info.symbol_scope != SS_UNIVERSAL
- && info.symbol_type != ST_STORAGE)
- continue;
-
- /* Do no include undefined symbols. */
- if (bfd_is_und_section (sym->symbol.section))
- continue;
-
- /* If this is the first symbol from this SOM, then update
- the SOM dictionary too. */
- if (som_dict[som_index].location == 0)
- {
- som_dict[som_index].location = curr_som_offset;
- som_dict[som_index].length = arelt_size (curr_bfd);
- }
-
- /* Fill in the lst symbol record. */
- curr_lst_sym->hidden = 0;
- curr_lst_sym->secondary_def = 0;
- curr_lst_sym->symbol_type = info.symbol_type;
- curr_lst_sym->symbol_scope = info.symbol_scope;
- curr_lst_sym->check_level = 0;
- curr_lst_sym->must_qualify = 0;
- curr_lst_sym->initially_frozen = 0;
- curr_lst_sym->memory_resident = 0;
- curr_lst_sym->is_common = bfd_is_com_section (sym->symbol.section);
- curr_lst_sym->dup_common = 0;
- curr_lst_sym->xleast = 0;
- curr_lst_sym->arg_reloc = info.arg_reloc;
- curr_lst_sym->name.n_strx = p - strings + 4;
- curr_lst_sym->qualifier_name.n_strx = 0;
- curr_lst_sym->symbol_info = info.symbol_info;
- curr_lst_sym->symbol_value = info.symbol_value;
- curr_lst_sym->symbol_descriptor = 0;
- curr_lst_sym->reserved = 0;
- curr_lst_sym->som_index = som_index;
- curr_lst_sym->symbol_key = som_bfd_ar_symbol_hash (&sym->symbol);
- curr_lst_sym->next_entry = 0;
-
- /* Insert into the hash table. */
- if (hash_table[curr_lst_sym->symbol_key % lst.hash_size])
- {
- struct lst_symbol_record *tmp;
-
- /* There is already something at the head of this hash chain,
- so tack this symbol onto the end of the chain. */
- tmp = last_hash_entry[curr_lst_sym->symbol_key % lst.hash_size];
- tmp->next_entry
- = (curr_lst_sym - lst_syms) * sizeof (struct lst_symbol_record)
- + lst.hash_size * 4
- + lst.module_count * sizeof (struct som_entry)
- + sizeof (struct lst_header);
- }
- else
- {
- /* First entry in this hash chain. */
- hash_table[curr_lst_sym->symbol_key % lst.hash_size]
- = (curr_lst_sym - lst_syms) * sizeof (struct lst_symbol_record)
- + lst.hash_size * 4
- + lst.module_count * sizeof (struct som_entry)
- + sizeof (struct lst_header);
- }
-
- /* Keep track of the last symbol we added to this chain so we can
- easily update its next_entry pointer. */
- last_hash_entry[curr_lst_sym->symbol_key % lst.hash_size]
- = curr_lst_sym;
-
-
- /* Update the string table. */
- bfd_put_32 (abfd, strlen (sym->symbol.name), p);
- p += 4;
- strcpy (p, sym->symbol.name);
- p += strlen (sym->symbol.name) + 1;
- while ((int)p % 4)
- {
- bfd_put_8 (abfd, 0, p);
- p++;
- }
-
- /* Head to the next symbol. */
- curr_lst_sym++;
- }
-
- /* Keep track of where each SOM will finally reside; then look
- at the next BFD. */
- curr_som_offset += arelt_size (curr_bfd) + sizeof (struct ar_hdr);
-
- /* A particular object in the archive may have an odd length; the
- linker requires objects begin on an even boundary. So round
- up the current offset as necessary. */
- curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
- curr_bfd = curr_bfd->next;
- som_index++;
- }
-
- /* Now scribble out the hash table. */
- if (bfd_write ((PTR) hash_table, lst.hash_size, 4, abfd)
- != lst.hash_size * 4)
- goto error_return;
-
- /* Then the SOM dictionary. */
- if (bfd_write ((PTR) som_dict, lst.module_count,
- sizeof (struct som_entry), abfd)
- != lst.module_count * sizeof (struct som_entry))
- goto error_return;
-
- /* The library symbols. */
- if (bfd_write ((PTR) lst_syms, nsyms, sizeof (struct lst_symbol_record), abfd)
- != nsyms * sizeof (struct lst_symbol_record))
- goto error_return;
-
- /* And finally the strings. */
- if (bfd_write ((PTR) strings, string_size, 1, abfd) != string_size)
- goto error_return;
-
- if (hash_table != NULL)
- free (hash_table);
- if (som_dict != NULL)
- free (som_dict);
- if (last_hash_entry != NULL)
- free (last_hash_entry);
- if (lst_syms != NULL)
- free (lst_syms);
- if (strings != NULL)
- free (strings);
- return true;
-
- error_return:
- if (hash_table != NULL)
- free (hash_table);
- if (som_dict != NULL)
- free (som_dict);
- if (last_hash_entry != NULL)
- free (last_hash_entry);
- if (lst_syms != NULL)
- free (lst_syms);
- if (strings != NULL)
- free (strings);
-
- return false;
-}
-
-/* SOM almost uses the SVR4 style extended name support, but not
- quite. */
-
-static boolean
-som_construct_extended_name_table (abfd, tabloc, tablen, name)
- bfd *abfd;
- char **tabloc;
- bfd_size_type *tablen;
- const char **name;
-{
- *name = "//";
- return _bfd_construct_extended_name_table (abfd, false, tabloc, tablen);
-}
-
-/* Write out the LST for the archive.
-
- You'll never believe this is really how armaps are handled in SOM... */
-
-/*ARGSUSED*/
-static boolean
-som_write_armap (abfd, elength, map, orl_count, stridx)
- bfd *abfd;
- unsigned int elength;
- struct orl *map;
- unsigned int orl_count;
- int stridx;
-{
- bfd *curr_bfd;
- struct stat statbuf;
- unsigned int i, lst_size, nsyms, stringsize;
- struct ar_hdr hdr;
- struct lst_header lst;
- int *p;
-
- /* We'll use this for the archive's date and mode later. */
- if (stat (abfd->filename, &statbuf) != 0)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
- /* Fudge factor. */
- bfd_ardata (abfd)->armap_timestamp = statbuf.st_mtime + 60;
-
- /* Account for the lst header first. */
- lst_size = sizeof (struct lst_header);
-
- /* Start building the LST header. */
- /* FIXME: Do we need to examine each element to determine the
- largest id number? */
- lst.system_id = CPU_PA_RISC1_0;
- lst.a_magic = LIBMAGIC;
- lst.version_id = VERSION_ID;
- lst.file_time.secs = 0;
- lst.file_time.nanosecs = 0;
-
- lst.hash_loc = lst_size;
- lst.hash_size = SOM_LST_HASH_SIZE;
-
- /* Hash table is a SOM_LST_HASH_SIZE 32bit offsets. */
- lst_size += 4 * SOM_LST_HASH_SIZE;
-
- /* We need to count the number of SOMs in this archive. */
- curr_bfd = abfd->archive_head;
- lst.module_count = 0;
- while (curr_bfd != NULL)
- {
- /* Only true SOM objects count. */
- if (curr_bfd->format == bfd_object
- && curr_bfd->xvec->flavour == bfd_target_som_flavour)
- lst.module_count++;
- curr_bfd = curr_bfd->next;
- }
- lst.module_limit = lst.module_count;
- lst.dir_loc = lst_size;
- lst_size += sizeof (struct som_entry) * lst.module_count;
-
- /* We don't support import/export tables, auxiliary headers,
- or free lists yet. Make the linker work a little harder
- to make our life easier. */
-
- lst.export_loc = 0;
- lst.export_count = 0;
- lst.import_loc = 0;
- lst.aux_loc = 0;
- lst.aux_size = 0;
-
- /* Count how many symbols we will have on the hash chains and the
- size of the associated string table. */
- if (som_bfd_prep_for_ar_write (abfd, &nsyms, &stringsize) == false)
- return false;
-
- lst_size += sizeof (struct lst_symbol_record) * nsyms;
-
- /* For the string table. One day we might actually use this info
- to avoid small seeks/reads when reading archives. */
- lst.string_loc = lst_size;
- lst.string_size = stringsize;
- lst_size += stringsize;
-
- /* SOM ABI says this must be zero. */
- lst.free_list = 0;
- lst.file_end = lst_size;
-
- /* Compute the checksum. Must happen after the entire lst header
- has filled in. */
- p = (int *)&lst;
- lst.checksum = 0;
- for (i = 0; i < sizeof (struct lst_header)/sizeof (int) - 1; i++)
- lst.checksum ^= *p++;
-
- sprintf (hdr.ar_name, "/ ");
- sprintf (hdr.ar_date, "%ld", bfd_ardata (abfd)->armap_timestamp);
- sprintf (hdr.ar_uid, "%ld", (long) getuid ());
- sprintf (hdr.ar_gid, "%ld", (long) getgid ());
- sprintf (hdr.ar_mode, "%-8o", (unsigned int) statbuf.st_mode);
- sprintf (hdr.ar_size, "%-10d", (int) lst_size);
- hdr.ar_fmag[0] = '`';
- hdr.ar_fmag[1] = '\012';
-
- /* Turn any nulls into spaces. */
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *) (&hdr))[i] == '\0')
- (((char *) (&hdr))[i]) = ' ';
-
- /* Scribble out the ar header. */
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
- return false;
-
- /* Now scribble out the lst header. */
- if (bfd_write ((PTR) &lst, 1, sizeof (struct lst_header), abfd)
- != sizeof (struct lst_header))
- return false;
-
- /* Build and write the armap. */
- if (som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst) == false)
- return false;
-
- /* Done. */
- return true;
-}
-
-/* Free all information we have cached for this BFD. We can always
- read it again later if we need it. */
-
-static boolean
-som_bfd_free_cached_info (abfd)
- bfd *abfd;
-{
- asection *o;
-
- if (bfd_get_format (abfd) != bfd_object)
- return true;
-
-#define FREE(x) if (x != NULL) { free (x); x = NULL; }
- /* Free the native string and symbol tables. */
- FREE (obj_som_symtab (abfd));
- FREE (obj_som_stringtab (abfd));
- for (o = abfd->sections; o != (asection *) NULL; o = o->next)
- {
- /* Free the native relocations. */
- o->reloc_count = -1;
- FREE (som_section_data (o)->reloc_stream);
- /* Free the generic relocations. */
- FREE (o->relocation);
- }
-#undef FREE
-
- return true;
-}
-
-/* End of miscellaneous support functions. */
-
-/* Linker support functions. */
-static boolean
-som_bfd_link_split_section (abfd, sec)
- bfd *abfd;
- asection *sec;
-{
- return (som_is_subspace (sec) && sec->_raw_size > 240000);
-}
-
-#define som_close_and_cleanup som_bfd_free_cached_info
-
-#define som_read_ar_hdr _bfd_generic_read_ar_hdr
-#define som_openr_next_archived_file bfd_generic_openr_next_archived_file
-#define som_get_elt_at_index _bfd_generic_get_elt_at_index
-#define som_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define som_truncate_arname bfd_bsd_truncate_arname
-#define som_slurp_extended_name_table _bfd_slurp_extended_name_table
-#define som_update_armap_timestamp bfd_true
-#define som_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
-
-#define som_get_lineno _bfd_nosymbols_get_lineno
-#define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define som_read_minisymbols _bfd_generic_read_minisymbols
-#define som_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-#define som_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-#define som_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define som_bfd_relax_section bfd_generic_relax_section
-#define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define som_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define som_bfd_final_link _bfd_generic_final_link
-
-
-const bfd_target som_vec =
-{
- "som", /* name */
- bfd_target_som_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIAN_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | DYNAMIC),
- (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
- | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-
-/* leading_symbol_char: is the first char of a user symbol
- predictable, and if so what is it */
- 0,
- '/', /* ar_pad_char */
- 14, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
- {_bfd_dummy_target,
- som_object_p, /* bfd_check_format */
- bfd_generic_archive_p,
- _bfd_dummy_target
- },
- {
- bfd_false,
- som_mkobject,
- _bfd_generic_mkarchive,
- bfd_false
- },
- {
- bfd_false,
- som_write_object_contents,
- _bfd_write_archive_contents,
- bfd_false,
- },
-#undef som
-
- BFD_JUMP_TABLE_GENERIC (som),
- BFD_JUMP_TABLE_COPY (som),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (som),
- BFD_JUMP_TABLE_SYMBOLS (som),
- BFD_JUMP_TABLE_RELOCS (som),
- BFD_JUMP_TABLE_WRITE (som),
- BFD_JUMP_TABLE_LINK (som),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
-
-#endif /* HOST_HPPAHPUX || HOST_HPPABSD || HOST_HPPAOSF */
diff --git a/contrib/gdb/bfd/som.h b/contrib/gdb/bfd/som.h
deleted file mode 100644
index 6290e88..0000000
--- a/contrib/gdb/bfd/som.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/* HP PA-RISC SOM object file format: definitions internal to BFD.
- Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
-
- Contributed by the Center for Software Science at the
- University of Utah (pa-gdb-bugs@cs.utah.edu).
-
- This file is part of BFD, the Binary File Descriptor library.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _SOM_H
-#define _SOM_H
-
-#include "../bfd/sysdep.h"
-#include "libhppa.h"
-
-#include <a.out.h>
-#include <lst.h>
-#include <ar.h>
-
-/* The SOM BFD backend doesn't currently use anything from these
- two include files, but it's likely to need them in the future. */
-#ifdef R_DLT_REL
-#include <shl.h>
-#include <dl.h>
-#endif
-
-#if defined(HOST_HPPABSD) || defined (HOST_HPPAOSF)
-/* BSD uses a completely different scheme for object file identification.
- so for now, define _PA_RISC_ID to accept any random value for a model
- number. */
-#undef _PA_RISC_ID
-#define _PA_RISC_ID(__m_num) 1
-#endif /* HOST_HPPABSD */
-
-#define FILE_HDR_SIZE sizeof(struct header)
-#define AUX_HDR_SIZE sizeof(struct som_exec_auxhdr)
-
-typedef struct som_symbol
- {
- asymbol symbol;
- unsigned int som_type;
-
- /* Structured like the ELF tc_data union. Allows more code sharing
- in GAS this way. */
- union
- {
- unsigned int hppa_arg_reloc;
- PTR any;
- }
- tc_data;
-
- /* Index of this symbol in the symbol table. Only used when
- building relocation streams for incomplete objects. */
- int index;
-
- /* How many times this symbol is used in a relocation. By sorting
- the symbols from most used to least used we can significantly
- reduce the size of the relocation stream for incomplete objects. */
- int reloc_count;
-
- /* During object file writing, the offset of the name of this symbol
- in the SOM string table. */
- int stringtab_offset;
- }
-som_symbol_type;
-
-/* A structure containing all the magic information stored in a BFD's
- private data which needs to be copied during an objcopy/strip run. */
-struct som_exec_data
- {
- /* Sort-of a magic number. BSD uses it to distinguish between
- native executables and hpux executables. */
- short system_id;
-
- /* Magic exec flags. These control things like whether or not
- null pointer dereferencing is allowed and the like. */
- long exec_flags;
-
- /* Add more stuff here as needed. Good examples of information
- we might want to pass would be presumed_dp, entry_* and maybe
- others from the file header. */
- };
-
-struct somdata
- {
- /* All the magic information about an executable which lives
- in the private BFD structure and needs to be copied from
- the input bfd to the output bfd during a objcopy/strip. */
- struct som_exec_data *exec_data;
-
- /* These three fields are only used when writing files and are
- generated from scratch. They need not be copied for objcopy
- or strip to work. */
- struct header *file_hdr;
- struct copyright_aux_hdr *copyright_aux_hdr;
- struct user_string_aux_hdr *version_aux_hdr;
- struct som_exec_auxhdr *exec_hdr;
-
- /* Pointers to a saved copy of the symbol and string tables. These
- need not be copied for objcopy or strip to work. */
- som_symbol_type *symtab;
- char *stringtab;
- asymbol **sorted_syms;
-
- /* We remember these offsets so that after check_file_format, we have
- no dependencies on the particular format of the exec_hdr.
- These offsets need not be copied for objcopy or strip to work. */
-
- file_ptr sym_filepos;
- file_ptr str_filepos;
- file_ptr reloc_filepos;
- unsigned stringtab_size;
- };
-
-struct som_data_struct
- {
- struct somdata a;
- };
-
-/* Substructure of som_section_data_struct used to hold information
- which can't be represented by the generic BFD section structure,
- but which must be copied during objcopy or strip. */
-struct som_copyable_section_data_struct
- {
- /* Various fields in space and subspace headers that we need
- to pass around. */
- unsigned int sort_key : 8;
- unsigned int access_control_bits : 7;
- unsigned int is_defined : 1;
- unsigned int is_private : 1;
- unsigned int quadrant : 2;
-
- /* For subspaces, this points to the section which represents the
- space in which the subspace is contained. For spaces it points
- back to the section for this space. */
- asection *container;
-
- /* The user-specified space number. It is wrong to use this as
- an index since duplicates and holes are allowed. */
- int space_number;
-
- /* Add more stuff here as needed. Good examples of information
- we might want to pass would be initialization pointers,
- and the many subspace flags we do not represent yet. */
- };
-
-/* Used to keep extra SOM specific information for a given section.
-
- reloc_size holds the size of the relocation stream, note this
- is very different from the number of relocations as SOM relocations
- are variable length.
-
- reloc_stream is the actual stream of relocation entries. */
-
-struct som_section_data_struct
- {
- struct som_copyable_section_data_struct *copy_data;
- unsigned int reloc_size;
- char *reloc_stream;
- struct space_dictionary_record *space_dict;
- struct subspace_dictionary_record *subspace_dict;
- };
-
-#define somdata(bfd) ((bfd)->tdata.som_data->a)
-#define obj_som_exec_data(bfd) (somdata(bfd).exec_data)
-#define obj_som_file_hdr(bfd) (somdata(bfd).file_hdr)
-#define obj_som_exec_hdr(bfd) (somdata(bfd).exec_hdr)
-#define obj_som_copyright_hdr(bfd) (somdata(bfd).copyright_aux_hdr)
-#define obj_som_version_hdr(bfd) (somdata(bfd).version_aux_hdr)
-#define obj_som_symtab(bfd) (somdata(bfd).symtab)
-#define obj_som_stringtab(bfd) (somdata(bfd).stringtab)
-#define obj_som_sym_filepos(bfd) (somdata(bfd).sym_filepos)
-#define obj_som_str_filepos(bfd) (somdata(bfd).str_filepos)
-#define obj_som_stringtab_size(bfd) (somdata(bfd).stringtab_size)
-#define obj_som_reloc_filepos(bfd) (somdata(bfd).reloc_filepos)
-#define obj_som_sorted_syms(bfd) (somdata(bfd).sorted_syms)
-#define som_section_data(sec) \
- ((struct som_section_data_struct *)sec->used_by_bfd)
-#define som_symbol_data(symbol) ((som_symbol_type *) symbol)
-
-
-/* Defines groups of basic relocations. FIXME: These should
- be the only basic relocations created by GAS. The rest
- should be internal to the BFD backend.
-
- The idea is both SOM and ELF define these basic relocation
- types so they map into a SOM or ELF specific reloation as
- appropriate. This allows GAS to share much more code
- between the two object formats. */
-
-#define R_HPPA_NONE R_NO_RELOCATION
-#define R_HPPA R_CODE_ONE_SYMBOL
-#define R_HPPA_PCREL_CALL R_PCREL_CALL
-#define R_HPPA_ABS_CALL R_ABS_CALL
-#define R_HPPA_GOTOFF R_DP_RELATIVE
-#define R_HPPA_ENTRY R_ENTRY
-#define R_HPPA_EXIT R_EXIT
-#define R_HPPA_COMPLEX R_COMP1
-#define R_HPPA_BEGIN_BRTAB R_BEGIN_BRTAB
-#define R_HPPA_END_BRTAB R_END_BRTAB
-
-/* Exported functions, mostly for use by GAS. */
-boolean bfd_som_set_section_attributes PARAMS ((asection *, int, int,
- unsigned int, int));
-boolean bfd_som_set_subsection_attributes PARAMS ((asection *, asection *,
- int, unsigned int, int));
-void bfd_som_set_symbol_type PARAMS ((asymbol *, unsigned int));
-boolean bfd_som_attach_aux_hdr PARAMS ((bfd *, int, char *));
-int ** hppa_som_gen_reloc_type
- PARAMS ((bfd *, int, int, enum hppa_reloc_field_selector_type_alt, int));
-#endif /* _SOM_H */
diff --git a/contrib/gdb/bfd/sparclynx.c b/contrib/gdb/bfd/sparclynx.c
deleted file mode 100644
index 0885620..0000000
--- a/contrib/gdb/bfd/sparclynx.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/* BFD support for Sparc binaries under LynxOS.
- Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#if 0
-#define BYTES_IN_WORD 4
-#define N_SHARED_LIB(x) 0
-
-#define TEXT_START_ADDR 0
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE TARGET_PAGE_SIZE
-#define DEFAULT_ARCH bfd_arch_sparc
-
-#endif
-
-#define MY(OP) CAT(sparclynx_aout_,OP)
-#define TARGETNAME "a.out-sparc-lynx"
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-
-#include "aout/sun4.h"
-#include "libaout.h" /* BFD a.out internal data structures */
-
-#include "aout/aout64.h"
-#include "aout/stab_gnu.h"
-#include "aout/ar.h"
-
-/* This is needed to reject a NewsOS file, e.g. in
- gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
- I needed to add M_UNKNOWN to recognize a 68000 object, so this will
- probably no longer reject a NewsOS object. <ian@cygnus.com>. */
-#define MACHTYPE_OK(mtype) ((mtype) == M_UNKNOWN \
- || (mtype) == M_68010 \
- || (mtype) == M_68020 \
- || (mtype) == M_SPARC)
-
-/*
-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{BFD_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
-
-*/
-
-/*SUPPRESS558*/
-/*SUPPRESS529*/
-
-void
-NAME(lynx,set_arch_mach) (abfd, machtype)
- bfd *abfd;
- int machtype;
-{
- /* Determine the architecture and machine type of the object file. */
- enum bfd_architecture arch;
- long machine;
- switch (machtype)
- {
-
- case M_UNKNOWN:
- /* Some Sun3s make magic numbers without cpu types in them, so
- we'll default to the 68000. */
- arch = bfd_arch_m68k;
- machine = 68000;
- 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:
- case M_386_DYNIX:
- 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);
-}
-
-#define SET_ARCH_MACH(ABFD, EXEC) \
- NAME(lynx,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \
- choose_reloc_size(ABFD);
-
-/* Determine the size of a relocation entry, based on the architecture */
-static void
-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;
- }
-}
-
-/* Write an object file in LynxOS format.
- Section contents have already been written. We write the
- file header, symbols, and relocation. */
-
-static boolean
-NAME(aout,sparclynx_write_object_contents) (abfd)
- bfd *abfd;
-{
- struct external_exec exec_bytes;
- struct internal_exec *execp = exec_hdr (abfd);
-
- /* 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);
-
- N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
-
- WRITE_HEADERS (abfd, execp);
-
- return true;
-}
-
-#define MY_set_sizes sparclynx_set_sizes
-static boolean
-sparclynx_set_sizes (abfd)
- bfd *abfd;
-{
- switch (bfd_get_arch (abfd))
- {
- default:
- return false;
- case bfd_arch_sparc:
- adata (abfd).page_size = 0x2000;
- adata (abfd).segment_size = 0x2000;
- adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
- return true;
- case bfd_arch_m68k:
- adata (abfd).page_size = 0x2000;
- adata (abfd).segment_size = 0x20000;
- adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
- return true;
- }
-}
-
-static CONST struct aout_backend_data sparclynx_aout_backend =
-{
- 0, 1, 1, 0, sparclynx_set_sizes, 0,
- 0, /* add_dynamic_symbols */
- 0, /* add_one_symbol */
- 0, /* link_dynamic_object */
- 0, /* write_dynamic_symbol */
- 0, /* check_dynamic_reloc */
- 0 /* finish_dynamic_link */
-};
-
-
-#define MY_bfd_debug_info_start bfd_void
-#define MY_bfd_debug_info_end bfd_void
-#define MY_bfd_debug_info_accumulate \
- (void (*) PARAMS ((bfd *, struct sec *))) bfd_void
-
-#define MY_write_object_contents NAME(aout,sparclynx_write_object_contents)
-#define MY_backend_data &sparclynx_aout_backend
-
-#define TARGET_IS_BIG_ENDIAN_P
-
-#ifdef LYNX_CORE
-
-char *lynx_core_file_failing_command ();
-int lynx_core_file_failing_signal ();
-boolean lynx_core_file_matches_executable_p ();
-const bfd_target *lynx_core_file_p ();
-
-#define MY_core_file_failing_command lynx_core_file_failing_command
-#define MY_core_file_failing_signal lynx_core_file_failing_signal
-#define MY_core_file_matches_executable_p lynx_core_file_matches_executable_p
-#define MY_core_file_p lynx_core_file_p
-
-#endif /* LYNX_CORE */
-
-#include "aout-target.h"
diff --git a/contrib/gdb/bfd/sparcnetbsd.c b/contrib/gdb/bfd/sparcnetbsd.c
deleted file mode 100644
index 69240f5..0000000
--- a/contrib/gdb/bfd/sparcnetbsd.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* BFD back-end for NetBSD/sparc a.out-ish binaries.
- Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define BYTES_IN_WORD 4
-#define TARGET_IS_BIG_ENDIAN_P
-
-#define TARGET_PAGE_SIZE 4096
-#define SEGMENT_SIZE 4096
-
-#define DEFAULT_ARCH bfd_arch_sparc
-#define MACHTYPE_OK(mtype) ((mtype) == M_SPARC_NETBSD || (mtype) == M_UNKNOWN)
-
-#define MY(OP) CAT(sparcnetbsd_,OP)
-/* This needs to start with a.out so GDB knows it is an a.out variant. */
-#define TARGETNAME "a.out-sparc-netbsd"
-
-#include "netbsd.h"
diff --git a/contrib/gdb/bfd/sunos.c b/contrib/gdb/bfd/sunos.c
deleted file mode 100644
index 77bf319..0000000
--- a/contrib/gdb/bfd/sunos.c
+++ /dev/null
@@ -1,2767 +0,0 @@
-/* BFD backend for SunOS binaries.
- Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
- Written by Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#define TARGETNAME "a.out-sunos-big"
-#define MY(OP) CAT(sunos_big_,OP)
-
-#include "bfd.h"
-#include "bfdlink.h"
-#include "libaout.h"
-
-/* Static routines defined in this file. */
-
-static boolean sunos_read_dynamic_info PARAMS ((bfd *));
-static long sunos_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
-static boolean sunos_slurp_dynamic_symtab PARAMS ((bfd *));
-static long sunos_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
-static long sunos_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
-static long sunos_canonicalize_dynamic_reloc
- PARAMS ((bfd *, arelent **, asymbol **));
-static struct bfd_hash_entry *sunos_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *sunos_link_hash_table_create
- PARAMS ((bfd *));
-static boolean sunos_create_dynamic_sections
- PARAMS ((bfd *, struct bfd_link_info *, boolean));
-static boolean sunos_add_dynamic_symbols
- PARAMS ((bfd *, struct bfd_link_info *, struct external_nlist **,
- bfd_size_type *, char **));
-static boolean sunos_add_one_symbol
- PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
- bfd_vma, const char *, boolean, boolean,
- struct bfd_link_hash_entry **));
-static boolean sunos_scan_relocs
- PARAMS ((struct bfd_link_info *, bfd *, asection *, bfd_size_type));
-static boolean sunos_scan_std_relocs
- PARAMS ((struct bfd_link_info *, bfd *, asection *,
- const struct reloc_std_external *, bfd_size_type));
-static boolean sunos_scan_ext_relocs
- PARAMS ((struct bfd_link_info *, bfd *, asection *,
- const struct reloc_ext_external *, bfd_size_type));
-static boolean sunos_link_dynamic_object
- PARAMS ((struct bfd_link_info *, bfd *));
-static boolean sunos_write_dynamic_symbol
- PARAMS ((bfd *, struct bfd_link_info *, struct aout_link_hash_entry *));
-static boolean sunos_check_dynamic_reloc
- PARAMS ((struct bfd_link_info *, bfd *, asection *,
- struct aout_link_hash_entry *, PTR, bfd_byte *, boolean *,
- bfd_vma *));
-static boolean sunos_finish_dynamic_link
- PARAMS ((bfd *, struct bfd_link_info *));
-
-#define MY_get_dynamic_symtab_upper_bound sunos_get_dynamic_symtab_upper_bound
-#define MY_canonicalize_dynamic_symtab sunos_canonicalize_dynamic_symtab
-#define MY_get_dynamic_reloc_upper_bound sunos_get_dynamic_reloc_upper_bound
-#define MY_canonicalize_dynamic_reloc sunos_canonicalize_dynamic_reloc
-#define MY_bfd_link_hash_table_create sunos_link_hash_table_create
-#define MY_add_dynamic_symbols sunos_add_dynamic_symbols
-#define MY_add_one_symbol sunos_add_one_symbol
-#define MY_link_dynamic_object sunos_link_dynamic_object
-#define MY_write_dynamic_symbol sunos_write_dynamic_symbol
-#define MY_check_dynamic_reloc sunos_check_dynamic_reloc
-#define MY_finish_dynamic_link sunos_finish_dynamic_link
-
-/* Include the usual a.out support. */
-#include "aoutf1.h"
-
-/* SunOS shared library support. We store a pointer to this structure
- in obj_aout_dynamic_info (abfd). */
-
-struct sunos_dynamic_info
-{
- /* Whether we found any dynamic information. */
- boolean valid;
- /* Dynamic information. */
- struct internal_sun4_dynamic_link dyninfo;
- /* Number of dynamic symbols. */
- unsigned long dynsym_count;
- /* Read in nlists for dynamic symbols. */
- struct external_nlist *dynsym;
- /* asymbol structures for dynamic symbols. */
- aout_symbol_type *canonical_dynsym;
- /* Read in dynamic string table. */
- char *dynstr;
- /* Number of dynamic relocs. */
- unsigned long dynrel_count;
- /* Read in dynamic relocs. This may be reloc_std_external or
- reloc_ext_external. */
- PTR dynrel;
- /* arelent structures for dynamic relocs. */
- arelent *canonical_dynrel;
-};
-
-/* The hash table of dynamic symbols is composed of two word entries.
- See include/aout/sun4.h for details. */
-
-#define HASH_ENTRY_SIZE (2 * BYTES_IN_WORD)
-
-/* Read in the basic dynamic information. This locates the __DYNAMIC
- structure and uses it to find the dynamic_link structure. It
- creates and saves a sunos_dynamic_info structure. If it can't find
- __DYNAMIC, it sets the valid field of the sunos_dynamic_info
- structure to false to avoid doing this work again. */
-
-static boolean
-sunos_read_dynamic_info (abfd)
- bfd *abfd;
-{
- struct sunos_dynamic_info *info;
- asection *dynsec;
- bfd_vma dynoff;
- struct external_sun4_dynamic dyninfo;
- unsigned long dynver;
- struct external_sun4_dynamic_link linkinfo;
-
- if (obj_aout_dynamic_info (abfd) != (PTR) NULL)
- return true;
-
- if ((abfd->flags & DYNAMIC) == 0)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- info = ((struct sunos_dynamic_info *)
- bfd_zalloc (abfd, sizeof (struct sunos_dynamic_info)));
- if (!info)
- return false;
- info->valid = false;
- info->dynsym = NULL;
- info->dynstr = NULL;
- info->canonical_dynsym = NULL;
- info->dynrel = NULL;
- info->canonical_dynrel = NULL;
- obj_aout_dynamic_info (abfd) = (PTR) info;
-
- /* This code used to look for the __DYNAMIC symbol to locate the dynamic
- linking information.
- However this inhibits recovering the dynamic symbols from a
- stripped object file, so blindly assume that the dynamic linking
- information is located at the start of the data section.
- We could verify this assumption later by looking through the dynamic
- symbols for the __DYNAMIC symbol. */
- if ((abfd->flags & DYNAMIC) == 0)
- return true;
- if (! bfd_get_section_contents (abfd, obj_datasec (abfd), (PTR) &dyninfo,
- (file_ptr) 0, sizeof dyninfo))
- return true;
-
- dynver = GET_WORD (abfd, dyninfo.ld_version);
- if (dynver != 2 && dynver != 3)
- return true;
-
- dynoff = GET_WORD (abfd, dyninfo.ld);
-
- /* dynoff is a virtual address. It is probably always in the .data
- section, but this code should work even if it moves. */
- if (dynoff < bfd_get_section_vma (abfd, obj_datasec (abfd)))
- dynsec = obj_textsec (abfd);
- else
- dynsec = obj_datasec (abfd);
- dynoff -= bfd_get_section_vma (abfd, dynsec);
- if (dynoff > bfd_section_size (abfd, dynsec))
- return true;
-
- /* This executable appears to be dynamically linked in a way that we
- can understand. */
- if (! bfd_get_section_contents (abfd, dynsec, (PTR) &linkinfo, dynoff,
- (bfd_size_type) sizeof linkinfo))
- return true;
-
- /* Swap in the dynamic link information. */
- info->dyninfo.ld_loaded = GET_WORD (abfd, linkinfo.ld_loaded);
- info->dyninfo.ld_need = GET_WORD (abfd, linkinfo.ld_need);
- info->dyninfo.ld_rules = GET_WORD (abfd, linkinfo.ld_rules);
- info->dyninfo.ld_got = GET_WORD (abfd, linkinfo.ld_got);
- info->dyninfo.ld_plt = GET_WORD (abfd, linkinfo.ld_plt);
- info->dyninfo.ld_rel = GET_WORD (abfd, linkinfo.ld_rel);
- info->dyninfo.ld_hash = GET_WORD (abfd, linkinfo.ld_hash);
- info->dyninfo.ld_stab = GET_WORD (abfd, linkinfo.ld_stab);
- info->dyninfo.ld_stab_hash = GET_WORD (abfd, linkinfo.ld_stab_hash);
- info->dyninfo.ld_buckets = GET_WORD (abfd, linkinfo.ld_buckets);
- info->dyninfo.ld_symbols = GET_WORD (abfd, linkinfo.ld_symbols);
- info->dyninfo.ld_symb_size = GET_WORD (abfd, linkinfo.ld_symb_size);
- info->dyninfo.ld_text = GET_WORD (abfd, linkinfo.ld_text);
- info->dyninfo.ld_plt_sz = GET_WORD (abfd, linkinfo.ld_plt_sz);
-
- /* Reportedly the addresses need to be offset by the size of the
- exec header in an NMAGIC file. */
- if (adata (abfd).magic == n_magic)
- {
- unsigned long exec_bytes_size = adata (abfd).exec_bytes_size;
-
- info->dyninfo.ld_need += exec_bytes_size;
- info->dyninfo.ld_rules += exec_bytes_size;
- info->dyninfo.ld_rel += exec_bytes_size;
- info->dyninfo.ld_hash += exec_bytes_size;
- info->dyninfo.ld_stab += exec_bytes_size;
- info->dyninfo.ld_symbols += exec_bytes_size;
- }
-
- /* The only way to get the size of the symbol information appears to
- be to determine the distance between it and the string table. */
- info->dynsym_count = ((info->dyninfo.ld_symbols - info->dyninfo.ld_stab)
- / EXTERNAL_NLIST_SIZE);
- BFD_ASSERT (info->dynsym_count * EXTERNAL_NLIST_SIZE
- == (unsigned long) (info->dyninfo.ld_symbols
- - info->dyninfo.ld_stab));
-
- /* Similarly, the relocs end at the hash table. */
- info->dynrel_count = ((info->dyninfo.ld_hash - info->dyninfo.ld_rel)
- / obj_reloc_entry_size (abfd));
- BFD_ASSERT (info->dynrel_count * obj_reloc_entry_size (abfd)
- == (unsigned long) (info->dyninfo.ld_hash
- - info->dyninfo.ld_rel));
-
- info->valid = true;
-
- return true;
-}
-
-/* Return the amount of memory required for the dynamic symbols. */
-
-static long
-sunos_get_dynamic_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- struct sunos_dynamic_info *info;
-
- if (! sunos_read_dynamic_info (abfd))
- return -1;
-
- info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
- if (! info->valid)
- {
- bfd_set_error (bfd_error_no_symbols);
- return -1;
- }
-
- return (info->dynsym_count + 1) * sizeof (asymbol *);
-}
-
-/* Read the external dynamic symbols. */
-
-static boolean
-sunos_slurp_dynamic_symtab (abfd)
- bfd *abfd;
-{
- struct sunos_dynamic_info *info;
-
- /* Get the general dynamic information. */
- if (obj_aout_dynamic_info (abfd) == NULL)
- {
- if (! sunos_read_dynamic_info (abfd))
- return false;
- }
-
- info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
- if (! info->valid)
- {
- bfd_set_error (bfd_error_no_symbols);
- return false;
- }
-
- /* Get the dynamic nlist structures. */
- if (info->dynsym == (struct external_nlist *) NULL)
- {
- info->dynsym = ((struct external_nlist *)
- bfd_alloc (abfd,
- (info->dynsym_count
- * EXTERNAL_NLIST_SIZE)));
- if (info->dynsym == NULL && info->dynsym_count != 0)
- return false;
- if (bfd_seek (abfd, info->dyninfo.ld_stab, SEEK_SET) != 0
- || (bfd_read ((PTR) info->dynsym, info->dynsym_count,
- EXTERNAL_NLIST_SIZE, abfd)
- != info->dynsym_count * EXTERNAL_NLIST_SIZE))
- {
- if (info->dynsym != NULL)
- {
- bfd_release (abfd, info->dynsym);
- info->dynsym = NULL;
- }
- return false;
- }
- }
-
- /* Get the dynamic strings. */
- if (info->dynstr == (char *) NULL)
- {
- info->dynstr = (char *) bfd_alloc (abfd, info->dyninfo.ld_symb_size);
- if (info->dynstr == NULL && info->dyninfo.ld_symb_size != 0)
- return false;
- if (bfd_seek (abfd, info->dyninfo.ld_symbols, SEEK_SET) != 0
- || (bfd_read ((PTR) info->dynstr, 1, info->dyninfo.ld_symb_size,
- abfd)
- != info->dyninfo.ld_symb_size))
- {
- if (info->dynstr != NULL)
- {
- bfd_release (abfd, info->dynstr);
- info->dynstr = NULL;
- }
- return false;
- }
- }
-
- return true;
-}
-
-/* Read in the dynamic symbols. */
-
-static long
-sunos_canonicalize_dynamic_symtab (abfd, storage)
- bfd *abfd;
- asymbol **storage;
-{
- struct sunos_dynamic_info *info;
- unsigned long i;
-
- if (! sunos_slurp_dynamic_symtab (abfd))
- return -1;
-
- info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
-
-#ifdef CHECK_DYNAMIC_HASH
- /* Check my understanding of the dynamic hash table by making sure
- that each symbol can be located in the hash table. */
- {
- bfd_size_type table_size;
- bfd_byte *table;
- bfd_size_type i;
-
- if (info->dyninfo.ld_buckets > info->dynsym_count)
- abort ();
- table_size = info->dyninfo.ld_stab - info->dyninfo.ld_hash;
- table = (bfd_byte *) bfd_malloc (table_size);
- if (table == NULL && table_size != 0)
- abort ();
- if (bfd_seek (abfd, info->dyninfo.ld_hash, SEEK_SET) != 0
- || bfd_read ((PTR) table, 1, table_size, abfd) != table_size)
- abort ();
- for (i = 0; i < info->dynsym_count; i++)
- {
- unsigned char *name;
- unsigned long hash;
-
- name = ((unsigned char *) info->dynstr
- + GET_WORD (abfd, info->dynsym[i].e_strx));
- hash = 0;
- while (*name != '\0')
- hash = (hash << 1) + *name++;
- hash &= 0x7fffffff;
- hash %= info->dyninfo.ld_buckets;
- while (GET_WORD (abfd, table + hash * HASH_ENTRY_SIZE) != i)
- {
- hash = GET_WORD (abfd,
- table + hash * HASH_ENTRY_SIZE + BYTES_IN_WORD);
- if (hash == 0 || hash >= table_size / HASH_ENTRY_SIZE)
- abort ();
- }
- }
- free (table);
- }
-#endif /* CHECK_DYNAMIC_HASH */
-
- /* Get the asymbol structures corresponding to the dynamic nlist
- structures. */
- if (info->canonical_dynsym == (aout_symbol_type *) NULL)
- {
- info->canonical_dynsym = ((aout_symbol_type *)
- bfd_alloc (abfd,
- (info->dynsym_count
- * sizeof (aout_symbol_type))));
- if (info->canonical_dynsym == NULL && info->dynsym_count != 0)
- return -1;
-
- if (! aout_32_translate_symbol_table (abfd, info->canonical_dynsym,
- info->dynsym, info->dynsym_count,
- info->dynstr,
- info->dyninfo.ld_symb_size,
- true))
- {
- if (info->canonical_dynsym != NULL)
- {
- bfd_release (abfd, info->canonical_dynsym);
- info->canonical_dynsym = NULL;
- }
- return -1;
- }
- }
-
- /* Return pointers to the dynamic asymbol structures. */
- for (i = 0; i < info->dynsym_count; i++)
- *storage++ = (asymbol *) (info->canonical_dynsym + i);
- *storage = NULL;
-
- return info->dynsym_count;
-}
-
-/* Return the amount of memory required for the dynamic relocs. */
-
-static long
-sunos_get_dynamic_reloc_upper_bound (abfd)
- bfd *abfd;
-{
- struct sunos_dynamic_info *info;
-
- if (! sunos_read_dynamic_info (abfd))
- return -1;
-
- info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
- if (! info->valid)
- {
- bfd_set_error (bfd_error_no_symbols);
- return -1;
- }
-
- return (info->dynrel_count + 1) * sizeof (arelent *);
-}
-
-/* Read in the dynamic relocs. */
-
-static long
-sunos_canonicalize_dynamic_reloc (abfd, storage, syms)
- bfd *abfd;
- arelent **storage;
- asymbol **syms;
-{
- struct sunos_dynamic_info *info;
- unsigned long i;
-
- /* Get the general dynamic information. */
- if (obj_aout_dynamic_info (abfd) == (PTR) NULL)
- {
- if (! sunos_read_dynamic_info (abfd))
- return -1;
- }
-
- info = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
- if (! info->valid)
- {
- bfd_set_error (bfd_error_no_symbols);
- return -1;
- }
-
- /* Get the dynamic reloc information. */
- if (info->dynrel == NULL)
- {
- info->dynrel = (PTR) bfd_alloc (abfd,
- (info->dynrel_count
- * obj_reloc_entry_size (abfd)));
- if (info->dynrel == NULL && info->dynrel_count != 0)
- return -1;
- if (bfd_seek (abfd, info->dyninfo.ld_rel, SEEK_SET) != 0
- || (bfd_read ((PTR) info->dynrel, info->dynrel_count,
- obj_reloc_entry_size (abfd), abfd)
- != info->dynrel_count * obj_reloc_entry_size (abfd)))
- {
- if (info->dynrel != NULL)
- {
- bfd_release (abfd, info->dynrel);
- info->dynrel = NULL;
- }
- return -1;
- }
- }
-
- /* Get the arelent structures corresponding to the dynamic reloc
- information. */
- if (info->canonical_dynrel == (arelent *) NULL)
- {
- arelent *to;
-
- info->canonical_dynrel = ((arelent *)
- bfd_alloc (abfd,
- (info->dynrel_count
- * sizeof (arelent))));
- if (info->canonical_dynrel == NULL && info->dynrel_count != 0)
- return -1;
-
- to = info->canonical_dynrel;
-
- if (obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE)
- {
- register struct reloc_ext_external *p;
- struct reloc_ext_external *pend;
-
- p = (struct reloc_ext_external *) info->dynrel;
- pend = p + info->dynrel_count;
- for (; p < pend; p++, to++)
- NAME(aout,swap_ext_reloc_in) (abfd, p, to, syms,
- info->dynsym_count);
- }
- else
- {
- register struct reloc_std_external *p;
- struct reloc_std_external *pend;
-
- p = (struct reloc_std_external *) info->dynrel;
- pend = p + info->dynrel_count;
- for (; p < pend; p++, to++)
- NAME(aout,swap_std_reloc_in) (abfd, p, to, syms,
- info->dynsym_count);
- }
- }
-
- /* Return pointers to the dynamic arelent structures. */
- for (i = 0; i < info->dynrel_count; i++)
- *storage++ = info->canonical_dynrel + i;
- *storage = NULL;
-
- return info->dynrel_count;
-}
-
-/* Code to handle linking of SunOS shared libraries. */
-
-/* A SPARC procedure linkage table entry is 12 bytes. The first entry
- in the table is a jump which is filled in by the runtime linker.
- The remaining entries are branches back to the first entry,
- followed by an index into the relocation table encoded to look like
- a sethi of %g0. */
-
-#define SPARC_PLT_ENTRY_SIZE (12)
-
-static const bfd_byte sparc_plt_first_entry[SPARC_PLT_ENTRY_SIZE] =
-{
- /* sethi %hi(0),%g1; address filled in by runtime linker. */
- 0x3, 0, 0, 0,
- /* jmp %g1; offset filled in by runtime linker. */
- 0x81, 0xc0, 0x60, 0,
- /* nop */
- 0x1, 0, 0, 0
-};
-
-/* save %sp, -96, %sp */
-#define SPARC_PLT_ENTRY_WORD0 0x9de3bfa0
-/* call; address filled in later. */
-#define SPARC_PLT_ENTRY_WORD1 0x40000000
-/* sethi; reloc index filled in later. */
-#define SPARC_PLT_ENTRY_WORD2 0x01000000
-
-/* This sequence is used when for the jump table entry to a defined
- symbol in a complete executable. It is used when linking PIC
- compiled code which is not being put into a shared library. */
-/* sethi <address to be filled in later>, %g1 */
-#define SPARC_PLT_PIC_WORD0 0x03000000
-/* jmp %g1 + <address to be filled in later> */
-#define SPARC_PLT_PIC_WORD1 0x81c06000
-/* nop */
-#define SPARC_PLT_PIC_WORD2 0x01000000
-
-/* An m68k procedure linkage table entry is 8 bytes. The first entry
- in the table is a jump which is filled in the by the runtime
- linker. The remaining entries are branches back to the first
- entry, followed by a two byte index into the relocation table. */
-
-#define M68K_PLT_ENTRY_SIZE (8)
-
-static const bfd_byte m68k_plt_first_entry[M68K_PLT_ENTRY_SIZE] =
-{
- /* jmps @# */
- 0x4e, 0xf9,
- /* Filled in by runtime linker with a magic address. */
- 0, 0, 0, 0,
- /* Not used? */
- 0, 0
-};
-
-/* bsrl */
-#define M68K_PLT_ENTRY_WORD0 (0x61ff)
-/* Remaining words filled in later. */
-
-/* An entry in the SunOS linker hash table. */
-
-struct sunos_link_hash_entry
-{
- struct aout_link_hash_entry root;
-
- /* If this is a dynamic symbol, this is its index into the dynamic
- symbol table. This is initialized to -1. As the linker looks at
- the input files, it changes this to -2 if it will be added to the
- dynamic symbol table. After all the input files have been seen,
- the linker will know whether to build a dynamic symbol table; if
- it does build one, this becomes the index into the table. */
- long dynindx;
-
- /* If this is a dynamic symbol, this is the index of the name in the
- dynamic symbol string table. */
- long dynstr_index;
-
- /* The offset into the global offset table used for this symbol. If
- the symbol does not require a GOT entry, this is 0. */
- bfd_vma got_offset;
-
- /* The offset into the procedure linkage table used for this symbol.
- If the symbol does not require a PLT entry, this is 0. */
- bfd_vma plt_offset;
-
- /* Some linker flags. */
- unsigned char flags;
- /* Symbol is referenced by a regular object. */
-#define SUNOS_REF_REGULAR 01
- /* Symbol is defined by a regular object. */
-#define SUNOS_DEF_REGULAR 02
- /* Symbol is referenced by a dynamic object. */
-#define SUNOS_REF_DYNAMIC 04
- /* Symbol is defined by a dynamic object. */
-#define SUNOS_DEF_DYNAMIC 010
- /* Symbol is a constructor symbol in a regular object. */
-#define SUNOS_CONSTRUCTOR 020
-};
-
-/* The SunOS linker hash table. */
-
-struct sunos_link_hash_table
-{
- struct aout_link_hash_table root;
-
- /* The object which holds the dynamic sections. */
- bfd *dynobj;
-
- /* Whether we have created the dynamic sections. */
- boolean dynamic_sections_created;
-
- /* Whether we need the dynamic sections. */
- boolean dynamic_sections_needed;
-
- /* The number of dynamic symbols. */
- size_t dynsymcount;
-
- /* The number of buckets in the hash table. */
- size_t bucketcount;
-
- /* The list of dynamic objects needed by dynamic objects included in
- the link. */
- struct bfd_link_needed_list *needed;
-};
-
-/* Routine to create an entry in an SunOS link hash table. */
-
-static struct bfd_hash_entry *
-sunos_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct sunos_link_hash_entry *ret = (struct sunos_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct sunos_link_hash_entry *) NULL)
- ret = ((struct sunos_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct sunos_link_hash_entry)));
- if (ret == (struct sunos_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct sunos_link_hash_entry *)
- NAME(aout,link_hash_newfunc) ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != NULL)
- {
- /* Set local fields. */
- ret->dynindx = -1;
- ret->dynstr_index = -1;
- ret->got_offset = 0;
- ret->plt_offset = 0;
- ret->flags = 0;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create a SunOS link hash table. */
-
-static struct bfd_link_hash_table *
-sunos_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct sunos_link_hash_table *ret;
-
- ret = ((struct sunos_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct sunos_link_hash_table)));
- if (ret == (struct sunos_link_hash_table *) NULL)
- return (struct bfd_link_hash_table *) NULL;
- if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
- sunos_link_hash_newfunc))
- {
- bfd_release (abfd, ret);
- return (struct bfd_link_hash_table *) NULL;
- }
-
- ret->dynobj = NULL;
- ret->dynamic_sections_created = false;
- ret->dynamic_sections_needed = false;
- ret->dynsymcount = 0;
- ret->bucketcount = 0;
- ret->needed = NULL;
-
- return &ret->root.root;
-}
-
-/* Look up an entry in an SunOS link hash table. */
-
-#define sunos_link_hash_lookup(table, string, create, copy, follow) \
- ((struct sunos_link_hash_entry *) \
- aout_link_hash_lookup (&(table)->root, (string), (create), (copy),\
- (follow)))
-
-/* Traverse a SunOS link hash table. */
-
-#define sunos_link_hash_traverse(table, func, info) \
- (aout_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the SunOS link hash table from the info structure. This is
- just a cast. */
-
-#define sunos_hash_table(p) ((struct sunos_link_hash_table *) ((p)->hash))
-
-static boolean sunos_scan_dynamic_symbol
- PARAMS ((struct sunos_link_hash_entry *, PTR));
-
-/* Create the dynamic sections needed if we are linking against a
- dynamic object, or if we are linking PIC compiled code. ABFD is a
- bfd we can attach the dynamic sections to. The linker script will
- look for these special sections names and put them in the right
- place in the output file. See include/aout/sun4.h for more details
- of the dynamic linking information. */
-
-static boolean
-sunos_create_dynamic_sections (abfd, info, needed)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean needed;
-{
- asection *s;
-
- if (! sunos_hash_table (info)->dynamic_sections_created)
- {
- flagword flags;
-
- sunos_hash_table (info)->dynobj = abfd;
-
- flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
-
- /* The .dynamic section holds the basic dynamic information: the
- sun4_dynamic structure, the dynamic debugger information, and
- the sun4_dynamic_link structure. */
- s = bfd_make_section (abfd, ".dynamic");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- /* The .got section holds the global offset table. The address
- is put in the ld_got field. */
- s = bfd_make_section (abfd, ".got");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- /* The .plt section holds the procedure linkage table. The
- address is put in the ld_plt field. */
- s = bfd_make_section (abfd, ".plt");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- /* The .dynrel section holds the dynamic relocs. The address is
- put in the ld_rel field. */
- s = bfd_make_section (abfd, ".dynrel");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- /* The .hash section holds the dynamic hash table. The address
- is put in the ld_hash field. */
- s = bfd_make_section (abfd, ".hash");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- /* The .dynsym section holds the dynamic symbols. The address
- is put in the ld_stab field. */
- s = bfd_make_section (abfd, ".dynsym");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- /* The .dynstr section holds the dynamic symbol string table.
- The address is put in the ld_symbols field. */
- s = bfd_make_section (abfd, ".dynstr");
- if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
- || ! bfd_set_section_alignment (abfd, s, 2))
- return false;
-
- sunos_hash_table (info)->dynamic_sections_created = true;
- }
-
- if (needed && ! sunos_hash_table (info)->dynamic_sections_needed)
- {
- bfd *dynobj;
-
- dynobj = sunos_hash_table (info)->dynobj;
-
- s = bfd_get_section_by_name (dynobj, ".got");
- s->_raw_size = BYTES_IN_WORD;
-
- sunos_hash_table (info)->dynamic_sections_needed = true;
- }
-
- return true;
-}
-
-/* Add dynamic symbols during a link. This is called by the a.out
- backend linker when it encounters an object with the DYNAMIC flag
- set. */
-
-static boolean
-sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp)
- bfd *abfd;
- struct bfd_link_info *info;
- struct external_nlist **symsp;
- bfd_size_type *sym_countp;
- char **stringsp;
-{
- asection *s;
- bfd *dynobj;
- struct sunos_dynamic_info *dinfo;
- unsigned long need;
-
- /* We do not want to include the sections in a dynamic object in the
- output file. We hack by simply clobbering the list of sections
- in the BFD. This could be handled more cleanly by, say, a new
- section flag; the existing SEC_NEVER_LOAD flag is not the one we
- want, because that one still implies that the section takes up
- space in the output file. */
- abfd->sections = NULL;
-
- /* The native linker seems to just ignore dynamic objects when -r is
- used. */
- if (info->relocateable)
- return true;
-
- /* There's no hope of using a dynamic object which does not exactly
- match the format of the output file. */
- if (info->hash->creator != abfd->xvec)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
-
- /* Make sure we have all the required information. */
- if (! sunos_create_dynamic_sections (abfd, info, true))
- return false;
-
- /* Make sure we have a .need and a .rules sections. These are only
- needed if there really is a dynamic object in the link, so they
- are not added by sunos_create_dynamic_sections. */
- dynobj = sunos_hash_table (info)->dynobj;
- if (bfd_get_section_by_name (dynobj, ".need") == NULL)
- {
- /* The .need section holds the list of names of shared objets
- which must be included at runtime. The address of this
- section is put in the ld_need field. */
- s = bfd_make_section (dynobj, ".need");
- if (s == NULL
- || ! bfd_set_section_flags (dynobj, s,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, s, 2))
- return false;
- }
-
- if (bfd_get_section_by_name (dynobj, ".rules") == NULL)
- {
- /* The .rules section holds the path to search for shared
- objects. The address of this section is put in the ld_rules
- field. */
- s = bfd_make_section (dynobj, ".rules");
- if (s == NULL
- || ! bfd_set_section_flags (dynobj, s,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_READONLY))
- || ! bfd_set_section_alignment (dynobj, s, 2))
- return false;
- }
-
- /* Pick up the dynamic symbols and return them to the caller. */
- if (! sunos_slurp_dynamic_symtab (abfd))
- return false;
-
- dinfo = (struct sunos_dynamic_info *) obj_aout_dynamic_info (abfd);
- *symsp = dinfo->dynsym;
- *sym_countp = dinfo->dynsym_count;
- *stringsp = dinfo->dynstr;
-
- /* Record information about any other objects needed by this one. */
- need = dinfo->dyninfo.ld_need;
- while (need != 0)
- {
- bfd_byte buf[16];
- unsigned long name, flags;
- unsigned short major_vno, minor_vno;
- struct bfd_link_needed_list *needed, **pp;
- bfd_byte b;
-
- if (bfd_seek (abfd, need, SEEK_SET) != 0
- || bfd_read (buf, 1, 16, abfd) != 16)
- return false;
-
- /* For the format of an ld_need entry, see aout/sun4.h. We
- should probably define structs for this manipulation. */
-
- name = bfd_get_32 (abfd, buf);
- flags = bfd_get_32 (abfd, buf + 4);
- major_vno = bfd_get_16 (abfd, buf + 8);
- minor_vno = bfd_get_16 (abfd, buf + 10);
- need = bfd_get_32 (abfd, buf + 12);
-
- needed = (struct bfd_link_needed_list *) bfd_alloc (abfd, sizeof (struct bfd_link_needed_list));
- if (needed == NULL)
- return false;
- needed->by = abfd;
-
- /* We return the name as [-l]name[.maj][.min]. */
-
- if ((flags & 0x80000000) != 0)
- bfd_alloc_grow (abfd, "-l", 2);
- if (bfd_seek (abfd, name, SEEK_SET) != 0)
- return false;
- do
- {
- if (bfd_read (&b, 1, 1, abfd) != 1)
- return false;
- bfd_alloc_grow (abfd, &b, 1);
- }
- while (b != '\0');
- if (major_vno != 0)
- {
- char verbuf[30];
-
- sprintf (verbuf, ".%d", major_vno);
- bfd_alloc_grow (abfd, verbuf, strlen (verbuf));
- if (minor_vno != 0)
- {
- sprintf (verbuf, ".%d", minor_vno);
- bfd_alloc_grow (abfd, verbuf, strlen (verbuf));
- }
- }
- needed->name = bfd_alloc_finish (abfd);
- if (needed->name == NULL)
- return false;
-
- needed->next = NULL;
-
- for (pp = &sunos_hash_table (info)->needed;
- *pp != NULL;
- pp = &(*pp)->next)
- ;
- *pp = needed;
- }
-
- return true;
-}
-
-/* Function to add a single symbol to the linker hash table. This is
- a wrapper around _bfd_generic_link_add_one_symbol which handles the
- tweaking needed for dynamic linking support. */
-
-static boolean
-sunos_add_one_symbol (info, abfd, name, flags, section, value, string,
- copy, collect, hashp)
- struct bfd_link_info *info;
- bfd *abfd;
- const char *name;
- flagword flags;
- asection *section;
- bfd_vma value;
- const char *string;
- boolean copy;
- boolean collect;
- struct bfd_link_hash_entry **hashp;
-{
- struct sunos_link_hash_entry *h;
- int new_flag;
-
- if (! sunos_hash_table (info)->dynamic_sections_created)
- {
- /* We must create the dynamic sections while reading the input
- files, even though at this point we don't know if any of the
- sections will be needed. This will ensure that the dynamic
- sections are mapped to the right output section. It does no
- harm to create these sections if they are not needed. */
- if (! sunos_create_dynamic_sections (abfd, info, false))
- return false;
- }
-
- if ((flags & (BSF_INDIRECT | BSF_WARNING | BSF_CONSTRUCTOR)) != 0
- || ! bfd_is_und_section (section))
- h = sunos_link_hash_lookup (sunos_hash_table (info), name, true, copy,
- false);
- else
- h = ((struct sunos_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (abfd, info, name, true, copy, false));
- if (h == NULL)
- return false;
-
- if (hashp != NULL)
- *hashp = (struct bfd_link_hash_entry *) h;
-
- /* Treat a common symbol in a dynamic object as defined in the .bss
- section of the dynamic object. We don't want to allocate space
- for it in our process image. */
- if ((abfd->flags & DYNAMIC) != 0
- && bfd_is_com_section (section))
- section = obj_bsssec (abfd);
-
- if (! bfd_is_und_section (section)
- && h->root.root.type != bfd_link_hash_new
- && h->root.root.type != bfd_link_hash_undefined
- && h->root.root.type != bfd_link_hash_defweak)
- {
- /* We are defining the symbol, and it is already defined. This
- is a potential multiple definition error. */
- if ((abfd->flags & DYNAMIC) != 0)
- {
- /* The definition we are adding is from a dynamic object.
- We do not want this new definition to override the
- existing definition, so we pretend it is just a
- reference. */
- section = bfd_und_section_ptr;
- }
- else if (h->root.root.type == bfd_link_hash_defined
- && h->root.root.u.def.section->owner != NULL
- && (h->root.root.u.def.section->owner->flags & DYNAMIC) != 0)
- {
- /* The existing definition is from a dynamic object. We
- want to override it with the definition we just found.
- Clobber the existing definition. */
- h->root.root.type = bfd_link_hash_new;
- }
- else if (h->root.root.type == bfd_link_hash_common
- && (h->root.root.u.c.p->section->owner->flags & DYNAMIC) != 0)
- {
- /* The existing definition is from a dynamic object. We
- want to override it with the definition we just found.
- Clobber the existing definition. We can't set it to new,
- because it is on the undefined list. */
- h->root.root.type = bfd_link_hash_undefined;
- h->root.root.u.undef.abfd = h->root.root.u.c.p->section->owner;
- }
- }
-
- if ((abfd->flags & DYNAMIC) != 0
- && abfd->xvec == info->hash->creator
- && (h->flags & SUNOS_CONSTRUCTOR) != 0)
- {
- /* The existing symbol is a constructor symbol, and this symbol
- is from a dynamic object. A constructor symbol is actually a
- definition, although the type will be bfd_link_hash_undefined
- at this point. We want to ignore the definition from the
- dynamic object. */
- section = bfd_und_section_ptr;
- }
- else if ((flags & BSF_CONSTRUCTOR) != 0
- && (abfd->flags & DYNAMIC) == 0
- && h->root.root.type == bfd_link_hash_defined
- && h->root.root.u.def.section->owner != NULL
- && (h->root.root.u.def.section->owner->flags & DYNAMIC) != 0)
- {
- /* The existing symbol is defined by a dynamic object, and this
- is a constructor symbol. As above, we want to force the use
- of the constructor symbol from the regular object. */
- h->root.root.type = bfd_link_hash_new;
- }
-
- /* Do the usual procedure for adding a symbol. */
- if (! _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section,
- value, string, copy, collect,
- hashp))
- return false;
-
- if (abfd->xvec == info->hash->creator)
- {
- /* Set a flag in the hash table entry indicating the type of
- reference or definition we just found. Keep a count of the
- number of dynamic symbols we find. A dynamic symbol is one
- which is referenced or defined by both a regular object and a
- shared object. */
- if ((abfd->flags & DYNAMIC) == 0)
- {
- if (bfd_is_und_section (section))
- new_flag = SUNOS_REF_REGULAR;
- else
- new_flag = SUNOS_DEF_REGULAR;
- }
- else
- {
- if (bfd_is_und_section (section))
- new_flag = SUNOS_REF_DYNAMIC;
- else
- new_flag = SUNOS_DEF_DYNAMIC;
- }
- h->flags |= new_flag;
-
- if (h->dynindx == -1
- && (h->flags & (SUNOS_DEF_REGULAR | SUNOS_REF_REGULAR)) != 0)
- {
- ++sunos_hash_table (info)->dynsymcount;
- h->dynindx = -2;
- }
-
- if ((flags & BSF_CONSTRUCTOR) != 0
- && (abfd->flags & DYNAMIC) == 0)
- h->flags |= SUNOS_CONSTRUCTOR;
- }
-
- return true;
-}
-
-/* Return the list of objects needed by BFD. */
-
-/*ARGSUSED*/
-struct bfd_link_needed_list *
-bfd_sunos_get_needed_list (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- if (info->hash->creator != &MY(vec))
- return NULL;
- return sunos_hash_table (info)->needed;
-}
-
-/* Record an assignment made to a symbol by a linker script. We need
- this in case some dynamic object refers to this symbol. */
-
-boolean
-bfd_sunos_record_link_assignment (output_bfd, info, name)
- bfd *output_bfd;
- struct bfd_link_info *info;
- const char *name;
-{
- struct sunos_link_hash_entry *h;
-
- if (output_bfd->xvec != &MY(vec))
- return true;
-
- /* This is called after we have examined all the input objects. If
- the symbol does not exist, it merely means that no object refers
- to it, and we can just ignore it at this point. */
- h = sunos_link_hash_lookup (sunos_hash_table (info), name,
- false, false, false);
- if (h == NULL)
- return true;
-
- /* In a shared library, the __DYNAMIC symbol does not appear in the
- dynamic symbol table. */
- if (! info->shared || strcmp (name, "__DYNAMIC") != 0)
- {
- h->flags |= SUNOS_DEF_REGULAR;
-
- if (h->dynindx == -1)
- {
- ++sunos_hash_table (info)->dynsymcount;
- h->dynindx = -2;
- }
- }
-
- return true;
-}
-
-/* Set up the sizes and contents of the dynamic sections created in
- sunos_add_dynamic_symbols. This is called by the SunOS linker
- emulation before_allocation routine. We must set the sizes of the
- sections before the linker sets the addresses of the various
- sections. This unfortunately requires reading all the relocs so
- that we can work out which ones need to become dynamic relocs. If
- info->keep_memory is true, we keep the relocs in memory; otherwise,
- we discard them, and will read them again later. */
-
-boolean
-bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
- srulesptr)
- bfd *output_bfd;
- struct bfd_link_info *info;
- asection **sdynptr;
- asection **sneedptr;
- asection **srulesptr;
-{
- bfd *dynobj;
- size_t dynsymcount;
- struct sunos_link_hash_entry *h;
- asection *s;
- size_t bucketcount;
- size_t hashalloc;
- size_t i;
- bfd *sub;
-
- *sdynptr = NULL;
- *sneedptr = NULL;
- *srulesptr = NULL;
-
- if (output_bfd->xvec != &MY(vec))
- return true;
-
- /* Look through all the input BFD's and read their relocs. It would
- be better if we didn't have to do this, but there is no other way
- to determine the number of dynamic relocs we need, and, more
- importantly, there is no other way to know which symbols should
- get an entry in the procedure linkage table. */
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- if ((sub->flags & DYNAMIC) == 0
- && sub->xvec == output_bfd->xvec)
- {
- if (! sunos_scan_relocs (info, sub, obj_textsec (sub),
- exec_hdr (sub)->a_trsize)
- || ! sunos_scan_relocs (info, sub, obj_datasec (sub),
- exec_hdr (sub)->a_drsize))
- return false;
- }
- }
-
- dynobj = sunos_hash_table (info)->dynobj;
- dynsymcount = sunos_hash_table (info)->dynsymcount;
-
- /* If there were no dynamic objects in the link, and we don't need
- to build a global offset table, there is nothing to do here. */
- if (! sunos_hash_table (info)->dynamic_sections_needed)
- return true;
-
- /* If __GLOBAL_OFFSET_TABLE_ was mentioned, define it. */
- h = sunos_link_hash_lookup (sunos_hash_table (info),
- "__GLOBAL_OFFSET_TABLE_", false, false, false);
- if (h != NULL && (h->flags & SUNOS_REF_REGULAR) != 0)
- {
- h->flags |= SUNOS_DEF_REGULAR;
- if (h->dynindx == -1)
- {
- ++sunos_hash_table (info)->dynsymcount;
- h->dynindx = -2;
- }
- h->root.root.type = bfd_link_hash_defined;
- h->root.root.u.def.section = bfd_get_section_by_name (dynobj, ".got");
- h->root.root.u.def.value = 0;
- }
-
- /* The .dynamic section is always the same size. */
- s = bfd_get_section_by_name (dynobj, ".dynamic");
- BFD_ASSERT (s != NULL);
- s->_raw_size = (sizeof (struct external_sun4_dynamic)
- + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE
- + sizeof (struct external_sun4_dynamic_link));
-
- /* Set the size of the .dynsym and .hash sections. We counted the
- number of dynamic symbols as we read the input files. We will
- build the dynamic symbol table (.dynsym) and the hash table
- (.hash) when we build the final symbol table, because until then
- we do not know the correct value to give the symbols. We build
- the dynamic symbol string table (.dynstr) in a traversal of the
- symbol table using sunos_scan_dynamic_symbol. */
- s = bfd_get_section_by_name (dynobj, ".dynsym");
- BFD_ASSERT (s != NULL);
- s->_raw_size = dynsymcount * sizeof (struct external_nlist);
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
- if (s->contents == NULL && s->_raw_size != 0)
- return false;
-
- /* The number of buckets is just the number of symbols divided by
- four. To compute the final size of the hash table, we must
- actually compute the hash table. Normally we need exactly as
- many entries in the hash table as there are dynamic symbols, but
- if some of the buckets are not used we will need additional
- entries. In the worst case, every symbol will hash to the same
- bucket, and we will need BUCKETCOUNT - 1 extra entries. */
- if (dynsymcount >= 4)
- bucketcount = dynsymcount / 4;
- else if (dynsymcount > 0)
- bucketcount = dynsymcount;
- else
- bucketcount = 1;
- s = bfd_get_section_by_name (dynobj, ".hash");
- BFD_ASSERT (s != NULL);
- hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
- s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
- if (s->contents == NULL && dynsymcount > 0)
- return false;
- memset (s->contents, 0, hashalloc);
- for (i = 0; i < bucketcount; i++)
- PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
- s->_raw_size = bucketcount * HASH_ENTRY_SIZE;
-
- sunos_hash_table (info)->bucketcount = bucketcount;
-
- /* Scan all the symbols, place them in the dynamic symbol table, and
- build the dynamic hash table. We reuse dynsymcount as a counter
- for the number of symbols we have added so far. */
- sunos_hash_table (info)->dynsymcount = 0;
- sunos_link_hash_traverse (sunos_hash_table (info),
- sunos_scan_dynamic_symbol,
- (PTR) info);
- BFD_ASSERT (sunos_hash_table (info)->dynsymcount == dynsymcount);
-
- /* The SunOS native linker seems to align the total size of the
- symbol strings to a multiple of 8. I don't know if this is
- important, but it can't hurt much. */
- s = bfd_get_section_by_name (dynobj, ".dynstr");
- BFD_ASSERT (s != NULL);
- if ((s->_raw_size & 7) != 0)
- {
- bfd_size_type add;
- bfd_byte *contents;
-
- add = 8 - (s->_raw_size & 7);
- contents = (bfd_byte *) bfd_realloc (s->contents,
- (size_t) (s->_raw_size + add));
- if (contents == NULL)
- return false;
- memset (contents + s->_raw_size, 0, (size_t) add);
- s->contents = contents;
- s->_raw_size += add;
- }
-
- /* Now that we have worked out the sizes of the procedure linkage
- table and the dynamic relocs, allocate storage for them. */
- s = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (s != NULL);
- if (s->_raw_size != 0)
- {
- s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
- if (s->contents == NULL)
- return false;
-
- /* Fill in the first entry in the table. */
- switch (bfd_get_arch (dynobj))
- {
- case bfd_arch_sparc:
- memcpy (s->contents, sparc_plt_first_entry, SPARC_PLT_ENTRY_SIZE);
- break;
-
- case bfd_arch_m68k:
- memcpy (s->contents, m68k_plt_first_entry, M68K_PLT_ENTRY_SIZE);
- break;
-
- default:
- abort ();
- }
- }
-
- s = bfd_get_section_by_name (dynobj, ".dynrel");
- if (s->_raw_size != 0)
- {
- s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
- if (s->contents == NULL)
- return false;
- }
- /* We use the reloc_count field to keep track of how many of the
- relocs we have output so far. */
- s->reloc_count = 0;
-
- /* Make space for the global offset table. */
- s = bfd_get_section_by_name (dynobj, ".got");
- s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
- if (s->contents == NULL)
- return false;
-
- *sdynptr = bfd_get_section_by_name (dynobj, ".dynamic");
- *sneedptr = bfd_get_section_by_name (dynobj, ".need");
- *srulesptr = bfd_get_section_by_name (dynobj, ".rules");
-
- return true;
-}
-
-/* Scan the relocs for an input section. */
-
-static boolean
-sunos_scan_relocs (info, abfd, sec, rel_size)
- struct bfd_link_info *info;
- bfd *abfd;
- asection *sec;
- bfd_size_type rel_size;
-{
- PTR relocs;
- PTR free_relocs = NULL;
-
- if (rel_size == 0)
- return true;
-
- if (! info->keep_memory)
- relocs = free_relocs = bfd_malloc ((size_t) rel_size);
- else
- {
- struct aout_section_data_struct *n;
-
- n = ((struct aout_section_data_struct *)
- bfd_alloc (abfd, sizeof (struct aout_section_data_struct)));
- if (n == NULL)
- relocs = NULL;
- else
- {
- set_aout_section_data (sec, n);
- relocs = bfd_malloc ((size_t) rel_size);
- aout_section_data (sec)->relocs = relocs;
- }
- }
- if (relocs == NULL)
- return false;
-
- if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || bfd_read (relocs, 1, rel_size, abfd) != rel_size)
- goto error_return;
-
- if (obj_reloc_entry_size (abfd) == RELOC_STD_SIZE)
- {
- if (! sunos_scan_std_relocs (info, abfd, sec,
- (struct reloc_std_external *) relocs,
- rel_size))
- goto error_return;
- }
- else
- {
- if (! sunos_scan_ext_relocs (info, abfd, sec,
- (struct reloc_ext_external *) relocs,
- rel_size))
- goto error_return;
- }
-
- if (free_relocs != NULL)
- free (free_relocs);
-
- return true;
-
- error_return:
- if (free_relocs != NULL)
- free (free_relocs);
- return false;
-}
-
-/* Scan the relocs for an input section using standard relocs. We
- need to figure out what to do for each reloc against a dynamic
- symbol. If the symbol is in the .text section, an entry is made in
- the procedure linkage table. Note that this will do the wrong
- thing if the symbol is actually data; I don't think the Sun 3
- native linker handles this case correctly either. If the symbol is
- not in the .text section, we must preserve the reloc as a dynamic
- reloc. FIXME: We should also handle the PIC relocs here by
- building global offset table entries. */
-
-static boolean
-sunos_scan_std_relocs (info, abfd, sec, relocs, rel_size)
- struct bfd_link_info *info;
- bfd *abfd;
- asection *sec;
- const struct reloc_std_external *relocs;
- bfd_size_type rel_size;
-{
- bfd *dynobj;
- asection *splt = NULL;
- asection *srel = NULL;
- struct sunos_link_hash_entry **sym_hashes;
- const struct reloc_std_external *rel, *relend;
-
- /* We only know how to handle m68k plt entries. */
- if (bfd_get_arch (abfd) != bfd_arch_m68k)
- {
- bfd_set_error (bfd_error_invalid_target);
- return false;
- }
-
- dynobj = NULL;
-
- sym_hashes = (struct sunos_link_hash_entry **) obj_aout_sym_hashes (abfd);
-
- relend = relocs + rel_size / RELOC_STD_SIZE;
- for (rel = relocs; rel < relend; rel++)
- {
- int r_index;
- struct sunos_link_hash_entry *h;
-
- /* We only want relocs against external symbols. */
- if (bfd_header_big_endian (abfd))
- {
- if ((rel->r_type[0] & RELOC_STD_BITS_EXTERN_BIG) == 0)
- continue;
- }
- else
- {
- if ((rel->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE) == 0)
- continue;
- }
-
- /* Get the symbol index. */
- if (bfd_header_big_endian (abfd))
- r_index = ((rel->r_index[0] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[2]);
- else
- r_index = ((rel->r_index[2] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[0]);
-
- /* Get the hash table entry. */
- h = sym_hashes[r_index];
- if (h == NULL)
- {
- /* This should not normally happen, but it will in any case
- be caught in the relocation phase. */
- continue;
- }
-
- /* At this point common symbols have already been allocated, so
- we don't have to worry about them. We need to consider that
- we may have already seen this symbol and marked it undefined;
- if the symbol is really undefined, then SUNOS_DEF_DYNAMIC
- will be zero. */
- if (h->root.root.type != bfd_link_hash_defined
- && h->root.root.type != bfd_link_hash_defweak
- && h->root.root.type != bfd_link_hash_undefined)
- continue;
-
- if ((h->flags & SUNOS_DEF_DYNAMIC) == 0
- || (h->flags & SUNOS_DEF_REGULAR) != 0)
- continue;
-
- if (dynobj == NULL)
- {
- if (! sunos_create_dynamic_sections (abfd, info, true))
- return false;
- dynobj = sunos_hash_table (info)->dynobj;
- splt = bfd_get_section_by_name (dynobj, ".plt");
- srel = bfd_get_section_by_name (dynobj, ".dynrel");
- BFD_ASSERT (splt != NULL && srel != NULL);
- }
-
- BFD_ASSERT ((h->flags & SUNOS_REF_REGULAR) != 0);
- BFD_ASSERT (h->plt_offset != 0
- || ((h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak)
- ? (h->root.root.u.def.section->owner->flags
- & DYNAMIC) != 0
- : (h->root.root.u.undef.abfd->flags & DYNAMIC) != 0));
-
- /* This reloc is against a symbol defined only by a dynamic
- object. */
-
- if (h->root.root.type == bfd_link_hash_undefined)
- {
- /* Presumably this symbol was marked as being undefined by
- an earlier reloc. */
- srel->_raw_size += RELOC_STD_SIZE;
- }
- else if ((h->root.root.u.def.section->flags & SEC_CODE) == 0)
- {
- bfd *sub;
-
- /* This reloc is not in the .text section. It must be
- copied into the dynamic relocs. We mark the symbol as
- being undefined. */
- srel->_raw_size += RELOC_STD_SIZE;
- sub = h->root.root.u.def.section->owner;
- h->root.root.type = bfd_link_hash_undefined;
- h->root.root.u.undef.abfd = sub;
- }
- else
- {
- /* This symbol is in the .text section. We must give it an
- entry in the procedure linkage table, if we have not
- already done so. We change the definition of the symbol
- to the .plt section; this will cause relocs against it to
- be handled correctly. */
- if (h->plt_offset == 0)
- {
- if (splt->_raw_size == 0)
- splt->_raw_size = M68K_PLT_ENTRY_SIZE;
- h->plt_offset = splt->_raw_size;
-
- if ((h->flags & SUNOS_DEF_REGULAR) == 0)
- {
- h->root.root.u.def.section = splt;
- h->root.root.u.def.value = splt->_raw_size;
- }
-
- splt->_raw_size += M68K_PLT_ENTRY_SIZE;
-
- /* We may also need a dynamic reloc entry. */
- if ((h->flags & SUNOS_DEF_REGULAR) == 0)
- srel->_raw_size += RELOC_STD_SIZE;
- }
- }
- }
-
- return true;
-}
-
-/* Scan the relocs for an input section using extended relocs. We
- need to figure out what to do for each reloc against a dynamic
- symbol. If the reloc is a WDISP30, and the symbol is in the .text
- section, an entry is made in the procedure linkage table.
- Otherwise, we must preserve the reloc as a dynamic reloc. */
-
-static boolean
-sunos_scan_ext_relocs (info, abfd, sec, relocs, rel_size)
- struct bfd_link_info *info;
- bfd *abfd;
- asection *sec;
- const struct reloc_ext_external *relocs;
- bfd_size_type rel_size;
-{
- bfd *dynobj;
- struct sunos_link_hash_entry **sym_hashes;
- const struct reloc_ext_external *rel, *relend;
- asection *splt = NULL;
- asection *sgot = NULL;
- asection *srel = NULL;
-
- /* We only know how to handle SPARC plt entries. */
- if (bfd_get_arch (abfd) != bfd_arch_sparc)
- {
- bfd_set_error (bfd_error_invalid_target);
- return false;
- }
-
- dynobj = NULL;
-
- sym_hashes = (struct sunos_link_hash_entry **) obj_aout_sym_hashes (abfd);
-
- relend = relocs + rel_size / RELOC_EXT_SIZE;
- for (rel = relocs; rel < relend; rel++)
- {
- unsigned int r_index;
- int r_extern;
- int r_type;
- struct sunos_link_hash_entry *h = NULL;
-
- /* Swap in the reloc information. */
- if (bfd_header_big_endian (abfd))
- {
- r_index = ((rel->r_index[0] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[2]);
- r_extern = (0 != (rel->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG));
- r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
- >> RELOC_EXT_BITS_TYPE_SH_BIG);
- }
- else
- {
- r_index = ((rel->r_index[2] << 16)
- | (rel->r_index[1] << 8)
- | rel->r_index[0]);
- r_extern = (0 != (rel->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE));
- r_type = ((rel->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
- >> RELOC_EXT_BITS_TYPE_SH_LITTLE);
- }
-
- if (r_extern)
- {
- h = sym_hashes[r_index];
- if (h == NULL)
- {
- /* This should not normally happen, but it will in any
- case be caught in the relocation phase. */
- continue;
- }
- }
-
- /* If this is a base relative reloc, we need to make an entry in
- the .got section. */
- if (r_type == RELOC_BASE10
- || r_type == RELOC_BASE13
- || r_type == RELOC_BASE22)
- {
- if (dynobj == NULL)
- {
- if (! sunos_create_dynamic_sections (abfd, info, true))
- return false;
- dynobj = sunos_hash_table (info)->dynobj;
- splt = bfd_get_section_by_name (dynobj, ".plt");
- sgot = bfd_get_section_by_name (dynobj, ".got");
- srel = bfd_get_section_by_name (dynobj, ".dynrel");
- BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
- }
-
- if (r_extern)
- {
- if (h->got_offset != 0)
- continue;
-
- h->got_offset = sgot->_raw_size;
- }
- else
- {
- if (r_index >= bfd_get_symcount (abfd))
- {
- /* This is abnormal, but should be caught in the
- relocation phase. */
- continue;
- }
-
- if (adata (abfd).local_got_offsets == NULL)
- {
- adata (abfd).local_got_offsets =
- (bfd_vma *) bfd_zalloc (abfd,
- (bfd_get_symcount (abfd)
- * sizeof (bfd_vma)));
- if (adata (abfd).local_got_offsets == NULL)
- return false;
- }
-
- if (adata (abfd).local_got_offsets[r_index] != 0)
- continue;
-
- adata (abfd).local_got_offsets[r_index] = sgot->_raw_size;
- }
-
- sgot->_raw_size += BYTES_IN_WORD;
-
- /* If we are making a shared library, or if the symbol is
- defined by a dynamic object, we will need a dynamic reloc
- entry. */
- if (info->shared
- || (h != NULL
- && (h->flags & SUNOS_DEF_DYNAMIC) != 0
- && (h->flags & SUNOS_DEF_REGULAR) == 0))
- srel->_raw_size += RELOC_EXT_SIZE;
-
- continue;
- }
-
- /* Otherwise, we are only interested in relocs against symbols
- defined in dynamic objects but not in regular objects. We
- only need to consider relocs against external symbols. */
- if (! r_extern)
- {
- /* But, if we are creating a shared library, we need to
- generate an absolute reloc. */
- if (info->shared)
- {
- if (dynobj == NULL)
- {
- if (! sunos_create_dynamic_sections (abfd, info, true))
- return false;
- dynobj = sunos_hash_table (info)->dynobj;
- splt = bfd_get_section_by_name (dynobj, ".plt");
- sgot = bfd_get_section_by_name (dynobj, ".got");
- srel = bfd_get_section_by_name (dynobj, ".dynrel");
- BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
- }
-
- srel->_raw_size += RELOC_EXT_SIZE;
- }
-
- continue;
- }
-
- /* At this point common symbols have already been allocated, so
- we don't have to worry about them. We need to consider that
- we may have already seen this symbol and marked it undefined;
- if the symbol is really undefined, then SUNOS_DEF_DYNAMIC
- will be zero. */
- if (h->root.root.type != bfd_link_hash_defined
- && h->root.root.type != bfd_link_hash_defweak
- && h->root.root.type != bfd_link_hash_undefined)
- continue;
-
- if (r_type != RELOC_JMP_TBL
- && ! info->shared
- && ((h->flags & SUNOS_DEF_DYNAMIC) == 0
- || (h->flags & SUNOS_DEF_REGULAR) != 0))
- continue;
-
- if (r_type == RELOC_JMP_TBL
- && ! info->shared
- && (h->flags & SUNOS_DEF_DYNAMIC) == 0
- && (h->flags & SUNOS_DEF_REGULAR) == 0)
- {
- /* This symbol is apparently undefined. Don't do anything
- here; just let the relocation routine report an undefined
- symbol. */
- continue;
- }
-
- if (strcmp (h->root.root.root.string, "__GLOBAL_OFFSET_TABLE_") == 0)
- continue;
-
- if (dynobj == NULL)
- {
- if (! sunos_create_dynamic_sections (abfd, info, true))
- return false;
- dynobj = sunos_hash_table (info)->dynobj;
- splt = bfd_get_section_by_name (dynobj, ".plt");
- sgot = bfd_get_section_by_name (dynobj, ".got");
- srel = bfd_get_section_by_name (dynobj, ".dynrel");
- BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
- }
-
- BFD_ASSERT (r_type == RELOC_JMP_TBL
- || info->shared
- || (h->flags & SUNOS_REF_REGULAR) != 0);
- BFD_ASSERT (r_type == RELOC_JMP_TBL
- || info->shared
- || h->plt_offset != 0
- || ((h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak)
- ? (h->root.root.u.def.section->owner->flags
- & DYNAMIC) != 0
- : (h->root.root.u.undef.abfd->flags & DYNAMIC) != 0));
-
- /* This reloc is against a symbol defined only by a dynamic
- object, or it is a jump table reloc from PIC compiled code. */
-
- if (r_type != RELOC_JMP_TBL
- && h->root.root.type == bfd_link_hash_undefined)
- {
- /* Presumably this symbol was marked as being undefined by
- an earlier reloc. */
- srel->_raw_size += RELOC_EXT_SIZE;
- }
- else if (r_type != RELOC_JMP_TBL
- && (h->root.root.u.def.section->flags & SEC_CODE) == 0)
- {
- bfd *sub;
-
- /* This reloc is not in the .text section. It must be
- copied into the dynamic relocs. We mark the symbol as
- being undefined. */
- srel->_raw_size += RELOC_EXT_SIZE;
- if ((h->flags & SUNOS_DEF_REGULAR) == 0)
- {
- sub = h->root.root.u.def.section->owner;
- h->root.root.type = bfd_link_hash_undefined;
- h->root.root.u.undef.abfd = sub;
- }
- }
- else
- {
- /* This symbol is in the .text section. We must give it an
- entry in the procedure linkage table, if we have not
- already done so. We change the definition of the symbol
- to the .plt section; this will cause relocs against it to
- be handled correctly. */
- if (h->plt_offset == 0)
- {
- if (splt->_raw_size == 0)
- splt->_raw_size = SPARC_PLT_ENTRY_SIZE;
- h->plt_offset = splt->_raw_size;
-
- if ((h->flags & SUNOS_DEF_REGULAR) == 0)
- {
- if (h->root.root.type == bfd_link_hash_undefined)
- h->root.root.type = bfd_link_hash_defined;
- h->root.root.u.def.section = splt;
- h->root.root.u.def.value = splt->_raw_size;
- }
-
- splt->_raw_size += SPARC_PLT_ENTRY_SIZE;
-
- /* We will also need a dynamic reloc entry, unless this
- is a JMP_TBL reloc produced by linking PIC compiled
- code, and we are not making a shared library. */
- if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
- srel->_raw_size += RELOC_EXT_SIZE;
- }
-
- /* If we are creating a shared library, we need to copy over
- any reloc other than a jump table reloc. */
- if (info->shared && r_type != RELOC_JMP_TBL)
- srel->_raw_size += RELOC_EXT_SIZE;
- }
- }
-
- return true;
-}
-
-/* Build the hash table of dynamic symbols, and to mark as written all
- symbols from dynamic objects which we do not plan to write out. */
-
-static boolean
-sunos_scan_dynamic_symbol (h, data)
- struct sunos_link_hash_entry *h;
- PTR data;
-{
- struct bfd_link_info *info = (struct bfd_link_info *) data;
-
- /* Set the written flag for symbols we do not want to write out as
- part of the regular symbol table. This is all symbols which are
- not defined in a regular object file. For some reason symbols
- which are referenced by a regular object and defined by a dynamic
- object do not seem to show up in the regular symbol table. It is
- possible for a symbol to have only SUNOS_REF_REGULAR set here, it
- is an undefined symbol which was turned into a common symbol
- because it was found in an archive object which was not included
- in the link. */
- if ((h->flags & SUNOS_DEF_REGULAR) == 0
- && (h->flags & SUNOS_DEF_DYNAMIC) != 0
- && strcmp (h->root.root.root.string, "__DYNAMIC") != 0)
- h->root.written = true;
-
- /* If this symbol is defined by a dynamic object and referenced by a
- regular object, see whether we gave it a reasonable value while
- scanning the relocs. */
-
- if ((h->flags & SUNOS_DEF_REGULAR) == 0
- && (h->flags & SUNOS_DEF_DYNAMIC) != 0
- && (h->flags & SUNOS_REF_REGULAR) != 0)
- {
- if ((h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak)
- && ((h->root.root.u.def.section->owner->flags & DYNAMIC) != 0)
- && h->root.root.u.def.section->output_section == NULL)
- {
- bfd *sub;
-
- /* This symbol is currently defined in a dynamic section
- which is not being put into the output file. This
- implies that there is no reloc against the symbol. I'm
- not sure why this case would ever occur. In any case, we
- change the symbol to be undefined. */
- sub = h->root.root.u.def.section->owner;
- h->root.root.type = bfd_link_hash_undefined;
- h->root.root.u.undef.abfd = sub;
- }
- }
-
- /* If this symbol is defined or referenced by a regular file, add it
- to the dynamic symbols. */
- if ((h->flags & (SUNOS_DEF_REGULAR | SUNOS_REF_REGULAR)) != 0)
- {
- asection *s;
- size_t len;
- bfd_byte *contents;
- unsigned char *name;
- unsigned long hash;
- bfd *dynobj;
-
- BFD_ASSERT (h->dynindx == -2);
-
- dynobj = sunos_hash_table (info)->dynobj;
-
- h->dynindx = sunos_hash_table (info)->dynsymcount;
- ++sunos_hash_table (info)->dynsymcount;
-
- len = strlen (h->root.root.root.string);
-
- /* We don't bother to construct a BFD hash table for the strings
- which are the names of the dynamic symbols. Using a hash
- table for the regular symbols is beneficial, because the
- regular symbols includes the debugging symbols, which have
- long names and are often duplicated in several object files.
- There are no debugging symbols in the dynamic symbols. */
- s = bfd_get_section_by_name (dynobj, ".dynstr");
- BFD_ASSERT (s != NULL);
- contents = (bfd_byte *) bfd_realloc (s->contents,
- s->_raw_size + len + 1);
- if (contents == NULL)
- return false;
- s->contents = contents;
-
- h->dynstr_index = s->_raw_size;
- strcpy (contents + s->_raw_size, h->root.root.root.string);
- s->_raw_size += len + 1;
-
- /* Add it to the dynamic hash table. */
- name = (unsigned char *) h->root.root.root.string;
- hash = 0;
- while (*name != '\0')
- hash = (hash << 1) + *name++;
- hash &= 0x7fffffff;
- hash %= sunos_hash_table (info)->bucketcount;
-
- s = bfd_get_section_by_name (dynobj, ".hash");
- BFD_ASSERT (s != NULL);
-
- if (GET_SWORD (dynobj, s->contents + hash * HASH_ENTRY_SIZE) == -1)
- PUT_WORD (dynobj, h->dynindx, s->contents + hash * HASH_ENTRY_SIZE);
- else
- {
- bfd_vma next;
-
- next = GET_WORD (dynobj,
- (s->contents
- + hash * HASH_ENTRY_SIZE
- + BYTES_IN_WORD));
- PUT_WORD (dynobj, s->_raw_size / HASH_ENTRY_SIZE,
- s->contents + hash * HASH_ENTRY_SIZE + BYTES_IN_WORD);
- PUT_WORD (dynobj, h->dynindx, s->contents + s->_raw_size);
- PUT_WORD (dynobj, next, s->contents + s->_raw_size + BYTES_IN_WORD);
- s->_raw_size += HASH_ENTRY_SIZE;
- }
- }
-
- return true;
-}
-
-/* Link a dynamic object. We actually don't have anything to do at
- this point. This entry point exists to prevent the regular linker
- code from doing anything with the object. */
-
-/*ARGSUSED*/
-static boolean
-sunos_link_dynamic_object (info, abfd)
- struct bfd_link_info *info;
- bfd *abfd;
-{
- return true;
-}
-
-/* Write out a dynamic symbol. This is called by the final traversal
- over the symbol table. */
-
-static boolean
-sunos_write_dynamic_symbol (output_bfd, info, harg)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct aout_link_hash_entry *harg;
-{
- struct sunos_link_hash_entry *h = (struct sunos_link_hash_entry *) harg;
- int type;
- bfd_vma val;
- asection *s;
- struct external_nlist *outsym;
-
- if (h->dynindx < 0)
- return true;
-
- switch (h->root.root.type)
- {
- default:
- case bfd_link_hash_new:
- abort ();
- /* Avoid variable not initialized warnings. */
- return true;
- case bfd_link_hash_undefined:
- type = N_UNDF | N_EXT;
- val = 0;
- break;
- case bfd_link_hash_defined:
- case bfd_link_hash_defweak:
- {
- asection *sec;
- asection *output_section;
-
- sec = h->root.root.u.def.section;
- output_section = sec->output_section;
- BFD_ASSERT (bfd_is_abs_section (output_section)
- || output_section->owner == output_bfd);
- if (h->plt_offset != 0
- && (h->flags & SUNOS_DEF_REGULAR) == 0)
- {
- type = N_UNDF | N_EXT;
- val = 0;
- }
- else
- {
- if (output_section == obj_textsec (output_bfd))
- type = (h->root.root.type == bfd_link_hash_defined
- ? N_TEXT
- : N_WEAKT);
- else if (output_section == obj_datasec (output_bfd))
- type = (h->root.root.type == bfd_link_hash_defined
- ? N_DATA
- : N_WEAKD);
- else if (output_section == obj_bsssec (output_bfd))
- type = (h->root.root.type == bfd_link_hash_defined
- ? N_BSS
- : N_WEAKB);
- else
- type = (h->root.root.type == bfd_link_hash_defined
- ? N_ABS
- : N_WEAKA);
- type |= N_EXT;
- val = (h->root.root.u.def.value
- + output_section->vma
- + sec->output_offset);
- }
- }
- break;
- case bfd_link_hash_common:
- type = N_UNDF | N_EXT;
- val = h->root.root.u.c.size;
- break;
- case bfd_link_hash_undefweak:
- type = N_WEAKU;
- val = 0;
- break;
- case bfd_link_hash_indirect:
- case bfd_link_hash_warning:
- /* FIXME: Ignore these for now. The circumstances under which
- they should be written out are not clear to me. */
- return true;
- }
-
- s = bfd_get_section_by_name (sunos_hash_table (info)->dynobj, ".dynsym");
- BFD_ASSERT (s != NULL);
- outsym = ((struct external_nlist *)
- (s->contents + h->dynindx * EXTERNAL_NLIST_SIZE));
-
- bfd_h_put_8 (output_bfd, type, outsym->e_type);
- bfd_h_put_8 (output_bfd, 0, outsym->e_other);
-
- /* FIXME: The native linker doesn't use 0 for desc. It seems to use
- one less than the desc value in the shared library, although that
- seems unlikely. */
- bfd_h_put_16 (output_bfd, 0, outsym->e_desc);
-
- PUT_WORD (output_bfd, h->dynstr_index, outsym->e_strx);
- PUT_WORD (output_bfd, val, outsym->e_value);
-
- /* If this symbol is in the procedure linkage table, fill in the
- table entry. */
- if (h->plt_offset != 0)
- {
- bfd *dynobj;
- asection *splt;
- bfd_byte *p;
- asection *s;
- bfd_vma r_address;
-
- dynobj = sunos_hash_table (info)->dynobj;
- splt = bfd_get_section_by_name (dynobj, ".plt");
- p = splt->contents + h->plt_offset;
-
- s = bfd_get_section_by_name (dynobj, ".dynrel");
-
- r_address = (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset);
-
- switch (bfd_get_arch (output_bfd))
- {
- case bfd_arch_sparc:
- if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
- {
- bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD0, p);
- bfd_put_32 (output_bfd,
- (SPARC_PLT_ENTRY_WORD1
- + (((- (h->plt_offset + 4) >> 2)
- & 0x3fffffff))),
- p + 4);
- bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD2 + s->reloc_count,
- p + 8);
- }
- else
- {
- bfd_vma val;
-
- val = (h->root.root.u.def.section->output_section->vma
- + h->root.root.u.def.section->output_offset
- + h->root.root.u.def.value);
- bfd_put_32 (output_bfd,
- SPARC_PLT_PIC_WORD0 + ((val >> 10) & 0x3fffff),
- p);
- bfd_put_32 (output_bfd,
- SPARC_PLT_PIC_WORD1 + (val & 0x3ff),
- p + 4);
- bfd_put_32 (output_bfd, SPARC_PLT_PIC_WORD2, p + 8);
- }
- break;
-
- case bfd_arch_m68k:
- if (! info->shared && (h->flags & SUNOS_DEF_REGULAR) != 0)
- abort ();
- bfd_put_16 (output_bfd, M68K_PLT_ENTRY_WORD0, p);
- bfd_put_32 (output_bfd, (- (h->plt_offset + 2)), p + 2);
- bfd_put_16 (output_bfd, s->reloc_count, p + 6);
- r_address += 2;
- break;
-
- default:
- abort ();
- }
-
- /* We also need to add a jump table reloc, unless this is the
- result of a JMP_TBL reloc from PIC compiled code. */
- if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0)
- {
- BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
- < s->_raw_size);
- p = s->contents + s->reloc_count * obj_reloc_entry_size (output_bfd);
- if (obj_reloc_entry_size (output_bfd) == RELOC_STD_SIZE)
- {
- struct reloc_std_external *srel;
-
- srel = (struct reloc_std_external *) p;
- PUT_WORD (output_bfd, r_address, srel->r_address);
- if (bfd_header_big_endian (output_bfd))
- {
- srel->r_index[0] = h->dynindx >> 16;
- srel->r_index[1] = h->dynindx >> 8;
- srel->r_index[2] = h->dynindx;
- srel->r_type[0] = (RELOC_STD_BITS_EXTERN_BIG
- | RELOC_STD_BITS_JMPTABLE_BIG);
- }
- else
- {
- srel->r_index[2] = h->dynindx >> 16;
- srel->r_index[1] = h->dynindx >> 8;
- srel->r_index[0] = h->dynindx;
- srel->r_type[0] = (RELOC_STD_BITS_EXTERN_LITTLE
- | RELOC_STD_BITS_JMPTABLE_LITTLE);
- }
- }
- else
- {
- struct reloc_ext_external *erel;
-
- erel = (struct reloc_ext_external *) p;
- PUT_WORD (output_bfd, r_address, erel->r_address);
- if (bfd_header_big_endian (output_bfd))
- {
- erel->r_index[0] = h->dynindx >> 16;
- erel->r_index[1] = h->dynindx >> 8;
- erel->r_index[2] = h->dynindx;
- erel->r_type[0] =
- (RELOC_EXT_BITS_EXTERN_BIG
- | (RELOC_JMP_SLOT << RELOC_EXT_BITS_TYPE_SH_BIG));
- }
- else
- {
- erel->r_index[2] = h->dynindx >> 16;
- erel->r_index[1] = h->dynindx >> 8;
- erel->r_index[0] = h->dynindx;
- erel->r_type[0] =
- (RELOC_EXT_BITS_EXTERN_LITTLE
- | (RELOC_JMP_SLOT << RELOC_EXT_BITS_TYPE_SH_LITTLE));
- }
- PUT_WORD (output_bfd, (bfd_vma) 0, erel->r_addend);
- }
-
- ++s->reloc_count;
- }
- }
-
- return true;
-}
-
-/* This is called for each reloc against an external symbol. If this
- is a reloc which are are going to copy as a dynamic reloc, then
- copy it over, and tell the caller to not bother processing this
- reloc. */
-
-/*ARGSUSED*/
-static boolean
-sunos_check_dynamic_reloc (info, input_bfd, input_section, harg, reloc,
- contents, skip, relocationp)
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- struct aout_link_hash_entry *harg;
- PTR reloc;
- bfd_byte *contents;
- boolean *skip;
- bfd_vma *relocationp;
-{
- struct sunos_link_hash_entry *h = (struct sunos_link_hash_entry *) harg;
- bfd *dynobj;
- boolean baserel;
- boolean jmptbl;
- asection *s;
- bfd_byte *p;
- long indx;
-
- *skip = false;
-
- dynobj = sunos_hash_table (info)->dynobj;
-
- if (h != NULL && h->plt_offset != 0)
- {
- asection *splt;
-
- /* Redirect the relocation to the PLT entry. */
- splt = bfd_get_section_by_name (dynobj, ".plt");
- *relocationp = (splt->output_section->vma
- + splt->output_offset
- + h->plt_offset);
- }
-
- if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
- {
- struct reloc_std_external *srel;
-
- srel = (struct reloc_std_external *) reloc;
- if (bfd_header_big_endian (input_bfd))
- {
- baserel = (0 != (srel->r_type[0] & RELOC_STD_BITS_BASEREL_BIG));
- jmptbl = (0 != (srel->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG));
- }
- else
- {
- baserel = (0 != (srel->r_type[0] & RELOC_STD_BITS_BASEREL_LITTLE));
- jmptbl = (0 != (srel->r_type[0] & RELOC_STD_BITS_JMPTABLE_LITTLE));
- }
- }
- else
- {
- struct reloc_ext_external *erel;
- int r_type;
-
- erel = (struct reloc_ext_external *) reloc;
- if (bfd_header_big_endian (input_bfd))
- r_type = ((erel->r_type[0] & RELOC_EXT_BITS_TYPE_BIG)
- >> RELOC_EXT_BITS_TYPE_SH_BIG);
- else
- r_type = ((erel->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE)
- >> RELOC_EXT_BITS_TYPE_SH_LITTLE);
- baserel = (r_type == RELOC_BASE10
- || r_type == RELOC_BASE13
- || r_type == RELOC_BASE22);
- jmptbl = r_type == RELOC_JMP_TBL;
- }
-
- if (baserel)
- {
- bfd_vma *got_offsetp;
- asection *sgot;
-
- if (h != NULL)
- got_offsetp = &h->got_offset;
- else if (adata (input_bfd).local_got_offsets == NULL)
- got_offsetp = NULL;
- else
- {
- struct reloc_std_external *srel;
- int r_index;
-
- srel = (struct reloc_std_external *) reloc;
- if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
- {
- if (bfd_header_big_endian (input_bfd))
- r_index = ((srel->r_index[0] << 16)
- | (srel->r_index[1] << 8)
- | srel->r_index[2]);
- else
- r_index = ((srel->r_index[2] << 16)
- | (srel->r_index[1] << 8)
- | srel->r_index[0]);
- }
- else
- {
- struct reloc_ext_external *erel;
-
- erel = (struct reloc_ext_external *) reloc;
- if (bfd_header_big_endian (input_bfd))
- r_index = ((erel->r_index[0] << 16)
- | (erel->r_index[1] << 8)
- | erel->r_index[2]);
- else
- r_index = ((erel->r_index[2] << 16)
- | (erel->r_index[1] << 8)
- | erel->r_index[0]);
- }
-
- got_offsetp = adata (input_bfd).local_got_offsets + r_index;
- }
-
- BFD_ASSERT (got_offsetp != NULL && *got_offsetp != 0);
-
- sgot = bfd_get_section_by_name (dynobj, ".got");
-
- /* We set the least significant bit to indicate whether we have
- already initialized the GOT entry. */
- if ((*got_offsetp & 1) == 0)
- {
- if (h == NULL
- || (! info->shared
- && ((h->flags & SUNOS_DEF_DYNAMIC) == 0
- || (h->flags & SUNOS_DEF_REGULAR) != 0)))
- PUT_WORD (dynobj, *relocationp, sgot->contents + *got_offsetp);
- else
- PUT_WORD (dynobj, 0, sgot->contents + *got_offsetp);
-
- if (info->shared
- || (h != NULL
- && (h->flags & SUNOS_DEF_DYNAMIC) != 0
- && (h->flags & SUNOS_DEF_REGULAR) == 0))
- {
- /* We need to create a GLOB_DAT or 32 reloc to tell the
- dynamic linker to fill in this entry in the table. */
-
- s = bfd_get_section_by_name (dynobj, ".dynrel");
- BFD_ASSERT (s != NULL);
- BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
- < s->_raw_size);
-
- p = (s->contents
- + s->reloc_count * obj_reloc_entry_size (dynobj));
-
- if (h != NULL)
- indx = h->dynindx;
- else
- indx = 0;
-
- if (obj_reloc_entry_size (dynobj) == RELOC_STD_SIZE)
- {
- struct reloc_std_external *srel;
-
- srel = (struct reloc_std_external *) p;
- PUT_WORD (dynobj,
- (*got_offsetp
- + sgot->output_section->vma
- + sgot->output_offset),
- srel->r_address);
- if (bfd_header_big_endian (dynobj))
- {
- srel->r_index[0] = indx >> 16;
- srel->r_index[1] = indx >> 8;
- srel->r_index[2] = indx;
- if (h == NULL)
- srel->r_type[0] = 2 << RELOC_STD_BITS_LENGTH_SH_BIG;
- else
- srel->r_type[0] =
- (RELOC_STD_BITS_EXTERN_BIG
- | RELOC_STD_BITS_BASEREL_BIG
- | RELOC_STD_BITS_RELATIVE_BIG
- | (2 << RELOC_STD_BITS_LENGTH_SH_BIG));
- }
- else
- {
- srel->r_index[2] = indx >> 16;
- srel->r_index[1] = indx >> 8;
- srel->r_index[0] = indx;
- if (h == NULL)
- srel->r_type[0] = 2 << RELOC_STD_BITS_LENGTH_SH_LITTLE;
- else
- srel->r_type[0] =
- (RELOC_STD_BITS_EXTERN_LITTLE
- | RELOC_STD_BITS_BASEREL_LITTLE
- | RELOC_STD_BITS_RELATIVE_LITTLE
- | (2 << RELOC_STD_BITS_LENGTH_SH_LITTLE));
- }
- }
- else
- {
- struct reloc_ext_external *erel;
-
- erel = (struct reloc_ext_external *) p;
- PUT_WORD (dynobj,
- (*got_offsetp
- + sgot->output_section->vma
- + sgot->output_offset),
- erel->r_address);
- if (bfd_header_big_endian (dynobj))
- {
- erel->r_index[0] = indx >> 16;
- erel->r_index[1] = indx >> 8;
- erel->r_index[2] = indx;
- if (h == NULL)
- erel->r_type[0] =
- RELOC_32 << RELOC_EXT_BITS_TYPE_SH_BIG;
- else
- erel->r_type[0] =
- (RELOC_EXT_BITS_EXTERN_BIG
- | (RELOC_GLOB_DAT << RELOC_EXT_BITS_TYPE_SH_BIG));
- }
- else
- {
- erel->r_index[2] = indx >> 16;
- erel->r_index[1] = indx >> 8;
- erel->r_index[0] = indx;
- if (h == NULL)
- erel->r_type[0] =
- RELOC_32 << RELOC_EXT_BITS_TYPE_SH_LITTLE;
- else
- erel->r_type[0] =
- (RELOC_EXT_BITS_EXTERN_LITTLE
- | (RELOC_GLOB_DAT
- << RELOC_EXT_BITS_TYPE_SH_LITTLE));
- }
- PUT_WORD (dynobj, 0, erel->r_addend);
- }
-
- ++s->reloc_count;
- }
-
- *got_offsetp |= 1;
- }
-
- *relocationp = sgot->vma + (*got_offsetp &~ 1);
-
- /* There is nothing else to do for a base relative reloc. */
- return true;
- }
-
- if (! sunos_hash_table (info)->dynamic_sections_needed)
- return true;
- if (! info->shared)
- {
- if (h == NULL
- || h->dynindx == -1
- || h->root.root.type != bfd_link_hash_undefined
- || (h->flags & SUNOS_DEF_REGULAR) != 0
- || (h->flags & SUNOS_DEF_DYNAMIC) == 0
- || (h->root.root.u.undef.abfd->flags & DYNAMIC) == 0)
- return true;
- }
- else
- {
- if (h != NULL
- && (h->dynindx == -1
- || jmptbl
- || strcmp (h->root.root.root.string,
- "__GLOBAL_OFFSET_TABLE_") == 0))
- return true;
- }
-
- /* It looks like this is a reloc we are supposed to copy. */
-
- s = bfd_get_section_by_name (dynobj, ".dynrel");
- BFD_ASSERT (s != NULL);
- BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->_raw_size);
-
- p = s->contents + s->reloc_count * obj_reloc_entry_size (dynobj);
-
- /* Copy the reloc over. */
- memcpy (p, reloc, obj_reloc_entry_size (dynobj));
-
- if (h != NULL)
- indx = h->dynindx;
- else
- indx = 0;
-
- /* Adjust the address and symbol index. */
- if (obj_reloc_entry_size (dynobj) == RELOC_STD_SIZE)
- {
- struct reloc_std_external *srel;
-
- srel = (struct reloc_std_external *) p;
- PUT_WORD (dynobj,
- (GET_WORD (dynobj, srel->r_address)
- + input_section->output_section->vma
- + input_section->output_offset),
- srel->r_address);
- if (bfd_header_big_endian (dynobj))
- {
- srel->r_index[0] = indx >> 16;
- srel->r_index[1] = indx >> 8;
- srel->r_index[2] = indx;
- }
- else
- {
- srel->r_index[2] = indx >> 16;
- srel->r_index[1] = indx >> 8;
- srel->r_index[0] = indx;
- }
- }
- else
- {
- struct reloc_ext_external *erel;
-
- erel = (struct reloc_ext_external *) p;
- PUT_WORD (dynobj,
- (GET_WORD (dynobj, erel->r_address)
- + input_section->output_section->vma
- + input_section->output_offset),
- erel->r_address);
- if (bfd_header_big_endian (dynobj))
- {
- erel->r_index[0] = indx >> 16;
- erel->r_index[1] = indx >> 8;
- erel->r_index[2] = indx;
- }
- else
- {
- erel->r_index[2] = indx >> 16;
- erel->r_index[1] = indx >> 8;
- erel->r_index[0] = indx;
- }
- }
-
- ++s->reloc_count;
-
- if (h != NULL)
- *skip = true;
-
- return true;
-}
-
-/* Finish up the dynamic linking information. */
-
-static boolean
-sunos_finish_dynamic_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- bfd *dynobj;
- asection *o;
- asection *s;
- asection *sdyn;
- struct external_sun4_dynamic esd;
- struct external_sun4_dynamic_link esdl;
-
- if (! sunos_hash_table (info)->dynamic_sections_needed)
- return true;
-
- dynobj = sunos_hash_table (info)->dynobj;
-
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
- BFD_ASSERT (sdyn != NULL);
-
- /* Finish up the .need section. The linker emulation code filled it
- in, but with offsets from the start of the section instead of
- real addresses. Now that we know the section location, we can
- fill in the final values. */
- s = bfd_get_section_by_name (dynobj, ".need");
- if (s != NULL && s->_raw_size != 0)
- {
- file_ptr filepos;
- bfd_byte *p;
-
- filepos = s->output_section->filepos + s->output_offset;
- p = s->contents;
- while (1)
- {
- bfd_vma val;
-
- PUT_WORD (dynobj, GET_WORD (dynobj, p) + filepos, p);
- val = GET_WORD (dynobj, p + 12);
- if (val == 0)
- break;
- PUT_WORD (dynobj, val + filepos, p + 12);
- p += 16;
- }
- }
-
- /* The first entry in the .got section is the address of the
- dynamic information, unless this is a shared library. */
- s = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (s != NULL);
- if (info->shared)
- PUT_WORD (dynobj, 0, s->contents);
- else
- PUT_WORD (dynobj, sdyn->output_section->vma + sdyn->output_offset,
- s->contents);
-
- for (o = dynobj->sections; o != NULL; o = o->next)
- {
- if ((o->flags & SEC_HAS_CONTENTS) != 0
- && o->contents != NULL)
- {
- BFD_ASSERT (o->output_section != NULL
- && o->output_section->owner == abfd);
- if (! bfd_set_section_contents (abfd, o->output_section,
- o->contents, o->output_offset,
- o->_raw_size))
- return false;
- }
- }
-
- /* Finish up the dynamic link information. */
- PUT_WORD (dynobj, (bfd_vma) 3, esd.ld_version);
- PUT_WORD (dynobj,
- sdyn->output_section->vma + sdyn->output_offset + sizeof esd,
- esd.ldd);
- PUT_WORD (dynobj,
- (sdyn->output_section->vma
- + sdyn->output_offset
- + sizeof esd
- + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE),
- esd.ld);
-
- if (! bfd_set_section_contents (abfd, sdyn->output_section, &esd,
- sdyn->output_offset, sizeof esd))
- return false;
-
-
- PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_loaded);
-
- s = bfd_get_section_by_name (dynobj, ".need");
- if (s == NULL || s->_raw_size == 0)
- PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_need);
- else
- PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
- esdl.ld_need);
-
- s = bfd_get_section_by_name (dynobj, ".rules");
- if (s == NULL || s->_raw_size == 0)
- PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_rules);
- else
- PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
- esdl.ld_rules);
-
- s = bfd_get_section_by_name (dynobj, ".got");
- BFD_ASSERT (s != NULL);
- PUT_WORD (dynobj, s->output_section->vma + s->output_offset, esdl.ld_got);
-
- s = bfd_get_section_by_name (dynobj, ".plt");
- BFD_ASSERT (s != NULL);
- PUT_WORD (dynobj, s->output_section->vma + s->output_offset, esdl.ld_plt);
- PUT_WORD (dynobj, s->_raw_size, esdl.ld_plt_sz);
-
- s = bfd_get_section_by_name (dynobj, ".dynrel");
- BFD_ASSERT (s != NULL);
- BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) == s->_raw_size);
- PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
- esdl.ld_rel);
-
- s = bfd_get_section_by_name (dynobj, ".hash");
- BFD_ASSERT (s != NULL);
- PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
- esdl.ld_hash);
-
- s = bfd_get_section_by_name (dynobj, ".dynsym");
- BFD_ASSERT (s != NULL);
- PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
- esdl.ld_stab);
-
- PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_stab_hash);
-
- PUT_WORD (dynobj, (bfd_vma) sunos_hash_table (info)->bucketcount,
- esdl.ld_buckets);
-
- s = bfd_get_section_by_name (dynobj, ".dynstr");
- BFD_ASSERT (s != NULL);
- PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
- esdl.ld_symbols);
- PUT_WORD (dynobj, s->_raw_size, esdl.ld_symb_size);
-
- /* The size of the text area is the size of the .text section
- rounded up to a page boundary. FIXME: Should the page size be
- conditional on something? */
- PUT_WORD (dynobj,
- BFD_ALIGN (obj_textsec (abfd)->_raw_size, 0x2000),
- esdl.ld_text);
-
- if (! bfd_set_section_contents (abfd, sdyn->output_section, &esdl,
- (sdyn->output_offset
- + sizeof esd
- + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE),
- sizeof esdl))
- return false;
-
- abfd->flags |= DYNAMIC;
-
- return true;
-}
diff --git a/contrib/gdb/bfd/trad-core.c b/contrib/gdb/bfd/trad-core.c
index 09c74ae..62d6192 100644
--- a/contrib/gdb/bfd/trad-core.c
+++ b/contrib/gdb/bfd/trad-core.c
@@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
-#include <sys/dir.h>
#include <signal.h>
#include <sys/user.h> /* After a.out.h */
diff --git a/contrib/gdb/bfd/versados.c b/contrib/gdb/bfd/versados.c
deleted file mode 100644
index 84ad114..0000000
--- a/contrib/gdb/bfd/versados.c
+++ /dev/null
@@ -1,906 +0,0 @@
-/* BFD back-end for VERSAdos-E objects.
-
- Versados is a Motorola trademark.
-
- Copyright 1995 Free Software Foundation, Inc.
- Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
-
- This file is part of BFD, the Binary File Descriptor library.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
- SUBSECTION
- VERSAdos-E relocateable object file format
-
- DESCRIPTION
-
- This module supports reading of VERSAdos relocateable
- object files.
-
- A VERSAdos file looks like contains
-
- o Indentification Record
- o External Symbol Definition Record
- o Object Text Recrod
- o End Record
-
-
- */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "libbfd.h"
-#include "libiberty.h"
-
-
-static boolean versados_mkobject PARAMS ((bfd *));
-static boolean versados_scan PARAMS ((bfd *));
-static const bfd_target *versados_object_p PARAMS ((bfd *));
-
-
-#define VHEADER '1'
-#define VESTDEF '2'
-#define VOTR '3'
-#define VEND '4'
-
-
-#define ES_BASE 17 /* first symbol has esdid 17 */
-
-/* Per file target dependent information */
-
-/* one for each section */
-struct esdid
- {
- asection *section; /* ptr to bfd version */
- unsigned char *contents; /* used to build image */
- int pc;
- int relocs; /* reloc count, valid end of pass 1 */
- int donerel; /* have relocs been translated */
- };
-
-typedef struct versados_data_struct
- {
- int es_done; /* count of symbol index, starts at ES_BASE */
- asymbol *symbols; /* pointer to local symbols */
- char *strings; /* strings of all the above */
- int stringlen; /* len of string table (valid end of pass1) */
- int nsecsyms; /* number of sections */
-
- int ndefs; /* number of exported symbols (they dont get esdids) */
- int nrefs; /* number of imported symbols (valid end of pass1) */
-
- int ref_idx; /* current processed value of the above */
- int def_idx;
-
- int pass_2_done;
-
- struct esdid e[16]; /* per section info */
- int alert; /* to see if we're trampling */
- asymbol *rest[256 - 16]; /* per symbol info */
-
- }
-tdata_type;
-
-#define VDATA(abfd) (abfd->tdata.versados_data)
-#define EDATA(abfd, n) (abfd->tdata.versados_data->e[n])
-#define RDATA(abfd, n) (abfd->tdata.versados_data->rest[n])
-
-struct ext_otr
- {
- unsigned char size;
- char type;
- unsigned char map[4];
- unsigned char esdid;
- unsigned char data[200];
- };
-
-struct ext_vheader
- {
- unsigned char size;
- char type; /* record type */
- char name[10]; /* module name */
- char rev; /* module rev number */
- char lang;
- char vol[4];
- char user[2];
- char cat[8];
- char fname[8];
- char ext[2];
- char time[3];
- char date[3];
- char rest[211];
- };
-
-struct ext_esd
- {
- unsigned char size;
- char type;
- unsigned char esd_entries[1];
- };
-#define ESD_ABS 0
-#define ESD_COMMON 1
-#define ESD_STD_REL_SEC 2
-#define ESD_SHRT_REL_SEC 3
-#define ESD_XDEF_IN_SEC 4
-#define ESD_XREF_SYM 7
-#define ESD_XREF_SEC 6
-#define ESD_XDEF_IN_ABS 5
-union ext_any
- {
- unsigned char size;
- struct ext_vheader header;
- struct ext_esd esd;
- struct ext_otr otr;
- };
-
-/* Initialize by filling in the hex conversion array. */
-
-
-
-
-
-/* Set up the tdata information. */
-
-static boolean
-versados_mkobject (abfd)
- bfd *abfd;
-{
- if (abfd->tdata.versados_data == NULL)
- {
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
- if (tdata == NULL)
- return false;
- abfd->tdata.versados_data = tdata;
- tdata->symbols = NULL;
- VDATA (abfd)->alert = 0x12345678;
- }
-
- bfd_default_set_arch_mach (abfd, bfd_arch_m68k, 0);
- return true;
-}
-
-
-/* Report a problem in an S record file. FIXME: This probably should
- not call fprintf, but we really do need some mechanism for printing
- error messages. */
-
-
-
-static asymbol *
-versados_new_symbol (abfd, snum, name, val, sec)
- bfd *abfd;
- int snum;
- const char *name;
- bfd_vma val;
- asection *sec;
-{
- asymbol *n = VDATA (abfd)->symbols + snum;
- n->name = name;
- n->value = val;
- n->section = sec;
- n->the_bfd = abfd;
- n->flags = 0;
- return n;
-}
-
-
-static int
-get_record (abfd, ptr)
- bfd *abfd;
- union ext_any *ptr;
-{
- bfd_read (&ptr->size, 1, 1, abfd);
- if (bfd_read ((char *) ptr + 1, 1, ptr->size, abfd) != ptr->size)
- return 0;
- return 1;
-}
-
-int
-get_4 (pp)
- unsigned char **pp;
-{
- unsigned char *p = *pp;
- *pp += 4;
- return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3] << 0);
-}
-
-void
-get_10 (pp, name)
- unsigned char **pp;
- char *name;
-{
- char *p = (char *) *pp;
- int len = 10;
- *pp += len;
- while (*p != ' '
- && len)
- {
- *name++ = *p++;
- len--;
- }
- *name = 0;
-}
-
-static char *
-new_symbol_string (abfd, name)
- bfd *abfd;
- char *name;
-{
- char *n = VDATA (abfd)->strings;
- strcpy (VDATA (abfd)->strings, name);
- VDATA (abfd)->strings += strlen (VDATA (abfd)->strings) + 1;
- return n;
-}
-
-
-static void
-process_esd (abfd, esd, pass)
- bfd *abfd;
- struct ext_esd *esd;
- int pass;
-{
- /* Read through the ext def for the est entries */
- int togo = esd->size - 2;
- bfd_vma size;
- bfd_vma start;
- asection *sec;
- char name[11];
- unsigned char *ptr = esd->esd_entries;
- unsigned char *end = ptr + togo;
- while (ptr < end)
- {
- int scn = *ptr & 0xf;
- int typ = (*ptr >> 4) & 0xf;
-
- /* Declare this section */
- sprintf (name, "%d", scn);
- sec = bfd_make_section_old_way (abfd, strdup (name));
- sec->target_index = scn;
- EDATA (abfd, scn).section = sec;
- ptr++;
- switch (typ)
- {
- default:
- abort ();
- case ESD_XREF_SEC:
- case ESD_XREF_SYM:
- {
- int snum = VDATA (abfd)->ref_idx++;
- get_10 (&ptr, name);
- if (pass == 1)
- {
- VDATA (abfd)->stringlen += strlen (name) + 1;
- }
- else
- {
- int esidx;
- asymbol *s;
- char *n = new_symbol_string (abfd, name);
- s = versados_new_symbol (abfd, snum, n, 0,
- &bfd_und_section, scn);
- esidx = VDATA (abfd)->es_done++;
- RDATA (abfd, esidx - ES_BASE) = s;
- }
- }
- break;
-
-
- case ESD_ABS:
- size = get_4 (&ptr);
- start = get_4 (&ptr);
- break;
- case ESD_STD_REL_SEC:
- case ESD_SHRT_REL_SEC:
- {
- sec->_raw_size = get_4 (&ptr);
- sec->flags |= SEC_ALLOC;
- }
- break;
- case ESD_XDEF_IN_ABS:
- sec = (asection *) & bfd_abs_section;
- case ESD_XDEF_IN_SEC:
- {
- int snum = VDATA (abfd)->def_idx++;
- long val;
- get_10 (&ptr, name);
- val = get_4 (&ptr);
- if (pass == 1)
- {
- /* Just remember the symbol */
- VDATA (abfd)->stringlen += strlen (name) + 1;
- }
- else
- {
- asymbol *s;
- char *n = new_symbol_string (abfd, name);
- s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n, val, sec, scn);
- s->flags |= BSF_GLOBAL;
- }
- }
- break;
- }
- }
-}
-
-#define R_RELWORD 1
-#define R_RELLONG 2
-#define R_RELWORD_NEG 3
-#define R_RELLONG_NEG 4
-
-reloc_howto_type versados_howto_table[] =
-{
- HOWTO (R_RELWORD, 0, 1, 16, false,
- 0, complain_overflow_dont, 0,
- "+v16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_RELLONG, 0, 2, 32, false,
- 0, complain_overflow_dont, 0,
- "+v32", true, 0xffffffff, 0xffffffff, false),
-
- HOWTO (R_RELWORD_NEG, 0, -1, 16, false,
- 0, complain_overflow_dont, 0,
- "-v16", true, 0x0000ffff, 0x0000ffff, false),
- HOWTO (R_RELLONG_NEG, 0, -2, 32, false,
- 0, complain_overflow_dont, 0,
- "-v32", true, 0xffffffff, 0xffffffff, false),
-};
-
-
-static int
-get_offset (len, ptr)
- int len;
- unsigned char *ptr;
-{
- int val = 0;
- if (len)
- {
- int i;
- val = *ptr++;
- if (val & 0x80)
- val |= ~0xff;
- for (i = 1; i < len; i++)
- val = (val << 8) | *ptr++;
- }
-
- return val;
-}
-
-static void
-process_otr (abfd, otr, pass)
- bfd *abfd;
- struct ext_otr *otr;
- int pass;
-{
- unsigned long shift;
- unsigned char *srcp = otr->data;
- unsigned char *endp = (unsigned char *) otr + otr->size;
- unsigned int bits = (otr->map[0] << 24)
- | (otr->map[1] << 16)
- | (otr->map[2] << 8)
- | (otr->map[3] << 0);
-
- struct esdid *esdid = &EDATA (abfd, otr->esdid - 1);
- unsigned char *contents = esdid->contents;
- int need_contents = 0;
- unsigned int dst_idx = esdid->pc;
-
- for (shift = (1 << 31); shift && srcp < endp; shift >>= 1)
- {
- if (bits & shift)
- {
- int flag = *srcp++;
- int esdids = (flag >> 5) & 0x7;
- int sizeinwords = ((flag >> 3) & 1) ? 2 : 1;
- int offsetlen = flag & 0x7;
- int j;
-
-
- if (esdids == 0)
- {
- /* A zero esdid means the new pc is the offset given */
- dst_idx += get_offset (offsetlen, srcp);
- srcp += offsetlen;
- }
- else
- {
- int val = get_offset (offsetlen, srcp + esdids);
- if (pass == 1)
- need_contents = 1;
- else
- for (j = 0; j < sizeinwords * 2; j++)
- {
- contents[dst_idx + (sizeinwords * 2) - j - 1] = val;
- val >>= 8;
- }
-
- for (j = 0; j < esdids; j++)
- {
- int esdid = *srcp++;
-
- if (esdid)
- {
- int rn = EDATA (abfd, otr->esdid - 1).relocs++;
- if (pass == 1)
- {
- /* this is the first pass over the data,
- just remember that we need a reloc */
- }
- else
- {
- arelent *n =
- EDATA (abfd, otr->esdid - 1).section->relocation + rn;
- n->address = dst_idx;
-
- n->sym_ptr_ptr = (asymbol **) esdid;
- n->addend = 0;
- n->howto = versados_howto_table + ((j & 1) * 2) + (sizeinwords - 1);
- }
- }
- }
- srcp += offsetlen;
- dst_idx += sizeinwords * 2;
- }
- }
- else
- {
- need_contents = 1;
- if (dst_idx < esdid->section->_raw_size)
- if (pass == 2)
- {
- /* absolute code, comes in 16 bit lumps */
- contents[dst_idx] = srcp[0];
- contents[dst_idx + 1] = srcp[1];
- }
- dst_idx += 2;
- srcp += 2;
- }
- }
- EDATA (abfd, otr->esdid - 1).pc = dst_idx;
-
- if (!contents && need_contents)
- esdid->contents = (unsigned char *) bfd_alloc (abfd, esdid->section->_raw_size);
-
-
-}
-
-static boolean
-versados_scan (abfd)
- bfd *abfd;
-{
- int loop = 1;
- int i;
- int j;
- int nsecs = 0;
-
- VDATA (abfd)->nrefs = 0;
- VDATA (abfd)->ndefs = 0;
- VDATA (abfd)->ref_idx = 0;
- VDATA (abfd)->def_idx = 0;
-
- while (loop)
- {
- union ext_any any;
- if (!get_record (abfd, &any))
- return true;
- switch (any.header.type)
- {
- case VHEADER:
- break;
- case VEND:
- loop = 0;
- break;
- case VESTDEF:
- process_esd (abfd, &any.esd, 1);
- break;
- case VOTR:
- process_otr (abfd, &any.otr, 1);
- break;
- }
- }
-
- /* Now allocate space for the relocs and sections */
-
- VDATA (abfd)->nrefs = VDATA (abfd)->ref_idx;
- VDATA (abfd)->ndefs = VDATA (abfd)->def_idx;
- VDATA (abfd)->ref_idx = 0;
- VDATA (abfd)->def_idx = 0;
-
- abfd->symcount = VDATA (abfd)->nrefs + VDATA (abfd)->ndefs;
-
- for (i = 0; i < 16; i++)
- {
- struct esdid *esdid = &EDATA (abfd, i);
- if (esdid->section)
- {
- esdid->section->relocation
- = (arelent *) bfd_alloc (abfd, sizeof (arelent) * esdid->relocs);
-
- esdid->pc = 0;
-
- if (esdid->contents)
- esdid->section->flags |= SEC_HAS_CONTENTS | SEC_LOAD;
-
- esdid->section->reloc_count = esdid->relocs;
- if (esdid->relocs)
- esdid->section->flags |= SEC_RELOC;
-
- esdid->relocs = 0;
-
- /* Add an entry into the symbol table for it */
- nsecs++;
- VDATA (abfd)->stringlen += strlen (esdid->section->name) + 1;
- }
- }
-
- abfd->symcount += nsecs;
-
- VDATA (abfd)->symbols = (asymbol *) bfd_alloc (abfd,
- sizeof (asymbol) * (abfd->symcount));
-
- VDATA (abfd)->strings = bfd_alloc (abfd, VDATA (abfd)->stringlen);
-
-
- /* Actually fill in the section symbols,
- we stick them at the end of the table */
-
- for (j = VDATA (abfd)->nrefs + VDATA (abfd)->ndefs, i = 0; i < 16; i++)
- {
- struct esdid *esdid = &EDATA (abfd, i);
- asection *sec = esdid->section;
- if (sec)
- {
- asymbol *s = VDATA (abfd)->symbols + j;
- s->name = new_symbol_string (abfd, sec->name);
- s->section = sec;
- s->flags = BSF_LOCAL;
- s->value = 0;
- s->the_bfd = abfd;
- j++;
- }
- }
- if (abfd->symcount)
- abfd->flags |= HAS_SYMS;
-
- /* Set this to nsecs - since we've already planted the section
- symbols */
- VDATA (abfd)->nsecsyms = nsecs;
-
- VDATA (abfd)->ref_idx = 0;
-
- return 1;
-}
-
-
-
-/* Check whether an existing file is a versados file. */
-
-static const bfd_target *
-versados_object_p (abfd)
- bfd *abfd;
-{
- struct ext_vheader ext;
- unsigned char len;
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
- return NULL;
-
-
- bfd_read (&len, 1, 1, abfd);
- if (bfd_read (&ext.type, 1, len, abfd) != len
- || ext.type != '1')
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
- /* ok, looks like a record, build the tdata and read
- in.. */
-
- if (!versados_mkobject (abfd)
- || !versados_scan (abfd))
- return NULL;
-
- return abfd->xvec;
-}
-
-
-static boolean
-versados_pass_2 (abfd)
- bfd *abfd;
-{
- union ext_any any;
-
- if (VDATA (abfd)->pass_2_done)
- return 1;
-
- if (bfd_seek (abfd, 0, SEEK_SET) != 0)
- return 0;
-
- VDATA (abfd)->es_done = ES_BASE;
-
-
- /* read records till we get to where we want to be */
-
- while (1)
- {
- get_record (abfd, &any);
- switch (any.header.type)
- {
- case VEND:
- VDATA (abfd)->pass_2_done = 1;
- return 1;
- case VESTDEF:
- process_esd (abfd, &any.esd, 2);
- break;
- case VOTR:
- process_otr (abfd, &any.otr, 2);
- break;
- }
- }
-}
-
-static boolean
-versados_get_section_contents (abfd, section, location, offset, count)
- bfd *abfd;
- asection *section;
- PTR location;
- file_ptr offset;
- bfd_size_type count;
-{
- if (!versados_pass_2 (abfd))
- return false;
-
- memcpy (location,
- EDATA (abfd, section->target_index).contents + offset,
- (size_t) count);
-
- return true;
-}
-
-#define versados_get_section_contents_in_window \
- _bfd_generic_get_section_contents_in_window
-
-static boolean
-versados_set_section_contents (abfd, section, location, offset, bytes_to_do)
- bfd *abfd;
- sec_ptr section;
- PTR location;
- file_ptr offset;
- bfd_size_type bytes_to_do;
-{
- return false;
-}
-
-
-/*ARGSUSED */
-static int
-versados_sizeof_headers (abfd, exec)
- bfd *abfd;
- boolean exec;
-{
- return 0;
-}
-
-static asymbol *
-versados_make_empty_symbol (abfd)
- bfd *abfd;
-{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
- if (new)
- new->the_bfd = abfd;
- return new;
-}
-
-/* Return the amount of memory needed to read the symbol table. */
-
-static long
-versados_get_symtab_upper_bound (abfd)
- bfd *abfd;
-{
- return (bfd_get_symcount (abfd) + 1) * sizeof (asymbol *);
-}
-
-/* Return the symbol table. */
-
-static long
-versados_get_symtab (abfd, alocation)
- bfd *abfd;
- asymbol **alocation;
-{
- unsigned int symcount = bfd_get_symcount (abfd);
- unsigned int i;
- asymbol *s;
-
- versados_pass_2 (abfd);
-
- for (i = 0, s = VDATA (abfd)->symbols;
- i < symcount;
- s++, i++)
- {
- *alocation++ = s;
- }
-
- *alocation = NULL;
-
- return symcount;
-}
-
-/*ARGSUSED */
-void
-versados_get_symbol_info (ignore_abfd, symbol, ret)
- bfd *ignore_abfd;
- asymbol *symbol;
- symbol_info *ret;
-{
- bfd_symbol_info (symbol, ret);
-}
-
-/*ARGSUSED */
-void
-versados_print_symbol (ignore_abfd, afile, symbol, how)
- bfd *ignore_abfd;
- PTR afile;
- asymbol *symbol;
- bfd_print_symbol_type how;
-{
- FILE *file = (FILE *) afile;
- switch (how)
- {
- case bfd_print_symbol_name:
- fprintf (file, "%s", symbol->name);
- break;
- default:
- bfd_print_symbol_vandf ((PTR) file, symbol);
- fprintf (file, " %-5s %s",
- symbol->section->name,
- symbol->name);
-
- }
-}
-
-long
-versados_get_reloc_upper_bound (abfd, asect)
- bfd *abfd;
- sec_ptr asect;
-{
- return (asect->reloc_count + 1) * sizeof (arelent *);
-}
-
-
-long
-versados_canonicalize_reloc (abfd, section, relptr, symbols)
- bfd *abfd;
- sec_ptr section;
- arelent **relptr;
- asymbol **symbols;
-{
- unsigned int count;
- arelent *src;
-
- versados_pass_2 (abfd);
- src = section->relocation;
- if (!EDATA (abfd, section->target_index).donerel)
- {
- EDATA (abfd, section->target_index).donerel = 1;
- /* translate from indexes to symptr ptrs */
- for (count = 0; count < section->reloc_count; count++)
- {
- int esdid = (int) src[count].sym_ptr_ptr;
-
- if (esdid == 0)
- {
- src[count].sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
- }
- else if (esdid < ES_BASE) /* Section relative thing */
- {
- struct esdid *e = &EDATA (abfd, esdid - 1);
- if (!section)
- {
- /** relocation relative to section which was
- never declared ! */
- }
- src[count].sym_ptr_ptr = e->section->symbol_ptr_ptr;
- }
- else
- {
- src[count].sym_ptr_ptr = symbols + esdid - ES_BASE;
- }
-
- }
- }
-
- for (count = 0; count < section->reloc_count; count++)
- {
- *relptr++ = src++;
- }
- *relptr = 0;
- return section->reloc_count;
-}
-
-#define versados_close_and_cleanup _bfd_generic_close_and_cleanup
-#define versados_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
-#define versados_new_section_hook _bfd_generic_new_section_hook
-
-#define versados_bfd_is_local_label bfd_generic_is_local_label
-#define versados_get_lineno _bfd_nosymbols_get_lineno
-#define versados_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define versados_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define versados_read_minisymbols _bfd_generic_read_minisymbols
-#define versados_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define versados_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
-
-#define versados_set_arch_mach bfd_default_set_arch_mach
-
-#define versados_bfd_get_relocated_section_contents \
- bfd_generic_get_relocated_section_contents
-#define versados_bfd_relax_section bfd_generic_relax_section
-#define versados_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define versados_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define versados_bfd_final_link _bfd_generic_final_link
-#define versados_bfd_link_split_section _bfd_generic_link_split_section
-
-const bfd_target versados_vec =
-{
- "versados", /* name */
- bfd_target_versados_flavour,
- BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIAN_BIG, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
- (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
- | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* leading underscore */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {
- _bfd_dummy_target,
- versados_object_p, /* bfd_check_format */
- _bfd_dummy_target,
- _bfd_dummy_target,
- },
- {
- bfd_false,
- versados_mkobject,
- _bfd_generic_mkarchive,
- bfd_false,
- },
- { /* bfd_write_contents */
- bfd_false,
- bfd_false,
- _bfd_write_archive_contents,
- bfd_false,
- },
-
- BFD_JUMP_TABLE_GENERIC (versados),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (versados),
- BFD_JUMP_TABLE_RELOCS (versados),
- BFD_JUMP_TABLE_WRITE (versados),
- BFD_JUMP_TABLE_LINK (versados),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- (PTR) 0
-};
diff --git a/contrib/gdb/bfd/xcofflink.c b/contrib/gdb/bfd/xcofflink.c
deleted file mode 100644
index 16a76cc..0000000
--- a/contrib/gdb/bfd/xcofflink.c
+++ /dev/null
@@ -1,5798 +0,0 @@
-/* POWER/PowerPC XCOFF linker support.
- Copyright 1995, 1996 Free Software Foundation, Inc.
- Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
-
-This file is part of BFD, the Binary File Descriptor library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "bfd.h"
-#include "sysdep.h"
-#include "bfdlink.h"
-#include "libbfd.h"
-#include "coff/internal.h"
-#include "libcoff.h"
-
-/* This file holds the XCOFF linker code. */
-
-#define STRING_SIZE_SIZE (4)
-
-/* In order to support linking different object file formats into an
- XCOFF format, we need to be able to determine whether a particular
- bfd_target is an XCOFF vector. FIXME: We need to rethink this
- whole approach. */
-#define XCOFF_XVECP(xv) \
- (strcmp ((xv)->name, "aixcoff-rs6000") == 0 \
- || strcmp ((xv)->name, "xcoff-powermac") == 0)
-
-/* Get the XCOFF hash table entries for a BFD. */
-#define obj_xcoff_sym_hashes(bfd) \
- ((struct xcoff_link_hash_entry **) obj_coff_sym_hashes (bfd))
-
-/* XCOFF relocation types. These probably belong in a header file
- somewhere. The relocations are described in the function
- _bfd_ppc_xcoff_relocate_section in this file. */
-
-#define R_POS (0x00)
-#define R_NEG (0x01)
-#define R_REL (0x02)
-#define R_TOC (0x03)
-#define R_RTB (0x04)
-#define R_GL (0x05)
-#define R_TCL (0x06)
-#define R_BA (0x08)
-#define R_BR (0x0a)
-#define R_RL (0x0c)
-#define R_RLA (0x0d)
-#define R_REF (0x0f)
-#define R_TRL (0x12)
-#define R_TRLA (0x13)
-#define R_RRTBI (0x14)
-#define R_RRTBA (0x15)
-#define R_CAI (0x16)
-#define R_CREL (0x17)
-#define R_RBA (0x18)
-#define R_RBAC (0x19)
-#define R_RBR (0x1a)
-#define R_RBRC (0x1b)
-
-/* The first word of global linkage code. This must be modified by
- filling in the correct TOC offset. */
-
-#define XCOFF_GLINK_FIRST (0x81820000) /* lwz r12,0(r2) */
-
-/* The remaining words of global linkage code. */
-
-static unsigned long xcoff_glink_code[] =
-{
- 0x90410014, /* stw r2,20(r1) */
- 0x800c0000, /* lwz r0,0(r12) */
- 0x804c0004, /* lwz r2,4(r12) */
- 0x7c0903a6, /* mtctr r0 */
- 0x4e800420, /* bctr */
- 0x0, /* start of traceback table */
- 0x000c8000, /* traceback table */
- 0x0 /* traceback table */
-};
-
-#define XCOFF_GLINK_SIZE \
- (((sizeof xcoff_glink_code / sizeof xcoff_glink_code[0]) * 4) + 4)
-
-/* We reuse the SEC_ROM flag as a mark flag for garbage collection.
- This flag will only be used on input sections. */
-
-#define SEC_MARK (SEC_ROM)
-
-/* The ldhdr structure. This appears at the start of the .loader
- section. */
-
-struct internal_ldhdr
-{
- /* The version number: currently always 1. */
- unsigned long l_version;
- /* The number of symbol table entries. */
- bfd_size_type l_nsyms;
- /* The number of relocation table entries. */
- bfd_size_type l_nreloc;
- /* The length of the import file string table. */
- bfd_size_type l_istlen;
- /* The number of import files. */
- bfd_size_type l_nimpid;
- /* The offset from the start of the .loader section to the first
- entry in the import file table. */
- bfd_size_type l_impoff;
- /* The length of the string table. */
- bfd_size_type l_stlen;
- /* The offset from the start of the .loader section to the first
- entry in the string table. */
- bfd_size_type l_stoff;
-};
-
-struct external_ldhdr
-{
- bfd_byte l_version[4];
- bfd_byte l_nsyms[4];
- bfd_byte l_nreloc[4];
- bfd_byte l_istlen[4];
- bfd_byte l_nimpid[4];
- bfd_byte l_impoff[4];
- bfd_byte l_stlen[4];
- bfd_byte l_stoff[4];
-};
-
-#define LDHDRSZ (8 * 4)
-
-/* The ldsym structure. This is used to represent a symbol in the
- .loader section. */
-
-struct internal_ldsym
-{
- union
- {
- /* The symbol name if <= SYMNMLEN characters. */
- char _l_name[SYMNMLEN];
- struct
- {
- /* Zero if the symbol name is more than SYMNMLEN characters. */
- long _l_zeroes;
- /* The offset in the string table if the symbol name is more
- than SYMNMLEN characters. */
- long _l_offset;
- } _l_l;
- } _l;
- /* The symbol value. */
- bfd_vma l_value;
- /* The symbol section number. */
- short l_scnum;
- /* The symbol type and flags. */
- char l_smtype;
- /* The symbol storage class. */
- char l_smclas;
- /* The import file ID. */
- bfd_size_type l_ifile;
- /* Offset to the parameter type check string. */
- bfd_size_type l_parm;
-};
-
-struct external_ldsym
-{
- union
- {
- bfd_byte _l_name[SYMNMLEN];
- struct
- {
- bfd_byte _l_zeroes[4];
- bfd_byte _l_offset[4];
- } _l_l;
- } _l;
- bfd_byte l_value[4];
- bfd_byte l_scnum[2];
- bfd_byte l_smtype[1];
- bfd_byte l_smclas[1];
- bfd_byte l_ifile[4];
- bfd_byte l_parm[4];
-};
-
-#define LDSYMSZ (8 + 3 * 4 + 2 + 2)
-
-/* These flags are for the l_smtype field (the lower three bits are an
- XTY_* value). */
-
-/* Imported symbol. */
-#define L_IMPORT (0x40)
-/* Entry point. */
-#define L_ENTRY (0x20)
-/* Exported symbol. */
-#define L_EXPORT (0x10)
-
-/* The ldrel structure. This is used to represent a reloc in the
- .loader section. */
-
-struct internal_ldrel
-{
- /* The reloc address. */
- bfd_vma l_vaddr;
- /* The symbol table index in the .loader section symbol table. */
- bfd_size_type l_symndx;
- /* The relocation type and size. */
- short l_rtype;
- /* The section number this relocation applies to. */
- short l_rsecnm;
-};
-
-struct external_ldrel
-{
- bfd_byte l_vaddr[4];
- bfd_byte l_symndx[4];
- bfd_byte l_rtype[2];
- bfd_byte l_rsecnm[2];
-};
-
-#define LDRELSZ (2 * 4 + 2 * 2)
-
-/* The list of import files. */
-
-struct xcoff_import_file
-{
- /* The next entry in the list. */
- struct xcoff_import_file *next;
- /* The path. */
- const char *path;
- /* The file name. */
- const char *file;
- /* The member name. */
- const char *member;
-};
-
-/* An entry in the XCOFF linker hash table. */
-
-struct xcoff_link_hash_entry
-{
- struct bfd_link_hash_entry root;
-
- /* Symbol index in output file. Set to -1 initially. Set to -2 if
- there is a reloc against this symbol. */
- long indx;
-
- /* If we have created a TOC entry for this symbol, this is the .tc
- section which holds it. */
- asection *toc_section;
-
- union
- {
- /* If we have created a TOC entry (the XCOFF_SET_TOC flag is
- set), this is the offset in toc_section. */
- bfd_vma toc_offset;
- /* If the TOC entry comes from an input file, this is set to the
- symbo lindex of the C_HIDEXT XMC_TC symbol. */
- long toc_indx;
- } u;
-
- /* If this symbol is a function entry point which is called, this
- field holds a pointer to the function descriptor. If this symbol
- is a function descriptor, this field holds a pointer to the
- function entry point. */
- struct xcoff_link_hash_entry *descriptor;
-
- /* The .loader symbol table entry, if there is one. */
- struct internal_ldsym *ldsym;
-
- /* The .loader symbol table index. */
- long ldindx;
-
- /* Some linker flags. */
- unsigned short flags;
- /* Symbol is referenced by a regular object. */
-#define XCOFF_REF_REGULAR (01)
- /* Symbol is defined by a regular object. */
-#define XCOFF_DEF_REGULAR (02)
- /* Symbol is defined by a dynamic object. */
-#define XCOFF_DEF_DYNAMIC (04)
- /* Symbol is used in a reloc being copied into the .loader section. */
-#define XCOFF_LDREL (010)
- /* Symbol is the entry point. */
-#define XCOFF_ENTRY (020)
- /* Symbol is called; this is, it appears in a R_BR reloc. */
-#define XCOFF_CALLED (040)
- /* Symbol needs the TOC entry filled in. */
-#define XCOFF_SET_TOC (0100)
- /* Symbol is explicitly imported. */
-#define XCOFF_IMPORT (0200)
- /* Symbol is explicitly exported. */
-#define XCOFF_EXPORT (0400)
- /* Symbol has been processed by xcoff_build_ldsyms. */
-#define XCOFF_BUILT_LDSYM (01000)
- /* Symbol is mentioned by a section which was not garbage collected. */
-#define XCOFF_MARK (02000)
- /* Symbol size is recorded in size_list list from hash table. */
-#define XCOFF_HAS_SIZE (04000)
- /* Symbol is a function descriptor. */
-#define XCOFF_DESCRIPTOR (010000)
-
- /* The storage mapping class. */
- unsigned char smclas;
-};
-
-/* The XCOFF linker hash table. */
-
-struct xcoff_link_hash_table
-{
- struct bfd_link_hash_table root;
-
- /* The .debug string hash table. We need to compute this while
- reading the input files, so that we know how large the .debug
- section will be before we assign section positions. */
- struct bfd_strtab_hash *debug_strtab;
-
- /* The .debug section we will use for the final output. */
- asection *debug_section;
-
- /* The .loader section we will use for the final output. */
- asection *loader_section;
-
- /* A count of non TOC relative relocs which will need to be
- allocated in the .loader section. */
- size_t ldrel_count;
-
- /* The .loader section header. */
- struct internal_ldhdr ldhdr;
-
- /* The .gl section we use to hold global linkage code. */
- asection *linkage_section;
-
- /* The .tc section we use to hold toc entries we build for global
- linkage code. */
- asection *toc_section;
-
- /* The .ds section we use to hold function descriptors which we
- create for exported symbols. */
- asection *descriptor_section;
-
- /* The list of import files. */
- struct xcoff_import_file *imports;
-
- /* Required alignment of sections within the output file. */
- unsigned long file_align;
-
- /* Whether the .text section must be read-only. */
- boolean textro;
-
- /* Whether garbage collection was done. */
- boolean gc;
-
- /* A linked list of symbols for which we have size information. */
- struct xcoff_link_size_list
- {
- struct xcoff_link_size_list *next;
- struct xcoff_link_hash_entry *h;
- bfd_size_type size;
- } *size_list;
-
- /* Magic sections: _text, _etext, _data, _edata, _end, end. */
- asection *special_sections[6];
-};
-
-/* Information we keep for each section in the output file during the
- final link phase. */
-
-struct xcoff_link_section_info
-{
- /* The relocs to be output. */
- struct internal_reloc *relocs;
- /* For each reloc against a global symbol whose index was not known
- when the reloc was handled, the global hash table entry. */
- struct xcoff_link_hash_entry **rel_hashes;
- /* If there is a TOC relative reloc against a global symbol, and the
- index of the TOC symbol is not known when the reloc was handled,
- an entry is added to this linked list. This is not an array,
- like rel_hashes, because this case is quite uncommon. */
- struct xcoff_toc_rel_hash
- {
- struct xcoff_toc_rel_hash *next;
- struct xcoff_link_hash_entry *h;
- struct internal_reloc *rel;
- } *toc_rel_hashes;
-};
-
-/* Information that we pass around while doing the final link step. */
-
-struct xcoff_final_link_info
-{
- /* General link information. */
- struct bfd_link_info *info;
- /* Output BFD. */
- bfd *output_bfd;
- /* Hash table for long symbol names. */
- struct bfd_strtab_hash *strtab;
- /* Array of information kept for each output section, indexed by the
- target_index field. */
- struct xcoff_link_section_info *section_info;
- /* Symbol index of last C_FILE symbol (-1 if none). */
- long last_file_index;
- /* Contents of last C_FILE symbol. */
- struct internal_syment last_file;
- /* Symbol index of TOC symbol. */
- long toc_symindx;
- /* Start of .loader symbols. */
- struct external_ldsym *ldsym;
- /* Next .loader reloc to swap out. */
- struct external_ldrel *ldrel;
- /* File position of start of line numbers. */
- file_ptr line_filepos;
- /* Buffer large enough to hold swapped symbols of any input file. */
- struct internal_syment *internal_syms;
- /* Buffer large enough to hold output indices of symbols of any
- input file. */
- long *sym_indices;
- /* Buffer large enough to hold output symbols for any input file. */
- bfd_byte *outsyms;
- /* Buffer large enough to hold external line numbers for any input
- section. */
- bfd_byte *linenos;
- /* Buffer large enough to hold any input section. */
- bfd_byte *contents;
- /* Buffer large enough to hold external relocs of any input section. */
- bfd_byte *external_relocs;
-};
-
-static void xcoff_swap_ldhdr_in
- PARAMS ((bfd *, const struct external_ldhdr *, struct internal_ldhdr *));
-static void xcoff_swap_ldhdr_out
- PARAMS ((bfd *, const struct internal_ldhdr *, struct external_ldhdr *));
-static void xcoff_swap_ldsym_in
- PARAMS ((bfd *, const struct external_ldsym *, struct internal_ldsym *));
-static void xcoff_swap_ldsym_out
- PARAMS ((bfd *, const struct internal_ldsym *, struct external_ldsym *));
-static void xcoff_swap_ldrel_out
- PARAMS ((bfd *, const struct internal_ldrel *, struct external_ldrel *));
-static struct bfd_hash_entry *xcoff_link_hash_newfunc
- PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct internal_reloc *xcoff_read_internal_relocs
- PARAMS ((bfd *, asection *, boolean, bfd_byte *, boolean,
- struct internal_reloc *));
-static boolean xcoff_link_add_object_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean xcoff_link_check_archive_element
- PARAMS ((bfd *, struct bfd_link_info *, boolean *));
-static boolean xcoff_link_check_ar_symbols
- PARAMS ((bfd *, struct bfd_link_info *, boolean *));
-static bfd_size_type xcoff_find_reloc
- PARAMS ((struct internal_reloc *, bfd_size_type, bfd_vma));
-static boolean xcoff_link_add_symbols PARAMS ((bfd *, struct bfd_link_info *));
-static boolean xcoff_link_add_dynamic_symbols
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean xcoff_mark PARAMS ((struct bfd_link_info *, asection *));
-static void xcoff_sweep PARAMS ((struct bfd_link_info *));
-static boolean xcoff_build_ldsyms
- PARAMS ((struct xcoff_link_hash_entry *, PTR));
-static boolean xcoff_link_input_bfd
- PARAMS ((struct xcoff_final_link_info *, bfd *));
-static boolean xcoff_write_global_symbol
- PARAMS ((struct xcoff_link_hash_entry *, PTR));
-static boolean xcoff_reloc_link_order
- PARAMS ((bfd *, struct xcoff_final_link_info *, asection *,
- struct bfd_link_order *));
-static int xcoff_sort_relocs PARAMS ((const PTR, const PTR));
-
-/* Routines to swap information in the XCOFF .loader section. If we
- ever need to write an XCOFF loader, this stuff will need to be
- moved to another file shared by the linker (which XCOFF calls the
- ``binder'') and the loader. */
-
-/* Swap in the ldhdr structure. */
-
-static void
-xcoff_swap_ldhdr_in (abfd, src, dst)
- bfd *abfd;
- const struct external_ldhdr *src;
- struct internal_ldhdr *dst;
-{
- dst->l_version = bfd_get_32 (abfd, src->l_version);
- dst->l_nsyms = bfd_get_32 (abfd, src->l_nsyms);
- dst->l_nreloc = bfd_get_32 (abfd, src->l_nreloc);
- dst->l_istlen = bfd_get_32 (abfd, src->l_istlen);
- dst->l_nimpid = bfd_get_32 (abfd, src->l_nimpid);
- dst->l_impoff = bfd_get_32 (abfd, src->l_impoff);
- dst->l_stlen = bfd_get_32 (abfd, src->l_stlen);
- dst->l_stoff = bfd_get_32 (abfd, src->l_stoff);
-}
-
-/* Swap out the ldhdr structure. */
-
-static void
-xcoff_swap_ldhdr_out (abfd, src, dst)
- bfd *abfd;
- const struct internal_ldhdr *src;
- struct external_ldhdr *dst;
-{
- bfd_put_32 (abfd, src->l_version, dst->l_version);
- bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms);
- bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc);
- bfd_put_32 (abfd, src->l_istlen, dst->l_istlen);
- bfd_put_32 (abfd, src->l_nimpid, dst->l_nimpid);
- bfd_put_32 (abfd, src->l_impoff, dst->l_impoff);
- bfd_put_32 (abfd, src->l_stlen, dst->l_stlen);
- bfd_put_32 (abfd, src->l_stoff, dst->l_stoff);
-}
-
-/* Swap in the ldsym structure. */
-
-static void
-xcoff_swap_ldsym_in (abfd, src, dst)
- bfd *abfd;
- const struct external_ldsym *src;
- struct internal_ldsym *dst;
-{
- if (bfd_get_32 (abfd, src->_l._l_l._l_zeroes) != 0)
- memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN);
- else
- {
- dst->_l._l_l._l_zeroes = 0;
- dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->_l._l_l._l_offset);
- }
- dst->l_value = bfd_get_32 (abfd, src->l_value);
- dst->l_scnum = bfd_get_16 (abfd, src->l_scnum);
- dst->l_smtype = bfd_get_8 (abfd, src->l_smtype);
- dst->l_smclas = bfd_get_8 (abfd, src->l_smclas);
- dst->l_ifile = bfd_get_32 (abfd, src->l_ifile);
- dst->l_parm = bfd_get_32 (abfd, src->l_parm);
-}
-
-/* Swap out the ldsym structure. */
-
-static void
-xcoff_swap_ldsym_out (abfd, src, dst)
- bfd *abfd;
- const struct internal_ldsym *src;
- struct external_ldsym *dst;
-{
- if (src->_l._l_l._l_zeroes != 0)
- memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN);
- else
- {
- bfd_put_32 (abfd, 0, dst->_l._l_l._l_zeroes);
- bfd_put_32 (abfd, src->_l._l_l._l_offset, dst->_l._l_l._l_offset);
- }
- bfd_put_32 (abfd, src->l_value, dst->l_value);
- bfd_put_16 (abfd, src->l_scnum, dst->l_scnum);
- bfd_put_8 (abfd, src->l_smtype, dst->l_smtype);
- bfd_put_8 (abfd, src->l_smclas, dst->l_smclas);
- bfd_put_32 (abfd, src->l_ifile, dst->l_ifile);
- bfd_put_32 (abfd, src->l_parm, dst->l_parm);
-}
-
-/* As it happens, we never need to swap in the ldrel structure. */
-
-/* Swap out the ldrel structure. */
-
-static void
-xcoff_swap_ldrel_out (abfd, src, dst)
- bfd *abfd;
- const struct internal_ldrel *src;
- struct external_ldrel *dst;
-{
- bfd_put_32 (abfd, src->l_vaddr, dst->l_vaddr);
- bfd_put_32 (abfd, src->l_symndx, dst->l_symndx);
- bfd_put_16 (abfd, src->l_rtype, dst->l_rtype);
- bfd_put_16 (abfd, src->l_rsecnm, dst->l_rsecnm);
-}
-
-/* Routine to create an entry in an XCOFF link hash table. */
-
-static struct bfd_hash_entry *
-xcoff_link_hash_newfunc (entry, table, string)
- struct bfd_hash_entry *entry;
- struct bfd_hash_table *table;
- const char *string;
-{
- struct xcoff_link_hash_entry *ret = (struct xcoff_link_hash_entry *) entry;
-
- /* Allocate the structure if it has not already been allocated by a
- subclass. */
- if (ret == (struct xcoff_link_hash_entry *) NULL)
- ret = ((struct xcoff_link_hash_entry *)
- bfd_hash_allocate (table, sizeof (struct xcoff_link_hash_entry)));
- if (ret == (struct xcoff_link_hash_entry *) NULL)
- return (struct bfd_hash_entry *) ret;
-
- /* Call the allocation method of the superclass. */
- ret = ((struct xcoff_link_hash_entry *)
- _bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
- table, string));
- if (ret != NULL)
- {
- /* Set local fields. */
- ret->indx = -1;
- ret->toc_section = NULL;
- ret->u.toc_indx = -1;
- ret->descriptor = NULL;
- ret->ldsym = NULL;
- ret->ldindx = -1;
- ret->flags = 0;
- ret->smclas = XMC_UA;
- }
-
- return (struct bfd_hash_entry *) ret;
-}
-
-/* Create a XCOFF link hash table. */
-
-struct bfd_link_hash_table *
-_bfd_xcoff_bfd_link_hash_table_create (abfd)
- bfd *abfd;
-{
- struct xcoff_link_hash_table *ret;
-
- ret = ((struct xcoff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct xcoff_link_hash_table)));
- if (ret == (struct xcoff_link_hash_table *) NULL)
- return (struct bfd_link_hash_table *) NULL;
- if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc))
- {
- bfd_release (abfd, ret);
- return (struct bfd_link_hash_table *) NULL;
- }
-
- ret->debug_strtab = _bfd_xcoff_stringtab_init ();
- ret->debug_section = NULL;
- ret->loader_section = NULL;
- ret->ldrel_count = 0;
- memset (&ret->ldhdr, 0, sizeof (struct internal_ldhdr));
- ret->linkage_section = NULL;
- ret->toc_section = NULL;
- ret->descriptor_section = NULL;
- ret->imports = NULL;
- ret->file_align = 0;
- ret->textro = false;
- ret->gc = false;
- memset (ret->special_sections, 0, sizeof ret->special_sections);
-
- /* The linker will always generate a full a.out header. We need to
- record that fact now, before the sizeof_headers routine could be
- called. */
- xcoff_data (abfd)->full_aouthdr = true;
-
- return &ret->root;
-}
-
-/* Look up an entry in an XCOFF link hash table. */
-
-#define xcoff_link_hash_lookup(table, string, create, copy, follow) \
- ((struct xcoff_link_hash_entry *) \
- bfd_link_hash_lookup (&(table)->root, (string), (create), (copy),\
- (follow)))
-
-/* Traverse an XCOFF link hash table. */
-
-#define xcoff_link_hash_traverse(table, func, info) \
- (bfd_link_hash_traverse \
- (&(table)->root, \
- (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
- (info)))
-
-/* Get the XCOFF link hash table from the info structure. This is
- just a cast. */
-
-#define xcoff_hash_table(p) ((struct xcoff_link_hash_table *) ((p)->hash))
-
-/* Read internal relocs for an XCOFF csect. This is a wrapper around
- _bfd_coff_read_internal_relocs which tries to take advantage of any
- relocs which may have been cached for the enclosing section. */
-
-static struct internal_reloc *
-xcoff_read_internal_relocs (abfd, sec, cache, external_relocs,
- require_internal, internal_relocs)
- bfd *abfd;
- asection *sec;
- boolean cache;
- bfd_byte *external_relocs;
- boolean require_internal;
- struct internal_reloc *internal_relocs;
-{
- if (coff_section_data (abfd, sec) != NULL
- && coff_section_data (abfd, sec)->relocs == NULL
- && xcoff_section_data (abfd, sec) != NULL)
- {
- asection *enclosing;
-
- enclosing = xcoff_section_data (abfd, sec)->enclosing;
-
- if (enclosing != NULL
- && (coff_section_data (abfd, enclosing) == NULL
- || coff_section_data (abfd, enclosing)->relocs == NULL)
- && cache
- && enclosing->reloc_count > 0)
- {
- if (_bfd_coff_read_internal_relocs (abfd, enclosing, true,
- external_relocs, false,
- (struct internal_reloc *) NULL)
- == NULL)
- return NULL;
- }
-
- if (enclosing != NULL
- && coff_section_data (abfd, enclosing) != NULL
- && coff_section_data (abfd, enclosing)->relocs != NULL)
- {
- size_t off;
-
- off = ((sec->rel_filepos - enclosing->rel_filepos)
- / bfd_coff_relsz (abfd));
- if (! require_internal)
- return coff_section_data (abfd, enclosing)->relocs + off;
- memcpy (internal_relocs,
- coff_section_data (abfd, enclosing)->relocs + off,
- sec->reloc_count * sizeof (struct internal_reloc));
- return internal_relocs;
- }
- }
-
- return _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
- require_internal, internal_relocs);
-}
-
-/* Given an XCOFF BFD, add symbols to the global hash table as
- appropriate. */
-
-boolean
-_bfd_xcoff_bfd_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- switch (bfd_get_format (abfd))
- {
- case bfd_object:
- return xcoff_link_add_object_symbols (abfd, info);
- case bfd_archive:
- return (_bfd_generic_link_add_archive_symbols
- (abfd, info, xcoff_link_check_archive_element));
- default:
- bfd_set_error (bfd_error_wrong_format);
- return false;
- }
-}
-
-/* Add symbols from an XCOFF object file. */
-
-static boolean
-xcoff_link_add_object_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- if (! _bfd_coff_get_external_symbols (abfd))
- return false;
- if (! xcoff_link_add_symbols (abfd, info))
- return false;
- if (! info->keep_memory)
- {
- if (! _bfd_coff_free_symbols (abfd))
- return false;
- }
- return true;
-}
-
-/* Check a single archive element to see if we need to include it in
- the link. *PNEEDED is set according to whether this element is
- needed in the link or not. This is called via
- _bfd_generic_link_add_archive_symbols. */
-
-static boolean
-xcoff_link_check_archive_element (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- if (! _bfd_coff_get_external_symbols (abfd))
- return false;
-
- if (! xcoff_link_check_ar_symbols (abfd, info, pneeded))
- return false;
-
- if (*pneeded)
- {
- if (! xcoff_link_add_symbols (abfd, info))
- return false;
- }
-
- if (! info->keep_memory || ! *pneeded)
- {
- if (! _bfd_coff_free_symbols (abfd))
- return false;
- }
-
- return true;
-}
-
-/* Look through the symbols to see if this object file should be
- included in the link. */
-
-static boolean
-xcoff_link_check_ar_symbols (abfd, info, pneeded)
- bfd *abfd;
- struct bfd_link_info *info;
- boolean *pneeded;
-{
- bfd_size_type symesz;
- bfd_byte *esym;
- bfd_byte *esym_end;
-
- *pneeded = false;
-
- symesz = bfd_coff_symesz (abfd);
- esym = (bfd_byte *) obj_coff_external_syms (abfd);
- esym_end = esym + obj_raw_syment_count (abfd) * symesz;
- while (esym < esym_end)
- {
- struct internal_syment sym;
-
- bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
-
- if (sym.n_sclass == C_EXT && sym.n_scnum != N_UNDEF)
- {
- const char *name;
- char buf[SYMNMLEN + 1];
- struct bfd_link_hash_entry *h;
-
- /* This symbol is externally visible, and is defined by this
- object file. */
-
- name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
- if (name == NULL)
- return false;
- h = bfd_link_hash_lookup (info->hash, name, false, false, true);
-
- /* We are only interested in symbols that are currently
- undefined. If a symbol is currently known to be common,
- XCOFF linkers do not bring in an object file which
- defines it. We also don't bring in symbols to satisfy
- undefined references in shared objects. */
- if (h != (struct bfd_link_hash_entry *) NULL
- && h->type == bfd_link_hash_undefined)
- {
- if (! (*info->callbacks->add_archive_element) (info, abfd, name))
- return false;
- *pneeded = true;
- return true;
- }
- }
-
- esym += (sym.n_numaux + 1) * symesz;
- }
-
- /* We do not need this object file. */
- return true;
-}
-
-/* Returns the index of reloc in RELOCS with the least address greater
- than or equal to ADDRESS. The relocs are sorted by address. */
-
-static bfd_size_type
-xcoff_find_reloc (relocs, count, address)
- struct internal_reloc *relocs;
- bfd_size_type count;
- bfd_vma address;
-{
- bfd_size_type min, max, this;
-
- if (count < 2)
- {
- if (count == 1 && relocs[0].r_vaddr < address)
- return 1;
- else
- return 0;
- }
-
- min = 0;
- max = count;
-
- /* Do a binary search over (min,max]. */
- while (min + 1 < max)
- {
- bfd_vma raddr;
-
- this = (max + min) / 2;
- raddr = relocs[this].r_vaddr;
- if (raddr > address)
- max = this;
- else if (raddr < address)
- min = this;
- else
- {
- min = this;
- break;
- }
- }
-
- if (relocs[min].r_vaddr < address)
- return min + 1;
-
- while (min > 0
- && relocs[min - 1].r_vaddr == address)
- --min;
-
- return min;
-}
-
-/* Add all the symbols from an object file to the hash table.
-
- XCOFF is a weird format. A normal XCOFF .o files will have three
- COFF sections--.text, .data, and .bss--but each COFF section will
- contain many csects. These csects are described in the symbol
- table. From the linker's point of view, each csect must be
- considered a section in its own right. For example, a TOC entry is
- handled as a small XMC_TC csect. The linker must be able to merge
- different TOC entries together, which means that it must be able to
- extract the XMC_TC csects from the .data section of the input .o
- file.
-
- From the point of view of our linker, this is, of course, a hideous
- nightmare. We cope by actually creating sections for each csect,
- and discarding the original sections. We then have to handle the
- relocation entries carefully, since the only way to tell which
- csect they belong to is to examine the address. */
-
-static boolean
-xcoff_link_add_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- unsigned int n_tmask;
- unsigned int n_btshft;
- boolean default_copy;
- bfd_size_type symcount;
- struct xcoff_link_hash_entry **sym_hash;
- asection **csect_cache;
- bfd_size_type linesz;
- asection *o;
- asection *last_real;
- boolean keep_syms;
- asection *csect;
- unsigned int csect_index;
- asection *first_csect;
- bfd_size_type symesz;
- bfd_byte *esym;
- bfd_byte *esym_end;
- struct reloc_info_struct
- {
- struct internal_reloc *relocs;
- asection **csects;
- bfd_byte *linenos;
- } *reloc_info = NULL;
-
- if ((abfd->flags & DYNAMIC) != 0
- && ! info->static_link)
- {
- if (! xcoff_link_add_dynamic_symbols (abfd, info))
- return false;
- }
-
- /* We need to build a .loader section, so we do it here. This won't
- work if we're producing an XCOFF output file with no XCOFF input
- files. FIXME. */
- if (xcoff_hash_table (info)->loader_section == NULL)
- {
- asection *lsec;
-
- lsec = bfd_make_section_anyway (abfd, ".loader");
- if (lsec == NULL)
- goto error_return;
- xcoff_hash_table (info)->loader_section = lsec;
- lsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
- }
- /* Likewise for the linkage section. */
- if (xcoff_hash_table (info)->linkage_section == NULL)
- {
- asection *lsec;
-
- lsec = bfd_make_section_anyway (abfd, ".gl");
- if (lsec == NULL)
- goto error_return;
- xcoff_hash_table (info)->linkage_section = lsec;
- lsec->flags |= SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
- lsec->alignment_power = 2;
- }
- /* Likewise for the TOC section. */
- if (xcoff_hash_table (info)->toc_section == NULL)
- {
- asection *tsec;
-
- tsec = bfd_make_section_anyway (abfd, ".tc");
- if (tsec == NULL)
- goto error_return;
- xcoff_hash_table (info)->toc_section = tsec;
- tsec->flags |= SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
- tsec->alignment_power = 2;
- }
- /* Likewise for the descriptor section. */
- if (xcoff_hash_table (info)->descriptor_section == NULL)
- {
- asection *dsec;
-
- dsec = bfd_make_section_anyway (abfd, ".ds");
- if (dsec == NULL)
- goto error_return;
- xcoff_hash_table (info)->descriptor_section = dsec;
- dsec->flags |= SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
- dsec->alignment_power = 2;
- }
- /* Likewise for the .debug section. */
- if (xcoff_hash_table (info)->debug_section == NULL)
- {
- asection *dsec;
-
- dsec = bfd_make_section_anyway (abfd, ".debug");
- if (dsec == NULL)
- goto error_return;
- xcoff_hash_table (info)->debug_section = dsec;
- dsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
- }
-
- if ((abfd->flags & DYNAMIC) != 0
- && ! info->static_link)
- return true;
-
- n_tmask = coff_data (abfd)->local_n_tmask;
- n_btshft = coff_data (abfd)->local_n_btshft;
-
- /* Define macros so that ISFCN, et. al., macros work correctly. */
-#define N_TMASK n_tmask
-#define N_BTSHFT n_btshft
-
- if (info->keep_memory)
- default_copy = false;
- else
- default_copy = true;
-
- symcount = obj_raw_syment_count (abfd);
-
- /* We keep a list of the linker hash table entries that correspond
- to each external symbol. */
- sym_hash = ((struct xcoff_link_hash_entry **)
- bfd_alloc (abfd,
- (symcount
- * sizeof (struct xcoff_link_hash_entry *))));
- if (sym_hash == NULL && symcount != 0)
- goto error_return;
- coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
- memset (sym_hash, 0,
- (size_t) symcount * sizeof (struct xcoff_link_hash_entry *));
-
- /* Because of the weird stuff we are doing with XCOFF csects, we can
- not easily determine which section a symbol is in, so we store
- the information in the tdata for the input file. */
- csect_cache = ((asection **)
- bfd_alloc (abfd, symcount * sizeof (asection *)));
- if (csect_cache == NULL && symcount != 0)
- goto error_return;
- xcoff_data (abfd)->csects = csect_cache;
- memset (csect_cache, 0, (size_t) symcount * sizeof (asection *));
-
- /* While splitting sections into csects, we need to assign the
- relocs correctly. The relocs and the csects must both be in
- order by VMA within a given section, so we handle this by
- scanning along the relocs as we process the csects. We index
- into reloc_info using the section target_index. */
- reloc_info = ((struct reloc_info_struct *)
- bfd_malloc ((abfd->section_count + 1)
- * sizeof (struct reloc_info_struct)));
- if (reloc_info == NULL)
- goto error_return;
- memset ((PTR) reloc_info, 0,
- (abfd->section_count + 1) * sizeof (struct reloc_info_struct));
-
- /* Read in the relocs and line numbers for each section. */
- linesz = bfd_coff_linesz (abfd);
- last_real = NULL;
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- last_real = o;
- if ((o->flags & SEC_RELOC) != 0)
- {
- reloc_info[o->target_index].relocs =
- xcoff_read_internal_relocs (abfd, o, true, (bfd_byte *) NULL,
- false, (struct internal_reloc *) NULL);
- reloc_info[o->target_index].csects =
- (asection **) bfd_malloc (o->reloc_count * sizeof (asection *));
- if (reloc_info[o->target_index].csects == NULL)
- goto error_return;
- memset (reloc_info[o->target_index].csects, 0,
- o->reloc_count * sizeof (asection *));
- }
-
- if ((info->strip == strip_none || info->strip == strip_some)
- && o->lineno_count > 0)
- {
- bfd_byte *linenos;
-
- linenos = (bfd_byte *) bfd_malloc (o->lineno_count * linesz);
- if (linenos == NULL)
- goto error_return;
- reloc_info[o->target_index].linenos = linenos;
- if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0
- || (bfd_read (linenos, linesz, o->lineno_count, abfd)
- != linesz * o->lineno_count))
- goto error_return;
- }
- }
-
- /* Don't let the linker relocation routines discard the symbols. */
- keep_syms = obj_coff_keep_syms (abfd);
- obj_coff_keep_syms (abfd) = true;
-
- csect = NULL;
- csect_index = 0;
- first_csect = NULL;
-
- symesz = bfd_coff_symesz (abfd);
- BFD_ASSERT (symesz == bfd_coff_auxesz (abfd));
- esym = (bfd_byte *) obj_coff_external_syms (abfd);
- esym_end = esym + symcount * symesz;
- while (esym < esym_end)
- {
- struct internal_syment sym;
- union internal_auxent aux;
- const char *name;
- char buf[SYMNMLEN + 1];
- int smtyp;
- flagword flags;
- asection *section;
- bfd_vma value;
- struct xcoff_link_hash_entry *set_toc;
-
- bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
-
- /* In this pass we are only interested in symbols with csect
- information. */
- if (sym.n_sclass != C_EXT && sym.n_sclass != C_HIDEXT)
- {
- if (sym.n_sclass == C_FILE && csect != NULL)
- {
- xcoff_section_data (abfd, csect)->last_symndx =
- ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz);
- csect = NULL;
- }
-
- if (csect != NULL)
- *csect_cache = csect;
- else if (first_csect == NULL || sym.n_sclass == C_FILE)
- *csect_cache = coff_section_from_bfd_index (abfd, sym.n_scnum);
- else
- *csect_cache = NULL;
- esym += (sym.n_numaux + 1) * symesz;
- sym_hash += sym.n_numaux + 1;
- csect_cache += sym.n_numaux + 1;
- continue;
- }
-
- name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
- if (name == NULL)
- goto error_return;
-
- /* If this symbol has line number information attached to it,
- and we're not stripping it, count the number of entries and
- add them to the count for this csect. In the final link pass
- we are going to attach line number information by symbol,
- rather than by section, in order to more easily handle
- garbage collection. */
- if ((info->strip == strip_none || info->strip == strip_some)
- && sym.n_numaux > 1
- && csect != NULL
- && ISFCN (sym.n_type))
- {
- union internal_auxent auxlin;
-
- bfd_coff_swap_aux_in (abfd, (PTR) (esym + symesz),
- sym.n_type, sym.n_sclass,
- 0, sym.n_numaux, (PTR) &auxlin);
- if (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0)
- {
- asection *enclosing;
- bfd_size_type linoff;
-
- enclosing = xcoff_section_data (abfd, csect)->enclosing;
- if (enclosing == NULL)
- {
- (*_bfd_error_handler)
- ("%s: `%s' has line numbers but no enclosing section",
- bfd_get_filename (abfd), name);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
- linoff = (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr
- - enclosing->line_filepos);
- if (linoff < enclosing->lineno_count * linesz)
- {
- struct internal_lineno lin;
- bfd_byte *linpstart;
-
- linpstart = (reloc_info[enclosing->target_index].linenos
- + linoff);
- bfd_coff_swap_lineno_in (abfd, (PTR) linpstart, (PTR) &lin);
- if (lin.l_lnno == 0
- && ((bfd_size_type) lin.l_addr.l_symndx
- == ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz)))
- {
- bfd_byte *linpend, *linp;
-
- linpend = (reloc_info[enclosing->target_index].linenos
- + enclosing->lineno_count * linesz);
- for (linp = linpstart + linesz;
- linp < linpend;
- linp += linesz)
- {
- bfd_coff_swap_lineno_in (abfd, (PTR) linp,
- (PTR) &lin);
- if (lin.l_lnno == 0)
- break;
- }
- csect->lineno_count += (linp - linpstart) / linesz;
- /* The setting of line_filepos will only be
- useful if all the line number entries for a
- csect are contiguous; this only matters for
- error reporting. */
- if (csect->line_filepos == 0)
- csect->line_filepos =
- auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr;
- }
- }
- }
- }
-
- /* Pick up the csect auxiliary information. */
-
- if (sym.n_numaux == 0)
- {
- (*_bfd_error_handler)
- ("%s: class %d symbol `%s' has no aux entries",
- bfd_get_filename (abfd), sym.n_sclass, name);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- bfd_coff_swap_aux_in (abfd,
- (PTR) (esym + symesz * sym.n_numaux),
- sym.n_type, sym.n_sclass,
- sym.n_numaux - 1, sym.n_numaux,
- (PTR) &aux);
-
- smtyp = SMTYP_SMTYP (aux.x_csect.x_smtyp);
-
- flags = BSF_GLOBAL;
- section = NULL;
- value = 0;
- set_toc = NULL;
-
- switch (smtyp)
- {
- default:
- (*_bfd_error_handler)
- ("%s: symbol `%s' has unrecognized csect type %d",
- bfd_get_filename (abfd), name, smtyp);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
-
- case XTY_ER:
- /* This is an external reference. */
- if (sym.n_sclass == C_HIDEXT
- || sym.n_scnum != N_UNDEF
- || aux.x_csect.x_scnlen.l != 0)
- {
- (*_bfd_error_handler)
- ("%s: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d",
- bfd_get_filename (abfd), name, sym.n_sclass, sym.n_scnum,
- aux.x_csect.x_scnlen.l);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- /* An XMC_XO external reference is actually a reference to
- an absolute location. */
- if (aux.x_csect.x_smclas != XMC_XO)
- section = bfd_und_section_ptr;
- else
- {
- section = bfd_abs_section_ptr;
- value = sym.n_value;
- }
- break;
-
- case XTY_SD:
- /* This is a csect definition. */
-
- if (csect != NULL)
- {
- xcoff_section_data (abfd, csect)->last_symndx =
- ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz);
- }
-
- csect = NULL;
- csect_index = -1;
-
- /* When we see a TOC anchor, we record the TOC value. */
- if (aux.x_csect.x_smclas == XMC_TC0)
- {
- if (sym.n_sclass != C_HIDEXT
- || aux.x_csect.x_scnlen.l != 0)
- {
- (*_bfd_error_handler)
- ("%s: XMC_TC0 symbol `%s' is class %d scnlen %d",
- bfd_get_filename (abfd), name, sym.n_sclass,
- aux.x_csect.x_scnlen.l);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
- xcoff_data (abfd)->toc = sym.n_value;
- }
-
- /* We must merge TOC entries for the same symbol. We can
- merge two TOC entries if they are both C_HIDEXT, they
- both have the same name, they are both 4 bytes long, and
- they both have a relocation table entry for an external
- symbol with the same name. Unfortunately, this means
- that we must look through the relocations. Ick. */
- if (aux.x_csect.x_smclas == XMC_TC
- && sym.n_sclass == C_HIDEXT
- && aux.x_csect.x_scnlen.l == 4
- && info->hash->creator == abfd->xvec)
- {
- asection *enclosing;
- struct internal_reloc *relocs;
- bfd_size_type relindx;
- struct internal_reloc *rel;
-
- enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
- if (enclosing == NULL)
- goto error_return;
-
- relocs = reloc_info[enclosing->target_index].relocs;
- relindx = xcoff_find_reloc (relocs, enclosing->reloc_count,
- sym.n_value);
- rel = relocs + relindx;
- if (relindx < enclosing->reloc_count
- && rel->r_vaddr == (bfd_vma) sym.n_value
- && rel->r_size == 31
- && rel->r_type == R_POS)
- {
- bfd_byte *erelsym;
- struct internal_syment relsym;
-
- erelsym = ((bfd_byte *) obj_coff_external_syms (abfd)
- + rel->r_symndx * symesz);
- bfd_coff_swap_sym_in (abfd, (PTR) erelsym, (PTR) &relsym);
- if (relsym.n_sclass == C_EXT)
- {
- const char *relname;
- char relbuf[SYMNMLEN + 1];
- boolean copy;
- struct xcoff_link_hash_entry *h;
-
- /* At this point we know that the TOC entry is
- for an externally visible symbol. */
- relname = _bfd_coff_internal_syment_name (abfd, &relsym,
- relbuf);
- if (relname == NULL)
- goto error_return;
-
- /* We only merge TOC entries if the TC name is
- the same as the symbol name. This handles
- the normal case, but not common cases like
- SYM.P4 which gcc generates to store SYM + 4
- in the TOC. FIXME. */
- if (strcmp (name, relname) == 0)
- {
- copy = (! info->keep_memory
- || relsym._n._n_n._n_zeroes != 0
- || relsym._n._n_n._n_offset == 0);
- h = xcoff_link_hash_lookup (xcoff_hash_table (info),
- relname, true, copy,
- false);
- if (h == NULL)
- goto error_return;
-
- /* At this point h->root.type could be
- bfd_link_hash_new. That should be OK,
- since we know for sure that we will come
- across this symbol as we step through the
- file. */
-
- /* We store h in *sym_hash for the
- convenience of the relocate_section
- function. */
- *sym_hash = h;
-
- if (h->toc_section != NULL)
- {
- asection **rel_csects;
-
- /* We already have a TOC entry for this
- symbol, so we can just ignore this
- one. */
- rel_csects =
- reloc_info[enclosing->target_index].csects;
- rel_csects[relindx] = bfd_und_section_ptr;
- break;
- }
-
- /* We are about to create a TOC entry for
- this symbol. */
- set_toc = h;
- }
- }
- }
- }
-
- /* We need to create a new section. We get the name from
- the csect storage mapping class, so that the linker can
- accumulate similar csects together. */
- {
- static const char *csect_name_by_class[] =
- {
- ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
- ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0",
- ".td"
- };
- const char *csect_name;
- asection *enclosing;
-
- if ((aux.x_csect.x_smclas >=
- sizeof csect_name_by_class / sizeof csect_name_by_class[0])
- || csect_name_by_class[aux.x_csect.x_smclas] == NULL)
- {
- (*_bfd_error_handler)
- ("%s: symbol `%s' has unrecognized smclas %d",
- bfd_get_filename (abfd), name, aux.x_csect.x_smclas);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- csect_name = csect_name_by_class[aux.x_csect.x_smclas];
- csect = bfd_make_section_anyway (abfd, csect_name);
- if (csect == NULL)
- goto error_return;
- enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
- if (enclosing == NULL)
- goto error_return;
- if (! bfd_is_abs_section (enclosing)
- && ((bfd_vma) sym.n_value < enclosing->vma
- || ((bfd_vma) sym.n_value + aux.x_csect.x_scnlen.l
- > enclosing->vma + enclosing->_raw_size)))
- {
- (*_bfd_error_handler)
- ("%s: csect `%s' not in enclosing section",
- bfd_get_filename (abfd), name);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
- csect->vma = sym.n_value;
- csect->filepos = (enclosing->filepos
- + sym.n_value
- - enclosing->vma);
- csect->_raw_size = aux.x_csect.x_scnlen.l;
- csect->flags |= SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
- csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
-
- /* Record the enclosing section in the tdata for this new
- section. */
- csect->used_by_bfd =
- ((struct coff_section_tdata *)
- bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
- if (csect->used_by_bfd == NULL)
- goto error_return;
- coff_section_data (abfd, csect)->tdata =
- bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
- if (coff_section_data (abfd, csect)->tdata == NULL)
- goto error_return;
- xcoff_section_data (abfd, csect)->enclosing = enclosing;
- xcoff_section_data (abfd, csect)->lineno_count =
- enclosing->lineno_count;
-
- if (enclosing->owner == abfd)
- {
- struct internal_reloc *relocs;
- bfd_size_type relindx;
- struct internal_reloc *rel;
- asection **rel_csect;
-
- relocs = reloc_info[enclosing->target_index].relocs;
- relindx = xcoff_find_reloc (relocs, enclosing->reloc_count,
- csect->vma);
- rel = relocs + relindx;
- rel_csect = (reloc_info[enclosing->target_index].csects
- + relindx);
- csect->rel_filepos = (enclosing->rel_filepos
- + relindx * bfd_coff_relsz (abfd));
- while (relindx < enclosing->reloc_count
- && *rel_csect == NULL
- && rel->r_vaddr < csect->vma + csect->_raw_size)
- {
- *rel_csect = csect;
- csect->flags |= SEC_RELOC;
- ++csect->reloc_count;
- ++relindx;
- ++rel;
- ++rel_csect;
- }
- }
-
- /* There are a number of other fields and section flags
- which we do not bother to set. */
-
- csect_index = ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz);
-
- xcoff_section_data (abfd, csect)->first_symndx = csect_index;
-
- if (first_csect == NULL)
- first_csect = csect;
-
- /* If this symbol is C_EXT, we treat it as starting at the
- beginning of the newly created section. */
- if (sym.n_sclass == C_EXT)
- {
- section = csect;
- value = 0;
- }
-
- /* If this is a TOC section for a symbol, record it. */
- if (set_toc != NULL)
- set_toc->toc_section = csect;
- }
- break;
-
- case XTY_LD:
- /* This is a label definition. The x_scnlen field is the
- symbol index of the csect. I believe that this must
- always follow the appropriate XTY_SD symbol, so I will
- insist on it. */
- {
- boolean bad;
-
- bad = false;
- if (aux.x_csect.x_scnlen.l < 0
- || (aux.x_csect.x_scnlen.l
- >= esym - (bfd_byte *) obj_coff_external_syms (abfd)))
- bad = true;
- if (! bad)
- {
- section = xcoff_data (abfd)->csects[aux.x_csect.x_scnlen.l];
- if (section == NULL
- || (section->flags & SEC_HAS_CONTENTS) == 0)
- bad = true;
- }
- if (bad)
- {
- (*_bfd_error_handler)
- ("%s: misplaced XTY_LD `%s'",
- bfd_get_filename (abfd), name);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- value = sym.n_value - csect->vma;
- }
- break;
-
- case XTY_CM:
- /* This is an unitialized csect. We could base the name on
- the storage mapping class, but we don't bother. If this
- csect is externally visible, it is a common symbol. */
-
- if (csect != NULL)
- {
- xcoff_section_data (abfd, csect)->last_symndx =
- ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz);
- }
-
- csect = bfd_make_section_anyway (abfd, ".bss");
- if (csect == NULL)
- goto error_return;
- csect->vma = sym.n_value;
- csect->_raw_size = aux.x_csect.x_scnlen.l;
- csect->flags |= SEC_ALLOC;
- csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
- /* There are a number of other fields and section flags
- which we do not bother to set. */
-
- csect_index = ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz);
-
- csect->used_by_bfd =
- ((struct coff_section_tdata *)
- bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
- if (csect->used_by_bfd == NULL)
- goto error_return;
- coff_section_data (abfd, csect)->tdata =
- bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
- if (coff_section_data (abfd, csect)->tdata == NULL)
- goto error_return;
- xcoff_section_data (abfd, csect)->first_symndx = csect_index;
-
- if (first_csect == NULL)
- first_csect = csect;
-
- if (sym.n_sclass == C_EXT)
- {
- csect->flags |= SEC_IS_COMMON;
- csect->_raw_size = 0;
- section = csect;
- value = aux.x_csect.x_scnlen.l;
- }
-
- break;
- }
-
- /* Check for magic symbol names. */
- if ((smtyp == XTY_SD || smtyp == XTY_CM)
- && aux.x_csect.x_smclas != XMC_TC)
- {
- int i;
-
- i = -1;
- if (name[0] == '_')
- {
- if (strcmp (name, "_text") == 0)
- i = 0;
- else if (strcmp (name, "_etext") == 0)
- i = 1;
- else if (strcmp (name, "_data") == 0)
- i = 2;
- else if (strcmp (name, "_edata") == 0)
- i = 3;
- else if (strcmp (name, "_end") == 0)
- i = 4;
- }
- else if (name[0] == 'e' && strcmp (name, "end") == 0)
- i = 5;
-
- if (i != -1)
- xcoff_hash_table (info)->special_sections[i] = csect;
- }
-
- /* Now we have enough information to add the symbol to the
- linker hash table. */
-
- if (sym.n_sclass == C_EXT)
- {
- boolean copy;
-
- BFD_ASSERT (section != NULL);
-
- /* We must copy the name into memory if we got it from the
- syment itself, rather than the string table. */
- copy = default_copy;
- if (sym._n._n_n._n_zeroes != 0
- || sym._n._n_n._n_offset == 0)
- copy = true;
-
- if (info->hash->creator == abfd->xvec)
- {
- /* If we are statically linking a shared object, it is
- OK for symbol redefinitions to occur. I can't figure
- out just what the XCOFF linker is doing, but
- something like this is required for -bnso to work. */
- if (! bfd_is_und_section (section))
- *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
- name, true, copy, false);
- else
- *sym_hash = ((struct xcoff_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (abfd, info, name,
- true, copy, false));
- if (*sym_hash == NULL)
- goto error_return;
- if (((*sym_hash)->root.type == bfd_link_hash_defined
- || (*sym_hash)->root.type == bfd_link_hash_defweak)
- && ! bfd_is_und_section (section)
- && ! bfd_is_com_section (section))
- {
- if ((abfd->flags & DYNAMIC) != 0)
- {
- section = bfd_und_section_ptr;
- value = 0;
- }
- else if (((*sym_hash)->root.u.def.section->owner->flags
- & DYNAMIC) != 0)
- {
- (*sym_hash)->root.type = bfd_link_hash_undefined;
- (*sym_hash)->root.u.undef.abfd =
- (*sym_hash)->root.u.def.section->owner;
- }
- }
- }
-
- /* _bfd_generic_link_add_one_symbol may call the linker to
- generate an error message, and the linker may try to read
- the symbol table to give a good error. Right now, the
- line numbers are in an inconsistent state, since they are
- counted both in the real sections and in the new csects.
- We need to leave the count in the real sections so that
- the linker can report the line number of the error
- correctly, so temporarily clobber the link to the csects
- so that the linker will not try to read the line numbers
- a second time from the csects. */
- BFD_ASSERT (last_real->next == first_csect);
- last_real->next = NULL;
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, name, flags, section, value,
- (const char *) NULL, copy, true,
- (struct bfd_link_hash_entry **) sym_hash)))
- goto error_return;
- last_real->next = first_csect;
-
- if (smtyp == XTY_CM)
- {
- if ((*sym_hash)->root.type != bfd_link_hash_common
- || (*sym_hash)->root.u.c.p->section != csect)
- {
- /* We don't need the common csect we just created. */
- csect->_raw_size = 0;
- }
- else
- {
- (*sym_hash)->root.u.c.p->alignment_power
- = csect->alignment_power;
- }
- }
-
- if (info->hash->creator == abfd->xvec)
- {
- int flag;
-
- if (smtyp == XTY_ER || smtyp == XTY_CM)
- flag = XCOFF_REF_REGULAR;
- else
- flag = XCOFF_DEF_REGULAR;
- (*sym_hash)->flags |= flag;
-
- if ((*sym_hash)->smclas == XMC_UA
- || flag == XCOFF_DEF_REGULAR)
- (*sym_hash)->smclas = aux.x_csect.x_smclas;
- }
- }
-
- *csect_cache = csect;
-
- esym += (sym.n_numaux + 1) * symesz;
- sym_hash += sym.n_numaux + 1;
- csect_cache += sym.n_numaux + 1;
- }
-
- BFD_ASSERT (last_real == NULL || last_real->next == first_csect);
-
- /* Make sure that we have seen all the relocs. */
- for (o = abfd->sections; o != first_csect; o = o->next)
- {
- /* Reset the section size and the line numebr count, since the
- data is now attached to the csects. Don't reset the size of
- the .debug section, since we need to read it below in
- bfd_xcoff_size_dynamic_sections. */
- if (strcmp (bfd_get_section_name (abfd, o), ".debug") != 0)
- o->_raw_size = 0;
- o->lineno_count = 0;
-
- if ((o->flags & SEC_RELOC) != 0)
- {
- bfd_size_type i;
- struct internal_reloc *rel;
- asection **rel_csect;
-
- rel = reloc_info[o->target_index].relocs;
- rel_csect = reloc_info[o->target_index].csects;
- for (i = 0; i < o->reloc_count; i++, rel++, rel_csect++)
- {
- if (*rel_csect == NULL)
- {
- (*_bfd_error_handler)
- ("%s: reloc %s:%d not in csect",
- bfd_get_filename (abfd), o->name, i);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
-
- /* We identify all symbols which are called, so that we
- can create glue code for calls to functions imported
- from dynamic objects. */
- if (info->hash->creator == abfd->xvec
- && *rel_csect != bfd_und_section_ptr
- && (rel->r_type == R_BR
- || rel->r_type == R_RBR)
- && obj_xcoff_sym_hashes (abfd)[rel->r_symndx] != NULL)
- {
- struct xcoff_link_hash_entry *h;
-
- h = obj_xcoff_sym_hashes (abfd)[rel->r_symndx];
- h->flags |= XCOFF_CALLED;
- /* If the symbol name starts with a period, it is
- the code of a function. If the symbol is
- currently undefined, then add an undefined symbol
- for the function descriptor. This should do no
- harm, because any regular object that defines the
- function should also define the function
- descriptor. It helps, because it means that we
- will identify the function descriptor with a
- dynamic object if a dynamic object defines it. */
- if (h->root.root.string[0] == '.'
- && h->descriptor == NULL)
- {
- struct xcoff_link_hash_entry *hds;
-
- hds = xcoff_link_hash_lookup (xcoff_hash_table (info),
- h->root.root.string + 1,
- true, false, true);
- if (hds == NULL)
- goto error_return;
- if (hds->root.type == bfd_link_hash_new)
- {
- if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, hds->root.root.string,
- (flagword) 0, bfd_und_section_ptr,
- (bfd_vma) 0, (const char *) NULL, false,
- true,
- (struct bfd_link_hash_entry **) &hds)))
- goto error_return;
- }
- hds->flags |= XCOFF_DESCRIPTOR;
- BFD_ASSERT ((hds->flags & XCOFF_CALLED) == 0
- && (h->flags & XCOFF_DESCRIPTOR) == 0);
- hds->descriptor = h;
- h->descriptor = hds;
- }
- }
- }
-
- free (reloc_info[o->target_index].csects);
- reloc_info[o->target_index].csects = NULL;
-
- /* Reset SEC_RELOC and the reloc_count, since the reloc
- information is now attached to the csects. */
- o->flags &=~ SEC_RELOC;
- o->reloc_count = 0;
-
- /* If we are not keeping memory, free the reloc information. */
- if (! info->keep_memory
- && coff_section_data (abfd, o) != NULL
- && coff_section_data (abfd, o)->relocs != NULL
- && ! coff_section_data (abfd, o)->keep_relocs)
- {
- free (coff_section_data (abfd, o)->relocs);
- coff_section_data (abfd, o)->relocs = NULL;
- }
- }
-
- /* Free up the line numbers. FIXME: We could cache these
- somewhere for the final link, to avoid reading them again. */
- if (reloc_info[o->target_index].linenos != NULL)
- {
- free (reloc_info[o->target_index].linenos);
- reloc_info[o->target_index].linenos = NULL;
- }
- }
-
- free (reloc_info);
-
- obj_coff_keep_syms (abfd) = keep_syms;
-
- return true;
-
- error_return:
- if (reloc_info != NULL)
- {
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if (reloc_info[o->target_index].csects != NULL)
- free (reloc_info[o->target_index].csects);
- if (reloc_info[o->target_index].linenos != NULL)
- free (reloc_info[o->target_index].linenos);
- }
- free (reloc_info);
- }
- obj_coff_keep_syms (abfd) = keep_syms;
- return false;
-}
-
-#undef N_TMASK
-#undef N_BTSHFT
-
-/* This function is used to add symbols from a dynamic object to the
- global symbol table. */
-
-static boolean
-xcoff_link_add_dynamic_symbols (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- asection *lsec;
- bfd_byte *buf = NULL;
- struct internal_ldhdr ldhdr;
- const char *strings;
- struct external_ldsym *elsym, *elsymend;
- struct xcoff_import_file *n;
- const char *bname;
- const char *mname;
- const char *s;
- unsigned int c;
- struct xcoff_import_file **pp;
-
- /* We can only handle a dynamic object if we are generating an XCOFF
- output file. */
- if (info->hash->creator != abfd->xvec)
- {
- (*_bfd_error_handler)
- ("%s: XCOFF shared object when not producing XCOFF output",
- bfd_get_filename (abfd));
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
-
- /* The symbols we use from a dynamic object are not the symbols in
- the normal symbol table, but, rather, the symbols in the export
- table. If there is a global symbol in a dynamic object which is
- not in the export table, the loader will not be able to find it,
- so we don't want to find it either. Also, on AIX 4.1.3, shr.o in
- libc.a has symbols in the export table which are not in the
- symbol table. */
-
- /* Read in the .loader section. FIXME: We should really use the
- o_snloader field in the a.out header, rather than grabbing the
- section by name. */
- lsec = bfd_get_section_by_name (abfd, ".loader");
- if (lsec == NULL)
- {
- (*_bfd_error_handler)
- ("%s: dynamic object with no .loader section",
- bfd_get_filename (abfd));
- bfd_set_error (bfd_error_no_symbols);
- goto error_return;
- }
-
- buf = (bfd_byte *) bfd_malloc (lsec->_raw_size);
- if (buf == NULL && lsec->_raw_size > 0)
- goto error_return;
-
- if (! bfd_get_section_contents (abfd, lsec, (PTR) buf, (file_ptr) 0,
- lsec->_raw_size))
- goto error_return;
-
- /* Remove the sections from this object, so that they do not get
- included in the link. */
- abfd->sections = NULL;
-
- xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) buf, &ldhdr);
-
- strings = (char *) buf + ldhdr.l_stoff;
-
- elsym = (struct external_ldsym *) (buf + LDHDRSZ);
- elsymend = elsym + ldhdr.l_nsyms;
- BFD_ASSERT (sizeof (struct external_ldsym) == LDSYMSZ);
- for (; elsym < elsymend; elsym++)
- {
- struct internal_ldsym ldsym;
- char nambuf[SYMNMLEN + 1];
- const char *name;
- struct xcoff_link_hash_entry *h;
-
- xcoff_swap_ldsym_in (abfd, elsym, &ldsym);
-
- /* We are only interested in exported symbols. */
- if ((ldsym.l_smtype & L_EXPORT) == 0)
- continue;
-
- if (ldsym._l._l_l._l_zeroes == 0)
- name = strings + ldsym._l._l_l._l_offset;
- else
- {
- memcpy (nambuf, ldsym._l._l_name, SYMNMLEN);
- nambuf[SYMNMLEN] = '\0';
- name = nambuf;
- }
-
- /* Normally we could not call xcoff_link_hash_lookup in an add
- symbols routine, since we might not be using an XCOFF hash
- table. However, we verified above that we are using an XCOFF
- hash table. */
-
- h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, true,
- true, true);
- if (h == NULL)
- goto error_return;
-
- h->flags |= XCOFF_DEF_DYNAMIC;
-
- /* If the symbol is undefined, and the BFD it was found in is
- not a dynamic object, change the BFD to this dynamic object,
- so that we can get the correct import file ID. */
- if ((h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- && (h->root.u.undef.abfd == NULL
- || (h->root.u.undef.abfd->flags & DYNAMIC) == 0))
- h->root.u.undef.abfd = abfd;
-
- if (h->root.type == bfd_link_hash_new)
- {
- h->root.type = bfd_link_hash_undefined;
- h->root.u.undef.abfd = abfd;
- /* We do not want to add this to the undefined symbol list. */
- }
-
- if (h->smclas == XMC_UA
- || h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- h->smclas = ldsym.l_smclas;
-
- /* Unless this is an XMC_XO symbol, we don't bother to actually
- define it, since we don't have a section to put it in anyhow.
- Instead, the relocation routines handle the DEF_DYNAMIC flag
- correctly. */
-
- if (h->smclas == XMC_XO
- && (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak))
- {
- /* This symbol has an absolute value. */
- h->root.type = bfd_link_hash_defined;
- h->root.u.def.section = bfd_abs_section_ptr;
- h->root.u.def.value = ldsym.l_value;
- }
- }
-
- if (buf != NULL)
- {
- free (buf);
- buf = NULL;
- }
-
- /* Record this file in the import files. */
-
- n = ((struct xcoff_import_file *)
- bfd_alloc (abfd, sizeof (struct xcoff_import_file)));
- if (n == NULL)
- goto error_return;
- n->next = NULL;
-
- /* For some reason, the path entry in the import file list for a
- shared object appears to always be empty. The file name is the
- base name. */
- n->path = "";
- if (abfd->my_archive == NULL)
- {
- bname = bfd_get_filename (abfd);
- mname = "";
- }
- else
- {
- bname = bfd_get_filename (abfd->my_archive);
- mname = bfd_get_filename (abfd);
- }
- s = strrchr (bname, '/');
- if (s != NULL)
- bname = s + 1;
- n->file = bname;
- n->member = mname;
-
- /* We start c at 1 because the first import file number is reserved
- for LIBPATH. */
- for (pp = &xcoff_hash_table (info)->imports, c = 1;
- *pp != NULL;
- pp = &(*pp)->next, ++c)
- ;
- *pp = n;
-
- xcoff_data (abfd)->import_file_id = c;
-
- return true;
-
- error_return:
- if (buf != NULL)
- free (buf);
- return false;
-}
-
-/* Routines that are called after all the input files have been
- handled, but before the sections are laid out in memory. */
-
-/* Mark a symbol as not being garbage, including the section in which
- it is defined. */
-
-static INLINE boolean
-xcoff_mark_symbol (info, h)
- struct bfd_link_info *info;
- struct xcoff_link_hash_entry *h;
-{
- if ((h->flags & XCOFF_MARK) != 0)
- return true;
-
- h->flags |= XCOFF_MARK;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *hsec;
-
- hsec = h->root.u.def.section;
- if ((hsec->flags & SEC_MARK) == 0)
- {
- if (! xcoff_mark (info, hsec))
- return false;
- }
- }
-
- if (h->toc_section != NULL
- && (h->toc_section->flags & SEC_MARK) == 0)
- {
- if (! xcoff_mark (info, h->toc_section))
- return false;
- }
-
- return true;
-}
-
-/* The mark phase of garbage collection. For a given section, mark
- it, and all the sections which define symbols to which it refers.
- Because this function needs to look at the relocs, we also count
- the number of relocs which need to be copied into the .loader
- section. */
-
-static boolean
-xcoff_mark (info, sec)
- struct bfd_link_info *info;
- asection *sec;
-{
- if ((sec->flags & SEC_MARK) != 0)
- return true;
-
- sec->flags |= SEC_MARK;
-
- if (sec->owner->xvec == info->hash->creator
- && coff_section_data (sec->owner, sec) != NULL
- && xcoff_section_data (sec->owner, sec) != NULL)
- {
- register struct xcoff_link_hash_entry **hp, **hpend;
- struct internal_reloc *rel, *relend;
-
- /* Mark all the symbols in this section. */
-
- hp = (obj_xcoff_sym_hashes (sec->owner)
- + xcoff_section_data (sec->owner, sec)->first_symndx);
- hpend = (obj_xcoff_sym_hashes (sec->owner)
- + xcoff_section_data (sec->owner, sec)->last_symndx);
- for (; hp < hpend; hp++)
- {
- register struct xcoff_link_hash_entry *h;
-
- h = *hp;
- if (h != NULL
- && (h->flags & XCOFF_MARK) == 0)
- {
- if (! xcoff_mark_symbol (info, h))
- return false;
- }
- }
-
- /* Look through the section relocs. */
-
- if ((sec->flags & SEC_RELOC) != 0
- && sec->reloc_count > 0)
- {
- rel = xcoff_read_internal_relocs (sec->owner, sec, true,
- (bfd_byte *) NULL, false,
- (struct internal_reloc *) NULL);
- if (rel == NULL)
- return false;
- relend = rel + sec->reloc_count;
- for (; rel < relend; rel++)
- {
- asection *rsec;
- struct xcoff_link_hash_entry *h;
-
- if ((unsigned int) rel->r_symndx
- > obj_raw_syment_count (sec->owner))
- continue;
-
- h = obj_xcoff_sym_hashes (sec->owner)[rel->r_symndx];
- if (h != NULL
- && (h->flags & XCOFF_MARK) == 0)
- {
- if (! xcoff_mark_symbol (info, h))
- return false;
- }
-
- rsec = xcoff_data (sec->owner)->csects[rel->r_symndx];
- if (rsec != NULL
- && (rsec->flags & SEC_MARK) == 0)
- {
- if (! xcoff_mark (info, rsec))
- return false;
- }
-
- /* See if this reloc needs to be copied into the .loader
- section. */
- switch (rel->r_type)
- {
- default:
- if (h == NULL
- || h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_common
- || ((h->flags & XCOFF_CALLED) != 0
- && (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- && h->root.root.string[0] == '.'
- && h->descriptor != NULL
- && ((h->descriptor->flags & XCOFF_DEF_DYNAMIC) != 0
- || info->shared
- || ((h->descriptor->flags & XCOFF_IMPORT) != 0
- && (h->descriptor->flags
- & XCOFF_DEF_REGULAR) == 0))))
- break;
- /* Fall through. */
- case R_POS:
- case R_NEG:
- case R_RL:
- case R_RLA:
- ++xcoff_hash_table (info)->ldrel_count;
- if (h != NULL)
- h->flags |= XCOFF_LDREL;
- break;
- case R_TOC:
- case R_GL:
- case R_TCL:
- case R_TRL:
- case R_TRLA:
- /* We should never need a .loader reloc for a TOC
- relative reloc. */
- break;
- }
- }
-
- if (! info->keep_memory
- && coff_section_data (sec->owner, sec) != NULL
- && coff_section_data (sec->owner, sec)->relocs != NULL
- && ! coff_section_data (sec->owner, sec)->keep_relocs)
- {
- free (coff_section_data (sec->owner, sec)->relocs);
- coff_section_data (sec->owner, sec)->relocs = NULL;
- }
- }
- }
-
- return true;
-}
-
-/* The sweep phase of garbage collection. Remove all garbage
- sections. */
-
-static void
-xcoff_sweep (info)
- struct bfd_link_info *info;
-{
- bfd *sub;
-
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- asection *o;
-
- for (o = sub->sections; o != NULL; o = o->next)
- {
- if ((o->flags & SEC_MARK) == 0)
- {
- /* Keep all sections from non-XCOFF input files. Keep
- special sections. Keep .debug sections for the
- moment. */
- if (sub->xvec != info->hash->creator
- || o == xcoff_hash_table (info)->debug_section
- || o == xcoff_hash_table (info)->loader_section
- || o == xcoff_hash_table (info)->linkage_section
- || o == xcoff_hash_table (info)->toc_section
- || o == xcoff_hash_table (info)->descriptor_section
- || strcmp (o->name, ".debug") == 0)
- o->flags |= SEC_MARK;
- else
- {
- o->_raw_size = 0;
- o->reloc_count = 0;
- o->lineno_count = 0;
- }
- }
- }
- }
-}
-
-/* Record the number of elements in a set. This is used to output the
- correct csect length. */
-
-boolean
-bfd_xcoff_link_record_set (output_bfd, info, harg, size)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct bfd_link_hash_entry *harg;
- bfd_size_type size;
-{
- struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
- struct xcoff_link_size_list *n;
-
- if (! XCOFF_XVECP (output_bfd->xvec))
- return true;
-
- /* This will hardly ever be called. I don't want to burn four bytes
- per global symbol, so instead the size is kept on a linked list
- attached to the hash table. */
-
- n = ((struct xcoff_link_size_list *)
- bfd_alloc (output_bfd, sizeof (struct xcoff_link_size_list)));
- if (n == NULL)
- return false;
- n->next = xcoff_hash_table (info)->size_list;
- n->h = h;
- n->size = size;
- xcoff_hash_table (info)->size_list = n;
-
- h->flags |= XCOFF_HAS_SIZE;
-
- return true;
-}
-
-/* Import a symbol. */
-
-boolean
-bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile,
- impmember)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct bfd_link_hash_entry *harg;
- bfd_vma val;
- const char *imppath;
- const char *impfile;
- const char *impmember;
-{
- struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
-
- if (! XCOFF_XVECP (output_bfd->xvec))
- return true;
-
- h->flags |= XCOFF_IMPORT;
-
- if (val != (bfd_vma) -1)
- {
- if (h->root.type == bfd_link_hash_defined
- && (! bfd_is_abs_section (h->root.u.def.section)
- || h->root.u.def.value != val))
- {
- if (! ((*info->callbacks->multiple_definition)
- (info, h->root.root.string, h->root.u.def.section->owner,
- h->root.u.def.section, h->root.u.def.value,
- output_bfd, bfd_abs_section_ptr, val)))
- return false;
- }
-
- h->root.type = bfd_link_hash_defined;
- h->root.u.def.section = bfd_abs_section_ptr;
- h->root.u.def.value = val;
- }
-
- if (h->ldsym == NULL)
- {
- h->ldsym = ((struct internal_ldsym *)
- bfd_zalloc (output_bfd, sizeof (struct internal_ldsym)));
- if (h->ldsym == NULL)
- return false;
- }
-
- if (imppath == NULL)
- h->ldsym->l_ifile = (bfd_size_type) -1;
- else
- {
- unsigned int c;
- struct xcoff_import_file **pp;
-
- /* We start c at 1 because the first entry in the import list is
- reserved for the library search path. */
- for (pp = &xcoff_hash_table (info)->imports, c = 1;
- *pp != NULL;
- pp = &(*pp)->next, ++c)
- {
- if (strcmp ((*pp)->path, imppath) == 0
- && strcmp ((*pp)->file, impfile) == 0
- && strcmp ((*pp)->member, impmember) == 0)
- break;
- }
-
- if (*pp == NULL)
- {
- struct xcoff_import_file *n;
-
- n = ((struct xcoff_import_file *)
- bfd_alloc (output_bfd, sizeof (struct xcoff_import_file)));
- if (n == NULL)
- return false;
- n->next = NULL;
- n->path = imppath;
- n->file = impfile;
- n->member = impmember;
- *pp = n;
- }
-
- h->ldsym->l_ifile = c;
- }
-
- return true;
-}
-
-/* Export a symbol. */
-
-boolean
-bfd_xcoff_export_symbol (output_bfd, info, harg, syscall)
- bfd *output_bfd;
- struct bfd_link_info *info;
- struct bfd_link_hash_entry *harg;
- boolean syscall;
-{
- struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
-
- if (! XCOFF_XVECP (output_bfd->xvec))
- return true;
-
- h->flags |= XCOFF_EXPORT;
-
- /* FIXME: I'm not at all sure what syscall is supposed to mean, so
- I'm just going to ignore it until somebody explains it. */
-
- /* See if this is a function descriptor. It may be one even though
- it is not so marked. */
- if ((h->flags & XCOFF_DESCRIPTOR) == 0
- && h->root.root.string[0] != '.')
- {
- char *fnname;
- struct xcoff_link_hash_entry *hfn;
-
- fnname = (char *) bfd_malloc (strlen (h->root.root.string) + 2);
- if (fnname == NULL)
- return false;
- fnname[0] = '.';
- strcpy (fnname + 1, h->root.root.string);
- hfn = xcoff_link_hash_lookup (xcoff_hash_table (info),
- fnname, false, false, true);
- free (fnname);
- if (hfn != NULL
- && hfn->smclas == XMC_PR
- && (hfn->root.type == bfd_link_hash_defined
- || hfn->root.type == bfd_link_hash_defweak))
- {
- h->flags |= XCOFF_DESCRIPTOR;
- h->descriptor = hfn;
- hfn->descriptor = h;
- }
- }
-
- /* Make sure we don't garbage collect this symbol. */
- if (! xcoff_mark_symbol (info, h))
- return false;
-
- /* If this is a function descriptor, make sure we don't garbage
- collect the associated function code. We normally don't have to
- worry about this, because the descriptor will be attached to a
- section with relocs, but if we are creating the descriptor
- ourselves those relocs will not be visible to the mark code. */
- if ((h->flags & XCOFF_DESCRIPTOR) != 0)
- {
- if (! xcoff_mark_symbol (info, h->descriptor))
- return false;
- }
-
- return true;
-}
-
-/* Count a reloc against a symbol. This is called for relocs
- generated by the linker script, typically for global constructors
- and destructors. */
-
-boolean
-bfd_xcoff_link_count_reloc (output_bfd, info, name)
- bfd *output_bfd;
- struct bfd_link_info *info;
- const char *name;
-{
- struct xcoff_link_hash_entry *h;
-
- if (! XCOFF_XVECP (output_bfd->xvec))
- return true;
-
- h = ((struct xcoff_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (output_bfd, info, name, false, false,
- false));
- if (h == NULL)
- {
- (*_bfd_error_handler) ("%s: no such symbol", name);
- bfd_set_error (bfd_error_no_symbols);
- return false;
- }
-
- h->flags |= XCOFF_REF_REGULAR | XCOFF_LDREL;
- ++xcoff_hash_table (info)->ldrel_count;
-
- /* Mark the symbol to avoid garbage collection. */
- if (! xcoff_mark_symbol (info, h))
- return false;
-
- return true;
-}
-
-/* This function is called for each symbol to which the linker script
- assigns a value. */
-
-boolean
-bfd_xcoff_record_link_assignment (output_bfd, info, name)
- bfd *output_bfd;
- struct bfd_link_info *info;
- const char *name;
-{
- struct xcoff_link_hash_entry *h;
-
- if (! XCOFF_XVECP (output_bfd->xvec))
- return true;
-
- h = xcoff_link_hash_lookup (xcoff_hash_table (info), name, true, true,
- false);
- if (h == NULL)
- return false;
-
- h->flags |= XCOFF_DEF_REGULAR;
-
- return true;
-}
-
-/* This structure is used to pass information through
- xcoff_link_hash_traverse. */
-
-struct xcoff_loader_info
-{
- /* Set if a problem occurred. */
- boolean failed;
- /* Output BFD. */
- bfd *output_bfd;
- /* Link information structure. */
- struct bfd_link_info *info;
- /* Whether all defined symbols should be exported. */
- boolean export_defineds;
- /* Number of ldsym structures. */
- size_t ldsym_count;
- /* Size of string table. */
- size_t string_size;
- /* String table. */
- bfd_byte *strings;
- /* Allocated size of string table. */
- size_t string_alc;
-};
-
-/* Build the .loader section. This is called by the XCOFF linker
- emulation before_allocation routine. We must set the size of the
- .loader section before the linker lays out the output file.
- LIBPATH is the library path to search for shared objects; this is
- normally built from the -L arguments passed to the linker. ENTRY
- is the name of the entry point symbol (the -e linker option).
- FILE_ALIGN is the alignment to use for sections within the file
- (the -H linker option). MAXSTACK is the maximum stack size (the
- -bmaxstack linker option). MAXDATA is the maximum data size (the
- -bmaxdata linker option). GC is whether to do garbage collection
- (the -bgc linker option). MODTYPE is the module type (the
- -bmodtype linker option). TEXTRO is whether the text section must
- be read only (the -btextro linker option). EXPORT_DEFINEDS is
- whether all defined symbols should be exported (the -unix linker
- option). SPECIAL_SECTIONS is set by this routine to csects with
- magic names like _end. */
-
-boolean
-bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry,
- file_align, maxstack, maxdata, gc,
- modtype, textro, export_defineds,
- special_sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- const char *libpath;
- const char *entry;
- unsigned long file_align;
- unsigned long maxstack;
- unsigned long maxdata;
- boolean gc;
- int modtype;
- boolean textro;
- boolean export_defineds;
- asection **special_sections;
-{
- struct xcoff_link_hash_entry *hentry;
- asection *lsec;
- struct xcoff_loader_info ldinfo;
- int i;
- size_t impsize, impcount;
- struct xcoff_import_file *fl;
- struct internal_ldhdr *ldhdr;
- bfd_size_type stoff;
- register char *out;
- asection *sec;
- bfd *sub;
- struct bfd_strtab_hash *debug_strtab;
- bfd_byte *debug_contents = NULL;
-
- if (! XCOFF_XVECP (output_bfd->xvec))
- {
- for (i = 0; i < 6; i++)
- special_sections[i] = NULL;
- return true;
- }
-
- ldinfo.failed = false;
- ldinfo.output_bfd = output_bfd;
- ldinfo.info = info;
- ldinfo.export_defineds = export_defineds;
- ldinfo.ldsym_count = 0;
- ldinfo.string_size = 0;
- ldinfo.strings = NULL;
- ldinfo.string_alc = 0;
-
- xcoff_data (output_bfd)->maxstack = maxstack;
- xcoff_data (output_bfd)->maxdata = maxdata;
- xcoff_data (output_bfd)->modtype = modtype;
-
- xcoff_hash_table (info)->file_align = file_align;
- xcoff_hash_table (info)->textro = textro;
-
- hentry = xcoff_link_hash_lookup (xcoff_hash_table (info), entry,
- false, false, true);
- if (hentry != NULL)
- hentry->flags |= XCOFF_ENTRY;
-
- /* Garbage collect unused sections. */
- if (info->relocateable
- || ! gc
- || hentry == NULL
- || (hentry->root.type != bfd_link_hash_defined
- && hentry->root.type != bfd_link_hash_defweak))
- {
- gc = false;
- xcoff_hash_table (info)->gc = false;
-
- /* We still need to call xcoff_mark, in order to set ldrel_count
- correctly. */
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- asection *o;
-
- for (o = sub->sections; o != NULL; o = o->next)
- {
- if ((o->flags & SEC_MARK) == 0)
- {
- if (! xcoff_mark (info, o))
- goto error_return;
- }
- }
- }
- }
- else
- {
- if (! xcoff_mark (info, hentry->root.u.def.section))
- goto error_return;
- xcoff_sweep (info);
- xcoff_hash_table (info)->gc = true;
- }
-
- /* Return special sections to the caller. */
- for (i = 0; i < 6; i++)
- {
- asection *sec;
-
- sec = xcoff_hash_table (info)->special_sections[i];
- if (sec != NULL
- && gc
- && (sec->flags & SEC_MARK) == 0)
- sec = NULL;
- special_sections[i] = sec;
- }
-
- if (info->input_bfds == NULL)
- {
- /* I'm not sure what to do in this bizarre case. */
- return true;
- }
-
- xcoff_link_hash_traverse (xcoff_hash_table (info), xcoff_build_ldsyms,
- (PTR) &ldinfo);
- if (ldinfo.failed)
- goto error_return;
-
- /* Work out the size of the import file names. Each import file ID
- consists of three null terminated strings: the path, the file
- name, and the archive member name. The first entry in the list
- of names is the path to use to find objects, which the linker has
- passed in as the libpath argument. For some reason, the path
- entry in the other import file names appears to always be empty. */
- impsize = strlen (libpath) + 3;
- impcount = 1;
- for (fl = xcoff_hash_table (info)->imports; fl != NULL; fl = fl->next)
- {
- ++impcount;
- impsize += (strlen (fl->path)
- + strlen (fl->file)
- + strlen (fl->member)
- + 3);
- }
-
- /* Set up the .loader section header. */
- ldhdr = &xcoff_hash_table (info)->ldhdr;
- ldhdr->l_version = 1;
- ldhdr->l_nsyms = ldinfo.ldsym_count;
- ldhdr->l_nreloc = xcoff_hash_table (info)->ldrel_count;
- ldhdr->l_istlen = impsize;
- ldhdr->l_nimpid = impcount;
- ldhdr->l_impoff = (LDHDRSZ
- + ldhdr->l_nsyms * LDSYMSZ
- + ldhdr->l_nreloc * LDRELSZ);
- ldhdr->l_stlen = ldinfo.string_size;
- stoff = ldhdr->l_impoff + impsize;
- if (ldinfo.string_size == 0)
- ldhdr->l_stoff = 0;
- else
- ldhdr->l_stoff = stoff;
-
- /* We now know the final size of the .loader section. Allocate
- space for it. */
- lsec = xcoff_hash_table (info)->loader_section;
- lsec->_raw_size = stoff + ldhdr->l_stlen;
- lsec->contents = (bfd_byte *) bfd_zalloc (output_bfd, lsec->_raw_size);
- if (lsec->contents == NULL)
- goto error_return;
-
- /* Set up the header. */
- xcoff_swap_ldhdr_out (output_bfd, ldhdr,
- (struct external_ldhdr *) lsec->contents);
-
- /* Set up the import file names. */
- out = (char *) lsec->contents + ldhdr->l_impoff;
- strcpy (out, libpath);
- out += strlen (libpath) + 1;
- *out++ = '\0';
- *out++ = '\0';
- for (fl = xcoff_hash_table (info)->imports; fl != NULL; fl = fl->next)
- {
- register const char *s;
-
- s = fl->path;
- while ((*out++ = *s++) != '\0')
- ;
- s = fl->file;
- while ((*out++ = *s++) != '\0')
- ;
- s = fl->member;
- while ((*out++ = *s++) != '\0')
- ;
- }
-
- BFD_ASSERT ((bfd_size_type) ((bfd_byte *) out - lsec->contents) == stoff);
-
- /* Set up the symbol string table. */
- if (ldinfo.string_size > 0)
- {
- memcpy (out, ldinfo.strings, ldinfo.string_size);
- free (ldinfo.strings);
- ldinfo.strings = NULL;
- }
-
- /* We can't set up the symbol table or the relocs yet, because we
- don't yet know the final position of the various sections. The
- .loader symbols are written out when the corresponding normal
- symbols are written out in xcoff_link_input_bfd or
- xcoff_write_global_symbol. The .loader relocs are written out
- when the corresponding normal relocs are handled in
- xcoff_link_input_bfd. */
-
- /* Allocate space for the magic sections. */
- sec = xcoff_hash_table (info)->linkage_section;
- if (sec->_raw_size > 0)
- {
- sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
- if (sec->contents == NULL)
- goto error_return;
- }
- sec = xcoff_hash_table (info)->toc_section;
- if (sec->_raw_size > 0)
- {
- sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
- if (sec->contents == NULL)
- goto error_return;
- }
- sec = xcoff_hash_table (info)->descriptor_section;
- if (sec->_raw_size > 0)
- {
- sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);
- if (sec->contents == NULL)
- goto error_return;
- }
-
- /* Now that we've done garbage collection, figure out the contents
- of the .debug section. */
- debug_strtab = xcoff_hash_table (info)->debug_strtab;
-
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- asection *subdeb;
- bfd_size_type symcount;
- unsigned long *debug_index;
- asection **csectpp;
- bfd_byte *esym, *esymend;
- bfd_size_type symesz;
-
- if (sub->xvec != info->hash->creator)
- continue;
- subdeb = bfd_get_section_by_name (sub, ".debug");
- if (subdeb == NULL || subdeb->_raw_size == 0)
- continue;
-
- if (info->strip == strip_all
- || info->strip == strip_debugger
- || info->discard == discard_all)
- {
- subdeb->_raw_size = 0;
- continue;
- }
-
- if (! _bfd_coff_get_external_symbols (sub))
- goto error_return;
-
- symcount = obj_raw_syment_count (sub);
- debug_index = ((unsigned long *)
- bfd_zalloc (sub, symcount * sizeof (unsigned long)));
- if (debug_index == NULL)
- goto error_return;
- xcoff_data (sub)->debug_indices = debug_index;
-
- /* Grab the contents of the .debug section. We use malloc and
- copy the neams into the debug stringtab, rather than
- bfd_alloc, because I expect that, when linking many files
- together, many of the strings will be the same. Storing the
- strings in the hash table should save space in this case. */
- debug_contents = (bfd_byte *) bfd_malloc (subdeb->_raw_size);
- if (debug_contents == NULL)
- goto error_return;
- if (! bfd_get_section_contents (sub, subdeb, (PTR) debug_contents,
- (file_ptr) 0, subdeb->_raw_size))
- goto error_return;
-
- csectpp = xcoff_data (sub)->csects;
-
- symesz = bfd_coff_symesz (sub);
- esym = (bfd_byte *) obj_coff_external_syms (sub);
- esymend = esym + symcount * symesz;
- while (esym < esymend)
- {
- struct internal_syment sym;
-
- bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym);
-
- *debug_index = (unsigned long) -1;
-
- if (sym._n._n_n._n_zeroes == 0
- && *csectpp != NULL
- && (! gc
- || ((*csectpp)->flags & SEC_MARK) != 0
- || *csectpp == bfd_abs_section_ptr)
- && bfd_coff_symname_in_debug (sub, &sym))
- {
- char *name;
- bfd_size_type indx;
-
- name = (char *) debug_contents + sym._n._n_n._n_offset;
- indx = _bfd_stringtab_add (debug_strtab, name, true, true);
- if (indx == (bfd_size_type) -1)
- goto error_return;
- *debug_index = indx;
- }
-
- esym += (sym.n_numaux + 1) * symesz;
- csectpp += sym.n_numaux + 1;
- debug_index += sym.n_numaux + 1;
- }
-
- free (debug_contents);
- debug_contents = NULL;
-
- /* Clear the size of subdeb, so that it is not included directly
- in the output file. */
- subdeb->_raw_size = 0;
-
- if (! info->keep_memory)
- {
- if (! _bfd_coff_free_symbols (sub))
- goto error_return;
- }
- }
-
- xcoff_hash_table (info)->debug_section->_raw_size =
- _bfd_stringtab_size (debug_strtab);
-
- return true;
-
- error_return:
- if (ldinfo.strings != NULL)
- free (ldinfo.strings);
- if (debug_contents != NULL)
- free (debug_contents);
- return false;
-}
-
-/* Add a symbol to the .loader symbols, if necessary. */
-
-static boolean
-xcoff_build_ldsyms (h, p)
- struct xcoff_link_hash_entry *h;
- PTR p;
-{
- struct xcoff_loader_info *ldinfo = (struct xcoff_loader_info *) p;
- size_t len;
-
- /* If all defined symbols should be exported, mark them now. */
- if (ldinfo->export_defineds
- && (h->flags & XCOFF_DEF_REGULAR) != 0)
- h->flags |= XCOFF_EXPORT;
-
- /* We don't want to garbage collect symbols which are not defined in
- XCOFF files. This is a convenient place to mark them. */
- if (xcoff_hash_table (ldinfo->info)->gc
- && (h->flags & XCOFF_MARK) == 0
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && (h->root.u.def.section->owner == NULL
- || (h->root.u.def.section->owner->xvec
- != ldinfo->info->hash->creator)))
- h->flags |= XCOFF_MARK;
-
- /* If this symbol is called and defined in a dynamic object, or not
- defined at all when building a shared object, or imported, then
- we need to set up global linkage code for it. (Unless we did
- garbage collection and we didn't need this symbol.) */
- if ((h->flags & XCOFF_CALLED) != 0
- && (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- && h->root.root.string[0] == '.'
- && h->descriptor != NULL
- && ((h->descriptor->flags & XCOFF_DEF_DYNAMIC) != 0
- || ldinfo->info->shared
- || ((h->descriptor->flags & XCOFF_IMPORT) != 0
- && (h->descriptor->flags & XCOFF_DEF_REGULAR) == 0))
- && (! xcoff_hash_table (ldinfo->info)->gc
- || (h->flags & XCOFF_MARK) != 0))
- {
- asection *sec;
- struct xcoff_link_hash_entry *hds;
-
- sec = xcoff_hash_table (ldinfo->info)->linkage_section;
- h->root.type = bfd_link_hash_defined;
- h->root.u.def.section = sec;
- h->root.u.def.value = sec->_raw_size;
- h->smclas = XMC_GL;
- h->flags |= XCOFF_DEF_REGULAR;
- sec->_raw_size += XCOFF_GLINK_SIZE;
-
- /* The global linkage code requires a TOC entry for the
- descriptor. */
- hds = h->descriptor;
- BFD_ASSERT ((hds->root.type == bfd_link_hash_undefined
- || hds->root.type == bfd_link_hash_undefweak)
- && (hds->flags & XCOFF_DEF_REGULAR) == 0);
- hds->flags |= XCOFF_MARK;
- if (hds->toc_section == NULL)
- {
- hds->toc_section = xcoff_hash_table (ldinfo->info)->toc_section;
- hds->u.toc_offset = hds->toc_section->_raw_size;
- hds->toc_section->_raw_size += 4;
- ++xcoff_hash_table (ldinfo->info)->ldrel_count;
- ++hds->toc_section->reloc_count;
- hds->indx = -2;
- hds->flags |= XCOFF_SET_TOC | XCOFF_LDREL;
-
- /* We need to call xcoff_build_ldsyms recursively here,
- because we may already have passed hds on the traversal. */
- xcoff_build_ldsyms (hds, p);
- }
- }
-
- /* If this symbol is exported, but not defined, we need to try to
- define it. */
- if ((h->flags & XCOFF_EXPORT) != 0
- && (h->flags & XCOFF_IMPORT) == 0
- && (h->flags & XCOFF_DEF_REGULAR) == 0
- && (h->flags & XCOFF_DEF_DYNAMIC) == 0
- && (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak))
- {
- if ((h->flags & XCOFF_DESCRIPTOR) != 0
- && (h->descriptor->root.type == bfd_link_hash_defined
- || h->descriptor->root.type == bfd_link_hash_defweak))
- {
- asection *sec;
-
- /* This is an undefined function descriptor associated with
- a defined entry point. We can build up a function
- descriptor ourselves. Believe it or not, the AIX linker
- actually does this, and there are cases where we need to
- do it as well. */
- sec = xcoff_hash_table (ldinfo->info)->descriptor_section;
- h->root.type = bfd_link_hash_defined;
- h->root.u.def.section = sec;
- h->root.u.def.value = sec->_raw_size;
- h->smclas = XMC_DS;
- h->flags |= XCOFF_DEF_REGULAR;
- sec->_raw_size += 12;
-
- /* A function descriptor uses two relocs: one for the
- associated code, and one for the TOC address. */
- xcoff_hash_table (ldinfo->info)->ldrel_count += 2;
- sec->reloc_count += 2;
-
- /* We handle writing out the contents of the descriptor in
- xcoff_write_global_symbol. */
- }
- else
- {
- (*_bfd_error_handler)
- ("attempt to export undefined symbol `%s'",
- h->root.root.string);
- ldinfo->failed = true;
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
- }
-
- /* If this is still a common symbol, and it wasn't garbage
- collected, we need to actually allocate space for it in the .bss
- section. */
- if (h->root.type == bfd_link_hash_common
- && (! xcoff_hash_table (ldinfo->info)->gc
- || (h->flags & XCOFF_MARK) != 0)
- && h->root.u.c.p->section->_raw_size == 0)
- {
- BFD_ASSERT (bfd_is_com_section (h->root.u.c.p->section));
- h->root.u.c.p->section->_raw_size = h->root.u.c.size;
- }
-
- /* We need to add a symbol to the .loader section if it is mentioned
- in a reloc which we are copying to the .loader section and it was
- not defined or common, or if it is the entry point, or if it is
- being exported. */
-
- if (((h->flags & XCOFF_LDREL) == 0
- || h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_common)
- && (h->flags & XCOFF_ENTRY) == 0
- && (h->flags & XCOFF_EXPORT) == 0)
- {
- h->ldsym = NULL;
- return true;
- }
-
- /* We don't need to add this symbol if we did garbage collection and
- we did not mark this symbol. */
- if (xcoff_hash_table (ldinfo->info)->gc
- && (h->flags & XCOFF_MARK) == 0)
- {
- h->ldsym = NULL;
- return true;
- }
-
- /* We may have already processed this symbol due to the recursive
- call above. */
- if ((h->flags & XCOFF_BUILT_LDSYM) != 0)
- return true;
-
- /* We need to add this symbol to the .loader symbols. */
-
- /* h->ldsym will already have been allocated for an explicitly
- imported symbol. */
- if (h->ldsym == NULL)
- {
- h->ldsym = ((struct internal_ldsym *)
- bfd_zalloc (ldinfo->output_bfd,
- sizeof (struct internal_ldsym)));
- if (h->ldsym == NULL)
- {
- ldinfo->failed = true;
- return false;
- }
- }
-
- /* The first 3 symbol table indices are reserved to indicate the
- sections. */
- h->ldindx = ldinfo->ldsym_count + 3;
-
- ++ldinfo->ldsym_count;
-
- len = strlen (h->root.root.string);
- if (len <= SYMNMLEN)
- strncpy (h->ldsym->_l._l_name, h->root.root.string, SYMNMLEN);
- else
- {
- if (ldinfo->string_size + len + 3 > ldinfo->string_alc)
- {
- size_t newalc;
- bfd_byte *newstrings;
-
- newalc = ldinfo->string_alc * 2;
- if (newalc == 0)
- newalc = 32;
- while (ldinfo->string_size + len + 3 > newalc)
- newalc *= 2;
-
- newstrings = ((bfd_byte *)
- bfd_realloc ((PTR) ldinfo->strings, newalc));
- if (newstrings == NULL)
- {
- ldinfo->failed = true;
- return false;
- }
- ldinfo->string_alc = newalc;
- ldinfo->strings = newstrings;
- }
-
- bfd_put_16 (ldinfo->output_bfd, len + 1,
- ldinfo->strings + ldinfo->string_size);
- strcpy (ldinfo->strings + ldinfo->string_size + 2, h->root.root.string);
- h->ldsym->_l._l_l._l_zeroes = 0;
- h->ldsym->_l._l_l._l_offset = ldinfo->string_size + 2;
- ldinfo->string_size += len + 3;
- }
-
- h->flags |= XCOFF_BUILT_LDSYM;
-
- return true;
-}
-
-/* Do the final link step. */
-
-boolean
-_bfd_xcoff_bfd_final_link (abfd, info)
- bfd *abfd;
- struct bfd_link_info *info;
-{
- bfd_size_type symesz;
- struct xcoff_final_link_info finfo;
- asection *o;
- struct bfd_link_order *p;
- size_t max_contents_size;
- size_t max_sym_count;
- size_t max_lineno_count;
- size_t max_reloc_count;
- size_t max_output_reloc_count;
- file_ptr rel_filepos;
- unsigned int relsz;
- file_ptr line_filepos;
- unsigned int linesz;
- bfd *sub;
- bfd_byte *external_relocs = NULL;
- char strbuf[STRING_SIZE_SIZE];
-
- if (info->shared)
- abfd->flags |= DYNAMIC;
-
- symesz = bfd_coff_symesz (abfd);
-
- finfo.info = info;
- finfo.output_bfd = abfd;
- finfo.strtab = NULL;
- finfo.section_info = NULL;
- finfo.last_file_index = -1;
- finfo.toc_symindx = -1;
- finfo.internal_syms = NULL;
- finfo.sym_indices = NULL;
- finfo.outsyms = NULL;
- finfo.linenos = NULL;
- finfo.contents = NULL;
- finfo.external_relocs = NULL;
-
- finfo.ldsym = ((struct external_ldsym *)
- (xcoff_hash_table (info)->loader_section->contents
- + LDHDRSZ));
- finfo.ldrel = ((struct external_ldrel *)
- (xcoff_hash_table (info)->loader_section->contents
- + LDHDRSZ
- + xcoff_hash_table (info)->ldhdr.l_nsyms * LDSYMSZ));
-
- xcoff_data (abfd)->coff.link_info = info;
-
- finfo.strtab = _bfd_stringtab_init ();
- if (finfo.strtab == NULL)
- goto error_return;
-
- /* Count the line number and relocation entries required for the
- output file. Determine a few maximum sizes. */
- max_contents_size = 0;
- max_lineno_count = 0;
- max_reloc_count = 0;
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- o->reloc_count = 0;
- o->lineno_count = 0;
- for (p = o->link_order_head; p != NULL; p = p->next)
- {
- if (p->type == bfd_indirect_link_order)
- {
- asection *sec;
-
- sec = p->u.indirect.section;
-
- if (info->strip == strip_none
- || info->strip == strip_some)
- o->lineno_count += sec->lineno_count;
-
- o->reloc_count += sec->reloc_count;
-
- if (sec->_raw_size > max_contents_size)
- max_contents_size = sec->_raw_size;
- if (sec->lineno_count > max_lineno_count)
- max_lineno_count = sec->lineno_count;
- if (coff_section_data (sec->owner, sec) != NULL
- && xcoff_section_data (sec->owner, sec) != NULL
- && (xcoff_section_data (sec->owner, sec)->lineno_count
- > max_lineno_count))
- max_lineno_count =
- xcoff_section_data (sec->owner, sec)->lineno_count;
- if (sec->reloc_count > max_reloc_count)
- max_reloc_count = sec->reloc_count;
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- ++o->reloc_count;
- }
- }
-
- /* Compute the file positions for all the sections. */
- if (abfd->output_has_begun)
- {
- if (xcoff_hash_table (info)->file_align != 0)
- abort ();
- }
- else
- {
- bfd_vma file_align;
-
- file_align = xcoff_hash_table (info)->file_align;
- if (file_align != 0)
- {
- boolean saw_contents;
- int indx;
- asection **op;
- file_ptr sofar;
-
- /* Insert .pad sections before every section which has
- contents and is loaded, if it is preceded by some other
- section which has contents and is loaded. */
- saw_contents = true;
- for (op = &abfd->sections; *op != NULL; op = &(*op)->next)
- {
- (*op)->target_index = indx;
- if (strcmp ((*op)->name, ".pad") == 0)
- saw_contents = false;
- else if (((*op)->flags & SEC_HAS_CONTENTS) != 0
- && ((*op)->flags & SEC_LOAD) != 0)
- {
- if (! saw_contents)
- saw_contents = true;
- else
- {
- asection *n, *hold;
-
- hold = *op;
- *op = NULL;
- n = bfd_make_section_anyway (abfd, ".pad");
- BFD_ASSERT (*op == n);
- n->next = hold;
- n->flags = SEC_HAS_CONTENTS;
- n->alignment_power = 0;
- saw_contents = false;
- }
- }
- }
-
- /* Reset the section indices after inserting the new
- sections. */
- indx = 0;
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- ++indx;
- o->target_index = indx;
- }
- BFD_ASSERT ((unsigned int) indx == abfd->section_count);
-
- /* Work out appropriate sizes for the .pad sections to force
- each section to land on a page boundary. This bit of
- code knows what compute_section_file_positions is going
- to do. */
- sofar = bfd_coff_filhsz (abfd);
- sofar += bfd_coff_aoutsz (abfd);
- sofar += abfd->section_count * bfd_coff_scnhsz (abfd);
- for (o = abfd->sections; o != NULL; o = o->next)
- if (o->reloc_count >= 0xffff || o->lineno_count >= 0xffff)
- sofar += bfd_coff_scnhsz (abfd);
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if (strcmp (o->name, ".pad") == 0)
- {
- bfd_vma pageoff;
-
- BFD_ASSERT (o->_raw_size == 0);
- pageoff = sofar & (file_align - 1);
- if (pageoff != 0)
- {
- o->_raw_size = file_align - pageoff;
- sofar += file_align - pageoff;
- o->flags |= SEC_HAS_CONTENTS;
- }
- }
- else
- {
- if ((o->flags & SEC_HAS_CONTENTS) != 0)
- sofar += BFD_ALIGN (o->_raw_size,
- 1 << o->alignment_power);
- }
- }
- }
-
- bfd_coff_compute_section_file_positions (abfd);
- }
-
- /* Allocate space for the pointers we need to keep for the relocs. */
- {
- unsigned int i;
-
- /* We use section_count + 1, rather than section_count, because
- the target_index fields are 1 based. */
- finfo.section_info =
- ((struct xcoff_link_section_info *)
- bfd_malloc ((abfd->section_count + 1)
- * sizeof (struct xcoff_link_section_info)));
- if (finfo.section_info == NULL)
- goto error_return;
- for (i = 0; i <= abfd->section_count; i++)
- {
- finfo.section_info[i].relocs = NULL;
- finfo.section_info[i].rel_hashes = NULL;
- finfo.section_info[i].toc_rel_hashes = NULL;
- }
- }
-
- /* Set the file positions for the relocs. */
- rel_filepos = obj_relocbase (abfd);
- relsz = bfd_coff_relsz (abfd);
- max_output_reloc_count = 0;
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if (o->reloc_count == 0)
- o->rel_filepos = 0;
- else
- {
- o->flags |= SEC_RELOC;
- o->rel_filepos = rel_filepos;
- rel_filepos += o->reloc_count * relsz;
-
- /* We don't know the indices of global symbols until we have
- written out all the local symbols. For each section in
- the output file, we keep an array of pointers to hash
- table entries. Each entry in the array corresponds to a
- reloc. When we find a reloc against a global symbol, we
- set the corresponding entry in this array so that we can
- fix up the symbol index after we have written out all the
- local symbols.
-
- Because of this problem, we also keep the relocs in
- memory until the end of the link. This wastes memory.
- We could backpatch the file later, I suppose, although it
- would be slow. */
- finfo.section_info[o->target_index].relocs =
- ((struct internal_reloc *)
- bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
- finfo.section_info[o->target_index].rel_hashes =
- ((struct xcoff_link_hash_entry **)
- bfd_malloc (o->reloc_count
- * sizeof (struct xcoff_link_hash_entry *)));
- if (finfo.section_info[o->target_index].relocs == NULL
- || finfo.section_info[o->target_index].rel_hashes == NULL)
- goto error_return;
-
- if (o->reloc_count > max_output_reloc_count)
- max_output_reloc_count = o->reloc_count;
- }
- }
-
- /* We now know the size of the relocs, so we can determine the file
- positions of the line numbers. */
- line_filepos = rel_filepos;
- finfo.line_filepos = line_filepos;
- linesz = bfd_coff_linesz (abfd);
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- if (o->lineno_count == 0)
- o->line_filepos = 0;
- else
- {
- o->line_filepos = line_filepos;
- line_filepos += o->lineno_count * linesz;
- }
-
- /* Reset the reloc and lineno counts, so that we can use them to
- count the number of entries we have output so far. */
- o->reloc_count = 0;
- o->lineno_count = 0;
- }
-
- obj_sym_filepos (abfd) = line_filepos;
-
- /* Figure out the largest number of symbols in an input BFD. Take
- the opportunity to clear the output_has_begun fields of all the
- input BFD's. We want at least 4 symbols, since that is the
- number which xcoff_write_global_symbol may need. */
- max_sym_count = 4;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
- {
- size_t sz;
-
- sub->output_has_begun = false;
- sz = obj_raw_syment_count (sub);
- if (sz > max_sym_count)
- max_sym_count = sz;
- }
-
- /* Allocate some buffers used while linking. */
- finfo.internal_syms = ((struct internal_syment *)
- bfd_malloc (max_sym_count
- * sizeof (struct internal_syment)));
- finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
- finfo.outsyms = ((bfd_byte *)
- bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
- finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
- * bfd_coff_linesz (abfd));
- finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
- finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
- if ((finfo.internal_syms == NULL && max_sym_count > 0)
- || (finfo.sym_indices == NULL && max_sym_count > 0)
- || finfo.outsyms == NULL
- || (finfo.linenos == NULL && max_lineno_count > 0)
- || (finfo.contents == NULL && max_contents_size > 0)
- || (finfo.external_relocs == NULL && max_reloc_count > 0))
- goto error_return;
-
- obj_raw_syment_count (abfd) = 0;
- xcoff_data (abfd)->toc = (bfd_vma) -1;
-
- /* We now know the position of everything in the file, except that
- we don't know the size of the symbol table and therefore we don't
- know where the string table starts. We just build the string
- table in memory as we go along. We process all the relocations
- for a single input file at once. */
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- for (p = o->link_order_head; p != NULL; p = p->next)
- {
- if (p->type == bfd_indirect_link_order
- && p->u.indirect.section->owner->xvec == abfd->xvec)
- {
- sub = p->u.indirect.section->owner;
- if (! sub->output_has_begun)
- {
- if (! xcoff_link_input_bfd (&finfo, sub))
- goto error_return;
- sub->output_has_begun = true;
- }
- }
- else if (p->type == bfd_section_reloc_link_order
- || p->type == bfd_symbol_reloc_link_order)
- {
- if (! xcoff_reloc_link_order (abfd, &finfo, o, p))
- goto error_return;
- }
- else
- {
- if (! _bfd_default_link_order (abfd, info, o, p))
- goto error_return;
- }
- }
- }
-
- /* Free up the buffers used by xcoff_link_input_bfd. */
-
- if (finfo.internal_syms != NULL)
- {
- free (finfo.internal_syms);
- finfo.internal_syms = NULL;
- }
- if (finfo.sym_indices != NULL)
- {
- free (finfo.sym_indices);
- finfo.sym_indices = NULL;
- }
- if (finfo.linenos != NULL)
- {
- free (finfo.linenos);
- finfo.linenos = NULL;
- }
- if (finfo.contents != NULL)
- {
- free (finfo.contents);
- finfo.contents = NULL;
- }
- if (finfo.external_relocs != NULL)
- {
- free (finfo.external_relocs);
- finfo.external_relocs = NULL;
- }
-
- /* The value of the last C_FILE symbol is supposed to be -1. Write
- it out again. */
- if (finfo.last_file_index != -1)
- {
- finfo.last_file.n_value = -1;
- bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
- (PTR) finfo.outsyms);
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + finfo.last_file_index * symesz),
- SEEK_SET) != 0
- || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
- goto error_return;
- }
-
- /* Write out all the global symbols which do not come from XCOFF
- input files. */
- xcoff_link_hash_traverse (xcoff_hash_table (info),
- xcoff_write_global_symbol,
- (PTR) &finfo);
-
- if (finfo.outsyms != NULL)
- {
- free (finfo.outsyms);
- finfo.outsyms = NULL;
- }
-
- /* Now that we have written out all the global symbols, we know the
- symbol indices to use for relocs against them, and we can finally
- write out the relocs. */
- external_relocs = (bfd_byte *) malloc (max_output_reloc_count * relsz);
- if (external_relocs == NULL && max_output_reloc_count != 0)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
-
- for (o = abfd->sections; o != NULL; o = o->next)
- {
- struct internal_reloc *irel;
- struct internal_reloc *irelend;
- struct xcoff_link_hash_entry **rel_hash;
- struct xcoff_toc_rel_hash *toc_rel_hash;
- bfd_byte *erel;
-
- if (o->reloc_count == 0)
- continue;
-
- irel = finfo.section_info[o->target_index].relocs;
- irelend = irel + o->reloc_count;
- rel_hash = finfo.section_info[o->target_index].rel_hashes;
- for (; irel < irelend; irel++, rel_hash++, erel += relsz)
- {
- if (*rel_hash != NULL)
- {
- if ((*rel_hash)->indx < 0)
- {
- if (! ((*info->callbacks->unattached_reloc)
- (info, (*rel_hash)->root.root.string,
- (bfd *) NULL, o, irel->r_vaddr)))
- goto error_return;
- (*rel_hash)->indx = 0;
- }
- irel->r_symndx = (*rel_hash)->indx;
- }
- }
-
- for (toc_rel_hash = finfo.section_info[o->target_index].toc_rel_hashes;
- toc_rel_hash != NULL;
- toc_rel_hash = toc_rel_hash->next)
- {
- if (toc_rel_hash->h->u.toc_indx < 0)
- {
- if (! ((*info->callbacks->unattached_reloc)
- (info, toc_rel_hash->h->root.root.string,
- (bfd *) NULL, o, toc_rel_hash->rel->r_vaddr)))
- goto error_return;
- toc_rel_hash->h->u.toc_indx = 0;
- }
- toc_rel_hash->rel->r_symndx = toc_rel_hash->h->u.toc_indx;
- }
-
- /* XCOFF requires that the relocs be sorted by address. We tend
- to produce them in the order in which their containing csects
- appear in the symbol table, which is not necessarily by
- address. So we sort them here. There may be a better way to
- do this. */
- qsort ((PTR) finfo.section_info[o->target_index].relocs,
- o->reloc_count, sizeof (struct internal_reloc),
- xcoff_sort_relocs);
-
- irel = finfo.section_info[o->target_index].relocs;
- irelend = irel + o->reloc_count;
- erel = external_relocs;
- for (; irel < irelend; irel++, rel_hash++, erel += relsz)
- bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
-
- if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
- || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
- abfd) != relsz * o->reloc_count)
- goto error_return;
- }
-
- if (external_relocs != NULL)
- {
- free (external_relocs);
- external_relocs = NULL;
- }
-
- /* Free up the section information. */
- if (finfo.section_info != NULL)
- {
- unsigned int i;
-
- for (i = 0; i < abfd->section_count; i++)
- {
- if (finfo.section_info[i].relocs != NULL)
- free (finfo.section_info[i].relocs);
- if (finfo.section_info[i].rel_hashes != NULL)
- free (finfo.section_info[i].rel_hashes);
- }
- free (finfo.section_info);
- finfo.section_info = NULL;
- }
-
- /* Write out the loader section contents. */
- BFD_ASSERT ((bfd_byte *) finfo.ldrel
- == (xcoff_hash_table (info)->loader_section->contents
- + xcoff_hash_table (info)->ldhdr.l_impoff));
- o = xcoff_hash_table (info)->loader_section;
- if (! bfd_set_section_contents (abfd, o->output_section,
- o->contents, o->output_offset,
- o->_raw_size))
- goto error_return;
-
- /* Write out the magic sections. */
- o = xcoff_hash_table (info)->linkage_section;
- if (o->_raw_size > 0
- && ! bfd_set_section_contents (abfd, o->output_section, o->contents,
- o->output_offset, o->_raw_size))
- goto error_return;
- o = xcoff_hash_table (info)->toc_section;
- if (o->_raw_size > 0
- && ! bfd_set_section_contents (abfd, o->output_section, o->contents,
- o->output_offset, o->_raw_size))
- goto error_return;
- o = xcoff_hash_table (info)->descriptor_section;
- if (o->_raw_size > 0
- && ! bfd_set_section_contents (abfd, o->output_section, o->contents,
- o->output_offset, o->_raw_size))
- goto error_return;
-
- /* Write out the string table. */
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * symesz),
- SEEK_SET) != 0)
- goto error_return;
- bfd_h_put_32 (abfd,
- _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
- (bfd_byte *) strbuf);
- if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
- goto error_return;
- if (! _bfd_stringtab_emit (abfd, finfo.strtab))
- goto error_return;
-
- _bfd_stringtab_free (finfo.strtab);
-
- /* Write out the debugging string table. */
- o = xcoff_hash_table (info)->debug_section;
- if (o != NULL)
- {
- struct bfd_strtab_hash *debug_strtab;
-
- debug_strtab = xcoff_hash_table (info)->debug_strtab;
- BFD_ASSERT (o->output_section->_raw_size - o->output_offset
- >= _bfd_stringtab_size (debug_strtab));
- if (bfd_seek (abfd,
- o->output_section->filepos + o->output_offset,
- SEEK_SET) != 0)
- goto error_return;
- if (! _bfd_stringtab_emit (abfd, debug_strtab))
- goto error_return;
- }
-
- /* Setting bfd_get_symcount to 0 will cause write_object_contents to
- not try to write out the symbols. */
- bfd_get_symcount (abfd) = 0;
-
- return true;
-
- error_return:
- if (finfo.strtab != NULL)
- _bfd_stringtab_free (finfo.strtab);
- if (finfo.section_info != NULL)
- {
- unsigned int i;
-
- for (i = 0; i < abfd->section_count; i++)
- {
- if (finfo.section_info[i].relocs != NULL)
- free (finfo.section_info[i].relocs);
- if (finfo.section_info[i].rel_hashes != NULL)
- free (finfo.section_info[i].rel_hashes);
- }
- free (finfo.section_info);
- }
- if (finfo.internal_syms != NULL)
- free (finfo.internal_syms);
- if (finfo.sym_indices != NULL)
- free (finfo.sym_indices);
- if (finfo.outsyms != NULL)
- free (finfo.outsyms);
- if (finfo.linenos != NULL)
- free (finfo.linenos);
- if (finfo.contents != NULL)
- free (finfo.contents);
- if (finfo.external_relocs != NULL)
- free (finfo.external_relocs);
- if (external_relocs != NULL)
- free (external_relocs);
- return false;
-}
-
-/* Link an input file into the linker output file. This function
- handles all the sections and relocations of the input file at once. */
-
-static boolean
-xcoff_link_input_bfd (finfo, input_bfd)
- struct xcoff_final_link_info *finfo;
- bfd *input_bfd;
-{
- bfd *output_bfd;
- const char *strings;
- bfd_size_type syment_base;
- unsigned int n_tmask;
- unsigned int n_btshft;
- boolean copy, hash;
- bfd_size_type isymesz;
- bfd_size_type osymesz;
- bfd_size_type linesz;
- bfd_byte *esym;
- bfd_byte *esym_end;
- struct xcoff_link_hash_entry **sym_hash;
- struct internal_syment *isymp;
- asection **csectpp;
- unsigned long *debug_index;
- long *indexp;
- unsigned long output_index;
- bfd_byte *outsym;
- unsigned int incls;
- asection *oline;
- boolean keep_syms;
- asection *o;
-
- /* We can just skip DYNAMIC files, unless this is a static link. */
- if ((input_bfd->flags & DYNAMIC) != 0
- && ! finfo->info->static_link)
- return true;
-
- /* Move all the symbols to the output file. */
-
- output_bfd = finfo->output_bfd;
- strings = NULL;
- syment_base = obj_raw_syment_count (output_bfd);
- isymesz = bfd_coff_symesz (input_bfd);
- osymesz = bfd_coff_symesz (output_bfd);
- linesz = bfd_coff_linesz (input_bfd);
- BFD_ASSERT (linesz == bfd_coff_linesz (output_bfd));
-
- n_tmask = coff_data (input_bfd)->local_n_tmask;
- n_btshft = coff_data (input_bfd)->local_n_btshft;
-
- /* Define macros so that ISFCN, et. al., macros work correctly. */
-#define N_TMASK n_tmask
-#define N_BTSHFT n_btshft
-
- copy = false;
- if (! finfo->info->keep_memory)
- copy = true;
- hash = true;
- if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
- hash = false;
-
- if (! _bfd_coff_get_external_symbols (input_bfd))
- return false;
-
- esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
- esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
- sym_hash = obj_xcoff_sym_hashes (input_bfd);
- csectpp = xcoff_data (input_bfd)->csects;
- debug_index = xcoff_data (input_bfd)->debug_indices;
- isymp = finfo->internal_syms;
- indexp = finfo->sym_indices;
- output_index = syment_base;
- outsym = finfo->outsyms;
- incls = 0;
- oline = NULL;
-
- while (esym < esym_end)
- {
- struct internal_syment isym;
- union internal_auxent aux;
- int smtyp = 0;
- boolean skip;
- boolean require;
- int add;
-
- bfd_coff_swap_sym_in (input_bfd, (PTR) esym, (PTR) isymp);
-
- /* If this is a C_EXT or C_HIDEXT symbol, we need the csect
- information. */
- if (isymp->n_sclass == C_EXT || isymp->n_sclass == C_HIDEXT)
- {
- BFD_ASSERT (isymp->n_numaux > 0);
- bfd_coff_swap_aux_in (input_bfd,
- (PTR) (esym + isymesz * isymp->n_numaux),
- isymp->n_type, isymp->n_sclass,
- isymp->n_numaux - 1, isymp->n_numaux,
- (PTR) &aux);
- smtyp = SMTYP_SMTYP (aux.x_csect.x_smtyp);
- }
-
- /* Make a copy of *isymp so that the relocate_section function
- always sees the original values. This is more reliable than
- always recomputing the symbol value even if we are stripping
- the symbol. */
- isym = *isymp;
-
- /* If this symbol is in the .loader section, swap out the
- .loader symbol information. If this is an external symbol
- reference to a defined symbol, though, then wait until we get
- to the definition. */
- if (isym.n_sclass == C_EXT
- && *sym_hash != NULL
- && (*sym_hash)->ldsym != NULL
- && (smtyp != XTY_ER
- || (*sym_hash)->root.type == bfd_link_hash_undefined))
- {
- struct xcoff_link_hash_entry *h;
- struct internal_ldsym *ldsym;
-
- h = *sym_hash;
- ldsym = h->ldsym;
- if (isym.n_scnum > 0)
- {
- ldsym->l_scnum = (*csectpp)->output_section->target_index;
- ldsym->l_value = (isym.n_value
- + (*csectpp)->output_section->vma
- + (*csectpp)->output_offset
- - (*csectpp)->vma);
- }
- else
- {
- ldsym->l_scnum = isym.n_scnum;
- ldsym->l_value = isym.n_value;
- }
-
- ldsym->l_smtype = smtyp;
- if (((h->flags & XCOFF_DEF_REGULAR) == 0
- && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
- || (h->flags & XCOFF_IMPORT) != 0)
- ldsym->l_smtype |= L_IMPORT;
- if (((h->flags & XCOFF_DEF_REGULAR) != 0
- && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
- || (h->flags & XCOFF_EXPORT) != 0)
- ldsym->l_smtype |= L_EXPORT;
- if ((h->flags & XCOFF_ENTRY) != 0)
- ldsym->l_smtype |= L_ENTRY;
-
- ldsym->l_smclas = aux.x_csect.x_smclas;
-
- if (ldsym->l_ifile == (bfd_size_type) -1)
- ldsym->l_ifile = 0;
- else if (ldsym->l_ifile == 0)
- {
- if ((ldsym->l_smtype & L_IMPORT) == 0)
- ldsym->l_ifile = 0;
- else
- {
- bfd *impbfd;
-
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- impbfd = h->root.u.def.section->owner;
- else if (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- impbfd = h->root.u.undef.abfd;
- else
- impbfd = NULL;
-
- if (impbfd == NULL)
- ldsym->l_ifile = 0;
- else
- {
- BFD_ASSERT (impbfd->xvec == finfo->output_bfd->xvec);
- ldsym->l_ifile = xcoff_data (impbfd)->import_file_id;
- }
- }
- }
-
- ldsym->l_parm = 0;
-
- BFD_ASSERT (h->ldindx >= 0);
- BFD_ASSERT (LDSYMSZ == sizeof (struct external_ldsym));
- xcoff_swap_ldsym_out (finfo->output_bfd, ldsym,
- finfo->ldsym + h->ldindx - 3);
- h->ldsym = NULL;
-
- /* Fill in snentry now that we know the target_index. */
- if ((h->flags & XCOFF_ENTRY) != 0
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak))
- xcoff_data (output_bfd)->snentry =
- h->root.u.def.section->output_section->target_index;
- }
-
- *indexp = -1;
-
- skip = false;
- require = false;
- add = 1 + isym.n_numaux;
-
- /* If we are skipping this csect, we want to skip this symbol. */
- if (*csectpp == NULL)
- skip = true;
-
- /* If we garbage collected this csect, we want to skip this
- symbol. */
- if (! skip
- && xcoff_hash_table (finfo->info)->gc
- && ((*csectpp)->flags & SEC_MARK) == 0
- && *csectpp != bfd_abs_section_ptr)
- skip = true;
-
- /* An XCOFF linker always skips C_STAT symbols. */
- if (! skip
- && isymp->n_sclass == C_STAT)
- skip = true;
-
- /* We skip all but the first TOC anchor. */
- if (! skip
- && isymp->n_sclass == C_HIDEXT
- && aux.x_csect.x_smclas == XMC_TC0)
- {
- if (finfo->toc_symindx != -1)
- skip = true;
- else
- {
- bfd_vma tocval, tocend;
-
- tocval = ((*csectpp)->output_section->vma
- + (*csectpp)->output_offset
- + isym.n_value
- - (*csectpp)->vma);
- /* We want to find out if tocval is a good value to use
- as the TOC anchor--that is, whether we can access all
- of the TOC using a 16 bit offset from tocval. This
- test assumes that the TOC comes at the end of the
- output section, as it does in the default linker
- script. If the TOC anchor is too far into the .toc
- section, the relocation routine will report
- overflows. */
- tocend = ((*csectpp)->output_section->vma
- + (*csectpp)->output_section->_raw_size);
- if (tocval + 0x8000 < tocend)
- {
- bfd_vma tocadd;
-
- tocadd = tocend - (tocval + 0x8000);
- tocval += tocadd;
- isym.n_value += tocadd;
- }
-
- finfo->toc_symindx = output_index;
- xcoff_data (finfo->output_bfd)->toc = tocval;
- xcoff_data (finfo->output_bfd)->sntoc =
- (*csectpp)->output_section->target_index;
- require = true;
- }
- }
-
- /* If we are stripping all symbols, we want to skip this one. */
- if (! skip
- && finfo->info->strip == strip_all)
- skip = true;
-
- /* We can skip resolved external references. */
- if (! skip
- && isym.n_sclass == C_EXT
- && smtyp == XTY_ER
- && (*sym_hash)->root.type != bfd_link_hash_undefined)
- skip = true;
-
- /* We can skip common symbols if they got defined somewhere
- else. */
- if (! skip
- && isym.n_sclass == C_EXT
- && smtyp == XTY_CM
- && ((*sym_hash)->root.type != bfd_link_hash_common
- || (*sym_hash)->root.u.c.p->section != *csectpp)
- && ((*sym_hash)->root.type != bfd_link_hash_defined
- || (*sym_hash)->root.u.def.section != *csectpp))
- skip = true;
-
- /* Skip local symbols if we are discarding them. */
- if (! skip
- && finfo->info->discard == discard_all
- && isym.n_sclass != C_EXT
- && (isym.n_sclass != C_HIDEXT
- || smtyp != XTY_SD))
- skip = true;
-
- /* If we stripping debugging symbols, and this is a debugging
- symbol, then skip it. */
- if (! skip
- && finfo->info->strip == strip_debugger
- && isym.n_scnum == N_DEBUG)
- skip = true;
-
- /* If some symbols are stripped based on the name, work out the
- name and decide whether to skip this symbol. We don't handle
- this correctly for symbols whose names are in the .debug
- section; to get it right we would need a new bfd_strtab_hash
- function to return the string given the index. */
- if (! skip
- && (finfo->info->strip == strip_some
- || finfo->info->discard == discard_l)
- && (debug_index == NULL || *debug_index == (unsigned long) -1))
- {
- const char *name;
- char buf[SYMNMLEN + 1];
-
- name = _bfd_coff_internal_syment_name (input_bfd, &isym, buf);
- if (name == NULL)
- return false;
-
- if ((finfo->info->strip == strip_some
- && (bfd_hash_lookup (finfo->info->keep_hash, name, false,
- false) == NULL))
- || (finfo->info->discard == discard_l
- && (isym.n_sclass != C_EXT
- && (isym.n_sclass != C_HIDEXT
- || smtyp != XTY_SD))
- && strncmp (name, finfo->info->lprefix,
- finfo->info->lprefix_len) == 0))
- skip = true;
- }
-
- /* We can not skip the first TOC anchor. */
- if (skip
- && require
- && finfo->info->strip != strip_all)
- skip = false;
-
- /* We now know whether we are to skip this symbol or not. */
- if (! skip)
- {
- /* Adjust the symbol in order to output it. */
-
- if (isym._n._n_n._n_zeroes == 0
- && isym._n._n_n._n_offset != 0)
- {
- /* This symbol has a long name. Enter it in the string
- table we are building. If *debug_index != -1, the
- name has already been entered in the .debug section. */
- if (debug_index != NULL && *debug_index != (unsigned long) -1)
- isym._n._n_n._n_offset = *debug_index;
- else
- {
- const char *name;
- bfd_size_type indx;
-
- name = _bfd_coff_internal_syment_name (input_bfd, &isym,
- (char *) NULL);
- if (name == NULL)
- return false;
- indx = _bfd_stringtab_add (finfo->strtab, name, hash, copy);
- if (indx == (bfd_size_type) -1)
- return false;
- isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
- }
- }
-
- if (isym.n_sclass != C_BSTAT
- && isym.n_sclass != C_ESTAT
- && isym.n_sclass != C_DECL
- && isym.n_scnum > 0)
- {
- isym.n_scnum = (*csectpp)->output_section->target_index;
- isym.n_value += ((*csectpp)->output_section->vma
- + (*csectpp)->output_offset
- - (*csectpp)->vma);
- }
-
- /* The value of a C_FILE symbol is the symbol index of the
- next C_FILE symbol. The value of the last C_FILE symbol
- is -1. We try to get this right, below, just before we
- write the symbols out, but in the general case we may
- have to write the symbol out twice. */
- if (isym.n_sclass == C_FILE)
- {
- if (finfo->last_file_index != -1
- && finfo->last_file.n_value != (long) output_index)
- {
- /* We must correct the value of the last C_FILE entry. */
- finfo->last_file.n_value = output_index;
- if ((bfd_size_type) finfo->last_file_index >= syment_base)
- {
- /* The last C_FILE symbol is in this input file. */
- bfd_coff_swap_sym_out (output_bfd,
- (PTR) &finfo->last_file,
- (PTR) (finfo->outsyms
- + ((finfo->last_file_index
- - syment_base)
- * osymesz)));
- }
- else
- {
- /* We have already written out the last C_FILE
- symbol. We need to write it out again. We
- borrow *outsym temporarily. */
- bfd_coff_swap_sym_out (output_bfd,
- (PTR) &finfo->last_file,
- (PTR) outsym);
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + finfo->last_file_index * osymesz),
- SEEK_SET) != 0
- || (bfd_write (outsym, osymesz, 1, output_bfd)
- != osymesz))
- return false;
- }
- }
-
- finfo->last_file_index = output_index;
- finfo->last_file = isym;
- }
-
- /* The value of a C_BINCL or C_EINCL symbol is a file offset
- into the line numbers. We update the symbol values when
- we handle the line numbers. */
- if (isym.n_sclass == C_BINCL
- || isym.n_sclass == C_EINCL)
- {
- isym.n_value = finfo->line_filepos;
- ++incls;
- }
-
- /* Output the symbol. */
-
- bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
-
- *indexp = output_index;
-
- if (isym.n_sclass == C_EXT)
- {
- long indx;
- struct xcoff_link_hash_entry *h;
-
- indx = ((esym - (bfd_byte *) obj_coff_external_syms (input_bfd))
- / isymesz);
- h = obj_xcoff_sym_hashes (input_bfd)[indx];
- BFD_ASSERT (h != NULL);
- h->indx = output_index;
- }
-
- /* If this is a symbol in the TOC which we may have merged
- (class XMC_TC), remember the symbol index of the TOC
- symbol. */
- if (isym.n_sclass == C_HIDEXT
- && aux.x_csect.x_smclas == XMC_TC
- && *sym_hash != NULL)
- {
- BFD_ASSERT (((*sym_hash)->flags & XCOFF_SET_TOC) == 0);
- BFD_ASSERT ((*sym_hash)->toc_section != NULL);
- (*sym_hash)->u.toc_indx = output_index;
- }
-
- output_index += add;
- outsym += add * osymesz;
- }
-
- esym += add * isymesz;
- isymp += add;
- csectpp += add;
- sym_hash += add;
- if (debug_index != NULL)
- debug_index += add;
- ++indexp;
- for (--add; add > 0; --add)
- *indexp++ = -1;
- }
-
- /* Fix up the aux entries and the C_BSTAT symbols. This must be
- done in a separate pass, because we don't know the correct symbol
- indices until we have already decided which symbols we are going
- to keep. */
-
- esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
- esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
- isymp = finfo->internal_syms;
- indexp = finfo->sym_indices;
- csectpp = xcoff_data (input_bfd)->csects;
- outsym = finfo->outsyms;
- while (esym < esym_end)
- {
- int add;
-
- add = 1 + isymp->n_numaux;
-
- if (*indexp < 0)
- esym += add * isymesz;
- else
- {
- int i;
-
- if (isymp->n_sclass == C_BSTAT)
- {
- struct internal_syment isym;
- unsigned long indx;
-
- /* The value of a C_BSTAT symbol is the symbol table
- index of the containing csect. */
- bfd_coff_swap_sym_in (output_bfd, (PTR) outsym, (PTR) &isym);
- indx = isym.n_value;
- if (indx < obj_raw_syment_count (input_bfd))
- {
- long symindx;
-
- symindx = finfo->sym_indices[indx];
- if (symindx < 0)
- isym.n_value = 0;
- else
- isym.n_value = symindx;
- bfd_coff_swap_sym_out (output_bfd, (PTR) &isym,
- (PTR) outsym);
- }
- }
-
- esym += isymesz;
- outsym += osymesz;
-
- for (i = 0; i < isymp->n_numaux && esym < esym_end; i++)
- {
- union internal_auxent aux;
-
- bfd_coff_swap_aux_in (input_bfd, (PTR) esym, isymp->n_type,
- isymp->n_sclass, i, isymp->n_numaux,
- (PTR) &aux);
-
- if (isymp->n_sclass == C_FILE)
- {
- /* This is the file name (or some comment put in by
- the compiler). If it is long, we must put it in
- the string table. */
- if (aux.x_file.x_n.x_zeroes == 0
- && aux.x_file.x_n.x_offset != 0)
- {
- const char *filename;
- bfd_size_type indx;
-
- BFD_ASSERT (aux.x_file.x_n.x_offset
- >= STRING_SIZE_SIZE);
- if (strings == NULL)
- {
- strings = _bfd_coff_read_string_table (input_bfd);
- if (strings == NULL)
- return false;
- }
- filename = strings + aux.x_file.x_n.x_offset;
- indx = _bfd_stringtab_add (finfo->strtab, filename,
- hash, copy);
- if (indx == (bfd_size_type) -1)
- return false;
- aux.x_file.x_n.x_offset = STRING_SIZE_SIZE + indx;
- }
- }
- else if ((isymp->n_sclass == C_EXT
- || isymp->n_sclass == C_HIDEXT)
- && i + 1 == isymp->n_numaux)
- {
- /* We don't support type checking. I don't know if
- anybody does. */
- aux.x_csect.x_parmhash = 0;
- /* I don't think anybody uses these fields, but we'd
- better clobber them just in case. */
- aux.x_csect.x_stab = 0;
- aux.x_csect.x_snstab = 0;
- if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_LD)
- {
- unsigned long indx;
-
- indx = aux.x_csect.x_scnlen.l;
- if (indx < obj_raw_syment_count (input_bfd))
- {
- long symindx;
-
- symindx = finfo->sym_indices[indx];
- if (symindx < 0)
- aux.x_sym.x_tagndx.l = 0;
- else
- aux.x_sym.x_tagndx.l = symindx;
- }
- }
- }
- else if (isymp->n_sclass != C_STAT || isymp->n_type != T_NULL)
- {
- unsigned long indx;
-
- if (ISFCN (isymp->n_type)
- || ISTAG (isymp->n_sclass)
- || isymp->n_sclass == C_BLOCK)
- {
- indx = aux.x_sym.x_fcnary.x_fcn.x_endndx.l;
- if (indx > 0
- && indx < obj_raw_syment_count (input_bfd))
- {
- /* We look forward through the symbol for
- the index of the next symbol we are going
- to include. I don't know if this is
- entirely right. */
- while (finfo->sym_indices[indx] < 0
- && indx < obj_raw_syment_count (input_bfd))
- ++indx;
- if (indx >= obj_raw_syment_count (input_bfd))
- indx = output_index;
- else
- indx = finfo->sym_indices[indx];
- aux.x_sym.x_fcnary.x_fcn.x_endndx.l = indx;
- }
- }
-
- indx = aux.x_sym.x_tagndx.l;
- if (indx > 0 && indx < obj_raw_syment_count (input_bfd))
- {
- long symindx;
-
- symindx = finfo->sym_indices[indx];
- if (symindx < 0)
- aux.x_sym.x_tagndx.l = 0;
- else
- aux.x_sym.x_tagndx.l = symindx;
- }
- }
-
- /* Copy over the line numbers, unless we are stripping
- them. We do this on a symbol by symbol basis in
- order to more easily handle garbage collection. */
- if ((isymp->n_sclass == C_EXT
- || isymp->n_sclass == C_HIDEXT)
- && i == 0
- && isymp->n_numaux > 1
- && ISFCN (isymp->n_type)
- && aux.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0)
- {
- if (finfo->info->strip != strip_none
- && finfo->info->strip != strip_some)
- aux.x_sym.x_fcnary.x_fcn.x_lnnoptr = 0;
- else
- {
- asection *enclosing;
- unsigned int enc_count;
- bfd_size_type linoff;
- struct internal_lineno lin;
-
- o = *csectpp;
- enclosing = xcoff_section_data (abfd, o)->enclosing;
- enc_count = xcoff_section_data (abfd, o)->lineno_count;
- if (oline != enclosing)
- {
- if (bfd_seek (input_bfd,
- enclosing->line_filepos,
- SEEK_SET) != 0
- || (bfd_read (finfo->linenos, linesz,
- enc_count, input_bfd)
- != linesz * enc_count))
- return false;
- oline = enclosing;
- }
-
- linoff = (aux.x_sym.x_fcnary.x_fcn.x_lnnoptr
- - enclosing->line_filepos);
-
- bfd_coff_swap_lineno_in (input_bfd,
- (PTR) (finfo->linenos + linoff),
- (PTR) &lin);
- if (lin.l_lnno != 0
- || ((bfd_size_type) lin.l_addr.l_symndx
- != ((esym
- - isymesz
- - ((bfd_byte *)
- obj_coff_external_syms (input_bfd)))
- / isymesz)))
- aux.x_sym.x_fcnary.x_fcn.x_lnnoptr = 0;
- else
- {
- bfd_byte *linpend, *linp;
- bfd_vma offset;
- bfd_size_type count;
-
- lin.l_addr.l_symndx = *indexp;
- bfd_coff_swap_lineno_out (output_bfd, (PTR) &lin,
- (PTR) (finfo->linenos
- + linoff));
-
- linpend = (finfo->linenos
- + enc_count * linesz);
- offset = (o->output_section->vma
- + o->output_offset
- - o->vma);
- for (linp = finfo->linenos + linoff + linesz;
- linp < linpend;
- linp += linesz)
- {
- bfd_coff_swap_lineno_in (input_bfd, (PTR) linp,
- (PTR) &lin);
- if (lin.l_lnno == 0)
- break;
- lin.l_addr.l_paddr += offset;
- bfd_coff_swap_lineno_out (output_bfd,
- (PTR) &lin,
- (PTR) linp);
- }
-
- count = (linp - (finfo->linenos + linoff)) / linesz;
-
- aux.x_sym.x_fcnary.x_fcn.x_lnnoptr =
- (o->output_section->line_filepos
- + o->output_section->lineno_count * linesz);
-
- if (bfd_seek (output_bfd,
- aux.x_sym.x_fcnary.x_fcn.x_lnnoptr,
- SEEK_SET) != 0
- || (bfd_write (finfo->linenos + linoff,
- linesz, count, output_bfd)
- != linesz * count))
- return false;
-
- o->output_section->lineno_count += count;
-
- if (incls > 0)
- {
- struct internal_syment *iisp, *iispend;
- long *iindp;
- bfd_byte *oos;
-
- /* Update any C_BINCL or C_EINCL symbols
- that refer to a line number in the
- range we just output. */
- iisp = finfo->internal_syms;
- iispend = (iisp
- + obj_raw_syment_count (input_bfd));
- iindp = finfo->sym_indices;
- oos = finfo->outsyms;
- while (iisp < iispend)
- {
- if ((iisp->n_sclass == C_BINCL
- || iisp->n_sclass == C_EINCL)
- && ((bfd_size_type) iisp->n_value
- >= enclosing->line_filepos + linoff)
- && ((bfd_size_type) iisp->n_value
- < (enclosing->line_filepos
- + enc_count * linesz)))
- {
- struct internal_syment iis;
-
- bfd_coff_swap_sym_in (output_bfd,
- (PTR) oos,
- (PTR) &iis);
- iis.n_value =
- (iisp->n_value
- - enclosing->line_filepos
- - linoff
- + aux.x_sym.x_fcnary.x_fcn.x_lnnoptr);
- bfd_coff_swap_sym_out (output_bfd,
- (PTR) &iis,
- (PTR) oos);
- --incls;
- }
-
- iisp += iisp->n_numaux + 1;
- iindp += iisp->n_numaux + 1;
- oos += (iisp->n_numaux + 1) * osymesz;
- }
- }
- }
- }
- }
-
- bfd_coff_swap_aux_out (output_bfd, (PTR) &aux, isymp->n_type,
- isymp->n_sclass, i, isymp->n_numaux,
- (PTR) outsym);
- outsym += osymesz;
- esym += isymesz;
- }
- }
-
- indexp += add;
- isymp += add;
- csectpp += add;
- }
-
- /* If we swapped out a C_FILE symbol, guess that the next C_FILE
- symbol will be the first symbol in the next input file. In the
- normal case, this will save us from writing out the C_FILE symbol
- again. */
- if (finfo->last_file_index != -1
- && (bfd_size_type) finfo->last_file_index >= syment_base)
- {
- finfo->last_file.n_value = output_index;
- bfd_coff_swap_sym_out (output_bfd, (PTR) &finfo->last_file,
- (PTR) (finfo->outsyms
- + ((finfo->last_file_index - syment_base)
- * osymesz)));
- }
-
- /* Write the modified symbols to the output file. */
- if (outsym > finfo->outsyms)
- {
- if (bfd_seek (output_bfd,
- obj_sym_filepos (output_bfd) + syment_base * osymesz,
- SEEK_SET) != 0
- || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1,
- output_bfd)
- != (bfd_size_type) (outsym - finfo->outsyms)))
- return false;
-
- BFD_ASSERT ((obj_raw_syment_count (output_bfd)
- + (outsym - finfo->outsyms) / osymesz)
- == output_index);
-
- obj_raw_syment_count (output_bfd) = output_index;
- }
-
- /* Don't let the linker relocation routines discard the symbols. */
- keep_syms = obj_coff_keep_syms (input_bfd);
- obj_coff_keep_syms (input_bfd) = true;
-
- /* Relocate the contents of each section. */
- for (o = input_bfd->sections; o != NULL; o = o->next)
- {
- bfd_byte *contents;
-
- if ((o->flags & SEC_HAS_CONTENTS) == 0
- || o->_raw_size == 0
- || (o->flags & SEC_IN_MEMORY) != 0)
- continue;
-
- /* We have set filepos correctly for the sections we created to
- represent csects, so bfd_get_section_contents should work. */
- if (coff_section_data (input_bfd, o) != NULL
- && coff_section_data (input_bfd, o)->contents != NULL)
- contents = coff_section_data (input_bfd, o)->contents;
- else
- {
- if (! bfd_get_section_contents (input_bfd, o, finfo->contents,
- (file_ptr) 0, o->_raw_size))
- return false;
- contents = finfo->contents;
- }
-
- if ((o->flags & SEC_RELOC) != 0)
- {
- int target_index;
- struct internal_reloc *internal_relocs;
- struct internal_reloc *irel;
- bfd_vma offset;
- struct internal_reloc *irelend;
- struct xcoff_link_hash_entry **rel_hash;
- long r_symndx;
-
- /* Read in the relocs. */
- target_index = o->output_section->target_index;
- internal_relocs = (xcoff_read_internal_relocs
- (input_bfd, o, false, finfo->external_relocs,
- true,
- (finfo->section_info[target_index].relocs
- + o->output_section->reloc_count)));
- if (internal_relocs == NULL)
- return false;
-
- /* Call processor specific code to relocate the section
- contents. */
- if (! bfd_coff_relocate_section (output_bfd, finfo->info,
- input_bfd, o,
- contents,
- internal_relocs,
- finfo->internal_syms,
- xcoff_data (input_bfd)->csects))
- return false;
-
- offset = o->output_section->vma + o->output_offset - o->vma;
- irel = internal_relocs;
- irelend = irel + o->reloc_count;
- rel_hash = (finfo->section_info[target_index].rel_hashes
- + o->output_section->reloc_count);
- for (; irel < irelend; irel++, rel_hash++)
- {
- struct xcoff_link_hash_entry *h = NULL;
- struct internal_ldrel ldrel;
-
- *rel_hash = NULL;
-
- /* Adjust the reloc address and symbol index. */
-
- irel->r_vaddr += offset;
-
- r_symndx = irel->r_symndx;
-
- if (r_symndx != -1)
- {
- h = obj_xcoff_sym_hashes (input_bfd)[r_symndx];
- if (h != NULL
- && (irel->r_type == R_TOC
- || irel->r_type == R_GL
- || irel->r_type == R_TCL
- || irel->r_type == R_TRL
- || irel->r_type == R_TRLA))
- {
- /* This is a TOC relative reloc with a symbol
- attached. The symbol should be the one which
- this reloc is for. We want to make this
- reloc against the TOC address of the symbol,
- not the symbol itself. */
- BFD_ASSERT (h->toc_section != NULL);
- BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
- if (h->u.toc_indx != -1)
- irel->r_symndx = h->u.toc_indx;
- else
- {
- struct xcoff_toc_rel_hash *n;
- struct xcoff_link_section_info *si;
-
- n = ((struct xcoff_toc_rel_hash *)
- bfd_alloc (finfo->output_bfd,
- sizeof (struct xcoff_toc_rel_hash)));
- if (n == NULL)
- return false;
- si = finfo->section_info + target_index;
- n->next = si->toc_rel_hashes;
- n->h = h;
- n->rel = irel;
- si->toc_rel_hashes = n;
- }
- }
- else if (h != NULL)
- {
- /* This is a global symbol. */
- if (h->indx >= 0)
- irel->r_symndx = h->indx;
- else
- {
- /* This symbol is being written at the end
- of the file, and we do not yet know the
- symbol index. We save the pointer to the
- hash table entry in the rel_hash list.
- We set the indx field to -2 to indicate
- that this symbol must not be stripped. */
- *rel_hash = h;
- h->indx = -2;
- }
- }
- else
- {
- long indx;
-
- indx = finfo->sym_indices[r_symndx];
-
- if (indx == -1)
- {
- struct internal_syment *is;
-
- /* Relocations against a TC0 TOC anchor are
- automatically transformed to be against
- the TOC anchor in the output file. */
- is = finfo->internal_syms + r_symndx;
- if (is->n_sclass == C_HIDEXT
- && is->n_numaux > 0)
- {
- PTR auxptr;
- union internal_auxent aux;
-
- auxptr = ((PTR)
- (((bfd_byte *)
- obj_coff_external_syms (input_bfd))
- + ((r_symndx + is->n_numaux)
- * isymesz)));
- bfd_coff_swap_aux_in (input_bfd, auxptr,
- is->n_type, is->n_sclass,
- is->n_numaux - 1,
- is->n_numaux,
- (PTR) &aux);
- if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_SD
- && aux.x_csect.x_smclas == XMC_TC0)
- indx = finfo->toc_symindx;
- }
- }
-
- if (indx != -1)
- irel->r_symndx = indx;
- else
- {
- struct internal_syment *is;
- const char *name;
- char buf[SYMNMLEN + 1];
-
- /* This reloc is against a symbol we are
- stripping. It would be possible to handle
- this case, but I don't think it's worth it. */
- is = finfo->internal_syms + r_symndx;
-
- name = (_bfd_coff_internal_syment_name
- (input_bfd, is, buf));
- if (name == NULL)
- return false;
-
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, o,
- irel->r_vaddr)))
- return false;
- }
- }
- }
-
- switch (irel->r_type)
- {
- default:
- if (h == NULL
- || h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_common)
- break;
- /* Fall through. */
- case R_POS:
- case R_NEG:
- case R_RL:
- case R_RLA:
- /* This reloc needs to be copied into the .loader
- section. */
- ldrel.l_vaddr = irel->r_vaddr;
- if (r_symndx == -1)
- ldrel.l_symndx = -1;
- else if (h == NULL
- || (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_common))
- {
- asection *sec;
-
- if (h == NULL)
- sec = xcoff_data (input_bfd)->csects[r_symndx];
- else if (h->root.type == bfd_link_hash_common)
- sec = h->root.u.c.p->section;
- else
- sec = h->root.u.def.section;
- sec = sec->output_section;
-
- if (strcmp (sec->name, ".text") == 0)
- ldrel.l_symndx = 0;
- else if (strcmp (sec->name, ".data") == 0)
- ldrel.l_symndx = 1;
- else if (strcmp (sec->name, ".bss") == 0)
- ldrel.l_symndx = 2;
- else
- {
- (*_bfd_error_handler)
- ("%s: loader reloc in unrecognized section `%s'",
- bfd_get_filename (input_bfd),
- sec->name);
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
- }
- else
- {
- if (h->ldindx < 0)
- {
- (*_bfd_error_handler)
- ("%s: `%s' in loader reloc but not loader sym",
- bfd_get_filename (input_bfd),
- h->root.root.string);
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- ldrel.l_symndx = h->ldindx;
- }
- ldrel.l_rtype = (irel->r_size << 8) | irel->r_type;
- ldrel.l_rsecnm = o->output_section->target_index;
- if (xcoff_hash_table (finfo->info)->textro
- && strcmp (o->output_section->name, ".text") == 0)
- {
- (*_bfd_error_handler)
- ("%s: loader reloc in read-only section %s",
- bfd_get_filename (input_bfd),
- bfd_get_section_name (finfo->output_bfd,
- o->output_section));
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
- xcoff_swap_ldrel_out (output_bfd, &ldrel,
- finfo->ldrel);
- BFD_ASSERT (sizeof (struct external_ldrel) == LDRELSZ);
- ++finfo->ldrel;
- break;
-
- case R_TOC:
- case R_GL:
- case R_TCL:
- case R_TRL:
- case R_TRLA:
- /* We should never need a .loader reloc for a TOC
- relative reloc. */
- break;
- }
- }
-
- o->output_section->reloc_count += o->reloc_count;
- }
-
- /* Write out the modified section contents. */
- if (! bfd_set_section_contents (output_bfd, o->output_section,
- contents, o->output_offset,
- (o->_cooked_size != 0
- ? o->_cooked_size
- : o->_raw_size)))
- return false;
- }
-
- obj_coff_keep_syms (input_bfd) = keep_syms;
-
- if (! finfo->info->keep_memory)
- {
- if (! _bfd_coff_free_symbols (input_bfd))
- return false;
- }
-
- return true;
-}
-
-#undef N_TMASK
-#undef N_BTSHFT
-
-/* Write out a non-XCOFF global symbol. */
-
-static boolean
-xcoff_write_global_symbol (h, p)
- struct xcoff_link_hash_entry *h;
- PTR p;
-{
- struct xcoff_final_link_info *finfo = (struct xcoff_final_link_info *) p;
- bfd *output_bfd;
- bfd_byte *outsym;
- struct internal_syment isym;
- union internal_auxent aux;
-
- output_bfd = finfo->output_bfd;
-
- /* If this symbol was garbage collected, just skip it. */
- if (xcoff_hash_table (finfo->info)->gc
- && (h->flags & XCOFF_MARK) == 0)
- return true;
-
- /* If we need a .loader section entry, write it out. */
- if (h->ldsym != NULL)
- {
- struct internal_ldsym *ldsym;
- bfd *impbfd;
-
- ldsym = h->ldsym;
-
- if (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- {
- ldsym->l_value = 0;
- ldsym->l_scnum = N_UNDEF;
- ldsym->l_smtype = XTY_ER;
- impbfd = h->root.u.undef.abfd;
- }
- else if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *sec;
-
- sec = h->root.u.def.section;
- ldsym->l_value = (sec->output_section->vma
- + sec->output_offset
- + h->root.u.def.value);
- ldsym->l_scnum = sec->output_section->target_index;
- ldsym->l_smtype = XTY_SD;
- impbfd = sec->owner;
- }
- else
- abort ();
-
- if (((h->flags & XCOFF_DEF_REGULAR) == 0
- && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
- || (h->flags & XCOFF_IMPORT) != 0)
- ldsym->l_smtype |= L_IMPORT;
- if (((h->flags & XCOFF_DEF_REGULAR) != 0
- && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
- || (h->flags & XCOFF_EXPORT) != 0)
- ldsym->l_smtype |= L_EXPORT;
- if ((h->flags & XCOFF_ENTRY) != 0)
- ldsym->l_smtype |= L_ENTRY;
-
- ldsym->l_smclas = h->smclas;
-
- if (ldsym->l_ifile == (bfd_size_type) -1)
- ldsym->l_ifile = 0;
- else if (ldsym->l_ifile == 0)
- {
- if ((ldsym->l_smtype & L_IMPORT) == 0)
- ldsym->l_ifile = 0;
- else if (impbfd == NULL)
- ldsym->l_ifile = 0;
- else
- {
- BFD_ASSERT (impbfd->xvec == output_bfd->xvec);
- ldsym->l_ifile = xcoff_data (impbfd)->import_file_id;
- }
- }
-
- ldsym->l_parm = 0;
-
- BFD_ASSERT (h->ldindx >= 0);
- BFD_ASSERT (LDSYMSZ == sizeof (struct external_ldsym));
- xcoff_swap_ldsym_out (output_bfd, ldsym, finfo->ldsym + h->ldindx - 3);
- h->ldsym = NULL;
- }
-
- /* If this symbol needs global linkage code, write it out. */
- if (h->root.type == bfd_link_hash_defined
- && (h->root.u.def.section
- == xcoff_hash_table (finfo->info)->linkage_section))
- {
- bfd_byte *p;
- bfd_vma tocoff;
- unsigned int i;
-
- p = h->root.u.def.section->contents + h->root.u.def.value;
-
- /* The first instruction in the global linkage code loads a
- specific TOC element. */
- tocoff = (h->descriptor->toc_section->output_section->vma
- + h->descriptor->toc_section->output_offset
- - xcoff_data (output_bfd)->toc);
- if ((h->descriptor->flags & XCOFF_SET_TOC) != 0)
- tocoff += h->descriptor->u.toc_offset;
- bfd_put_32 (output_bfd, XCOFF_GLINK_FIRST | (tocoff & 0xffff), p);
- for (i = 0, p += 4;
- i < sizeof xcoff_glink_code / sizeof xcoff_glink_code[0];
- i++, p += 4)
- bfd_put_32 (output_bfd, xcoff_glink_code[i], p);
- }
-
- /* If we created a TOC entry for this symbol, write out the required
- relocs. */
- if ((h->flags & XCOFF_SET_TOC) != 0)
- {
- asection *tocsec;
- asection *osec;
- int oindx;
- struct internal_reloc *irel;
- struct internal_ldrel ldrel;
-
- tocsec = h->toc_section;
- osec = tocsec->output_section;
- oindx = osec->target_index;
- irel = finfo->section_info[oindx].relocs + osec->reloc_count;
- irel->r_vaddr = (osec->vma
- + tocsec->output_offset
- + h->u.toc_offset);
- if (h->indx >= 0)
- irel->r_symndx = h->indx;
- else
- {
- h->indx = -2;
- irel->r_symndx = obj_raw_syment_count (output_bfd);
- }
- irel->r_type = R_POS;
- irel->r_size = 31;
- finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
- ++osec->reloc_count;
-
- BFD_ASSERT (h->ldindx >= 0);
- ldrel.l_vaddr = irel->r_vaddr;
- ldrel.l_symndx = h->ldindx;
- ldrel.l_rtype = (31 << 8) | R_POS;
- ldrel.l_rsecnm = oindx;
- xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
- ++finfo->ldrel;
- }
-
- /* If this symbol is a specially defined function descriptor, write
- it out. The first word is the address of the function code
- itself, the second word is the address of the TOC, and the third
- word is zero. */
- if ((h->flags & XCOFF_DESCRIPTOR) != 0
- && h->root.type == bfd_link_hash_defined
- && (h->root.u.def.section
- == xcoff_hash_table (finfo->info)->descriptor_section))
- {
- asection *sec;
- asection *osec;
- int oindx;
- bfd_byte *p;
- struct xcoff_link_hash_entry *hentry;
- asection *esec;
- struct internal_reloc *irel;
- struct internal_ldrel ldrel;
- asection *tsec;
-
- sec = h->root.u.def.section;
- osec = sec->output_section;
- oindx = osec->target_index;
- p = sec->contents + h->root.u.def.value;
-
- hentry = h->descriptor;
- BFD_ASSERT (hentry != NULL
- && (hentry->root.type == bfd_link_hash_defined
- || hentry->root.type == bfd_link_hash_defweak));
- esec = hentry->root.u.def.section;
- bfd_put_32 (output_bfd,
- (esec->output_section->vma
- + esec->output_offset
- + hentry->root.u.def.value),
- p);
-
- irel = finfo->section_info[oindx].relocs + osec->reloc_count;
- irel->r_vaddr = (osec->vma
- + sec->output_offset
- + h->root.u.def.value);
- irel->r_symndx = esec->output_section->target_index;
- irel->r_type = R_POS;
- irel->r_size = 31;
- finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
- ++osec->reloc_count;
-
- ldrel.l_vaddr = irel->r_vaddr;
- if (strcmp (esec->output_section->name, ".text") == 0)
- ldrel.l_symndx = 0;
- else if (strcmp (esec->output_section->name, ".data") == 0)
- ldrel.l_symndx = 1;
- else if (strcmp (esec->output_section->name, ".bss") == 0)
- ldrel.l_symndx = 2;
- else
- {
- (*_bfd_error_handler)
- ("%s: loader reloc in unrecognized section `%s'",
- bfd_get_filename (output_bfd),
- esec->output_section->name);
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
- ldrel.l_rtype = (31 << 8) | R_POS;
- ldrel.l_rsecnm = oindx;
- xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
- ++finfo->ldrel;
-
- bfd_put_32 (output_bfd, xcoff_data (output_bfd)->toc, p + 4);
-
- tsec = coff_section_from_bfd_index (output_bfd,
- xcoff_data (output_bfd)->sntoc);
-
- ++irel;
- irel->r_vaddr = (osec->vma
- + sec->output_offset
- + h->root.u.def.value
- + 4);
- irel->r_symndx = tsec->output_section->target_index;
- irel->r_type = R_POS;
- irel->r_size = 31;
- finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
- ++osec->reloc_count;
-
- ldrel.l_vaddr = irel->r_vaddr;
- if (strcmp (tsec->output_section->name, ".text") == 0)
- ldrel.l_symndx = 0;
- else if (strcmp (tsec->output_section->name, ".data") == 0)
- ldrel.l_symndx = 1;
- else if (strcmp (tsec->output_section->name, ".bss") == 0)
- ldrel.l_symndx = 2;
- else
- {
- (*_bfd_error_handler)
- ("%s: loader reloc in unrecognized section `%s'",
- bfd_get_filename (output_bfd),
- tsec->output_section->name);
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
- ldrel.l_rtype = (31 << 8) | R_POS;
- ldrel.l_rsecnm = oindx;
- xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
- ++finfo->ldrel;
- }
-
- if (h->indx >= 0)
- return true;
-
- if (h->indx != -2
- && (finfo->info->strip == strip_all
- || (finfo->info->strip == strip_some
- && (bfd_hash_lookup (finfo->info->keep_hash,
- h->root.root.string, false, false)
- == NULL))))
- return true;
-
- if (h->indx != -2
- && (h->flags & (XCOFF_REF_REGULAR | XCOFF_DEF_REGULAR)) == 0)
- return true;
-
- outsym = finfo->outsyms;
-
- memset (&aux, 0, sizeof aux);
-
- h->indx = obj_raw_syment_count (output_bfd);
-
- if (strlen (h->root.root.string) <= SYMNMLEN)
- strncpy (isym._n._n_name, h->root.root.string, SYMNMLEN);
- else
- {
- boolean hash;
- bfd_size_type indx;
-
- hash = true;
- if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
- hash = false;
- indx = _bfd_stringtab_add (finfo->strtab, h->root.root.string, hash,
- false);
- if (indx == (bfd_size_type) -1)
- return false;
- isym._n._n_n._n_zeroes = 0;
- isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
- }
-
- if (h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak)
- {
- isym.n_value = 0;
- isym.n_scnum = N_UNDEF;
- isym.n_sclass = C_EXT;
- aux.x_csect.x_smtyp = XTY_ER;
- }
- else if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- struct xcoff_link_size_list *l;
-
- isym.n_value = (h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset
- + h->root.u.def.value);
- isym.n_scnum = h->root.u.def.section->output_section->target_index;
- isym.n_sclass = C_HIDEXT;
- aux.x_csect.x_smtyp = XTY_SD;
-
- if ((h->flags & XCOFF_HAS_SIZE) != 0)
- {
- for (l = xcoff_hash_table (finfo->info)->size_list;
- l != NULL;
- l = l->next)
- {
- if (l->h == h)
- {
- aux.x_csect.x_scnlen.l = l->size;
- break;
- }
- }
- }
- }
- else if (h->root.type == bfd_link_hash_common)
- {
- isym.n_value = (h->root.u.c.p->section->output_section->vma
- + h->root.u.c.p->section->output_offset);
- isym.n_scnum = h->root.u.c.p->section->output_section->target_index;
- isym.n_sclass = C_EXT;
- aux.x_csect.x_smtyp = XTY_CM;
- aux.x_csect.x_scnlen.l = h->root.u.c.size;
- }
- else
- abort ();
-
- isym.n_type = T_NULL;
- isym.n_numaux = 1;
-
- bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
- outsym += bfd_coff_symesz (output_bfd);
-
- aux.x_csect.x_smclas = h->smclas;
-
- bfd_coff_swap_aux_out (output_bfd, (PTR) &aux, T_NULL, isym.n_sclass, 0, 1,
- (PTR) outsym);
- outsym += bfd_coff_auxesz (output_bfd);
-
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- /* We just output an SD symbol. Now output an LD symbol. */
-
- h->indx += 2;
-
- isym.n_sclass = C_EXT;
- bfd_coff_swap_sym_out (output_bfd, (PTR) &isym, (PTR) outsym);
- outsym += bfd_coff_symesz (output_bfd);
-
- aux.x_csect.x_smtyp = XTY_LD;
- aux.x_csect.x_scnlen.l = obj_raw_syment_count (output_bfd);
-
- bfd_coff_swap_aux_out (output_bfd, (PTR) &aux, T_NULL, C_EXT, 0, 1,
- (PTR) outsym);
- outsym += bfd_coff_auxesz (output_bfd);
- }
-
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + (obj_raw_syment_count (output_bfd)
- * bfd_coff_symesz (output_bfd))),
- SEEK_SET) != 0
- || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1, output_bfd)
- != (bfd_size_type) (outsym - finfo->outsyms)))
- return false;
- obj_raw_syment_count (output_bfd) +=
- (outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd);
-
- return true;
-}
-
-/* Handle a link order which is supposed to generate a reloc. */
-
-static boolean
-xcoff_reloc_link_order (output_bfd, finfo, output_section, link_order)
- bfd *output_bfd;
- struct xcoff_final_link_info *finfo;
- asection *output_section;
- struct bfd_link_order *link_order;
-{
- reloc_howto_type *howto;
- struct xcoff_link_hash_entry *h;
- asection *hsec;
- bfd_vma hval;
- bfd_vma addend;
- struct internal_reloc *irel;
- struct xcoff_link_hash_entry **rel_hash_ptr;
- struct internal_ldrel ldrel;
-
- if (link_order->type == bfd_section_reloc_link_order)
- {
- /* We need to somehow locate a symbol in the right section. The
- symbol must either have a value of zero, or we must adjust
- the addend by the value of the symbol. FIXME: Write this
- when we need it. The old linker couldn't handle this anyhow. */
- abort ();
- }
-
- howto = bfd_reloc_type_lookup (output_bfd, link_order->u.reloc.p->reloc);
- if (howto == NULL)
- {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- h = ((struct xcoff_link_hash_entry *)
- bfd_wrapped_link_hash_lookup (output_bfd, finfo->info,
- link_order->u.reloc.p->u.name,
- false, false, true));
- if (h == NULL)
- {
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, link_order->u.reloc.p->u.name, (bfd *) NULL,
- (asection *) NULL, (bfd_vma) 0)))
- return false;
- return true;
- }
-
- if (h->root.type == bfd_link_hash_common)
- {
- hsec = h->root.u.c.p->section;
- hval = 0;
- }
- else if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- hsec = h->root.u.def.section;
- hval = h->root.u.def.value;
- }
- else
- {
- hsec = NULL;
- hval = 0;
- }
-
- addend = link_order->u.reloc.p->addend;
- if (hsec != NULL)
- addend += (hsec->output_section->vma
- + hsec->output_offset
- + hval);
-
- if (addend != 0)
- {
- bfd_size_type size;
- bfd_byte *buf;
- bfd_reloc_status_type rstat;
- boolean ok;
-
- size = bfd_get_reloc_size (howto);
- buf = (bfd_byte *) bfd_zmalloc (size);
- if (buf == NULL)
- return false;
-
- rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
- switch (rstat)
- {
- case bfd_reloc_ok:
- break;
- default:
- case bfd_reloc_outofrange:
- abort ();
- case bfd_reloc_overflow:
- if (! ((*finfo->info->callbacks->reloc_overflow)
- (finfo->info, link_order->u.reloc.p->u.name,
- howto->name, addend, (bfd *) NULL, (asection *) NULL,
- (bfd_vma) 0)))
- {
- free (buf);
- return false;
- }
- break;
- }
- ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
- (file_ptr) link_order->offset, size);
- free (buf);
- if (! ok)
- return false;
- }
-
- /* Store the reloc information in the right place. It will get
- swapped and written out at the end of the final_link routine. */
-
- irel = (finfo->section_info[output_section->target_index].relocs
- + output_section->reloc_count);
- rel_hash_ptr = (finfo->section_info[output_section->target_index].rel_hashes
- + output_section->reloc_count);
-
- memset (irel, 0, sizeof (struct internal_reloc));
- *rel_hash_ptr = NULL;
-
- irel->r_vaddr = output_section->vma + link_order->offset;
-
- if (h->indx >= 0)
- irel->r_symndx = h->indx;
- else
- {
- /* Set the index to -2 to force this symbol to get written out. */
- h->indx = -2;
- *rel_hash_ptr = h;
- irel->r_symndx = 0;
- }
-
- irel->r_type = howto->type;
- irel->r_size = howto->bitsize - 1;
- if (howto->complain_on_overflow == complain_overflow_signed)
- irel->r_size |= 0x80;
-
- ++output_section->reloc_count;
-
- /* Now output the reloc to the .loader section. */
-
- ldrel.l_vaddr = irel->r_vaddr;
-
- if (hsec != NULL)
- {
- const char *secname;
-
- secname = hsec->output_section->name;
-
- if (strcmp (secname, ".text") == 0)
- ldrel.l_symndx = 0;
- else if (strcmp (secname, ".data") == 0)
- ldrel.l_symndx = 1;
- else if (strcmp (secname, ".bss") == 0)
- ldrel.l_symndx = 2;
- else
- {
- (*_bfd_error_handler)
- ("%s: loader reloc in unrecognized section `%s'",
- bfd_get_filename (output_bfd), secname);
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
- }
- else
- {
- if (h->ldindx < 0)
- {
- (*_bfd_error_handler)
- ("%s: `%s' in loader reloc but not loader sym",
- bfd_get_filename (output_bfd),
- h->root.root.string);
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- ldrel.l_symndx = h->ldindx;
- }
-
- ldrel.l_rtype = (irel->r_size << 8) | irel->r_type;
- ldrel.l_rsecnm = output_section->target_index;
- xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
- ++finfo->ldrel;
-
- return true;
-}
-
-/* Sort relocs by VMA. This is called via qsort. */
-
-static int
-xcoff_sort_relocs (p1, p2)
- const PTR p1;
- const PTR p2;
-{
- const struct internal_reloc *r1 = (const struct internal_reloc *) p1;
- const struct internal_reloc *r2 = (const struct internal_reloc *) p2;
-
- if (r1->r_vaddr > r2->r_vaddr)
- return 1;
- else if (r1->r_vaddr < r2->r_vaddr)
- return -1;
- else
- return 0;
-}
-
-/* This is the relocation function for the RS/6000/POWER/PowerPC.
- This is currently the only processor which uses XCOFF; I hope that
- will never change. */
-
-boolean
-_bfd_ppc_xcoff_relocate_section (output_bfd, info, input_bfd,
- input_section, contents, relocs, syms,
- sections)
- bfd *output_bfd;
- struct bfd_link_info *info;
- bfd *input_bfd;
- asection *input_section;
- bfd_byte *contents;
- struct internal_reloc *relocs;
- struct internal_syment *syms;
- asection **sections;
-{
- struct internal_reloc *rel;
- struct internal_reloc *relend;
-
- rel = relocs;
- relend = rel + input_section->reloc_count;
- for (; rel < relend; rel++)
- {
- long symndx;
- struct xcoff_link_hash_entry *h;
- struct internal_syment *sym;
- bfd_vma addend;
- bfd_vma val;
- struct reloc_howto_struct howto;
- bfd_reloc_status_type rstat;
-
- /* Relocation type R_REF is a special relocation type which is
- merely used to prevent garbage collection from occurring for
- the csect including the symbol which it references. */
- if (rel->r_type == R_REF)
- continue;
-
- symndx = rel->r_symndx;
-
- if (symndx == -1)
- {
- h = NULL;
- sym = NULL;
- addend = 0;
- }
- else
- {
- h = obj_xcoff_sym_hashes (input_bfd)[symndx];
- sym = syms + symndx;
- addend = - sym->n_value;
- }
-
- /* We build the howto information on the fly. */
-
- howto.type = rel->r_type;
- howto.rightshift = 0;
- howto.size = 2;
- howto.bitsize = (rel->r_size & 0x1f) + 1;
- howto.pc_relative = false;
- howto.bitpos = 0;
- if ((rel->r_size & 0x80) != 0)
- howto.complain_on_overflow = complain_overflow_signed;
- else
- howto.complain_on_overflow = complain_overflow_bitfield;
- howto.special_function = NULL;
- howto.name = "internal";
- howto.partial_inplace = true;
- if (howto.bitsize == 32)
- howto.src_mask = howto.dst_mask = 0xffffffff;
- else
- {
- howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1;
- if (howto.bitsize == 16)
- howto.size = 1;
- }
- howto.pcrel_offset = false;
-
- val = 0;
-
- if (h == NULL)
- {
- asection *sec;
-
- if (symndx == -1)
- {
- sec = bfd_abs_section_ptr;
- val = 0;
- }
- else
- {
- sec = sections[symndx];
- /* Hack to make sure we use the right TOC anchor value
- if this reloc is against the TOC anchor. */
- if (sec->name[3] == '0'
- && strcmp (sec->name, ".tc0") == 0)
- val = xcoff_data (output_bfd)->toc;
- else
- val = (sec->output_section->vma
- + sec->output_offset
- + sym->n_value
- - sec->vma);
- }
- }
- else
- {
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- asection *sec;
-
- sec = h->root.u.def.section;
- val = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (h->root.type == bfd_link_hash_common)
- {
- asection *sec;
-
- sec = h->root.u.c.p->section;
- val = (sec->output_section->vma
- + sec->output_offset);
- }
- else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0
- || (h->flags & XCOFF_IMPORT) != 0)
- {
- /* Every symbol in a shared object is defined somewhere. */
- val = 0;
- }
- else if (! info->relocateable
- && ! info->shared)
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd, input_section,
- rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
-
- /* I took the relocation type definitions from two documents:
- the PowerPC AIX Version 4 Application Binary Interface, First
- Edition (April 1992), and the PowerOpen ABI, Big-Endian
- 32-Bit Hardware Implementation (June 30, 1994). Differences
- between the documents are noted below. */
-
- switch (rel->r_type)
- {
- case R_RTB:
- case R_RRTBI:
- case R_RRTBA:
- /* These relocs are defined by the PowerPC ABI to be
- relative branches which use half of the difference
- between the symbol and the program counter. I can't
- quite figure out when this is useful. These relocs are
- not defined by the PowerOpen ABI. */
- default:
- (*_bfd_error_handler)
- ("%s: unsupported relocation type 0x%02x",
- bfd_get_filename (input_bfd), (unsigned int) rel->r_type);
- bfd_set_error (bfd_error_bad_value);
- return false;
- case R_POS:
- /* Simple positive relocation. */
- break;
- case R_NEG:
- /* Simple negative relocation. */
- val = - val;
- break;
- case R_REL:
- /* Simple PC relative relocation. */
- howto.pc_relative = true;
- break;
- case R_TOC:
- /* TOC relative relocation. The value in the instruction in
- the input file is the offset from the input file TOC to
- the desired location. We want the offset from the final
- TOC to the desired location. We have:
- isym = iTOC + in
- iinsn = in + o
- osym = oTOC + on
- oinsn = on + o
- so we must change insn by on - in.
- */
- case R_GL:
- /* Global linkage relocation. The value of this relocation
- is the address of the entry in the TOC section. */
- case R_TCL:
- /* Local object TOC address. I can't figure out the
- difference between this and case R_GL. */
- case R_TRL:
- /* TOC relative relocation. A TOC relative load instruction
- which may be changed to a load address instruction.
- FIXME: We don't currently implement this optimization. */
- case R_TRLA:
- /* TOC relative relocation. This is a TOC relative load
- address instruction which may be changed to a load
- instruction. FIXME: I don't know if this is the correct
- implementation. */
- if (h != NULL && h->toc_section == NULL)
- {
- (*_bfd_error_handler)
- ("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry",
- bfd_get_filename (input_bfd), rel->r_vaddr,
- h->root.root.string);
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- if (h != NULL)
- {
- BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
- val = (h->toc_section->output_section->vma
- + h->toc_section->output_offset);
- }
- val = ((val - xcoff_data (output_bfd)->toc)
- - (sym->n_value - xcoff_data (input_bfd)->toc));
- addend = 0;
- break;
- case R_BA:
- /* Absolute branch. We don't want to mess with the lower
- two bits of the instruction. */
- case R_CAI:
- /* The PowerPC ABI defines this as an absolute call which
- may be modified to become a relative call. The PowerOpen
- ABI does not define this relocation type. */
- case R_RBA:
- /* Absolute branch which may be modified to become a
- relative branch. */
- case R_RBAC:
- /* The PowerPC ABI defines this as an absolute branch to a
- fixed address which may be modified to an absolute branch
- to a symbol. The PowerOpen ABI does not define this
- relocation type. */
- case R_RBRC:
- /* The PowerPC ABI defines this as an absolute branch to a
- fixed address which may be modified to a relative branch.
- The PowerOpen ABI does not define this relocation type. */
- howto.src_mask &= ~3;
- howto.dst_mask = howto.src_mask;
- break;
- case R_BR:
- /* Relative branch. We don't want to mess with the lower
- two bits of the instruction. */
- case R_CREL:
- /* The PowerPC ABI defines this as a relative call which may
- be modified to become an absolute call. The PowerOpen
- ABI does not define this relocation type. */
- case R_RBR:
- /* A relative branch which may be modified to become an
- absolute branch. FIXME: We don't implement this,
- although we should for symbols of storage mapping class
- XMC_XO. */
- howto.pc_relative = true;
- howto.src_mask &= ~3;
- howto.dst_mask = howto.src_mask;
- break;
- case R_RL:
- /* The PowerPC AIX ABI describes this as a load which may be
- changed to a load address. The PowerOpen ABI says this
- is the same as case R_POS. */
- break;
- case R_RLA:
- /* The PowerPC AIX ABI describes this as a load address
- which may be changed to a load. The PowerOpen ABI says
- this is the same as R_POS. */
- break;
- }
-
- /* If we see an R_BR or R_RBR reloc which is jumping to global
- linkage code, and it is followed by an appropriate cror nop
- instruction, we replace the cror with lwz r2,20(r1). This
- restores the TOC after the glink code. Contrariwise, if the
- call is followed by a lwz r2,20(r1), but the call is not
- going to global linkage code, we can replace the load with a
- cror. */
- if ((rel->r_type == R_BR || rel->r_type == R_RBR)
- && h != NULL
- && h->root.type == bfd_link_hash_defined
- && (rel->r_vaddr - input_section->vma + 8
- <= input_section->_cooked_size))
- {
- bfd_byte *pnext;
- unsigned long next;
-
- pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
- next = bfd_get_32 (input_bfd, pnext);
- if (h->smclas == XMC_GL)
- {
- if (next == 0x4def7b82 /* cror 15,15,15 */
- || next == 0x4ffffb82) /* cror 31,31,31 */
- bfd_put_32 (input_bfd, 0x80410014, pnext); /* lwz r1,20(r1) */
- }
- else
- {
- if (next == 0x80410014) /* lwz r1,20(r1) */
- bfd_put_32 (input_bfd, 0x4ffffb82, pnext); /* cror 31,31,31 */
- }
- }
-
- /* A PC relative reloc includes the section address. */
- if (howto.pc_relative)
- addend += input_section->vma;
-
- rstat = _bfd_final_link_relocate (&howto, input_bfd, input_section,
- contents,
- rel->r_vaddr - input_section->vma,
- val, addend);
-
- switch (rstat)
- {
- default:
- abort ();
- case bfd_reloc_ok:
- break;
- case bfd_reloc_overflow:
- {
- const char *name;
- char buf[SYMNMLEN + 1];
- char howto_name[10];
-
- if (symndx == -1)
- name = "*ABS*";
- else if (h != NULL)
- name = h->root.root.string;
- else
- {
- name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
- if (name == NULL)
- return false;
- }
- sprintf (howto_name, "0x%02x", rel->r_type);
-
- if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto_name, (bfd_vma) 0, input_bfd,
- input_section, rel->r_vaddr - input_section->vma)))
- return false;
- }
- }
- }
-
- return true;
-}
diff --git a/contrib/gdb/gdb/ChangeLog-93 b/contrib/gdb/gdb/ChangeLog-93
deleted file mode 100644
index 463154d..0000000
--- a/contrib/gdb/gdb/ChangeLog-93
+++ /dev/null
@@ -1,7597 +0,0 @@
-Fri Dec 31 14:33:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * nindy-share/nindy.c: Fix order of arguments to store_unsigned_integer
- (second and third arguments were reversed).
- (say): Use varargs.
-
-Fri Dec 31 12:13:47 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * remote-mips.c: Add timeout parameter to mips_request and
- mips_receive_packet.
- (callers): pass in mips_receive_wait except mips_initialize (where
- we use it to clean up the kludge where we had been changing
- mips_receive_wait temporarily) and mips_wait (where we pass in
- -1 for no timeout).
-
-Fri Dec 31 14:33:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stack.c (print_block_frame_locals): Also print LOC_BASEREG variables.
-
-Fri Dec 31 06:55:38 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symtab.c (find_methods): Call fprintf_symbol_filtered with DMGL_ANSI.
-
-Thu Dec 30 10:16:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * values.c (unpack_long): Fix garbled error message.
-
- * remote-mips.c (mips_error): New function.
- * remote-mips.c: Use it instead of error() most places.
- * remote-mips.c (mips_receive_packet): New arg throw_error.
- (mips_initialize): Use it not catch_errors.
- * defs.h: Declare error_pre_print and warning_pre_print here...
- * main.c: ...not here.
-
- * breakpoint.c (breakpoint_chain): Make static.
- * breakpoint.c, breakpoint.h (frame_in_dummy): New function.
- * stack.c (print_frame_info): Use it.
-
-Thu Dec 30 07:41:36 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * exec.c (add_to_section_table): Check for SEC_ALLOC instead of
- SEC_LOAD to handle .bss segments properly.
-
-Thu Dec 30 10:16:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (wait_for_inferior): Enable code which assumes that if
- we jump into the prologue from another function, then it was a
- subroutine call. #if 0 AT_FUNCTION_START; the above code should
- take care of this case.
-
-Wed Dec 29 12:32:08 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * valprint.c (val_print_string): Change chunksize from 200
- to 8.
-
- * symfile.c (generic_load): If no arguments, get file name
- from get_exec_file.
-
- * c-exp.y: Revert Kung's change. "..." is not a type, and the
- change caused "p (...)0" to dump core.
- * gdbtypes.c (check_stub_method): Don't pass "..." to
- parse_and_eval_type. This should fix the bug which Kung was
- trying to fix.
-
- * stabsread.c (define_symbol): If we choose not to combine
- two symbols, don't just ignore the second (LOC_REGISTER) one.
- * printcmd.c (print_frame_args): If we have a LOC_ARG and a
- LOC_REGISTER, use the LOC_ARG not the LOC_REGISTER.
-
-Tue Dec 28 15:08:00 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * solib.c (DEBUG_BASE): Remove macro and all references.
- * solib.c (debug_base_symbols): Add array of symbols to lookup.
- * solib.c (IGNORE_FIRST_LINK_MAP_ENTRY): Add macro.
- * solib.c (look_for_base, locate_base): Use debug_base_symbols.
- * solib.c (find_solib): Use IGNORE_FIRST_LINK_MAP_ENTRY.
-
-Tue Dec 28 12:06:57 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * c-exp.y : fix grammar to parse ellipsis (...)
-
-Mon Dec 27 18:42:14 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * stabsread.c (read_type): fix problem when reading static member
- of a class. caused by change to allow :: inside template
- instantiated name.
-
-Mon Dec 27 11:07:05 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbtypes.h: Expand on comments for TYPE_CODE_BITSTRING and
- TYPE_CODE_STRING a bit.
-
- * m68k-tdep.c (m68k_skip_prologue, m68k_find_saved_regs):
- Allow pea %fp; move.l %sp, %fp instead of link instruction to
- set up the new frame.
-
- * main.c (init_main): Change "set remotedebug" back to var_zinteger
- from var_boolean.
-
- * c-exp.y (yylex): Don't try to deal with nested types.
-
- * cp-valprint.c (cplus_print_value): Call check_stub_type on
- TYPE_BASECLASS (type, i) before we look at its name.
-
- * dbxread.c: Move default definition of GCC_COMPILED_FLAG_SYMBOL
- from here . . .
- * symtab.h: . . . to here.
- * dbxread.c (record_minimal_symbol): Move check for gcc{,2}_compiled.
- and __gnu_compiled* from here . . .
- * minsyms.c (prim_record_minimal_symbol_and_info): . . . to here.
- * minsyms.c (prim_record_minimal_symbol): Call
- prim_record_minimal_symbol_and_info rather than duplicating code.
- * minsyms.c, symtab.h (prim_record_minimal_symbol{,_and_info}),
- coffread.c (record_minimal_symbol),
- xcoffread.c (RECORD_MINIMAL_SYMBOL), callers: Add objfile parameter.
-
-Sun Dec 26 20:44:02 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * dbxread.c (process_one_symbol): Handle stabs-in-som just like
- stabs-in-elf.
- (pastab_build_psymtabs): Likewise.
-
- * hppa-tdep.c: Change all comments to reference %r3 or frame
- pointer rather than %r4.
- (frame_chain, skip_prologue, dig_rp_from_stack): Handle %r3 as the
- frame pointer.
-
- * config/pa/tm-hppa.h (FP_REGNUM): Define as %r3.
- (FIND_FRAME_SAVED_REGS): Handle %r3 as frame pointer.
- (CALL_DUMMY): Likewise.
-
-Sun Dec 26 16:59:39 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * exec.c (exec_file_command): If error occurs after we have opened
- exec_bfd but before we call push_target, make sure to close exec_bfd.
-
- * infrun.c (wait_for_inferior): Remove confusing and inaccurate
- stuff about subroutine calls, return, etc., from comment which
- says "We've wandered out of the step range.".
-
-Sun Dec 26 09:18:10 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * infrun.c (wait_for_inferior): When checking whether the line has
- changed, check the symtab as well.
-
-Sun Dec 26 09:18:10 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbtypes.c (force_to_range_type): Use switch statement.
- complain() not warning() if the TYPE_CODE isn't one we know how to
- deal with gracefully. Use builtin_type_int not
- lookup_fundamental_type (the objfile we passed to
- lookup_fundamental_type was sometimes NULL).
-
- * valops.c (call_function_by_hand, push_word), defs.h (push_word),
- convex-xdep.c, m88k-nat.c, i386m3-nat.c, mips-tdep.c, mipsm3-nat.c,
- ns32km3-nat.c, remote-bug.c, m88k-tdep.c, remote-hms.c, remote-mips.c,
- config/gould/tm-np1.h, hppa-tdep.c (hppa_fix_call_dummy), remote-vx.c:
- Use REGISTER_SIZE, unsigned LONGEST, and
- {store,extract}_unsigned_integer, instead of sizeof
- (REGISTER_TYPE) and REGISTER_TYPE.
- * All tm.h files: Change REGISTER_TYPE to REGISTER_SIZE.
- * hppa-tdep.c (pa_print_fp_reg): Remove unused variable val.
-
- * Makefile.in (ALLDEPFILES): Remove i386ly-nat.c and m68kly-nat.c.
- Add lynx-nat.c.
-
-Sat Dec 25 20:05:41 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (init_extra_frame_info): Correctly adjust the base
- of the current frame when "fromleaf" is true. Do not adjust the
- frame base of the innermost frame if it is a leaf function.
-
-Sat Dec 25 13:39:21 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (define_symbol): Only combine a p/r pair into a
- LOC_REGPARM if REG_STRUCT_HAS_ADDR.
-
-Sat Dec 25 09:50:29 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * valops.c (value_struct_elt): Check for (value)-1 return from
- search_struct_method.
-
-Sat Dec 25 09:50:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * defs.h: Move definitions of TARGET_*_BIT after include of tm.h.
- The old way (using #undef in tm.h) was ugly and asking for
- trouble, because it makes it possible for some file to use the
- wrong definition. Move definition of HOST_CHAR_BIT after definition
- of TARGET_CHAR_BIT.
- * config/alpha/tm-alpha.h, config/h8300/tm-h8300.h,
- config/h8500/tm-h8500.h, config/z8k/tm-z8k.h: Don't undef TARGET_*_BIT
- before defining them.
-
- * mdebugread.c: Change the builtin_type_* in this file to
- mdebug_type_* and make them static. Use TYPE_CODE_ERROR for
- complex and float decimal.
-
- * printcmd.c (disassemble_command): Call wrap_here between printing
- address and printing instruction.
-
-Fri Dec 24 14:23:57 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (read_type): Don't fall through 'S' case (the case it
- was falling though happened to do the right thing ("break;") but that
- is hardly a good thing to assume).
-
-Tue Dec 21 13:32:02 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- * ch-exp.y (match_dollar_tokens): Fix off-by-one bug.
- * ch-lang.c (chill_is_varying_struct), ch-lang.h: New function.
- * ch-lang.c (chill_printstr): Use double quotes, not single quotes.
- * ch-typeprint.c (chill_type_print_base): Handle TYPE_CODE_BITSTRING.
- Improve printing of TYPE_CODE_STRING, TYPE_CODE_SET, and
- TYPE_CODE_STRUCT (including checking chill_is_varying_struct).
- Print TYPE_DUMMY_RANGE by printing its TYPE_TARGET_TYPE.
- Handle TYPE_CODE_ENUM.
- * ch-valprint.c (chill_val_print): Handle TYPE_CODE_BITSTRING.
- For TYPE_CODE_STRING, never print address. Handle VARYING strings.
- * gdbtypes.c (force_to_range_type): New.
- * gdbtypes.c (create_set_type): Make work, following Chill layout.
- * gdbtypes.h (TYPE_LOW_BOUND, TYPE_HIGH_BOUND, TYPE_DUMMY_RANGE): New.
- * stabsread.c (read_type): Distinguish string and bitstring from
- char-array and set.
- * valarith.c (value_subscript), valops.c (value_coerce_array):
- Handle STRINGs as well as ARRAYs.
- * valarith.c (value_bit_index): Fix think. Use new macros.
-
-
-Fri Dec 17 10:45:32 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * symtab (decode_line_1): fix a bug when position char is not
- set correctly.
- * c-valprint (c_val_print): handle vtbl printing when vtbl is not
- set up yet.
-
-Thu Dec 16 16:46:01 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * mips-tdep.c (read_next_frame_reg): If SIGFRAME_REG_SIZE is not
- defined, define it as 4.
-
-Thu Dec 16 13:08:01 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * config/m68k/nm-hp300bsd.h: Correctly identify 4.3BSD vs 4.4BSD.
-
- * config/m68k/tm-hp300bsd.h (REMOTE_BPT_VECTOR): Define.
-
- * config/m68k/tm-m68k.h (REMOTE_BPT_VECTOR): Allow targets to
- override.
- (REMOTE_BREAKPOINT): Likewise.
-
-Thu Dec 16 09:14:58 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (read_hp_function_type): Correctly handle
- pass-by-value structures > 64bits in size.
- (process_one_debug_symbol): Likewise.
-
-Mon Dec 13 20:17:39 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- Implement support for Chill POWERSETs.
- * ch-exp.y (operand_2): Implement 'Element IN PowerSet'.
- * ch-typeprint.c (chill_type_print_base): Handle POWERSETs.
- * ch-valprint.c (chill_val_print): Handle TYPE_CODE_SET.
- * eval.c (evaluate_subexp): Implement BINOP_IN.
- * expression.h (enum exp_opcode): Added BINOP_IN.
- * gdbtypes.c (create_set_type), gdbtypes.h: New function.
- * stabsread.c (read_type): If 'S', create a set type.
- * valarith.c (value_bit_index, value_in), value.h: New functions,
- for indexing in SETs.
-
-Mon Dec 13 06:42:37 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * paread.c (pa_symfile_init): Check for the existance of stabs
- after DBX_TEXT_SECT has been initialized.
-
-Tue Nov 23 17:29:28 1993 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * config/h8300/tm-h8300.h (BREAKPOINT): Insn changed to sleep.
- (DECP_PC_AFTER_BREAK): Now is 0.
- * config/h8500/tm-h8500.h (REGISTER_BYTES, REGISTER_BYTE,
- REGISTER_NAMES): update to new view. (INIT_EXTRA_FRAME_INFO): No
- extra frame info now.
- * config/sh/sh.h (NOP): Define NOP insn.
- * config/z8k/tm-z8k.h (BIG): is now sim_z8001_mode.
- * config/z8k/z8ksim.mt (TDEPFILES): Add remote-sim.o to list.
- * ser-go32.c: Lint. (strncasecmp): Removed, now in libiberty.
- (go32_readchar): Special handling for faster polling. (async
- structure): Volatile.
- * h8300-tdep.c (print_register_hook): Allocate and use the right
- number bytes for the raw register.
- * h8500-tdep.c (regoff, frame_find_saved_reg, examine_prologue):
- deleted. (h8500_register_size, h8500_register_virtual_type, ):
- Use new way of counting registers.
- * remote-e7000.c (echo_index): deleted. (expect): Better handling
- of user interrupts. (expect_prompt): Remove never used log file
- support. (want, want_nopc): Add support for H8/300H.
- (fetch_regs_from_dump): Treat \r and \n as whitespace.
- (e7000_drain): Send an "end" command before waiting for output to
- stop. (e7000_wait): Cope with H8/300H, better handling of user
- interrupts. (why_stop, expect_n, sub2_from_pc): New function.
- * remote-utils.c (gr_load_image): call fflush and QUIT more regularly.
- * utils.c (notice_quit): New function for polling for user interrupts.
-
-Fri Dec 10 15:53:56 1993 Per Bothner (bothner@kalessin.cygnus.com)
-
- * stabsread.c (read_array_type): Allow negative array bounds,
- without interpreting that to mean "adjustable."
- * ch-valprint.c (chill_val_print): Handle RANGE types.
- * ch-typeprint.c (chill_type_print_base): Handle BOOL.
- Handle variant records. Handle RANGE types.
-
-Tue Dec 7 15:41:32 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * config/mips/idt.mt: Use tm-idt.h instead of tm-bigmips.h.
- * config/mips/idtl.mt: Use tm-idtl.h instead of tm-mips.h.
- * config/mips/tm-idt.h, config/mips/tm-idtl.h: New files; use
- different BREAKPOINT value for IDT.
-
- * mipsread.c: Include bfd.h and coff/sym.h.
-
-Mon Dec 6 16:34:10 1993 K. Richard Pixley (rich@cygnus.com)
-
- * ser-unix.c (set_tty_state): set the rest of the terminal state
- pieces.
-
-Mon Dec 6 12:01:37 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * configure.in: Recognize mips* for all mips targets.
- (mips*el-*-elf*, mips*-*-elf*): New targets; use idt and idtl.
-
- Added Irix 5 support.
- * configure.in (mips-sgi-irix5*): New host and target. Use irix5
- for both.
- * config/mips/irix5.mh, config/mips/irix5.mt,
- config/mips/xm-irix5.h, config/mips/nm-irix5.h,
- config/mips/tm-irix5.h, irix5-nat.c: New files for Irix 5 support.
- * mdebugread.c: New file, split out of mipsread.c. Added
- elfmdebug_build_psymtabs routine. Added some checks on external
- symbols. Changed code to keep ecoff_debug_info and
- ecoff_debug_swap structs in the psymtab and in global pointers
- rather than retrieving them from the bfd. Also changed to keep
- the pending list with the psymtab rather than the objfile (each
- psymtab for a single objfile points to the same pending list).
- * mipsread.c: Bulk of file moved into mdebugread.c, leaving just
- the sym_fns.
- * Makefile.in (SFILES): Added mdebugread.c.
- (OBS): Added mdebugread.o.
- (mdebugread.o): New target.
- * symfile.h: Declare mdebug_build_psymtabs and
- elfmdebug_build_psymtabs.
- * elfread.c (struct elfinfo): Added mdebugsect field.
- (elf_locate_sections): Remember location of .mdebug section.
- (elf_symfile_read): Call elfmdebug_build_psymtabs on .mdebug
- section.
- * infrun.c (AT_FUNCTION_START): Set to 0 if not already defined.
- (wait_for_inferior): Use AT_FUNCTION_START if it is defined to see
- if PC is at the start of a function.
- * mips-tdep.c (read_next_frame_reg): Use SIGFRAME_REG_SIZE, and
- give it a default definition.
- (mips_skip_prologue): Skip instructions which initialize $gp
- register.
- (in_sigtramp): New procedure, moved in from mipsread.c.
- * config/mips/tm-mips.h: Declare in_sigtramp.
-
- * serial.h (serial_fdopen): Make parameter const to match
- function definition.
-
-Fri Dec 3 14:20:43 1993 Stu Grossman (grossman at cygnus.com)
-
- * config/mips/irix4.mh: Enable ser-tcp.o.
-
-Tue Nov 30 15:24:24 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * Makefile.in (check): Do not use subdir_do, so that
- TARGET_FLAGS_TO_PASS is used correctly.
-
-Mon Nov 29 16:10:38 1993 Stu Grossman (grossman at cygnus.com)
-
- * i386-nlmstub.c: Undo I/O redirection changes by Tom Lord.
- These definitely won't work under Netware.
-
-Mon Nov 29 15:34:58 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * stabsread.c(read_struct_field): Fix the check when getting to
- member functions.
-
-Mon Nov 29 16:48:16 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- gcc -Wall -O lint:
- * mips-tdep.c (heuristic_proc_desc): Initialize reg30 to avoid
- warning. Unnest comment.
- (init_extra_frame_info): Remove unused variable mask.
- (MASK): Fully parenthesize.
- (mips_push_dummy_frame): Remove unused variable val.
- (mips_skip_prologue): Remove unused variables f and b.
-
-Mon Nov 29 12:23:25 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (parse_symbol, parse_partial_symbols): Do not create
- (partial) symbols for opaque struct definitions.
-
-Mon Nov 29 11:36:57 1993 Stu Grossman (grossman at cygnus.com)
-
- * i386ly-tdep.c (i386lynx_saved_pc_after_call): Change call_inst
- to unsigned char to avoid domain warning for some values.
-
-Mon Nov 22 23:42:59 1993 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * remote-e7000.c (e7000_wait): Cope with H8/300 register dump.
- * config/h8300/h8300hms.mt: Add remote-e7000.
-
-Mon Nov 22 11:03:45 1993 Fred Fish (fnf@cygnus.com)
-
- Merged changes from kev@spuds.geg.mot.com (Kevin A. Buettner):
- * gdb/config/m88k/delta88.mh (NATDEPFILES): Added corelow.o and
- coredep.o to this list.
- * gdb/m88k-nat.c (m88k_register_u_addr): Avoid error when passed
- the number for an M88110 extended register by just returning the
- address of r0.
-
-Sat Nov 20 09:20:51 1993 Fred Fish (fnf@rtl.cygnus.com)
-
- * go32-xdep.c (re_comp, re_exec): Remove stubs now that gdb
- always uses it's own version of regex.
-
-Fri Nov 19 18:23:19 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * valops.c(value_struct_elt_for_reference): enhance search operator in
- c++.
- * symtab.c(decode_line_1): same as above.
-
-Fri Nov 19 15:08:47 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.c (decode_line_1): Add comment about use of
- return_to_top_level directly instead of error. Add comment saying
- that the '' should not be needed--that the completer should be fixed.
-
-Fri Nov 19 11:00:33 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * symtab.c(decode_line_1): fix the inconsistency of setting
- breakpoint with '' or without them. The '' is needed when you
- want name completion.
-
-Thu Nov 18 08:25:50 1993 Fred Fish (fnf@cygnus.com)
-
- * valprint.c (val_print_string): When looking for a null
- terminator compare current bufsize to fetchlimit to determine
- when to stop, instead of computing buffer+fetchlimit which
- may overflow for very large limits (like "unlimited").
-
-Wed Nov 17 18:23:09 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * eval.c(evaluate_subexp): to use unified search so type conversion
- operator works in calling method.
- * valarith.c(value_x_binop, value_x_unop): same as above.
- * valops.c(search_struct_method): same as above.
-
-Wed Nov 17 18:47:34 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * mipsread.c: Change use of ECOFF information to correspond to
- changes in bfd/libecoff.h.
- (mipscoff_symfile_offsets): Made static.
-
-Wed Nov 17 09:43:31 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * valops.c (typecmp): improve prototype matching when calling
- a method. Make 'p (*(ostream *) &cout) << "lll" ' to work.
- * eval.c(evalute_subexp): fix operator search problem when call
- like p x.'operator+'(i).
-
-Tue Nov 16 17:15:03 1993 Stu Grossman (grossman at cygnus.com)
-
- * i386ly-nat.c, i386lynx-nat.c, m68kly-nat.c: Remove. Move
- common code into lynx-nat.c.
- * lynx-nat.c: New module. Contains portable code for Lynx native
- stuff (mostly ptrace related).
- * config/i386/i386lynx.mh (NATDEPFILES): i386ly-nat.o -> lynx-nat.o
- * config/m68k/m68klynx.mh (NATDEPFILES): i386ly-nat.o -> lynx-nat.o
-
- * config/nm-lynx.h, config/tm-lynx.h: New files to contain
- non-architecture specific native and target defs.
- * config/i386/nm-i386lynx.h, config/i386/tm-i386lynx.h,
- config/m68k/nm-m68klynx.h, config/m68k/tm-m68klynx.h: Move all
- (arch) portable stuff into ../{tm nm}-lynx.h.
-
-Tue Nov 16 13:33:47 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.c (gdb_mangle_name): Only assume that the physname is
- the entire mangled name if it looks like the mangled name of a
- constructor. Needed for testsuite to work with GCC 2.4.5.
-
- * a68v-nat.c: Replace with new version from Troy Rollo. The
- version I am replacing appears to be an old copy of sun3-nat.c.
- * dstread.c (dst_symfile_read): Replace sort_all_symtab_syms call
- with loop.
-
- * Makefile.in (TAGS): Depend on TAGFILES_{NO,WITH}_SRCDIR.
-
- * Makefile.in: (HFILES,TAGFILES): Split into _WITH_SRCDIR and
- _NO_SRCDIR versions.
- (TAGS): Only add srcdir to TAGFILES_NO_SRCDIR.
- (This is part of a long saga involving me putting srcdir on
- everything (perhaps for now-obsolete reasons, I forget), Rich
- removing the srcdir from everything, Stu putting it back some
- places for Sun make, and me just now getting around to fixing
- `make TAGS' again).
-
-Mon Nov 15 12:29:10 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * stack.c(print_frame_info): print demangled function name
- ansi style.
-
-Mon Nov 15 14:32:29 1993 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * remote-e7000.c: New file to cope with the Hitachi E7000 ICE.
- * remote-utils.c, remote-utils.h (gr_load_image): New function to
- download to target.
- * h8300-tdep.c, h8500-tdep.c, remote-z8k.c, sh-tdep.c z8k-tdep.c
- (sim_load): delete.
- * remote-sim.c (gdbsim_load): Use gr_load_image, rather than
- sim_load.
- * config/sh/sh.mt: Add remote-e7000
-
-Mon Nov 15 11:38:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/i386/linux.mh: Remove XM_CLIBS, TERMLIB, SYSV_DEFINE, and
- REGEX.
- * config/i386/xm-linux.h: Don't include xm-i386v.h. Define
- HOST_BYTE_ORDER ourselves. Define HAVE_TERMIOS not HAVE_TERMIO.
- Define NEED_POSIX_SETPGID. Include unistd.h.
-
-Mon Nov 15 12:29:10 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * symtab.c(gdb_mangle_name): fix the problem with constructor
- name mangling.
-
-Mon Nov 15 11:38:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbtypes.h: Add TYPE_FLAG_TARGET_STUB.
- * gdbtypes.c (check_stub_type): On TYPE_FLAG_TARGET_STUB, do
- what cleanup_undefined_types does for arrays, except we clear
- TYPE_FLAG_TARGET_STUB if we fix up the type.
- * stabsread.c (cleanup_undefined_types): Add comments about how
- doing arrays here is no longer the clean way to do it.
- (read_array_type): Set TYPE_FLAG_TARGET_STUB as well as calling
- add_undefined_type.
- * c-typeprint.c, ch-typeprint.c: Move call to check_stub_type
- outside switch so it happens for all type codes.
- * cp-valprint.c (cp_print_value_fields): Recurse to val_print,
- instead of c_val_print, so that check_stub_type gets called.
-
- * gdbtypes.h, gdbtypes.c, m2-lang.c, ch-lang.c, c-lang.c: Remove
- TYPE_FLAG_SIGNED. It was inconsistently set, never checked
- (except in recursive_dump_type), and is pointless.
-
-Mon Nov 15 00:40:38 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * paread.c (pa_symfile_init): Look for the $TEXT$ section rather
- than the .text section.
-
-Sun Nov 14 00:28:13 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c: Remove #if 0'd dbx_class_complaint. We now handle
- this (more or less) gracefully, and complain() was never a good
- way of dealing with this.
-
- * stabsread.c (read_type): Skip the colon when reading a
- cross-reference. Only complain, not error_type, on unrecognized
- cross-reference types. error_type, not dump core, if the colon is
- missing.
-
-Fri Nov 12 16:23:08 1993 Stu Grossman (grossman at cygnus.com)
-
- * config/m68k/tm-sun3.h: Disable use of alternate breakpoint insn
- when doing remote stuff.
-
-Fri Nov 12 16:22:39 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * c-exp.y (yylex): Call lookup_symtab not lookup_partial_symtab.
-
- * partial-stab.h: Ignore ':' symbol descriptors. Same case as
- Kung's stabsread.c change.
-
-Fri Nov 12 11:18:02 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * stabsread.c (patch_block_stabs, define_symbol, read_type): in
- g++ template instantiation, nested class can be part of the
- params, and '::' can gets into symbol or type names. This is
- to fix the problem.
-
- * gdbtypes.c (lookup_struct_elt_type): Handle type ref or pointer
- to struct/union case.
-
-Fri Nov 12 10:39:31 1993 Stu Grossman (grossman at cygnus.com)
-
- * coff-solib.c (coff_solib_add): Cast result of alloca().
- * m68k-tdep.c (m68k_saved_pc_after_call): Get rid of
- GDB_TARGET_IS_SUN3. Use more general SYSCALL_TRAP macro.
- * config/m68k/m68klynx.mh (NATDEPFILES): Remove exec.o (it's
- already in TDEPFILES).
- * config/m68k/tm-m68k.h (SAVED_PC_AFTER_CALL): Use
- m68k_saved_pc_after_call.
- * Remove all Sun3 specific stuff.
- * (FIX_CALL_DUMMY): Cast arg to bfd_putb32 to unsigned char *.
- * config/m68k/tm-m68klynx.h: Define SYSCALL_TRAP as trap #10.
- Disable REMOTE_BREAKPOINT mechanism.
- * config/m68k/tm-sun3.h: Get rid of GDB_TARGET_IS_SUN3.
- * Protect from multiple includion.
- * Move Sun3 specific stuff from tm-m68k.h to here.
- * Define SYSCALL_TRAP as trap #0.
- * Remove def of SAVED_PC_AFTER_CALL (now in tm-m68k.h).
- * gdbserver/low-lynx.c: Redo all register store/fetch stuff to
- make it portable for 386 and 68k.
-
-Fri Nov 12 09:53:26 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * mips-tdep.c (init_extra_frame_info): Check to see whether the
- registers mentioned in the proc_desc have been saved. This
- generalizes mips_in_lenient_prologue in the sense that we keep
- searching until we've found saves for all the registers, not just
- look for a "lenient prologue" pattern.
- * mips-tdep.c: #if 0 lenient prologue code.
-
- * mips-tdep.c (heuristic_proc_desc): Don't assume a host short
- is 16 bits.
-
-Thu Nov 11 19:58:05 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/i386/i386sol2.mh: Comment out corelow.o.
-
- * printcmd.c (address_info): Use filtered, not unfiltered functions.
- We should be able to deal with a QUIT here.
-
-Thu Nov 11 15:22:20 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * printcmd.c (address_info): Use fprintf_symbol_filtered
- to print the symbol name.
-
- * stabsread.c (define_symbol): Handle cfront lossage for
- struct/union/enums and typedefs.
-
- * partial-stab.h (case N_BINCL): Update psymtab_language
- as appropriate when changing subfiles.
- (case N_SOL): Update psymtab_language as appropriate when
- changing subfiles. Add typedef for structs, unions, and enums
- when processing C++ files.
-
-Thu Nov 11 13:18:47 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * README: Remove information on languages and just cite the (newly
- updated) information in doc/gdb.texinfo instead.
-
- * delta68-nat.c: Fix typos (add missing ");" and stuct -> struct).
-
-Wed Nov 10 09:31:10 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dbxread.c (process_one_symbol, N_RBRAC): Don't clear
- within_function just because local_symbols is NULL. It appears
- that this bug has existed since the 10 Apr 89 change which started
- clearing within_function here.
-
- * config/m68k/tm-m68k.h: Clean up CALL_DUMMY comment.
- * config/m68k/{tm-hp300bsd.h,tm-hp300hpux.h,tm-m68k-em.h,
- tm-monitor.h,tm-sun3.h,tm-vx68.h}, config/sparc/tm-sparc.h:
- Define BELIEVE_PCC_PROMOTION.
- * dbxread.c: Remove BELIEVE_PCC_PROMOTION define. The code which
- used this was moved to stabsread.c a long time ago.
-
- * dstread.c (dst_sym_fns): Update for flavours.
- * symfile.c (find_sym_fns): Add kludge for apollo like for rs/6000.
- * dstread.c (dst_symfile_offsets): Set objfile->num_sections.
-
- gcc -Wall lint:
- * thread.c: Include "gdbcmd.h" and <ctype.h>.
- * Makefile.in: Update dependency.
- * thread.c (thread_command): Remove unused variable p.
- * values.c (unpack_double): Use len instead of TYPE_LENGTH (type).
- * valprint.c (print_floating): Correctly check sign bit now that
- we are using unsigned arithmetic.
- * symtab.c (find_pc_line_range): Remove unused variables exact_match,
- ind, and l.
-
-Tue Nov 9 17:42:25 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * valarith.c (value_x_binop): fix search operator in class bug
- * valarith.c (value_x_unop): fix search operator in class bug
-
-Tue Nov 9 19:20:17 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (init.c): Add udi2go32.o to list of files that we
- should not try to search for _initialize_* functions.
-
- * remote-udi.c (udi_wait): Change UDIGdb_StdoutReady back to
- UDIStdoutReady. It accidentally got changed on 24 Oct 93 when
- stdout was changed to gdb_stdout. Likewise for UDIGetStdout,
- UDIStderrReady, and UDIGetStderr.
-
-Tue Nov 9 12:48:06 1993 Tom Lord (lord@cygnus.com)
-
- * remote-hms.c (hms_wait): fixed too many arguments to putc_unfiltered.
-
-Tue Nov 9 12:20:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * utils.c (quit): Also call gdb_flush on standard output and error.
-
- * .gdbinit: Remove "source /.gdbinit". It causes a spurious error
- if /.gdbinit doesn't exist (and I know of no convention of putting
- something in /.gdbinit).
-
-Mon Nov 8 18:17:11 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * cp-valprint.c (cp_print_value_fields): change output from <no
- value> to <optimized out or zero length>
-
-Mon Nov 08 17:05:30 1993 Jeffrey Wheat (cassidy@cygnus.com)
-
- * Makefile.in: Change RUNTEST_FLAGS back to RUNTESTFLAGS
- Change RUNTEST = runtest to test for existance of
- a runtest in the source tree first.
-
-Mon Nov 8 10:42:03 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in: Remove unused variable GCC. Remove "#CC=cc" line
- which doesn't really relate to anything.
-
- * Makefile.in (CC_FOR_TARGET): Test for existence of gcc/xgcc, not
- for existence of gcc/Makefile.
-
- * inflow.c (terminal_init_inferior), infptrace.c (child_resume):
- Add comments about use of Lynx PIDGET and how we will want to
- clean it up.
-
- * stabsread.c: Remove long_kludge_name code (it was already #if 0).
- * stabsread.c (read_one_struct_field): Clean up comments to reflect
- Kung's change of 5 Nov 93.
- * stabsread.c (read_one_struct_field): Don't give up on unknown
- visibility character, just shove it in fip->list->visibility.
- (read_baseclasses): Don't give up on unknown virtual or visibility
- characters, just assume a reasonable default, complain, and keep
- going.
- (attach_fields_to_type): Complain on unrecognized visibility.
- One result of all this is that '9' (VISIBILITY_IGNORE) can be used
- in a stab as well as being something which GDB uses internally.
-
-Mon Nov 8 07:57:30 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * configure.in: Remove h8300h, we have multilib now.
-
-Mon Nov 8 06:11:24 1993 D. V. Henkel-Wallace (gumby@cirdan.cygnus.com)
-
- * configure.in: Add unixware as a configuration alias for x86
- sysv4
-
- * config/i386/i386nw.mt: add i387-tdep.o, exec.o to TDEPFILES
-
-Sun Nov 7 23:49:21 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symtab.c (decode_line_1, decode_line_2): Do not adjust pc by
- FUNCTION_START_OFFSET if funfirstline is not set.
-
-Fri Nov 5 17:19:30 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * gdbtypes.h : add a field 'ignore_field_bits in cplus_specific,
- and macros to handle the bits.
- * stabsread.c (read_one_struct_field): add VISIBILITY_IGNORE, and
- for field of length 0, set this bit on.
- * cp-valprint.c (cp_print_value_fields): for VISIBILITY_IGNORE
- field, print <no value>.
-
-Fri Nov 5 14:43:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Version 4.11.2.
-
-Fri Nov 5 09:49:22 1993 Stu Grossman (grossman at cygnus.com)
-
- * inflow.c (terminal_init_inferior): Temporarily use Lynx PIDGET
- macro to set process groups.
- * infptrace.c (child_resume): Temporarily use Lynx PIDGET to
- specify resumption of all threads.
- * infrun.c (wait_for_inferior): Fix handling of thread-specific
- breakpoints for systems where DECR_PC_AFTER_BREAK > 0 (ie: backup
- PC by the right amount when continuing the thread).
- * thread.c (thread_apply_command): Add the `thread apply'
- command to apply a given GDB command to a list of threads.
-
-Fri Nov 5 05:58:03 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Makefile.in (init.c): Don't call sed if filename is empty.
-
-Thu Nov 4 08:27:24 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dbxread.c (unknown_symchar_complaint): Make message refer to
- "symbol descriptor" not "symbol type character" for consistency
- with stabs.texinfo terminology.
-
- * stabsread.c (read_struct_fields): Accept either '$' or '.' as
- the character which introduces a cpp_abbrev or anonymous type.
-
- * c-lang.c (c_printstr): Print "" to stream (like all the other
- output from this function), not gdb_stdout.
-
- * dbxread.c (process_one_symbol): Do relocate 'S' symbols by
- the text offset (revert 12 Oct 93 change).
-
- * configure.in: Make hppa*-*-hiux* use hppahpux,
- not non-existent hppahiux.
-
-Wed Nov 3 16:24:09 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * values.c (value_fn_field): when physical name not found, do not
- error, but return null.
- * valops.c (value_struct_elt): when name and args match does not
- mean it is the one, some times a typedef class can have the same
- member method and args. This probably will not happen with new
- version of g++, but it does happen in old g++ and cause gdb error.
-
-Wed Nov 3 09:20:18 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- Merge changes for dos x udi:
- * Makefile.in (udi2go32.o): add rule to build this file
- * 29k-share/udi/udi2go32.c: new file
- * config/a29k/a29k-udi.mt: add udi2go32.o
- * 29k-share/udi/{udr.c, udip2soc.c}: #ifdef out the entire file
- if __GO32__ is defined. What a hack.
-
-Wed Nov 3 09:20:18 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote.c (putpkt, getpkt): Don't call interrupt_query.
-
- * findvar.c (value_of_register): Rename val to reg_val to avoid
- name conflict with some (e.g. tm-m68k.h) REGISTER_CONVERT_TO_VIRTUAL.
-
- * main.c: Add variables source_line_number, source_file_name,
- source_error, source_error_allocated, and source_pre_error.
- (command_line_input): If source_file_name set, increment
- source_line_number and set error_pre_print with them.
- (source_command): Set source_* and make a cleanup so they get
- set back.
-
-Tue Nov 2 16:28:34 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stack.c (down_silently_command): Add comment about PR 1913.
-
- * breakpoint.c (insert_breakpoints, delete_breakpoint): Call
- target_terminal_ours_for_output before attempting output.
-
- * fork-child.c (fork_inferior): Fix comment so that it suggests
- "set shell" rather than having "set env SHELL" affect GDB's
- operation.
-
-Tue Nov 2 15:03:08 1993 Tom Lord (lord@rtl.cygnus.com)
-
- * utils.c (vfprintf_unfiltered): don't use maybe_filtered
- since it involves a fixed size buffer.
-
-Tue Nov 2 13:42:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * findvar.c (value_of_register, value_from_register),
- hppa-tdep.c (pa_print_fp_reg), infcmd.c (do_registers_info),
- valops.c (value_assign): Use REGISTER_CONVERT_TO_* only if
- REGISTER_CONVERTIBLE is defined, otherwise just copy the content.
- Pass desired type to REGISTER_CONVERT_TO_*.
-
- * config/m68k/tm-m68k.h, config/i960/tm-i960.h (REGISTER_CONVERT_*):
- Pass length of desired type to store/extract_floating.
- * config/i386/tm-arm.h, config/i386/tm-i386aix.h,
- config/i386/tm-sun386.h, config/i386/tm-symmetry.h,
- config/m88k/tm-m88k.h config/rs6000/tm-rs6000.h (REGISTER_CONVERT_*):
- Use extract_floating and store_floating with length of desired type.
- * config/m68k/tm-news.h (STORE,EXTRACT_RETURN_VALUE): Add type
- parameter to REGISTER_CONVERT_*.
-
- * config/a29k/tm-a29k.h, config/convex/tm-convex.h,
- config/gould/tm-np1.h, config/gould/tm-pn.h, config/h8300/tm-h8300.h,
- config/h8500/tm-h8500.h, config/i386/tm-i386v.h,
- config/mips/tm-mips.h, config/ns32k/tm-merlin.h,
- config/ns32k/tm-umax.h, config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
- config/sh/tm-sh.h, config/sparc/tm-sparc.h, config/tahoe/tm-tahoe.h,
- config/vax/tm-vax.h, config/z8k/tm-z8k.h (REGISTER_CONVERTIBLE,
- REGISTER_CONVERT_TO_RAW, REGISTER_CONVERT_TO_VIRTUAL): Remove
- versions for which REGISTER_CONVERTIBLE is always false.
- * z8k-tdep.c (register_convert_to_virtual, register_convert_to_raw):
- Remove, no longer used.
-
- * alpha-tdep.c (alpha_register_convert_to_raw,
- alpha_register_convert_to_virtual): New routines to handle
- the different raw formats in alpha floating point registers.
- * config/alpha/tm-alpha.h (REGISTER_CONVERTIBLE,
- REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW): Use them.
-
-Tue Nov 2 12:45:23 1993 Stan Shebs (shebs@rtl.cygnus.com)
-
- * gdbserver/configure.in: Recognize *-*-lynxos* instead of
- *-*-lynx*, recognize sparc-*-lynxos*.
- * gdbserver/Makefile.in (install, install_only): Add.
- * gdbserver/gdbserver.1: New file, man page for gdbserver.
-
-Tue Nov 2 03:01:01 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Include <time.h> and <sys/types.h>. Change include
- of "libhppa.h" to "som.h".
- (BYTES_IN_WORD): Define.
- (hppa_sym_fns): "hppa" is 4 characters, not 5.
-
-Mon Nov 1 09:40:21 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.c, symtab.h, source.c: Change find_line_pc_range to take
- a struct symtab_and_line argument, rather than a symtab and a line.
- Re-write it to be based on the address rather than bogusly adding
- one to the line number and hoping that has something to do with the
- end of the line.
-
- * config/m88k/m88k.mh (NATDEPFILES): Remove exec.o.
-
- * paread.c (pa_symtab_read): Change comments to say ignoring
- labels really should be handled by the assembler/compiler.
-
- * Makefile.in: Add -O to CXXFLAGS.
-
- * TODO: Expand comments on fast watchpoints.
-
-Sun Oct 31 19:45:06 1993 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * paread.c (pa_symtab_read): Also filter out local symbols
- starting with "L$".
-
-Sun Oct 31 09:28:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symfile.h (sym_fns), symfile.c (find_sym_fns), xcoffread.c,
- coffread.c, dbxread.c, elfread.c, mipsread.c, nlmread.c, paread.c:
- Change from using bfd target name to using the flavour.
-
- * objfiles.h, infcmd.c, symfile.c: Add comments about how various
- objfiles get created and when we should blow them away.
-
-Sat Oct 30 08:32:53 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symfile.c (reread_symbols): When re-reading symbols, do all the
- right operations ourself, rather than calling symbol_file_command.
- If we re-read something, call clear_symtab_users not just
- breakpoint_re_set.
- * objfiles.h, objfiles.c (build_objfile_section_table): No longer
- static.
- * symfile.c (clear_symtab_users): Call clear_pc_function_cache.
- * coffread.c, dbxread.c, elfread.c, mipsread.c, nlmread.c, paread.c
- (*_symfile_offsets): Set objfile->num_sections.
- * remote.c (remote_wait), symfile.c (syms_from_objfile):
- Don't muck with objfile->num_sections now that all the symbol
- readers set it.
- * elfread.c: Clean up obsolete comment about handling only DWARF.
- * paread.c: Remove comment about how we should use an "ordinary"
- file format with an hppa suffix. There is nothing ordinary about SOM.
-
- * config/i386/{i386m3.mh,i386mk.mh}, config/mips/mipsm3.mh,
- config/ns32k/ns32km3.mh: Change MMALLOC_LIB to MMALLOC.
- * TODO: Update Mach stuff.
-
-Fri Oct 29 16:30:36 1993 Stan Shebs (shebs@rtl.cygnus.com)
-
- LynxOS support:
- * configure.in: Change *-*-lynx* to *-*-lynxos*, add
- sparc-*-lynxos*.
- * Makefile.in (ALLDEPFILES): Add m68kly-nat.c, sparcly-nat.c.
- Rename i386lynx-nat.[co] to i386ly-nat.[co].
- (ALLCONFIG): Add config/{m68k,sparc}/{m68k,sparc}lynx.m[ht].
- (m68kly-nat.o, sparcly-nat.o): Add rules.
- * i386ly-tdep.c: Cosmetics.
- * i386lynx-nat.c: Removed.
- * i386ly-nat.c: New file, was i386lynx-nat.c.
- * m68kly-nat.c: New file.
- * sparcly-nat.c: New file.
- * config/xm-lynx.h: New file, cpu-independent host info.
- * config/i386/i386lynx.mh: Changes for consistency.
- * config/i386/i386lynx.mt: Ditto.
- * config/i386/tm-i386lynx.h: Ditto.
- * config/i386/nm-i386lynx.h: Ditto.
- * config/i386/xm-i386lynx.h: Include config/xm-lynx.h.
- * config/m68k/m68klynx.mh, config/m68k/m68klynx.mt,
- config/m68k/tm-m68klynx.h, config/m68k/nm-m68klynx.h,
- config/m68k/xm-m68klynx.h: New files, M68K LynxOS support.
- * config/sparc/sparclynx.mh, config/sparc/sparclynx.mt,
- config/sparc/tm-sparclynx.h, config/sparc/nm-sparclynx.h,
- config/sparc/xm-sparclynx.h: New files, Sparc LynxOS support.
-
-Fri Oct 29 08:11:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * defs.h, findvar.c (extract_floating, store_floating): New functions.
- * Move SWAP_TARGET_AND_HOST from defs.h to findvar.c because it is
- now used only by extract_floating and store_floating.
- * valprint.c (print_floating): Use unsigned arithmetic. Use
- extract_unsigned_integer instead of SWAP_TARGET_AND_HOST.
- Change sizeof (float) to 4 and sizeof (double) to 8 (those are always
- the relevant sizes for this code, which is in #ifdef IEEE_FLOAT).
- * values.c (unpack_long, unpack_double, value_from_double),
- valarith.c (value_binop), stabsread.c (define_symbol):
- Use extract_floating and store_floating instead of
- SWAP_TARGET_AND_HOST.
- * config/m68k/tm-m68k.h, config/i960/tm-i960.h (REGISTER_CONVERT_*):
- Use extract_floating and store_floating.
- * config/m88k/tm-m88k.h: Add comments (it should be doing the same).
- * i386-tdep.c (i386_extract_return_value),
- * remote-nindy.c (nindy_store_registers): Use store_floating.
-
-Fri Oct 29 09:31:38 1993 Steve Chamberlain (sac@rtl.cygnus.com)
-
- * remote-sim.c (gdbsim_store_register): Change var name so
- it compiles with non-ANSI compilers.
-
-Fri Oct 29 08:11:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * TODO: Add idea for "disassemble" with source.
-
-Fri Oct 29 00:41:01 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.11.1 after release and cvs
- tagging.
-
-Thu Oct 28 09:14:42 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * TODO: Add section on Mach. Stop calling it a "bug list".
- Remove John's name and email address. Remove item on "always"
- ("hook-stop" takes care of this). Remove item on executables with
- no symbols (this works on some machines, at least). Remove item
- about calling error() during symbol reading (I think all the important
- ones have been cleaned up). Revise items about signals and remote
- systems. Remove section on ^Z requiring several continues to make
- it go (this now works. Perhaps the item is based on confusion over
- programs (like GDB itself) which catch SIGTSTP and then re-send
- themselves the signal. PR 2575 might contain relevant info).
-
-Thu Oct 28 16:55:34 1993 Fred Fish (fnf@cygnus.com)
-
- * NEWS: Note improvements in C++ support, preliminary thread
- implementation, and LynxOS native and target support for 386.
-
-Thu Oct 28 16:55:34 1993 Fred Fish (fnf@cygnus.com)
-
- * README: Add note from Peter Schauer about OSF/1 shared
- libraries. Add note from Pace Willisson about configuring on BSDI
- BSD/386 release 1.0. Update gdb references to gdb 4.11.
-
-Thu Oct 28 09:14:42 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * NEWS: Add notes about Alpha and "set remotedebug" for UDI.
-
- * valops.c (value_assign): Change bitfield code to use a buffer of
- the correct size, rather than an int.
-
-Wed Oct 27 13:43:07 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/i386/{i386m3.mt,i386m3.mh},
- config/mips/{mipsm3.mt,mipsm3.mh},
- config/ns32k/{ns32km3.mt,ns32km3.mh}: Use correct names for TM_FILE
- and XM_FILE. Replace host files *mach3-xdep.o with native
- files *m3-nat.o. Replace host file os-mach3.o with native
- file m3-nat.o.
-
- * remote-udi.c: Remove LOG_FILE stuff; superceded by "set remotedebug".
- * remote-mon.c: Remove commented out "set remotedebug" command.
- * remote-nindy.c: Clean up comment about wanting alternative to
- options specified on the GDB command line.
-
- * fork-child.c (fork_inferior): Set inferior_pid before calling
- init_trace_fun. Move the code which gets us through the shell
- to new function startup_inferior.
- * inferior.h: Declare startup_inferior.
- * procfs.c (procfs_init_inferior), inftarg.c (ptrace_him):
- Call startup_inferior.
- * m3-nat.c (m3_trace_him): Call intercept_exec_calls.
- * config/nm-m3.h: Don't define STARTUP_INFERIOR.
- * config/i386/tm-i386m3.h, config/ns32k/tm-ns32k.h,
- config/mips/tm-mipsm3.h: Don't define START_INFERIOR_TRAPS_EXPECTED.
-
- * m68k-stub.c: Change vector 13 from SIGFPE to SIGBUS.
-
-Tue Oct 26 22:05:03 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * mips-tdep.c (mips_pop_frame): If proc_desc is NULL, don't dump core.
-
-Tue Oct 26 15:07:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- gcc -Wall lint:
- * nlmread.c: Include stabsread.h.
- * Makefile.in: Update dependencies.
-
- * remote.c: Change PBUFSIZ back to 400. John's 28 Feb 1992 change
- to increase it broke the ability to write large chunks of memory
- with m68k-stub and i386-stub. Now we only use more than 400 on
- machines where we need that much to write the registers.
- * remote.c (remote_write_bytes): Eliminate possible abort(). The
- check for when to abort was off by a few bytes and besides which,
- it is handled by MAXBUFBYTES, which the caller uses.
- * m68k-stub.c: Add comments about trap #1 and trap #8 instructions.
-
-Tue Oct 26 08:36:07 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * remote-sim.h (SIM_ADDR): New type (same as CORE_ADDR).
- (sim_set_pc): Update prototype.
- (sim_read, sim_write): Ditto, and use unsigned char *buf.
- (sim_fetch_register, sim_store_register): Use unsigned char *buf.
- (sim_info): Pass printf function as argument, add verbose argument.
- (sim_stop_reason): Renamed from sim_stop_signal, fix prototype.
- * remote-sim.c (gdbsim_wait): Update call to sim_stop_reason.
- (gdbsim_files_info): Update call to sim_info.
-
-Tue Oct 26 10:41:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * valops.c (value_assign): Call reinit_frame_cache when assigning
- to a register.
-
-Mon Oct 25 11:08:59 1993 Stu Grossman (grossman at cygnus.com)
-
- * infrun.c (wait_for_inferior): Fix PC out of objfile bounds
- check to just use stop_func_name == 0.
- * remote-udi.c (store_register): Invalidate NPC/PC_REGNUM after
- changing PC.
-
-Mon Oct 25 14:57:45 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbserver/{low-lynx.c,low-sparc.c,low-sun3.c}, standalone.c,
- m3-nat.c, i386m3-nat.c, mipsm3-nat.c, ns32km3-nat.c: bcopy -> memcpy.
-
- gcc -Wall lint:
- * breakpoint.c: Include thread.h.
- * coffread.c: Include stabsread.h.
- * Makefile.in: Update dependencies.
- * breakpoint.c (mention): Add bp_call_dummy to switch.
- * symmisc.c (dump_symtab): Use %d not %ld for line number.
-
-Sun Oct 24 18:29:32 1993 Tom Lord (lord@rtl.cygnus.com)
-
- * every non-obsolete file except utils.c:
- Change the stream argument to _filtered to GDB_FILE *.
- Change all references to stdout/stderr to gdb_stdout/gdb_stderr.
- Replace all calls to stdio output functions with
- calls to corresponding _unfiltered functions.
- Replaced calls to fopen for output to gdb_fopen.
- Added sufficient goo to utils.c and defs.h to make the above
- work.
-
- The net effect is that stdio output functions are only directly
- used in utils.c. Elsewhere, the _unfiltered and _filtered
- functions and GDB_FILE type are used.
-
- In the near future, GDB_FILE will stop being equivalant to
- FILE.
-
- The semantics of some commands has changed in a very subtle way:
- called in the right context, they may cause new occurences of
- prompt_for_continue() behavior.
-
- Please respect this change by not reintroducing stdio output
- dependencies in the main body of gdb code. All output from
- commands should go to a GDB_FILE.
-
-Sun Oct 24 20:16:38 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * parse.c, parser-defs.h (write_exp_msymbol): New function to write
- the appropriate expression for a minimal symbol. Taken from c-exp.y
- and m2-exp.y but handles mst_file_*.
- * c-exp.y, m2-exp.y: Use it.
-
-Sun Oct 24 09:31:05 1993 Fred Fish (fnf@lisa.cygnus.com)
-
- * elfread.c (elf_symtab_read): Use bfd convention that both
- initialized and uninitialized data sections have the SEC_ALLOC
- flag bit set, but only initialized sections have SEC_LOAD set.
- SEC_DATA is ignored since it only gets set for initialized
- data.
-
-Sat Oct 23 14:48:18 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * remote-sim.h (sim_stop): New enum.
- (sim_stop_signal): Change prototype, result is enum sim_stop.
- * remote-sim.c (gdbsim_wait): Update call to sim_stop_signal.
-
-Fri Oct 22 07:49:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (define_symbol): Skip the whole thing about "pcc
- promotion" on little-endian machines.
-
- * remote-vx.c (vx_wait): Rename pid parameter to pid_to_wait_for.
- Some compilers (legitimately) don't like variables in the
- function's outermost block whose name is the the same as the name of
- a parameter.
-
- Merge Apollo patches from Troy Rollo (troy@cbme.unsw.edu.au):
- * dst.h, dstread.c, config/m68k/{apollo68b.mt,tm-apollo68b.h}:
- New files.
- * config/m68k/nm-apollo68b.h: Add more defines.
- * configure.in: Recognize apollo target, not just host.
-
- * configure.in: Add * to end of all OS names.
-
-Fri Oct 22 06:14:01 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (ALLPARAM): Add config/m88k/xm-delta88v4.h
-
-Thu Oct 21 12:23:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (init.c): Generate using the source, not munch. This
- cleans up all kinds of hassles (which nm to use in munch, etc). The
- new formatting conventions (mostly already followed) are that
- the name of the _initialize_* routines must start in column zero,
- and must not be inside #if.
- * munch: Removed.
- * Makefile.in: Remove references to munch.
- * serial.c, remote.c, infptrace.c, maint.c, convex-tdep.c,
- alpha-tdep.c, hp300ux-nat.c, hppab-nat.c, osfsolib.c, remote-es.c,
- procfs.c, remote-udi.c, ser-go32.c, ultra3-xdep.c, sh-tdep.c,
- i960-tdep.c, hppa-tdep.c, h8500-tdep.c, dpx2-nat.c, delta68-nat.c,
- z8k-tdep.c: Make sure the above conventions are followed. Make
- sure they are all declared as returning void. Clean up
- miscellaneous comments and such.
-
- * sh-tdep.c (sim_load): Add function.
-
-Thu Oct 21 15:58:48 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * remote-mips.c (mips_wait): add pid argument.
-
-Thu Oct 21 12:23:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (c-exp.tab.o): Remove notice about shift/reduce conflicts
- which no longer occur.
-
- gcc -Wall lint:
- * findvar.c (symbol_read_needs_frame), corelow.c (ignore),
- inflow.c (gdb_has_a_terminal): Make sure to return a value.
- * regex.h: Declare re_set_syntax.
- * printcmd.c: Include valprint.h.
- * infcmd.c, exec.c, maint.c, core.c: Include language.h.
- * maint.c: Include expression.h.
- * infrun.c, fork-child.c, corelow.c, inflow.c: Include thread.h.
- * inftarg.c: Include command.h.
- * coredep.c: Include value.h.
- * c-exp.y, m2-exp.y, ch-exp.y: Include bfd.h, symfile.h and objfiles.h.
- * ch-typeprint.c: Include typeprint.h.
- * ch-valprint.c: Include c-lang.h.
- * nlmread.c: Include buildsym.h.
- * environ.c: Include gdbcore.h. Only include defs.h once.
- (set_in_environ): Cast const char * to char * when passing to
- set_gnutarget.
- * Makefile.in: Update dependencies to reflect all these new includes.
- Remove unused variables:
- * printcmd.c (printf_command): args_to_vprintf.
- * coffread.c (coff_symfile_init): strsection.
- Move variables to within the #ifdefs where they are used:
- * symtab.c (gdb_mangle_name): opname.
- * inftarg.c (child_attach): pid and exec_file.
- * inftarg.c (child_detach): siggnal.
- * objfiles.c (allocate_objfile): mapto, md, and fd.
- * objfiles.c (free_objfile): mmfd.
- * infrun.c (wait_for_inferior): Include BPSTAT_WHAT_LAST in switch.
- * infrun.c (wait_for_inferior): Remove unused same_pid label.
- * inferior.h: Declare set_sigint_trap and clear_sigint_trap.
- * parser-defs.h: Declare write_exp_elt_block.
- * stabsread.h: Declare elfstab_offset_sections and
- coffstab_build_psymtabs.
-
-Thu Oct 21 12:05:08 1993 Ken Raeburn (raeburn@cygnus.com)
-
- Patch from Jeff Law:
- * paread.c: Fix references to "hppa" that should now be "som".
-
-Thu Oct 21 12:23:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.c (decode_line_1): Don't use SYMBOL_LINE for functions.
-
-Thu Oct 21 02:59:07 1993 Stu Grossman (grossman at cygnus.com)
-
- * remote-udi.c (udi_store_registers, store_register): Use
- UDI29KPC address space when modifying PC. It seems that you can't
- modify the PC directly (at least in the isstip simulator).
-
-Wed Oct 20 11:35:43 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * target.h: Put remote_debug declaration back here. Add baud_rate.
- * remote.c, remote-udi.c, remote-utils.h: Let target.h take care of
- declaring these. Those random externs all over are error prone.
- * Move "set remotebaud" from remote-utils.c to main.c to it applies
- to remote.c as well.
-
- * xcoffread.c (xcoff_symfile_read), coffread.c (coff_symfile_read):
- Sort symtabs for this objfile only, not for all objfiles.
- * symfile.c, symfile.h (sort_all_symtab_syms): Remove; no longer used.
-
- * mipsread.c (parse_symbol): In third-eye, a function has a block
- within it which represents the whole function. Create only one
- GDB block for both.
-
-Wed Oct 20 17:47:42 1993 Stu Grossman (grossman at cygnus.com)
-
- * main.c: Make baud_rate and remote_debug be global variables,
- remove #include "remote-utils.h". This makes it possible to build
- GDB without remote-utils.c. Also, move setting of remote_debug
- into main, so that all remote*.c files can use it (not just the
- serial line ones). And, make baud_rate be an int.
- * remote-udi.c: Change kiodebug to remote_debug.
- * remote-utils.c: Move setting of baud rate and debug into main.c.
- * remote-utils.h: Redefine sr_{get set}_debug and sr_{get set}_baud
- to use baud_rate and remote_debug globals for compatibility.
- * remote.c: Use remote_debug and baud_rate globals directly,
- instead of sr_ functions, so that we don't need to load
- remote-utils.c.
- * config/a29k/a29k-udi.mt: Define REMOTE_O as null so that we don't
- get the default remote* modules.
-
-Wed Oct 20 11:35:43 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (define_symbol): When combining a LOC_ARG and a
- LOC_REGISTER, use the type from the LOC_REGISTER, not from the
- LOC_ARG.
-
-Wed Oct 20 14:34:38 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * config/i386/xm-go32.h: define some signals if they aren't
- already defined.
-
-Wed Oct 20 11:35:43 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (INTERNAL_LDFLAGS): New macro. The new part is
- that we use CFLAGS and PROFILE_CFLAGS to link.
- (gdb, rapp, kdb): Use INTERNAL_LDFLAGS instead of
- LDFLAGS and/or GLOBAL_CFLAGS.
-
-Wed Oct 20 09:29:55 1993 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in: Add $(srcdir) to all refs to 29k-share
- directories.
-
-Tue Oct 19 17:23:34 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * Makefile.in (ALLCONFIG): Add config/i386/{i386m3.mh, i386m3.mt,
- i386/i386mk.mh i386/i386mk.mt}, config/mips/{mipsm3.mh,
- mipsm3.mt}, config/ns32k/{ns32km3.mh, ns32m3.mt}
- * Makefile.in (remote_utils_h): Add remote-sim.h
- * Makefile.in (NONSRC): Add i386-nlmstub.c
- * Makefile.in (HFILES): Add coff-solib.h
-
-Tue Oct 19 14:15:40 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * values.c (value_virtual_fn_field): Fix the offset calculation
- when calling virtual functions. (gdb.t22/virtfunc.exp).
- * eval.c (evaluate_subexp): same as above.
-
-Tue Oct 19 10:43:16 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/rs6000/rs6000.mh (TERMCAP): Define to -lcurses.
-
- * Makefile.in: Define CXXFLAGS.
-
-Tue Oct 19 09:28:52 1993 Stu Grossman (grossman@cygnus.com)
-
- * sparclite/Makefile.in: Fixup so that this works with Sun make
- and VPATH.
-
-Tue Oct 19 10:43:16 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.h (struct bpstat_what): Don't use bitfields.
-
- * typeprint.c: Add "class CLASS-NAME" to docstring for ptype.
-
-Tue Oct 19 06:17:10 1993 Fred Fish (fnf@cirdan.cygnus.com)
-
- * Makefile.in (ALLPARAM): Add config/m88k/{nm-delta88v4.h,
- tm-delta88v4.h, xm-dgux.h}.
- * Makefile.in (ALLCONFIG): Add config/m88k/{delta88v4.mh,
- delta88v4.mt}.
-
- * README: Remove comment about SunOS 5.x programs leaving
- coredumps. Info from Sun is that this was not in customer
- releases.
-
-Mon Oct 18 10:28:08 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * hppa-tdep.c (restore_pc_queue): Call target_terminal_ours after
- done stepping the inferior.
-
- * c-exp.y: Remove never-used (because of shift/reduce conflicts)
- rules for pointers to members.
- * Makefile.in: Remove notice about expected shift/reduce conflicts.
-
- * buildsym.c (finish_block): If we pop the context stack and it is
- not empty, complain () instead of abort ().
-
-Sun Oct 17 19:42:31 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * parse.c, parser-defs.h (follow_types): New function.
- * c-exp.y (ptype : typebase abs_decl): Use it.
- * c-exp.y (ptype): Add support for type qualifiers after the
- typebase. The typebase rule already has support for them before
- the typebase.
- * Makefile.in: Change the expected number of shift/reduce
- conflicts to 6. This is OK--the 2 new conflicts are basically the
- same as one of the old ones.
-
-Sun Oct 17 13:04:49 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.10.3.
-
-Sun Oct 17 09:18:57 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (wait_for_inferior): Clean up comments which were at
- the top of the file, making them more concise and moving them with
- the code (Sorry, Randy, but these stream-of-consciousness comments
- really have to go). Switch the order of the "&&", which makes
- things clearer and turns out to be an improvement with respect to
- side effects and speed.
-
-Sun Oct 17 02:06:01 1993 Stu Grossman (grossman at cygnus.com)
-
- * procfs.c: Handle process exits more elegantly by trapping on
- entry to _exit. Also, cleanup procinfo list when process dies of
- it's own accord (as opposed to being killed).
-
-Sat Oct 16 20:47:30 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/m88k/xm-dgux.h: Define NO_PTRACE_H.
-
- * corelow.c (add_to_thread_list): Need a cast to go from PTR to
- asection *.
-
- * infrun.c: Add comment about signals.
-
- * fork-child.c (fork_inferior): Remove CREATE_INFERIOR_HOOK again.
- Stu reinstated it (accidently I assume).
-
-Sat Oct 16 15:27:10 1993 Stu Grossman (grossman at cygnus.com)
-
- * procfs.c (procfs_wait): Losing Unixware can't do poll on /proc
- files. Use PIOCWSTOP instead.
- * corelow.c (add_to_thread_list): Fix arg to match prototype.
-
- * procfs.c (procfs_set_sproc_trap): Don't use this if sproc
- isn't available.
- * (procfs_notice_signals): Fix prototype.
-
-Fri Oct 15 22:46:07 1993 Stu Grossman (grossman at cygnus.com)
-
- * breakpoint.c (breakpoint_thread_match break_command_1):
- Thread-specific breakpoint support.
- * breakpoint.h (struct breakpoint): Add thread id field.
- * fork-child.c (fork_inferior): Move call to init_thread_list()
- back a bit so that init_trace_fun can do thread functions.
- * hppa-tdep.c (restore_pc_queue): Add pid to call to target_wait.
- * hppab-nat.c (child_resume): Handle default pid.
- * hppah-nat.c (child_resume): Handle default pid.
- * i386lynx-nat.c (child_wait): New arg pid.
- * inflow.c (kill_command): Reset thread list.
- * infptrace.c (child_resume): Handle default pid.
- * infrun.c: Thread-specific breakpoint support.
- * inftarg.c (child_wait): Add pid arg.
- * osfsolib.c (solib_create_inferior_hook): Add pid to call to
- target_resume.
- * procfs.c: Multi-thread support.
- * remote-bug.c (bug_wait): Add pid arg.
- * remote-hms.c (hms_wait): Add pid arg.
- * remote-mips.c (mips_wait): Add pid arg.
- * remote-mon.c (monitor_wait): Add pid arg.
- * remote-nindy.c (nindy_wait): Add pid arg.
- * remote-sim.c (gdbsim_wait): Add pid arg.
- * remote-udi.c (udi_wait): Add pid arg.
- * remote-vx.c (vx_wait): Add pid arg.
- * remote-z8k.c (sim_wait): Add pid arg.
- * remote.c (remote_wait): Add pid arg.
- * solib.c (solib_create_inferior_hook): Add pid to call to
- target_resume.
- * target.h (struct target_ops): Add pid arg to to_wait and
- to_notice_signals.
- * thread.c (valid_thread_id): New func to validate thread #s.
- * (pid_to_thread_id): New func to do the obvious.
- * thread.h: Prototypes for above.
-
- * coff-solib.c (coff_solib_add): Use nameoffset field to locate
- filename.
-
-Fri Oct 15 21:29:40 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * h8300-tdep.c, h8500-tdep.c: Define sim_load only, but not
- sim_kill, sim_open, or sim_set_args.
-
- * stack.c (print_stack_frame): Put catch_errors around
- print_frame_info so (for example) error printing source doesn't
- cause auto-displays to get skipped in normal_stop.
-
- * findvar.c (value_from_register): When preparing to cast a value
- from REGISTER_VIRTUAL_TYPE to type, copy the REGISTER_VIRTUAL_SIZE;
- the old code didn't copy the whole thing.
- * valops.c (value_assign): Add comment.
-
-Fri Oct 15 12:57:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (upgrade_type): Replace bitsize sanity checks and
- complaint by a comment explaining why they were useless.
-
-Fri Oct 15 14:30:30 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Move comments on bypassing call dummy breakpoint from stack.c
- to breakpoint.h.
-
-Fri Oct 15 11:52:56 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symtab.c (lookup_partial_symtab): If filename is not found and
- contains no slashes, try again and compare without leading path
- components.
- * symtab.c (lookup_symtab_1): Replace open coded version of
- lookup_partial_symtab with a function call.
-
-Thu Oct 14 20:34:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * fork-child.c (fork_inferior), remote-eb.c (eb_create_inferior),
- remote-mon.c (monitor_create_inferior), remote-nindy.c
- (nindy_create_inferior), remote-st.c (st2000_create_inferior),
- remote-vx.c (vx_create_inferior): Remove CREATE_INFERIOR_HOOK; it
- is replaced by init_trace_fun.
- * config/convex/xm-convex.h, convex-xdep.c: Add comments explaining
- how to do without CREATE_INFERIOR_HOOK for whoever fixes the Convex
- port.
-
- * Makefile.in: Add Mach files to ALLDEPFILES, etc.
- * m3-nat.c: Clean up more hair--message(), cprocs.
- * configure.in: Recognize Mach targets and hosts.
- * config/ns32k/tm-umax.h: Add some #ifndef's so tm-ns32km3.h can
- include this file.
- * Mach headers in config/*/tm-*.h: Fix includes to match correct
- locations of files.
-
-Thu Oct 14 21:35:55 1993 Rob Savoye (rob@darkstar.cygnus.com)
-
- * remote-mon.c (general_open): Set dev_name. Minor tweaking to get
- it working again.
- * config/m68k/tm-monitor.h: Remove floating point register names
- as there aren't any on any of the monitors that use this code.
-
-Wed Oct 13 11:47:23 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * inflow.c: Pass pointer to process group, not process group itself,
- to TIOCSPGRP ioctl.
-
- * inflow.c (terminal_ours_1): Don't print warning on failure to
- set process group.
-
- * printcmd.c (printf_command): Instead of using makeva* and
- calling vprintf, just make the appropriate calls to printf.
- * printcmd.c, config/pa/xm-pa.h, config/mips/xm-makeva.h,
- config/alpha/xm-alpha.h, config/m88k/xm-m88k.h: Remove all
- traces of makeva*. My apologies to everyone (including me!)
- who spent so much time getting it to work on various machines,
- but look at the bright side, at least you won't have to do it
- again in the future.
-
- * printcmd.c (printf_command): Make a cleanup for val_args (fixes
- a memory leak).
-
-Tue Oct 12 22:54:41 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/mips/xm-mips.h: Remove comment about HAVE_SGTTY vs. usleep.
-
-Tue Oct 12 12:01:29 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in: only configure gdbserver for native environments
-
-Tue Oct 12 08:59:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (read_type): Treat a negative type number at the start
- of a type as a type reference, not as a definition of a type with
- "50=" omitted. This makes things work on the RS/6000 again (the
- 14 Sep 1993 change broke it).
-
- * inflow.c: Use 0 (standard input) not scb->fd.
- (terminal_ours_1): If printing warning, don't claim it happened in
- terminal_inferior.
-
- * blockframe.c (get_prev_frame_info): Don't error() if there are no
- frames; just return NULL.
-
- * xcoffsolib.h, xcoffexec.c: Undo the part of Fred's bfd->abfd
- change which involved structure elements. It was unnecessary and
- was not consistently done.
-
- * stabsread.h, stabsread.c, dbxread.c (common_block*, copy_pending):
- Move common block handling from dbxread.c to stabsread.c.
- Use the name from the BCOMM instead of the ECOMM.
- Allocate things on the symbol_obstack.
- * xcoffread.c (process_xcoff_symbol): Process C_BCOMM, C_ECOMM,
- and C_ECOML. On unrecognized storage classes, go ahead and call
- define_symbol (after the complaint).
-
- * dbxread.c (process_one_symbol): Don't relocate 'S' symbols by
- the text offset.
-
-Tue Oct 12 12:33:09 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * osfsolib.c (solib_create_inferior_hook): Reset stop_soon_quietly
- after shared library symbol reading to get rid of warning from
- heuristic_proc_start.
-
-Tue Oct 12 12:01:29 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * remote-sim.c: fix unterminated character string
-
-Tue Oct 12 08:59:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c: Fix comment about gcc 2.3.3 stab for long long int.
-
-Mon Oct 11 14:27:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * m3-nat.c, config/nm-m3.h: Add a target_ops struct and other
- various things to try to get this to work.
-
- * symtab.h: Fix comments re headers, sharing blockvectors, etc.
-
-Mon Oct 11 11:46:06 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * config/i960/vxworks960.mt (REMOTE_O): add dcache.o and remote-utils.o
-
-Mon Oct 11 02:48:57 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (parse_partial_symbols): Do not add undefined
- symbols to the partial symbol table.
- * alpha-tdep.c (init_extra_frame_info): Remove kludge for gcc,
- gcc has to be compatible with the native tools.
- * alpha-tdep.c (alpha_push_arguments): Rename NUM_ARG_REGS to
- ALPHA_NUM_ARG_REGS and move its definition to tm-alpha.h.
- * config/alpha/tm-alpha.h (FRAME_ARGS_ADDRESS): Change it to the
- way the native tools define it, update comment.
-
-Fri Oct 8 15:54:06 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * osfsolib.c, remote-sim.c, remote.c, solib.c, xcoffexec.c,
- xcoffsolib.h: Use 'abfd' for bfd variables instead of 'bfd'.
- Sun cc doesn't like variable names that match their typedef'd type.
-
-Fri Oct 8 14:56:21 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * inflow.c: Remove unused includes of sys/param.h and sys/types.h.
-
- * inflow.c, ser-unix.c, ser-go32.c, ser-tcp.c, serial.h,
- terminal.h, fork-child.c, main.c, utils.c: Move all the process
- group stuff back to inflow.c and terminal.h; that's a better place
- for it and fixes problems with trying to get/set the process group
- of a tty we're doing remote debugging on.
- * terminal.h: Skip the redefines and includes if HAVE_TERMIOS.
-
- * findvar.c, value.h (symbol_read_needs_frame): New function.
- * c-exp.y, m2-exp.y: Call it instead of having our own switch on
- the symbol's class.
- * valops.c (value_of_variable): Use symbol_read_needs_frame to
- decide whether we care about finding a frame.
-
-Fri Oct 8 02:34:21 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * blockframe.c (get_frame_block): Do not adjust pc if the frame
- function was interrupted by a signal.
-
-Thu Oct 7 19:20:11 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/h8300/tm-h8300.h: Don't define sr_get_debug.
- * remote-sim.c: Include remote-utils.h.
- * target.h: Add comment about target_has_execution.
-
-Thu Oct 7 16:14:19 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
-
- * h8300-tdep.c (sim_load, sim_kill, sim_open, sim_set_args):
- New functions.
- * infrun.c (normal_stop): Don't try and set the pc in the current
- frame coredump if there isn't one.
- * remote-sim.c (gdbsim_store_register): Don't
- SWAP_TARGET_AND_HOST, sim_store_register takes bytes in raw order.
- (gdbsim_wait): Set status with WSETSTOP.
- * config/h8300/tm-h8300.h (sr_get_debug): Define
-
-Thu Oct 7 12:56:57 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- New Mach stuff:
- * config/i386/i386mach.c: Explain this is for the old (probably
- non-functional and/or obsolete) Mach stuff.
- * m3-nat.c, config/nm-m3.h,
- i386m3-nat.c, mipsm3-nat.c, ns32km3-nat.c,
- config/i386/{i386m3.mh,i386m3.mt,tm-i386m3.h,xm-i386m3.h},
- config/i386/{i386mk.mh,i386mk.mt,tm-i386mk.h,xm-i386mk.h},
- config/mips/{mipsm3.mh,mipsm3.mt,tm-mipsm3.h,xm-mipsm3.h},
- config/ns32k/{ns32km3.mh,ns32km3.mt,tm-ns32km3.h,xm-ns32km3.h}:
- New files.
-
- * blockframe.c (find_pc_partial_function): If we call
- PSYMTAB_TO_SYMTAB, call target_terminal_ours_for_output first.
- This is needed now that wait_for_inferior passes in endaddr.
- * infrun.c: Move call to target_terminal_inferior from proceed
- to resume.
-
-Thu Oct 7 09:22:04 1993 Stu Grossman (grossman at cygnus.com)
-
- * blockframe.c (find_pc_partial_function): Fix handling for PCs
- beyond the end of the last function in an objfile.
- * coff-solib.c (coff_solib_add): Use BFD to get fields from .lib
- section.
- * infrun.c (wait_for_inferior): Modify test for subroutine entry
- to include pc out of bounds of the previous function.
- * remote.c (remote_wait): Use strtoul for parsing 'N' message.
- Add code to relocate symfile_objfile->sections.
-
-Thu Oct 7 06:22:43 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/sparc/sun4os4.mh: Add comment saying why we don't use
- -lresolv.
-
-Thu Oct 7 09:29:11 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
- that clears the `inserted' flag for all breakpoints and deletes
- any breakpoints which should go away between runs of programs.
- * inflow.c (generic_mourn_inferior), infrun.c (init_wait_for_inferior),
- remote-es.c (es1800_load), comments in exec.c and corelow.c:
- Use it instead of mark_breakpoints_out.
- * breakpoint.c (mark_breakpoints_out): Update comment, tm-rs6000.h
- uses it in a completely different context.
- * breakpoint.c (breakpoint_re_set_one): Add bp_call_dummy case.
-
-Thu Oct 7 09:29:11 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * Makefile.in (REGEX, REGEX1): Always use our own version of
- regex.c to be consistent across hosts.
- * source.c (_initialize_source): Initialize regex to use grep
- style syntax as an approximation to POSIX basic regex syntax.
-
-Wed Oct 6 12:43:47 1993 Jeffrey A Law (law@snake.cs.utah.edu)
- Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * hppa-tdep.c (frame_chain): Rework so that it correctly
- handles boundaries where code with a frame pointer calls code
- without a frame pointer.
- (dig_fp_from_stack): New function.
-
-Wed Oct 6 12:43:47 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (delete_breakpoint): Don't insert a disabled breakpoint.
-
- * README: Add Alpha notes from Schauer.
-
-Tue Oct 5 15:26:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (install, uninstall): Remove $$n.1 stuff; I don't
- understand what it is trying to do, but I suspect it's not doing
- it.
-
- * config/ns32k/merlin.mh: Add comment about M_INSTALL.
- * config/m88k/{delta88.mh,delta88v4.mh}: Remove M_INSTALL and
- M_UNINSTALL; it tries to install a non-existent file gdb.z.
- * Makefile.in: Remove M_INSTALL stuff; the above were the only uses.
-
- * stabsread.c (read_range_type): Remove comment which recommends
- distinguishing float from complex by the name.
-
-Tue Oct 5 12:17:40 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
- Jim Kingdon (kingdon@cygnus.com)
- Stu Grossman (grossman@cygnus.com)
-
- Changes to support alpha OSF/1 in native mode.
- * alpha-nat.c, alpha-tdep.c, config/alpha/alpha-osf1.mt,
- config/alpha/nm-alpha.h, config/alpha/tm-alpha.h, osfsolib.c:
- New files.
- * Makefile.in: Add new files and dependencies.
- * configure.in: Add alpha target.
- * config/alpha/alpha-osf1.mh (NATDEPFILES): Add osfsolib.o
- * config/alpha/alpha-osf1.mh (MH_CFLAGS): Remove, we can handle
- shared libraries now.
- * config/alpha/xm-alpha.h: Cleanup, get MAKEVA_* defines right.
-
- * defs.h (CORE_ADDR): Make its type overridable via CORE_ADDR_TYPE,
- provide `unsigned int' default.
- * breakpoint.c (breakpoint_auto_delete): Delete only if we really
- stopped for the breakpoint.
- * stabsread.c, stabsread.h (define_symbol): Change valu parameter
- to a CORE_ADDR.
- * stabsread.c (read_range_type): Handle the case where the lower
- bound overflows and the upper doesn't and the range is legal.
- * infrun.c (resume): Do not step a breakpoint instruction if
- CANNOT_STEP_BREAKPOINT is defined.
-
- * inferior.h (CALL_DUMMY_LOCATION): New variant AT_ENTRY_POINT.
- Now that we have the bp_call_dummy breakpoint the call dummy code
- is no longer needed. PUSH_DUMMY_FRAME, PUSH_ARGUMENTS and
- FIX_CALL_DUMMY can be used to set up everything for the dummy.
- The breakpoint for the dummy is set at the entry point and thats it.
- * blockframe.c (inside_entry_file, inside_entry_func): Do not stop
- backtraces if pc is in the call dummy at the entry point.
- * infcmd.c (run_stack_dummy): Handle AT_ENTRY_POINT case. Use
- the expected breakpoint pc when setting up the frame for
- set_momentary_breakpoint.
- * symfile.c (entry_point_address): New function for AT_ENTRY_POINT
- support.
- * valops.c (call_function_by_hand): Handle AT_ENTRY_POINT case.
-
-Tue Oct 5 11:37:02 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in: Recognize hppa*-*-hiux* (currently synonym for hpux).
- Change other hppa host entries to use -*- not -hp-.
-
-Mon Oct 4 19:16:14 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * i386-nlmstub.c: New file; debugging stub for i386 NetWare. Must
- be compiled with NetWare header files and turned into an NLM with
- nlmconv.
-
-Mon Oct 4 11:02:11 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * minsyms.c (lookup_minimal_symbol_by_pc): Don't use mst_abs symbols.
-
- * dbxread.c (process_one_symbol): Make n_opt_found static.
-
- * Rename i386lynx-tdep.c to i386ly-tdep.c for 14 character file names.
- * Makefile.in, config/i386/i386lynx.mt: Change accordingly.
-
- * values.c (record_latest_value): Fetch lazy values and set VALUE_LVAL
- to not_lval.
-
-Sun Oct 3 15:54:51 1993 Stan Shebs (shebs@rtl.cygnus.com)
-
- * objfiles.h (objfile): New slot sym_stab_info, use by most
- stab-reading formats.
- * gdb-stabs.h (DBX_SYMFILE_INFO): Access sym_stab_info instead of
- sym_private.
- * coffread.c (coff_symfile_init): Alloc struct for sym_stab_info.
- * dbxread.c, elfread.c, paread.c: Change sym_private references to
- sym_stab_info references.
-
-Sat Oct 2 19:28:35 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * mipsread.c, objfiles.c, utils.c: Use PTR not void *. RISC/OS
- 4.02 lacks void *.
- * elfread.c: Use void * not PTR inside PARAMS.
-
- * config/mips/news-mips.mh: Remove coredep.o; mips-nat.o does it.
- * config/mips/news-mips.mh: Define NAT_FILE not NM_FILE.
- * config/mips/nm-news-mips.h: Include mips/nm-mips.h not nm-mips.h.
-
-Sat Oct 2 16:05:22 1993 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in, coff-solib.c, coff-solib.h, i386lynx.mt,
- tm-i386lynx.h: Add support for SVR3 COFF shared libraries.
-
-Sat Oct 2 15:50:41 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * m88k-nat.c (store_inferior_registers): When writing all registers,
- don't try to write EXIP_REGNUM or ENIP_REGNUM (not needed for this
- case, and they cause trouble).
-
- * TODO: Don't suggest doing fast watchpoints by stepping a line
- at a time. That would be really hairy and still not fast enough.
- Do suggest debug registers and page table diddling.
-
-Fri Oct 1 14:54:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (do_examine): Make meaning of 'h', 'w', and 'g' not
- depend on builtin_type_*. Instead, it is always 2, 4, and 8 bytes
- like the documentation says.
- * printcmd.c (decode_format) [CC_HAS_LONG_LONG]: Remove 'l' as
- synonym for 'g'. This was never documented, it shouldn't depend on
- CC_HAS_LONG_LONG, and I don't see what's wrong with 'g'.
-
-Fri Oct 1 10:06:35 1993 Kung Hsu (kung@cirdan.cygnus.com)
-
- * symtab.c: fix a bug in testsuite (virtfunc.exp)
-
-Thu Sep 30 11:30:56 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * m88k-nat.c (fill_gregset): Fix typo (R_SFIP -> R_FIP).
-
- * c-typeprint.c (c_type_print_base, TYPE_FN_FIELD_STUB code):
- If demangled name lacks a colon, don't dump core.
-
- * blockframe.c (find_pc_partial_function): If pst->readin is
- set, don't try to get symbols from pst.
-
- * inflow.c (generic_mourn_inferior): Call reinit_frame_cache
- instead of doing it ourself.
- * blockframe.c (reinit_frame_cache): Use code which was in
- generic_mourn_inferior so we can use this function even when
- we have switched targets.
- * corelow.c (core_detach): Call reinit_frame_cache.
- * target.c (target_detach): Don't call generic_mourn_inferior
- (revert yesterday's change, now handled by core_detach).
- * objfiles.c (free_objfile): Detach any core file if we call
- SOLIB_CLEAR. #include target.h.
-
- * fork-child.c (fork_inferior): Don't call target_terminal_init
- and target_terminal_inferior until we are sure that the inferior
- has called gdb_setpgid. This fixes PR 2900 (Schauer tracked it
- down and was able to reliably reproduce it by putting a sleep()
- before the gdb_setpgid()).
-
-Thu Sep 30 12:00:49 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * c-exp.y, m2-exp.y: Change type of address for msymbol to
- builtin_type_long.
- * infptrace.c (fetch_register, store_inferior_register,
- child_xfer_memory): Use PTRACE_XFER_TYPE for the type of ptrace
- transfers. Provide an `int' default for PTRACE_XFER_TYPE.
-
-Thu Sep 30 11:30:56 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * defs.h (TARGET_*_BIT): Don't use host information (sizeof) in
- picking defaults.
-
- * cp-valprint.c (cp_is_vtbl_ptr_type): Continue to accept old form.
-
-Thu Sep 30 11:25:55 1993 Kung Hsu (kung@cygnus.com)
-
- * cp-valprint.c (cp_is_vtbl_ptr_type):
- change vtable field name to __vtbl (pr2695).
-
- * symtab.c (gdb_mangle_name): fix a bug, to get mangled name right.
-
-Wed Sep 29 18:34:22 1993 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in: Add deps for i386lynx-nat.o and i386lynx-tdep.o to
- keep non-gnu makes happy.
-
-Wed Sep 29 17:20:54 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (read_hpux_symtab): When a K_END is found for a
- K_MODULE, clear the have_module and have_name flags.
-
-Wed Sep 29 10:52:19 1993 Kung Hsu (kung@cygnus.com)
-
- * c-valprint.c: to fix virtual table print bug (pr2695).
-
-Wed Sep 29 10:52:19 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * target.c (target_detach): Call generic_mourn_inferior.
- * inflow.c (generic_mourn_inferior): Call flush_cached_frames.
-
-Tue Sep 28 23:08:59 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dbxread.c, coffread.c, elfread.c: A few changes to comments.
-
-Tue Sep 28 18:39:37 1993 Stan Shebs (shebs@rtl.cygnus.com)
-
- * configure.in: Rename ...-lynx* to ...-lynxos*.
- Add m68*-*-lynxos* configuration.
- * dbxread.c (coffstab_build_psymtabs): New function,
- interfaces coffread.c to dbxread functions.
- * coffread.c (coff_symfile_info): Expand to include
- dbx_symfile_info slots.
- (coff_symfile_init): Init coff_symfile_info struct.
- (coff_locate_sections): New functions, finds the stab and stabstr
- sections.
- (coff_symfile_read): Call coffstab_build_psymtabs if a stab
- section is present.
- (coff_section_offsets): Replace fake version with real offsets.
-
-Tue Sep 28 18:00:50 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infcmd.c (run_stack_dummy): Set the frame in the bp_call_dummy
- breakpoint.
-
-Tue Sep 28 17:53:26 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * config/nm-sysv4.h: Include solib.h. Define SVR4_SHARED_LIBS.
- * config/tm-sysv4.h: Don't include solib.h.
- * config/xm-sysv4.h: Don't define SVR4_SHARED_LIBS.
- * config/i386/i386v4.mt (TDEPFILES): Move solib.o from here...
- * config/i386/i386v4.mh (NATDEPFILES): ...to here.
- * config/i386/nm-i386v4.h: Include nm-sysv4.h.
- * config/m68k/amix.mt (TDEPFILES): Move solib.o from here...
- * config/m68k/amix.mh (NATDEPFILES): ...to here.
-
-Tue Sep 28 09:45:38 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symmisc.c (print_symbol): Use %02x not %2x for LOC_CONST_BYTES.
-
- Clean up problems with targets and hosts that have 64 bit longs
- and pointers and 32 bit ints.
- * breakpoint.c, buildsym.c, c-lang.c, c-valprint.c, ch-lang.c,
- ch-valprint.c, core.c, cp-valprint.c, dbxread.c, exec.c,
- expprint.c, gdbtypes.c, infcmd.c, language.c, language.h,
- m2-lang.c, maint.c, mips-tdep.c, mipsread.c, partial-stab.h,
- printcmd.c, remote-vx.c, solib.c, source.c, stack.c, symfile.c,
- symmisc.c, symtab.c, valops.c, valprint.c, xcoffexec.c:
- Change all printf formats from %x to %lx if outputting an address.
- Change la_*_format to use long format.
- local_hex_string, local_hex_string_custom now take an unsigned long
- argument, change all callers.
- * coffread.c (read_coff_symtab): Remove superfluous cast for
- complaint output.
- * dbxread.c (end_psymtab): Cast MSYMBOL_INFO to long, not int.
- * findvar.c, value.h (write_register): Change val to LONGEST.
- * gdbtypes.h (struct type): Change `bitsize' to long as
- TYPE_FIELD_STATIC_PHYSNAME uses this field as a pointer.
- * inferior.h (struct inferior_status): Change type of stop_pc to
- CORE_ADDR.
- * language.h (local_octal_string, local_octal_string_custom):
- Remove prototype, the functions are neither defined nor used.
- * mipsread.c (parse_symbol): Use temporary variable for bitsize as
- f->bitsize is a long now.
- * objfiles.c (add_to_objfile_sections, build_objfile_section_table):
- Use unsigned long casts instead of int for abusing sections_end
- pointer as integer.
- * stack.c (parse_frame_specification): Change type of `args' to
- CORE_ADDR for SETUP_ARBITRARY_FRAME.
-
- * printcmd.c (make_vasize): Allow redefinition via MAKEVA_SIZE.
- * mipsread.c (parse_type): Alpha cc now supports the t->continued
- bit, update algorithm to match the way the compiler uses it.
-
-Tue Sep 28 12:05:11 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * utils.c (fprintfi_filtered): Fix comments.
-
-Mon Sep 27 18:10:08 1993 Stu Grossman (grossman at cygnus.com)
-
- * coffread.c (read_coff_symtab): Don't call getfilename if there
- are no auxents.
-
-Mon Sep 27 10:22:37 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.c (find_pc_line): Fix comments.
-
- * remote-udi.c (udi_mourn): Don't pop target.
-
-Fri Sep 24 17:25:41 1993 Stu Grossman (grossman at cygnus.com)
-
- * corelow.c: Add multi thread/process support for core files with
- .reg/XXX pseudo-sections.
- * i386lynx-nat.c thread.h thread.c: Remove unnecessary core file
- support.
-
-Thu Sep 23 10:49:37 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-udi.c (download): Skip zero length sections.
-
- * valops.c (search_struct_method, value_struct_elt):
- Use (value)-1, not -1, for error.
-
- * infcmd.c (step_1), infrun.c (wait_for_inferior): Add comments
- about SHIFT_INST_REGS.
-
- * exec.c (exec_file_command): Set text_end based on all code readonly
- sections, not just ".text".
-
- * defs.h, infcmd.c, config/z8k/tm-z8k.h, config/m88k/tm-m88k.h,
- config/sh/tm-sh.h, config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
- z8k-tdep.c: Remove all references to ADDR_BITS_SET.
- * config/m88k/tm-m88k.h: Define TARGET_WRITE_PC.
-
- * config/m88k/tm-m88k.h, m88k-tdep.c: Add call function stuff.
-
-Thu Sep 23 00:13:06 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/mips/tm-mips.h (STORE_STRUCT_RETURN): Define as noop as
- the pushing of the struct return address is already handled in
- mips_push_arguments.
- * mips-tdep.c (reinit_frame_cache_sfunc): Fix typo in prototype
- declaration.
- * mipsread.c (parse_symbol, parse_type, upgrade_type): Add more
- sanity checks for corrupt symbol entries to avoid core dumps
- reported by benson@odi.com. Obviously Ultrix 4.3A cc now has
- the same problems as the OSF/1 alpha cc.
- * mipsread.c (parse_lines): Iterate over the range of the compressed
- line number entries, the old iteration sometimes failed to stop
- and wrote past the end of the LINETABLE. Add sanity check to avoid
- the same problem in case the line number info is corrupt.
- * mipsread.c (parse_procedure): Adjust pdr for alpha __sigtramp.
- * mipsread.c (parse_external, parse_partial_symbols): Ignore stNil
- symbols that are produced for statics in .o files and stLocal symbols
- that are produced for every section in OSF/1 dynamically linked
- executables.
- * mipsread.c (psymtab_to_symtab_1): Put out `undefined symbols'
- warning only under `verbose on' as there are many undefined symbols
- in a dynamically linked executable.
-
-Wed Sep 22 10:28:06 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/i960/nindy960.mt: Don't define REMOTE_O; REMOTE_O was
- intended only for VxWorks. Remove dcache.o from TDEPFILES now
- that we pick it up from the default REMOTE_O.
-
- * breakpoint.c (bpstat_what): Initialize retval.call_dummy and
- retval.step_resume.
-
- * mips-tdep.c (mips_frame_chain): If frame size zero, return zero.
- * rs6000-tdep.c: Add comment about framelessness.
-
- * remote-nindy.c: Declare ninMemGet and ninMemPut.
-
-Wed Sep 22 08:02:57 1993 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in: Add i386lynx-tdep to the right places.
- (TARDIRS): Add gdbserver.
-
- * exec.c (print_section_info): Print entry point.
- * i386lynx-nat.c (i386lynx_saved_pc_after_call): Move into
- i386lynx-tdep.c. Add core file support.
- * i386lynx-tdep.c: New module for Lynx/386 target dependant code.
- * maint.c: Add `maint info sections' command to print info about all
- sections that BFD knows about for exec and core files.
- * sparc-tdep.c (sparc_push_dummy_frame): Update stack pointer
- before putting frame on the stack. Consolidate writes to reduce
- traffic for remote debugging.
- * config/i386/i386lynx.mh (NATDEPFILES): Remove exec.o.
- * config/i386/i386lynx.mt (TDEPFILES): Add exec.o, i386lynx-tdep.o.
- * config/i386/nm-i386lynx.h: Add target_pid_to_str().
- * config/i386/tm-i386lynx.h: Remove target_pid_to_str().
- * sparclite/Makefile.in: Add deps to keep Sun make happy.
-
-Tue Sep 21 17:48:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.h, breakpoint.c (bpstat_stop_status): Add new argument
- not_a_breakpoint.
- * infrun.c (wait_for_inferior): Pass it. Also consolidate the
- test of whether we are stepping into a CURRENTLY_STEPPING macro.
-
-Tue Sep 21 17:22:34 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * breakpoint.c (bpstat_stop_status),
- infcmd.c (step_1),
- infrun.c (wait_for_inferior): collapse SHIFT_INST_REGS ifdef
- and insert macro.
-
- * m88k-tdep.c: include ieee-float.h. new global target_is_m88110.
- new const struct ext_format_m88110 for float format.
- (pic_prologue_code): add braces.
- (next_insn): remove unused variable buf.
- (frame_find_saved_regs): remove unused variables next_addr,
- saved_regs, regnum.
- (frame_locals_address): remove unused variables frame, ap.
- (frame_args_address): remove unused variables frame, ap.
- (push_parameters): add some breaks and a default case.
-
- * remote-bug.c: remove redundant includes of value.h, target.h,
- serial.h.
- (bug_open): corrected typo, sr_multi_scan -> gr_multi_scan.
- (bug_fetch_register): special case sfip register for m88110.
- remove flag bit masking of pc registers. This should be handled
- by the ADDR_BITS_* macros.
- (bug_store_register): special case sfip register for m88110.
- Corrected sprint format for extended registers.
-
- * config/m88k/tm-m88k.h: white space and comment changes. include
- ieee-float.h. expanded to cope with m88110 extended registers.
- (R0_REGNUM, XFP_REGNUM, X0_REGNUM): new macros.
- (SHIFT_INST_REGS): becomes a real macro.
-
-Tue Sep 21 17:48:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (breakpoint_1): Support bp_call_dummy.
-
-Tue Sep 21 17:06:19 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * elfread.c (record_minimal_symbol_and_info): Guess the section to
- use from the type.
- * objfiles.c: Include gdb-stabs.h for SECT_* macros.
- (objfile_relocate): Relocate textlow and texthigh in psymtabs.
- Relocate partial symbols. Check that minimal SYMBOL_SECTION is
- nonnegative before using it.
- * symtab.h: Adjust section field comment.
-
- * remote.c (interrupt_query): New function.
- (remote_interrupt_twice): Call interrupt_query.
- (putpkt, getpkt): If quit_flag is set, call interrupt_query.
- (remote_wait): Don't bother with objfile_relocate if the addresses
- haven't changed.
- (remote_fetch_registers): If we see a packet that doesn't start
- with a hex character, fetch a new one.
-
-Tue Sep 21 11:44:00 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote.c, remote-utils.c: Use SERIAL_FLUSH_INPUT after opening it.
-
- * printcmd.c (print_scalar_formatted): When truncating value we are
- going to print as unsigned, handle it generally for any length
- less than sizeof (LONGEST), rather than special-casing sizeof (char),
- sizeof (short), and sizeof (long). Clarify comment on what this
- is for.
-
- * symfile.c (deduce_language_from_filename): Accept .cxx for C++.
- * buildsym.c (start_subfile): Use deduce_language_from_filename
- rather than checking for .C or .cc ourself.
-
-Mon Sep 20 14:53:11 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * defs.h: Declare argument of re_comp as const char *.
-
- * remote.c, remote-mips.c: Use sr_get_debug not remote_debug.
-
- * README: Say using bfd from another release doesn't generally work.
-
-Sat Sep 18 10:13:18 1993 Jim Kingdon (kingdon@poseidon.cygnus.com)
-
- * mipsread.c (parse_type): Don't complain() if we guessed struct
- and it was a union, or vice versa.
-
- * defs.h (make_cleanup): Change PTR to void * when inside PARAMS.
-
- Some of the following is in #ifdef CALL_DUMMY_BREAKPOINT_OFFSET.
- * breakpoint.h (enum bptype): Add bp_call_dummy.
- (struct bpstat_what): Add call_dummy field.
- * infrun.c (wait_for_inferior): Deal with it.
- * breakpoint.c (bpstat_what): Deal with call dummy breakpoint.
- * infcmd.c (run_stack_dummy): Set the call dummy breakpoint.
- * config/sparc/tm-sparc.h: Define CALL_DUMMY_BREAKPOINT_OFFSET.
-
- * remote-sim.h: New file.
- * remote-sim.c: Add remote debug feature. Rename stuff to distinguish
- interface to simulator from gdb-specific stuff. Other changes.
- * remote-sp64sim.c: Renamed to remote-sim.c.
- Use sr_get_debug instead of our own sim_verbose/simif_snoop.
- Use gnutarget in call to bfd_openr.
- Rename simif_* to gdbsim_*.
- * config/sparc/sp64sim.mt: Change remote-sp64sim.c to remote-sim.c.
-
-Fri Sep 17 04:41:17 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * findvar.c (extract_signed_integer): Cast *p to LONGEST before doing
- the xor and subtract. Otherwise it will not sign extend if the type
- of LONGEST is larger than int.
- * cp-valprint.c (cp_print_class_method): Inhibit core dump if
- domain is an undefined cross reference.
- * valops.c (call_function_by_hand): Set real_pc to correct
- value if CALL_DUMMY_LOCATION != ON_STACK.
-
-Thu Sep 16 20:37:06 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
-
- * config/a29k/tm-a29k.h (FRAME_CHAIN): If rsize is zero, return zero.
-
-Thu Sep 16 13:16:22 1993 Stu Grossman (grossman at cygnus.com)
-
- * infrun.c (wait_for_inferior): Allow user to single step within
- a stack dummy.
-
-Thu Sep 16 12:34:01 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
-
- * dbxread.c (copy_pending): Deal with END NULL.
- (process_one_symbol): Add comments about what common_block NULL means.
-
-Wed Sep 15 14:50:26 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
-
- * remote-udi.c, remote-adapt.c, remote-mm.c: Move processor_type
- to tm-a29k.h and a29k-tdep.c and make it an enum.
- * a29k-tdep.c (a29k_get_processor_type): New function. Fix many
- aspects of how we detected the processor type.
- * remote-udi.c, remote-adapt.c, remote-mm.c (*_open): Call it
- rather than figuring out the type ourselves.
-
-Thu Sep 16 12:12:59 1993 Stu Grossman (grossman at cygnus.com)
-
- * sparc-stub.c (_trap_low): Do restore/save sequence after
- setting sp to ensure that we load the previous window from the
- right place on the stack.
-
-Thu Sep 16 00:36:32 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c: Many changes for alpha ecoff format:
- Correct sizeof(int) == sizeof(long) assumptions.
- Replace stParsed hack by putting the parsed types on the pending chain.
- Replace mips specific ecoff mapping by ECOFF_REG_TO_REGNUM macro,
- provide default for cross debugging.
- Swapping the symbol back is no longer needed as the symbol is not
- modified anymore.
- Add new alpha basic types, handle btTypedef, handle stStaticProc
- external symbols .
- Update and clean up cross_ref for alpha cc cross ref variations.
- Allocate types on the type_obstack to inhibit storage leaks.
- * config/mips/tm-mips.h (ECOFF_REG_TO_REGNUM): Define.
- * gdbtypes.c (recursive_dump_type): Dump TYPE_TAG_NAME if it is set.
-
-Tue Sep 14 09:12:17 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
-
- * stabsread.c (read_type): Process "s" (size) type attribute.
- If type is defined to another type, copy the type.
-
-Tue Sep 14 18:37:17 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * config/i386/i386v4.mh (NATDEPFILES): Move exec.o from here...
- * config/i386/i386v4.mt (TDEPFILES): ...to here.
-
-Tue Sep 14 12:21:49 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * Makefile.in (remote_utils_h): add serial.h and target.h.
- (main.o, remote-es.o, remote-nindy.o, remote.o): remove target.h
- (already in remote_utils_h).
- (remote-utils.o): new rule.
-
- * remote-utils.h: include serial.h.
-
- * serial.h: ifdef protect from multiple inclusion.
-
- * remote.c, remote-nindy.c, remote-mon.c, remote-es.c: include
- remote-utils.h.
-
- * remote.c (remote_open), remote-nindy.c (nindy_open,
- nindy_files_info), remote-mon.c (general_open), remote-es.c
- (es1800_open): use remote-utils facilities for baud rate.
-
-Tue Sep 14 09:12:17 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
-
- * paread.c, coffread.c, elfread.c, dwarfread.c:
- Include <time.h> and <sys/types.h> before libbfd.h.
-
- * paread.c: Define BYTES_IN_WORD before including aout/aout64.h.
-
- * Makefile.in (a29k-tdep.o): Depend on $(defs_h).
- * config/a29k/tm-a29k.h (SAVED_PC_AFTER_CALL): Use gr122 not lr0
- if this is a transparent procedure.
-
-Mon Sep 13 16:06:43 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
-
- * remote.c: Define remote_debug to 0 and #if 0 baud_rate. Temporary
- hack so this file compiles again.
-
- * remote-utils.c (gr_multi_scan): Cast return value from alloca.
- (gr_multi_scan): #if 0 never-reached return(-1).
-
- * remote-udi.c (udi_wait): Return inferior_pid not 0.
-
-Mon Sep 13 14:14:35 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- Collect some remote things into remote-utils.
- * remote-utils.[ch]: new files of functions collected from several
- different remote targets.
- * Makefile.in (REMOTE_O): add remote-utils.o.
- (dcache_h, remote_utils_h): new macros.
- (HFILES): add $(remote_utils_h).
- (ALLDEPFILES): add $(remote_utils_h).
- (dcache.o): new rule.
- (main.o, remote-bug.o): also depend on $(remote_utils_h).
- * target.h (remote_debug): extern moved to remote-utils.h.
- * target.c (find_default_run_target, find_core_target): initialize
- runable.
- (remote_debug): moved to remote-utils.c.
- (_initialize_targets): move declaration of user variable
- remotedebug to remote-utils.c.
- * remote-bug.c: include remote-utils.h rather than dcache.h.
- (bug_close, bug_write, bug_write_cr, desc, bug_dcache, timeout,
- dev_name, check_open, is_open, readchar, readchar_nofail,
- pollchar, expect, expect_prompt, get_hex_digit, get_hex_byte,
- get_hex_word, bug_kill, bug_detach, bug_create_inferior,
- multi-scan, bug_prepare_to_store, bug_fetch_word,
- bug_store_word, bug_files_info, bug_mourn, bug_com, bug_device,
- bug_speed): removed and replaced with facilities from
- remote-utils.[ch].
- (bug_read_inferior_memory): renamed to bug_read_memory.
- (bug_write_inferior_memory): renamed to bug_write_memory.
- (bug_xfer_inferior_memory): renamed to bug_xfer_memory.
- (get_word): comment out this unused function for now.
- (bug_settings, cpu_check_strings): new statics.
- (bug_open): rewritten to use gr_open.
- (_initialize_remote_bug): remove declarations of commands bug,
- device, speed.
- * main.c: include remote-utils.h.
- (baud_rate): removed to remote-utils.c.
- (main): handle baud rate settings using new facilities from
- remote-utils.
- * defs.h (baud_rate): removed extern.
-
- m88110 support via bug-197 monitor.
- * remote-bug.c (get_reg_name, bug_fetch_register,
- bug_store_register): added m88110 extended register support.
- (wait_strings): added bug-197 prompt.
- (bug_wait): cope with bug-197 prompt.
- (start_load): cope with either bug-197 or bug-187 prompt.
-
-Mon Sep 13 12:53:09 1993 Jim Kingdon (kingdon@cirdan.cygnus.com)
-
- * inferior.h, infrun.c, thread.c, infcmd.c: Remove all uses of
- pc_changed. If it was ever set to a non-zero value, it was before
- GDB 2.8. It doesn't seem to have any useful function.
-
- * defs.h: Don't define NORETURN (see comment).
-
-Sat Sep 11 10:46:09 1993 Jim Kingdon (kingdon@poseidon.cygnus.com)
-
- * m88k-nat.c (fill_gregset): Set r31 and sfip.
-
-Thu Sep 9 10:18:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-udi.c (udi_wait, case UDIStdinNeeded): Use a loop calling
- getchar() (terminated only on '\n') instead of scanf. Send the
- '\n' which terminates it to the remote system.
-
- More gcc lint:
- * exec.c (ignore): Return 0.
- * stack.c (return_command): Fetch lazy value directly, not via
- VALUE_CONTENTS, to avoid "value computed is not used".
- * inflow.c (new_tty): Move osigttou inside #if.
-
- * remote.c (remote_fetch_registers): If remote reply is short, just
- note that fact and keep going (reading extra registers as all bits 0).
- (remote_store_registers): Send number of registers that were found
- by remote_fetch_registers.
- * m68k-tdep.c, config/m68k/tm-m68k.h, config/m68k/tm-*.h: Remove
- HAVE_68881. Define CANNOT_STORE_REGISTER if ptrace() can't write
- floating registers.
- * config/m68k/{tm-m68k-nofp.h,m68k-nofp.mt,tm-m68k-fp.h,m68k-fp.mt}:
- Remove, replaced by {tm-m68k-em.h,m68k-em.mt}.
- * Makefile.in, configure.in: Change accordingly.
-
-Thu Sep 9 04:59:03 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (cross_ref): Allow SGI extended symbol types as cross
- reference targets.
- * symmisc.c (print_symbol): Use TYPE_TAG_NAME not TYPE_NAME to avoid
- printing of identities.
-
-Wed Sep 8 19:18:27 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (breakpoint_1): Deal with step resume breakpoint.
-
-Wed Sep 8 13:01:10 1993 K. Richard Pixley (rich@cygnus.com)
-
- Gcc lint.
- * config/m88k/tm-m88k.h (frame_find_saved_regs): prototype.
- * config/h8300/tm-h8300.h (NUM_REGS): rewrite to avoid nested comment.
- * blockframe.c (get_prev_frame_info): initialize address.
- * breakpoint.c (bpstat_copy): initialize retval.
- (bpstat_stop_status): initialize value_is_zero.
- (bpstat_what): initialize bs_class.
- (breakpoint_1, mention): add do-nothing case for bp_step_resume.
- (break_command_1): initialize cond_end, addr_end, &
- canonical_strings_chain.
- (enable_breakpoint): initialize save_selected_frame.
- * buildsym.c (end_symtab): initialize symtab & linetablesize.
- * c-exp.y (parse_number): initialize i.
- * c-typeprint.c (c_type_print_varspec_prefix): include
- TYPE_CODE_BITSTRING in switch statements and do nothing.
- * c-valprint.c (c_val_print): removed unused variable c.
- * ch-valprint.c (chill_val_print): removed unused variable eltlen.
- * cp-valprint.c (cp_print_class_method): initialize f & j.
- * eval.c (evaluate_subexp): initialize pc2, arg1, arg2.
- * expprint.c (print_subexp): initialize myprec, assoc, & tempstr.
- * findvar.c (value_from_register): initialize first_addr.
- * gdbtypes.c (lookup_struct_elt_type): localize use of temporary
- variable typename.
- * infcmd.c (run_stack_dummy): return zero rather than simple
- return.
- * infrun.c (wait_for_inferior): initialize stop_sp, prologue_pc.
- remove symtab, appears unused.
- (restore_selected_frame): return 1.
- * mipsread.c (psymtab_to_symtab_1): initialize first_off.
- (fixup_sigtramp): initialize b0.
- * printcmd.c (do_examine): initialize val_type.
- (print_frame_args): initialize b.
- * ser-tcp.c (tcp_restore): comment out declaration. Appears
- unused.
- * ser-unix.c (hardwire_restore): comment out declaration. Appears
- unused.
- (hardwire_send_break): moved variable status into ifdef
- HAVE_SGTTY.
- (wait_for): moved variable numfds into ifdef HAVE_SGTTY.
- * serial.h: comment change only.
- * stabsread.c (rs6000_builtin_type): initialize rettype.
- (read_range_type): initialize nbits.
- * stack.c (print_frame_info): remove unused variable numargs.
- (parse_frame_specification): remove unused variables arg1, arg2,
- arg3.
- (return_command): initialize return_value.
- * symfile.c (cashier_psymtab): initialize pprev.
- * symtab.c (find_pc_psymbol): initialize best.
- (lookup_symbol): initialize s.
- (make_symbol_completion_list): initialize quote_pos.
- * thread.c: include command.h.
- (thread_info): static declaration removed; unused.
- (info_threads_command): fix == vs = typo.
- * typeprint.c (whatis_exp): initialize old_chain.
- * valprint.c (val_print_string): remove unused variable
- first_addr_err. Initialize old_chain.
- (_initialize_valprint): white space comment change.
- * values.c (show_values): rewrite if statement to avoid empty
- body.
- (vb_match): remove unused variable fieldtype_target_type.
-
-Wed Sep 8 10:21:33 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (mipsread.o): Depend on $(bfd_h).
-
-Tue Sep 7 13:06:44 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbserver/Makefile.in (TAGS): config files are in
- $(srcdir)/../config, not $(srcdir)/config.
-
- * config/pa/tm-hppa.h: Declare target_read_pc and target_write_pc.
- (STORE_RETURN_VALUE): Pass the correct offset of the return
- register to write_register_bytes.
- * hppa-tdep.c: Use target_write_pc if PCOQ_TAIL_REGNUM was not saved.
-
-Tue Sep 7 14:30:34 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * remote.c (remote_wait): Don't call error. Instead, call warning
- inside a loop. User can ^C to get out.
-
- * config/m68k/tm-m68k.h (FIX_CALL_DUMMY): Changed name of swapping
- routine to match BFD name change.
- * config/z8k/tm-z8k.h (FIX_CALL_DUMMY): Likewise.
-
-Mon Sep 6 15:01:57 1993 Jeffrey Wheat (cassidy@cygnus.com)
-
- * elfread.c: change elf32_symbol_type to elf_symbol_type
-
-Mon Sep 6 15:43:25 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * remote.c (remote_wait): Added 'W' and 'N' responses.
-
-Fri Sep 3 08:57:10 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c, utils.c: Add comments about immediate_quit.
-
- * elfread.c (elf_symtab_read): Don't add symbols starting with ".L"
- to minimal symbols.
-
- * target.c (pop_target): Don't try to deal with the stack becoming
- empty. Shouldn't happen and the code that tried was broken.
-
- * dcache.c: Cast return value from xmalloc.
-
- * remote.c: Move setting of immediate_quit from remote_open to
- remote_start_dummy and set it back to zero when done.
-
-Thu Sep 2 00:07:36 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * m88k-tdep.c: Remove a bunch of unused #includes.
-
- * language.h: Add comment about current_language.
-
- * mips-tdep.c (_initialize_mips_tdep): Change heuristic-fence-post
- from var_uinteger to var_zinteger.
-
- * configure.in: Fix typo (delta88r4 -> delta88v4).
-
- * config/m88k/xm-delta88.h: Don't include sys/siginfo.h. It was
- to make this work on SVR4 before SVR4 had its own configuration,
- and it breaks SVR3.
-
- * config/m88k/tm-delta88v4.h: Define FRAME_CHAIN_VALID_ALTERNATE.
-
- * config/m88k/delta88v4.h (NATDEPFILES): Remove infptrace.o inftarg.o.
-
- * config/m88k/xm-dgux.h: Renamed from config/m88k/xm-m88k.h.
- * config/m88k/m88k.mh: Use xm-dgux.h.
- * config/m88k/xm-m88k.h: New file, with HOST_BYTE_ORDER,
- MAKEVA_END and MAKEVA_ARG.
- * config/m88k/xm-*.h: Include m88k/xm-m88k.h.
- * printcmd.c: Remove __INT_VARARGS_H code; now in xm-m88k.h.
-
-Wed Sep 1 19:31:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-udi.c (udi_wait): Call `warning' not `error'.
-
- * symtab.c (COMPLETION_LIST_ADD_SYMBOL): If the symbol has a
- demangling, don't put the mangled form in the completion list.
-
- * symtab.c, symfile.c, c-exp.y, ch-exp.y, m2-exp.y, buildsym.c,
- symfile.h, stabsread.c, minsyms.c, solib.c, nlmread.c, dwarfread.c
- partial-stab.h, symmisc.c, gdbtypes.c: Lint. Remove (or put
- inside #if) unused variables and labels. Fix unclosed comment.
- Deal with enumeration values unhandled in switch statements. Make
- sure non-void functions return values. Include appropriate
- headers.
- * dbxread.c (elfstab_build_psymtabs): Don't check for unsigned
- value < 0.
-
-Wed Sep 1 14:36:00 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * i960-tdep.c, ns32k-pinsn.c, remote-adapt.c, xcoffread.c:
- index -> strchr.
-
-Wed Sep 1 11:35:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote.c: Add comment explaining why dcache is disabled.
- (remote_fetch_word, remote_store_word): Make static and #if 0.
- They are not called from anywhere.
-
-Wed Sep 1 14:41:28 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * arm-tdep.c, convex-tdep.c, convex-xdep.c, dbxread.c,
- h8300-tdep.c, h8500-tdep.c, i960-pinsn.c, i960-tdep.c,
- infptrace.c, m88k-tdep.c, mips-tdep.c, regex.c, remote-vx.c,
- rs6000-tdep.c, xcoffexec.c, xcoffread.c, z8k-tdep.c,
- config/arm/tm-arm.h, config/convex/tm-convex.h,
- config/gould/tm-np1.h, config/gould/tm-pn.h,
- config/m68k/tm-isi.h, config/ns32k/tm-umax.h,
- config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
- config/rs6000/tm-rs6000.h, config/tahoe/tm-tahoe.h,
- config/vax/tm-vax.h: bzero -> memset.
-
- * regex.c: bcmp -> memcmp.
-
-Wed Sep 1 11:35:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.c (find_pc_line, find_line_common),
- symtab.h (struct linetable), xcoffread.c (arrange_linetable):
- Revise comments re linetable sorting.
- * buildsym.c (compare_line_numbers): Sort by pc, not by line.
- * coffread.c: Tell end_symtab to sort the line table.
-
- * coffread.c: Re-work a lot of the coff-specific stuff to use stuff
- in buildsym.c. This includes coff_finish_block, coff_context_stack,
- coff_local_symbols, coff_file_symbols, coff_global_symbols,
- coff_end_symtab and coff_add_symbol_to_list.
- (read_enum_type): Deal with it now that we have a "struct pending"
- not a "struct coff_pending".
-
- * buildsym.c (end_symtab): Don't realloc subfile->linetable.
-
-Wed Sep 1 13:12:43 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * a68v-nat.c, altos-xdep.c, convex-tdep.c, convex-xdep.c,
- findvar.c, hppab-nat.c, hppah-nat.c, i386mach-nat.c,
- irix4-nat.c, m68k-tdep.c, m88k-tdep.c, mipsread.c, regex.c,
- remote-bug.c, remote-hms.c, rs6000-nat.c, rs6000-tdep.c,
- sparc-nat.c, stabsread.c, sun3-nat.c, sun386-nat.c, symfile.c,
- umax-xdep.c, xcoffread.c, 29k-share/udi/udip2soc.c,
- 29k-share/udi/udr.c, config/a29k/tm-a29k.h, config/arm/tm-arm.h,
- config/convex/tm-convex.h, config/gould/tm-np1.h,
- config/gould/tm-pn.h, config/h8300/tm-h8300.h,
- config/h8500/tm-h8500.h, config/i386/tm-i386aix.h,
- config/i386/tm-sun386.h, config/i386/tm-symmetry.h,
- config/i960/tm-i960.h, config/m68k/tm-news.h,
- config/m88k/tm-m88k.h, config/mips/tm-mips.h,
- config/ns32k/tm-merlin.h, config/ns32k/tm-umax.h,
- config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
- config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
- config/tahoe/tm-tahoe.h, config/vax/tm-vax.h,
- config/z8k/tm-z8k.h, nindy-share/nindy.c: bcopy -> memcpy.
-
-Wed Sep 1 05:05:53 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (parse_partial_symbols): Use language from FDR if it
- is unambigous. Patch from ptf@delcam.co.uk (Paul Flinders).
- * mipsread.c (ecoff_symfile_info): New struct to hold the global
- pending_list.
- * mipsread.c (mipscoff_symfile_init, parse_partial_symbols):
- Allocate the global pending list and link it to the objfile.
- * mipsread.c (is_pending_symbol, add_pending): Use global pending
- list from objfile. Allocate pending list entries from the
- psymbol_obstack.
- * mipsread.c (free_pending): Remove. The pending list is now
- freed when the psymbol_obstack is freed.
- * mipsread.c (psymtab_to_symtab1): Remove pending list allocation,
- the global pending list is used now.
- * mipsread.c (parse_partial_symbols): Skip only the first
- file indirect entry when building the dependency list.
-
-Tue Aug 31 15:01:27 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- Break dcache code out of remote.c.
- * dcache.h: white space changes only.
- * dcache.c: add user settable variable to set whether data caching
- is in use.
- * remote.c: include dcache.h. removed data caching code which is
- now in dcache.c. Compile in data caching again. (data caching
- is currently off by default.)
- (remote_read_bytes, remote_write_bytes): change second arg to
- unsigned char.
- (remote_dcache): new static variable.
- * Makefile.in (REMOTE_O): add dcache.o.
- * config/m88k/m88k.mt (TDEPFILES): removed dcache.o.
-
- Break dcache code out of remote-nindy.c.
- * remote-nindy.c: removed dcache code. Changed callers to use new
- conventions. include dcache.h.
- (nindy_dcache): new static variable.
- * config/i960/nindy960.mt (TDEPFILES): added dcache.o.
-
- Break dcache code out of remote-bug.c into dcache.[hc].
- * Makefile.in (dcache_h): new macro.
- (HFILES): added $(dcache_h).
- (ALLDEPFILES): added dcache.c.
- (dcache.o): new rule.
- (remote-bug.o): now depends on $(dcache_h).
- * remote-bug.c: include dcache.h. remove externs for insque and
- remque, add extern for bcopy. Prototype bug_close,
- bug_clear_breakpoints, bug_write_cr. dcache code moved to
- dcache.[hc]. Changed dcache calling convention to include an
- initial DCACHE argument.
- (bug_dcache): new static variable.
- (bug_read_inferior_memory): change second arg to
- unsigned char.
- * dcache.[ch]: new files.
- * config/m88k/m88k.mt (TDEPFILES): add dcache.o.
-
-Tue Aug 31 10:33:13 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * c-typeprint.c (c_print_type_base): Treat show = 0 just like
- show < 0. The only case where we had been distinguishing is that
- show = 0 used to print "struct " or "enum " instead of
- "struct {...}" or "enum {...}" which seems clearly wrong.
-
-Mon Aug 30 17:51:32 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * configure.in: recognize m88110 as an m88k.
-
-Mon Aug 30 16:07:59 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * valops.c (call_function_by_hand): If we discard cleanups, call
- bpstat_clear (&inf_status.stop_bpstat).
-
-Mon Aug 30 12:47:46 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * stabsread.h, dbxread.c (end_psymtab): Return NULL if the psymtab
- was empty and thrown away.
- * mipsread.c (parse_partial_symbols): Do not add empty psymtabs to
- dependency list, skip self dependencies.
- * mipsread.c (parse_fdr): Removed, obsolete.
- * mipsread.c (parse_lines): Check for cbLine being zero, not
- cbLineOffset.
- * mipsread.c (struct symloc): Add pst_language.
- * mipsread.c (parse_partial_symbols): Set up proper language for
- header files, save it in pst_language for psymtab_to_symtab_1.
- * mipsread.c (psymtab_to_symtab_1): Use pst_language.
-
-Mon Aug 30 10:48:06 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in: Fix typo m88*-motorola-svr4* -> sysv4*.
-
-Fri Aug 27 17:09:19 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * paread.c: Include som.h instead of libhppa.h. (From Utah.)
-
-Fri Aug 27 09:30:40 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * symmisc.c (dump_symtab): Use catch_errors around print_symbol.
- Change calling sequence of print_symbol to fit catch_errors.
-
- * mips-tdep.c: Call reinit_frame_cache every time the user does
- "set heuristic-fence-post".
-
- * gdbserver/low-sun3.c: New file.
- * gdbserver/Makefile.in, config/m68k/sun3.mh: Change accordingly.
-
- * Rename files for 14-character limits:
- gdbserver/remote-gutils.c -> gdbserver/utils.c
- gdbserver/remote-inflow.c -> gdbserver/low-lynx.c
- gdbserver/remote-inflow-sparc.c -> gdbserver/low-sparc.c
- gdbserver/remote-server.c -> gdbserver/server.c
- remote-monitor.c -> remote-mon.c
- * Makefile.in, gdbserver/Makefile.in, gdbserver/configure.in,
- config/m68k/monitor.mt, config/i386/i386lynx.mh,
- config/sparc/sun4os4.mh: Change accordingly.
- * gdbserver/Makefile.in: Remove more junk inherited from gdb Makefile.
-
-Thu Aug 26 14:32:51 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infcmd.c, inferior.h (run_stack_dummy): If we stop somewhere
- besides the dummy, return 1 rather than calling error().
- Let caller print the error message. Remove name argument.
- * valops.c (call_function_by_hand): Deal with changes to calling
- sequence of run_stack_dummy. Discard restore_inferior_status cleanup
- if run_stack_dummy returns 1.
-
- * Version 4.10.2.
-
- * config/mips/tm-mips.h (EXTRACT_STRUCT_VALUE_ADDRESS):
- Get struct return address from v0, not a0.
-
- * infrun.c (restore_inferior_status): Use catch_errors when
- restoring selected frame.
-
-Wed Aug 25 21:52:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (save_inferior_status, restore_inferior_status):
- Save and restore the registers too.
- * inferior.h (struct inferior_status): Add "registers".
-
-Tue Aug 24 00:36:17 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dbxread.c (end_psymtab): Clean up comment.
-
- * frame.h, symtab.h, findvar.c (read_var_value): Change basereg
- support to use LOC_BASEREG rather than SYMBOL_BASEREG_VALID.
- * dwarfread.c: Use LOC_BASEREG where appropriate.
- * Various: Support LOC_BASEREG and LOC_BASEREG_ARG.
-
- * coffread.c (init_lineno, init_stringtab): Don't check whether
- xmalloc returned NULL.
-
- * config/vax/xm-vaxult.h: Define NO_PTRACE_H.
-
- * target.c, target.h: Add "set remotedebug" command.
- * remote-bug.c, remote.c, remote-mips.c: Remove "set remotedebug" and
- "set m88ksnoop" options and use generic "set remotedebug" instead.
- * NEWS: Describe this change.
-
-Mon Aug 23 20:26:22 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * buildsym.h: Remove declaration of dbxread.c functions.
- * stabsread.h: Group together dbxread.c functions.
- Move elfstab_build_psymtabs here from symfile.h.
- Declare pastab_build_psymtabs.
- * elfread.c, paread.c: Include stabsread.h (for stabsread_new_init
- declaration, etc).
-
-Mon Aug 23 17:16:23 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * remote-bug.c: rename quiet to bug88k_snoop.
- (double_scan, multi_scan): generalize double_scan into a scan
- for multiple patterns. Rename to multi_scan.
- (bug_wait, bug_write_inferior_memory): adapt to use the new
- multi_scan in order to catch and represent target bus errors.
- (bug_scan): currently unused, so comment out.
- (bug_quiet): removed. Replaced with a standard user settable boolean.
-
- * m88k-tdep.c: remove include of sys/dir.h. Appears unnecessary
- and isn't available on solaris.
-
-Mon Aug 23 14:56:42 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/m88k/{delta88v4.mt,delta88v4.mh}: New files
- * config/m88k/delta88.mh: Fix comment.
- * config/m88k/tm-delta88.h: Remove unused BCS define.
- * config/m88k/{tm-delta88v4.h,xm-delta88v4.h,nm-delta88v4.h}:
- New files.
- * configure.in: Recognize m88*-motorola-sysv4*.
- * m88k-nat.c: Always include sys/types.h; don't depend on USG.
-
-Mon Aug 23 12:57:42 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (parse_symbol, parse_type, cross_ref): Pass name of
- symbol as an argument and use it in complaints.
- * symmisc.c (dump_psymtab): Dump filenames of dependencies.
-
-Mon Aug 23 1993 Sean Fagan (sef@cygnus.com)
- and Jim Kingdon (kingdon@cygnus.com)
-
- Add NetBSD support:
- * configure.in: Recognize netbsd.
-
-Sun Aug 22 22:50:32 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (get_textlow): Don't go past a K_END when looking for a
- K_FUNCTION. Avoids losing on source files with no functions.
-
-Fri Aug 20 14:01:39 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-nindy.c: Remove unused include of sys/ioctl.h.
-
- * frame.h, symtab.h: Revise comments regarding baseregs.
-
-Fri Aug 20 15:07:05 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (parse_partial_symbols, psymtab_to_symtab_1):
- Set language for psymtab and symtab.
- * mipsread.c (new_symbol): Set language and initialize demangled
- name for symbol.
- * symmisc.c (print_symbol): Use SYMBOL_SOURCE_NAME when printing
- the symbol type.
- * symtab.c (decode_line_1): Inhibit coredumps with cfront executables.
-
-Fri Aug 20 14:01:39 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Move KERNEL_U_ADDR from xm-hp300bsd.h to nm-hp300bsd.h and make
- it conditionalized on 4.3 vs. 4.4.
- * config/m68k/nm-hp300bsd.h: Move REGISTER_U_ADDR out of 4.3 and
- 4.4 sections; it was identical and now works for 4.4.
-
- * mips-tdep.c (is_delayed): Use INSN*BRANCH* not ANY_DELAY.
-
- * printcmd.c (MAKEVA_END): Update this version to use "aligner".
-
-Thu Aug 19 22:08:09 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/vax/tm-vax.h (BELIEVE_PCC_PROMOTION): Define.
- * mipsread.c (parse_symbol, parse_type, cross_ref): Handle corrupt
- file indirect entries with complaints instead of core dumps. Remove
- complaint for stTypedef within aggregates.
-
-Thu Aug 19 17:58:39 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * coffread.c (process_coff_symbol): Ignore tagnames like .0fake.
-
- * coffread.c (coff_read_enum_type): #if 0 out code which changes
- enum {FALSE, TRUE} into boolean.
-
- * config/m68k/delta68.m{t,h}: Use nm-delta68.h, etc. not
- non-existent files nm-delta.h, etc.
- * config/m68k/tm-delta68.h: Define CANNOT_STORE_REGISTER.
- * delta68-nat.c: Add "[0]" in offsetof argument.
- * delta68-nat.c (_initialize_kernel_u_addr): Don't try to set up
- nl with initializer, just assign to it. Check n_scnum field on
- return.
-
-Wed Aug 18 21:42:52 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (read_hpux_symtab): Call SET_NAMESTRING for K_MODULE
- debug symbols.
-
-Wed Aug 18 12:03:00 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (print_address), values.c (value_as_pointer): Don't
- use ADDR_BITS_REMOVE.
- * defs.h: Try to clarify comment about ADDR_BITS_REMOVE.
-
- * blockframe.c (block_innermost_frame): Uncomment.
- Return NULL if passed NULL.
- * frame.h: Declare it.
- * expression.h (union exp_element): Add field block.
- * parse.c (write_exp_elt_block): New function.
- * expression.h (OP_VAR_VALUE): Now takes additional struct block *.
- * *-exp.y: Write block for OP_VAR_VALUE.
- * eval.c, expprint.c, parse.c: Deal with block for OP_VAR_VALUE.
- * valops.c, value.h (value_of_variable), callers:
- Add second argument, for block.
-
- * main.c (gdb_readline): If we read some characters followed by EOF,
- return them rather than returning NULL.
-
-Tue Aug 17 11:14:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * mips-tdep.c: Remove unused #ifndef NUMERIC_REG_NAMES and add comment.
-
-Tue Aug 17 15:10:04 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * config/m88k/tm-m88k.h: Fix typo in comment.
- (FP_REGNUM): define in terms of SP_REGNUM
- rather than by absolute number. Also clearly comment that this
- is a convenient lie in order to decrease future confusion.
- (ACTUAL_FP_REGNUM): new macro for FP.
- (FRAME_CHAIN_VALID): removed. Standard default works fine.
- * m88k-tdep.c (frame_chain_valid): redundant, so removed.
- (NEXT_PROLOGUE_INSN): removed unused fourth arg, fixed all
- callers.
- (read_next_frame_reg): declare static.
- (examine_prologue): removed unused variabel insn2, rename insn1
- to insn, rewrote comment about finding fp, sp, etc. set frame_fp
- based on ACTUAL_FP_REGNUM rather than FP_REGNUM which is
- actually a scammed alias for SP_REGNUM on m88k.
-
- * frame.h: fixed typo in comment.
-
-Tue Aug 17 11:14:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * 29k-share/udi/udiphcfg.h: Always include udiphunix.h not udiphdos.h.
-
- * complaints.c (complain): fflush (stdout) after output.
-
-Tue Aug 17 01:43:55 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * blockframe.c, frame.h (sigtramp_saved_pc): New routine to fetch
- the saved pc from sigcontext on the stack for BSD signal handling.
- * config/i386/tm-i386bsd.h (SIGTRAMP_START, SIGTRAMP_END, FRAME_CHAIN,
- FRAMELESS_FUNCTION_INVOCATION, FRAME_SAVED_PC, SIGCONTEXT_PC_OFFSET):
- Define to make backtracing through sigtramp work.
- * config/vax/tm-vax.h (SIGTRAMP_START, SIGTRAMP_END, TARGET_UPAGES,
- FRAME_SAVED_PC, SIGCONTEXT_PC_OFFSET): Ditto.
-
-Mon Aug 16 13:52:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c (cd_command): If current_directory on entry is "/", then
- don't append an extra slash.
- Don't assume that /../.. means /.
-
- * target.c (target_xfer_memory): Clear errno before calling
- to_xfer_memory.
-
- * stack.c (frame_info, print_frame_info): Add comment about using
- the starting source line number on a line boundary if backtracing
- through sigtramp.
-
-Mon Aug 16 09:52:33 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Add U Utah contribution notice. Add TODO list.
- (hp_type_lookup): Use TYPE_NAME and TYPE_TAG_NAME.
- (process_one_debug_symbol): Likewise.
-
-Mon Aug 16 02:56:01 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * blockframe.c (create_new_frame, get_prev_frame_info):
- Use the function name when calling IN_SIGTRAMP.
- * config/m68k/tm-m68k.h (SIG_PC_FP_OFFSET, SIG_SP_FP_OFFSET):
- Define for correct handling of bachtraces through _sigtramp.
- * m68k-tdep.c (m68k_find_saved_regs): Adjust saved sp for fake
- sigtramp frames.
- * mipsread.c (parse_type): Handle corrupt TIR info with complaint
- instead of core dump.
- * mipsread.c (parse_partial_symbols): Put static symbols into the
- mimimal symbol table, use proper mst_types for all minimal symbols.
- * stack.c (frame_info, print_frame_info): Use the starting source
- line number on a line boundary if backtracing through sigtramp.
-
-Fri Aug 13 14:37:05 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * remote-bug.c: include gdbcmd.h.
- (sleep, remque, insque): forward decls added.
- (bug_fetch_registers, bug_store_registers): forward decls
- removed.
- (bug_read_inferior_memory, bug_write_inferior_memory): forward
- decls added.
- (srec_frame, srec_max_retries, srec_bytes, srec_echo_pace,
- srec_sleep, srec_noise): new static variables for user settable
- options. Mostly these are for debugging and tuning. I don't
- expect them to stay user settable options for long.
- (timeout): change default to 4 seconds.
- (check_open): declare funtion static, force return value.
- (readchar_nofail): if timeout, then say so if not being quiet.
- (pollchar, double_scan, bug_scan, bug_srec_write_cr,
- start_load): new functions.
- (bug_wait): rewritten to use double scan.
- (expect): while (1) -> for (;;)
- (get_hex_digit): rewrite if condition to avoid gcc complaints.
- (bug_load, bug_create_inferior, bug_open, bug_store_register):
- removed unused variables.
- (bug_load): replaced DELTA macro with user settable srec_frame
- variable. Other minor lint.
- (find_end_of_word, is_baudrate_right, set_rate, not_bug_wait,
- gethex, timed_read, translate_addr, bug_before_main_loop):
- unsused and removed.
- (bug_resume): add missing first arg, pid.
- (get_reg_name): use ip rather than cr04.
- (bug_write, bug_write_cr, but_clear_breakpoints, bug_quiet):
- declare type, args, and explicitly return.
- (bug_store_register): straighten out the ip vs cr04 confusion.
- (bug_write_inferior_memory): rewrite to cope with errors while
- downloading s-records.
- (bug_read_inferior_memory): declare static.
- (bug_clear_breakpoints): expect nobr before prompt.
- (_initialize_remote_bug): add initializations for srec-bytes,
- srec-max-retries, srec-frame, srec-noise, srec-sleep,
- srec-echo-pace.
-
- * Makefile.in (remote-bug.o): new rule.
- (ALLDEPFILES): added remote-bug.c
-
- * remote-hms.c (hms_wait): use -1 for timeout's which means block
- forever rather than 99999.
-
- * ser-unix.c (get_tty_state): if a descriptor is not a tty, then
- simply save encode this fact as the process group and return
- success rather than an error.
- (set_tty_state): if process group is -1, do not reset the
- process group.
- (hardwire_reachar): comment change.
-
- * serial.h: comment change.
-
- * config/m88k/tm-m88k.h: comment change to remove embedded
- comment.
- (SKIP_PROLOGUE): skip_prologue returns a value which is expected
- to reset the pc argument. So reset it.
-
-Fri Aug 13 10:15:24 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.10.1 after release and cvs
- tagging.
-
-Thu Aug 12 20:40:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbserver/Makefile.in: Use GDBSERVER_LIBS and
- GDBSERVER_DEPFILES. Also remove much (but not all that could be
- removed) crud inherited from gdb Makefile.in.
- * config/i386/i386lynx.mh, config/sparc/sun4os4.mh: Define GDBSERVER_*.
- * gdbserver/README: Say it works on Sun and change configuration
- instructions slightly.
-
-Wed Aug 11 18:56:59 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * config/i386/i386v4.mh: use -lsocket and -lnsl, for remote
- targets that use BSD style network connections
-
-Wed Aug 11 17:54:24 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-{monitor,bug}.c: Make bug_ops not static (forward declaration
- of statics doesn't work with SunOS4 /bin/cc).
- Rename the occurrence in remote-monitor.c to monitor_bug_ops.
-
-Tue Aug 10 13:07:14 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * blockframe.c (find_pc_partial_function),
- mips-tdep.c (find_proc_desc): Deal with "pathological" case.
-
-Tue Aug 10 14:50:30 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * utils.c (wrap_here): Allow indent to be NULL.
- (fputs_filtered): Don't check for null wrap_indent (wrap_here now
- guarantees that it isn't, and anyway we were only checking one out
- of the two places we dereferenced it).
-
- * objfiles.h (struct objfile): Clean up comments for
- {obj,sym}_private to clarify what they are private to.
-
-Mon Aug 9 16:45:00 1993 Stan Shebs (shebs@rtl.cygnus.com)
-
- * stabsread.c, buildsym.c (hashname): Moved function to
- buildsym.c, as suggested in the sources.
-
-Mon Aug 9 09:53:45 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-udi.c: Make udi_ops extern rather than trying forward
- declaration of a static variable.
-
- * hppab-nat.c: Define ptrace to call_ptrace and pass the 5th arg
- there, rather than using an ANSI C specific macro.
-
- * 29k-share/udi/udr.c: Include fcntl.h not sys/fcntl.h. Also put
- sys/types.h near the top (just on general principles).
-
- * environ.c (set_in_environ): Remove G960BASE and G960BIN; they are
- no longer used.
-
- * gdbcore.h: New variable gnutarget.
- * core.c: Add commands to set and show it.
- * Callers to bfd_*open*: Pass gnutarget instead of NULL as target.
- * environ.c (set_in_environ): For GNUTARGET, use set_gnutarget not
- putenv.
-
- * symtab.c (decode_line_1): Give error on unmatched single quote.
-
-Sun Aug 8 13:59:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * ser-unix.c (hardwire_send_break) [HAVE_SGTTY]: Use select not usleep.
-
- * remote.c: Add comments about 'd', 'r', and unrecognized requests.
-
- * inflow.c (terminal_init_inferior): Don't muck with tty state if
- gdb_has_a_terminal() is false.
-
-Sun Aug 8 10:07:47 1993 Fred Fish (fnf@cygnus.com)
-
- * dwarfread.c (record_minimal_symbol): Remove prototype and
- function.
- * dwarfread.c (add_partial_symbol): Remove code to add minimal
- symbols and remove comment about limitations. Experiments show
- that now that gdb handles the ELF symtab better for creating
- minimal symbols, that no additional information is added by
- examining the DWARF information, and in fact, given the
- limitations, the DWARF code was actually making things worse.
-
-Sat Aug 7 10:59:03 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * elfread.c (elf_symtab_read): Properly sort out the bss symbols
- from the data symbols and give them the correct minimal_symbol_type.
- Add file static symbols to the minimal symbol table, not just
- global symbols. Add absolute symbols as well (like _edata, _end).
- Redo stabs-in-elf special symbol handling now that file static
- symbols are entered into the into the minimal symbol table.
- * dwarfread.c (add_partial_symbol): Add comment about limitations
- of DWARF symbols for distinquishing data from bss when adding
- minimal symbols. Add file local symbols to minimal symbols.
-
-Thu Aug 5 08:58:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * ser-go32.c: Define job_control variable.
-
-Thu Aug 5 15:56:13 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
-
- * configure.in: z8k-coff is the same as z8k-sim
-
-Thu Aug 5 08:58:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * 29k-share/udi/udip2soc.c: Include sys/types.h before sys/file.h.
-
- * config/i386/tm-i386bsd.h (NUM_REGS): There are only 10, not 11.
-
- * inflow.c: Put all uses of F_GETFL and F_SETFL in #ifdef F_GETFL.
-
- * 29k-share/udi/udip2soc.c: Include fcntl.h not sys/fcntl.h.
-
-Wed Aug 4 18:32:12 1993 Fred Fish (fnf@cygnus.com)
-
- * inflow.c (pass_signal): Signal handlers take one int arg;
- supply an unused one to make it type compatible as an arg to
- signal().
-
-Tue Aug 3 18:34:14 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * config/mips/tm-mips.h: Include bfd.h before coff/sym.h.
-
-Tue Aug 3 15:34:57 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (ALLCONFIG): Add config/i386/i386nw.mt,
- config/m68k/delta68.mh, config/m68k/delta68.mt,
- config/m68k/dpx2.mh, config/m68k/dpx2.mt, config/mips/riscos.mh,
- config/mips/news-mips.mh.
- * Makefile.in (ALLPARAM): Add config/i386/nm-symmetry.h,
- config/i386/tm-i386nw.h, config/m68k/nm-delta68.h,
- config/m68k/tm-delta68.h, config/m68k/xm-delta68.h,
- config/m68k/nm-dpx2.h, config/m68k/tm-dpx2.h,
- config/m68k/xm-dpx2.h, config/mips/xm-makeva.h.
- * Makefile.in (ALLDEPFILES): Add dpx2-nat.c.
-
-Tue Aug 3 12:02:09 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mipsread.c: Updated for BFD ECOFF changes. Now gets the
- swapping routines and external structure sizes via the
- ecoff_backend information. No longer includes coff/mips.h.
-
-Tue Aug 3 10:58:04 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (SFILES): Add thread.c
-
-Tue Aug 3 10:21:58 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * remote-sp64sim.c (simif_create_inferior): Add FIXME regarding
- sim_set_args return code.
-
-Mon Aug 2 16:35:31 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * Makefile.in (VERSION): bumped to 4.9.4.
-
- * remote-monitor.c: updated copyright.
- (bug_ops, monitor_desc): now static.
- (monitor_desc): in several places, check and/or set to NULL.
-
- * remote-hms.c (hms_files_info): Add the appropriate items where
- missing in the printf call.
-
- * remote-bug.c: new file for m88k bug support.
-
- * config/m88k/m88k.mt (TDEPFILES): added remote-bug.o.
-
-Mon Aug 2 14:22:09 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
-
- * h8300-tdep.c: Use new variable h8300hmode.
-
-Mon Aug 2 12:06:00 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * valops.c (typecmp): If we are passing a non-reference to a function
- which takes a reference, pass the address.
- (value_arg_coerce): Don't use COERCE_ENUM; we don't want to dereference
- references here.
-
- * thread.c (thread_switch): Define as static.
- (add_thread): Cast return value from xmalloc.
-
- * gdbtypes.c (fill_in_vptr_fieldno): Call check_stub_type.
- * gdbtypes.{c,h}: Improve comments on vptr_fieldno.
-
-Mon Aug 2 11:58:52 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * README: Elaborate on gdb C++ support and cfront support.
-
-Mon Aug 2 11:30:57 1993 Stu Grossman (grossman at cygnus.com)
-
- * i386lynx-nat.c, thread.c, thread.h: Update copyrights.
-
-Mon Aug 2 12:06:00 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (ALLDEPFILES): Add i386lynx-nat.c.
-
-Mon Aug 2 08:42:50 1993 Stu Grossman (grossman at cygnus.com)
-
- * gdbserver/remote-inflow.c (create_inferior): Fix comments, and
- error msg. Setup seperate process group for child.
- * (write_inferior_memory): Sleep for 1 second and retry on ptrace
- failure.
-
-Sun Aug 1 22:58:18 1993 Stu Grossman (grossman at cygnus.com)
-
- * config/i386/i386lynx.mh (NATDEPFILES): Drop coredep (for now).
- * config/i386/nm-i386bsd.h: Protect from multiple inclusion.
- * config/i386/nm-i386lynx.h: Lotsa new host porting stuff.
- * config/i386/tm-i386lynx.h: Define SAVED_PC_AFTER_CALL and
- target_pid_to_str.
-
- * Makefile.in (CLIBS): Reorder to make Lynx ld happy.
- * (HFILES): New file thread.h.
- * (OBS): New file thread.c.
- * configure.in: Host config for Lynx/386.
- * fork-child.c (fork_inferior): Call init_thread_list().
- * infrun.c (resume): Add pid to invocation of target_resume().
- * (wait_for_inferior): Pay attention to pid from target_wait().
- Multi-threading code now uses this to determine what to do.
- * inftarg.c (child_wait): Conditionalize based on CHILD_WAIT macro.
- Use target_pid_to_str() macro throughout when printing pid.
- * inferior.h (child_resume): Add pid to prototype.
- * hppab-nat.c hppah-nat.c infptrace.c (child_resume): Pass in pid as
- argument, instead of using inferior_pid.
- * procfs.c (procfs_resume): Pass in pid as argument. Ignored for
- now. Use target_pid_to_str() macro throughout for printing process id.
- * remote-adapt.c (adapt_resume): Pass in pid as argument.
- * remote-eb.c (eb_resume): Pass in pid as argument.
- * remote-es.c (es1800_resume): Pass in pid as argument.
- * remote-hms.c (hms_resume): Pass in pid as argument.
- * remote-mips.c (mips_resume): Pass in pid as argument.
- * remote-mm.c (mm_resume): Pass in pid as argument.
- * remote-monitor.c (monitor_resume): Pass in pid as argument.
- * remote-nindy.c (nindy_resume): Pass in pid as argument.
- * remote-sa.sparc.c (remote_resume): Pass in pid as argument.
- * remote-sim.c (rem_resume): Pass in pid as argument.
- * remote-sp64sim.c (simif_resume): Pass in pid as argument.
- * remote-st.c (st2000_resume): Pass in pid as argument.
- * remote-udi.c (udi_resume): Pass in pid as argument.
- * remote-vx.c (vx_resume): Pass in pid as argument.
- * remote-z8k.c (rem_resume): Pass in pid as argument.
- * remote.c (remote_resume): Pass in pid as argument.
- * solib.c (solid_create_inferior_hook): Pass inferior_pid to
- target_resume().
- * target.c (normal_pid_to_str): New routine to print out process
- ID normally.
- * target.h (struct target_ops): Add pid to prototype at
- to_resume(). (target_resume): Add pid argument.
- * (target_pid_to_str): Default definition for normal type pids.
- * thread.h, thread.c: New modules for multi thread/process control.
-
-Sun Aug 1 13:02:42 1993 John Gilmore (gnu@cygnus.com)
-
- * README: Say that bug-gdb is also the place to send requests
- for help with GDB.
-
-Sun Aug 1 09:42:13 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (make-proto-gdb-1): Use -f opt on rm of Makefile.
- * h8500-tdep.c: Add parens around a few macro args.
-
-Fri Jul 30 15:43:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * TODO: Remove items about unix-to-unix/rapp debugging (now we
- have gdbserver), moving xm files to subdirectory, ptype yylval,
- and file-local symbols.
-
- * gdbtypes.h: Improve comments about C++ methods.
-
-Fri Jul 30 14:16:32 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * c-exp.y: Add missing 5th arg for one call to lookup_symbol, cast
- NULL in all other calls to correct pointer types.
-
-Fri Jul 30 15:43:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- From Jeffrey Law:
- * tm-hppa.h (TARGET_WRITE_PC): Define.
- * hppa-tdep.c (hppa_fix_call_dummy): If in a syscall,
- then return the address of the dummy itself rather than
- the address of $$dyncall.
- (target_write_pc): New function to store a new PC.
-
-Fri Jul 30 12:51:27 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
- and Jim Kingdon (kingdon@cygnus.com)
-
- * breakpoint.c (breakpoint_re_set_one): Always reparse breakpoint
- conditions, they might contain symbol table references.
-
-Fri Jul 30 12:51:27 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (parse_symbol): Handle opaque struct definitions and
- type naming for stTypedef symbols.
-
-Fri Jul 30 14:44:21 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * c-exp.y (yylex): Detect C++ nested types.
-
-Fri Jul 30 11:07:37 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * sp64-tdep.c (sparc64_frame_chain, sparc64_frame_saved_pc): Deleted.
- (dump_ccreg, sparc_print_register_hook): New fns.
- * remote-sim.h: New file.
- * remote-sp64sim.h (sim_*): External fns. (simif_*): Internal fns.
-
- * config/sparc/sp64.mt: New file.
- * config/sparc/tm-sp64.h (FRAME_CHAIN, FRAME_SAVED_PC): Deleted.
- (PRINT_REGISTER_HOOK): Call new fn sparc_print_register_hook.
-
-Fri Jul 30 10:15:01 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * Makefile.in (ALLCONFIG): Add config/i386/ptx.mh
-
-Fri Jul 30 08:58:01 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- From J. Law:
- * infcmd.c (read_pc): Remove PA specific code.
- * tm-hppa.h (TARGET_READ_PC): Define.
- * hppa-tdep.c (target_read_pc): New function.
-
- * symtab.c (gdb_mangle_name): Deal with it if type lacks a name.
-
-Fri Jul 30 07:36:53 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * NEWS: Add note that DEC alpha support is host only, not native.
- * README: Emphasize that C++ support works best with GNU C++ and
- stabs debugging format.
- * delta68-nat.c: Add missing FSF copyright.
-
-Fri Jul 30 08:58:01 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * paread.c (pa_symtab_read): Put file-local symbols in minimal symbols.
- * hppa-tdep.c (frame_chain_valid): Check that our function has the
- same address as _start, not that it must be the same symbol.
-
-Fri Jul 30 00:18:40 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * Makefile.in (ALLDEPFILES): Add delta68-nat.c
- * Makefile.in (delta68-nat.o): Add dependency.
-
-Thu Jul 29 12:09:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * value.h (COERCE_ENUM): Use COERCE_REF to coerce refs; value_ind
- was adequate in gdb 3.5 but not now.
-
- * valops.c (typecmp): An array in t2 matches a pointer in t1.
-
- * valops.c (typecmp): When comparing type1& to type2, compare
- type1 and type2 as leniently as if we were comparing type1 to
- type2.
-
- * cp-valprint.c (cplus_print_value): Don't dump core if the
- baseclass doesn't have a name.
- * values.c (vb_match): New function, which finds the virtual
- base class pointer even if the types are nameless.
- (baseclass_{addr,offset}): Use it.
-
- * hppa-tdep.c: Make "maintenance print unwind" command from old
- "unwind" command.
-
- * remote-udi.c: Remove udi_timer, call to siginterrupt, and associated
- obsolete junk which apparently had been copied from the
- pre-serial.h remote.c, but which is no longer used.
-
-Thu Jul 29 12:36:20 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * Makefile.in (NONSRC): Need 29k-share/README, not
- 29k-share/udi/README.
-
-Thu Jul 29 12:09:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * paread.c (pa_symfile_init): If error reading string table, don't
- use errno in cases where it hasn't been set.
-
- * ser-unix.c (gdb_setpgid): Pass our pid, not 0, to setpgid.
-
- * remote-monitor.c (_initialize_monitor): Comment out use of
- connect_command, since connect_command itself is commented out.
-
- * remote-monitor.c (generic_open): Parse arguments the same way
- as remote.c.
-
- * hppa-tdep.c (pc_in_linker_stub): Fix unclosed comments.
-
-Wed Jul 28 13:19:34 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/mips/xm-mips.h: Define HAVE_TERMIOS.
-
- * dbxread.c (record_minimal_symbol): Don't put gcc_compiled or
- __gnu_compiled* symbols into the minimal symbols.
-
-Wed Jul 28 08:26:58 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * remote-mips.c (_initialize_remote_mips): Added "timeout" and
- "retransmit-timeout" variables to set mips_receive_wait and
- mips_retransmit_wait, respectively.
-
-Wed Jul 28 03:58:58 1993 (pes@regent.e-technik.tu-muenchen.de)
-
- * symmisc.c (dump_msymbols): Handle new mst_file_* types.
-
-Tue Jul 27 12:07:38 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-udi.c: Remove old comment about download not implemented.
-
- * serial.h, ser-{unix,go32,tcp}.c: Add flush_input and send_break.
- * nindy-share/*, remote-nindy.c: Extensive hacking to make it
- conform to GDB conventions like using memcpy not bcopy, serial.h,
- etc. This is to make it host on Solaris, AIX, etc.
- * Makefile.in: Reflect removed nindy-share files.
- * config/i960/nindy960.mt (TDEPFILES): Remove ttybreak.o.
-
- * stack.c (print_frame_info): Revise comment about `pathological'
- case (there was a wrong FIXME about text labels; also asm() can
- trigger this as well as versions of ar which truncate .o names).
-
- * buildsym.c (start_subfile): If a .c file includes a .C file, set
- the language of both of them to C++.
-
- * config/sparc/xm-sun4os4.h: Define MEM_FNS_DECLARED and include
- <memory.h>.
- Include <malloc.h> rather than declaring malloc functions ourself.
-
- * ser-unix.c (set_tty_state): Don't ignore errors setting process
- group.
- * inflow.c (terminal_inferior): If attach_flag set, ignore errors
- from set_tty_state.
-
- * fork-child.c (fork_inferior): Only quote exec file if needed.
-
- * mipsread.c (parse_symbol): Remove 21 Jul 93 change with
- stTypedef inside an stBlock.
-
-Tue Jul 27 12:36:49 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * breakpoint.c (breakpoint_1): Walk the breakpoint chain to decide if
- we have breakpoints or watchpoints as we might have to ignore internal
- breakpoints.
-
- Fix gdb core dumps after `file newfile' commands.
- * symtab.h, symfile.c (clear_symtab_users): New routine which
- unconditionally clears symtab users. clear_symtab_users_once
- commented out as it was a noop anyway.
- * objfiles.c (free_objfile): Don't call clear_symtab_users_once.
- * objfiles.c (free_all_objfiles), symfile.c (new_symfile_objfile),
- xcoffexec.c (exec_close): Call clear_symtab_users if necessary.
- * symfile.c (syms_from_objfile): Install cleanups for errors during
- symbol reading.
- * coffread.c, dbxread.c, mipsread.c, xcoffread.c (*_symfile_read):
- Lint cleanup code, call do_cleanups explicitly.
- * symfile.c (symbol_file_add): Call new_symfile_objfile and
- reinit_frame_cache _after_ the new symbols are read in.
-
-Tue Jul 27 01:57:01 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (parse_type): Do not set tag name for compiler
- generated fake tag names.
-
-Mon Jul 26 17:31:49 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * config/m88k/m88k.mt (TDEPFILES): add exec.o.
-
-Mon Jul 26 13:17:36 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * hppa-tdep.c: Remove all uses of use_unwind and `set use_unwind'
- command. Now we use unwind info by default if we can find it.
-
- * config/sparc: Move VARIABLES_INSIDE_BLOCK and SUN_FIXED_LBRAC_BUG
- to tm-sparc.h so they are shared between Solaris and SunOS4.
- * dbxread.c (process_one_symbol): Deal with SunOS4 acc N_STSYM and
- N_GSYM functions.
-
- * config/pa/tm-hppa.h (REGISTER_NAMES): Use "fr" rather than "fp"
- for floating point registers.
-
- * mipsread.c (parse_symbol): Put stStaticProc symbols in minimal
- symbols as mst_file_text.
-
- * hppa-tdep.c (pc_in_linker_stub): Return 0 if can't read memory.
-
- * stabsread.c (rs6000_builtin_type): Make logical types be
- TYPE_CODE_BOOL.
-
-Sun Jul 25 23:41:48 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.{c,h} (struct breakpoint): Replace symtab field with
- source_file field.
-
-Fri Jul 23 09:57:25 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * remote.c: Don't error() on errors xferring memory.
- * target.h: Clean up comments about *xfer_memory.
-
- * exec.c, corelow.c (target_ops struct): Don't allow
- {insert,remove}_breakpoints to be defaulted to
- memory_{insert_remove}_breakpoint.
-
- * demangle.c: Make it so `help set dem' tells you how to get the
- list of demangling styles.
-
-Thu Jul 22 15:41:09 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * Makefile.in: Use REMOTE_O macro not remote.o.
- * config/i960/{nindy960,vxworks960}: Don't use remote.o.
-
-Thu Jul 22 12:43:25 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * coredep.c: If NEED_SYS_CORE_H defined, include <sys/core.h>
- (can't include it in nm-*.h file because it causes conflicts with
- a.out symbol definitions).
- * hp300ux-nat.c (fetch_core_registers): Commented out; obsolete.
- * config/m68k/hp300hpux.mh (NATDEPFILES): Added coredep.o and
- corelow.o.
- * config/m68k/nm-hp300hpux.h (NEED_SYS_CORE_H): Defined.
- (REGISTER_U_ADDR): Defined.
- * config/m68k/xm-hp300hpux.h (HAVE_TERMIOS): Define instead of
- HAVE_TERMIO.
- * config/pa/xm-hppah.h: Likewise.
-
-Wed Jul 21 11:37:30 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * mipsread.c (parse_symbol): when stTypedef and friends occur within
- an stBlock, skip over the fields of the inner one.
-
- * mips-tdep.c (init_extra_frame_info): If in lenient prologue, call
- heuristic_proc_desc rather than just assuming registers not saved.
-
- * Makefile.in (regex.o): Add dependency.
-
- * hppa{b,h}-nat.c: Warning, not error, if can't access registers.
-
- * config/pa/hppa{b,h}.h: Define ATTACH_DETACH.
-
-Wed Jul 21 03:07:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/mips/xm-makeva.h: New file implements va_list alignment
- restrictions for mips hosts.
- * config/mips/{xm-irix3.h, xm-mips.h, xm-news-mips.h, xm-riscos.h}:
- Use it.
-
-Wed Jul 21 00:11:05 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mips-tdep.c (init_extra_frame_info): Do not check for
- mips_in_lenient_prologue if it is a dummy frame.
- * mipsread.c (fixup_sigtramp): Initialize pdr.adr, it is used by
- mips_in_lenient_prologue.
-
-Tue Jul 20 14:14:59 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (read_hp_array_type): Handle "char foo[]".
-
-Tue Jul 20 12:53:47 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * mips-tdep.c (heuristic_proc_start): First time we print the
- warning, elaborate.
- (_initialize_mips_tdep): Improve docstring for `set heur'.
-
- * config/rs6000/tm-rs6000.h: Remove call to insert_step_breakpoint.
-
- * symtab.c (find_line_symtab): New function, to deal with multiple
- symtabs with the same name.
- (find_line_pc{,_range}): Use it.
- (find_pc_symtab): Add comment about overlapping symtabs.
-
-Mon Jul 19 21:29:14 1993 Fred Fish (fnf@deneb.cygnus.com)
-
- * Makefile.in (SFILES): Add nlmread.c.
- * Makefile.in (OBS): Add nlmread.o.
- * Makefile.in (nlmread.o): Add new target.
- * configure.in (i[34]86-*-netware): New configuration.
- * nlmread.c, config/i386/{i386nw.mt, tm-i386nw.h}: New files
- for NLM/NetWare support.
-
-Mon Jul 19 11:48:57 1993 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * symtab.h (enum minimal_symbol_type): Add mst_file_*.
- * partial-stab.h [DBXREAD_ONLY]: Record statics in miminal symbols.
- * dbxread.c (record_minimal_symbol): Deal with statics.
- * minsyms.c (lookup_minimal_symbol): Prefer externals to statics.
-
- * config/i386/xm-i386sco.h: Define HAVE_TERMIOS.
-
- * printcmd.c, config/pa/xm-pa.h, config/alpha/xm-alpha.h: Make it so
- arg_bytes field of makeva_list is always aligned.
- * config/pa/xm-pa.h: Make arglist_address a char *.
-
- * ser-unix.c: Don't try to use job control with termio.
-
-Sun Jul 18 23:11:28 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
- and Jim Kingdon (kingdon@cygnus.com)
-
- Make breakpoint_re_set_one work with overloaded member functions,
- `b 123' and `b foo' if foo is a static function.
- * symtab.c (decode_line_1, decode_line_2): New argument `canonical'
- to return canonical line specs if requested by the caller.
- * breakpoint.c, source.c, symtab.c, symtab.h: Change prototypes and
- callers accordingly.
- * symtab.c (build_canonical_line_spec): New helper function which
- constructs the canonical line spec.
- * breakpoint.c (break_command_1): Use canonical line spec instead
- of command string as addr_string if necessary.
- * source.c (line_info): Fix storage leak.
-
-Sun Jul 18 15:22:45 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
-
- * infptrace.c: Split out define of PT_KILL; Sequent defines PT_KILL
- but not the others.
- * symm-tdep.c: Remove exec_file_command.
- [_SEQUENT_] (ptx_coff_regno_to_gdb, register_addr): New functions.
- A few miscellaneous cleanups.
- * symm-nat.c: Renamed from symm-xdep.c.
- * All symmetry dependent files: Many changes.
-
- * mips-tdep.c (mips_skip_prologue): New argument lenient.
- Use read_memory_nobpt.
- (is_delayed, mips_in_lenient_prologue): New functions.
- (init_extra_frame_info): If in the prologue, don't use saved registers.
- * config/mips/tm-mips.h: Declare mips_skip_prologue.
-
- * partial-stab.h (N_SO): Add the text offset to valu before, not after,
- passing it to END_PSYMTAB.
-
-Fri Jul 16 18:48:52 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
-
- * symtab.c (find_pc_symtab): Call warning, not printf directly.
-
- * solib.c (solib_add): Use x{re,m}alloc, not {re,m}alloc.
-
-Fri Jul 16 09:56:42 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mipsread.c: No longer need to undefine ZMAGIC.
-
-Thu Jul 15 18:03:37 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * m88k-pinsn.c: Moved code into opcodes/m88k-dis.c.
- (print_insn): Now just calls print_insn_m88k.
-
-Thu Jul 15 14:54:05 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * h8300-tdep.c (examine_prologue): Make prototype match definition.
-
-Thu Jul 15 08:34:49 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * NEWS: Mention that remote.c now has a `load' operation.
-
- * hppa-tdep.c (pc_in_linker_stub): New function.
- (find_proc_framesize): Return 0 for linker stubs.
- (rp_saved): Tell the caller where rp is saved.
- (frame_chain_valid): Return 1 for linker stubs.
- (frame_saved_pc): Use return value from rp_saved.
-
- * stack.c (print_frame_info): When checking PC_IN_CALL_DUMMY,
- pass the sp relative to the frame in question, not the sp in the
- innermost frame.
-
-Wed Jul 14 17:37:03 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * mipsread.c (parse_procedure): Take as argument the symtab to look
- the name up in. Look it up with mylookup_symbol, not lookup_symbol.
- (psymtab_to_symtab_1): For stabs, pass the symtab to parse_procedure.
-
- * mipsread.c (mylookup_symbol): Use strcmp, not STREQ, as we have
- already checked the first characters.
-
- Changes from Jeffrey Law:
- * printcmd.c (makeva_list): Use MAKEVA_EXTRA_INFO to define
- machine dependent fields in the makeva_list structure.
- (makeva_size): Allocate extra space to handle gaps made by
- alignment restrictions.
- * config/pa/xm-pa.h (MAKEVA_EXTRA_INFO): Define.
- (MAKEVA_START): Initialize arglist_address field.
- (MAKEVA_ARG): Always store arguments on natural alignment
- boundaries. Set arglist_address to the address right after
- the args.
- (MAKEVA_END): Simply return the value stored in arglist_address.
-
-Wed Jul 14 13:51:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * ch-valprint.c (chill_val_print, case TYPE_CODE_STRING): Print
- address, not addr.
-
- * hppah-nat.c (store_inferior_registers): Don't print i in cases
- where we aren't using it.
-
- * a29k-tdep.c (get_saved_register): Fix typo.
-
-Wed Jul 14 09:45:52 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * configure.in: Recognize h8300h (variant of h8300).
-
-Wed Jul 14 09:45:52 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * configure.in: Recognize sparc64-*-*.
-
-Tue Jul 13 14:03:48 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (define_symbol): Make the caddr_t hack apply to `function
- returning foo' as well as `pointer to foo'.
-
- * remote.c [REMOTE_BREAKPOINT]: Use for breakpoint insn if defined.
- * config/m68k/tm-m68k.h: Define it.
- * mem-break.c, breakpoint.c: Improve comments.
-
-Tue Jul 13 13:35:31 1993 Frederic Pierresteguy (F.Pierresteguy@frcl.bull.fr)
-
- * config/m68k/tm-dpx2.h: Replace "tm-68k.h" with "m68k/tm-m68k.h".
- * config/m68k/xm-dpx2.h: Define HAVE_TERMIOS not HAVE_TERMIO.
-
-Tue Jul 13 11:50:38 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * gdbcore.h (read_memory_integer, read_memory_unsigned_integer):
- Make prototype match definition.
-
-Tue Jul 13 11:15:15 1993 Fred Fish (fnf@cygnus.com)
-
- * elfread.c: Remove notice about file still being under
- construction.
- * Makefile.in (ultra3-xdep.o, umax-xdep.o): Add missing ')'.
-
-Mon Jul 12 17:46:35 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * a29k-tdep.c (read_register_stack): Make val static.
-
-Mon Jul 12 14:10:48 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * config/h8300/tm-h8300.h (REGISTER_CONVERTIBLE): Change value to 0.
- (REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW): Move def'n to
- usual spot.
-
-Mon Jul 12 11:29:44 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * c-valprint.c (c_val_print): Fix thinko with unspecified length
- arrays.
-
- * hppa-tdep.c (find_proc_framesize): If there is a frame pointer,
- use it.
-
-Sun Jul 11 19:35:05 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.c (decode_line_1): Use end of block to figure out whether
- val.end is in the same function, not minimal symbols.
-
- * source.c (line_info): Add a few more wrap_here's.
-
- * i386-tdep.c (i386_follow_jump): Do byteswapping where needed and
- don't make assumptions about sizes of host data types.
-
- * blockframe.c, symtab.h (find_pc_partial_function): New arg endaddr.
- * infrun.c, breakpoint.c, printcmd.c: Change callers.
- * printcmd.c (containing_function_bounds): Remove.
- * printcmd.c (disassemble_command): Use find_pc_partial_function,
- not containing_function_bounds.
- * infcmd.c (step_1): Use find_pc_partial_function rather than
- trying to roll our own. Move check for a pc between SIGTRAMP_START and
- SIGTRAMP_END in find_pc_partial_function, not step_1.
-
- * sparc-tdep.c (sparc_frame_chain, frame_saved_pc):
- Keep unswapped value in array of char, not REGISTER_TYPE.
- Use REGISTER_RAW_SIZE not sizeof (REGISTER_TYPE).
- (sparc_extract_struct_value_address): Use TARGET_PTR_BIT not
- sizeof (CORE_ADDR).
-
-Thu Jul 1 15:50:05 1993 Frederic Pierresteguy (F.Pierresteguy@frcl.bull.fr)
-
- * configure.in (m68*-bull-sysv*): added support for Bull dpx2.
- * config/m68k/{t,x,n}m-dpx2.h, dpx2-nat.c: New files.
- * config/m68k/dpx2.m{h,t}: New files.
-
-Thu Jul 1 15:46:10 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Run through gnu-indent.
-
-Sun Jul 11 12:32:08 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * config/sparc/tm-sparc.h (PRINT_REGISTER_HOOK): Fix typo, add
- more parens around macro arg.
-
-Sat Jul 10 09:54:17 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c: Remove step_resume_{duplicate,shadow}. Replace
- step_resume_break_address with step_resume_breakpoint (now local
- to wait_for_inferior).
- ({insert,remove}_step_breakpoint): Remove.
- (wait_for_inferior): Set step resume break with
- set_momentary_breakpoint. Test hitting it with bpstat_stop_status
- and bpstat_what (stop_step_resume_break removed).
- * breakpoint.{h,c}, infrun.c: Return value from bpstat_what now struct
- which includes previous return value as main_action, and a step_resume
- bit.
- * breakpoint.c (delete_breakpoint): If breakpoint was inserted, and
- there is another breakpoint there, insert it.
- * infrun.c (wait_for_inferior): Rearrange the spaghetti a bit. Use
- a few more gotos.
- Various: Clean up and add comments.
-
- * infrun.c [TDESC]: Remove remaining tdesc code (see ChangeLog
- for Wed Nov 13 16:45:13 1991).
-
-Fri Jul 9 12:36:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * values.c, value.h (modify_field), callers: Make fieldval a LONGEST.
-
- * h8300-tdep.c (NEXT_PROLOGUE_INSN): Make pword1 an INSN_WORD *
- not short *.
-
- * findvar.c, defs.h
- ({extract,store}_{signed_integer,unsigned_integer,address}):
- New routines to replace SWAP_TARGET_AND_HOST.
- All over: All uses of SWAP_TARGET_AND_HOST on integers replaced.
-
- * config/sparc/tm-sparc.h: Add comment suggesting that removing
- ins and locals from the registers array might clean things up.
-
- * utils.c: Clean up comments about wrap buffer and wrap_here.
- * printcmd.c (printf_command): Call wrap_here before vprintf.
-
- * mipsread.c (cross_ref): Set the name to unknown for "struct *" case.
- Patch from ptf@delcam.co.uk (Paul Flinders).
-
- * a29k-tdep.c, findvar.c (get_saved_register): Fix byteswapping sins.
-
-Fri Jul 9 09:47:02 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * defs.h, remote-eb.c (TM_FILE_OVERRIDE): Remove it.
- * mips-tdep.c (init_extra_frame_info): Set proper fci->frame if pc
- is at the start of the dummy code.
-
-Thu Jul 8 14:48:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * sparc-tdep.c (sparc_push_dummy_frame): Skip all the do_save_insn
- stuff, just write the sp and fp.
- (sparc_pop_frame): Skip the do_restore_insn; we already restore
- the sp with the other out registers.
-
- * hppa-tdep.c (hppa_push_arguments): Allocate enough space for
- arguments.
-
- * hppa-tdep.c: Change _initialize_hppab_tdep to _initialize_hppa_tdep.
-
-Thu Jul 8 14:47:00 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * sparc-tdep.c (sparc_frame_chain): Handle sizeof (CORE_ADDR)
- != sizeof (REGISTER_TYPE).
- (frame_saved_pc): Ditto.
-
-Thu Jul 8 08:22:05 1993 Doug Evans (dje@canuck.cygnus.com)
-
- * config/h8300/tm-h8300.h: (REGISTER_TYPES): Adjust for h8/300h.
- (REGISTER_RAW_SIZE): Ditto.
- (REGISTER_VIRTUAL_TYPE): Use builtin_type_unsigned_long for regs
- on the h8/300h (ints may still be 16 bits).
- (EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE,
- EXTRACT_STRUCT_VALUE_ADDRESS): Add FIXME's for h8/300h. Some
- thought needed here.
-
- * h8300-tdep.c (print_insn): Call print_insn_h8300h if h8/300h.
- (examine_prologue): reg_save_depth is 4 if h8/300h.
-
- * findvar.c (read_register): Provide some support for 64 bit regs.
- (write_register): Ditto.
-
-Wed Jul 7 14:30:00 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/mips/nm-riscos.h: machine/machparam.h is always the right
- place to look for BSD43_NBPG, not machine/vmparam.h
-
- * infcmd.c (run_stack_dummy): New argument name.
- Change error message in (another) attempt to make it comprehensible.
- * valops.c (call_function_by_hand): Pass name to run_stack_dummy.
- * symtab.h: Declare demangle and asm_demangle since macros use them.
-
- * eval.c (evaluate_subexp): Add comment about calling a member
- function of a variable in a register.
-
- * expression.h: Clean up comment about string in STRUCT_STRUCT etc.
-
- * config/{rs6000/tm-rs6000.h,sparc/tm-sparc.h,pyr/tm-pyr.h},
- inferior.h (PC_IN_CALL_DUMMY) [ON_STACK]: Add comments about stack
- frame tops and bottoms.
-
- * frame.h, blockframe.c, stack.c, a29k-tdep.c,
- config/gould/tmp-{pn,np1}.h,
- config/{sparc/tm-sparc.h,pyr/tm-pyr.h,vax/tm-vax.h}: Remove field
- next_frame from struct frame_info. It has no purpose beyond
- ->next->frame and is an artifact from GDB 2.8.
-
-Tue Jul 6 11:51:18 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in: Remove gdb before creating a new one.
- Update init.c atomically.
-
- * Makefile.in (ALLPARAM): Add config/{alpha/xm-alpha.h,pa/xm-pa.h}.
- (ALLCONFIG): Add config/alpha/alpha-osf1.mh.
-
- * infcmd.c (_initialize_infcmd): In docstring for "continue",
- describe argument as setting ignore count.
-
-Sun Jul 4 15:04:47 1993 Doug Evans (dje@cygnus.com)
-
- * h8300-tdep.c (examine_prologue): Fix call to
- read_memory_unsigned_integer.
-
-Fri Jul 2 18:22:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/mips/{x,n}m-irix{3,4}.h: Make some definitions here
- rather than including xm-bigmips.h.
-
- * eval.c (evaluate_subexp): Improve error messages for OP_TYPE and
- default cases.
-
- * Makefile.in (distclean): Remove y.tab.h.
-
-Fri Jul 2 14:55:48 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * exec.c (exec_file_command): Remove Mar 28 hack as BFD handles
- file updates properly now.
- * mipsread.c (mips_coff_new_init): Force reevaluation of sigtramp
- addresses if switching to a new symbol file.
- * dbxread.c (process_one_symbol): Avoid dereferencing NULL
- symbols that might be returned from define_symbol.
-
-Fri Jul 2 13:33:12 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
-
- New target macros for getting at the pc, sp and fp.
- * infcmd.c (read_pc, write_pc): Modify to use new macros.
- (read_sp, write_sp, read_fp, write_fp): New functions.
- * blockframe.c (reinit_frame_cache, get_prev_frame_info):
- Use new functions.
- * breakpoint.c (bpstat_alloc): ditto.
- * infrun.c (wait_for_inferior): ditto.
- * stack.c (print_frame_info): ditto.
- * valops (call_function_by_hand): ditto.
- * corelow.c (core_open): ditto.
- * h8500-tdep.c: (target_read_sp, target_write_sp, target_read_pc,
- target_write_pc, target_read_fp, target_write_fp): New functions.
- * inferior.h (read_sp, write_sp, read_fp, write_fp): Prototypes.
-
- * config/alpha/xm-alpha.h: Add MAKEVA_END.
- * config/h8500/tm-h8500.h: Define new macros.
-
-Fri Jul 2 13:51:04 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure.in (mipos-*-riscos*): New host and target; use riscos.
- * config/mips/nm-riscos.h: If BSD43_NBPG is not defined by
- vmparam.h, include machparam.h.
- (KERNEL_U_ADDR): Define to be BSD43_UADDR.
-
-Fri Jul 2 13:39:48 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * c-exp.y (yylex): Give error if unmatched single quote.
-
- * configure.in, config/m68k/*delta68*, delta68-nat.c: New port.
-
- * Remove unused STACK_END_ADDR in the following files (in other
- files it is used for something): tm-mips.h, tm-sun2.h, tm-news.h,
- tm-a29k, tm-i386v.h, tm-hppa.h, tm-nindy960.h, tm-amix.h,
- tm-hp300hpux.h, tm-isi.h.
-
-Thu Jul 1 09:51:27 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * config/mips/nm-riscos.h: Define NBPG and UPAGES.
- config/mips/xm-riscos.h: Include <sys/types.h>.
-
- * ser-unix.c (hardwire_noflush_set_tty_state): Use an assignment,
- not an initializer, to copy the structure.
-
- * gdbtypes.h (struct type): Add field tag_name.
- * gdbtypes.c (type_name_no_tag), c-typeprint.c (c_type_print_base):
- Use it.
- * {coff,dwarf,mips,stabs}read.c: Set it.
-
- * xm-sysv4.h: Undefine HAVE_TERMIO.
-
- * config/mips/nm-riscos.h: Remove unmatched #endif.
- Define FETCH_INFERIOR_REGISTERS.
- * config/mips/riscos.mh: Don't include coredep.o; mips-nat.o is enough.
- Fix misspelling of NAT_FILE.
- * mips-nat.c (fetch_core_registers): If KERNEL_U_ADDR is not defined,
- we can still process "modern" core files.
-
- * ser-unix.c (hardwire_print_tty_state) [HAVE_TERMIOS]: Don't
- print c_line.
- (_initialize_ser_hardwire): Just check whether _POSIX_JOB_CONTROL
- is defined; don't care what it is defined to.
-
-Wed Jun 30 20:06:46 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/vax/xm-vaxult2.h: Define FD_SET and FD_ZERO.
-
-Tue Jun 29 11:02:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * inftarg.c: Remove unused include of terminal.h.
- * signals.h: Don't undefine signals anymore.
- * main.c: Use job_control from serial.h.
- * fork-child.c (fork_inferior): Use gdb_setpgid.
- * serial.h, ser-unix.c, ser-go32.c: Provide gdb_setpgid.
- * utils.c (quit): Use current_target->to_terminal_ours to figure
- out whether we care about lack of job control, rather than __GO32__.
- * utils.c: Include serial.h not terminal.h
- (quit): Use job_control not TIOCGPGRP.
- * terminal.h: Don't undefine TIOCGPGRP.
- * serial.h, ser-unix.c, ser-go32.c, ser-tcp.c: Add SERIAL_FLUSH_OUTPUT.
- * utils.c (quit): Use it.
- * serial.h: Add SERIAL_UN_FDOPEN.
- * utils.c (quit): Use it.
- * ser-unix.c: Add process group to ttystate.
- [HAVE_SGTTY]: Add tchars, ltchars, and lmode to ttystate.
- * inflow.c: Include serial.h not terminal.h.
- Use serial.h stuff to replace most of the maze of #ifdef's.
- * inflow.c, main.c, inferior.h: make gdb_has_a_terminal a function.
- * serial.h: Document SERIAL_SET_TTY_STATE as being immediate.
- * ser-unix.c: Use TIOCSETN not TIOCSETP so it is true.
- * serial.h, ser-unix.c, ser-go32.c, ser-tcp.c:
- Add SERIAL_PRINT_TTY_STATE, SERIAL_NOFLUSH_SET_TTY_STATE, and
- SERIAL_SET_PROCESS_GROUP.
- * inflow.c: Use them.
- * config/xm-svr4.h, config/rs6000/xm-rs6000.h, config/sparc/sun4os4.h:
- Define HAVE_TERMIOS.
- * Various: Remove all use of TIOC*_BROKEN.
-
-Wed Jun 30 12:20:51 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/m68k/tm-sun3.h (BELIEVE_PCC_PROMOTION_TYPE): Define.
-
-Tue Jun 29 13:44:41 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * target.h (target_detach): Turn macro into function.
- * target.c (target_detach): Define it, do deferred register stores
- before calling the real target function.
-
-Tue Jun 29 13:15:42 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
- and Jim Kingdon (kingdon@cygnus.com)
-
- * symtab.h (BLOCK_SHOULD_SORT): Do not sort blocks corresponding to
- a function to avoid printing of function arguments in wrong order
- due to sorting.
- * symfile.c (compare_symbols): Remove code for sorting arguments
- as blocks containing arguments are no longer sorted.
- * symtab.c (lookup_block_symbol): Update comment accordingly.
-
-Tue Jun 29 11:02:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/pa/tm-hppa.h: Remove unused ARGS_GROW_DOC.
- (REG_STRUCT_HAS_ADDR): Add comment.
-
- * infrun.c (wait_for_inferior): Use find_pc_line not find_pc_symtab
- to check whether there is line number information.
-
-Tue Jun 29 08:29:17 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * remote-udi.c: Fix docstring so that it compiles.
-
- * remote-mips.c, remote-nindy.c: move bfd.h before symfile.h
- (for file_ptr).
-
-Tue Jun 29 09:11:27 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dbxread.c (process_one_symbol): If we find a LOC_BLOCK where we
- don't expect it, change it to LOC_STATIC so at least we don't coredump.
-
- * c-typeprint.c (c_type_print_base): Don't error() on invalid type.
-
- * symtab.h: Add comments about line numbers.
- * source.c (identify_source_line): Fix off by one bug with line.
-
-Mon Jun 28 19:00:21 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Do not include libhppax. Instead include libhppa.h
- and hpux-symtab.h. Misc indention fixes.
- (find_unwind_entry): Add PARAM prototype.
- (read_hpux_symtab): More fixes for names and sizes of structs,
- unions, enums, typedefs, and tagdefs.
- (read_hp_enum_type, read_hp_struct_type): Likewise.
- (read_hp_set_type, read_hp_subrange_type): Likewise.
- (hp_type_lookup, process_one_debug_symbol): Likewise.
- (process_one_debug_symbol): Search forward from the K_FUNCTION for
- the first K_BEGIN when setting the line number associated with a
- function. Avoid unnecessary calls to savestring.
- (hp_alloc_type): Initialize TYPE_CPLUS_SPECIFIC here. Remove
- most cases where we set it elsewhere.
- (hppa_sym_fns): Use "hppa" instead of hppax since hpread.c and
- paread.c use the same BFD backend now. All references changed.
- (hpux_symfile_init): Allocate space to hold the debugging section
- contents on the symbol obstack.
-
-Mon Jun 28 10:09:08 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (makeva*): New interface, for making a va_list.
- (printf_command): Use it.
- * config/m88k/xm-delta88.h: Remove VPRINTF define, not needed.
- * config/pa/xm-pa.h: New file.
- * config/pa/xm-hppa{b,h}.h: Include it.
-
- * xcoffread.c: Remove obsolete NO_TYPEDEFS comment.
-
-Sun Jun 27 08:54:55 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * valprint.c (val_print_type_code_int): Fix off by one error with
- eliminating leading zeroes for large little endian integers.
-
-Sun Jun 27 08:58:56 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/mips/riscos.mh (CC): Use -systype sysv.
-
- * ser-unix.c: Move #include of <sys/time.h> to HAVE_SGTTY section.
-
- * Makefile.in (ALLPARAM): Add config/mips/{x,n}-{news-mips,riscos}.h.
-
-Fri Jun 25 11:22:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/m68k/tm-m68k.h: Remove obsolete comment about duplicating
- CALL_DUMMY between different 68k machines.
-
-Fri Jun 25 17:02:45 1993 Stu Grossman (grossman at cygnus.com)
-
- * gdbserver/Makefile.in: Add dependancies on server.h.
- * gdbserver/remote-gutils.c: Remove lots of unused functions and
- variables.
- * gdbserver/remote-inflow.c: Remove lots of unused variables and
- #includes. Also, use PTRACE_* symbols instead of constants.
- (mywait): Surround calls to wait() with enable/disable_async_io()
- so that we can be interrupted from GDB while waiting for the
- child. Also, handle child exit more gracefully.
- * gdbserver/remote-server.c: Remove lots of unused variables.
- Move all extern defs into server.h. Redo main loop so that
- failure from getpkt() causes communications to be re-established.
- Fix 'k' command so that it restarts the child.
- * gdbserver/remote-utils.c: Remove lots of unloved vars and
- subrs. Move many extern decls into server.h. (remote_open): For
- tcp, seperate usage of proto fd from connected fd. Close proto
- fd after getting connection. (putpkt/getpkt): Pay attention to
- errors when reading/writing. Report these to the caller. New
- routines input_interrupt/enable_async_io/disable_async_io to make
- it possible to get an I/O interrupt when data arrives from the
- comm link.
- * serial.h: New file to contain common defs for all remote files.
-
-Fri Jun 25 17:02:45 1993 Stu Grossman (grossman at cygnus.com)
-
- * remote.c: Add arg names to prototypes, in a modest effort at
- clarification. Also add prototypes for some new functions.
- * (remote_wait): Better error reporting for 'T' responses.
- * ser-go32.c (strncasecmp): Make str1 & str2 be const.
- * (dos_async_init): Make usage message reflect requested port #.
- * ser-tcp.c (tcp_open): Terminate hostname properly to prevent
- random hostname lookup failures. Add nicer message for unknown
- host error. (wait_for): Wake up in case of exceptions. Also,
- restart select() if we got EINTR.
- * ser-unix.c (wait_for): Restart select() if we got EINTR.
- * serial.c: (serial_close): Clean up code.
-
-Fri Jun 25 11:22:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/m68k/tm-m68k.h: Remove obsolete comment about duplicating
- CALL_DUMMY between different 68k machines.
-
-Fri Jun 25 11:22:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (*.tab.c): Use ./c-exp.tab.c not just c-exp.tab.c.
- Make comment explaining this comprehensible.
- (TAGFILES): Include ALLDEPFILES.
- (ALLDEPFILES): udi2soc.c and udr.c are in 29k-share/udi, not
- 29k-share/udi/udi.
- (update-alldeps): Remove; obsolete.
-
- * remote.c: Move comments regarding packets to top of file with the
- rest of the protocol comments.
- Fix incorrect description of 'T' response.
-
- * README (Reporting Bugs): Refer people to the GDB manual.
-
- * c-valprint.c (c_val_print): Handle TYPE_CODE_BOOLEAN.
- * stabsread.c: Type -16 is 4 bytes.
-
- * remote-udi.c: Improve docstring.
-
-Fri Jun 25 11:16:31 1993 Fred Fish (fnf@cygnus.com)
-
- * elfread.c (elf_symfile_read): Call bfd_elf_find_section, not
- bfd_elf32_find_section, to track bfd changes.
-
-Fri Jun 25 11:22:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/mips/riscos.mh (REGEX{,1}, MUNCH_DEFINE, MH_CFLAGS): Define.
- * config/mips/xm-riscos.h: Define USG.
-
-Thu Jun 24 14:52:45 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c (filename_completer): Don't complete to files ending in ~.
-
- * NEWS: Mention filename completion and "info line" enhancements.
-
- * main.c (symbol_completion_function): On "info t foo", return NULL,
- don't error().
-
- * main.c (symbol_completion_function): Don't use readline word
- breaking. Use new calling convention for c->completer and
- complete_on_cmdlist.
- * command.h (struct command): Change arguments; now the text passed
- to completer does not have any word breaking done. New arg word.
- * symtab.{c,h} (make_symbol_completion_list): Do word breaking. Take
- word argument.
- * {main.c,gdbcmd.h} ({filename,noop}_completer): Take word argument.
- * command.{c,h} (complete_on_cmdlist): Take word argument.
-
- * command.c (lookup_cmd_1): Doc fix.
-
-Thu Jun 24 13:26:04 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * Makefile.in (OP_INCLUDE): define.
- (OPCODE_CFLAGS): use OP_INCLUDE.
-
- * config/i386/ncr3000.mh, config/i386/i386v4.mh,
- config/i386/i386sol2.mh, config/m68k/hp300hpux.mh,
- config/m68k/amix.mh, config/mips/irix[34].mh,
- config/m88k/delta88.mh, config/sparc/sun4sol2.mh (ALLOCA,
- ALLOCA1): macros removed.
-
- * config/mips/decstation.mh, config/rs6000/rs6000.mh
- (MMALLOC_LIB): renamed to MMALLOC.
-
-Wed Jun 23 00:25:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * partial-stab.h: Consolidate case statements for N_LSYM and N_FUN.
- * dbxread.c: Change comment regarding acc.
-
-Wed Jun 23 16:33:36 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Document a few functions, misc cleanups. Update
- copyright to reflect the first "release" of this file.
- (struct hpux_symfile_info): Delete unneeded fields. Keep pointers
- to the contents of the debug sections rather than offsets within
- the file itself. Corresponding changes to the accessor macros.
- (sl_symbol_size, slt_symbuf): Delete unneeded global variables.
- (slt_symbuf_start, slt_symbuf_end, lntt_symbuf): Likewise.
- (lntt_symbuf_start, lntt_symbuf_end, gntt_symbuf): Likewise.
- (gntt_symbuf_start, gntt_symbuf_end): Likewise.
- (fill_slt_symbuf, fill_lntt_symbuf): Delete unneeded functions.
- (fill_gntt_symbuf): Likewise.
- (get_lntt, get_gntt, get_slt): Simplify.
- (hpux_symfile_init): Read and store the contents of the debugging
- sections. Do error checking on memory allocation and BFD calls.
- (read_hpux_symtab): Delete KERNELDEBUG crud. Ignore debug symbols
- which are not needed for building partial symbol tables. Handle
- K_CONST, K_TYPEDEF, and K_TAGDEF just like K_SVAR and K_DVAR.
- (read_ofile_symtab): Delete useless processing_gcc_compilation stuff.
- (read_hp_struct_type): Initialize TYPE_CPLUS_SPECIFIC.
- (read_hp_set_type, read_hp_array_type): Likewise.
- (read_hp_subrange_type, hp_type_lookup): Likewise.
-
-Wed Jun 23 15:04:54 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- Makefile overhaul dropping autodepend features.
- * Makefile.in: many comment changes. forced consistent use of $()
- for makefile variables references. dropped leading ./ in file
- references. Drop $(srcdir)/ prefix on all dependencies.
- Inserted contents of alldeps.mak and depend.
- (INCLUDE_CFLAGS): defined as new macro for getting libiberty's
- include directory into the compilation line.
- (GDB_CFLAGS): new macro to take up the semantic previously held
- by INCLUDE_CFLAGS.
- (LIBIBERTY): dropped ancient subdir macro. I last removed this
- macro in feb of '92. How does it keep coming back?
- (MMALLOC_LIB): renamed to MMALLOC.
- (BFD_SRC_DIR): renamed to BFD_SRC.
- (BFD_OBJ_DIR): renamed to BFD_DIR.
- (BFD_LIB): renamed to BFD.
- (BFD_INCLUDES): renamed to BFD_CFLAGS.
- (READLINE_DIR): now represents object directory.
- (RL_LIB): renamed to READLINE.
- (READLINE_SRC, READLINE_CFLAGS, OPCODES, OPCODES_CFLAGS): new
- macros.
- (INTERNAL_CFLAGS): added GDB_CFLAGS, OPCODES_CFLAGS,
- READLINE_CFLAGS, BFD_CFLAGS. Dropped USER_CFLAGS.
- (LDFLAGS): removed default assignment.
- (TEXIDIR, INCLUDE_DEP, MMALLOC_DIR, MMALLOC_DEP, BFD_DEP,
- READLINE_DEP, LIBIBERTY_DIR, TESTS, depend, STAGESTUFF): unused, so removed.
- (ALLOCA1, ALLOCA): removed all references. alloca is now in
- libiberty.
- (VERSION): unilaterally and arbitrarily bumped to 4.9.3.
- (SFILES, NONSRC, HFILES, ALLDEPFILES, ALLPARAM, ALLCONFIG):
- removed all $(srcdir) prefixes.
- (getopt_h, ieee-float_h, bfd_h, wait_h, dis-asm_h): new macros
- for potential dependencies. commented out by default.
- (readline_headers, udiheaders): convenient abbreviations.
- (gdbcore_h, frame_h, symtab_h, gdbtypes_h, expression_h,
- value_h, breakpoint_h, command_h, gdbcmd_h, defs_h, inferior_h):
- new macros used for header file dependencies.
- (install-info, clean-info): collapse into the info rule.
- (install): now depends on all.
- (install-only): new target for installing without depending on
- all.
- (uninstall): new target.
- (config-check, config-check-hosts, config-check-targets): added
- fixme comments.
- (ch-exp.tab.c, m2-exp.tab.c): added artificial dependencies in
- order to force parallel makes into keeping these rules separate.
- * configure.in: omit cat'ing depend file onto generated Makefile.
- * alldeps.mak, depend: removed.
-
- * inferior.h: remove redundant include of symtab.h which is
- included in value.h via breakpoint.h.
-
- * alloca.c: removed. alloca is now in libiberty.
-
- * config/m88k/delta88.mh, config/ns32k/merlin.mh (M_UNINSTALL):
- new macro to undo what M_INSTALL does.
-
-Wed Jun 23 00:25:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/ns32k/{merlin.mh,xm-merlin.h}: Be consistent about name
- of gdb-sh.
-
- * dbxread.c (copy_pending): Change name and function of begi argument
- to endi, since that is what the caller needs.
-
- * Makefile.in (TAGFILES): Don't include YYFILES.
-
- * Makefile.in (HFILES): Include monitor.h.
-
- * Makefile.in: Include text that used to be in alldeps.mak.
- Remove config/mips/{bigmips.mh,xm-bigmips} from it.
- * Makefile.in, configure.in: Remove all traces of alldeps.mak.
-
- * main.c (main): Print help message on stdout not stderr
- per standards.texi.
- New option --version per standards.texi.
- In help message, show long options with "--" not "-".
- Don't try to print help message or version until after we have
- called initialize_all_files.
-
-Tue Jun 22 11:03:13 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Delete useless #if 1 statements.
- (hp_type_translate): Use T_LONG, T_UNS_LONG, and T_DOUBLE instead
- of magic integers. Fix handling for T_UNS_INT. Abort if the type
- passed in is not an "immediate" type.
- (read_hp_enum_type): Properly compute the size of the type.
- (read_hp_array_type): Likewise.
- (hp_type_lookup): Prefix the names of structs, unions and enums
- with "struct", "union", and "enum" as appropriate.
-
-Tue Jun 22 03:15:38 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * solib.c (solib_add_common_symbols): Don't call lookup_minimal_symbol.
- (solib_add): Call special_symbol_handling once, not once per library.
-
- * procfs.c (procfs_resume): Don't pass a SIGTSTP whose action
- is SIG_DFL.
-
- * procfs.c (procfs_resume): Skip the unnecessary PRSVADDR on all
- systems, not just Solaris.
-
- * stabsread.c: Include <ctype.h>.
-
-Mon Jun 21 16:09:46 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * fork-child.c (fork_inferior): Quote exec_file so it can contain
- funky characters.
-
-Mon Jun 21 16:56:47 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (INCLUDE_CFLAGS): Add BFD_INCLUDES for now, since
- bfd.h is included by target.h, which most of gdb includes.
- * depend: Hand remove BFD_INCLUDES from ${CC} lines, now that
- it's in INCLUDE_CFLAGS.
-
-Mon Jun 21 16:09:46 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * config/i386/*aix*, i386aix-nat.c: New files.
- * configure.in: Use them.
- * alldeps.mak: List them.
- * coffread.c (decode_base_type): Deal with anonymous enum type.
- * i387-tdep.c (print_387_status_word): Add comment re "top".
- * i386-tdep.c [I386_AIX_TARGET] (i386_extract_return_value): New func.
- * dbxread.c: Use SEEK_SET and SEEK_CUR, not L_*. Define them if and
- only if not defined by a header file.
- * mipsread.c: Don't define L_SET or L_INCR.
-
-Mon Jun 21 15:10:07 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (BFD_INCLUDES): Bfd.h is now back in bfd build dir.
- * depend: Hand updated to match.
-
-Mon Jun 21 10:13:42 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Include "demangle.h".
- (process_one_debug_symbol): Set the SYMBOL_LANGUAGE and
- SYMBOL_INIT_DEMANGLED_NAME for the current symbol. Adjust
- SYMBOL_VALUE for local variables in the stack by the size of the
- current function's stack (found in unwind descriptor). Keep
- better track of the current unwind descriptor.
-
-Sun Jun 20 13:11:11 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * stabsread.c (read_struct_fields): Don't call read_cpp_abbrev on $_.
- (read_cpp_abbrev): Don't complain specially for $_. Also return 0 if
- we don't recognize the abbrev.
-
-Sun Jun 20 00:24:41 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * solib.c (solib_add_common_symbols): Add comment about performance.
-
-Fri Jun 18 12:37:36 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/mips/{{x,n}m-riscos.h,riscos.mh}: New files.
- * configure.in (mips-*-sysv*): Use riscos for host, bigmips for target.
-
- * config/mips/{{x,n}m-news-mips.h,news-mips.mh}: New files.
- * config/mips/{bigmips.mh,xm-bigmips.h}: Remove.
- * configure.in (mips-sony-*): Use news-mips for host.
-
- * buildsym.h: Doc fix for processing_acc_compilation.
-
-Thu Jun 17 19:57:08 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (print_formatted): Don't use tab in wrap_here arg.
-
-Thu Jun 17 17:29:30 1993 Jim Kingdon (kingdon@lisa.cygnus.com)
-
- * Makefile.in (INTERNAL_CFLAGS): Include ../include as well as
- ${srcdir}/../include.
-
- * config/m88k/xm-delta88.h: Comment out unused defines which conflict
- with system headers.
- * printcmd.c (printf_command): Cast second arg to vprintf to PTR.
- Use VPRINTF macro if defined.
- * config/m88k/xm-delta88.h: Define VPRINTF. Include <sys/siginfo.h>.
- Define TIOC{GETC,GLTC}_BROKEN.
- * m88k-nat.c: Uncomment include of <sys/ptrace.h>.
- * main.c: Rename initialize_{main,cmd_lists,history} to init_* to
- make things easier on munch (apparently this matters on
- the delta88 with svr3).
-
-Thu Jun 17 16:53:56 1993 david d `zoo' zuhn (zoo@cygnus.com)
-
- * Makefile.in: canonicalize install.sh; for use within
- this directory (and subdirs)
-
-Tue Jun 15 17:01:23 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: remove parentdir support; use INSTALL_XFORM
-
-Thu Jun 17 15:08:35 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
-
- * configure.in (alpha-*-osf*), config/alpha/alpha-osf.mh: New
- host.
- * sh-tdep.c (frame_find_saved_regs): Use NUM_REGS rather than hard
- wired (and wrong) constant.
- * values.c (unpack_long): Add case to unpack when target object is
- sizeof(int).
- * config/sh/tm-sh.h (REGISTER_NAMES): Know about the news ones the
- simulator defines.
-
-Wed Jun 16 16:08:18 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * NEWS: tracking user visible changes starting with
- vxworks-timeout.
-
- * remote-vx.c (_initialize_vx): rename user settable option from
- rpcTimeout to vxworks-timeout.
-
-Wed Jun 16 14:34:10 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (hp_type_translate): Fix promotion bugs from
- char to short and short to int.
-
-Wed Jun 16 12:21:49 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (depend): More makefile diddling.
- * alldeps.mak, depend: Update to latest automatically built
- versions.
-
- * Makefile.in (depend): Bfd.h keeps moving, keep up with it.
- * alldeps.mak, depend: Update to latest automatically built
- versions.
-
-Tue Jun 15 12:26:05 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * remote-vx.c: include gdbcmd.h for setlist.
- (_initialize_vx): make rpcTimeout user settable.
-
-Mon Jun 14 09:23:51 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * main.c, gdbcmd.h: Add function filename_completer.
- * main.c, symfile.c, source.c, exec.c, core.c: Use it for
- "directory", "source", "cd", "symbol-file" "add-symbol-file",
- "load", "file", "exec-file", "core-file" commands.
- (But '/' is a word break, limiting usefulness; see comments).
-
- * source.c (mod_path): Warning not error if can't find directory.
-
- * isi-xdep.c: New file.
- * config/m68k/isi.mh (XDEPFILES): Add isi-xdep.o
-
-Sun Jun 13 09:17:48 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * config/m68k/xm-news.h: Include <sys/param.h>.
-
- * m88k-tdep.c (IEEE_isNAN): Remove.
- config/m88k/tm-m88k.h (INVALID_FLOAT): Return 0. This was the same
- broken isNAN as on the mips.
-
- * valprint.c (_initialize_valprint): Use c->function.sfunc not just
- c->function.
-
- * dbxread.c (process_one_symbol): If SUN_FIXED_LBRAC_BUG is not
- defined, don't worry about Sun's silly LBRAC bug.
- * config/m68k/tm-sun3.h: Define SUN_FIXED_LBRAC_BUG to 0.
-
- * dbxread.c (process_one_symbol): If there's a symbol before an
- N_SO, don't error().
- (case N_BCOMM): complain () not error ().
-
- * defs.h, main.c (catch_errors): Add return_mask arg.
- stack.c (print_frame_info): Pass RETURN_MASK_ERROR.
- other callers: Pass RETURN_MASK_ALL.
- (return_to_top_level), callers: Add return_reason arg.
- * utils.c (quit):
- Use return_to_top_level (RETURN_QUIT) instead of error ().
- * main.c (main), tm-nindy960.h (ADDITIONAL_OPTION_HANDLER):
- Use SET_TOP_LEVEL not setjmp (to_top_level).
- * remote-nindy.c: Use catch_errors not setjmp (to_top_level).
-
-Sat Jun 12 14:40:54 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * solib.c (solib_create_inferior_hook) [SVR4_SHARED_LIBS]:
- Don't try to get the debug base yet.
-
- * dbxread.c (process_one_symbol): Set n_opt_found based on whether
- a non-gcc N_OPT symbol is found. Make SUN_FIXED_LBRAC_BUG a macro
- which returns 0 or 1 to say whether to do it.
- * config/sparc/sun4{sol2,os4}.h
- (SUN_FIXED_LBRAC_BUG,VARIABLES_INSIDE_BLOCK): Use n_opt_found so
- the right thing happens for both acc and SunOS4 /bin/cc.
-
- * valprint.c (print_hex_chars): Use local_hex_format_{pre,suf}fix.
- * printcmd.c (print_scalar_formatted): Use val_print_type_code_int.
-
- * mips-tdep.c: Remove isa_NAN; it assumed sizeof(host int) == 4 and
- probably contained byte-order sins too.
- config/mips/tm-mips.h (INVALID_FLOAT): Define to 0 like most machines.
- The IEEE_FLOAT code in print_floating takes care of it.
-
-Sat Jun 12 14:47:04 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.9.2.
- * c-valprint.c (c_val_print): For array of chars printed with
- string syntax, don't print the address of the array. From
- bothner@cygnus.com.
- * c-exp.y (yylex): Recognize '.' as indicating a floating point
- number regardless of the radix. From wilson@cygnus.com.
- * valprint.c (set_input_radix_1, set_output_radix_1): New
- prototypes and functions that do the actual radix setting work.
- * valprint.c (set_radix, set_output_radix, set_input_radix):
- Rewrite to use set_input_radix_1 and set_output_radix_1.
- * valprint.c (initialize_valprint): Enable commands to
- independently set and show input and output radices.
- * valprint.c (show_radix): New prototype and function that
- handles separate input and output radices.
-
-Fri Jun 11 18:39:38 1993 Ken Raeburn (raeburn@cygnus.com)
-
- Patches from Jeff Law, law@cs.utah.edu:
- * hppa-pinsn.c: Now uses disassembler from opcode library,
- this contains only the stub function print_insn.
-
-Fri Jun 11 15:19:59 1993 K. Richard Pixley (rich@cygnus.com)
-
- * main.c (main): back to two periods for elipse.
- (print_gdb_version): revised format for configuration info.
-
-Fri Jun 11 10:24:35 1993 Fred Fish (fnf@cygnus.com)
-
- * defs.h (INT_MAX): Cast unsigned shift result to int.
-
-Fri Jun 11 10:17:41 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * dbxread.c (process_one_symbol): Rather than having
- BLOCK_ADDRESS_FUNCTION_RELATIVE a macro, make it a variable which
- is true if we are doing stabs-in-elf, false otherwise.
- config/sparc/tm-sun4sol2.h: Don't define it.
-
-Fri Jun 11 13:33:40 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * remote-mips.c (mips_send_packet): Don't print garbage character
- in debugging info.
- (mips_request): Don't check that remote pid is 0, because
- sometimes it isn't.
- (mips_fetch_registers): Pass a pointer to SWAP_TARGET_AND_HOST,
- not an integer.
-
-Fri Jun 11 10:17:41 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * stack.c (print_frame_info): Use catch_errors around print_frame_args.
-
- * Makefile.in (install): Don't depend on gdb.
-
- * Rename remote-es1800.c to remote-es.c
- and remote-st2000.c to remote-st.c for 14-char filenames.
- config/m68k/{es1800,st2000}: Use the new names.
-
- * mips-tdep.c (isa_NAN): Don't return true on -0.
-
-Fri Jun 11 10:24:35 1993 Fred Fish (fnf@cygnus.com)
-
- * defs.h (INT_MAX): Cast unsigned shift result to int.
-
-Thu Jun 10 13:26:41 1993 Fred Fish (fnf@cygnus.com)
-
- * elfread.c (elf_symtab_read): Add bfd section address to bfd
- symbols, now that they are section relative.
- * solib.c (bfd_lookup_symbol): Ditto.
-
-Thu Jun 10 11:27:34 1993 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (read_hp_function_type): Adjust SYMBOL_VALUE for
- arguments in the stack by the size of the current function's stack
- (found in the unwind descriptor).
- (process_one_debug_symbol): Likewise. Keep track of the current
- function's unwind descriptor.
-
-Thu Jun 10 10:56:56 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Makefile.in (depend): Add bfd -I's for paread.c and xcoffexec.c
- depend: Updated accordingly.
-
-Wed Jun 9 16:08:44 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Makefile.in (*.tab.c): Use mv for atomic update.
-
- * Makefile.in ({dist,real}clean): Also remove nm.h.
- (realclean): Also remove ${TESTS}, y.output, yacc.{acts,tmp}.
- (distclean): Don't rebuild *.tab.c or TAGS.
-
-Wed Jun 9 12:56:58 1993 K. Richard Pixley (rich@cygnus.com)
-
- * Makefile.in (version.c): add host and target names to version.c.
- * main.c (main): print three periods for the elipse.
- (print_gdb_version): also print configuration.
-
- * udi/udiids.h, udi/udip2soc.c, udi/udiphcfg.h, udi/udiphunix.h,
- udi/udiproc.h, udi/udipt29k.h, udi/udiptcfg.h, udi/udisoc.h,
- udi/udr.c: Change AMD copyrights to FSF copyleft '93.
-
- * remote-eb.c (get_hex_regs, eb_fetch_registers), remote-adapt.c
- (get_hex_regs, adapt_fetch_registers): cast args to
- supply_register to avoid gcc warning.
-
- * config/a29k/a29k.mt (TDEPFILES): drop minimon support. It
- doesn't compile on solaris and is now obsolete.
-
- * config/sparc/sun4os4.mh (XM_CLIBS): remove -lresolv. This
- breaks stock sunos installations.
-
-Wed Jun 9 06:14:33 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * m68k-stub.c: Add comment about frame cache.
-
- * target.h (target_store_registers): Doc fix re error handling.
-
- * findvar.c (write_register): Call SWAP_TARGET_AND_HOST regardless
- of register_valid[regno].
-
-Tue Jun 8 14:42:10 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
-
- * symtab.h, dwarfread.c: Doc fix re dependencies.
-
-Tue Jun 8 17:54:09 1993 Rob Savoye (rob@rtl.cygnus.com)
-
- * serial.c (serial_close): If scb is NULL, don't try to close
- it.
- * configure.in: Add support for rom68k and bug boot monitors.
-
-Tue Jun 8 17:39:12 1993 Steve Chamberlain (sac@phydeaux.cygnus.com)
-
- * coffread.c (init_stringtab): Fix bug where sizeof(long) != 4.
- * gdbcore.h, core.c (read_memory_unsigned_integer): New function.
- * findvar.c (read_register, write_register): Fix thinko where
- sizeof(host long) != sizeof(target int).
- * h8300-tdep.c: Use new read_memory_unsigned_integer call.
- * sh-tdep.c (_initialize_sh_tdep): Add memory_size command.
-
-Tue Jun 8 14:42:10 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
-
- * Move config/m68k/tm-m68k.h (FRAME_FIND_SAVED_REGS) to
- m68k-tdep.c (m68k_find_saved_regs). Don't duplicate code between
- 68881 and non-68881 cases. Check for a pair of movel instructions.
-
-Tue Jun 8 14:52:55 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- First cut at sparc-vxworks targetting.
- * config/sparc/tm-vxsparc.h, config/sparc/vxsparc.mt: new files.
- * configure.in: sparc-vxworks gdb_target now vxsparc.
-
- * remote-eb.c, remote.c: symfile.h requires bfd.h so include it.
-
-Tue Jun 8 14:42:10 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
-
- * config/m68k/xm-news.h: add "extern int errno".
-
-Tue Jun 8 13:45:07 1993 K. Richard Pixley (rich@sendai.cygnus.com)
-
- * remove-vx.c (vx_read_register, vx_write_register): collapse
- ifdef I80960 else (assumes) m68k into parameterizable macros
- VX_NUM_REGS and VX_SIZE_FPREGS.
- * config/m68k/tm-vx68.h, config/i960/tm-vx960.h (VX_NUM_REGS,
- VX_SIZE_FPREGS): new definitions.
-
-Tue Jun 8 11:08:29 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * symfile.{c,h} (generic_load): New function.
- remote{,-nindy,-eb,-mips}.c: Use it.
-
-Mon Jun 7 20:07:30 1993 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in (depend): More sed gubbish to deal with
- ../bfd/bfd.h being generated during the build.
- * depend: Re-done with corrected makefile.
-
-Mon Jun 7 16:32:05 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (BFD_SRC_DIR): Renamed def and usages from BFD_DIR.
- * Makefile.in (BFD_OBJ_DIR): New definition for the bfd build
- directory to find automatically generated header files and library.
- * Makefile.in (BFD_LIB): Use BFD_OBJ_DIR.
- * Makefile.in (LINTFLAGS): Include BFD_OBJ_DIR.
- * Makefile.in (saber_gdb): Include BFD_OBJ_DIR.
- * Makefile.in (depend): Include BFD_OBJ_DIR in gcc args.
- * Makefile.in (paread.o, xcoffexec.o): Remove, now in depend.
- * depend, alldeps.mak: Rebuild after Makefile.in changes.
-
-Fri Jun 4 10:18:51 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: change lynx support to CPU-*-lynxos*
-
- * Makefile.in (subdir_do): change test from existence of directory
- to existence of Makefile (the directory may exist but not be configured)
-
-Thu Jun 3 01:18:51 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config/sparc/xm-sun4sol2.h: define MEM_FNS_DECLARED
-
-Fri Jun 4 10:43:33 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * configure.in (mips-idt-ecoffl*): New target; use idtl.
- (mips-idt-ecoff*): Added trailing '*'.
- * config/mips/idtl.mt: New file; like idt.mt, but little endian.
-
-Thu Jun 3 17:36:56 1993 Stu Grossman (grossman@cygnus.com)
-
- * ser-go32.c: Clean up lots of compilation nits.
-
-Thu Jun 3 14:44:57 1993 Stu Grossman (grossman@cygnus.com)
-
- * Patches from Jeffrey Law <law@cs.utah.edu>.
- * hppab-nat.c: Eliminate unnecessary ifdefs for
- FETCH_INFERIOR_REGISTERS, CANNOT_FETCH_REGISTER, and
- CANNOT_STORE_REGISTER.
- (fetch_register): Delete code to handle CANNOT_FETCH_REGISTER.
- * hppa-pinsn.c: Support 'I', 'J', and 'K' in output
- templates for 1.1 FP computational instructions.
-
-Thu Jun 3 03:34:49 1993 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in: Remove ser-tcp.[co]. (Use XDEPFILES instead.)
- * alldeps.mak, depend: Rebuild to account for ser-tcp.
- * config/sparc/sun4os4.mh: Add ser-tcp to XDEPFILES.
- * gdbserver/Makefile.in (gdbserver): Use -lbsd.
- * gdbserver/remote-inflow{-sparc}.c (create_inferior): Don't use a
- shell when running the child, as args have been expanded by the
- time we get here. Simplify calling convention.
- * gdbserver/remote-server.c (main): Use new calling convention
- for create_inferior, remove defunct code for coalescing argv.
- Remove extra calls to mywait(), as we no longer have to wade
- through a shell.
-
- * target.c (target_read_memory_partial): Don't deref errnoptr
- when checking for null pointer.
-
-Wed Jun 2 19:58:46 1993 John Gilmore (gnu@cygnus.com)
-
- * remote-es1800.c: Fix typo.
-
-Tue Jun 1 21:22:39 1993 Fred Fish (fnf@cygnus.com)
-
- * target.c (target_read_memory_partial): Like target_read_memory,
- but does partial reads, such as reads that bump into the end of
- the address space.
- * target.h (target_read_memory_partial): Add prototype.
- * valprint.c (PRINT_MAX_DEFAULT): New define, initial value 200.
- * valprint.c (val_print_string): Complete rewrite to fix bug with
- bumping into end of memory, avoiding unnecessarily long reads, and
- fixing bug when print_max is set to 0 (unlimited print length).
- * valprint.c (_initialize_valprint): Use PRINT_MAX_DEFAULT to
- initialize print_max.
-
-Tue Jun 1 18:11:35 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * configure.in: Add support for rom68k and bug boot monitors.
-
-Mon May 31 10:37:04 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * printcmd.c (print_scalar_formatted): Print integers bigger than
- LONGEST in hex no matter how big, and no matter what the format
- and size.
-
- * stabsread.c (read_type): Skip type attributes if present.
-
- * stabsread.c (read_huge_number): Don't accept '0' + radix as part
- of number, just through '0' + radix - 1.
-
-Sun May 30 15:35:21 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (SER_HARDWIRE): Temporarily comment out ser-tcp.o.
-
- * {dbxread.c, dwarfread.c} (read_ofile_symtab): Rewrite to take
- single parameter, the pointer to the partial symtab, rather than
- a bunch of args that are derived from the partial symtab. Change
- prototypes and callers to match.
-
- * dbxread.c (read_ofile_symtab): Remove "#if 1" around code to
- set demangling style automatically.
- * defs.h (CPLUS_MARKER): Clarify comment that this is only for
- GNU C++, not C++ in general.
- * symtab.h (general_symbol_info): Simplify by eliminating one
- structure level for the language dependent info.
-
-Sat May 29 15:59:29 1993 Fred Fish (fnf@cygnus.com)
-
- * c-typeprint.c (c_type_print_base): Avoid dereferencing NULL
- names for TYPE_CODE_STRUCT and TYPE_CODE_UNION types.
- TYPE_CODE_ENUM was already testing for this.
-
-Fri May 28 17:18:05 1993 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in: Add new file ser-tcp.c.
- * defs.h (memcmp): Add decl for memcmp to #ifndef MEM_FNS_DECLARED.
- * findvar.c (write_register): See if we are writing back the same
- value that's already in the register. If so, don't bother.
- * remote.c (putpkt, getpkt): Improve handling of communication
- problems.
- * ser-go32.c: Prototype it to death. Update serial_ops and add
- dummy routines where appropriate.
- * ser-tcp.c: New module to implement serial I/O via TCP
- connections.
- * ser-unix.c: Clean up getting/setting of tty state. Get rid of
- SERIAL_RESTORE, add SERIAL_{GET|SET}_TTY_STATE interfaces.
- * serial.c: Add start of support for connect command.
- (serial_open): Distinguish between tcp and local devices.
- * serial.h (struct serial_ops): Get rid of restore, add
- get_tty_state and set_tty_state. Define protoypes and macros for
- this mess.
- * gdbserver/remote-utils.c: Add tcp support. (readchar): Do
- some real buffering. Handle error conditions gracefully.
- * gdbserver/remote-inflow-sparc.c: Update to remote-inflow.c
- (Lynx), remove lots of cruft.
-
-Fri May 28 17:24:51 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * printcmd.c (print_address_symbolic): turn this into an assigment
- instead of an initialization (many compilers don't accept
- structure initialization).
-
-Thu May 27 16:56:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab): If several program csects in one
- source file, give them all the name of the source file, rather than
- the 2nd and subsequent ones having NULL names.
-
-Thu May 27 06:16:56 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * printcmd.c (print_address_symbolic): Append source filename and
- linenumber of the symbol if print symbol-filename is on.
- (initialize_printcmd): `set print symbol-filename'.
-
-Wed May 26 13:46:16 1993 Stu Grossman (grossman@cygnus.com)
-
- * configure.in: Add config for Lynx target. Configure gdbserver
- only for Lynx. Re-do selective configuration of sparclite.
-
- * gdbserver/{remote-gutils.c remote-server.c Makefile.in
- configure.in remote-inflow.c remote-utils.c}: New files to
- support GDB remote server. Currently only works for Lynx.
-
-Wed May 26 10:28:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (define_symbol, case 't'): Only set the name if it
- is not a pointer type.
-
- * stabsread.c (define_symbol): Clean up logic; move the read_type
- calls to inside the switch statement (this improves the error
- handling).
-
- * mipsread.c (parse_symbol, parse_partial_symbols): Deal with Fortran
- common blocks.
-
-Tue May 25 20:44:24 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (print_formatted, case 'i'): Pass a tab to wrap_here.
-
- * source.c (line_info): Change "pc" to "address" in messages and
- use print_address for addresses.
-
- * source.c (line_info): If we don't find a symtab, print more useful
- output, including the symbolic address.
-
- * source.c (line_info): If --fullname, display the source.
- (identify_source_line), callers: Take pc as argument, rather than
- assuming innermost frame (emacs doesn't use this, so no one ever
- noticed).
- * symtab.h: Declare frame_file_full_name.
- * main.c: Don't.
-
-Tue May 25 15:30:43 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
-
- * breakpoint.c (catch_command_1): Fix typo in error msg.
-
-Tue May 25 16:05:55 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
-
- * elfread.c (elf_symfile_read): Update ELF structure and routine
- names to specify 32-bit versions.
- (elf_symtab_read): Retrieve size field directly from symbol,
- instead of using old kludge.
-
- * mips-pinsn.c (print_insn): Cast address to bfd_vma before
- calling opcodes library.
- * z8k-tdep.c (print_insn): Likewise.
-
-Tue May 25 13:06:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c: Remove all uses of error(). Make error_type and
- read_type_number static.
- (define_symbol): Don't try to deal with a missing symbol
- descriptor which isn't followed by digit, '(', or '-'.
- * stabsread.h: Don't declare read_type_number here.
- * gdbtypes.h: Don't declare error_type here.
- * xcoffread.c: Remove NO_TYPEDEFS code.
-
-Tue May 25 09:33:16 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mips-tdep.c: Removed #include of many header files, and #define
- of MIPSMAGIC; no longer used.
-
-Tue May 25 09:36:13 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Many places: replace "the inferior" in messages with "the program"
- or "the program being debugged".
- * inflow.c (try_writing_regs): Remove; it's been #if 0'd forever
- and I'm getting sick of maintaining it.
-
- * config/i386/linux.mh: Don't use \ newline; the awk scripts don't
- support it.
-
- * config/i386/go32.mh: Define SER_HARDWIRE.
- * Makefile.in: Define SER_HARDWIRE.
- (DEPFILES): Use it.
- (alldeps.mak): Add SER_HARDWIRE.
- Remove all references to ser-hardwire.{c,o}.
- * configure.in: Remove all ser_hardwire and gdb_serial_driver stuff.
-
-Mon May 24 23:50:05 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * sparc-nat.c (store_inferior_registers): Fill in all members of
- inferior_fp_registers by reading them from the inferior before
- modifying and writing them back.
- Fixes unexplainable inferior FP exceptions after calls to the inferior
- or setting of floating point registers.
- * mips-tdep.c (mips_skip_prologue): Skip move of argument register
- to register which is generated by gcc-2.4.
-
-Tue May 25 00:42:39 1993 Ken Raeburn (raeburn@cygnus.com)
-
- * hppa-pinsn.c: Define OLD_TABLE before including opcode/hppa.h.
-
-Mon May 24 13:55:14 1993 Stu Grossman (grossman@cygnus.com)
-
- * config/i386/{i386lynx.mh i386lynx.mt nm-i386lynx.h tm-i386lynx.h
- xm-i386lynx.h}: New configuration for Lynx.
-
-Mon May 24 10:01:10 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * mipsread.c (parse_symbol): Deal with scVar and scVarRegister.
- * symtab.h: Comment that LOC_REGPARM_ADDR can be call by reference.
-
- * c-typeprint.c (c_type_print_base): Don't print typedef'd names
- as struct, union, or enum tags.
-
-Mon May 24 01:10:01 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symmisc.c (dump_msymbols): Avoid gdb coredump with stripped
- executable.
-
-Sat May 22 10:03:09 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (wait_for_inferior),
- infcmd.c (program_info, signal_command): Use symbolic signal names.
-
- * inftarg.c (child_wait): Deal with EINTR and include message from
- strerror if printing an error message.
-
- * main.c (command_line_input): Use STOP_SIGNAL not SIGTSTP.
-
- * stabsread.c: Remove most uses of lookup_fundamental_type.
- (define_symbol): Use read_type for type of enum constant,
- not just read_type_number. Also don't call error().
- (define_symbol): For unrecognized constant type, one complaint (the
- one from error_type) is enough. Don't make our own in addition.
- (define_symbol): Don't treat an N_FUN 'R' as a prototype.
- * gdbtypes.h: Doc fixes.
-
-Sat May 22 03:33:07 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- Fix stack unwinding through _sigtramp on Irix. These patches are from
- Paul Flinders <ptf@delcam.co.uk>.
- * mipsread.c (fixup_sigtramp): Find _sigtramp on Irix even when the
- executable uses sigvec.
- * mips-tdep.c (read_next_frame_reg): Allow tm-file to override
- sigcontext offsets.
- * config/mips/tm-irix3.h: Add sigcontext offsets for Irix.
-
-Sat May 22 00:39:01 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * infrun.c (wait_for_inferior): Clear stop_signal if it should not
- be passed to the inferior to make "handle <signal> nopass nostop" work.
-
-Sat May 22 00:21:41 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/mips/tm-irix3.h: Clean up, use tm-bigmips.h and redefine
- the necessary bits.
- * findvar.c (value_from_register): Fix uninitialized first_addr
- which caused problems with assignment of doubles to register variables
- on some targets.
- * mipsread.c: Remove TM_FILE_OVERRIDE, include tm.h and provide the
- missing mips definitions if necessary.
-
- Fix handling of double register variables for mips targets and big
- endian hosts. These patches are from Paul Flinders <ptf@delcam.co.uk>.
- * config/mips/tm-mips.h: Increase MAX_REGISTER_{RAW,VIRTUAL}_SIZE to
- 8 bytes for doubles.
- * config/mips/tm-mips.h (REGISTER_CONVERT_TO_TYPE): New macro for
- conversion of type held in multiple registers to host format.
- * config/mips/tm-mips.h (REGISTER_CONVERT_FROM_TYPE): New macro,
- companion to REGISTER_CONVERT_TO_TYPE.
- * config/mips/tm-mips.h (EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE):
- Convert to function calls.
- * config/mips/tm-mips.h (FIX_CALL_DUMMY): New code for big endian
- mips targets.
- * mips-tdep.c (mips_print_register): Raw buffer now needs just
- MAX_REGISTER_RAW_SIZE bytes.
- * mips-tdep.c (mips_print_register): Use REGISTER_CONVERT_TO_TYPE
- (if defined) for doubles.
- * mips-tdep.c: (mips_extract_return_value, mips_store_return_value):
- New functions, take care of REGISTER_CONVERT_TO/FROM_TYPE.
- * valops.c (value_assign): Use REGISTER_CONVERT_TO_TYPE if
- defined.
- * findvar.c (value_from_register): Use REGISTER_CONVERT_TO_TYPE if
- defined.
-
-Fri May 21 09:04:25 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in: Add i[34]86-*-isc*.
-
- * stabsread.c: Make sure all complain() pass the address of the struct.
-
- * xcoffread.c: Make sure all struct complaints are static not auto.
-
- * Makefile.in: Add rule for xcoffexec.o like that for paread.o.
-
- * xcoffread.c (process_xcoff_symbol, case C_LSYM): Use define_symbol.
-
-Wed May 19 12:33:59 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/i386/linux.mh: Re-enable coredumps now that they should work.
-
-Wed May 19 15:44:20 1993 K. Richard Pixley (rich@cygnus.com)
-
- * config/m68k/tm-m68k.h (FRAME_CHAIN): add missing close paren.
-
-Wed May 19 15:33:57 1993 Stu Grossman (grossman@cygnus.com)
-
- * config/pa/nm-hppab.h: Comment PTRACE_ARG3_TYPE.
-
-Wed May 19 12:33:59 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (INSTALLED_LIBS): New variable.
-
-Tue May 18 14:08:50 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c (quit_command): In the "quit anyway?" message, tell the user
- whether we are planning to detach or kill the program.
-
- * config/vax/vaxbsd.mh: Add "NAT_FILE= nm-vax.h".
- * config/vax/xm-vaxbsd.h: Use <sys/param.h> not <machine/limits.h>
-
- * infcmd.c (read_pc): Doc fix.
-
- * printcmd.c (print_address_symbolic): Use %u not %d for offset.
-
- * blockframe.c (get_prev_frame_info): If pc in sigtramp, set
- signal_handler_caller.
- * tm-68k.h (FRAME_{CHAIN,SAVED_PC}): Deal with sigtramp.
- * tm-hp300bsd.h: Define SIGTRAMP_{START,END} not IN_SIGTRAMP.
- * inferior.h (IN_SIGTRAMP): Definition moved from infrun.c.
- Use SIGTRAMP_START if defined.
- * infcmd.c (step_1): Use SIGTRAMP_{START,END} if needed.
- * infrun.c (wait_for_inferior): Check IN_SIGTRAMP before SKIP_PROLOGUE.
-
- * infptrace.c: Remove unused KERNEL_U_ADDR_HPUX code.
-
- * infcmd.c (step_1): Fix poorly worded error message.
-
- * config/{i386/linux.mh,m68k/isi.mh} (NATDEPFILES):
- Comment out corelow.c because core dumps are broken on these machines.
-
- * Makefile.in (depend): Put "${srcdir}" in generated dependencies
- if srcdir is not ".".
- Also put in -I${BFD_DIR} or -I${READLINE_DIR} for files which need it.
- (INCLUDE_CFLAGS): Remove BFD_DIR and READLINE_DIR.
- * depend: Update to latest automatically built version.
-
-Tue May 18 08:10:45 1993 Fred Fish (fnf@cygnus.com)
-
- * ChangeLog, ChangeLog-92: Split ChangeLog at 1993.
- * Makefile.in (NONSRC): Add ChangeLog-92
-
-Tue May 18 08:03:37 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * findvar.c ({read,write}_register): Use REGISTER_RAW_SIZE
- not typo RAW_REGISTER_SIZE.
-
- * frame.h, inferior.h: Doc fixes.
-
-Mon May 17 15:43:03 1993 Stu Grossman (grossman@cygnus.com)
-
- * findvar.c (write_register): Add sanity check for register size.
- (read_register): Fixup sanity check for register size to be
- consistent with write_register().
-
-Mon May 17 07:36:20 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * sparclite/Makefile.in: Add dummy info, install and install-info
- targets.
-
-Thu May 13 07:30:22 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * remote-nindy.c: Removed declaration of coffstrip.
- * nindy-share/nindy.c: #if 0 coffstrip routine; no longer used.
-
-Wed May 12 00:35:19 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.9.1 after release and cvs
- tagging.
-
- * Makefile.in (VERSION): GDB 4.9 release.
-
-Tue May 11 08:04:41 1993 Fred Fish (fnf@cygnus.com)
-
- * README: Update known bugs to include the Solaris bug that
- leaves core dumps in the current directory when restarting the
- inferior with "run". Expand on the testsuite information.
-
- * Makefile.in (VERSION): Bump to 4.8.96 for what should hopefully
- be the last 4.9 prerelease test archive.
-
-Mon May 10 22:13:23 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * config/m68k/xm-hp300bsd.h: Include <sys/param.h> to avoid INT_MAX
- redefined warnings.
-
-Mon May 10 20:00:43 1993 Fred Fish (fnf@cygnus.com)
-
- * README, NEWS: Update for gdb 4.9 release.
-
-Mon May 10 19:38:34 1993 John Gilmore (gnu@cygnus.com)
-
- * ch-exp.y (MAX, MIN): Rename to MAX_TOKEN, MIN_TOKEN.
- * target.c (MIN): #undef before defining.
-
-Mon May 10 16:03:03 1993 Jim Kingdon (kingdon@cygnus.com)
-
- Patch from Jeffrey Law:
- * gdb/config/pa/nm-hppab.h (PTRACE_ARG3_TYPE): Define as caddr_t.
-
-Mon May 10 15:28:27 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * hppa-tdep.c (hppa_push_arguments): Allocate correct amount of
- memory.
-
-Mon May 10 13:14:46 1993 Fred Fish (fnf@cygnus.com)
-
- * ch-exp.y (start): Apply work-around to avoid bison warning.
-
-Sun May 9 07:25:02 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (BISON): Remove double quotes around BISON
- definition when bison is used.
-
- * configure.in (hppa*-hp-bsd): Change to hppa*-hp-bsd*
- * configure.in (hppa*-hp-hpux): Change to hppa*-hp-hpux*
- * configure.in (m68*-hp-bsd): Change to m68*-hp-bsd*
- * configure.in (m68*-hp-hpux): Change to m68*-hp-hpux*
- * configure.in (hppa*-*-bsd): Change to hppa*-*-bsd*
- * configure.in (hppa*-*-hpux): Change to hppa*-*-hpux*
- * configure.in (m68*-hp-bsd): Change to m68*-hp-bsd*
- * configure.in (m68*-hp-hpux): Change to m68*-hp-hpux*
-
- * Makefile.in (VERSION): Bump to 4.8.6.
-
-Sat May 8 12:36:03 1993 Fred Fish (fnf@cygnus.com)
-
- * config/pa/xm-hppah.h (MALLOC_INCOMPATIBLE): Define it, and
- include declarations for malloc/realloc/free. Both malloc and
- realloc return 'void *' for non-ANSI compilations.
-
-Sat May 8 01:39:30 1993 (pes@regent.e-technik.tu-muenchen.de)
-
- * coffread.c (read_coff_symtab): Don't fclose stream as it is no
- longer opened twice.
-
-Thu May 6 21:08:55 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * solib.c (clear_solib): Don't close bfd if it is NULL.
-
-Thu May 6 20:55:35 1993 Fred Fish (fnf@cygnus.com)
-
- * core.c (dis_asm_read_memory): Cast second arg of
- target_read_memory to "char *".
- * breakpoint.c (watchpoint_check): Change arg type from PTR to
- "char *", to match other functions called by catch_errors().
-
-Thu May 6 15:47:45 1993 Stu Grossman (grossman@cygnus.com)
-
- * More patches from Jeffrey Law (law@cs.utah.edu).
- * gdb/config/nm-hppab.h (PTRACE_ARG3_TYPE): Define as caddr_t.
- * gdb/config/pa/tm-hppah.h (millicode_start, millicode_end):
- Delete unnecessary declarations.
-
-Thu May 6 15:15:46 1993 Stu Grossman (grossman@cygnus.com)
-
- * ser-unix.c (wait_for): Use VTIME to do timeouts instead of
- poll() for termio{s}.
-
-Thu May 6 10:03:41 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * i386-tdep.c (i386_frame_num_args): Always return -1.
-
-Wed May 5 15:16:33 1993 Stu Grossman (grossman@cygnus.com)
-
- * Patches from Jeffrey Law <law@cs.utah.edu>.
- * gdb/hppa-tdep.c: Declare frame_saved_pc.
- (frameless_function_invocation): New function.
- (frame_saved_pc, init_extra_frame_info): Use
- frameless_function_invocation.
- * gdb/config/pa/tm-hppa.h (SAVED_PC_AFTER_CALL): Use saved_pc_after
- call instead of just grabbing the value currently in %r2.
- (FRAMELESS_FUNCTION_INVOCATION): Use frameless_function_invocation.
- * gdb/config/pa/tm-hppah.h (SAVED_PC_AFTER_CALL): Delete private
- definition and use the common one in tm-hppa.h.
- * gdb/hppa-tdep.c (frame_chain_valid): If "use_unwind" is true, then
- use unwind descriptors to determine if the frame chain is valid.
- * gdb/hppa-tdep.c (find_dummy_frame_regs): Rework so that
- it does not assume %r4 is the frame pointer.
- * gdb/hppa-pinsn.c (print_insn): Handle 'r' and 'R' for break, rsm,
- and ssm instructions.
- * gdb/hppa-tdep.c (extract_5r_store, extract_5R_store): New
- helper functions for print_insn.
- * gdb/hppa-tdep.c (gcc_p, hpux_cc_p): Delete unused functions.
- * gdb/config/pa/tm-hppa.h (ABOUT_TO_RETURN): Handle a return
- which nullifies the following instruction.
-
-Tue May 4 12:11:38 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * infptrace.c [FIVE_ARG_PTRACE]: Define ptrace to call_ptrace and
- pass the 5th arg there, rather than using an ANSI C-specific macro.
-
- * Makefile.in (depend): Don't include ${CC} command for *.tab.c.
-
-Tue May 4 19:33:12 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.8.5
- * Makefile.in (INCLUDE_CFLAGS): Add BFD_DIR and READLINE_DIR
- directories to include search path.
- * Makefile.in (CLIBS, CDEPS, ADD_FILES, ADD_DEPS): Clean up
- whitespace.
- * Makefile.in (depend): For gcc -MM line, use INTERNAL_CFLAGS
- * Makefile.in (main.o, dbxread.o, coffread.o, mipsread.o,
- elfread.o, dwarfread.o, stabsread.o, xcoffread.o, xcoffexec.o,
- xdr_ld.o, xdr_rdb.o, nindy.o, Onindy.o, ttybreak.o, ttyflush.o,
- udr.o, udip2soc.o): Remove explicit rules, use the ones that
- are automatically generated in "depend".
- * Makefile.in (paread.o): Document why a dependency doesn't get
- automatically generated in "depend" and leave this explicit rule
- in for now (FIXME).
- * depend: Update to latest automatically generated version.
-
-Tue May 4 12:11:38 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffread.c: Doc fix.
-
- * Makefile.in (depend): Include $(CC) command in generated output.
-
-Mon May 3 22:51:05 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (NONSRC): Remove ${srcdir}/putenv.c.
- * Makefile.in (SFILES): Add ${srcdir}/putenv.c.
- * depend: Update to latest automatically built version.
-
-Mon May 3 19:20:20 1993 Stu Grossman (grossman@cygnus.com)
-
- * sparclite/Makefile.in: Create default target that does nothing
- in order to force user to build by hand.
-
- * sparclite/Makefile: Remove. It's not necessary anymore.
-
- * ser-unix.c (wait_for): New routine to handle read timeouts,
- etc. Uses poll() if HAVE_TERMIO[S] is defined, select() otherwise.
-
-Mon May 3 13:52:08 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mips-pinsn.c (print_insn): Return value.
-
-Sun May 2 11:43:57 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (SFILES): Remove ser-hardwire.c; it is a link made
- at configuration time and doesn't belong in the distribution archive.
-
- * Makefile.in (NONSRC): Add 29k-share/README.
- * Makefile.in (HFILES): Add 29k-share/udi/udiids.h.
-
- * defs.h (UINT_MAX, LONG_MAX, INT_MAX, INT_MIN): Replace hex
- constants with slightly more portable definitions (still depends
- on 2's complement arithmetic though).
- * config/i386/nm-linux.h: Define NO_SYS_REG_H for no <sys/reg.h>.
- * i386v-nat.c (sys/reg.h): Conditionalize include on
- NO_SYS_REG_H. Linux doesn't have <sys/reg.h>.
- * ser-unix.c (termio.h): Include <termio.h> like other files that
- include termio.h, not <sys/termio.h> which may not exist (on
- linux for example).
-
-Sat May 1 16:05:24 1993 Fred Fish (fnf@cygnus.com)
-
- * valprint.c (print_longest): Change format parameter from a
- 'char' to an 'int'. We can't have 'char' parameters with the
- current coding style, where we mix prototypes with pre-ANSI
- style declarations.
- * value.h (print_longest): Change format parameter in prototype
- from a 'char' to an 'int'.
-
-Sat May 1 02:47:20 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/mips/tm-mips.h (STAB_REG_TO_REGNUM): Match it with the gcc
- definition.
- * config/mips/tm-irix3.h (STAB_REG_TO_REGNUM): Add.
- * irix4-nat.c (fill_fpregset): Fix bug with indexing into fpregsetp.
-
-Fri Apr 30 17:45:32 1993 Stu Grossman (grossman@cygnus.com)
-
- * The following patches are from Jeffrey Law <law@cs.utah.edu>.
- * config/pa/hppabsd.mh: Add more files to NATDEPFILES.
- * config/pa/xm-hppa[bh].h: Define FIVE_ARG_PTRACE.
- * hppab-nat.c: Delete WANT_NATIVE_TARGET ifdefs.
- ptrace needs 5 arguments, #define ptrace to always
- pass zero as the 5th argument.
-
-Fri Apr 30 15:54:13 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * configure.in: Match z8k-*-sim for z8000.
- * config/h8500/tm-h8500.h, h8500-tdep.c: Lint.
- * remote-hms.c: Update to use new serial protocol.
-
-Fri Apr 30 16:50:38 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * mips-tdep.c: remove include of sys/dir.h. Doesn't seem
- necessary and Solaris doesn't have it.
-
- * Makefile.in (clean-info, install, install-info, info, dvi,
- check, all): do not echo recursion lines.
-
- * 29k-share/udip2soc.c (UDIConnect): replace union wait with int.
-
- * config/sparc/sun4sol2.mh (XM_CLIBS): add -lsocket which is
- required target ports which use sockets (like a29k-udi).
-
- * remote-udi.c (udi_wait): Use SIGURG, as Solaris doesn't have SIGLOST.
-
-Fri Apr 30 11:05:42 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * ser-unix.c [USE_{TERMIO,ALARM}_TIMEOUT]: New code to deal with
- systems lacking select().
-
- * Makefile.in (TAGS): Doc fix. Deal with empty DEPFILES.
-
-Fri Apr 30 10:06:46 1993 Fred Fish (fnf@cygnus.com)
-
- * alldeps.mak, depend: Update with latest automatically built
- versions.
-
-Thu Apr 29 12:03:23 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (SFILES): Add ser-unix.c and ser-go32.c.
-
- * Makefile.in (make-proto-testsuite.dir): New target to make
- prototype testsuite tree.
-
- * Makefile.in (VERSION): Bump to 4.8.4.
-
-Thu Apr 29 08:46:22 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * stabsread.c (define_symbol): If unrecognized constant type,
- complain() not error().
-
-Thu Apr 29 00:03:59 1993 Fred Fish (fnf@cygnus.com)
-
- * infptrace.c: Add missing close paren to test for
- FIVE_ARG_PTRACE defined.
-
- * defs.h (CC_HAS_LONG_LONG): Set up to define CC_HAS_LONG_LONG
- when compiling with gcc, but disable it for now. See comment.
- * defs.h (LONGEST): Define as either "long" or "long long"
- based on CC_HAS_LONG_LONG.
- * defs.h (longest_to_int): Use CC_HAS_LONG_LONG to control
- how longest_to_int is defined.
- * c-valprint.c (c_val_print): Call print_longest.
- * expprint.c (dump_expression): Use PRINTF_HAS_LONG_LONG
- instead of LONG_LONG.
- * {printcmd.c, gdbtypes.h} (LONG_LONG): Replace usages with
- CC_HAS_LONG_LONG.
- * printcmd.c (print_scalar_formatted): Call print_longest
- and let it figure out what to do for PRINTF_HAS_LONG_LONG.
- * typeprint.c (print_type_scalar): Call print_longest and let
- it figure out what to do for PRINTF_HAS_LONG_LONG.
- * valprint.c (val_print_type_code_int): Call print_longest
- and let it figure out what to do for PRINTF_HAS_LONG_LONG.
- * stabsread.c (LONG_LONG): Replace usages with CC_HAS_LONG_LONG.
- * value.h (struct value): Replace usage of LONG_LONG with
- CC_HAS_LONG_LONG.
- * value.h (print_longest): Add prototype.
- * values.c (LONG_LONG): Replace usages with CC_HAS_LONG_LONG.
- * values.c (unpack_double): Collapse code that was unnecessarily
- dependent on CC_HAS_LONG_LONG. Use LONGEST instead of direct types.
- * values.c (value_from_longest): Remove dependency on
- CC_HAS_LONG_LONG and just use LONGEST.
- * solib.c (solib_map_sections): Use bfd_get_filename
- to access filename field.
- * solib.c (clear_solib): Save filename and free it later, after
- bfd_close, since bfd_close may reference it. Use bfd_get_filename
- to access the field.
- * config/convex/xm-convex.h (LONG_LONG): Replace with
- CC_HAS_LONG_LONG. Add define for PRINTF_HAS_LONG_LONG.
- * doc/gdbint.texinfo (LONG_LONG): Replace with CC_HAS_LONG_LONG.
- Add PRINTF_HAS_LONG_LONG references.
-
-Wed Apr 28 06:11:38 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * inflow.c (kill_command), infcmd.c (attach_command),
- remote.c (remote_interrupt_twice): In messages for the user, call it
- "the program" or "the program being debugged" not "the inferior".
-
- * hp300ux-nat.c: Cast second arg to supply_register calls.
- (_initialize_kernel_u_addr, getpagesize): New functions.
- (store_inferior_register_1): Change arg name from value to val.
- (fetch_core_registers): Make arg core_reg_size unsigned.
- Pass 5 args to ptrace.
- * config/m68k/xm-hp300hpux.h: Define FIVE_ARG_PTRACE.
- Remove KERNEL_U_ADDR stuff.
- * infptrace.c [FIVE_ARG_PTRACE]: Pass 5th arg to ptrace.
- * config/m68k/hp300hpux.m{t,h}:
- Move exec.o from NATDEPFILES to TDEPFILES
- * config/m68k/hp300hpux.mt: Mention GAS requirement. Remove
- hp-include stuff. Add m68k-tdep.o to TDEPFILES.
-
-Wed Apr 28 13:27:54 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * ch-exp.y (yylex): Don't STREQ with simplename if it is NULL.
-
-Wed Apr 28 06:11:38 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * config/sparc/xm-sun4os4.h [__STDC__]: Don't use MALLOC_INCOMPATIBLE.
-
-Wed Apr 28 11:39:18 1993 Roland H. Pesch (pesch@fowanton.cygnus.com)
-
- * doc/gdb.texinfo: make node "Shell Commands" unconditional;
- describe `set demangle-style arm' (not cfront);
- mention can type `q' to discard output, when gdb pages
-
-Wed Apr 28 11:32:39 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * valops.c (search_struct_field): Fix gdb core dump with incomplete
- stabs info.
-
-Wed Apr 28 06:11:38 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * remote.c: Change timeout to 2.
- (remote_open): Use unpush_target not remote_close.
- (remote_resume): If siggnal != 0, give warning not error().
- (remote_wait, remote_interrupt, remote_interrupt_twice):
- If we get two interrupts, let the user get out if they want.
- (remote_{kill,mourn}): New functions.
- i386-stub.c (handle_exception, case 'k'): Don't BREAKPOINT.
-
-Wed Apr 28 09:20:55 1993 Ian Lance Taylor (ian@rtl.cygnus.com)
-
- * config/sparc/sun4sol2.mh (XM_CLIBS): Define to be -lnsl.
-
-Wed Apr 28 06:11:38 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Remote targets (mourn): Call unpush_target.
-
- * config/sparc/xm-sun4os4.h: Declare free() to return int.
- Remove twisted use of PARAMS.
-
- * config/rs6000/xm-rs6000.h: Don't define MALLOC_INCOMPATIBLE now
- that ansidecl.h assumes ANSI on AIX.
-
-Tue Apr 27 10:01:33 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * README: Move most stuff about hacking GDB to doc/gdbint.texinfo.
- (Known bugs): Remove AIX bugs, revise SPARC struct bug description.
-
-Tue Apr 27 13:44:19 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * expprint.c (print_subexp): Fix bug with OP_SCOPE operator output.
-
-Tue Apr 27 10:01:33 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * remote-vx.c (net_connect): Allow numeric IP address for host.
-
-Mon Apr 26 17:59:38 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * config/sh/sh.mt, config/sh/tm-sh.h, sh-tdep.c: New files.
-
-Mon Apr 26 07:13:32 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * rs6000-tdep.c (branch_dest): Deal with stepping through system call.
-
- * symtab.h, xcoffread.c: Revise linetable sorting comments.
-
-Sun Apr 25 02:32:16 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * valops.c (value_cast): A cast might also change the object
- representation in C++.
- * dbxread.c (end_psymtab): Copy subpst read_symtab function from pst
- to get the proper read_symtab function when called from mipsread.c.
- * mipsread.c (mipscoff_psymtab_to_symtab, psymtab_to_symtab_1):
- Set cur_bfd in psymtab_to_symtab_1 as CURBFD(pst) is invalid
- for dummy psymtabs, inhibit processing of dummy psymtabs.
-
-Sat Apr 24 19:59:54 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Changes from (or inspired by) AMD:
- * remote-udi.c (udi_attach): Assignments to Space and Offset were
- switched, fix it.
- (udi_wait): Make error message (UDIGetStdout) match error.
- (udi_wait): Handle UDIStdinNeeded.
- * command.c [CANT_FORK]: Use system().
- * utils.c (prompt_for_continue): Allow quit with 'q'.
-
- * solib.c (solib_add): Don't call special_symbol_handling if there
- were errors in symbol_add_stub. Also set so->from_tty before
- calling symbol_add_stub.
-
-Fri Apr 23 16:17:00 1993 Stu Grossman (grossman@cygnus.com)
-
- * Merge in HPPA/BSD patches from Utah:
- * defs.h: Add const to 2nd arg of psignal prototype.
- * hppah-tdep.c: Renamed to hppa-tdep.c 'cuz it's common code with
- BSD now.
- * hppab-core.c: Deleted. No longer useful.
- * hppab-nat.c: #include more files. Use PT_WUREGS, not
- PT_WRITE_U.
- * hppab-tdep.c: Deleted. Supplanted by hppa-tdep.c.
- * config/pa/hppabsd.mh (NATDEPFILES): Remove hppab-core.o.
- * config/pa/hppabsd.mt (TDEPFILES): hppab-tdep.o => hppa-tdep.o
- * config/pa/hppahpux.mt (TDEPFILES): hppab-tdep.o => hppa-tdep.o
- * config/pa/xm-hppab.h: #define SET_STACK_LIMIT_HUGE.
-
-Fri Apr 23 10:34:02 1993 Stu Grossman (grossman@cygnus.com)
-
- * Fix two bugs found by deja-gnu. One is the incorrect reporting
- of the PC being in a stack dummy when looking at a core file
- without symbols. The other is the incorrect passing of char
- arguments during expression evaluation (ie: p foo('a','b') would
- mess up the passing of it's args because it wasn't coercing the
- char's to ints).
- * hppah-tdep.c: Rename global functions to have consistent hppa_
- prefix. Make more functions static. Drop hp_ prefix from static
- functions. (hppa_push_arguments): Call value_arg_coerce to cast
- char to int args if necessary. (hppa_fix_call_dummy): Create
- this routine from FIX_CALL_DUMMY macro in tm-hppa.h.
- * inferior.h (PC_IN_CALL_DUMMY): Check for frame_address being
- valid (ie: != 0) before doing comparison against PC.
- * valops.c (call_function_by_hand): Adjust call to FIX_CALL_DUMMY
- to reflect new arguments.
- * config/pa/tm-hppa.h (POP_FRAME, PUSH_ARGUMENTS): Use new hppa_
- prefix for func name. (FIX_CALL_DUMMY): Move code into
- hppah-tdep.c.
-
- * testsuite/gdb.t16/gdbme.c, testsuite/gdb.t17/gdbme.c: Add calls
- to malloc() so that we can test GDB eval of dynamically created
- arrays (like char strings in `print "foo"').
-
-Fri Apr 23 01:28:14 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * printcmd.c (print_address_symbolic): Search symtabs as well as the
- minimal symbols for a nearby symbol.
-
-Thu Apr 22 19:44:21 1993 John Gilmore (gnu@cacophony.cygnus.com)
-
- * coffread.c: Comment changes around minimal symbol recording.
-
-Thu Apr 22 16:24:36 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * command.c: comment changes only.
-
- * mips-tdep.c (heuristic_fence_post): new static variable.
- (heuristic_proc_start): use heuristic_fence_post, print better
- warnings, but only if not stop_soon_quietly.
- (_initialize_mips_tdep): add_set_cmd for heuristic-fence-post.
-
-Thu Apr 22 14:50:05 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * symtab.h: Fix LOC_REF_ARG comment.
-
-Wed Apr 22 20:21:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
- and Jim Kingdon (kingdon@cygnus.com)
-
- * stabsread.c (define_symbol): Combine a 'p', 'r' arg pair to a
- LOC_REGPARM symbol.
- * config/sparc/tm-sparc.h (REG_STRUCT_HAS_ADDR): Revise comments.
- symfile.c (compare_symbols): Don't check first character; STRCMP
- does that.
-
- * stabsread.c (define_symbol): Generate a LOC_REGPARM_ADDR for
- structures that are passed by address in a register.
- * symtab.h (enum address_class): Add LOC_REGPARM_ADDR.
- * findvar.c (read_var_value),
- printcmd.c (address_info, print_frame_args),
- stack.c (print_frame_arg_vars), symmisc.c (print_{,partial_}symbol),
- * symtab.c (lookup_block_symbol): Deal with it.
-
-Thu Apr 22 09:07:24 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * objfiles.h (obj_section), objfiles.c (build_objfile_section_table):
- Add objfile field.
- * objfiles.c (find_pc_section): Return a struct obj_section *.
- * sparc-tdep.c (in_solib_trampoline): Deal with find_pc_section return.
- * symfile.c (syms_from_objfile) [IBM6000_TARGET]:
- Don't use obj_section hack.
- * xcoffexec (vmap_symtab): Relocate obj_sections.
- * printcmd.c (containing_function_bounds): Use find_pc_section.
-
- * symtab.h: Clean up SYMBOL_VALUE comments.
-
-Wed Apr 21 14:29:57 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * stack.c (print_frame_arg_vars), printcmd.c (print_frame_args):
- Expand comments about LOC_ARG/LOC_LOCAL pairs.
-
- * coffread.c (read_coff_symtab): Use rewind before fseek.
-
-Wed Apr 21 14:24:19 1993 Per Bothner (bothner@cygnus.com)
-
- * ch-exp.y: Removed unused structure_primitive_value and FIXME_23.
- * Makefile.in: Add $(YFLAGS) when using $(YACC).
- * Makefile.in: Remove message to expect conflicts and unused
- rules in ch-exp.y, since there no longer are any such.
-
-Wed Apr 21 13:27:50 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * stabs.texinfo: fixed bad xrefs (un-initialized statics)
-
-Tue Apr 20 08:55:11 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffexec.c (xcoff_relocate_core): If no exec file, error()
- rather than dumping core.
-
- * Makefile.in: Add ${srcdir}/ to all source files.
- (alldeps.mak): Add "${srcdir}/" to files when generating alldeps.mak.
- (TAGS): Deal with srcdir and new config directory scheme.
- createtags: Remove.
- Makefile.in (NONSRC): Remove createtags.
- alldeps.mak: Updated.
-
- * rs6000-tdep.c: Delete unused function print_frame.
-
- * frame.h (struct frame_info): Doc fix for next_frame.
- New field signal_handler_caller.
- blockframe.c (create_new_frame, get_prev_frame_info),
- config/rs6000/tm-rs6000.h (INIT_EXTRA_FRAME_INFO): Set it (needs
- INIT_FRAME_PC_FIRST).
- stack.c (print_frame_info), rs6000-tdep.c (rs6000_frame_chain):
- Check it.
-
-Mon Apr 19 22:52:33 1993 Stu Grossman (grossman@cygnus.com)
-
- * irix4-nat.c (fetch_core_registers): Special version of this for
- Irix 4.x, which stores regs a bit differently from other /proc
- based systems.
- * procfs.c, core-svr4.c: Move fetch_core_registers from procfs.c
- to new file core-svr4.c.
- * config/i386/i386sol2.mh, config/i386/i386v4.mh, config/m68k/amix.mh,
- config/i386/ncr3000.mh, config/sparc/sun4sol2.mh: Add core-svr4.o
- to NATDEPFILES.
- * config/mips/irix4.mh: Add corelow.o to NATDEPFILES.
-
-Mon Apr 19 11:13:34 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * i387-tdep.c: Remove unused #includes.
-
- * configure.in: Match i[34]86-*-sysv3.2 not i[34]86-*-sysv32.
-
- * config/i386/nm-i386v.h: Define NO_PTRACE_H.
-
-Sun Apr 18 10:39:35 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffread.c: Nuke NO_DEFINE_SYMBOL code. There is no going back.
-
- * stabsread.c (define_symbol): 'R' is synonym for 'P', not 'r'.
- xcoffread.c (process_xcoff_symbol, case C_RPSYM):
- Don't muck with SYMBOL_CLASS.
-
-Fri Apr 16 17:38:33 1993 Stu Grossman (grossman@cygnus.com)
-
- * munch: Don't use head command. It doesn't exist everywhere.
-
-Fri Apr 16 15:07:57 1993 Fred Fish (fnf@cygnus.com)
-
- * inflow.c (new_tty): Remove spurious 'o' character at end
- of #endif line.
-
-Fri Apr 16 12:27:11 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mips-tdep.c (mips_skip_prologue): Always skip the typical prologue
- instructions and nothing more.
- * mipsread.c (add_line): Add comment why we have to combine line number
- entries for the same line number.
-
-Fri Apr 16 09:42:03 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * symtab.{c,h}: Doc fixes (remove symseg references, last relevant
- in gdb 2.8!).
-
-Thu Apr 15 21:16:58 1993 Fred Fish (fnf@cygnus.com)
-
- * depend, alldeps.mak: Update, now that gcc -MM bug is fixed.
-
-Thu Apr 15 12:38:39 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * source.c (select_source_symtab): Clean up comment. Also, if
- we have a current_source_symtab, and s is NULL, return without
- doing anything.
- xcoffread.c (xcoff_symfile_read): Don't call select_source_symtab.
- breakpoint.c (breakpoint_re_set): Don't call select_source_symtab.
-
-Thu Apr 15 02:37:48 1993 John Gilmore (gnu@cacophony.cygnus.com)
-
- * dbxread.c (unknown_symchar_complaint): Add new complaint.
- * stabsread.h: Declare it.
- * partial-stab.h: Use it.
-
- * utils.c (malloc_botch): Don't forward-declare if NO_MMALLOC.
-
-Wed Apr 14 17:12:51 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * stack.c (print_frame_info): Print specially if dummy frame.
-
- * breakpoint.c: Add comments regarding within_scope future direction.
-
- * Version 4.8.3.
-
- * xcoffread.c (record_include_{begin,end}): Change fatal to complain.
-
-Wed Apr 14 14:03:18 1993 Per Bothner (bothner@cygnus.com)
-
- * ch-exp.y: Fix thinko that broke parsing of FALSE.
-
-Wed Apr 14 12:49:29 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * stabsread.c (read_member_functions): Initialize domain for stubbed
- member functions to avoid gdb core dumps when printing pointers
- to member functions.
- * cp-valprint.c (cp_print_class_method): Check for stubbed member
- functions.
-
-Tue Apr 13 08:28:26 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * expprint.c (print_subexp): If opcode not found in op_print_tab,
- stop with an error().
- eval.c (evaluate_subexp): Change error message.
-
- * objfiles.c (build_objfile_section_table): Cast return value
- from obstack_finish.
-
-Mon Apr 12 10:53:50 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * config/rs6000/tm-rs6000.h, rs6000-tdep.c: Move FRAME_CHAIN
- to rs6000_frame_chain and deal with it if we're in a signal handler.
- (FRAME_SAVED_PC): Use rs6000_frame_chain.
-
- * breakpoint.c (within_scope): New function.
- (enable_breakpoint, watchpoint_check): Use it.
-
- * source.c (openp): Handle "exec-file ./ls" correctly.
-
- * breakpoint.c (breakpoint_1): Use wrap_here before "at".
-
-Sat Apr 10 01:32:43 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * ch-exp.y: Clean up lexing of identifiers and
- reserved words. (E.g. don't recognize FALSEXXX as the
- keyword FALSE followed by the identifier XXX.)
- Also, convert identifiers to lower case.
-
-Fri Apr 9 15:53:19 1993 Stu Grossman (grossman@cygnus.com)
-
- * remote-mips.c, remote-monitor.c, remote-st2000.c: Convert to
- new serial interface.
-
-Fri Apr 9 15:01:12 1993 Stu Grossman (grossman@cygnus.com)
-
- * remote.c (remote_open): Use SERIAL_OPEN instead of serial_open.
- (putpkt, getpkt): Use new return codes for SERIAL_READCHAR.
- * ser-go32.c: Return -1 on most failures, 0 on most successes,
- and use new return codes for go32_readchar().
- * ser-unix.c: Ditto. Also, move error handling up to caller for
- SERIAL_SETBAUDRATE().
- * serial.c (serial_open): Internal call, not SERIAL_OPEN to get
- to specific routine.
- (serial_close): New routine to wrap around device close routine.
- serial.h: Clean & document return values more clearly.
-
-Fri Apr 9 10:20:55 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * rs6000-pinsn.c (print_operand): Deal with no operand instructions.
-
- * rs6000-pinsn.c (print_operand, case LI): Print condition register
- operand in decimal rather than wrong textual versions.
-
- * printcmd.c (_initialize_printcmd): Clean up docstring for "x"
- (mention 't', remove false thing about 'g' only good with 'f').
-
- * breakpoint.h: move "struct breakpoint" and friends to top of
- file so that bpstat_find_breakpoint prototype works.
-
- * solib.c (struct so_list): Add bfd field.
- (solib_map_sections): Leave bfd open and scratch_pathname allocated.
- Put the bfd in bfd field of the so_list.
- (clear_solib): Free bfd name and close_bfd on the bfd.
-
-Fri Apr 9 00:45:41 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * valarith.c (value_subscript): Add COERCE_REF.
- * ch-exp.y (operand_5): We can generalize the 2nd operand
- of a string repetition ot 'literal' without ambiguity.
-
-Thu Apr 8 10:15:10 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.h (struct bpstat): Remove momentary field.
- Remove bpstat_momentary_breakpoint. This was always kludgy
- and is no longer used.
-
- * breakpoint.h: Add enum bpstat_what.
- breakpoint.h (struct bpstat), breakpoint.c (bpstat_stop_status):
- stop and print fields of bpstat now per-breakpoint, not just
- one for the whole chain.
- breakpoint.{c,h} (bpstat_what): New function.
- breakpoint.h: Remove bpstat_stop and bpstat_should_print.
- infrun.c: Replace switch (stop_bpstat->breakpoint_at->type)
- with call to bpstat_what.
- README: Remove watchpoint/breakpoint bug from known bugs.
-
- * breakpoint.h: Prototype bpstat_find_breakpoint.
-
-Thu Apr 8 16:01:21 1993 Fred Fish (fnf@cygnus.com)
-
- * symtab.c (find_methods, gdb_mangle_name): Note that functions
- are g++ specific.
- * symtab.h (VTBL_FNADDR_OFFSET, OPNAME_PREFIX_P, VTBL_PREFIX_P,
- DESTRUCTOR_PREFIX_P): Note that macros are g++ specific.
-
-Thu Apr 8 12:45:32 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * i960-pinsn.c (tabent): Copied struct definition from
- opcodes/i960-dis.c.
-
-Thu Apr 8 10:34:37 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symtab.h (DESTRUCTOR_PREFIX_P): New macro to check if physname
- is a C++ destructor.
- * symtab.c (gdb_mangle_name): Use it.
- * symtab.c (find_methods): Do not add destructors to choice list
- for constructors.
- * symtab.c (decode_line_1): Make breakpoints on destructors work
- for gcc-2.x again.
-
-Wed Apr 7 18:43:09 1993 Stu Grossman (grossman@cygnus.com)
-
- * ser-go32.c: Make it use serial port name.
- * go32-xdep.c: Put in def for strlwr, needed by dir.o in go32 libc.
-
- * infcmd.c (read_pc): Make sure that we read PC_REGNUM when not
- in a system call!
-
-Wed Apr 7 15:52:11 1993 Stu Grossman (grossman@cygnus.com)
-
- * configure.in: Only configure sparclite subdir when target_cpu
- is sparclite.
-
-Wed Apr 7 10:11:22 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffread.c (struct coff_symbol): Change c_sclass to unsigned char.
- Remove FIXME comment regarding this.
-
- * symfile.h: Change NULL->'\0' in comment (that wasn't a typo).
-
- * xcoffread.c (read_xcoff_symtab): Use E_SYMNMLEN.
-
-Tue Apr 6 22:30:58 1993 K. Richard Pixley (rich@cygnus.com)
-
- Add section table to objfile struct. Use it for find_pc_section.
- * objfiles.c (add_to_objfile_sections,
- build_objfile_section_table, find_pc_section): new functions.
- (allocate_objfile): build section table.
- * objfiles.h (struct obj_section): new structure.
- (struct objfile): add section table.
- (find_pc_section): new prototype.
- * solib.[ch] (find_pc_section_from_so_list): removed.
- * sparc-tdep.c: include objfiles.h for find_pc_section. include
- symfile.h for objfiles.h.
- (in_solib_trampoline): adjusted for new find_pc_section
- prototype. Removed BAD_RICH_HACK ifdefs.
- * symfile.c (syms_from_objfile): offset objfile sections.
- (find_pc_section): removed. Also removed BAD_RICH_HACK ifdefs.
- * symfile.h (find_pc_section): prototype removed. Also fixed
- comment typo NUL -> NULL.
- * target.[ch] (find_pc_section_from_targets): removed.
- * config/sparc/tm-sun4sol2.h (BAD_RICHH_HACK): removed.
-
-Tue Apr 6 21:41:13 1993 Stu Grossman (grossman@cygnus.com)
-
- * ser-go32.c: Format. (go32_open): Use proper return value.
-
- * configure.in: Undo conditional configdirs hack for sparclite.
-
-Tue Apr 6 17:07:37 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
-
- * symtab.c (list_symbols): When call break_command, pass both
- filename and function name not just function name.
-
-Tue Apr 6 15:00:09 1993 Fred Fish (fnf@cygnus.com)
-
- (Changes and new files to make "none" a full fledged configuration)
- * config/none/{nm-none.h, tm-none.h, xm-none.h}: New files.
- Currently only tm-none.h has any meaningful contents.
- * config/none/none.mh (NAT_FILE): Use nm-none.h
- * config/none/none.mh (XM_FILE): Use xm-none.h
- * config/none/none.mt (TM_FILE): Use tm-none.h
- * Makefile.in (depend): Remove comment about parse errors in
- valops.c, it now parses correctly and generates a correct depend
- line. Remove line that touches xm.h, tm.h, and nm.h; they are
- now linked to config/none/{xm-none.h, tm-none.h, nm-none.h}.
-
-Tue Apr 6 09:54:29 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * values.c (USE_STRUCT_RETURN): Only use gcc wierdness for gcc1.
-
- * xcoffread.c (read_xcoff_symtab): Deal correctly with symbols of
- exactly 8 characters.
-
-Tue Apr 6 10:31:26 1993 Stu Grossman (grossman@cygnus.com)
-
- * configure.in: Sparclite uses sparc config dir. Also has it's
- own tm- & .mt files now. Also add sparclite to configdirs.
- * go32-xdep.c: Dummy routines for sigsetmask & strlwr.
- * config/i386/go32.mh: Nullify def of TERMCAP.
- * config/i386/xm-go32.h: Get rid of redef of EIO.
- * config/sparc/{sparclite.mh tm-sparclite.h}: New sparclite
- specific configs. Very similar to sun4os4, but without solib.
- * sparclite/{Makefile.in configure.in}: First cut at making this
- dir configgable.
-
-Tue Apr 6 03:10:44 1993 Stu Grossman (grossman@cygnus.com)
-
- * ser-go32.c: First cut at adapting to new serial interface.
-
-Mon Apr 5 22:29:43 1993 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in (SFILES OBS): Add serial.[co] & ser-hardwire.[co].
- These implement a new serial line interface for talking to remote
- targets.
- * configure.in: Link ser-hardwire.c to ser-unix.c for all hosts,
- EXCEPT go32, which gets ser-go32.c.
- * remote.c: Use new serial interface. More remote-xxx's to be
- converted later.
- * ser-bsd.c, ser-termios.c: Removed.
- * serial.c: New. Implements common operations for all serial
- types.
- * ser-unix.c: New. Unix specific serial operations for various
- flavors of Unix (Posix, SysV, BSD).
- * serial.h: Generic serial interface defs.
- * config/i386/go32.mh, config/i386/i386bsd.h,
- config/m68k/apollo68b.mh, config/sparc/sun4os4.mh: Remove
- ser-bsd.o from XDEPFILES. All the magic is now handled in
- configure.in.
-
-Mon Apr 5 20:48:54 1993 Stu Grossman (grossman@cygnus.com)
-
- * config/h8500/tm-h8500.h: Clean up brain damage found by GCC.
-
-Fri Apr 2 08:23:14 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffread.c (xcoff_symfile_offsets): Use 0 not addr for offsets.
-
- * rs6000-tdep.c (frameless_function_invocation): Don't even think
- about framelessness except on the innermost frame.
-
- * xcoffexec.c: Call fatal() not abort().
-
- * stabsread.c (patch_block_stabs): If stab & no symbol, make
- a LOC_OPTIMIZED_OUT symbol.
- symtab.h (enum address_class): Add LOC_OPTIMIZED_OUT.
- findvar.c (read_var_value), printcmd.c (address_info),
- symmisc.c (print_{,partial_}symbol), c-exp.y (variable),
- m2-exp.y (yylex): Deal with it.
- ch-exp.y (yylex): Deal with it.
-
-Thu Apr 1 18:43:02 1993 Stu Grossman (grossman@cygnus.com)
-
- * findvar.c (value_from_register): H8500 specific, check to see
- if we are looking at short pointer. If so, skip crock.
- * h8500-tdep.c (h8500_frame_chain): Mask down value from
- read_memory_integer() to avoid getting messed up by sign extension.
-
-Thu Apr 1 16:44:41 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * sparc-tdep.c (in_solib_trampoline), symfile.c (find_pc_section):
- ifdef protect using BAD_RICH_HACK. This should be removed soon.
- * config/sparc/tm-sun4sol2.h (BAD_RICH_HACK): define.
-
-Thu Apr 1 09:01:38 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * i960-pinsn.c, a29k-pinsn.c: Much abridged, just use libopcodes.a.
-
- * core.c (dis_asm_print_address): New function.
-
- * core.c (dis_asm_read_memory): Reinstate 4th arg. The prototype
- has been fixed.
-
-Thu Apr 1 09:34:43 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * breakpoint.c (bpstat_print, bpstat_stop_status): Change to walk the
- entire breakpoint chain and print only the first entry that needs to
- be printed and needs to be stopped for. Fixes problems with printing
- of multiple breakpoints with different conditions.
- * breakpoint.c (print_it_done): Renamed from print_it_noop as it
- effectively stops printing of the breakpoint chain.
- * breakpoint.c (print_it_noop): New routine to print nothing
- for this breakpoint entry and dont stop printing.
- * breakpoint.c (breakpoint_re_set_one): mention the reevaluated
- watchpoint only if it is enabled.
- * mipsread.c (parse_procedure): Correct incorrect setjmp procedure
- descriptor from the library to make backtraces through setjmp work.
- * mipsread.c (fixup_sigtramp): Correct pcreg and fregoffset for
- sigtramp.
- * mips-tdep.c (read_next_frame_reg): Provide correct values for
- all registers saved within sigtramp, cleanup.
-
-Wed Mar 31 12:52:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * sparc-pinsn.c: Much abridged, just calls version in libopcodes.a.
-
-Wed Mar 31 21:23:41 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * core.c (dis_asm_read_memory): drop fourth arg which conflicts
- with prototype in ../include/dis-asm.h.
-
-Wed Mar 31 12:52:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * core.c (dis_asm_{read_memory,memory_error}): New functions.
- m68k-pinsn.c, h8500-tdep.c, i386-pinsn.c, mips-pinsn.c, z8k-tdep.c:
- Use read_memory_func interface to disassembler.
-
-Tue Mar 30 15:46:14 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- Teach sparc solaris to next over shared library functions.
- * solib.[hc] (find_pc_section_from_so_list): new function and
- prototype.
- * sparc-tdep.c (in_solib_trampoline): new function.
- * symfile.[hc] (find_pc_section): new function and prototypes.
- * target.[hc] (find_pc_section_from_targets): new function and
- prototypes.
- * config/sparc/tm-sun4sol2.h (IN_SOLIB_TRAMPOLINE): redefine to
- in_solib_trampoline.
-
-Tue Mar 30 08:06:24 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * infrun.c (wait_for_inferior): Revise comment.
-
- * command.c (do_setshow_command): Use %u with var_{u,z}integer.
-
- * command.{c,h}: New var_type var_integer.
- main.c: Use it for history_size.
-
- * rs6000-tdep.c, xcoffexec.c, config/rs6000/xm-rs6000.h, breakpoint.c:
- Lint and byte-order fixups.
-
- * breakpoint.c (print_it_normal): Return 0 after hitting watchpoint.
-
- * breakpoint.h (bpstat): New field print_it.
- breakpoint.c (bpstat_print): Use it.
- (print_it_normal): New function (from old bpstat_print code).
- (bpstat_{alloc,stop_status}): Set print_it field.
-
- * breakpoint.c (bpstat_stop_status): Use catch_errors when
- evaluating watchpoint condition, via new function watchpoint_check.
- Also stop if watchpoint disabled due to leaving its block.
-
- * findvar.c [REG_STRUCT_HAS_ADDR]: Add comment.
-
-Tue Mar 30 00:14:38 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mips-pinsn.c: Add missing include of dis-asm.h.
-
-Mon Mar 29 15:03:25 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (clean, distclean, realclean): Recursively apply
- to subdirs first, rather than last. This avoids, for example,
- Makefile being removed in a parent directory before the recursive
- make is run.
-
- * alldeps.mak, depend: Update for below changes.
-
- * config/m68k/tm-m68k.h: Renamed from config/m68k/tm-68k.h.
- * m68k/{tm-3b1.h, tm-altos.h, tm-amix.h, tm-es1800.h,
- tm-hp300bsd.h, tm-hp300hpux.h, tm-isi.h, tm-news.h, tm-os68k.h,
- tm-st2000.h, tm-sun2.h, tm-sun3.h, tm-vx68.h}: Include tm-m68k.h
- instead of tm-68k.h.
- * Makefile.in (HFILES): tm-68k.h renamed to tm-m68k.h.
- * README, a29k-pinsn.c, m68k-pinsn.c, m68k-stub.c, remote-vx.c,
- m68k/{altos.mh, altos.mt, apollo68b.mh, nm-apollo68b.h,
- nm-hp300bsd.h, config/m68k/xm-apollo68b.h}: Map '68k' to 'm68k'.
- * a29k/tm-a29k.h, doc/gdbint.texinfo: Account for renaming of
- tm-68k.h to tm-m68k.h.
- * m68k/m68k-fp.mt (TM_FILE): tm-68k-fp.h renamed to tm-m68k-fp.h.
- * m68k/m68k-nofp.mt (TM_FILE): tm-68k-nofp.h renamed to
- tm-m68k-nofp.h.
-
- * config/a29k/tm-a29k.h: Renamed from config/a29k/tm-29k.h.
- * a29k-pinsn.c: Renamed from am29k-pinsn.c.
- * a29k-tdep.c: Renamed from am29k-tdep.c.
- * remote-eb.c, config/a29k/tm-ultra3.h: Include renamed tm-a29k.h.
- * remote-monitor.c, remote-st2000.c, config/a29k/{nm-ultra3.h,
- tm-a29k.h, xm-ultra3.h}, config/romp/rtbsd.mh, doc/gdbinv-s.texi,
- testsuite/gdb.t15/funcargs.exp, testsuite/gdb.t17/callfuncs.exp:
- Map '29k' to 'a29k'.
- * config/a29k/{a29k-kern.mt, a29k-udi.mt, a29k.mt, ultra3.mt}
- (TDEPFILES): Use renamed a29k-pinsn.o and a29k-tdep.o.
- * config/a29k/{a29k-udi.mt, a29k.mt} (TM_FILE): Use renamed
- tm-a29k.h.
- * config/a29k/a29k-udi.mt (MT_CFLAGS): Remove TARGET_AM29K
- define that does not appear anywhere else in the gdb source tree.
- * doc/gdbinit.texinfo: Document renaming of tm-29k.h to tm-a29k.h.
-
-Mon Mar 29 13:55:29 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * breakpoint.c: Add comments regarding breakpoint_re_set.
-
- * xcoffread.c (sort_syms, compare_symbols): Remove.
- (xcoff_symfile_read): Use sort_all_symtab_syms from symfile.c
- not our own sort_syms (it is identical).
-
- * xcoffread.c: Nuke NAMES_HAVE_DOT define (not used).
-
-Sun Mar 28 11:24:37 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * breakpoint.c (breakpoint_re_set_one): Fix storage leak.
- * breakpoint.c (enable_breakpoint): Don't enable watchpoint if it
- went out of scope.
- * exec.c (exec_close): Fix storage leak.
- * exec.c (exec_file_command): Make sure that bfd doesn't realign the
- output sections when patching an executable.
- * mips-nat.c (store_inferior_registers): Use REGISTER_PTRACE_ADDR
- when writing all registers.
- * mips-tdep.c (mips_push_dummy_frame): Save floating point registers
- at the right offset in the dummy frame.
- * mipsread.c (psymtab_to_symtab_1): Do not complain for stProc,
- stStaticProc and stEnd symbols as they are generated by gcc-2.x.
- * mipsread.c (mipscoff_new_init): Initialize stabsread and buildsym.
-
-Fri Mar 26 15:25:05 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (TARFILES): Avoid trailing backslash.
-
-Fri Mar 26 11:29:30 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * breakpoint.{c,h}: Add exp_string to struct breakpoint and use
- it in breakpoint_re_set.
- * breakpoint.c (watch_command, enable_breakpoint): Fetch lazy values.
-
- * rs6000-tdep.c (single_step): Misc cleanups (CORE_ADDR not int,
- don't use sizeof(int) for target stuff, etc).
-
-Thu Mar 25 15:03:53 1993 Fred Fish (fnf@cygnus.com)
-
- * alldeps.mak, configure.in, i860-break.h, i860-opcode.h,
- i860-pinsn.c, i860-tdep.c, config/i860/*: Remove incomplete i860
- support that can't be integrated anyway due to lack of clear
- authorship.
-
-Thu Mar 25 12:26:50 1993 Stu Grossman (grossman@cygnus.com)
-
- * findvar.c (read_register, write_register): Make these capable
- of reading/writing registers that are shorter than REGISTER_TYPE.
- * (value_from_register): Install H8500 specific code to return
- proper value when register is being used as a pointer.
- * h8500-tdep.c: Remove extra defines of NUM_REGS.
- (h8500_skip_prologue): Use correct lengths for LINK instructions.
- (FRAME_CHAIN): Change name to h8500_frame_chain. Rewrite code to
- chain frames properly by combining frame pointer with T reg.
- (init_extra_frame_info): Delete. It's now a macro.
- (frame_args_address): Don't add PTR_SIZE. Stack args are already
- offset by the correct amount off of the frame pointer.
- (register_byte): Delete. It's now a macro.
- (register_raw_size, register_virtual_size): Delete. Replaced by
- common routine h8500_register_size, cuz there's no difference
- between the raw & virtual sizes on this machine.
- (register_convert_to_raw, register_convert_to_virtual): Delete,
- cuz there's no difference between the raw & virtual forms.
- Replaced by memcpy in tm file.
- (register_virtual_type): Rename to h8500_register_virtual_type.
- Get rid of pointer pseudo-regs, use _REGNUM with all reg names.
- (_initialize_h8500_tdep): Get rid of crock to ensure that GDB &
- emulator have same reg offsets. This is all handled in the
- simulator code now.
- (h8500_trapped_internalvar): New routine to detect references to
- convenience vars acting as pointer pseudo-regs.
- (h8500_value_trapped_internalvar): Conjure up value of pointer
- pseudo-regs.
- (h8500_set_trapped_internalvar): Convert set value in real
- register references.
- infcmd.c (read_pc, write_pc): Add h8500 specific code to handle
- code segment register.
- infrun.c (proceed): Simplify. Call write_pc instead of doing it
- by hand.
- (wait_for_inferior): Add h8500 specific code to add stack segment
- when reading SP register.
- remote-sim.c (fetch_register): Spacing.
- tm-h8500.h: #define GDB_TARGET_IS_H8500 to make it easier to
- detect cruft. Redo all register manipulation stuff. Get rid of
- pointer pseudo-regs. (INIT_EXTRA_FRAME_INFO): Adds stack segment
- to frame pointer. (IS_TRAPPED_INTERNALVAL,
- VALUE_OF_TRAPPED_INTERNALVAR, SET_TRAPPED_INTERNALVAR): Use these
- to create internal vars for pointer pseudo-regs.
-
-Thu Mar 25 10:10:28 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in: Numerous small changes to macro definitions
- and rules for building gdb distribution tree. Many macros
- eliminated or merged, and rules simplified.
- * alldeps.mak: Update.
- * depend: Update.
-
-Wed Mar 24 13:52:29 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
-
- * Makefile.in: recurse through SUBDIRS for dvi target too
-
-Wed Mar 24 08:48:30 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * Clean up xcoff relocation.
- objfiles.h (struct objfiles): Add section_offsets, num_sections.
- symfile.c (syms_from_objfile), xcoffread.c (xcoff_symfile_offsets):
- Set them.
- symtab.h (struct general_symbol_info): Add section field.
- minsyms.c (prim_record_minimal_symbol{,_and_info}): Set it.
- xcoffread.c: Set section for symbols and msymbols.
- (struct symtab): Add block_line_section field.
- buildsym.c (end_symtab): Set it.
- (end_symtab and callers): Add section parameter.
- objfiles.c (objfile_relocate): New funciton.
- xcoffexec.c (vmap_symtab): Use it.
- xcoffsolib.h (struct vmap): Remove unused fields.
- config/rs6000/tm-rs6000.h, stack.c, xcoffexec.c: Remove
- CORE_NEEDS_RELOCATION, symtab_relocated.
- config/rs6000/tm-rs6000.h: Remove use of loadinfotext.
- rs6000-tdep.c: Make loadinfotext static.
- breakpoint.c (fixup_breakpoints): Doc fix.
- symtab.h (struct symtab), config/rs6000/tm-rs6000.h, buildsym.c
- (end_symtab): primary field replaces nonreloc.
-
-Tue Mar 23 00:10:53 1993 John Gilmore (gnu@cygnus.com)
-
- * symtab.h (struct linetable_entry): Remove confusing comment.
-
-Tue Mar 23 00:01:23 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: add installcheck target
-
-Mon Mar 22 16:17:58 1993 Fred Fish (fnf@cygnus.com)
-
- * config/{a29k, arm, convex, gould, h8300, i386, i860, i960, m68k,
- m88k, mips, none, ns32k, pa, pyr, romp, rs6000, sparc, tahoe, vax,
- z8k}: New directories to hold cpu specific configuration files.
- Naming follows gcc convention.
- * config/{*.mt, *.mh}: All target and host makefile fragment
- config files moved to an appropriate config/<cpu> subdirectory.
- * nm-*, xm-*, tm-*: All native, host, and target files, which
- get linked to nm.h, xm.h, and tm.h respectively by configure,
- moved to appropriate config/<cpu> subdirectory.
- * nm-sysv4.h, xm-sysv4.h, tm-sysv4.h, tm-sunos.h, nm-trash.h:
- Native, host, and target files that are common across more than
- one cpu architecture and included by one of the configured
- native, host, or target files, get moved to config directory.
- * Makefile.in (INCLUDE_CFLAGS): Add -I${srcdir}/config to
- pick up native, host, or target include files moved to one of
- the config subdirectories, and that are included by other files.
- * Makefile.in (alldeps.mak): Modify to account for new config
- directory structure.
- * alldeps.mak, depend: Update for new config directory structure.
- * config/*/[ntx]m-*.h: Modify all files that include other
- [ntx]m-*.h files to use path relative to gdb/config. I.E.
- "a29k/tm-ultra3.h" includes "a29k/tm-29k.h" rather than just
- "tm-29k.h".
- * remote-eb.c (tm-29k.h): Include a29k/tm-29k.h.
- * mipsread.c (tm-mips.h): Include mips/tm-mips.h.
- * i860-pinsn.c (tm-i860.h): Include i860/tm-i860.h.
- * configure.in: Default gdb_host_cpu to host_cpu, and remap
- the ones where the default is not unique or different than the
- config subdirectory name. Similarly, handle gdb_target_cpu.
- Modify configure.in as appropriate to make use of gdb_host_cpu
- and gdb_target_cpu to find makefile fragments and make links.
-
-Mon Mar 22 12:36:24 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mipsread.c (compare_blocks): Sort blocks with the same start
- address by decreasing ending address.
-
-Mon Mar 22 20:36:04 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mipsread.c (parse_procedure): Save cur_fdr accross call to
- lookup_symbol as it might get clobbered by the call.
-
- * mipsread.c (parse_partial_symbols): Use ADD_PSYMBOL_ADDR_TO_LIST.
- The previous code did not initialize the language field for the psymtab
- entry.
-
-Sat Mar 20 00:33:39 1993 John Gilmore (gnu@cygnus.com)
-
- * c-exp.y (parse_number): Avoid shift warning.
- * serial.h (struct ttystate): Declare empty one on DOS.
-
-Fri Mar 19 12:59:50 1993 Stu Grossman (grossman@cygnus.com)
-
- * xm-sun4os4.h: Return type of free() should be void, not int.
-
- * vx-share/vxWorks.h: Remove #def of NULL.
-
-Fri Mar 19 11:28:18 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * tm-rs6000.h: Nuke no-op STAB_REG_TO_REGNUM.
-
-Fri Mar 19 07:40:09 1993 Steve Chamberlain (sac@cygnus.com)
-
- * z8k-tdep.c (print_insn): Include the new dis-asm header file.
-
-Thu Mar 18 14:26:57 1993 Per Bothner (bothner@rtl.cygnus.com)
-
- * ieee-float.c: Moved to ../libiberty.
- * ieee-float.h: Moved to ../include.
- * Makefile.in: Update accordingly.
- * i386-pinsn.c (print_insn), m68k-pinsn.c (print_insn):
- Convert to stubs that call disassemblers in ../opcodes/*-dis.c.
- * m68k-tdep.c: Removed definition of ext_format ext_format_68881;
- it is now in ../opcodes/m68881-ext.c.
- * mips-tdep.c (mips_skip_prologue): Try to skip more of the
- prologue (some callers _do_ care).
- * mips-pinsn.c (print_insn), z8k-tdep.c (print_insn): Convert to
- new interface of ../opcodes/*-dis.c.
- * ch-exp.y: Add #include <ctype.h>.
-
-Thu Mar 18 11:57:49 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffexec.c (exec_close): Don't close exec_bfd twice.
-
- * xcoffread.c (enter_line_range): endaddr is exclusive, not inclusive.
-
-Wed Mar 17 09:46:31 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffread.c (arrange_linetable): Use x{m,re}alloc not {m,re}alloc.
-
-Wed Mar 17 11:28:11 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * z8k-tdep.c (extract_return_value, write_return_value,
- store_struct_return): New functions from macros in tm-z8k.h.
-
-Wed Mar 17 11:23:06 1993 Fred Fish (fnf@cygnus.com)
-
- * valops.c (value_arg_coerce): Apply temporary patch to
- fix problem with coercion of array and function types when
- passed as arguments to C functions, pending a more complete
- review of when and how coercion should be done, depending
- upon context and language.
-
-Wed Mar 17 09:46:31 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffread.c (MIN_TBTABSIZ): Change to 12.
-
- * xcoffread.c (xcoff_symfile_read): Only read stringtab and
- debugsec if there are a non-zero number of symbols.
-
-Tue Mar 16 18:08:45 1993 John Gilmore (gnu@cygnus.com)
-
- * command.c (show_user): Avoid fprintf_filtered botch (AGAIN!).
-
-Tue Mar 16 15:18:17 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffexec.c (add_vmap): Wrap symbol read in catch_errors.
-
- * xcoffread.c (read_symbol_lineno): Look to end of symbols for .bf,
- not just 50 symbols.
- (symtbl_num_syms): New variable.
- (read_xcoff_symtab): Set it.
- (read_symbol_nvalue): Check for bad symno.
- (read_symbol_{lineno,nvalue}, callers): Don't pass symtable; it's
- always symtbl.
-
-Tue Mar 16 10:09:05 1993 Stu Grossman (grossman@cygnus.com)
-
- * config/rs6000.mh: Get rid of -Dfd_set=int crock.
- This is defined in defs.h if necessary.
- * vx-share/vxWorks.h: Remove #defs of min and max.
- * vx-share/xdr_ld.c, vx-share/xdr_ptrace.c,
- vx-share/xdr_rdb.c: include defs.h.
-
-Fri Mar 12 09:33:23 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffread.c (retrieve_tracebackinfo): Move assignment out
- of while condition.
-
- * xcoffread.c (enter_line_range): complain() on bad endoffset.
- xcoffread.c: Doc fixes.
-
-Tue Mar 9 09:56:12 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * tm-rs6000.h (CORE_NEEDS_RELOCATION): Just call xcoff_relocate_core.
- xcoffexec.c (xcoff_relocate_core): New function.
- (text_adjustment): Removed.
- (add_vmap): Return the vmap.
- rs6000-tdep.c (add_text_to_loadinfo): No longer static.
-
-Fri Mar 5 05:22:46 1993 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffsolib.h: Add objfile member to struct vmap.
- xcoff{exec,solib}.c: Use it, not lookup_objfile_bfd.
- xcoffexec.c (add_vmap): Allocate objfiles here.
-
-Sun Mar 14 02:54:15 1993 John Gilmore (gnu@cygnus.com)
-
- Support 68000 series without floating point.
-
- * configure.in (m68000-*-{aout,elf,coff}): New configs.
- * tm-68k-nofp.h: New file, lacks 68881 support.
- * config/m68k-nofp.mt: New file.
-
-Sun Mar 14 02:30:08 1993 John Gilmore (gnu@cygnus.com)
-
- Remove a few remaining underscore/no-underscore remnants from
- config files.
-
- * config/{m68k-un.mt, sparc-un.mt}: Remove.
- * config/m68k-noun.mt: Rename to m68k-fp.mt.
- * config/sparc-noun.mt: Rename to sparc-em.mt.
- * tm-68k-noun.h, tm-spc-noun.h: Remove.
- * tm-68k-un.h: Rename to tm-68k-fp.h.
- * tm-spc-un.h: Rename to tm-spc-em.h.
- * tm-sun4sol2.h: Cleanup.
- * configure.in (m68k-*, sparc-* targets): Corresponding changes.
-
-Sat Mar 13 14:58:22 1993 John Gilmore (gnu@cygnus.com)
-
- * symmisc.c (std_in, std_out, std_err): Move initializations
- to runtime code, in case they aren't constant.
-
-Fri Mar 12 16:23:54 1993 K. Richard Pixley (rich@cygnus.com)
-
- * symtab.c (find_pc_symtab): some object file formats, notably
- mips, have holes in the address ranges of symtabs. Change
- this algorithm from first hit to tightest fit.
-
- * mips-tdep.c (heuristic_proc_start): if we walk the pc into the
- fence post without finding the enclosing function, then print a
- warning.
-
-Thu Mar 11 09:33:01 1993 Fred Fish (fnf@cygnus.com)
-
- * utils.c (fputs_demangled, fprint_symbol): Remove.
- * utils.c (fprintf_symbol_filtered): New function which combines
- the functionality of fputs_demangled and fprint_symbol. Uses a
- caller provided language parameter to select the appropriate
- demangler, and caller provided args to pass to the demangler.
- * defs.h (enum language): Move further up in file so enum can
- be used in prototypes.
- * defs.h (fputs_demangled, fprint_symbol): Remove prototypes.
- * defs.h (fprintf_symbol_filtered): Add prototype.
- * c-typeprint.c (cp_type_print_method_args): Replace calls to
- fputs_demangled with call to fprintf_symbol_filtered.
- * cp-valprint.c (demangle.h): Include
- * cp-valprint.c (cp_print_value_fields): Replace calls to
- fprint_symbol with calls to fprintf_symbol_filtered.
- * printcmd.c (print_frame_args): Replace call to fprint_symbol
- with call to fprintf_symbol_filtered.
- * stack.c (print_frame_info): Remove obsolete code so we don't
- have to update fputs_demangled usage in it.
- * stack.c (print_frame_info, frame_info): Add language variable
- to pass to fprintf_symbol_demangled and initialize it from the
- symbol's language. Replace calls to fputs_demangled with calls
- to fprintf_symbol_filtered.
- * symtab.c (find_methods): Replace call to fputs_demangled with
- call to fprintf_symbol_filtered.
- * ch-valprint.c (demangle.h): Include.
- * ch-valprint.c (chill_print_value_fields): Replace call to
- fprint_symbol with call to new fprintf_symbol_filtered.
-
-Wed Mar 10 17:37:11 1993 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump version to 4.8.2.
-
- * main.c (source_command): Require an explicit pathname of file
- to source, since previous behavior of defaulting to gdb init file
- was troublesome and undocumented.
- * printcmd.c (disassemble_command): Add missing '{}' pair to
- else with two statements. Bug reported by Stephane Tsacas
- <slt@isoft.fr>.
- * symtab.c (find_pc_line): Don't complain about zero length or
- negative length line numbers for the moment, since we may not own
- the terminal when called, such as when single stepping. (FIXME)
- * language.h (CAST_IS_CONVERSION): True if current language is
- C++ as well as C. Fix from Peter Schauer.
- * environ.c (get_in_environ, set_in_environ, unset_in_environ):
- Use STREQN macro rather than bare '!strncmp()'.
- * environ.c (unset_in_environ): Avoid use of memcpy on
- overlapping memory regions, as suggested by Paul Eggert
- <eggert@twinsun.com>.
- * c-exp.y (%union struct): Remove unused ulval as suggested
- by Paul Eggert <eggert@twinsun.com>.
-
-Mon Mar 8 19:03:06 1993 Fred Fish (fnf@cygnus.com)
-
- * main.c (gdbinit): Make static.
- * main.c (inhibit_gdbinit): Move to file scope.
- * main.c (main): Remove local inhibit_gdbinit.
- * main.c (source_command): Don't source '.gdbinit' file by
- default if gdb has been told to ignore it.
-
-Sun Mar 7 21:58:53 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (MAKEOVERRIDES): Define to be empty for GNU Make
- 3.63.
-
-Fri Mar 5 17:39:45 1993 John Gilmore (gnu@cacophony.cygnus.com)
-
- * printcmd.c (print_address_symbolic): Only print if offset
- is shorter than max_symbolic_offset.
- (initialize_printcmd): `set print max-symbolic-offset'.
-
- * am29k-tdep.c (TAGWORD_ZERO_MASK): New #define.
- (examine_tag): Use it.
- (read_register_stack): Only look in the local registers for a
- memory address if it's between rfb and rsp; go to memory otherwise.
- (initialize_29k): Fix call_scratch_address doc. Remove reginv_com.
- (reginv_com): Remove ancient kludge command.
-
-Fri Mar 5 17:16:26 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * tm-irix3.h (ZERO_REGNUM): copy this macro from tm-mips.h so that
- irix4 will again compile.
-
- * tm-mips.h (GDB_TARGET_IS_MIPS): no longer used, now removed.
-
- * configure.in: accept mips-sgi-irix4* for irix4.
-
-Fri Mar 5 07:49:48 1993 Steve Chamberlain (sac@lisa.cygnus.com)
-
- * z8k-tdep.c (print_register_hook): Lint.
-
-Thu Mar 4 17:42:03 1993 John Gilmore (gnu@cygnus.com)
-
- Lint fixes from Paul Eggert (eggert@twinsun.com):
-
- * command.c (do_setshow_command): var_uintegers are unsigned.
- * sparc-tdep.c (save_insn_opcodes, restore_insn_opcodes):
- unsigned, since they use hex values with the high bit set.
-
-Thu Mar 4 08:22:55 1993 Fred Fish (fnf@cygnus.com)
-
- Fixes submitted by Karl Berry (karl@nermal.hq.ileaf.com):
- * m88k-pinsn.c (sprint_address): Use SYMBOL_NAME macro to
- access symbol name.
- * m88k-nat-c (SXIP_OFFSET, SNIP_OFFSET, SFIP_OFFSET): Enclose
- macro definitions in parenthesis.
-
- * dbxread.c (dbx_symfile_init): Catch the case where there is
- no string table, but the only way we find out is by reading zero
- bytes from EOF.
-
-Wed Mar 3 15:51:28 1993 Fred Fish (fnf@cygnus.com)
-
- * dbxread.c (dbx_symfile_init): Make size of the string table
- size field a define (DBX_STRINGTAB_SIZE_SIZE). Ensure that the
- offset to the string table is nonzero and handle the nonexistant
- string table case, should it occur. Ensure that the string table
- size read from the file is reasonable, with a minimum lower bound
- of DBX_STRINGTAB_SIZE_SIZE instead of zero.
-
-Wed Mar 3 07:23:03 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in: Changes to build testsuite correctly.
- (FLAGS_TO_PASS): Added CXX and CXXFLAGS.
- (CC_FOR_TARGET, CXX, CXX_FOR_TARGET): New variables.
- (TARGET_FLAGS_TO_PASS): New variable.
- (SUBDIRS): Added testsuite.
- (all): Build testsuite using TARGET_FLAGS_TO_PASS, so that
- testsuite is compiled with CC_FOR_TARGET rather than CC.
-
-Tue Mar 2 17:57:56 1993 Fred Fish (fnf@cygnus.com)
-
- * dbxread.c (dbx_symfile_init): Fix for nonexistant string table,
- reported by mycroft@gnu.ai.mit.edu.
-
- (Ultrix 2.2 support from Michael Rendell <michael@mercury.cs.mun.ca>)
- * configure.in (vax-*-ultrix2*): New triplet.
- * config/vaxult2.mh: New file.
- * xm-vaxult2.h: New file.
-
- * c-exp.y (parse_number): Change high_bit to unsigned.
- * demangle.c: Change all references to cfront to ARM, since the
- actual algorithm is the one specified in the Annotated Reference
- Manual. This was confusing users into thinking that full cfront
- support was implemented.
- * dwarfread.c (CFRONT_PRODUCER): Remove, was never really used.
- * eval.c (evaluate_subexp): For STRUCTOP_PTR pass the arg type
- directly to lookup_struct_elt_type, which will do the
- dereferencing itself.
- * gdbtypes.c (lookup_struct_elt_type): Expand comments. Fix
- NULL dereferencing bug for unnamed structs, comment out
- questionable code.
-
-Mon Mar 1 17:54:41 1993 John Gilmore (gnu@cygnus.com)
-
- * coffread.c (process_coff_symbol): Change PCC argument correction
- so that it only happens on big-endian targets; so that it only
- happens if the short or char argument is aligned on an int
- boundary; and so that it changes the location, rather than the
- type, of the argument. These changes tend to parallel similar
- (old) changes in stabsread.c.
-
- * coffread.c (coff_read_enum_type): Use the specified size for
- enums, don't assume that they are int-sized.
-
- * c-valprint.c (c_val_print): Don't assume enums are the same as
- ints.
-
- * coredep.c: Handle NO_PTRACE_H in coredep.c. Fix by Michael
- Rendell, <michael@mercury.cs.mun.ca>.
-
-Mon Mar 1 09:25:57 1993 Fred Fish (fnf@cygnus.com)
-
- * language.h (local_decimal_format_custom): Add prototype.
- * language.c (local_decimal_format_custom): Add function, bug
- reported by Robert R. Henry (rrh@tera.com).
-
-Fri Feb 26 18:33:18 1993 John Gilmore (gnu@cacophony.cygnus.com)
-
- * xcoffexec.c (vmap_ldinfo): Fix "/" for '/' typo, reported
- by Josef Leherbauer, joe@takeFive.co.at.
-
-Wed Feb 24 19:17:11 1993 John Gilmore (gnu@cacophony.cygnus.com)
-
- * symfile.c (syms_from_objfile), tm-29k.h, tm-3b1.h, tm-68k-un.h,
- tm-altos.h, tm-arm.h, tm-convex.h, tm-es1800.h, tm-h8300.h,
- tm-hp300bsd.h, tm-hp300hpux.h, tm-hppa.h, tm-i386bsd.h,
- tm-i386v.h, tm-i960.h, tm-irix3.h, tm-isi.h, tm-linux.h,
- tm-m88k.h, tm-merlin.h, tm-mips.h, tm-news.h, tm-np1.h, tm-pn.h,
- tm-pyr.h, tm-rs6000.h, tm-spc-un.h, tm-sun386.h, tm-sunos.h,
- tm-symmetry.h, tm-sysv4.h, tm-tahoe.h, tm-umax.h, tm-vax.h,
- tm-vx68.h, tm-z8k.h: Remove remnants of NAMES_HAVE_UNDERSCORE.
-
-Wed Feb 24 07:41:15 1993 Fred Fish (fnf@cygnus.com)
-
- * symtab.h (SYMBOL_INIT_DEMANGLED_NAME): Initialize contents
- of demangled name fields to NULL if no demangling exists for
- a symbol. SYMBOL_INIT_LANGUAGE_SPECIFIC does this for new
- symbols if their language is known at the time they are created,
- but sometimes the language is not known until later.
-
- * ch-typeprint.c (chill_print_type_base): Name changed to
- chill_type_print_base to match pattern for C and C++ names.
- * ch-typeprint.c (chill_print_type): Change "char" to "CHAR"
- to be consistent with other usages.
- * ch-typeprint.c (chill_type_print_base): Add support for
- printing Chill STRUCT types.
- * ch-valprint.c: Include values.h.
- * ch-valprint.c (chill_print_value_fields): New function and
- prototype for printing Chill STRUCT values.
- * ch-valprint.c (chill_val_print): Fix call to val_print_string
- that was being called with two args instead of three.
- * ch-valprint.c (chill_val_print): Call chill_print_value_fields
- to print Chill STRUCT values.
-
-Tue Feb 23 18:58:11 1993 Mike Werner (mtw@poseidon.cygnus.com)
-
- * configure.in: added testsuite to configdirs.
-
-Tue Feb 23 11:46:11 1993 Mike Stump (mrs@cygnus.com)
-
- * doc/stabs.texi: The `this' pointer is now known by the name
- `this' instead of `$t'.
-
-Tue Feb 23 11:21:33 1993 Fred Fish (fnf@cygnus.com)
-
- * dwarfread.c (read_tag_string_type): Rewrite to allow forward
- references of TAG_string_type DIEs in user defined types.
- * ch-lang.c (chill_create_fundamental_type): Track compiler
- change that now emits debugging info with the type long for Chill
- longs.
-
-Mon Feb 22 15:21:54 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * remote-mips.c: New file; implements MIPS remote debugging
- protocol.
- * config/idt.mt: New file; uses remote-mips.c
- * configure.in (mips-idt-ecoff): New target; uses idt.mt.
-
- * mips-tdep.c (mips_fpu): New variable; controls use of MIPS
- floating point coprocessor.
- (mips_push_dummy_frame): If not mips_fpu, don't save floating
- point registers.
- (mips_pop_frame): If not mips_fpu, don't restore floating point
- registers.
- (_initialize_mips_tdep): New function; let the user reset mips_fpu
- variable.
- * tm-mips.h (EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE): If not
- mips_fpu, don't use fp0 as floating point return register.
- (FIX_CALL_DUMMY): If not mips_fpu, don't save floating point
- registers.
-
-Mon Feb 22 07:54:03 1993 Mike Werner (mtw@poseidon.cygnus.com)
-
- * gdb/testsuite: made modifications to testcases, etc., to allow
- them to work properly given the reorganization of deja-gnu and the
- relocation of the testcases from deja-gnu to a "tool" subdirectory.
-
-Sun Feb 21 10:55:55 1993 Mike Werner (mtw@poseidon.cygnus.com)
-
- * gdb/testsuite: Initial creation of gdb/testsuite.
- Migrated dejagnu testcases and support files for testing nm to
- gdb/testsuite from deja-gnu. These files were moved "as is"
- with no modifications. This migration is part of a major overhaul
- of dejagnu. The modifications to these testcases, etc., which
- will allow them to work with the new version of dejagnu will be
- made in a future update.
-
-Fri Feb 19 18:36:55 1993 John Gilmore (gnu@cygnus.com)
-
- * NEWS: Add reminders for next release.
-
-Fri Feb 19 10:01:39 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mipsread.c (parse_lines): Correct check for files compiled with
- -g1.
-
-Fri Feb 19 05:56:15 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (VERSION): 4.8.1 to distinguish local versions.
-
-Fri Feb 19 01:32:58 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (VERSION): GDB-4.8 release!
- * README, NEWS: Update for release.
-
-Thu Feb 18 22:44:40 1993 Stu Grossman (grossman@cygnus.com)
-
- * am29k-pinsn.c (print_insn): Minor nits with const.
- * am29k-tdep.c: More minor nits with arg types for
- supply_register, NULL vs. 0, read_register_gen, & reginv_com.
-
-Thu Feb 18 22:38:03 1993 John Gilmore (gnu@cygnus.com)
-
- * gcc.patch: Update for a different GCC (G++) bug.
- * main.c (print_gdb_version): Update copyright year to 1993.
- * nm-hp300bsd.h: Decide whether this is BSD 4.3 or 4.4,
- conditionalize this file on it. FIXME, right way is to split
- these into two config files.
- (ATTACH_DETACH): Define for BSD 4.4
- (PTRACE_ARG_TYPE): caddr_t for BSD 4.4, unset for 4.3.
- (U_REGS_OFFSET): Revise for 4.4.
- (REGISTER_U_ADDR): Separate for 4.4, but it doesn't work yet.
- * xm-hp300bsd.h: Move definitions of UINT_MAX, INT_MAX, INT_MIN,
- LONG_MAX into this file to avoid cpp "redefinition" warnings.
-
-Thu Feb 18 16:13:28 1993 K. Richard Pixley (rich@rtl.cygnus.com)
-
- * nm-hp300bsd.h (PTRACE_ARG3_TYPE): FSF's hp300's have int* not
- caddr_t.
-
-Thu Feb 18 04:10:06 1993 John Gilmore (gnu@cygnus.com)
-
- * c-lang.c (c_printstr): Bugfix for length==0 case.
-
- * c-lang.c (c_printstr): If a C string ends in a null, don't
- print the null.
-
-Thu Feb 18 02:39:21 1993 Stu Grossman (grossman at cygnus.com)
-
- * defs.h (STRCMP): Make it work for unsigned chars.
-
-Thu Feb 18 01:56:06 1993 John Gilmore (gnu@cygnus.com)
-
- * nm-hp300bsd.h (ATTACH_DETACH, PTRACE_ATTACH, PTRACE_DETACH): define.
- * config/hp300bsd.mh (REGEX, REGEX1): Define.
- * m68k-pinsn.c (BREAK_UP_BIG_DECL, AND_OTHER_PART): #if __GNUC__,
- define to kludge the large opcode table into two smaller tables,
- since GCC take exponential space to build the table. Lint.
- (NOPCODES): Remove, use "numopcodes" from opcode/m68k.h instead.
-
-Wed Feb 17 19:24:40 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (VERSION): Roll to 4.7.9.
- * xm-hp300bsd.h: Define PSIGNAL_IN_SIGNAL_H and put a compatible
- definition here, to handle both BSD 4.3 and 4.4 systems.
- * mipsread.c (ZMAGIC): #undef to avoid duplicate define.
- * remote.c (alarm): Move declaration to global level, before
- first reference to it.
- * tm-i386bsd.h (NUM_REGS): There are only eleven, not twelve.
- * dbxread.c (process_one_symbol): Cast to unsigned char, not int.
-
-Wed Feb 17 13:40:29 1993 K. Richard Pixley (rich@cygnus.com)
-
- * remote.c (readchar): forward declare alarm which otherwise looks
- like an undeclared variable to gcc.
-
- * dbxread.c (process_one_symbol): cast enum value N_SO into int
- when comparing against an int. Avoids superfluous warning from
- vax ultrix 4.2 cc.
-
- * inflow.c (set_sigint_trap): add cast to assignment from signal.
- Avoids superfluous warnings from some systems and/or compilers
- (like vax ultrix 4.2.)
-
- * language.c (struct op_print unk_op_print_tab): use the enum
- values rather naked zeros as initializers. Avoids warnings from
- ultrix type compilers.
-
-Tue Feb 16 00:53:20 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (VERSION): Roll to 4.7.6.
- (SFILES_SUBDIR): Add 29k-share/udi_soc.
- (SFILES_SUBSUBDIR): Move 29k-share/udi files to this macro.
- (alldeps.mak): Make ALLDEPFILES_SUBSUBDIR for files in sub sub dirs.
- (ALLDEPFILES_SUBSUBDIR): Depend on this for deeper dep files.
- (HFILES): Remove all nm-* except nm-trash.h. Add ns32k-opcode.h.
- (depend): Fix bug where nm-files in config files weren't noticed.
- (make-proto-gdb-1): Avoid changing directories while building new
- prototype. Build SFILES_SUBSUBDIR with longer symlinks.
-
-Mon Feb 15 20:48:09 1993 John Gilmore (gnu@cygnus.com)
-
- * remote.c: Improve error recovery. Allow user to break out
- of initial connection attempt with INTERRUPT. Treat a timeout
- while waiting for remote packet like a retry, unless the remote
- side is actively running user code. Fix a few long printf_filtered's.
-
- * xcoffread.c (read_xcoff_symtab): Don't use null symbol name for
- trampoline symbols.
-
- * buildsym.c (start_subfile): Allow null file name.
-
-Fri Feb 12 15:46:49 1993 K. Richard Pixley (rich@cygnus.com)
-
- * xcoffread.c (process_xcoff_symbol, read_symbol_lineno): complain
- expects a pointer to complaint rather than a complaint
- structure.
- (process_linenos): free the previously allocated subfile name,
- then allocate the new one from the heap.
-
-Fri Feb 12 08:06:05 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * h8300-tdep.c, tm-h8300.h: turn off some experimental features
-
-Thu Feb 11 00:59:07 1993 John Gilmore (gnu@cygnus.com)
-
- * stabsread.c (dbx_lookup_type): Handle negative type numbers.
- Previously, would bogusly index off the bottom of type_vector.
- (rs6000_builtin_type): Accept type number as argument.
- (read_type, case '-'): Handle negatives like any other type number.
-
- * symfile.c (deduce_language_from_filename): Handle null name.
-
- * mips-tdep.c (isa_NAN): Fix byte order dependency.
- Reported by Nobuyuki Hikichi <hikichi@sra.co.jp>,
- fixed by sato@sm.sony.co.jp.
-
- * xcoffread.c (parmsym): Don't use an initializer to set up
- this struct symbol. Set it up in initialize_xcoffread.
- (read_xcoff_symtab, xcoff_symfile_read): Surround code that only
- works on real rs/6000 target with #ifndef FAKING_RS6000.
-
-Wed Feb 10 23:42:37 1993 John Gilmore (gnu@cygnus.com)
-
- * stabsread.c (rs6000_builtin_type): Move function from
- xcoffread.c:builtin_type.
- * xcoffread.c (builtin_type): Move to stabsread. Remove
- IBM6000_HOST dependency. Move misplaced comments.
- (various): Change printf's to complaints.
- (patch_block_stabs, process_xcoff_symbol case C_DECL): Add
- objfile argument to read_type calls under #if 0.
- (process_xcoff_symbol case C_RSYM): Fix typo in #ifdef.
- * xcoffexec.c (map_vmap): Don't allocate an objfile for the exec_file.
- * Makefile.in: xcoffread.o is not built by default.
- * xm-rs6000.h (IBM6000_HOST): Remove.
- * config/rs6000.mh (NATDEPFILES): xcoffread.o is native only.
- * doc/gdbint.texinfo: Eliminate IBM6000_HOST, document
- IBM6000_TARGET.
-
-Wed Feb 10 18:31:20 1993 Stu Grossman (grossman at cygnus.com)
-
- * findvar.c (read_var_value): If REG_STRUCT_HAS_ADDR, then set
- VALUE_LVAL to be lval_memory so that we don't try to modify wild
- register numbers when user tries to modify elements in structs
- passed as arguments.
- * inflow.c (child_terminal_info): Move banner outside of system
- specific #ifdefs.
- * tm-hppa.h (REG_STRUCT_HAS_ADDR): Define this for HPPA, which
- passes struct/union arguments by address.
-
-Wed Feb 10 15:34:46 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Based on patch from Kean Johnston <maw@netcom.com>:
- * nm-i386sco4.h: New file. Like nm-i386sco.h, but define
- ATTACH_DETACH, PTRACE_ATTACH and PTRACE_DETACH.
- * config/i386sco4.mh (NAT_FILE): Use nm-i386sco4.h.
-
-Tue Feb 9 20:07:18 1993 John Gilmore (gnu@cygnus.com)
-
- * remote-udi.c (FREEZE_MODE): Fix && for & typo. Found and
- fixed by Lynn D. Shumaker, shumaker@saifr00.cfsat.honeywell.com.
-
-Tue Feb 9 08:18:07 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * config/i386sco4.mh (MUNCH_DEFINE): Pass -p to nm to avoid bug in
- cc debugging output.
-
-Tue Feb 9 00:19:28 1993 John Gilmore (gnu@cygnus.com)
-
- * stabsread.c (define_symbol): Complain about unrecognized names
- that begin with CPLUS_MARKER (often '$'), but don't die. Fix
- suggested by gb@cs.purdue.edu (Gerald Baumgartner).
- (read_cpp_abbrev): Don't use the class name as part of the
- vtable pointer member name (_vptr$) in $vf abbrevs or unrecognized
- abbrevs. Inspired by Mike Tiemann.
- (read_tilde_fields): Comment. Remove ancient dead code.
- Remove erroneous but non-dead code. Simplify. Add complaints.
- (in general): Remove extraneous (parentheses) in return
- statements.
-
-Fri Feb 5 14:01:22 1993 John Gilmore (gnu@cygnus.com)
-
- * coffread.c (coff_lookup_type): Fix fencepost error reported
- by Art Berggreen, <arg@opal.acc.com>.
-
- Fix long file name bug reported on SCO Open Desktop 2.0 by Ulf Lunde
- <Ulf.Lunde@kvatro.no> and Dag H. Wanvik <Dag.H.Wanvik@kvatro.no>:
-
- * coffread.c (getfilename): Eliminate COFF_NO_LONG_FILE_NAMES
- test, which is apparently left over from when we used native
- include files and couldn't depend on the member names being there.
- * tm-3b1.h, tm-altos.h, tm-i386v.h: Don't set it.
-
-Thu Feb 4 12:23:15 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mipsread.c: Major overhaul to use new BFD symbol table reading
- routines. Now swaps information as it is needed, rather than
- swapping everything when the file is read.
-
-Thu Feb 4 01:52:36 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (TARDIRS): Add sparclite demo dir.
- (*.tab.c): Change dependency on Makefile to depend on
- Makefile.in, otherwise it always rebuilds after configuring.
- Force output *.tab.c file into current directory even in "make"
- versions that rewrite dependent file names used in command lines.
-
- * TODO: Remove some things we did.
- * am29k-opcode.h, convx-opcode: Remove; now in ../include/opcode.
- * os68k-xdep.c: Remove; useless file (os68k is a target only).
- * convex-pinsn.c: Use ../include/opcode/convex.h. Add CONST.
- * symtab.h: Eliminate unnamed unions and structs.
-
-Wed Feb 3 14:48:08 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in (VERSION): Roll to 4.7.5.
-
-Tue Feb 2 20:47:42 1993 John Gilmore (gnu@cygnus.com)
-
- * breakpoint.c (breakpoint_re_set_one): Handle watchpoints when
- re-evaluating symbol pointers.
-
-Tue Feb 2 16:10:31 1993 Fred Fish (fnf@cygnus.com)
-
- * c-exp.y (lcurly, rcurly): New nonterminals.
- * c-exp.y (exp): Use lcurly and rcurly for arrays and UNOP_MEMVAL
- constructs.
- * parse.c (free_funcalls): Moved prototype from parser-defs.h,
- made function static.
- * parse.c (struct funcall): Moved struct def from parser-defs.h.
- * parse.c (funcall_chain): Moved from parser-defs.h, made static.
- * parse.c (start_arglist):
- * parser-defs.h (free_funcalls): Moved prototype to parse.c.
- * parser-defs.h (struct funcall): Moved struct def to parse.c.
- * parser-defs.h (funcall_chain): Moved to parse.c.
- * printcmd.c (print_frame_nameless_args): Fix prototype.
- * tm-mips.h (setup_arbitrary_frame): Fix prototype.
- * tm-sparc.h (setup_arbitrary_frame): Fix prototype.
- * valops.c (typecmp): Moved prototype from values.h.
- * value.h (typecmp): Moved prototype to valops.c, made static.
- * ch-exp.y (yylex): Change way control sequences are disabled.
-
-Tue Feb 2 16:11:43 1993 John Gilmore (gnu@cygnus.com)
-
- * tm-mips.h, tm-sparc.h: Fix thinko in SETUP_ARBITRARY_FRAME.
-
-Tue Feb 2 15:30:33 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mipsread.c (upgrade_type): Build array types correctly, using
- create_range_type and create_array_type.
-
-Tue Feb 2 00:19:08 1993 John Gilmore (gnu@cygnus.com)
-
- * remote-nindy.c: Cleanup.
-
- * infrun.c (wait_for_inferior): When rolling back the PC after
- a breakpoint, call write_pc so that NPC gets rolled back as well
- (for the 29K).
-
- * blockframe.c (inside_entry_file, inside_main_func,
- inside_entry_func): PC of zero is always "bottom of stack".
-
- * printcmd.c (print_frame_args, print_frame_nameless_args):
- Let print_frame_nameless_args decide whether there are any,
- laying groundwork for possibly later printing 29K args for
- functions where we have tag words but no symbols.
-
-Mon Feb 1 18:09:58 1993 Roland H. Pesch (pesch@fowanton.cygnus.com)
-
- * Makefile.in: fix GDB doc targets for new doc subdir structure
-
-Mon Feb 1 17:56:47 1993 John Gilmore (gnu@cygnus.com)
-
- * stack.c (parse_frame_specification): Parse as many arguments
- as there are (up to MAXARGS). Pass all of them in argc, argv
- format to SETUP_ARBITRARY_FRAME. Put the burden of checking how
- many there were, onto SETUP_ARBITRARY_FRAME.
- * tm-mips.h, tm-sparc.h: Corresponding changes.
- * mips-tdep.c, sparc-tdep.c: Ditto.
-
-Mon Feb 1 17:19:37 1993 John Gilmore (gnu@cygnus.com)
-
- * hp300ux-nat.c: Update copyrights.
- * mipsread.c (parse_partial_symbols): Complain about block
- indexes that go backwards. Fix from Peter Schauer.
- * symfile.c (syms_from_objfile, symbol_file_add): Allow a
- symbol-file that has no linkage symbols to be read.
- * tm-rs6000.h, xm-rs6000.h: (SIGWINCH_HANDLER and friends): Move
- from tm- file to xm-file, since they're host dependent.
- * valarith.c (value_binop): Typo.
-
-Mon Feb 1 16:16:59 1993 Stu Grossman (grossman at cygnus.com)
-
- * sparclite/aload.c: Add copyleft.
- * sparclite/crt0.s: Add comment at beginning.
-
-Mon Feb 1 14:36:11 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * remote-z8k.c, z8k-tdep.c: support for the Z8001 and Z8002.
- * parse.c (std_regs): Only declare if NO_STD_REGS is defined.
-
-Sun Jan 31 04:32:48 1993 Michael Tiemann (tiemann@rtl.cygnus.com)
-
- * values.c (value_headof): Fix typo in which VTBL and ARG were
- being confused for one another.
-
- * valops.c (typecmp): Now static.
-
- * gdbtypes.c (fill_in_vptr_fieldno): Don't ignore the first
- baseclass--we don't always inherit its virtual function table
- pointer.
-
- * eval.c (evaluate_subexp): In OP_FUNCALL case, adjust `this'
- pointer correctly in case value_struct_elt moves it around.
-
- * valops.c (typecmp): Now static. Also, now groks references
- better.
-
- * gdbtypes.c (lookup_struct_elt_type): Pass NOERR instead of
- zero on recursive call. If NAME is the name of TYPE, return TYPE.
-
-Sat Jan 30 19:55:52 1993 John Gilmore (gnu@cygnus.com)
-
- * hppah-nat.c: Eliminate <sys/user.h> and other unnecessary stuff,
- to avoid "too much defining" error from native C compiler (!).
-
- * Makefile.in (HFILES): Add typeprint.h.
- * typeprint.[ch]: Update copyrights.
-
-Thu Jan 28 19:09:02 1993 John Gilmore (gnu@cygnus.com)
-
- * Makefile.in: Update to match doc/ subdir changes.
-
- * config/hp300hpux.mh: No cross-host file needed, just native.
- * config/go32.mh: Remove nonexistent "native" support.
-
- M88K fixes reported by Carl Greco, <cgreco@Creighton.Edu>:
- * tm-m88k.h (REGISTER_CONVERT_TO_RAW): Fix typo.
- * m88k-tdep.c (next_insn): Lint, cleanup.
- (store_parm_word): Lint.
-
- * README: Fix typo (reported by karl@hq.ileaf.com).
-
-Wed Jan 27 21:34:21 1993 Fred Fish (fnf@cygnus.com)
-
- * expression.h (BINOP_CONCAT): Document use for self concatenation
- an integral number of times.
- * language.c (binop_type_check): Extend BINOP_CONCAT for self
- concatenation case.
- * valarith.c (value_concat): Rewrite to support self
- concatenation an integral number of times.
- * Makefile.in (ch-exp.tab.c): Change "expect" message.
- * ch-exp.y (FIXME's): Make all FIXME tokens distinct, to
- eliminate hundreds of spurious shift/reduce and reduce/reduce
- conflicts that mask the 5 real ones.
- * ch-exp.y (STRING, CONSTANT, SC): Remove unused tokens.
- * ch-exp.y (integer_literal_expression): Remove production,
- no longer used.
-
-Thu Jan 21 09:58:36 1993 Fred Fish (fnf@cygnus.com)
-
- * eval.c (evaluate_subexp): Fix OP_ARRAY, remove code that
- implied that "no side effects" was nonfunctional.
- * eval.c (evaluate_subexp): Add BINOP_CONCAT case to deal with
- character string and bitstring concatenation.
- * expprint.c (dump_expression): Add case for BINOP_CONCAT.
- * expression.h (exp_opcode): Add BINOP_CONCAT.
- * gdbtypes.h (type_code): Add TYPE_CODE_BITSTRING.
- * language.c (string_type): Add function to determine if a type
- is a string type.
- * language.c (binop_type_check): Add case for BINOP_CONCAT.
- * valarith.c (value_concat): New function to concatenate two
- values, such as character strings or bitstrings.
- * valops.c (value_string): Remove error stub and implement
- function body.
- * value.h (value_concat): Add prototype.
- * ch-exp.y (operand_3): Add actions for SLASH_SLASH (//).
- * ch-exp.y (yylex): Recognize SLASH_SLASH.
- * ch-lang.c (chill_op_print_tab): Add SLASH_SLASH (//) as
- BINOP_CONCAT.
-
-Tue Jan 19 14:26:15 1993 Fred Fish (fnf@cygnus.com)
-
- * c-exp.y (exp): Add production to support direct creation
- of array constants using the obvious syntax.
- * c-valprint.c (c_val_print): Set printed string length.
- * dwarfread.c (read_tag_string_type): New prototype and
- function that handles TAG_string_type DIEs.
- * dwarfread.c (process_dies): Add case for TAG_string_type
- that calls new read_tag_string_type function.
- * expprint.c (print_subexp): Add support for OP_ARRAY.
- * gdbtypes.c (create_range_type, create_array_type): Inherit
- objfile from the index type.
- * ch-typeprint.c (chill_print_type): Add case for
- TYPE_CODE_STRING.
- * ch-valprint.c (chill_val_print): Fix case for
- TYPE_CODE_STRING.
-
-Mon Jan 18 11:58:45 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mipsread.c (CODE_MASK, MIPS_IS_STAB, MIPS_MARK_STAB,
- MIPS_UNMARK_STAB, STABS_SYMBOLS): Removed; now in
- include/coff/mips.h.
-
-Fri Jan 15 20:26:50 1993 Fred Fish (fnf@cygnus.com)
-
- * c-exp.y (exp:STRING): Convert C strings into array-of-char
- constants with an explicit null byte terminator. OP_STRING is
- now used for real string types.
- * c-lang.c (builtin_type_*): Move declarations to lang.c since
- they are used by all languages.
- * c-lang.c (_initialize_c_language): Move initializations of
- builtin_type_* to lang.c.
- * c-typeprint.c (c_type_print_varspec_prefix,
- c_type_print_varspec_suffix): TYPE_CODE_PASCAL_ARRAY renamed
- to TYPE_CODE_STRING.
- * c-valprint.c (c_val_print): Change the way character arrays
- are printed as strings to be consistent with the way strings
- are printed when pointer-to-char types are dereferenced.
- Remove test of print_max before calling val_print_string, which
- now does it's own test.
- * eval.c (evaluate_subexp): Add case for OP_ARRAY.
- * expprint.c (print_subexp, dump_expression): Add case for OP_ARRAY.
- * expression.h (enum exp_opcode): Add OP_ARRAY and document.
- * gdbtypes.c (builtin_type_*): Add declarations moved from
- c-lang.c.
- * gdbtypes.c (create_string_type): New function to create real
- string types.
- * gdbtypes.c (recursive_dump_type): TYPE_CODE_PASCAL_ARRAY
- renamed to TYPE_CODE_STRING.
- * gdbtypes.c (_initialize_gdbtypes): Add initializations of
- builtin_type_* types moved from c-lang.c.
- * gdbtypes.h (enum type_code): TYPE_CODE_PASCAL_ARRAY renamed
- to TYPE_CODE_STRING.
- * gdbtypes.h (builtin_type_string): Add extern declaration.
- * gdbtypes.h (create_string_type): Add prototype.
- * m2-lang.c (m2_create_fundamental_type): TYPE_CODE_PASCAL_ARRAY
- renamed to TYPE_CODE_STRING.
- * m88k-tdep.c (pushed_size): TYPE_CODE_PASCAL_ARRAY renamed to
- TYPE_CODE_STRING.
- * mipsread.c (_initialize_mipsread): TYPE_CODE_PASCAL_ARRAY
- renamed to TYPE_CODE_STRING.
- * parse.c (length_of_subexp, prefixify_subexp): Add case for
- OP_ARRAY.
- * printcmd.c (print_formatted): Recognize TYPE_CODE_STRING.
- * typeprint.c (print_type_scalar): TYPE_CODE_PASCAL_ARRAY renamed
- to TYPE_CODE_STRING.
- * valops.c (allocate_space_in_inferior): New function and
- prototype, using code ripped out of value_string.
- * valops.c (value_string): Rewritten to use new function
- allocate_space_in_inferior, but temporarily disabled until some
- other support is in place.
- * valops.c (value_array): New function to create array constants.
- * valprint.c (val_print_string): Add comment to document use,
- complete rewrite to fix several small buglets.
- * value.h (value_array): Add prototype.
- * value.h (val_print_string): Change prototype to match rewrite.
- * ch-valprint.c (chill_val_print): Add case for TYPE_CODE_STRING.
- * ch-exp.y (match_character_literal): Disable recognition of
- control sequence form of character literals and document why.
-
-Thu Jan 14 15:48:12 1993 Stu Grossman (grossman at cygnus.com)
-
- * nindy-share/nindy.c: Add comments to #endif's to clarify
- grouping.
-
- * hppa-pinsn.c (print_insn): Use read_memory_integer, instead of
- read_memory to get byte order right.
- * hppah-tdep.c (find_unwind_info): Don't read in unwind info
- anymore. This is done in paread.c now. We expect unwind info
- to hang off of objfiles, and search all of the objfiles when until
- we find a match.
- * (skip_trampoline_code): Cast arg to target_read_memory.
- * objfiles.h (struct objfile): Add new field obj_private to hold
- per object file private data (unwind info in this case).
- * paread.c (read_unwind_info): New routine to read unwind info
- for the objfile. This data is hung off of obj_private.
- * tm-hppa.h: Define struct obj_unwind_info, to hold pointers to
- the unwind info for this objfile. Also define OBJ_UNWIND_INFO to
- make this easier to access.
-
-Wed Jan 13 20:49:59 1993 Fred Fish (fnf@cygnus.com)
-
- * c-valprint.c (cp_print_class_member): Add extern decl.
- * c-valprint.c (c_val_print): Extract code for printing methods
- and move it to cp_print_class_method in cp-valprint.c.
- * c-valprint.c (c_val_print): Extract code to print strings and
- move it to val_print_string in valprint.c.
- * cp-valprint.c (cp_print_class_method): New function using
- code extracted from c_val_print.
- * valprint.c (val_print_string): New function using code
- extracted from c_val_print.
- * value.h (val_print_string): Add prototype.
- * ch-exp.y (CHARACTER_STRING_LITERAL): Set correct token type.
- * ch-exp.y (literal): Add action for CHARACTER_STRING_LITERAL.
- * ch-exp.y (tempbuf, tempbufsize, tempbufindex, GROWBY_MIN_SIZE,
- CHECKBUF, growbuf_by_size): New variables, macros, and support
- functions for implementing a dynamically expandable temp buffer.
- * ch-exp.y (match_string_literal): New lexer function.
- * ch-exp.y (match_bitstring_literal): Dynamic buffer code
- removed and replaced with new CHECKBUF macro.
- * ch-exp.y (yylex): Call match_string_literal when appropriate.
- * ch-valprint.c (ch_val_print): Add code for TYPE_CODE_PTR.
-
-Sat Jan 9 19:59:33 1993 Stu Grossman (grossman at cygnus.com)
-
- * Makefile.in: Add info for paread.o.
- * config/hppahpux.mh: Add paread.o to NATDEPFILES.
-
- * blockframe.c (frameless_look_for_prologue): Correct the
- comment.
- * gdbtypes.h, gdbtypes.c: Use const in decl of
- cplus_struct_default, now that pa-gas assembler has been fixed.
- * hppah-nat.c: Formatting.
- * hppah-tdep.c: Remove lots of useless externs for variables we
- don't use.
- * (find_unwind_entry): Speed up by using binary search, and a one
- entry cache.
- * (rp_saved): New routine to see what unwind info says about RP
- being saved on the stack frame.
- * (frame_saved_pc): Look for prologue to see if we need to
- examine the stack for the saved RP or not.
- * (init_extra_frame_info): Check for prologue, instead of
- framesize to determine if we are frameless or not.
- * (frame_chain_valid): Stop backtraces when we run into _start.
- * (push_dummy_frame): Reformat to make more readable.
- * (find_dummy_frame_regs): ditto.
- * (hp_pop_frame): ditto.
- * (hp_restore_pc_queue): small cleanup.
- * (hp_push_arguments): ditto.
- * (pa_do_registers_info): ditto.
- * (skip_prologue): New routine created from SKIP_PROLOGUE macro.
- * tm-hppa.h: Move contents of SKIP_PROLOGUE into hppah-tdep.c.
- * Define FRAME_CHAIN_VALID.
- * Turn on BELIEVE_PCC_PROMOTION so that we can access char args
- passed to functions.
-
- * paread.c (pa_symtab_read): Use new bfd conventions for
- accessing linker symbol table.
- * (pa_symfile_init): Access embedded STAB info via BFD section
- mechanism and related macros.
-
-
-Sat Jan 9 19:31:43 1993 Stu Grossman (grossman at cygnus.com)
-
- * sparc-stub.c: Use a seperate stack for our traps.
- * Handle recursive traps.
- * Remove all trap init code. This needs to be done by the
- environment.
- * (set_mem_fault_trap): Call exceptionHandler() to setup this
- trap.
- * (handle_exception): See if we are at breakinst, if so, then
- advance PC sp that users can just step out of breakpoint().
- * (case 'G'): Don't let GDB hack CWP. Also, copy saved regs to
- new place if SP has changed.
- * (case 's'): Get rid of this, we can't do it yet.
- * (case 't'): New command to test any old random feature.
- * (case 'r'): New command to reset the system.
- * (breakpoint): Add label to breakpoint trap instruction so that
- handle_exception() can detect where we are and get past the
- breakpoint trivially.
-
-Thu Jan 7 13:33:06 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * mips-pinsn.c: Actual work now done by opcodes/mips-dis.c.
-
-Thu Jan 7 09:21:51 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in: recognise all sparclite variants
-
-Wed Jan 6 10:14:51 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * symfile.c: If O_BINARY isn't defined, set it to 0, call openp for
- binary files oring in the right bit.
-
- * main.c, source.c, state.c, symmisc.c: use macros defined in
- fopen-{bin|both} when fopening files.
-
-Wed Jan 6 08:19:11 1993 Fred Fish (fnf@cygnus.com)
-
- * defs.h (HOST_CHAR_BIT): New macro, defaults to either CHAR_BIT
- from a configuration file (typically including <limits.h>), or to
- TARGET_CHAR_BIT if CHAR_BIT is not defined.
- * eval.c (evaluate_subexp): Use new BYTES_TO_EXP_ELEM macro.
- * eval.c (evaluate_subexp): Add case for OP_BITSTRING.
- * expprint.c (print_subexp): Use new BYTES_TO_EXP_ELEM macro.
- * exppritn.c (print_subexp, dump_expression): Add case for
- OP_BITSTRING.
- * expression.h (OP_BITSTRING): New expression element type for
- packed bitstrings.
- * expression.h (EXP_ELEM_TO_BYTES, BYTES_TO_EXP_ELEM): New
- macros to convert between number of expression elements and bytes
- to store that many elements.
- * i960-tdep.c (leafproc_return): Use new macros to access
- minimal symbol name and address fields.
- * m88k-pinsn.c (sprint_address): Use new macros to access
- minimal symbol name and address fields.
- * nindy-tdep.c (nindy_frame_chain_valid): Use new macro to access
- minimal symbol address field.
- * parse.c (write_exp_elt, write_exp_string, prefixify_expression,
- parse_exp_1): Use new EXP_ELEM_TO_BYTES macro.
- * parse.c (write_exp_string, length_of_subexp, prefixify_expression):
- Use new BYTES_TO_EXP_ELEM macro.
- * parse.c (write_exp_bitstring): New function to write packed
- bitstrings into the expression element vector.
- * parse.c (length_of_subexp, prefixify_subexp): Add case for
- OP_BITSTRING.
- * parser-defs.h (struct stoken): Document that it is used for
- OP_BITSTRING as well as OP_STRING.
- * parser-defs.h (write_exp_bitstring): Add prototype.
- * ch-exp.y (BIT_STRING_LITERAL): Change token type to sval.
- * ch-exp.y (NUM, PRED, SUCC, ABS, CARD, MAX, MIN, SIZE, UPPER,
- LOWER, LENGTH): New tokens for keywords.
- * ch-exp.y (chill_value_built_in_routine_call, mode_argument,
- upper_lower_argument, length_argument, array_mode_name,
- string_mode_name, variant_structure_mode_name): New non-terminals
- and productions.
- * ch-exp.y (literal): Useful production for BIT_STRING_LITERAL.
- * ch-exp.y (match_bitstring_literal): New lexer support function
- to recognize bitstring literals.
- * ch-exp.y (tokentab6): New token table for 6 character keywords.
- * ch-exp.y (tokentab5): Add LOWER, UPPER.
- * ch-exp.y (tokentab4): Add PRED, SUCC, CARD, SIZE.
- * ch-exp.y (tokentab3): Add NUM, ABS, MIN, MAX.
- * ch-exp.y (yylex): Check tokentab6.
- * ch-exp.y (yylex): Call match_bitstring_literal.
-
-Mon Jan 4 16:54:18 1993 Fred Fish (fnf@cygnus.com)
-
- * xcoffexec.c (vmap_symtab): Use new macros to access minimal
- symbol name and value fields.
-
- * c-exp.y (yylex): Make static, to match prototype and other
- <lang>-exp.y files.
-
- * expression.h (exp_opcode): Add BINOP_MOD.
- * eval.c (evaluate_subexp): Handle new BINOP_MOD.
- * expprint.c (dump_expression): Handle new BINOP_MOD.
- * language.c (binop_type_check): Handle new BINOP_MOD.
- * main.c (float_handler): Re-enable float handler when hit.
- * valarith.c (language.h): Include, need current_language.
- * valarith.c (TRUNCATION_TOWARDS_ZERO): Define default macro
- for integer divide truncates towards zero for negative results.
- * valarith.c (value_x_binop): Handle BINOP_MOD if seen.
- * valarith.c (value_binop): Allow arithmetic operations on
- TYPE_CODE_CHAR variables. Add case to handle new BINOP_MOD.
- * ch-exp.y (operand_4): Add useful actions for MOD and REM.
- * ch-exp.y (tokentab3): Add MOD and REM.
- * ch-exp.y (yylex): Set innermost_block for symbols found
- in local scopes. Return LOCATION_NAME for local symbols.
- * ch-lang.c (chill_op_print_tab): Fix MOD entry to use
- BINOP_MOD instead of BINOP_REM. Add REM entry, using BINOP_REM.
-
-Mon Jan 4 07:35:31 1993 Steve Chamberlain (sac@wahini.cygnus.com)
-
- * command.c (shell_escape, make_command, _initialize_command):
- don't create or use fork if CANT_FORK is defined.
- * serial.h, ser-go32.c: now compiles, but "the obvious problems of
- code written for the IBM PC" remain.
- * xm-go32.h: define CANT_FORK
-
-Sun Jan 3 14:24:56 1993 Steve Chamberlain (sac@thepub.cygnus.com)
-
- * remote-sim.c: first attempt at general simulator interface
- * remote-hms.c: whitespace
- * h8300-tdep.c: (h8300_skip_prologue, examine_prologue):
- understand new stack layout. (print_register_hook): print ccr
- register in a fancy way.
-
-Sun Jan 3 14:16:10 1993 Fred Fish (fnf@cygnus.com)
-
- * eval.c (language.h): Include.
- * eval.c (evaluate_subexp_with_coercion): Only coerce arrays
- to pointer types when the current language is C. It loses for
- other languages when the lower index bound is nonzero.
- * valarith.c (value_subscript): Take array lower bounds into
- account when performing subscripting operations.
- * valops.c (value_coerce_array): Add comment describing why
- arrays with nonzero lower bounds are dealt with in value_subscript,
- rather than in value_coerce_array.
-
-Sat Jan 2 12:16:41 1993 Fred Fish (fnf@cygnus.com)
-
- * ch-exp.y (FLOAT_LITERAL): Add token.
- * ch-exp.y (literal): Add FLOAT_LITERAL.
- * ch-exp.y (match_float_literal): New lexer routine.
- * ch-exp.y (convert_float): Remove.
- * ch-exp.y (yylex): Call match_float_literal.
- * ch-exp.y (yylex): Match single '.' after trying
- to match floating point literals.
-
- * eval.c (evaluate_subexp): Add case MULTI_SUBSCRIPT.
- * expprint.c (print_subexp): Rename BINOP_MULTI_SUBSCRIPT to
- MULTI_SUBSCRIPT.
- * expprint.c (dump_expression): New function for dumping
- expression vectors during gdb debugging.
- * expression.h (BINOP_MULTI_SUBSCRIPT): Name changed to
- MULTI_SUBSCRIPT and moved out of BINOP range.
- * expression.h (DUMP_EXPRESSION): New macro that calls
- dump_expression if DEBUG_EXPRESSIONS is defined.
- * m2-exp.y (BINOP_MULTI_SUBSCRIPT): Changed to MULTI_SUBSCRIPT.
- * parse.c (length_of_subexp, prefixify_subexp): Change
- BINOP_MULTI_SUBSCRIPT to MULTI_SUBSCRIPT.
- * parse.c (parse_exp_1): Call DUMP_EXPRESSION before and after
- prefixify'ing the expression.
- * printcmd.c (print_command_1): Add comment.
- * ch-exp.y (expression_list): Add useful actions.
- * ch-exp.y (value_array_element): Add useful actions.
- * ch-exp.y (array_primitive_value): Add production.
- * ch-exp.y (yylex): Recognize ',' as a token.
-
-Fri Jan 1 18:22:02 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: pass prefix and exec_prefix via FLAGS_TO_PASS,
- POSIXize the recursive makes (make [variable assignments] target{s})
-
-Fri Jan 1 11:56:23 1993 Fred Fish (fnf@cygnus.com)
-
- * tm-sun4sol2.h (CPLUS_MARKER): Remove, now set in tm-sysv4.h.
- * tm-sysv4.h (CPLUS_MARKER): By default, g++ uses '.' as the
- CPLUS_MARKER for all SVR4 systems, so follow suit.
- * defs.h (strdup_demangled): Remove prototype.
- * dwarfread.c (enum_type, synthesize_typedef): Use new macro
- SYMBOL_INIT_LANGUAGE_SPECIFIC.
- * dwarfread.c (new_symbol): Use SYMBOL_INIT_DEMANGLED_NAME.
- * minsyms.c (install_minimal_symbols, prim_record_minimal_symbol,
- prim_record_minimal_symbol_and_info): Use new macro
- SYMBOL_INIT_LANGUAGE_SPECIFIC.
- * minsyms.c (install_minimal_symbols): Use new macro
- SYMBOL_INIT_DEMANGLED_NAME.
- * stabsread.c (define_symbol): Use new macro
- SYMBOL_INIT_DEMANGLED_NAME.
- * symfile.c (add_psymbol_to_list, add_psymbol_addr_to_list):
- Use new macro SYMBOL_INIT_DEMANGLED_NAME.
- * symfile.h (ADD_PSYMBOL_VT_TO_LIST): Use new macro
- SYMBOL_INIT_DEMANGLED_NAME.
- * symmisc.c (dump_msymbols, dump_symtab, print_partial_symbol):
- SYMBOL_DEMANGLED_NAME now tests language itself.
- * symtab.c (COMPLETION_LIST_ADD_SYMBOL): SYMBOL_DEMANGLED_NAME
- now tests language itself.
- * symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): New macro that does
- what SYMBOL_DEMANGLED_NAME used to do, directly access the C++
- mangled name member in the language dependent portion of a symbol.
- * symtab.h (SYMBOL_DEMANGLED_NAME): New macro that returns the
- mangled name member appropriate for a symbol's language.
- * symtab.h (SYMBOL_SOURCE_NAME, SYMBOL_LINKAGE_NAME,
- SYMBOL_MATCHES_NAME, SYMBOL_MATCHES_REGEXP):
- SYMBOL_DEMANGLED_NAME now tests language itself.
- * symtab.h (SYMBOL_INIT_LANGUAGE_SPECIFIC): New macro that
- initializes language dependent portion of symbol.
- * symtab.h (SYMBOL_INIT_DEMANGLED_NAME): New macro that
- demangles and caches the demangled form of symbol names.
- * utils.c (fputs_demangled, fprint_symbol): Use current language
- to select an appropriate demangling algorithm.
- * utils.c (strdup_demangled): Remove, no longer used.
- * symtab.h (SYMBOL_CHILL_DEMANGLED_NAME): New macro that directly
- access the Chill mangled name member in the language dependent
- portion of a symbol.
- * ch-lang.c (chill_demangle): New function, simple demangler.
- * defs.h (chill_demangle): Add prototype.
- * symtab.h (language_dependent_info): Add struct for Chill.
-
-For older changes see ChangeLog-92
-
-Local Variables:
-mode: indented-text
-left-margin: 8
-fill-column: 74
-version-control: never
-End:
diff --git a/contrib/gdb/gdb/ChangeLog-94 b/contrib/gdb/gdb/ChangeLog-94
deleted file mode 100644
index a691ace..0000000
--- a/contrib/gdb/gdb/ChangeLog-94
+++ /dev/null
@@ -1,5705 +0,0 @@
-Fri Dec 30 17:58:55 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * config/m68k/tm-est.h: Remove cruft.
-
-
-Thu Dec 29 22:40:00 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * Allow up to 10 whitespace separated arguments to user defined
- commands.
- * top.c (struct user_args): Structure for holding arguments to
- user defined commands.
- (print_command_line): Delete unused "tmp_chain" variable. Clean
- up flow control by having cases exit in the same manner.
- Before executing a command or evaluating an expression, substitute
- the current $arg0..$arg9 values if the command/expression uses them.
- (arg_cleanup): New function.
- (setup_user_args, locate_arg, insert_args): Likewise.
- (execute_user_command): Allow arguments to user defined commands.
-
- * Allow if/while commands to be used within a breakpoint command
- list.
- * breakpoint.c (bpstat_do_actions): Call execute_control_command
- rather than execute_command (passes entire command structure rather
- than just the command line text).
- (breakpoint_1): Use "print_command_line" to print a breakpoint
- command line (including control structures).
- * gdbcmd.h (execute_control_command): Provide extern decl.
- (print_command_line): Likewise.
- * top.c (execute_control_command): No longer static.
- (print_command_line): New function to recursively print a command
- line, including control structures.
-
-Thu Dec 29 18:18:31 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * hppa-tdep.c (pa_print_registers): Extract register values stored
- in big endian format on big and little endian hosts.
-
- * array-rom.c: Support for Array Tech LSI33k based RAID disk
- controller board.
- * configure.in: Recognize "mips*-*-ecoff*" rather than
- "mips*-idt-ecoff*" so it'll work for the LSI33k.
-
- * monitor.[ch], op50-rom.c, rom68k-rom.c, w89k-rom.c: Add support
- to monitor config structure for supported baud rates for a target
- and variable stop bits.
- * monitor.c (monitor_fetch_register): Store register values in big
- endian format on any host.
-
-Wed Dec 28 19:27:22 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (hppa_fix_call_dummy): Prefer import stubs over
- export stubs and actual shared library functions so that lazy
- binding works correctly. Try both __d_plt_call and __gcc_plt_call
- trampolines for calling import stubs.
-
-Wed Dec 28 15:29:02 1994 Stan Shebs <shebs@andros.cygnus.com>
-
- * a29k-tdep.c (pop_frame): Fix a variable name.
-
-Wed Dec 28 12:21:39 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (push_dummy_frame): Refine code to determine what
- space ID to place in the stack & inf_status structure.
- (hppa_pop_frame): Don't walk through trampoline code if popping a
- call dummy frame.
- (hppa_fix_call_dummy): Call the stack dummy directly if the
- current PC is in a shared library.
-
- * hppa-tdep.c (push_dummy_frame): Return type is void. Clear
- in_syscall bit in flags. Don't depend on the PC queue registers
- when in_syscall is set, they're not valid.
- * config/pa/tm-hppa.h (PUSH_DUMMY_FRAME): Pass inf_status down to
- push_dummy_frame.
- (SR4_REGNUM): Define.
-
- * hppa-tdep.c: Misc. lint changes.
-
-Tue Dec 27 12:32:43 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * breakpoint.c (watchpoint_check): Don't bother restoring the
- "selected" frame anymore, it's not necessary. Initialize the
- frame cache before trying to find the current frame in the frame
- chain.
-
- * somsolib.c (som_solib_add): Return without loading any shared
- libraries if symfile_objfile is NULL.
- (som_solib_create_inferior_hook): Likewise.
-
-Fri Dec 23 17:03:13 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * remote-est.c: New file supports EST-300 CPU32 background
- mode ICE.
- * remote-utils.c (sr_com): Call registers_changed.
- * configure.in (m68*-*-est*): New configuration.
- * config/m68k/tm-est.h: New file.
-
-Fri Dec 23 16:18:50 1994 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in (CLIBS): Put LIBIBERTY last.
-
-Thu Dec 22 09:27:16 1994 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * ser-tcp.c (tcp_open): Cast to struct sockaddr when passing to
- function which expects that.
-
-Thu Dec 22 13:25:33 1994 J.T. Conklin (jtc@rtl.cygnus.com)
-
- * nlm/gdbserve.c, nlm/ppc.c, nlm/ppc.h: Don't try to use
- ALTERNATE_MEM_FUNCS.
-
-Wed Dec 21 14:00:26 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * monitor.c: Now supports xmodem as a remoteloadprotocol.
-
-Tue Dec 20 23:01:17 1994 Stu Grossman (grossman@cygnus.com)
-
- * config/mips/xm-irix4.h, config/mips/xm-irix5.h: #define
- _BSD_COMPAT to get reliable signal handling.
-
-Tue Dec 20 11:44:28 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * sparc-tdep.c, a29k-tdep.c, findvar.c (get_saved_register):
- if !target_has_registers, call error().
-
- * value.h: Remove obsolete comments about FRAME vs struct
- frame_info *.
-
-
-Sun Dec 18 11:52:58 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * sparc-tdep.c (sparc_pop_frame): Remove erroneous extra argument
- to write_register.
-
-Sat Dec 17 13:23:21 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * tm-sparc.c (EXTRA_FRAME_INFO): New field sp_offset.
- * sparc-tdep.c (sparc_init_extra_frame_info): Set it.
- (examine_prologue, sparc_init_extra_frame_info): Use ->frame plus
- ->sp_offset to compute the address something is saved at, not
- ->bottom.
-
- * sparc-tdep.c (get_saved_register): New function.
- * tm-sparc.h: Define GET_SAVED_REGISTER; don't define
- FRAME_FIND_SAVED_REGS, HAVE_REGISTER_WINDOWS or REGISTER_IN_WINDOW_P.
- * stack.c (frame_info): Add comment about what to do if
- FRAME_FIND_SAVED_REGS is not defined.
-
- * sparc-tdep.c (sparc_init_extra_frame_info): Set ->frame field
- here. Get it right for flat frames.
- * sparc-tdep.c (sparc_frame_chain): Instead of returning
- meaningful value for ->frame field, just return dummy value.
- This change is needed because the old code didn't deal with mixed
- flat and non-flat frames.
-
- * sparc-tdep.c (sparc_pop_frame): Write SP_REGNUM from
- frame->frame, don't go through saved regs for this.
-
- * sparc-tdep.c: Move guts of skip_prologue to new function
- examine_prologue. Check for flat prologue and set is_flat.
- Provide the caller with the information about what is saved where
- if desired.
- (skip_prologue, sparc_frame_find_saved_regs): Call examine_prologue.
-
- * sparc-tdep.c: Replace union sparc_insn_layout and anonymous
- union in isannulled, which won't work on a little-endian host,
- with X_* macros.
-
- * sparc-tdep.c (sparc_frame_saved_pc): If addr == 0, the saved PC
- is still in %o7.
-
- * config/sparc/tm-sparc.h: Define INIT_FRAME_PC and
- INIT_FRAME_PC_FIRST.
- * blockframe.c (get_prev_frame_info): Modify comments regarding
- INIT_FRAME_PC_FIRST and the sparc.
-
- * sparc-tdep.c (single_step): Use 4 not sizeof (long) for size of
- instruction.
-
-Sat Dec 17 02:33:37 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * c-typeprint.c (c_type_print_base): Use `show' of -1 to print
- the return type of methods to avoid infinite loops with anonymous
- types.
- * valops.c (search_struct_field): Handle anonymous unions.
-
- * sparc-tdep.c (sunos4_skip_trampoline_code): New function
- to correctly handle steps into -g compiled PIC objects in the
- main executable.
- * config/sparc/tm-sun4os4.h (SKIP_TRAMPOLINE_CODE):
- Redefine to use sunos4_skip_trampoline_code.
-
- * dwarfread.c (DWARF_REG_TO_REGNUM): Provide a default mapping
- from DWARF to GDB register numbering.
- * dwarfread.c (locval): Use DWARF_REG_TO_REGNUM to map the
- register value.
- * config/mips/tm-mipsv4.h (DWARF_REG_TO_REGNUM): Define.
-
-Fri Dec 16 10:56:29 1994 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * Makefile.in (uninstall): transform file names.
-
-Thu Dec 15 16:55:35 1994 Stan Shebs <shebs@andros.cygnus.com>
-
- * defs.h: Include progress.h.
- (QUIT): Call PROGRESS.
- * main.c (main): Call START_PROGRESS and END_PROGRESS, break
- usage message into shorter strings.
- * source.c: Change long command help strings into concats of
- shorter ones, for picky ANSI compilers.
-
- * top.c (command_loop): For space usage display, show both
- absolute size and the change from before command execution.
-
-Thu Dec 15 16:40:10 1994 Stu Grossman (grossman@cygnus.com)
-
- * defs.h, main.c (gdb_fputs), top.c: Add stream arg to
- fputs_unfiltered_hook.
- * defs.h, top.c, utils.c (error): Add error_hook.
-
-Tue Dec 13 15:15:33 1994 Stan Shebs <shebs@andros.cygnus.com>
-
- * breakpoint.c, infrun.c, printcmd.c: Change long command help
- strings into concats of shorter ones, for picky ANSI compilers.
-
-Mon Dec 12 17:08:02 1994 Stan Shebs <shebs@andros.cygnus.com>
-
- Sparc flat register window support.
- * sparc-tdep.c (sparc_insn_layout): New union, defines layout of
- instructions symbolically (used to be local to skip_prologue).
- (sparc_init_extra_frame_info): New function.
- (sparc_frame_chain): Add flat cases throughout.
- (skip_prologue): Add recognition of flat prologues.
- (sparc_frame_find_saved_regs): Add flat cases.
- (sparc_pop_frame): Ditto.
- * config/sparc/tm-sparc.h (EXTRA_FRAME_INFO): New slots.
- (INIT_EXTRA_FRAME_INFO): Call sparc_init_extra_frame_info.
- (PRINT_EXTRA_FRAME_INFO): Define.
-
-
-Mon Dec 12 13:06:59 1994 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * f-lang.c: Remove duplicate declaration of
- builtin_type_f_integer, and only include it in the f_builtin_types
- once.
-
- * somread.c (som_symfile_read): Just assign to objfile->obj_private,
- not OBJ_UNWIND_INFO. Assigning to a cast is a GCC-ism which
- the HP compiler doesn't like.
-
-
-Fri Dec 9 15:50:05 1994 Stan Shebs <shebs@andros.cygnus.com>
-
- * remote.c (remote_wait): Pass string instead of char to strcpy.
-
-Fri Dec 9 04:43:17 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbserver/low-lynx.c (mywait): Remove debugging printf.
-
-Thu Dec 8 15:07:29 1994 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * frame.h: Restore pre-Nov 3 comments about FRAME_FP with minor
- changes. They are correct, unlike the post-Nov 3 comment
- (FRAME_FP doesn't have any machine-independent relationship with
- FP_REGNUM or any other such notion of a "frame pointer").
-
-Wed Dec 7 14:50:54 1994 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * gdbserver/remote-utils.c (write_ok): Write "OK", not "Ok", to
- match stubs and protocol spec.
- * gdbserver/remote-utils.c (remote_open): Cast to struct sockaddr
- when passing to function which expects that.
-
- The following changes aren't quite enough to make things work with
- LynxOS (apprently kernel problems).
- * infrun.c (wait_for_inferior): When resuming new thread, pass pid
- not -1 for remote case.
- * thread.c (info_threads_command): Give error if !target_has_stack.
- * infrun.c (start_remote): Call init_thread_list.
- * thread.c (info_threads_command): Don't call kill for remote
- debugging target.
- * target.c (normal_pid_to_str): Print "thread" not "process" for
- remote.
- * remote.c, gdbserver/*: Add 'H', 'S', and 'C' requests, 'X'
- response, and `thread' part of 'T' response.
- * gdbserver/*: If program exits, send packet to GDB before
- exiting. Handle termination with a signal the same as exiting
- with an exitstatus.
- * remote.c: Don't try to kill program after getting an 'X'
- response.
- * infrun.c (wait_for_inferior): Add comment about kill versus mourn.
-
-Thu Dec 8 12:37:38 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * config/pa/tm-pro.h tm-hppap.h, hppapro.mt: Rename tm-hppap.h to
- tm-pro.h.
-
-Wed Dec 7 18:22:59 1994 Stan Shebs <shebs@andros.cygnus.com>
-
- * source.c: Various cosmetic changes.
- (forward_search_command): Handle very long source lines correctly.
-
-Wed Dec 7 13:21:47 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * hppa-tdep.c: Use GDB_TARGET_IS_PA_ELF so SOM target support will
- stop being linked in.
-
- * config/pa/tm-hppap.h: New file. Set GDB_TARGET_IS_PA_ELF,
- otherwise it looks like BSD-ELF.
-
-Mon Dec 5 21:43:52 1994 Stu Grossman (grossman@cygnus.com)
-
- * inftarg.c: include <sys/types.h> to get def of pid_t.
-
-Fri Dec 2 15:03:07 1994 Stan Shebs <shebs@andros.cygnus.com>
-
- * solib.c (auto_solib_add_at_startup): New global.
- (solib_create_inferior_hook): Call solib_add only if
- auto_solib_add_at_startup is nonzero.
- (_initialize_solib): New command "set auto-solib-add".
-
-Fri Dec 2 12:52:04 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * parse.c (msymbol_addr_type): Replaced by
- lookup_pointer_type (builtin_type_void).
-
- * printcmd.c (_initialize_printcmd): Give examine_*_type
- a name for `ptype $_'.
-
-Fri Dec 2 12:52:04 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (print_formatted): Call val_print_string directly,
- rather than via value_print.
-
-Wed Nov 30 22:27:27 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * somsolib.c (som_solib_get_got_by_pc): New function.
- * somsolib.h (som_solib_get_got_by_pc): Add extern decl.
- * hppa-tdep.c (hppa_fix_call_dummy): Handle case where FUN is the
- function's export stub or real address in a shared library.
-
-Tue Nov 29 13:40:25 1994 J.T. Conklin (jtc@rtl.cygnus.com)
-
- * config/i386/nbsd.mh (REGEX, REGEX1): No longer define.
-
- * configure.in (i[345]86-*-freebsd*): New configuration.
- * config/i386/{fbsd.mh,fbsd.mt,nm-fbsd.h}: New files.
-
-Tue Nov 29 12:23:25 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * top.c (read_next_line): Pass annotation suffix "commands"
- instead of "command", matches documentation.
-
-Mon Nov 28 14:53:21 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config/a29k/tm-a29k.h (setup_arbitrary_frame): Replace
- FRAME_ADDR with CORE_ADDR in prototype.
-
- * top.c (command_line_input): If annotation suffix is NULL,
- replace it with an empty string.
- (read_next_line): Pass "command" as annotation suffix to
- command_line_input.
-
-Mon Nov 28 11:03:14 1994 J.T. Conklin (jtc@rtl.cygnus.com)
-
- * config/rs6000/tm-rs6000.h (setpgrp): move defn from here...
- * config/rs6000/xm-rs6000.h: ...to here.
-
-
-Fri Nov 25 21:26:02 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * tm-hppa.h (skip_trampoline_code): Add extern decl.
- * hppa-tdep.c (hppa_pop_frame): Silently restart the inferior and
- allow it to execute any return path trampoline code. Stop the
- inferior and give the user control when the trampoline has
- finished executing.
- (in_solib_call_trampoline): Handle export stubs which also perform
- parameter relocations.
- (in_solib_return_trampoline): Likewise.
-
-Fri Nov 25 13:37:10 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * coffread.c, symfile.h (coff_getfilename): Make it static again.
- * xcoffread.c (coff_getfilename): Use a static copy from
- coffread.c, modified for accessing the static xcoff strtbl.
-
-Fri Nov 25 00:51:05 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (in_solib_call_trampoline): Recognize calls through
- _sr4export and $$dyncall as trampolines. Likewise for long-call
- stubs and parameter relocation stubs.
- (in_solib_return_trampoline): Recognize a return trampoline for
- return value relocation stubs.
-
- * hpread.c: Include hp-symtab.h instead of hpux-symtab.h.
- Various name changes to match those used by hp-symtab.h.
-
-Thu Nov 24 00:39:27 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * blockframe.c (find_pc_partial_function): Inhibit mst_trampoline
- symbol special handling when INHIBIT_SUNSOLIB_TRANSFER_TABLE_HACK
- is defined.
- * infrun.c (IN_SOLIB_CALL_TRAMPOLINE): Renamed from
- IN_SOLIB_TRAMPOLINE. All callers changed.
- (IN_SOLIB_RETURN_TRAMPOLINE): Provide default definition.
- (wait_for_inferior): Handle single stepping through trampolines on
- return paths from shared libraries.
- * config/pa/tm-hppa.h (IN_SOLIB_CALL_TRAMPOLINE): Use
- in_solib_call_trampoline.
- (IN_SOLIB_RETURN_TRAMPOLINE): Use in_solib_return_trampoline.
- (INHIBIT_SUNSOLIB_TRANSFER_TABLE_HACK): Define.
- * hppa-tdep.c (in_solib_call_trampoline): New function.
- (in_solib_return_trampoline): New function.
-
-Wed Nov 23 21:43:03 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * tm-h8300.h (REMOTE_BREAKPOINT): Define.
- * h8300-tdep.c (h8300_pop_frame): Remove redundant call.
-
- * remote-e7000.c (HARD_BREAKPOINTS): Reenable.
- (BC_BREAKPOINTS): Disable.
- * sh-tdep.c (print_insn): Cope with big and little endian machines.
- * sh/sh.mt: Use libsim.a
- * sh/tm-sh.h (TARGET_BYTE_ORDER_SELECTABLE): New
- (BREAKPOINT): Changed to be byteorder independent.
-
-Tue Nov 22 19:13:39 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Maintenance commands to report time and space usage.
- * main.c (display_time, display_space): New globals.
- (main): Add argument --statistics to enable reporting, display
- time and space after startup is done.
- * maint.c (maintenance_time_display, maintenance_space_display):
- New commands.
- * top.c (command_loop): Display time and space after command
- execution.
-
- * top.c (pre_init_ui_hook): New global.
- (gdb_init): If pre_init_ui_hook set, call before all other init.
-
-Tue Nov 22 10:25:59 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * a29k-tdep.c (examine_tag): Fix a bug in stack frame size.
-
-Sat Nov 19 03:10:51 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/i386/i386sol2.mh: Reenable core file support.
-
- * symfile.c (deduce_language_from_filename): Treat .c++ as a
- C++ extension.
-
- * valops.c (destructor_name_p): Do not compare the template
- part for template classes.
-
-Fri Nov 18 14:55:59 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * defs.h, infcmd.c (reg_names): Don't declare as constant.
- * remote-mips.c (mips_open): Read and set the processor type.
- * mips-tdep.c (mips_set_processor_type): Always return an int.
-
-Fri Nov 18 10:38:12 1994 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * nlm/alpha.c (strtol): Remove, it is provided by NetWare C library.
- * nlm/gdbserve.def (strtol): Add to import list.
- * nlm/fake_aio.c: Remove file, no longer used.
-
- * Makefile.in (LD_FOR_TARGET, NLMCONV_FOR_TARGET): Remove.
- * nlm/Makefile.in (gdbserve.O): Link with ${CC_FOR_TARGET}.
- (LD_FOR_TARGET): Remove.
-
-Thu Nov 17 22:09:50 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * monitor.h, monitor.c, w89k-rom.c, op50n-rom.c, idp-rom.c: Add
- support for two variables used to control the load protocol and
- conversion type.
-
-Thu Nov 17 17:51:12 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Support for different MIPS IDT processor models.
- * mips-tdep.c (mips_processor_type, tmp_mips_processor_type,
- mips_generic_reg_names, mips_r3041_reg_names,
- mips_r3051_reg_names, mips_r3081_reg_names,
- mips_processor_type_table): New globals.
- (mips_do_registers_info): Don't display register if name is empty.
- (mips_set_processor_type_command): New command.
- (mips_show_processor_type_command): New command.
- (mips_set_processor_type): New function.
- (mips_read_processor_type): New function.
- * config/mips/tm-idt.h (DEFAULT_MIPS_TYPE): New macro.
- * config/mips/tm-mips.h (DEFAULT_MIPS_TYPE): New macro.
- (NUM_REGS): Increase to account for all CP0 registers.
- (REGISTER_NAMES): Add empty names for CP0 registers.
- (FIRST_EMBED_REGNUM, LAST_EMBED_REGNUM): Adjust.
- (PRID_REGNUM): New macro.
-
-Wed Nov 16 16:41:52 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * README: Add warning about termcap in Ultrix and OSF/1.
-
-Wed Nov 16 15:28:29 1994 Rob Savoye (rob@cygnus.com)
-
-
- * hppa-tdep.c: Remove including sys/dir.h from a target file.
-
-Wed Nov 16 10:31:27 1994 J.T. Conklin (jtc@cygnus.com)
-
- * config/powerpc/gdbserve.mt (TDEPFILES): Remove fake_aio.o.
-
- * nlm/gdbserve.c: Include <nwtypes.h> before other NetWare headers.
- * nlm/ppc.c: Likewise.
-
- * nlm/ppc.c (strtol): Remove, it is provided by NetWare C Library.
- (StopBell): New function (stubbed out).
-
-Wed Nov 16 00:12:21 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (skip_trampoline_code): Handle shared library import
- trampolines.
-
-Tue Nov 15 16:18:52 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * c-exp.y (yylex): Fix a bug in template scanning.
-
-Tue Nov 15 14:25:47 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * i386-stub.c, m68k-stub.c, sparc-stub.c, sparcl-stub.c: Mask out
- the top bit returned by getDebugChar.
-
-Tue Nov 15 01:03:56 1994 Rob Savoye (rob@slipknot.cygnus.com)
-
- * op50-rom.c, w89k-rom.c, monitor.c: Modify to usr two variables
- to set remote load type and protocol.
- * rom68k-rom.c: Add to_stop in target_ops.
-
-
-Sat Nov 12 21:55:47 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * somsolib.c: Add TODO list.
- (som_solib_add): Immediately return if $SHLIB_INFO$ sections does
- not exist or has size zero. Slightly simplify error handling.
- Keep an internal list of all the loaded shared libraries and
- various tidbits of information about the loaded shared libraries.
- Build section tables for each loaded shared library and add those
- tables to the core target if necessary.
- (som_solib_create_inferior_hook): Force re-reading of shared
- libraries at exec time.
- (som_sharedlibrary_info_command): New function for dumping
- information about the currently loaded shared libraries.
- (_initialize_som_solib): New function.
-
-Sat Nov 12 02:26:50 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * Makefile.in (copying.o, f-exp.tab.o, dpx2-nat.o, dstread.o,
- i386aix-nat.o, i386m3-nat.o, irix5-nat.o, lynx-nat.o, m3-nat.o,
- mipsm3-nat.o, ns32km3-nat.o, remote-e7000.o, remote-os9k.o):
- Add dependencies.
- (copying.o, os9kread.o, remote.o): Update dependencies.
-
- * valarith.c (value_sub): When subtracting pointers, only
- check for a match of the pointed to element lengths.
- Cast element length to LONGEST to obtain a signed result for
- pointer subtractions.
-
-Fri Nov 11 10:51:07 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * ch-exp.y (yylex): Fix off-by-one error when converting string to
- lowercase. Null terminate new string.
-
- * hppa-tdep.c (rp_saved): Handle IMPORT stubs too.
-
- * somsolib.c (som_solib_add): Check the value of __dld_flags, if
- it indicates __dld_list is not valid return an error. If it
- indicates that libraries were not mapped privately, issue a
- warning.
-
-Thu Nov 10 23:17:45 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symfile.c (syms_from_objfile): Only call find_lowest_section if
- no ".text" section exists.
-
-Thu Nov 10 15:16:21 1994 Rob Savoye <rob@rtl.cygnus.com>
-
- * rom68k-rom.c: New file. Replaces the old remote-mon.c and uses
- the new generic ROM interface in monitor.c.
- * config/m68k/monitor.mt: Use new ROM support.
- * monitor.c: Add support for xmodem download protocol.
-
-Wed Nov 9 18:46:24 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * findvar.c (find_saved_register): Fix a frame variable name.
- * infcmd.c (finish_command): Ditto.
-
-Tue Nov 8 13:20:14 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * TODO: Remove "Watchpoints seem not entirely reliable, though
- they haven't failed me recently." item--this old (4.6 at least)
- item is too vague to be useful (some watchpoint bugs have been
- fixed since then).
- * TODO: Add explanation of "RPC interface" item.
-
-Mon Nov 7 22:25:21 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (read_unwind_info): Use "text_offset" for linker
- stub unwind descriptors too.
-
- * Enable backtracing from inside a SOM shared library back into
- user code.
- * hppa-tdep.c (internalize_unwinds): Accept and use new
- "text_offset" argument for dynamic relocation of
- region_{start,end} fields in the unwind descriptor.
- (read_unwind_info): Pass text_offset to internalize unwinds.
-
-Mon Nov 7 14:34:42 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * m3-nat.c: Remove comments about arbitrary limit in
- printf_filtered; that limit is gone.
-
-Mon Nov 7 00:27:16 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * Beginnings of SOM shared library support. Breakpoints and
- single frame backtracing within the library only. Only works when
- using the HPUX 9 dynamic linker. More functionality to be added
- soon.
-
- * somsolib.c, somsolib.h: New files.
- * Makefile.in (HFILES_NO_SRCDIR): Add somsolib.h
- (ALLDEPFILES): Add somsolib.c.
- (somsolib.o): Add some dependencies.
- * somread.c (som_symtab_read): Accept multiple section offsets.
- All callers changed. Adjust all text symbols with the first
- section offset.
- * symfile.c (find_lowest_section): Enable this function. Add some
- tie-breaking logic when sections have the same vma.
- (syms_from_objfile): Use find_lowest_section rather than looking
- for ".text" by name. Relax warning to only warn if the lowest
- section is not a code section.
- * config/pa/{hppabsd.mh, hppahpux.mh} (NATDEPFILES): Add somsolib.o
- * config/pa/{nm-hppab.h, nm-hppah.h}: Include somsolib.h.
-
-Sun Nov 6 12:54:54 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * partial-stab.h (N_TEXT): Put back GDB_TARGET_IS_HPPA kludge,
- it is still needed for GCC-2.6 compiled code.
- * TODO (GDB_TARGET_IS_HPPA): Note this kludge can be nuked
- sometime after GCC-2.7 has been released.
-
- * hppa-tdep.c (frame_saved_pc): Mask off low two bits when
- retrieving the PC from a signal handler caller. Fix thinko
- in Stan's last change ("frame", should have been "frame->next").
- If the next frame is a signal handler caller and it's a system
- call which has entered the kernel ((PSW & 0x2) != 0), then the
- saved pc is in %r2 instead of %r31.
-
-Fri Nov 4 23:47:07 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (hppa_frame_find_saved_regs): Change "frame" to
- "frame_info" throughout.
-
-Fri Nov 4 16:26:59 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * sparcl-stub.c: get rid of defs.h.
-
-Fri Nov 4 13:11:54 1994 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * gdbserver/Makefile.in (MMALLOC_CFLAGS): Add -I${MMALLOC_DIR}.
- Correct definition of MMALLOC_DIR to reflect fact this is
- gdb/gdbserver/Makefile.in, not gdb/Makefile.in.
-
- * gdbserver/server.c (main): After we kill the inferior in
- response to a 'k' request, exit.
-
- * remote.c (remote_kill): Use catch_errors when calling putpkt.
- (putpkt): Return int, not void, to match catch_errors calling
- convention.
-
-Fri Nov 4 10:52:38 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * rs6000-tdep.c (pop_frame): Correct a variable name.
-
-Fri Nov 4 05:43:35 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * TODO: Re-write item about SIGINT handling to reflect the fact
- that target_stop now exists.
-
-Thu Nov 3 15:19:17 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Replace useless FRAME, FRAME_ADDR types with struct frame_info *
- and CORE_ADDR, respectively.
- * frame.h (FRAME, FRAME_INFO_ID, FRAME_ADDR): Remove.
- * blockframe.c (get_frame_info): Remove.
- * a29k-tdep.c, alpha-tdep.c, blockframe.c, breakpoint.c,
- breakpoint.h, energize.c, findvar.c, gould-pinsn.c,
- h8300-tdep.c, h8500-tdep.c, hppa-tdep.c, i386-tdep.c, i960-tdep.c,
- infcmd.c, inferior.h, infrun.c, m68k-tdep.c, m88k-tdep.c,
- mips-tdep.c, nindy-tdep.c, printcmd.c, pyr-tdep.c, rs6000-tdep.c,
- sh-tdep.c, sparc-tdep.c, stack.c, valops.c, z8k-tdep.c,
- config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
- config/gould/tm-pn.h, config/h8300/tm-h8300.h,
- config/h8500/tm-h8500.h, config/mips/tm-mips.h,
- config/ns32k/tm-merlin.h, config/ns32k/tm-umax.h,
- config/pyr/tm-pyr.h, config/sparc/tm-sparc.h): Replace FRAME with
- struct frame_info * everywhere, replace FRAME_ADDR with CORE_ADDR,
- rename variables consistently (using `frame' or `fi'), remove
- calls to get_frame_info and FRAME_INFO_ID, remove comments about
- FRAME and FRAME_ADDR cruftiness.
-
-Thu Nov 3 14:25:24 1994 Stu Grossman (grossman@cygnus.com)
-
- * corelow.c, exec.c, inftarg.c, m3-nat.c, op50-rom.c, procfs.c,
- remote-adapt.c, remote-e7000.c, remote-eb.c, remote-es.c,
- remote-hms.c, remote-mips.c, remote-mm.c, remote-mon.c,
- remote-nindy.c, remote-os9k.c, remote-pa.c, remote-sim.c,
- remote-st.c, remote-udi.c, remote-vx.c, remote-z8k.c, remote.c,
- w89k-rom.c, target.c, target.h: Add support for target_stop().
-
-Thu Nov 3 01:23:45 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * osfsolib.c (solib_map_sections, first_link_map_member,
- next_link_map_member, xfer_link_map_member): Retrieve and use
- shared library relocation offset from runtime loader structures.
- Use libxproc.a routines to get a working version if
- USE_LDR_ROUTINES is defined.
- * README: Remove item about shared library relocation for
- Alpha OSF/1.
-
-Wed Nov 2 15:05:39 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * c-exp.y (yylex): scan template names, and scan nested class
- names.
-
-Wed Nov 2 11:01:55 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * nlm/Makefile.in: install gdbserve.nlm.
-
-
-Tue Nov 1 13:00:46 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * c-valprint.c (c_value_print): Check for plain literal `char'
- target type when suppressing `(char *)' output for strings.
-
-Mon Oct 31 19:19:51 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * coffread.c (coff_symfile_init): Remove unused local abfd.
- * utils.c [NO_MMALLOC] (mmalloc, mrealloc): Define and use size_t
- instead of long, for compatibility with mmalloc.h.
-
-Sat Oct 29 02:40:40 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * top.c (line_completion_function): Renamed from
- symbol_completion_function, takes the line buffer and the
- point in the line buffer as additional arguments.
- (readline_line_completion_function): New function, interface
- between readline and line_completion_function.
- (init_main): Use it.
- (complete_command): Use line_completion_function instead of
- abusing rl_line_buffer. Free completion strings after printing
- them.
- * symtab.c (completion_list_add_name): Recheck for duplicates
- if we intend to add a modified symbol.
-
- * gdbtypes.h (cplus_struct_type): nfn_fields_total no longer
- includes the number of methods from the baseclasses.
- * stabsread.c (attach_fn_fields_to_type): No longer add the
- number of methods from the baseclasses to TYPE_NFN_FIELDS_TOTAL,
- the baseclass type might not have been completely filled in yet.
- * symtab.c (total_number_of_methods): New function to compute
- the total number of methods for a type, including the methods
- from baseclasses.
- (decode_line_1): Use it instead of TYPE_NFN_FIELDS_TOTAL to
- allocate the symbol array for find_methods.
-
- * stabsread.c (scan_file_globals): Add default case to minimal
- symbol type switch, to avoid gcc -Wall warnings.
-
- * config/rs6000/tm-rs6000.h (INIT_EXTRA_FRAME_INFO):
- Don't test for zero backchain pointer to recognize a signal
- handler frame, if read() gets interrupted by a signal, the
- backchain will be non zero.
- (SIG_FRAME_FP_OFFSET): Move to here from rs6000-tdep.c,
- improve comment.
- (SIG_FRAME_PC_OFFSET): New definition.
- (FRAME_SAVED_PC): Return saved pc from sigcontext if this
- is a signal handler frame.
- * rs6000-tdep.c (function_frame_info): Do not error out
- if we can't access the instructions.
-
- * config/rs6000/tm-rs6000.h (CONVERT_FROM_FUNC_PTR_ADDR):
- New definition to get the function address from a function pointer.
- * valops.c (find_function_addr): Use it when calling a user
- function through a function pointer.
-
-Fri Oct 28 16:16:52 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * Makefile.in (MMALLOC_DIR): New definition.
- (MMALLOC): Use MMALLOC_DIR.
- (MMALLOC_CFLAGS): Look in MMALLOC_DIR for mmalloc.h.
- (OPCODES): Remove gratuitous "./".
- * defs.h (mmalloc.h): Include.
- (mmalloc, mrealloc, etc): Remove decls.
- (cplus_demangle, cplus_demangle_opname): Remove decls.
-
-Wed Oct 26 15:41:07 1994 Stu Grossman (grossman@cygnus.com)
-
- * defs.h, main.c, top.c: Change sense and name of
- no_windows variable. Now called use_windows, and defaults to off
- (for compatibility).
-
-Wed Oct 26 12:20:53 1994 Jim Kingdon <kingdon@cygnus.com>
-
- * coffread.c (coff_symtab_read): If we get the address from
- target_lookup_symbol, set the section to -2 not SECT_OFF_BSS.
- (coff_symtab_read): Set value and section of symbol that
- process_coff_symbol returns.
-
-Tue Oct 25 09:53:04 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * config/i386/tm-nbsd.h: Enable longjmp support.
-
-Sat Oct 22 03:41:13 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * valarith.c (value_binop): Take care of ANSI `value preserving'
- rule, which was not addressed by the previous change.
-
- * rs6000-tdep.c (skip_prologue): Handle `mr r31,r1', which is
- generated by gcc-2.6, as a synonym for `oril r31,r1,0'.
-
- * TODO: Remove item about RS/6000 shared libraries.
-
-Thu Oct 20 17:35:45 1994 Stu Grossman (grossman@cygnus.com)
-
- * defs.h, infrun.c (wait_for_inferior), top.c: Call
- target_wait_hook to allow GUI to handle blocking for inferior. Call
- call_command_hook in execute_command to provide means for wrapping
- commands with GUI state change updates.
-
- * infrun.c (wait_for_inferior): Make sure
- through_sigtramp_breakpoint is non-null before deleting.
-
-Thu Oct 20 10:26:43 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * config/powerpc/ppc-nw.mt (TDEPFILES): Removed exec.o.
-
-Thu Oct 20 06:56:07 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (coffread.o): Depend on target.h.
- (remote-vx.o): Depend on gdb-stabs.h objfiles.h symfile.h $(bfd_h).
-
-Wed Oct 19 22:49:31 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * TODO: Fix typo.
-
-Wed Oct 19 11:32:15 1994 Jim Kingdon <kingdon@cygnus.com>
-
- * objfiles.c (objfile_relocate): When relocating ->sections, use
- objfile not symfile_objfile.
-
- * symtab.h, minsyms.c (minsyms_sort): New function.
- * objfiles.c (objfile_relocate): Call it.
-
- * remote-vx.c (vx_add_symbols): Call breakpoint_re_set.
-
- * objfiles.c, objfiles.h (objfile_to_front): New function.
- * remote-vx.c (vx_add_symbols): Call it.
-
- * coffread.c (coff_symtab_read): Handle common symbols the same
- way that partial-stab.h does.
-
-Wed Oct 19 21:06:12 1994 Rob Savoye (rob@cirdan.cygnus.com)
-
- * hppa-tdep.c: Remove include files a.out.h, ioctl.h, and
- machine/psl.h. These are host files.
-
-Wed Oct 19 15:13:51 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * objfiles.h (struct objfile): Fix comment--minimal_symbol_count
- does *not* include the terminating NULL msymbol.
-
-Tue Oct 18 20:53:29 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * monitor.c (monitor_load_srec,monitor_make_srec): Add an asrecord
- loader that reads files using BFD and converts it on the fly.
-
-Mon Oct 17 18:52:06 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * monitor.c (set_loadtype_command): Fixed so it doesn't core dump.
- * monitor.c (monitor_load): check the load type and load the file
- accordingly. Default to gr_load_image().
- * monitor.c (monitor_load_ascii_srec): Load an ascii file in
- srecord format by downloading to the monitor.
- * w89k-rom.c, op50n-rom.c: set supported load types.
-
-Mon Oct 17 10:29:08 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (ALLDEPFILES): Remove xcoffexec.c.
- * Makefile.in: Remove xcoffexec.o rule.
-
- * exec.c (exec_file_command): Add comment.
-
- Fix data and bss relocation for VxWorks 5.1:
- * remote-vx.c (vx_add_symbols): New function.
- (vx_load_command, add_symbol_stub): Call it instead of
- symbol_file_add.
- (vx_wait): Remove comment which was wrong to useless.
- * remote-vx.c: Reindent much of file.
- * coffread.c (cs_to_section, find_targ_sec): New functions.
- (process_coff_symbol): Set SYMBOL_SECTION to result
- from cs_to_section.
- (coff_symtab_read): Call cs_to_section and deal with result
- rather than assuming sections are in a certain order. Deal with
- BSS.
- * coffread.c: Remove text_bfd_scnum variable.
-
-Sat Oct 15 16:55:48 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * corelow.c: Format to standard.
- (core_close): Use name instead of bfd_filename.
-
-Fri Oct 14 10:29:08 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * exec.c (map_vmap): Cast return from xmalloc to its proper type,
- not to PTR.
-
- * symfile.c (reread_symbols): Include bfd_errmsg string in error
- message if bfd_close fails.
- * exec.c (exec_close), solib.c (clear_solib), corelow.c
- (core_close), objfiles.c (free_objfile), irix5-nat.c
- (clear_solib), osfsolib.c (clear_solib), remote-utils.c
- (gr_load_image): Check for errors from bfd_close.
- * solib.c (look_for_base), remote-utils.c (gr_load_image),
- remote-udi.c (download), corelow.c (core_open), symfile.c
- (symfile_bfd_open), symfile.c (generic_load): Add comment
- regarding error from bfd_close.
- * remote-udi.c (download), remote-utils.c (gr_load_image): Add
- comment about bogus handling of errors from bfd_openr.
- * exec.c (exec_close): Add comment regarding memory leak and
- dangling reference to vp->name.
-
-Sat Oct 15 03:43:00 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * eval.c (evaluate_subexp): Make fnptr a LONGEST instead
- of using longest_to_int.
-
- * infcmd.c (run_stack_dummy): Reinstate set_current_frame call,
- mips and alpha targets need the real breakpoint pc for
- creating the breakpoint frame.
-
- * stack.c (return_command): Cast return value to the return
- type of the function from which we return.
- * values.c (set_return_value): Pass VALUE_CONTENTS unmodified
- to STORE_RETURN_VALUE.
-
- * symtab.c (lookup_symbol): Remove search for `static mangled
- symbols', the search for `static symbols' already looks for
- mangled and demangled symbols via lookup_block_symbol.
-
- * valarith.c (value_binop): Use ANSI C arithmetic conversions
- when performing integral evaluations, implement BINOP_EQUAL and
- BINOP_LESS.
- (value_equal, value_less): Use value_binop to perform the
- comparison if both operands have TYPE_CODE_INT.
-
- * rs6000-tdep.c (pop_frame): Make sure all registers are valid,
- as they are written back later. Handle sp restore for frameless
- functions. Use fdata.nosavedpc instead of fdata.frameless to
- determine if the pc has been saved.
- (function_frame_info): Handle `mr r31,r1', which is generated by
- gcc-2.6, as a synonym for `oril r31,r1,0'.
- (skip_trampoline_code): Handle shared library trampolines.
- * xcoffread.c (read_xcoff_symtabs): Record XMC_GL symbols with
- their real name. Enables setting of breakpoints in shared libraries
- before the executable is run.
-
-Fri Oct 14 19:39:47 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * monitor.h, remote-mon.c: Hack up to so the old ROM monitor
- interface code still works with the new ROM monitor
- structures. Fake out a couple of fields.
-
-Fri Oct 14 14:54:37 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * h8500-tdep.c (target_read_sp, target_write_sp, target_read_pc,
- target_write_pc, target_read_fp, target_write_fp): Rename to
- h8500_read_sp, etc.
- (h8500_read_pc, h8500_write_pc): Add pid argument.
- * config/h8500/tm-h8500.h (TARGET_READ_SP, TARGET_WRITE_SP,
- TARGET_READ_PC, TARGET_WRITE_PC, TARGET_READ_FP, TARGET_WRITE_FP):
- Change to match functions above.
-
-Thu Oct 13 13:24:29 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * NEWS: Add item about if and while.
-
- * .gdbinit: Restore `end'; it was not excess. Reindent
- list-objfiles to make this clear. Comment out all of
- list-objfiles because old gdb's choke on it.
-
-Wed Oct 12 23:19:08 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * config/mips/tm-bigmips64.h: Just define TARGET_BYTE_ORDER and
- include tm-mips64.h.
-
-Wed Oct 12 18:02:17 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * Makefile.in (ANNOTATE_OBS): New definition.
- (COMMON_OBS): Add exec.o.
- (annotate.o): Remove extra compile rule.
- * config/*/*.mh, config/*/*.mt: Remove exec.o from *DEPFILES lists
- everywhere.
-
- * .gdbinit: Remove excess `end'.
-
- * exec.c: Merge in RS6000 support from xcoffexec.c.
- (symfile.h, objfiles.h, xcoffsolib.h): Include.
- (vmap): New global variable.
- (exec_close): Close and free objects in vmap chain.
- (exec_file_command) [IBM6000_TARGET]: Set up initial vmap.
- (bfdsec_to_vmap, map_vmap): Moved here from xcoffexec.c.
- (exec_files_info): Print vmap information.
- * xcoffexec.c: Remove.
- * config/rs6000/rs6000.mt, config/rs6000/rs6000lynx.mt
- (TDEPFILES): Use exec.o instead of xcoffexec.o.
- * TODO: Remove pertinent items.
-
-Wed Oct 12 10:08:19 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * partial-stab.h (N_TEXT): Delete GDB_TARGET_IS_HPPA kludge; they
- are no longer needed as of gcc-2.6.0.
-
-Tue Oct 11 15:51:01 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * lynx-nat.c (child_wait): Correct handling of byte reversed SPARC
- Lynx wait status.
- (fetch_core_registers): Don't try to fetch a register if
- regmap maps it to -1.
- * sparc-tdep.c (sparc_frame_find_saved_regs): Use FRAME_SAVED_I0
- and FRAME_SAVED_L0 when setting saved_regs_addr. SPARC Lynx
- stores the registers in a weird order.
-
-Sat Oct 8 20:59:13 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * blockframe.c (reinit_frame_cache): Reinstate select_frame call
- if inferior_pid is nonzero.
-
-Sat Oct 8 04:27:21 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- Speed up GDB startup time by not demangling partial symbols.
- * symfile.h (ADD_PSYMBOL_VT_TO_LIST),
- symfile.c (add_psymbol_to_list, add_psymbol_addr_to_list):
- No longer demangle partial symbols.
- * symtab.c (lookup_symbol, list_symbols): Handle mangled
- variables, e.g. C++ static members, via the minimal symbols.
-
- Handle reordered functions in an objfile, for Irix 5.2 shared
- libraries.
- * objfiles.h (OBJF_REORDERED): New bit in the objfile flags,
- set if the functions in an objfile are reordered.
- * mdebugread.c (parse_partial_symbols): Detect reordered
- functions in an objfile.
- * symtab.c (find_pc_psymtab, find_pc_symtab): Use expensive
- lookup algorithm if the functions in the objfile are reordered.
-
- * xcoffexec.c (exec_close): If the current target has a copy
- of the exec_ops sections, reflect the freeing of the sections
- in current_target.
-
- * valops.c (call_function_by_hand): Use `sizeof dummy1', not
- `sizeof dummy', for constructing the call dummy code.
-
- * config/sparc/tm-sparc.h: Add PARAMS declarations to all
- function declarations.
- * sparc-tdep.c (sparc_pop_frame): Cast result of
- read_memory_integer to CORE_ADDR when passing it to PC_ADJUST.
-
- * irix5-nat.c (enable_break): Set breakpoint at the entry point
- of the executable, to handle the case where main resides in a
- shared library.
- * irix5-nat.c (solib_create_inferior_hook): Reset stop_soon_quietly
- after shared library symbol reading, to get rid of a warning from
- heuristic_proc_start if the startup code has no symbolic debug info.
-
- * breakpoint.h (struct breakpoint): Add new fields language
- and input_radix, to enable breakpoint resetting with the
- proper language and radix.
- * breakpoint.c (set_raw_breakpoint): Initialize them.
- (breakpoint_re_set_one): Use them when resetting the breakpoint.
- (breakpoint_re_set): Preserve current language and input_radix
- across breakpoint_re_set_one calls.
-
- * symtab.c (decode_line_1): Do not build a canonical line
- specification for `*expr' line specifications.
-
- * breakpoint.h (bpstat_stop_status): Fix prototype declaration.
-
-Fri Oct 7 08:48:18 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- The point of these changes is to avoid reading the frame pointer
- and stack pointer during stepping, to speed things up.
- A. Changes to not select a frame until we need a selected frame:
- * blockframe.c (flush_cached_frames): Call select_frame (NULL, -1).
- * infrun.c (wait_for_inferior): Move call to select_frame back to
- normal_stop. This reverts a change of 13 Apr 94 (it says Jeff
- Law, but the change was my idea); the only reason for that change
- was so we could save and restore the selected frame in
- wait_for_inferior, and now that flush_cached frames clears the
- selected frame, that should work OK now.
- B. Changes to not create a current_frame until we need one:
- * blockframe.c (get_current_frame): If current_frame is NULL, try
- to create an innermost frame.
- * sparc-tdep.c (sparc_pop_frame), infcmd.c (run-stack_dummy),
- infrun.c (wait_for_inferior), thread.c (thread_switch),
- convex-tdep.c (set_thread_command), a29k-tdep.c (pop_frame),
- alpha-tdep.c (alpha_pop_frame), convex-xdep.c (core_file_command),
- h8300-tdep.c (h8300_pop_frame), h8500-tdep.c (h8300_pop_frame),
- hppa-tdep.c (hppa_pop_frame), i386-tdep.c (i386_pop_frame),
- i960-tdep.c (pop_frame), m68k-tdep.c
- (m68k_pop_frame), mips-tdep.c (mips_pop_frame), rs6000-tdep.c
- (push_dummy_frame, pop_dummy_frame, pop_frame), sh-tdep.c
- (pop_frame), config/arm/tm-arm.h (POP_FRAME),
- config/convex/tm-convex.h (POP_FRAME), config/gould/tm-pn.h
- (POP_FRAME), config/ns32k/tm-merlin.h (POP_FRAME),
- config/ns32k/tm-umax.h (POP_FRAME), config/tahoe/tm-tahoe.h
- (POP_FRAME), config/vax/tm-vax.h (POP_FRAME): Don't
- call create_new_frame.
- * corelow.c (core_open), altos-xdep.c (core_file_command),
- arm-xdep.c (core_file_command), gould-xdep.c (core_file_command),
- m3-nat.c (select_thread), sun386-nat.c (core_file_command),
- umax-xdep.c (core_file_command): Don't call create_new_frame; do
- call flush_cached_frames.
- * blockframe.c (reinit_frame_cache): Don't call create_new_frame
- or select_frame.
- C. Changes to get rid of stop_frame_address and instead only
- fetch the frame pointer when we need it.
- * breakpoint.c (bpstat_stop_status): Remove argument
- frame_address; use FRAME_FP (get_current_frame ()).
- * infrun.c (wait_for_inferior): Don't pass frame pointer to
- bpstat_stop_status.
- * infrun.c (wait_for_inferior): Use FRAME_FP (get_current_frame
- ()) instead of stop_frame_address.
- * infrun.c (save_inferior_status, restore_inferior_status),
- inferior.h (struct inferior_status): Don't save and restore
- stop_frame_address.
- * inferior.h, infcmd.c, thread.c (thread_switch), m3-nat.c
- (select_thread): Remove stop_frame_address and uses thereof.
- D. Same thing for the stack pointer.
- * infrun.c (wait_for_inferior): Remove stop_sp and replace
- uses thereof with read_sp ().
- E. Change to eliminate one nasty little spot where we were
- wanting to know the frame pointer from before the current step
- (idea from GDB 3.5, which saved my ass, because my other ideas of
- how to fix it were very baroque).
- * infrun.c: Remove prev_frame_address.
- * infrun.c (wait_for_inferior, step_over_function): Use
- step_frame_address instead of prev_frame_address.
- F. Same basic idea for the stack pointer.
- * inferior.h, infcmd.c: New variable step_sp.
- * infcmd.c (step_1, until_next_command): Set it.
- * infrun.c: Remove prev_sp and replace uses by step_sp.
- * infrun.c (wait_for_inferior): If we get out of the step
- range, then set step_sp to the current stack pointer before we
- start going again.
-
-Fri Oct 7 12:17:17 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * top.c (target_byte_order_auto): New static variable.
- (set_endian): Mention that ``auto'' is permitted.
- (set_endian_auto): New static function.
- (show_endian): Change message based on target_byte_order_auto.
- (set_endian_from_file): New function.
- (init_main): Add command ``auto'' to endianlist.
- * exec.c (exec_file_command): Call set_endian_from_file.
- * defs.h (set_endian_from_file): Declare.
-
-Thu Oct 6 18:10:41 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * nlm/i386.c (flush_i_cache): New function, does nothing.
- (frame_to_registers, registers_to_frame, set_step_traps,
- clear_step_traps, do_status): Make non-static.
-
-Thu Oct 6 12:26:42 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * config/mips/tm-mips.h (GDB_TARGET_IS_MIPS64): If not already
- defined, define as 0.
- (FIX_CALL_DUMMY): Rewrite to remove presumption that host and
- target are similar.
- * config/mips/tm-idt.h (TARGET_BYTE_ORDER_SELECTABLE): Define.
- * config/mips/tm-idtl.h (TARGET_BYTE_ORDER_SELECTABLE): Define.
- * config/mips/tm-idt64.h (TARGET_BYTE_ORDER_SELECTABLE): Define.
- (BREAKPOINT): Remove definition.
- * config/mips/tm-idtl64.h (TARGET_BYTE_ORDER_SELECTABLE): Define.
- (BREAKPOINT): Remove definition.
- * config/mips/tm-mips64.h (GDB_TARGET_IS_MIPS64): Define with a
- value of 1, rather than without a value.
- * config/mips/tm-bigmips64.h (GDB_TARGET_IS_MIPS64): Likewise.
- * mips-tdep.c: Rewrite uses of GDB_TARGET_IS_MIPS64 to switch at
- run time rather than at compile time.
-
- * remote-mips.c (break_insn): Remove.
- (BREAK_INSN, BREAK_INSN_SIZE): Define.
- (mips_insert_breakpoint): Use BREAK_INSN, not break_insn.
- (mips_remove_breakpoint): Likewise.
-
- * defs.h: If TARGET_BYTE_ORDER_SELECTABLE is defined by tm.h,
- define TARGET_BYTE_ORDER as target_byte_order, and declare
- target_byte_order as an extern int, and define BITS_BIG_ENDIAN as
- a test of TARGET_BYTE_ORDER.
- * top.c: Several additions if TARGET_BYTE_ORDER_SELECTABLE is
- defined:
- (endianlist, target_byte_order): New variables.
- (set_endian, set_endian_big, set_endian_little): New functions.
- (show_endian): New function.
- (init_cmd_lists): Initialize endianlist.
- (init_main): Add commands ``set endian big'', ``set endian
- little'', and ``show endian''.
- * a29k-pinsn.c: Rewrite uses of TARGET_BYTE_ORDER and
- BITS_BIG_ENDIAN to switch at run time rather than at compile time.
- * coffread.c, dwarfread.c, findvar.c, mips-tdep.c: Likewise.
- * remote-os9k.c, stabsread.c, valarith.c, valprint.c: Likewise.
- * values.c: Likewise.
-
-Wed Oct 5 11:41:24 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * nlm/configure.in: ${gdb_host_cpu} defaults to ${host_cpu}.
-
- * nlm/Makefile.in: Get rid of NWINCLUDES.
- * config/{alpha,powerpc}/gdbserve.mt: Remove NWINCLUDES.
- User should now configure with --with-headers.
-
-Mon Oct 3 07:48:34 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbserver/server.c (main): Silently accept all unrecognized
- requests and send back a zero length acknowledge. That is what
- *-stub.c do and is what remote.c expects.
-
-Mon Oct 3 05:11:47 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * corelow.c (core_open): Copy the modified to_sections_end
- vector from current_target to core_ops too.
-
- * gdbserver/server.c (main): Silently accept query requests
- and send back a zero length acknowledge.
-
-Fri Sep 30 17:17:21 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * nlm/Makefile.in: Don't define NWINCLUDES.
- * config/{alpha,powerpc}/gdbserve.mt: define NWINCLUDES.
-
-Fri Sep 30 15:59:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbserver/low-lynx.c (create_inferior): Pass all 4 args to ptrace.
-
-Fri Sep 30 06:42:42 1994 Ian Lance Taylor (ian@cygnus.com)
-
- * lynx-nat.c (child_wait): Use status.w_status, not status, in
- arithmetic. status is a `union wait'.
-
- * config/nm-lynx.h (PTRACE_ARG3_TYPE): Define to int, not char *.
-
- * lynx-nat.c (child_wait): Pass fourth argument to ptrace.
-
-Thu Sep 29 08:22:27 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab): Fix comment for yesterday's change.
-
-Wed Sep 28 17:48:18 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * coffread.c (complete_symtab): If last_source_file is set upon
- entry, free it.
-
-Wed Sep 28 08:59:14 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab, case C_FILE):
- Set main_aux before using it.
-
- * xcoffexec.c (exec_close): If quitting, don't call clear_symtab_users.
-
- * xcoffread.c (read_xcoff_symtab): Process XTY_LD symbols we were
- ignoring before. But continue to ignore XMC_DS.
-
-Wed Sep 28 00:35:23 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (hpread_read_array_type): Do not change the type code
- to TYPE_CODE_PTR for "char foo[]". Just make it a zero length
- array type.
-
- * hpread.c (hpread_type_translate): Handle T_UNS_LONG types with
- lengths other than 32bits (HP C 9.69 represents an "unsigned char"
- as an T_UNS_LONG with length 8).
-
- * hpread.c (struct hpread_symfile_info): Delete have_module field
- and accessor macro. Minor indentation fix.
- (hpread_build_psymtabs, case K_MODULE): Only start a new psymtab
- and reset state variables have_name & texthigh if pst is NULL.
- (hpread_build_psymtabs, case K_SRCFILE): Only reset the name of a
- partial symbol table if pst is non-NULL. If pst is NULL, then
- start a new psymtab.
- (hpread_process_one_debug_symbol, case K_MODULE): Now empty.
- (hpread_process_one_debug_symbol, case K_SRCFILE): Simplify and
- correct handling of subfiles.
-
-Mon Sep 26 02:59:00 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * defs.h (misc_command_type): Remove trailing comma from
- enumerator list.
-
-Sun Sep 25 23:19:58 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (frame_saved_pc): Fix thinko in code to dig saved pc
- out of an interrupt frame.
-
-Sun Sep 25 12:50:17 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
- defined.
- * values.c (unpack_double) [INVALID_FLOAT]: Ditto.
- * mips-tdep.c (mips_print_register): Don't test float validity.
- * config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
- config/arm/tm-arm.h, config/convex/tm-convex.h,
- config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
- config/i386/tm-i386v.h, config/i386/tm-sun386.h,
- config/i960/tm-i960.h, config/m68k/tm-m68k.h,
- config/m88k/tm-m88k.h, config/mips/tm-mips.h,
- config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
- config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
- config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
- config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
- config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
- Remove definition.
-
-Sun Sep 25 06:07:37 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * TODO: Remove item about adding general multi-threaded stuff;
- this is done.
- Remove item about specifying arbitrary locations of stack frames
- (this works on some machines).
- Remove item about debugging functions without a frame pointer
- (this works on some machines).
- Remove item about re-writing macros which handle frame chaining and
- frameless functions. They have been re-written at least once
- since that item was written.
- Remove item about gdb catching SIGINT when attached; this is done.
- Remove item about having list_command not read symbols--why bother?
-
-Sat Sep 24 17:40:10 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * TODO: Append contents of Projects file.
- * Projects: Remove.
-
-Sat Sep 24 01:47:25 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * corelow.c (add_solib_stub): Remove copying of to_sections,
- pass current_target to SOLIB_ADD. The Sep 10 change failed
- if SOLIB_ADD errored out, or if SOLIB_ADD was trying to access
- target memory.
- * corelow.c (core_open): After reading the shared libraries,
- copy the modified to_sections vector from current_target to
- core_ops, so that core_close can free it later.
- * config/rs6000/nm-rs6000.h, rs6000-nat.c (xcoff_relocate_core):
- Pass down target parameter from SOLIB_ADD and use it instead of
- directly accessing core_ops.
-
-Fri Sep 23 14:58:49 1994 J.T. Conklin (jtc@rtl.cygnus.com)
-
- * solib.c: *BSD systems need <a.out.h> to be included before
- <link.h>.
-
- * i386b-nat.c: Add i386_float_info(), etc.
- * config/i386/nm-nbsd.h: #define FLOAT_INFO.
-
- * config/nm-nbsd.h: New file, for generic NetBSD native support.
- * config/i386/nm-nbsd.h: Use it.
- * config/sparc/nm-nbsd.h: Use it.
- * config/ns32k/nm-nbsd.h: Use it.
-
- * configure.in (i386-*-netbsd): Use config/i386/nbsd.m[ht].
- (ns32k-*-netbsd): Use config/ns32k/nbsd.m[ht].
- * config/i386/{nbsd.mh,nbsd.mt,nm-nbsd.h,tm-nbsd.h,xm-nbsd.h}:
- New files, support for NetBSD/i386.
- * config/ns32k/{nbsd.mh,nbsd.mh,nm-nbsd.h,tm-nbsd.h,xm-nbsd.h}:
- New files, support for NetBSD/ns32k.
-
-Tue Sep 20 11:34:27 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * .gdbinit: Add list-objfiles command.
-
- * TODO: Reword item regarding NO_STD_REGS.
-
- * coffread.c (record_minimal_symbol, coff_read_enum_type,
- coff_read_struct_type): Allocate on symbol_obstack, not directly
- via malloc/savestring.
-
-Tue Sep 20 15:42:02 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * TODO: Add more items.
- * tests: Remove the directory and all of its (obsolete) contents.
-
-Tue Sep 20 11:34:27 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * coffread.c (init_stringtab): When copying length to stringtab,
- use target format, not host format, since that is what the rest of
- the code assumes.
-
-Mon Sep 19 15:48:10 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * Makefile.in: Removed prelude.o, i386-nlmstub.o, nlmstub.o,
- nlmstub.nlm, and nlmstub targets. Removed NWSOURCE and
- NWINCLUDES definitions.
- * i386-nlmstub.c: Removed.
-
-Mon Sep 19 07:48:36 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * dbxread.c (read_dbx_dynamic_symtab): Cast bfd_asymbol_name to
- char * (from const char *) before assigning. Don't save string we
- pass to record_minimal_symbol (it already saves it).
-
-
-Sat Sep 17 02:26:58 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * cp-valprint.c (static_field_print): New variable, controls
- printing of static members.
- (_initialize_cp_valprint): New print set subcommand
- "static-members". Turn on printing of static members by default.
- (cp_print_value_fields): Print static members if necessary.
-
- * solib.c: Remove inclusion of libelf.h and elf/mips.h.
- (elf_locate_base): Use only standard BFD functions to collect
- information about the .dynamic section. Check for DT_MIPS_RLD_MAP
- tag only if it got defined via the inclusion of <link.h>.
-
- * f-exp.y: Write block for OP_VAR_VALUE.
- * f-valprint.c (info_common_command): Handle `info common'
- without an argument correctly.
-
- * c-typeprint.c (c_type_print_base): Handle template constructors.
- * symtab.c (gdb_mangle_name): Handle template method mangling,
- get rid of GCC_MANGLE_BUG code, which only applied to gcc-2.2.2.
-
-Fri Sep 16 16:06:08 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * gdbtypes.h (TYPE_INDEX_TYPE): New macro.
- * ch-typeprint.c, ch-valprint.c: Use TYPE_INDEX_TYPE.
- * ch-valprint.c (chill_val_print): Pass index type directly
- (instead of its TYPE_TARGET_TYPE) to print_type_scalar.
- * stabsread.c (read_type): Don't set TYPE_FLAG_TARGET_STUB
- if the index type is a stub.
-
-Fri Sep 16 17:18:44 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config/i386/{i386aix.mh, i386bsd.mh, i386lynx.mh, i386sco.mh,
- i386sco4.mh, i386sol2.mh, i386v.mh, i386v32.mh, i386v4.mh,
- ncr3000.mh, ptx.mh, ptx4.mh}, config/m68k/{altos.mh, apollo68v.mh,
- delta68.mh, dpx2.mh, hp300bsd.mh, hp300hpux.mh, m68klynx.mh,
- m68kv4.mh}, config/m88k/{delta88.mh, delta88v4.mh},
- config/mips/riscos.mh, config/pa/hppahpux.mh,
- config/rs6000/rs6000lynx.mh, config/sparc/{sparclynx.mh,
- sun4sol2.mh}, config/tahoe/tahoe.mh, config/vax/{vaxbsd.mh,
- vaxult.mh, vaxult2.mh} (REGEX, REGEX1, SYSV_DEFINE): No longer
- define.
- * config/i386/i386sco4.mh (MUNCH_DEFINE): No longer define.
-
-Fri Sep 16 15:40:34 1994 Stu Grossman (grossman@cygnus.com)
-
- * defs.h (QUIT): Call interactive_hook to allow GUI to interrupt.
- Also, add decl for symtab_to_filename.
- * source.c (symtab_to_filename): New. Returns the file
- associated with a symtab.
- * top.c: Define interactive_hook. Called during QUIT to animate
- the GUI.
-
-Fri Sep 16 00:14:40 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * stabsread.c (read_type): Handle stub types for bitstrings.
- * stabsread.c (read_array_type): Check for stub domain type
- using TYPE_FLAG_STUB, not its length.
- * gdbtypes.c (create_set_type): Handle a stub domain type.
-
- * ch-exp.y: Get rid of some extra non-terminals, and move
- their rules into primitive_value.
- * parser-defs.h: Add comment about unary postfix operators.
- * ch-lang.c (chill_op_print_tab): Add '->', postfix and prefix.
- * expprint.c (print_subexp): Recognize unary postfix operator.
-
-Wed Sep 14 18:27:42 1994 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * remote-hms.c: use remote_debug instead of hms_silent toggle.
- Add warnings about depreciation of `snoop' cmd.
-
-Wed Sep 14 18:18:58 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * remote-hms.c (hms_read_inferior_memory): Cope when
- target sends both \r and \n.
-
-Wed Sep 14 17:14:57 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * remote-mips.c (mips_error): Place NORETURN macro correctly.
- * TODO: Add item about START_INFERIOR_TRAPS_EXPECTED.
-
-Wed Sep 14 14:26:21 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab): Fix obsolete comment about
- mst_solib_trampoline.
-
- * f-valprint.c (f_val_print): Change cast of valaddr from
- CORE_ADDR * to char **, since that is how it is used.
-
- * dbxread.c (read_dbx_dynamic_symtab): Save copy of symbol names
- using obsavestring, and pass that to prim_record_minimal_symbol.
- Having the objfile point to bfd_asymbol_name directly doesn't work
- if we save and restore a mapped symbol file.
-
-
-Tue Sep 13 18:23:26 1994 Rob Savoye (rob@darkstar.cygnus.com)
-
- * w89k-rom.c, op50-rom.c, monitor.c, config/pa/hppapro.mt: New files
- to add a generic ROM monitor interface, and support file for the
- WinBond W89K and the Oki OP50N PA based target boards.
-
-
-Sun Sep 11 22:34:57 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * config/pa/tm-hppa.h (REGISTER_NAMES): Use r26-r23 for arg0-arg3.
-
-Sun Sep 11 04:36:47 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * irix5-nat.c, osfsolib.c, solib.c (solib_add): Simplify last
- change by replacing `symbols_added' with `so_last'.
- * mdebugread.c (parse_external, parse_partial_symbols): Ignore
- global common symbols, they will be resolved by the runtime loader.
- * mdebugread.c (parse_symbol, parse_partial_symbols, cross_ref):
- Handle scSCommon like scCommon symbols.
-
-Sat Sep 10 01:43:28 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * corelow.c (add_solib_stub): Copy to_sections changes from
- core_ops to current_target after adding the shared libraries.
- * partial-stab.h (N_EXCL), dbxread.c (add_old_header_file,
- find_corresponding_bincl_psymtab): Change `repeated header not seen'
- error to a complaint, simplify complaint.
- * procfs.c (signalname, errnoname): Make `name' const.
- * symfile.c (reread_symbols): Use filename from old BFD to
- reopen the objfile.
- * values.c (record_latest_value): Don't record value in the
- history chain until we are sure there won't be an error.
-
-Fri Sep 9 15:52:09 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * nlm/Makefile.in: remove MMALLOC, READLINE, TERMCAP, and other
- cruft.
-
- * config/i386/gdbserve.mt: New file, defs for i386 nlm stub.
-
-Thu Sep 8 17:14:43 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * remote.c (fromhex): Make error more explicit.
- (read_frame): Don't print bad checksum information unless
- remote_debugging. Don't use repeat count unless it's > 0.
- * remote-e7000.c (expect): When echoing, ignore multiple newlines.
- (e7000_insert_breakpoint, e7000_remove_breakpoint, target_ops):
- Optionally cope with BC style breakpoints.
- (e7000_command): After command send directly to the E7000 mark
- registers as changed.
- (why_stop, e7000_wait: Understand BC style stop condition.
- * sh-tdep.c (sh_skip_prologue): Understand more complicated
- sequences. (frame_find_saved_regs): Likewise.
- * config/h8500/tm-h8500.h (target_write_pc, TARGET_WRITE_PC):
- Handle extra arg.
- * config/i386/xm-go32.h (GDBINIT_FILENAME): Set to gdb.ini.
- (more work here to come)
- * config/sh/tm-sh.h (EXTRA_FRAME_INFO): Add f_offset and leaf_function
- fields.
-
-Thu Sep 8 16:15:34 1994 J.T. Conklin (jtc@rtl.cygnus.com)
-
- * sparclite/Makefile.in: Assorted stuff needed for eload.
-
- * sparclite/eload.c: Merge in command line argument parsing and
- error message handling improvements orignally made to aload.c.
-
-Wed Sep 7 23:24:50 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * defs.h (enum misc_command_type, command_control_type): Enums
- for describing the command and control types.
- (struct command_line): Add new fields to keep track of the command
- type and body associated with the command.
- * top.c: Include value.h. Delete whitespace at the end of lines.
- (build_command_line, get_command_line): New functions.
- (execute_control_command, while_command, if_command): Likewise.
- (realloc_body_list, read_next_line): Likewise.
- (recurse_read_control_structure): Likewise.
- (execute_user_command): Call execute_control_command.
- (read_command_lines): Simplify by calling read_next_line, call
- read_control_structure for "if" and "while" commands.
- (free_command_lines): Free new fields in the command structure.
- (define_command): Reset control_level to zero.
- (init_main): Install command handlers for "if" and "while" commands.
-
-Tue Sep 6 16:24:07 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * c-typeprint.c (c_type_print_varspec_prefix,
- c_type_print_varspec_suffix): Add cases for Fortran type codes.
- * eval.c (evaluate_subexp): For OP_ARRAY expressions in Fortran,
- call f77_value_literal_string instead.
- * f_exp.y: Include <string.h>, move include of parser-defs.h.
- (parse_number): Translate 'd' floats to 'e' so atof() works.
- (yylex): Remove unused variables.
- * f-lang.c: Include <string.h>.
- (get_bf_for_fcn): Remove unused variable.
- * f-typeprint.c (f_type_print_varspec_prefix,
- f_type_print_varspec_suffix): Remove unused
- variables, add cases to switch statements.
- (f_type_print_base): Remove unused variables.
- * f-valprint.c (gdbcore.h, command.h): Include.
- (f77_get_dynamic_lowerbound, f77_get_dynamic_upperbound):
- Call read_memory_integer with correct number of arguments.
- (f77_get_dynamic_upperbound): Call f77_get_dynamic_lowerbound
- with correct argument type.
- (f77_print_array): Removed unused array array_size_array.
- (f_val_print): Don't use a CORE_ADDR as a char *.
- * valops.c (value_cast): Handle COMPLEX and BOOL types.
- (value_assign): Handle Fortran literal string and complex values.
- (f77_cast_into_complex, f77_assign_from_literal_string,
- f77_assign_from_literal_complex): New functions.
-
-Mon Sep 5 14:46:41 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * ch-typeprint.c (chill_type_print_base): Make TYPE_CODE_RANGE
- case more robust.
-
-Sun Sep 4 16:06:34 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * i960-tdep.c (signal.h): Don't include.
-
- * cxux-nat.c (target_is_m88110): Remove definition.
-
- * configure.in (config/nm-empty.h): If cross only, use instead
- of config/nm-trash.h.
- * config/nm-trash.h: Remove.
- * config/nm-empty.h: New file.
- * config/i386/nm-m3.h: New file, includes config/nm-m3.h.
- * config/mips/nm-m3.h: New file, includes config/nm-m3.h.
- * config/m68k/nm-sysv4.h: New file, includes config/nm-sysv4.h.
- * config/mips/nm-sysv4.h: New file, includes config/nm-sysv4.h.
- * config/sparc/nm-sysv4.h: New file, includes config/nm-sysv4.h.
-
-
-Fri Sep 2 17:35:55 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * configure.in: No longer look for nm, tm, and xm headers in
- config/<header>; they are always in config/<cpu>/<header>.
-
-Fri Sep 2 16:40:03 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * objfiles.c (allocate_objfile): Add the newly-created objfile to
- the end of the list of objfiles, instead of at the beginning.
-
- * xcoffread.c (allocate_include_entry): New function, abstracted
- from code in record_include_begin.
- (record_include_begin, record_include_end): Call it.
-
- * blockframe.c (reinit_frame_cache): Test inferior_pid instead of
- target_has_stack to decide whether to create a real stack frame
- for the cache.
-
- * coffread.c (process_coff_symbol) [CXUX_TARGET]: Ignore vendor
- section.
- * config/m88k/tm-cxux.h (CXUX_TARGET): Define.
-
- * h8300-tdep.c: Include "dis-asm.h" instead of <dis-asm.h>.
-
-Fri Sep 2 09:51:46 1994 J.T. Conklin (jtc@cygnus.com)
-
- * config/sparc/tm-nbsd.h: Add #defines to map NetBSD struct and
- field names into what is expected by sparc-nat.c.
-
-Thu Sep 1 17:32:54 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * c-typeprint.c (c_typedef_print): Add missing Chill support.
-
-Thu Sep 1 15:41:21 1994 Stu Grossman (grossman@cygnus.com)
-
- * rs6000-pinsn.c (print_insn): Use powerpc disassembler when
- doing Power PC.
- * config/powerpc/tm-ppc-nw.h: Define GDB_TARGET_POWERPC.
-
- * config/i386/i386lynx.mh, config/m68k/m68klynx.mh,
- config/rs6000/rs6000lynx.mh, config/sparc/sparclynx.mh: Enable
- ser-tcp.
-
- * nlm/Makefile.in: Get rid of NWSOURCE.
- * nlm/alpha-io.S (inVti, outVti): Remove extraneous ldha's.
- * nlm/gdbserve.o: Add dummy __main routine.
- * nlm/gdbserve.def: Turn on debug.
-
-Thu Sep 1 12:36:39 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * config/xm-nbsd.h: Don't define SET_STACK_LIMIT_HUGE; it is obsolete.
-
-Thu Sep 1 11:01:40 1994 J.T. Conklin (jtc@rtl.cygnus.com)
-
- * config/tm-nbsd.h: New file, support for all NetBSD targets.
- * config/xm-nbsd.h: fix typo.
- * config/sparc/{nm,tm,xm}-nbsd.h: New files, renamed from
- {nm,tm,xm}-sparcnbsd.h to conform to prefered file naming
- conventions.
- * configure.in: (sparc-*-netbsd): use config/sparc/nbsd.m[ht].
-
-Wed Aug 31 14:40:33 1994 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * remote-udi.c (udi_read_inferior_memory,udi_write_inferior_memory):
- change typeo in error msg (`inferrior' -> `inferior').
-
-Wed Aug 31 09:17:02 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * inflow.c (set_sigint_trap, clear_sigint_trap): Check for
- attach_flag (this check was performed by the callers). Also check
- inferior_thisrun_terminal.
- * inftarg.c (child_wait), lynx-nat.c (child_wait),
- procfs.c (wait_fd), symm-nat.c (child_wait): Don't check
- attach_flag in deciding whether to call set_sigint_trap and
- clear_sigint_trap.
-
- * value.h (struct value): Change literal_data from PTR to char *,
- since that is the way it is used.
-
-Tue Aug 30 21:56:54 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * somread.c (som_symfile_read): Force unwinds to be re-read after
- reading in a new partial symbol table.
-
-Tue Aug 30 13:14:16 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config/h8500/tm-8500.h (DONT_USE_REMOTE): Remove definition,
- an obsolete conditional.
- * config/pa/tm-hppa.h (BREAKPOINT) [KERNELDEBUG]: Remove use,
- an obsolete conditional.
- * config/rs6000/rs6000.mh, config/rs6000/rs6000.mt: Clean up
- comments.
-
-Mon Aug 29 14:39:42 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * Makefile.in (ns32k-opcode.h): Remove reference.
- (ns32k-pinsn.o): Update dependencies.
- * ns32k-opcode.h: Remove file.
- * ns32k-pinsn.c (print_insn): Call version in libopcodes, remove
- all other code in this file.
-
-Mon Aug 29 12:04:07 1994 Stu Grossman (grossman@cygnus.com)
-
- * nlm/configure.in: Stop using cpu.c. Put it in TDEPFILES instead.
- * config/alpha/gdbserve.mt (TDEPFILES): Remove alpha-patch.o.
-
- * nlm/Makefile.in: Add rule for .S.o.
- * nlm/aio.h: Protect from multiple inclusions.
- * nlm/alpha-io.S: Remove everything we don't need.
- * nlm/{alpha-patch.c, alpha-patch.h, alpha-uart.c, alpha-uart.h}:
- Remove, no longer needed.
- * nlm/alpha.c: Merge in lots of stuff from previous files.
- * nlm/alpha.h: Don't #include alpha-patch.h. Make
- breakpoint_insn extern.
- * Move stuff from alpha-patch.h into here.
-
- * config/alpha/gdbserve.mt (TDEPFILES): Get rid of alpha-uart.o.
-
-Mon Aug 29 11:34:34 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * annotate.c (annotate_starting): Flush output.
-
-Sat Aug 27 23:32:43 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symfile.c (symbol_file_add): Move reinit_frame_cache call to
- the callers of symbol_file_add. Gets rid of heuristic fence-post
- warnings on mips and alpha targets when the PC resides in a shared
- library which is not yet read in.
- * coff-solib.c (coff_solib_add), cxux-nat.c (add_shared_symbol_files),
- irix5-nat.c (solib_add), osfsolib.c (solib_add),
- remote-vx.c (vx_open), solib.c (solib_add):
- Add call to reinit_frame_cache after all shared libraries are read in.
- * remote-udi.c (udi_load), remote-vx.c (vx_load_command),
- symfile.c (symbol_file_command, add_symbol_file_command):
- Add call to reinit_frame_cache after symbol_file_add.
-
-Wed Aug 24 17:45:14 1994 J.T. Conklin (jtc@cygnus.com)
-
- * config/xm-nbsd.h: New file, support for all NetBSD ports.
- * config/sparc/{nm-sparcnbsd.h,tm-sparcnbsd.h,xm-sparcnbsd.h,
- sparcnbsd.mh,sparcnbsd.mt}: New files, support for NetBSD/sparc.
- * configure.in: Add sparc-*-netbsd target.
-
-Wed Aug 24 13:17:34 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * remote-vx.c (vx_attach): Interpret the command argument as an
- unsigned long.
-
-Wed Aug 24 13:08:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * configure.in: Change i[34]86 to i[345]86.
- * nlm/configure.in: Likewise.
- * gdbserver/configure.in: Likewise.
-
-Wed Aug 24 09:41:09 1994 J.T. Conklin (jtc@cygnus.com)
-
- * configure.in (i386-*-netware): Automatically configure nlm
- subdir.
-
-Tue Aug 23 17:51:13 1994 J.T. Conklin (jtc@cygnus.com)
-
- * nlm/gdbserve.c: conditionalize header file inclusion for either
- NetWare 4.0 or PIN targets.
- * nlm/i386.c: include appropriate header files.
- * nlm/prelude.c: define TERMINATE_BY_UNLOAD for NetWare 4.0
- targets.
-
-Tue Aug 23 16:54:16 1994 Stu Grossman (grossman@cygnus.com)
-
- * nlm/ppc.c (set_step_traps clear_step_traps): Cleanups.
- * nlm/gdbserve.def: Autoload clib.
-
-Tue Aug 23 12:05:19 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * breakpoint.c (condition_command): Call breakpoints_changed.
-
- * gdbtypes.h: Declare f77_create_literal_string_type and
- f77_create_literal_complex_type.
- * valops.c (f77_value_literal_string, f77_value_substring,
- f77_value_literal_complex): Use xmalloc not malloc.
- * valops.c (f77_value_literal_string, f77_value_substring):
- Make addr char * not CORE_ADDR.
- * value.h (struct value): Add new field literal_data of aligner union.
- (VALUE_LITERAL_DATA): Use it.
- * f-lang.h: Declare find_common_for_function.
- * value.h, valops.c: Split VALUE_SUBSTRING_START into memaddr and
- myaddr fields of a union. Don't overload it with the frame field
- (not sure this is necessary; I'm not sure what lval_* codes
- VALUE_SUBSTRING_* can be used with).
-
-Mon Aug 22 11:45:01 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config/a29k/{a29k-kern.mt,a29k-udi.mt,a29k.mt,ultra3.mh,
- ultra3.mt}: Clean up comments, remove no-longer-used definitions.
-
- * rs6000-nat.c: Include libbfd.h again, needed until reference
- to bfd_cache_lookup is cleaned out.
-
- * config/i386/linux.mh (XM_CLIBS): Add -lm.
-
-Mon Aug 22 10:42:15 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- Work to reduce the interrupts-off duration when running in DOS.
- * ser-go32.c: (dos_async_ready): See if anything is in the buffer.
- (dos_async_rx): rewrite to unpack as many characters from the
- asynctsr as possible into a local buffer.
-
-Fri Aug 19 14:55:45 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Initial Fortran language support, adapted from work by Farooq Butt
- (fmbutt@engage.sps.mot.com).
- * Makefile.in: Add Fortran-related files and dependencies.
- * defs.h (language_fortran): New language enum.
- * language.h (_LANG_fortran): Define.
- (MAX_FORTRAN_DIMS): Define.
- * expression.h: Reformat to standard.
- (MULTI_F77_SUBSCRIPT, OP_F77_UNDETERMINED_ARGLIST,
- OP_F77_LITERAL_COMPLEX, OP_F77_SUBSTR): New expression opcodes.
- * gdbtypes.h (TYPE_CODE_COMPLEX, TYPE_CODE_LITERAL_COMPLEX,
- TYPE_CODE_LITERAL_STRING): New type codes.
- (type): New fields upper_bound_type and lower_bound_type.
- (TYPE_ARRAY_UPPER_BOUND_TYPE, TYPE_ARRAY_LOWER_BOUND_TYPE,
- TYPE_ARRAY_UPPER_BOUND_VALUE, TYPE_ARRAY_LOWER_BOUND_VALUE): New
- macros.
- (builtin_type_f_character, etc): Declare.
- * value.h (VALUE_LITERAL_DATA, VALUE_SUBSTRING_START): Define.
- * f-exp.y: New file, Fortran expression grammar.
- * f-lang.c: New file, Fortran language support functions.
- * f-lang.h: New file, Fortran language support declarations.
- * f-typeprint.c: New file, Fortran type printing.
- * f-valprint.c: New file, Fortran value printing.
- * eval.c (evaluate_subexp): Add code for new expression opcodes,
- fix wording of error message.
- * gdbtypes.c (f77_create_literal_complex_type,
- f77_create_literal_string_type): New functions.
- * language.c (set_language_command): Add Fortran info.
- (calc_f77_array_dims): New function.
- * parse.c (length_of_subexp, prefixify_subexp): Add cases for new
- expression opcodes.
- * symfile.c (deduce_language_from_filename): Recognize .f and .F
- as Fortran source files.
- * valops.c (f77_value_literal_string, f77_value_substring,
- f77_value_literal_complex): New functions.
-
-Fri Aug 19 13:35:01 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * c-typeprint.c (c_print_type): Assume demangled arguments
- if a '(' is found in varstring, looking for ')' at the end of
- varstring did fail with demangled const member functions, which
- have a trailing `const'.
- * remote.c (get_offsets, putpkt): Change to `char' buffers,
- to avoid errors when compiling with DEC c89.
- (remote_wait): Cast to `char *' before passing buffer to
- fputs_filtered, to avoid errors when compiling with DEC c89.
- (remote_wait): Do not return inferior_pid by default, this
- statement is never reached, which causes warnings from some
- compilers.
- * stabsread.c (scan_file_globals): Ignore static minimal symbols.
- * symfile.c (load_command): If called with no argument, try
- to get the filename from the executable file.
- (generic_load): Remove check for NULL filename, it is done
- in load_command now.
-
-Fri Aug 19 10:36:15 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * Makefile.in (ALLDEPFILES): Add hpread.c.
- (hpread.o): Add dependencies.
-
- * somread.c: Do not include "aout/aout64.h". SOM has nothing to
- do with a.out.
- (BYTES_IN_WORD): Delete.
- (som_symfile_read): Call hpread_build_psymtabs to build any
- minimal symbols based on the HP C native debug symbols.
- (som_symfile_finish): Call hpread_symfile_finish.
- (som_symfile_init): Call hpread_symfile_init.
- * config/pa/tm-hppa.h (HPREAD_ADJUST_STACK_ADDRESS): Define.
- * hppa-tdep.c (hpread_adjust_stack_address): New function.
-
- * config/pa/hppabsd.mh (NATDEPFILES): Add hpread.o
- * config/pa/hppahpux.mh (NATDEPFILES): Likewise.
- * hpread.c: New file.
-
-Fri Aug 19 00:40:55 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (skip_trampoline_code): Revert incorrect change
- from June 2, 1994 (what was I thinking?!?). Fix it right this
- time.
-
-Thu Aug 18 17:01:35 1994 J.T. Conklin (jtc@rtl.cygnus.com)
-
- * nlm/i386.c, nlm/i386.h: New files that contain i386 specific code.
-
-Thu Aug 18 14:39:46 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * README: Grammar improvements, clarifications, updates.
-
-Wed Aug 17 23:08:53 1994 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in (TARGET_FLAGS_TO_PASS): Pass down LD_FOR_TARGET and
- NLMCONV_FOR_TARGET. (SUBDIRS): Add nlm target.
- * configure.in (powerpc-*-netware*): Automatically configure nlm
- subdir.
- * nlm/Makefile.in: Add {CC NLMCONV LD}_FOR_TARGET. Remove alpha
- specific stuff. Make things more configurable.
- * nlm/configure.in: Add powerpc-*-netware* target. Use
- gdbserve.mt/cpu.c/cpu.h for target stuff. Get rid of tm/xm/nm.h
- files.
- * nlm/gdbserve.c: Move Alpha specific stuff into other files.
- Remove lots of architecture-specific stuff.
- * nlm/gdbserve.def: Add new imports.
- * nlm/ppc.c, nlm/ppc.h: New files that contain PowerPC specific code.
- * nlm/prelude.c: Don't include libhooks.h, get rid of call to
- register library.
- * nlm/prelude.o: What was this doing here?
- * config/alpha/gdbserve.mt: Defs for alpha nlm stub.
- * config/powerpc/gdbserve.mt: Defs for PowerPC nlm stub.
- * config/powerpc/ppc-nw.mt: Defs for PowerPC target for GDB.
- * config/powerpc/tm-ppc-nw.h: Ditto.
-
- * nlmstub.def: New file, contains imports for 386 nlm stub.
-
-Wed Aug 17 23:17:33 1994 Rob Savoye (rob@darkstar.cygnus.com)
-
- * remote-pa.c: New file for HPPA embedded support. Currently it's
- a copy of remote.c.
- * config/pa/hppabsd.mt,hppahpux.mt,hppaosf.mt: User remote-pa.c.
-
-Wed Aug 17 13:19:52 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config/m68k/tm-delta68.h (EXTRACT_RETURN_VALUE,
- STORE_RETURN_VALUE): Define to use %a0 for pointers.
-
-Wed Aug 17 07:43:06 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-mips.c: Remove unused declaration of mips_load.
-
-Tue Aug 16 16:45:34 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * coffread.c: General cleanup, and support for section offsets.
- (time.h, sys/types.h, libbfd.h): Don't include.
- (cur_src_start_addr, cur_src_end_addr): Rename to
- current_source_start_addr, current_source_end_addr.
- (nlist_stream_global): Remove.
- (nlist_bfd_global): New global variable.
- (coff_symfile_read): Remove code that gets and uses fileno()
- directly.
- (read_coff_symtab, enter_linenos, process_coff_symbol): Add
- section_offsets parameter, add text/data section offset to
- appropriate symbols' values.
- (read_one_sym): Use bfd_read instead of fread.
- (init_stringtab, init_lineno): Change first parameter to a bfd,
- use bfd routines instead of raw I/O.
-
-Tue Aug 16 15:24:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.c (decode_line_1): If funfirstline and we get a
- non-LOC_BLOCK symbol (e.g. variable or type), then error().
-
- * Makefile.in (TARFILES, NONSRC, SFILES_STAND, SFILES_KGDB):
- Remove; unused.
- (TAGFILES_NO_SRCDIR): Remove ALLPARAM.
- (HFILES_NO_SRCDIR): Remove all files in config sub-directory.
- (TAGS): Also pass result of find on config sub-directory to etags.
- (ALLPARAM): Remove; now unused.
-
-Sun Aug 14 13:05:26 1994 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.13.1
- * NEWS, README: Update to match gdb 4.13 release version.
-
-Sat Aug 13 08:22:50 1994 Fred Fish (fnf@cygnus.com)
-
- Harris CX/UX support, from Bob Rusk (rrusk@mail.csd.harris.com).
- * cxux-nat.c: Remove dangling #else block.
- (m88k_harris_core_register_addr): New function.
-
- * environ.c (init_environ): If no environment, do nothing.
-
-Fri Aug 12 19:30:53 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Delete rest of TODO list. Do not include "libbfd.h",
- <time.h>, <sys/types.h>, "demangle.h", <sys/file.h>,
- "expression.h", "language.h", "gdbtypes.h", "demangleh".
- Move all global variables into the private symbol table structure
- and add accessor macros. Update some comments.
- (hpread_build_psymtabs): Delete dbsubc_addr, we don't need it.
- (hpread_end_psymtab): New function to end a partial symbol table,
- all callers changed (no more bogus sharing with dbxread.c).
-
-Fri Aug 12 15:52:37 1994 Stu Grossman (grossman@cygnus.com)
-
- * remote.c (remote_wait): Return inferior_pid instead of 0 for
- `W` message.
-
-Fri Aug 12 11:47:10 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * sparclite/aload.c (sys_error, error): Use vfprintf for variable
- argument lists.
-
-Thu Aug 11 04:06:42 1994 Doug Evans (dje@canuck.cygnus.com)
-
- * defs.h (concat, basename, buildargv, freeargv, strerrno, strsigno,
- errno_max, signo_max, strtoerrno, strtosigno): Delete.
- Include "libiberty.h" instead.
-
-Wed Aug 10 13:23:47 1994 Rick Sladkey (jrs@world.std.com)
-
- * i386v-nat.c (i386_insert_nonaligned_watchpoint):
- add additional argument specifying raw address to permit
- proper release of debug registers.
- (i386_insert_watchpoint, i386_insert_aligned_watchpoint):
- change all callers.
-
-Wed Aug 10 16:13:45 1994 Stu Grossman (grossman@cygnus.com)
-
- * defs.h, top.c: Use `extern' in declarations of GUI hooks, and
- define them in top.c. Add comments to the hooks.
-
-Wed Aug 10 15:57:43 1994 Doug Evans (dje@canuck.cygnus.com)
-
- * remote-sim.c (gdbsim_ops): Set `to_insert_breakpoint' and
- `to_remove_breakpoint' fields.
-
-Wed Aug 10 15:46:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infcmd.c (run_command): Remove comment suggesting using
- target_has_execution instead of inferior_pid.
-
-Wed Aug 10 10:33:20 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * remote-mips.c (mips_open): add code to handle baud rate.
-
-Tue Aug 9 09:44:42 1994 Stu Grossman (grossman@cygnus.com)
-
- * infrun.c (wait_for_inferior): Call target_resume() upon
- detection of new processes.
-
- * procfs.c (create_procinfo): Return pointer to new procinfo
- structure.
- * (do_detach): Spacing & formatting cleanup.
- * (procfs_wait): Move wait_again label to ensure that we really
- wait again. On exit from fork, release new child from gdbs'
- clutches.
- * (procfs_set_sproc_trap): Enable trapping of fork and vfork.
-
-Mon Aug 08 15:34:13 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (hpread_process_one_debug_symbol): Fix block scoping
- problem (losing localvars on the close-brace instead of after
- the close brace).
-
-Mon Aug 8 15:09:32 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * i386-nlmstub.c (handle_exception): Wait until the thread has
- been started before killing the NLM by pointing the PC at
- _exit().
-
-Sat Aug 6 22:27:30 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/mips/tm-irix5.h (IN_SIGTRAMP): Redefine for Irix 5,
- Irix 5 has a standard _sigtramp signal handler.
- * irix5-nat.c (solib_add): Get rid of sigtramp_address handling,
- it is not needed for a standard _sigtramp signal handler.
- Add shared library sections to the section table of the target
- before adding the symbols.
- * mips-tdep.c (mips_skip_prologue): Do not skip load immediate
- instructions that do not prepare a stack adjustment.
- * regex.c (SIGN_EXTEND_CHAR): Update to emacs-19.25 definition,
- which does the right thing on machines where `char' is unsigned.
-
-Fri Aug 5 17:50:59 1994 Stu Grossman (grossman@cygnus.com)
-
- * remote.c (remote_open): Move setting of inferior_pid prior to
- call to remote_start_remote. Also use unique value for pid to
- avoid confusion with read_register_pid & friends.
- * (remote_wait): Return inferior_pid instead of 0 in all cases.
-
-Fri Aug 5 12:23:02 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * dwarfread.c (bfd.h): Don't include.
-
-Fri Aug 5 09:08:34 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * i386-nlmstub.c (handle_exception): Point the PC at _exit() to
- kill the program being debugged. KillMe(), the undocumented
- call intended for this purpose, causes the server to hang.
-
-Thu Aug 4 16:26:06 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * remote.c (read_frame): Calculate run length encoded checksum
- correctly.
- * config/sh/stub.c: New file.
-
-Thu Aug 4 14:34:12 1994 Stu Grossman (grossman@cygnus.com)
-
- * target.c (find_default_run_target): Make sure to_can_run is set
- before calling it.
-
-Thu Aug 4 11:46:27 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * TODO: Remove note about fast watchpoints and remove obsolete
- Mach stuff.
-
-Thu Aug 4 11:08:03 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config/i386/xm-i386v4.h, config/m68k/xm-m68kv4.h,
- config/sparc/xm-sun4sol2.h (NORETURN): Don't define.
- * config/m88k/tm-cxux.h (ARCH_NUM_REGS): Undefine before defining.
-
-Thu Aug 4 10:26:36 1994 Stu Grossman (grossman@rtl.cygnus.com)
-
- * target.c (add_target): Don't call clean_target on target
- vectors anymore.
- * (unpush_target): Test for to_close being set before calling.
- * (target_xfer_memory, target_info): Check for to_has_memory
- before playing with memory.
-
- * remote.c (remote_open): Set inferior_pid to make kill command
- happy.
- * inflow.c (kill_command): Revert change of Aug 2. Use
- inferior_pid to determine whether to print out "The program is not
- being run." message.
-
-Thu Aug 4 07:55:04 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/i386/i386m3.mh (NAT_CLIBS): Add -lmachid and -lnetname.
- * m3-nat.c, config/nm-m3.h: #if 0 REQUEST_QUIT stuff.
- * m3-nat.c: Pass argument to return_to_top_level.
- Declare m3_kill_inferior before use.
- (port_chain_insert): In "can't happen" case, abort rather than
- setting `mid' to large decimal constant (which gcc warns about).
- (get_thread_name): Use cast to convert const char * to char *.
- (add_mach_specific_commands): #if 0 "thread break" command.
- (m3_trace_him): Call push_target.
- (mach_really_wait): New argument pid; remove unused
- variable pid.
- (intercept_exec_calls): Call target_terminal_init and
- target_terminal_inferior once the child execs.
- * infrun.c (proceed): Pass argument to PREPARE_TO_PROCEED.
-
-Wed Aug 3 22:41:13 1994 Tom Lord (lord@x1.cygnus.com)
-
- * procfs.c (procfs_mourn_inferior): don't dereference the
- procinfo pointer after it has been freed.
-
-Wed Aug 3 12:05:13 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * breakpoint.c (breakpoint_1): Improve pluralization in display
- of breakpoint hit counts.
-
- * language.h (struct language_defn): Remove unused field
- la_longest_float.
- (longest_float): Remove, no longer used.
- * language.c (unknown_language_defn, auto_language_defn,
- local_language_defn): Remove init of la_longest_float field.
- * c-lang.c (c_language_defn, cplus_language_defn,
- asm_language_defn): Ditto.
- * ch-lang.c (chill_language_defn): Ditto.
- * m2-lang.c (m2_language_defn): Ditto.
-
-Tue Aug 2 10:58:34 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * defs.h (bfd_read, bfd_seek): Remove declarations.
- * os9kread.c, rs6000-nat.c (libbfd.h): Don't include.
-
-Tue Aug 2 09:50:50 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * inflow.c (kill_command): Fix a bug which prevented target
- programs to be killed.
-
-Mon Aug 1 18:48:47 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * defs.h: Change two-line declarations to one-line form.
- (NORETURN): Define as "volatile" only for older GCCs.
- (ATTR_NORETURN): Define for newer GCCs.
- * procfs.c (proc_init_failed): Add ATTR_NORETURN to declaration.
-
-Mon Aug 1 16:43:24 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (mention), main.c (fputs_unfiltered): Add comments.
- * breakpoint.c (delete_breakpoint, enable_breakpoint,
- disable_breakpoint): Don't call breakpoints_changed; it is now
- called via the *_breakpoint_hook functions.
- * annotate.c (_initialize_annotate, breakpoint_changed): New functions.
-
-Mon Aug 1 13:38:04 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * stabsread.c (read_type): Fix a bug in enum size calculation.
-
-Mon Aug 1 01:36:13 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (compare_unwind_entries): Add "const" to both
- argument types to shut up GCC.
-
- * hppa-tdep.c (saved_pc_after_call): If the saved PC is in a
- linker stub, then return the address the stub will return to.
- (frame_saved_pc): Correctly restart the search for the saved
- pc when a linker stub is encountered.
-
- * hppa-tdep.c (inst_saves_gr): Handle 16 and 8 bit instruction
- register stores emitted by the version 9 HP compilers.
- (inst_saves_fr): Relax test for a specific base register (%r1);
- this avoids losing with the version 9 HP compilers.
- (skip_prologue): Try to skip argument stores emitted by the HP
- compilers. It's not perfect, but it's better than before.
-
-Fri Jul 29 23:20:30 1994 Stu Grossman (grossman@cygnus.com)
-
- * findvar.c (write_pc write_pc_pid): Remove casts to long when
- calling write_register_pid.
- * (write_register_pid): Add prototype.
-
-Fri Jul 29 21:56:23 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * remote.c (read_frame): Split readchar/checksum calculation into
- two parts since evaluation order is undefined.
-
-Fri Jul 29 13:46:08 1994 Fred Fish (fnf@cygnus.com)
-
- From Kevin A. Buettner (kev@cujo.geg.mot.com).
- * Makefile.in (coredep.o): Add inferior.h as dependency.
- * inflow.c: Add F_SETOWN to list of defines to check
- around code that uses F_SETOWN.
-
-Fri Jul 29 09:59:05 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * Makefile.in (CC_FOR_TARGET, CXX_FOR_TARGET): If using newlib,
- set the -L and -B directory prefixes so we can link with it.
-
-Thu Jul 28 14:37:36 1994 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in (INSTALLED_LIBS, CLIBS, DEPFILES): Add support for
- --enable-xxx configure option by adding ENABLE_{CLIBS DEPFILES}
- where appropriate.
-
- * General hackery to support alternate user-interface.
- * breakpoint.c (mention, delete_breakpoint, enable_breakpoint,
- disable_breakpoint): Call hooks for alternate user-interface.
- * defs.h: Add declarations for alternate user-interface hooks.
- * main.c (main): Add --nw (and --nowindows) options to disable
- the GUI.
- * (near call to command_loop): Call command_loop_hook if set.
- * (fputs_unfiltered): Call fputs_unfiltered_hook if set.
- * stack.c: Call print_frame_info_listing_hook if set.
- * top.c (gdb_init): Initialize targets.c and utils.c prior to
- other files to make sure that calls to error and warning will
- work. Call init_ui_hook after everything else.
- * utils.c (query): Call query_hook if set.
- * (gdb_flush): Call flush_hook if set.
- * Change _initialize_utils to initialize_utils cuz we don't use
- automatic initialization of utils.c anymore.
-
-
- * remote.c: Get rid of #ifdef DONT_USE_REMOTE. It's no longer
- necessary.
-
-Thu Jul 28 14:52:01 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * Makefile.in (CC_FOR_TARGET, CXX_FOR_TARGET): Use newlib if it is
- there and we are using the gcc from the tree.
- (LD_FOR_TARGET): Look for ld in ../ld/ld.new.
-
-Thu Jul 28 10:43:36 1994 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (annotate.o): Add dependencies.
-
-Wed Jul 27 14:34:42 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * sparclite/aload.c: Added new -q (quiet) option.
- return 0 exit status if file was successfully downloaded.
-
- * nlm/gdbserve.c: merge in command line argument parsing changes
- and bug fixes made to i386-nlmstub.c.
-
- * i386-nlmstub.c: The returnLength field must be initialized
- before portConfig is passed to AIOGetPortConfiguration.
- Compare command line arguments with strnicmp(); args are
- case insensitive on netware.
-
-Wed Jul 27 09:24:19 1994 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (DISTSTUFF): Add definition.
- (diststuff): Add for new distribution support.
- (gdb.tar.Z, make-proto-gdb.dir, setup-to-dist,
- gdb-$(VERSION).tar.Z, make-proto-gdb-1, make-proto-testsuite.dir):
- Remove old distribution building rules, now uses standard
- distribution support in parent directory Makefile.in.
-
-Tue Jul 26 14:15:53 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * target.c (push_target): Cast result from xmalloc.
-
-Tue Jul 26 18:20:46 1994 Paul Flinders (ptf@smee)
-
- * elfread.c (elf_symtab_read): Discard compiler labels generated
- by the Solaris 2.1/Intel SunPro compiler.
-
-Mon Jul 25 18:19:24 1994 Stu Grossman (grossman@cygnus.com)
-
- * target.c (nomemory): Fix prototype and routine to take correct
- args.
-
-Mon Jul 25 15:38:23 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (clean): Remove libgdb-files.
-
-Mon Jul 25 11:50:57 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * coredep.c: Include inferior.h.
-
-Mon Jul 25 11:36:02 1994 J.T. Conklin (jtc@phishhead.cygnus.com)
-
- * i386-nlmstub.c: Add support for NODE, PORT and BAUD command
- line arguments.
-
-Sat Jul 23 14:36:09 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * symfile.c (deduce_language_from_filename): Recognize .S as asm,
- .cp as C++, alphabetize better.
-
- * breakpoint.c (ignore, condition): Move usage note into body of
- help text, so first line can be one-line summary.
-
-Sat Jul 23 00:58:15 1994 Stu Grossman (grossman@cygnus.com)
-
- * target.c (unpush_target): Fix handling of removal of top target.
-
-Fri Jul 22 17:30:39 1994 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in: Add stuff to build nlmstub.
- * Add rule for annotate.o to keep Sun make happy.
- * configure.in: Add config for powerpc/Netware.
-
- * partial-stab.h (near N_SO): Don't call START_PSYMTAB with null
- filename. This speeds up handling of trailing N_SO stabs (they
- mark the end of a .o file).
-
- * target.c, target.h: Change the way pushing and popping of
- targets work to support target overlays and inheritance.
- * corelow.c, hppa-tdep.c, inflow.c, remote-nindy.c, utils.c:
- Fixup references to current_target, due to previous changes.
-
- * config/i386/tm-i386nw.h: Enable longjmp support. More work is
- needed to get the address of longjmp out of the target.
-
-Tue Jul 19 13:25:06 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * main.c: Include <ctype.h>.
-
-Mon Jul 18 15:32:17 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * remote-mips.c (mips_readchar): Fix a bug in checking <IDT>
- prompt.
-
-Mon Jul 18 14:26:35 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * solib.c (look_for_base): Don't deref exec_bfd if NULL.
-
-Sun Jul 17 15:38:36 1994 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.12.4.
-
-Sun Jul 17 12:20:35 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Harris CX/UX support, from Bob Rusk (rrusk@mail.csd.harris.com).
- * configure.in (m88*-harris-cxux*): New configuration.
- * cxux-nat.c, config/m88k/cxux.mh, config/m88k/cxux.mt,
- config/m88k/xm-cxux.h, config/m88k/tm-cxux.h, config/m88k/nm-cxux.h:
- New files.
- * config/m88k/tm-m88k.h: Add comment about Harris OS.
- (TARGET_WRITE_PC): Pass pid through to register writers.
-
- * configure.in (m68*): Put vendor-only-specified host configs
- after vendor-and-os-specified configs.
- (m68*-atari-sysv4*, m68*-cbm-sysv4*): Replace with m68*-*-sysv4.
-
- * config/m88k/delta88.mh (MUNCH_DEFINE): Remove.
- * config/m88k/delta88.mt, config/m88k/delta88v4.mh: Format
- consistently.
-
-Sat Jul 16 23:39:17 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * elfread.c (elf_symtab_read): Handle error return from
- bfd_get_dynamic_symtab_upper_bound gracefully.
-
-Sat Jul 16 14:43:17 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * inferior.h (ARCH_NUM_REGS): New macro, actual number of
- registers in use by the inferior.
- * coredep.c (fetch_core_registers, register_addr): Use it.
- * findvar.c (registers_changed, registers_fetched,
- read_register_bytes): Ditto.
- * infcmd.c (do_registers_info, registers_info): Ditto.
- * infptrace.c (fetch_inferior_registers,
- store_inferior_registers): Ditto.
- * stack.c (frame_info): Ditto.
-
- * coredep.c (CORE_REGISTER_ADDR): New macro.
- (fetch_core_registers): Use it.
-
- * breakpoint.c (ignore, condition): Add usage notes to help strings.
- * symfile.c (add-symbol-file): Add usage note to help string.
- (add_shared_symbol_files_command): New command.
-
- gcc -Wall lint.
- * inferior.h (read_pc_pid): Declare.
- * breakpoint.c (watchpoint_check): Cache breakpoint in local
- variable b, remove unused variable other_type_used.
- * main.c (inferior.h, call-cmds.h): Include.
- (gdb_init): Declare.
- * remote.c (remote_wait): Return 0 by default.
-
-Fri Jul 15 16:43:33 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Stop printing at null char option, from Oliver Meyer
- (omeyer@i3.informatik.rwth-aachen.de).
- * valprint.h, valprint.c (stop_print_at_null): New global.
- * valprint.c (_initialize_valprint): New print set subcommand
- "null-stop".
- * c-valprint.c (c_val_print): If stop_print_at_null is on, and
- printing a char array, adjust the number of chars to print.
-
-Fri Jul 15 14:33:40 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- From Kevin A. Buettner (kev@cujo.geg.mot.com).
- * m88k-tdep.c (examine_prologue): Modified to handle prologues for
- pic code in addition to prologues where an instruction from the
- prologue gets moved into the delay slot of a branch instruction
- immediately following the prologue. A table of potential prologue
- instructions (prologue_insn_tbl) is now used for picking apart a
- function prologue.
- (frame_find_saved_regs): Changed the way in which limit gets set
- so that the delay slot of branch instructions immediately
- following the prologue gets examined.
- (pushed_size, store_parm_word, store_parm, push_parameters,
- collect_returned_value): Deleted.
-
-Fri Jul 15 01:06:00 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * infrun.c (wait_for_inferior): Handle stepping into leaf
- functions whose prologue consists of gp loading code only.
-
-Thu Jul 14 14:22:12 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * dbxread.c: Don't include libbfd.h.
- * dwarfread.c, elfread.c somread.c: Don't include libbfd.h,
- <time.h>, or <sys/types.h>.
- * elfread.c (elf_symfile_read): Use only standard BFD functions to
- collect information about the stab and stab string sections.
-
-Thu Jul 14 13:17:39 1994 Kung Hsu (kung@x1.cygnus.com)
-
- * stabsread.c (read_huge_number): handle large unsigned number
- for stabs generated by os9k C compiler.
-
-Wed Jul 13 18:58:15 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Breakpoint hit counts, from Bob Rusk (rrusk@mail.csd.harris.com).
- * breakpoint.h (hit_count): New breakpoint field.
- * breakpoint.c (show_breakpoint_hit_counts): New variable.
- (clear_breakpoint_hit_counts): New function.
- (bpstat_stop_status): Increment the hit count.
- (breakpoint_1): Display the hit count.
- * infcmd.c (run_command): Reset breakpoint hit counts.
- * target.c (generic_mourn_inferior): Don't clear ignore counts if
- displaying hit counts.
-
-Tue Jul 12 12:23:15 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * elfread.c (elf_symfile_read): Unconditionally add dynamic
- symbols for all symbol files. Makes skipping over the
- trampoline code work when stepping from a function in a shared
- library into a function in a different shared library for Irix 5.
- Other ELF targets do not have enough information in their
- dynamic symbol tables to make this work.
- (elf_symtab_read): Relocate mst_solib_trampoline address.
-
-Mon Jul 11 16:38:49 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Atari support, from Uwe Seimet (seimet@chemie.uni-kl.de).
- * configure.in (m68*-atari-sysv4*): New configuration.
- (m68*-cbm-sysv4*): Use m68kv4 instead of amix.
- * m68k-tdep.c (R_PS): Define as R_SR if necessary.
- * config/m68k/m68kv4.mh, config/m68k/m68kv4.mt,
- config/m68k/tm-m68kv4.h, config/m68k/xm-m68kv4.h: New files.
- * config/m68k/amix.mh, config/m68k/amix.mt,
- config/m68k/tm-amix.h, config/m68k/xm-amix.h: Removed, superseded
- by m68kv4 files.
-
-Sat Jul 9 16:28:43 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symtab.c (find_function_start_sal): New function to find
- the start of a function from a function symbol.
- (decode_line_1, decode_line_2): Use it instead of open coded
- partial copies of the code.
- (list_symbols): Quote symbol name before passing it to
- break_command to enable proper handling of mangled symbols.
-
-Wed Jul 6 20:22:07 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * ch-exp.y (match_simple_name_string): Don't lower-case here.
- * ch-exp.y (yylex): First try name lookup using exact name
- typed by user; if that fails, try lower-cased name.
-
-Wed Jul 06 12:39:07 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: More cleanups. Delete lots of trailing whitespace.
- Remove some items from the TODO list and notes throughout code
- for things which need fixing. Add more comments.
- Document bogus struct symloc sharing with dbxread.c. Delete more
- useless variables. Add more PARAM prototypes. Fixup more
- indention problems that have crept in.
- (SET_NAMESTRING): Accept new namep and objfile arguments so that
- it doesn't depend on the variable names on the procedures it's
- used from.
- (hpread_symfile_init): Delete incorrect checks for bogus sizes of
- the debug sections.
-
-Wed Jul 6 00:48:57 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * dbxread.c, elfread.c, mipsread.c, nlmread.c, os9kread.c:
- Move "no debugging symbols found" test to symfile.c.
- * symfile.c (syms_from_objfile, reread_symbols): Add
- "no debugging symbols found" test.
- * coffread.c (init_stringtab): Handle stripped files with a
- stringtab offset of zero gracefully.
- * osfsolib.c (solib_create_inferior_hook): Use DYNAMIC flag from
- BFD instead of stop_pc heuristic to determine if it is a dynamically
- linked object file.
- * procfs.c (wait_fd): Handle ENOENT error return from PIOCWSTOP
- ioctl, it indicates that the process has exited.
-
-Mon Jul 04 19:48:03 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (hpread_symfile_init): Make sure to initialize all the
- private data to zero. Not having any HP C debug symbols is not an
- error. Just return.
-
-Mon Jul 4 19:28:56 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (read_unwind_info): ELF unwind information is in the
- .PARISC.unwind section now.
-
-Mon Jul 4 17:06:26 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * breakpoint.c (mention): Always show breakpoint address if no
- source file.
-
-Sat Jul 2 01:51:33 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * solib.c (bfd_lookup_symbol, look_for_base): Reinstate to reenable
- handling of shared libraries for non-ELF executables, but only if
- HANDLE_SVR4_EXEC_EMULATORS is defined.
- (locate_base): Try to find debug_base in the dynamic linker
- for non-ELF executables if HANDLE_SVR4_EXEC_EMULATORS is defined.
- * config/sparc/tm-sun4sol2.h (HANDLE_SVR4_EXEC_EMULATORS):
- Define to enable handling of shared libraries for a.out executables,
- run under Solaris BCP.
-
-Fri Jul 01 19:50:21 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c: Change contribution notice to the Cygnus/Utah agreed
- upon notice. Delete some stuff from the TODO list. Rework
- many comments to be clearer. Major cleanups. Consistently
- use "hpread_" prefix. Delete unnecessary macros, structures
- variables, fiels, functions and #if 0 code. Mark code which
- still needs to be cleaned up. PARAMize and make most functions
- static. Fix error checking when reading in the debug section
- contents. No more minimal symbol table handling in this code!
-
-Thu Jun 30 13:59:23 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (wait_for_inferior): Print "Program exited normally"
- regardless of batch_mode.
- * defs.h, top.c (batch_mode): Removed.
-
-Wed Jun 29 18:53:36 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * Makefile.in (dcache_h): Remove redundant definition.
- (init.c): Add a comment.
- (top.c): Remove explicit compile action.
- * breakpoint.c (mention): Share code indicating location of
- break/watchpoints, don't print address if addressprint is off.
- * breakpoint.c, c-typeprint.c, c-valprint.c, energize.c, symtab.h
- (demangle): Remove redundant declarations.
- * eval.c: Remove redundant function declarations.
- * objfiles.h: Cosmetic and grammatical improvements.
- * TODO: Various updates.
-
- * remote-mips.c: Replace all \r chars with \015.
- (mips_receive_header): Display control characters readably.
- (mips_xfer_memory): Add a simple progress display.
-
-Wed Jun 29 13:11:45 1994 Steve Chamberlain (sac@cirdan.cygnus.com)
-
- * remote-e7000.c (e7000_open): Don't try a tcp open if we're
- using go32.
- * remote-hms.c (flush): New function.
- (expect): Get edge case right.
- (hms_read_inferior_memory): Be more tolerant of line noise.
-
-Tue Jun 28 14:17:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * configure.in: Use i386m3.mh and i386m3.mt as names of host and
- target files, not non-existent mach3.mh and mach3.mt.
-
-Wed Jun 29 00:26:17 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * dbxread.c (dbx_symfile_read): Unconditionally add dynamic
- symbols for all symbol files. Makes skipping over the
- trampoline code work when stepping from a function in a shared
- library into a function in a different shared library.
- (read_dbx_dynamic_symtab): Relocate mst_solib_trampoline address.
-
-Tue Jun 28 15:28:01 1994 Stu Grossman (grossman@cygnus.com)
-
- * dbxread.c, partial-stab.h (near N_SO): SO stabs with blank
- names mean end of .o file.
- * infrun.c (wait_for_inferior): Clean up multi-thread logic near
- top of routine. Handle new thread notification cleanly.
- * lynx-nat.c (child_wait): General cleanups, handle new LynxOS
- thread notification scheme.
- * (child_resume): General cleanups, handle resumption of all
- threads properly.
-
-Mon Jun 27 09:57:23 1994 Steve Chamberlain (sac@cirdan.cygnus.com)
-
- * ser-go32.c: Rewrite to run under windows.
- * ser-e7kpc.c: New file to support the E7000 with the PC ISA
- bus interface.
- * serial.c (serial_open): Notice device "pc".
- * remote-e7000.c: Fix copyright date.
- (expect): Compare \n and \r the same.
- (e7000_open): Allow pc as a serial port
- * sh/sh.mt: Add ser-e7kpc.
- * h8300/h8300hms.mt: Add ser-e7kpc.
- * main.c (proc_wait): Don't wait if using go32.
-
-Mon Jun 27 00:35:51 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * somread.c: Simplify by using stabsect_build_psymtabs.
- * dbxread.c (stabsect_build_psymtabs): New argument "text_name"
- corresponding to the name of the text section. All references
- changed.
- (somstab_build_psymtabs): Delete function, no longer needed.
-
-Sun Jun 26 23:54:08 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * somread.c: Renamed from paread.c. Changed function names and
- comments to reflect that this file deals with SOM (an object file
- format), rather than the PA (a cpu).
- (Makefile.in): Chaned appropriately.
- (config/pa/hppabsd.mh, config/pa/hppahpux.mh): Likewise.
- * dbxread.c (somstab_build_psymtabs): Renamed from
- pastab_build_psymtabs.
-
-Fri Jun 24 08:15:42 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * core-sol2.c: New file to handle ELF and BCP core file flavours.
- * config/sparc/sun4sol2.mh (NATDEPFILES): Use it instead of
- core-svr4.
- * Makefile.in: Updated for core-sol2.c.
- * README: Add notes about SPARCworks cc under Solaris 2.x,
- from Casper H.S. Dik (casper@fwi.uva.nl).
- * config/mips/xm-makeva.h: Removed, no longer necessary.
- * Makefile.in, config/mips/xm-irix3.h, config/mips/xm-irix5.h,
- config/mips/xm-mips.h, config/mips/xm-news-mips.h,
- config/mips/xm-riscos.h: Remove references to xm-makeva.h
-
-Wed Jun 22 17:48:21 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdba.el: Put program input and output in a separate buffer.
-
-Wed Jun 22 16:54:15 1994 Fred Fish (fnf@cygnus.com)
-
- * energize-patches, main.c (main), top.c (gdb_init, pwd_command),
- top.h: Change all occurances of dirbuf to gdb_dirbuf. Collides
- with global variable of same name in libnsl.so on UnixWare.
-
-Wed Jun 22 14:40:52 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * symtab.c (decode_line_1): fix a bug in dealing with '<>'
- embedded in template name.
-
-Tue Jun 21 14:06:46 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * config/i386/nm-linux.h: change calling convention of
- TARGET_CAN_USE_HARDWARE_WATCHPOINT() and
- target_insert_watchpoint() and
- target_remove_watchpoint().
-
- * config/mips/tm-mips64.h: define FORCE_LONG_LONG to force LONGEST
- to be long long in gdb.
- * config/mips/tm-bigmips.h: ditto.
-
-Mon Jun 20 23:54:37 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * c-lang.c (asm_language_defn): New definitions for language_asm,
- mostly copied from c_language_defn, to avoid warnings when
- switching between c and asm stack frames.
-
-Mon Jun 20 13:51:55 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
-
- * mdebugread.c (parse_symbol): Don't call ecoff_swap_tir_in or
- ecoff_swap_rndx_in directly; use the debug_swap pointer instead.
- (upgrade_type, handle_psymbol_enumerators): Likewise.
- (has_opaque_xref, cross_ref): Likewise.
- (elfmdebug_build_psymtabs): Call swap->read_debug_info to read
- debugging information, rather than doing it here.
- * mipsread.c (mipscoff_symfile_read): Call read_debug_info entry
- point in ecoff_debug_swap backend structure, rather than calling
- ecoff_slurp_symbolic_info directly.
-
-Fri Jun 17 20:58:58 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c: Include annotate.h. Call annotate_field rather
- than printing annotation directly.
-
- * main.c: Include string.h.
-
-Thu Jun 16 14:41:37 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * fork-child.c (startup_inferior) [STARTUP_INFERIOR]: If defined,
- call it instead of doing normal loop.
- * infcmd.c (attach_command): Don't call wait_for_inferior if
- running Mach 3.
- * infrun.c (proceed) [PREPARE_TO_PROCEED]: If defined, call
- hook that can decide whether to step over the next breakpoint.
- * utils.c (wrap_here): Abort if wrap_buffer not allocated.
- (request_quit) [REQUEST_QUIT]: If defined, call it instead of
- doing normal quit.
-
- * configure.in: Improve sorting/formatting of hosts and targets.
- (i[34]86-*-mach3*, i[34]86-*-osf1mk*, mips-*-mach3*,
- m88*-*-mach3*, ns32k-*-mach3*): Recognize.
- * Makefile.in (stop-gdb): New target.
- * stop-gdb.c: New file, utility to get attention of waiting GDBs
- in Mach 3.
-
-Wed Jun 15 00:41:03 1994 Tom Lord (lord@rtl.cygnus.com)
-
- * top.c (gdb_init): Init current_directory in gdb_init. Probably
- the identical initialization can be deleted from main.c, but i
- haven't done so just in case.
-
-Tue Jun 14 17:24:41 1994 Tom Lord (lord@x1.cygnus.com)
-
- * gdba.el: Added menu windows and slightly improved window
- handling to gdba.el. Fixed numerous minor bugs that were causing
- emacs and gdb to fall out of sync.
-
-Tue Jun 14 16:18:44 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * breakpoint.c: annotate changes lost at merge, put back in.
-
-Mon Jun 13 17:28:50 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * config/i386/i386sco.mh, i386sco4.mh (XDEPFILES): Remove
- i387-tdep.o.
-
-Sun Jun 12 03:51:52 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/m68k/dpx2.mh (NATDEPFILES): Remove duplicate inclusion
- of inftarg.o.
- * config/m68k/tm-dpx2.h (CANNOT_STORE_REGISTER): Define to inhibit
- writing of floating registers, the dpx2 kernel disallows it.
- * irix5-nat.c (LM_ADDR): The loaded address of the shared library
- is contained in o_praw.
- * irix5-nat.c (solib_map_sections): Adjust sections by the
- difference between the loaded address and the prelinked address.
- * irix5-nat.c (solib_address): Use LM_ADDR for the loaded start
- address.
- * mdebugread.c (parse_symbol): Do not relocate stEnd/scText
- symbols, their value is absolute.
- * mdebugread.c (parse_partial_symbols): Handle Irix 5.2 shared
- libraries fh->adr fields of zero. Relocate minimal symbol values
- upon readin. Relocate non-stabs symbols upon readin.
- * mdebugread.c (psymtab_to_symtab_1): Use pst->textlow for the
- start address of the outermost block.
- * mdebugread.c (parse_lines, parse_procedure): Pass in pst
- instead of section_offsets and use relocated pst->textlow for
- line number and procedure address relocations.
-
- From gmo@MicroUnity.com (Guillermo A. Loyola):
- * mdebugread.c (parse_symbol, parse_partial_symbols, cross_ref):
- Handle SGI Irix5 stIndirect symbol type.
-
-Fri Jun 10 14:52:56 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * breakpoint.c: fix a syntax error native cc does not like.
-
- * Makefile.in: change sparclite-tdep.c to sparcl-tdep.c.
- * sparclite/Makefile.in: ditto.
- * sparcl-tdpe.c: change file name because first 8 chars has to be
- unique.
- * sparcl-stub.c: ditto.
-
- * sparclite/Makefile.in: fix INCLUDE_CFLAGS to have {srcdir}/../config.
-
-Fri Jun 10 10:38:15 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (target_read_pc, target_write_pc): Accept (and
- ignore) a PID argument.
- (hppa_pop_frame): Pass a PID to target_write_pc.
- * config/pa/tm-hppa.h (TARGET_READ_PC, TARGET_WRITE_PC): Accept
- and pass through a PID argument.
- (target_read_pc, target_write_pc): Update prototypes.
-
-Thu Jun 9 18:10:44 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * Makefile.in: add new file sparclite-tdep.c.
- * sparclite/Makefile.in: add new file sparclite-stub.c.
- * sparclite/hw_breakpoint.note: note for SPARClite hardware breapoint
- support.
- * config/sparc/sparclite.mt: add sparclite-tdep.o.
- * config/sparc/tm-sparclite.h: add hardware breakpoints support
- defiines and code.
- * sparclite-tdep.c: new file, contains hardware breakpoint support
- code.
- * sparclite-stub.c: new file, stub code that add support hardware
- breakpoint support.
- * breakpoint.c: add hardware breakpoint support.
- * breakpoint.h: add new breakpoint type to support hardware
- breakpoint.
- * config/mips/nm-irix4.h: change interface for target dependent
- code supporting watch point.
- * config/pa/nm-hppab.h: change interface for target dependent
- code supporting watch point.
-
-Thu Jun 9 14:59:58 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * remote-os9k.c (rombuf_command): fix a bug accepting rombug
- output.
- * stabsread.c (read_struct_fields): os9k nested structure does not
- have terminating ';', instead it just get to ',' and bit position
- and length.
-
-Wed Jun 8 23:20:45 1994 Stu Grossman (grossman@cygnus.com)
-
- * nlmread.c (nlm_symtab_read): Clean up a bit.
- * (nlm_symfile_read): Record bounds of main() so that backtrace
- command will know where to stop.
- * objfiles.c (objfile_relocate): Relocate entry point/func info
- for backtrace as well.
- * objfiles.h: Define values for invalid PCs for entry point info.
- * symfile.c (init_entry_point_info): Initialize invalid values
- with aforementioned macros.
- * config/alpha/tm-alphanw.h: Turn on FRAME_CHAIN_VALID_ALTERNATE
- to cause backtrace to stop when it gets back to main().
- * config/i386/tm-i386nw.h: Ditto.
-
-Sat Jun 4 18:17:03 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- Fix value_print, which used to be ostensibly language-independent,
- but would print pointers and arrays in C syntax. Instead, call
- a language-specific function.
- * language.h (struct language_defn): New functional field
- la_value_print.
- (LA_VALUE_PRINT): New macro.
- * language.c (unk_lang_value_print): New stub/dummy function.
- (unknown_language_defn, auto_language_defn, local_language_defn):
- Use it.
- * c-valprint.c (c_value_print): New function, with code moved from:
- * valprint.c (value_print): ... here. Now just invoke
- LA_VALUE_PRINT to do language-specific stuff.
- * valprint.c (value_print_array_elements): Make non-static.
- * c-lang.c (c_language_defn, cplus_language_defn): Add
- c_value_print in the la_value_print field.
- * m2-lang.c (m2_language_defn): Likewise.
- * ch-lang.c (chill_language_defn): But here use chill_value_print.
- * ch-valprint.c (chill_val_print): Print null pointer as NULL.
- * ch-valprint.c (chill_value_print): New function, based on
- c_value_print, but use Chill "look and feel."
- * c-lang.h (c_value_print): New prototype.
- * ch-lang.h (chill_value_print): New prototype.
- * value.h (value_print_array_elements): New prototype.
-
- * ch-valprint.c (chill_val_print, case TYPE_CODE_BITSTRING
- and case TYPE_CODE_SET): Check that the element type isn't a stub.
-
-Fri Jun 3 09:15:00 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c: Move entire file except for #ifndef MAIN_OVERRIDE code
- to new file top.c. Make things extern instead of static and
- similar rearrangements to deal with this.
- * top.h: New file.
- * utils.c: Move fputs_unfiltered to main.c. Remove
- FPUTS_UNFILTERED_OVERRIDE ifndef.
- * Makefile.in: Change so that gdb uses main.c, utils.c, and top.c,
- and libgdb uses utils.c and top.c.
-
-Thu Jun 2 23:19:10 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (skip_trampoline_code): Fix typo.
-
-Thu Jun 2 18:09:59 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * ch-valprint.c (chill_val_print_array_elements): New function.
- A Chill version of val_print_array_elements, it prints the
- array index labels, in additions ot the array element values.
- (chill_val_print): Use the new function.
-
-Thu Jun 2 08:50:00 1994 Stu Grossman (grossman@cygnus.com)
-
- * configure.in: Add nlm subdir to configdirs for alpha-*-netware
- target.
- * defs.h (enum language): Add language_asm.
- * findvar.c (read_register_bytes read_register_gen
- write_register_bytes read_register read_register_pid
- write_register write_register_pid supply_register): Move multi-
- thread handling down into these routines. Create XXX_pid routines
- that allow register references to specify the pid.
- * findvar.c infcmd.c (read_pc read_pc_pid write_pc write_pc_pid
- read_sp write_sp read_fp write_fp): Move these routines from
- infcmd to findvar to centralize the whole mess.
- * i386-nlmstub.c: Portability fixes.
- * infptrace.c (child_resume): Conditionalize to allow other natives
- to override it. Remove PIDGET gubbish, it's no longer necessary.
- * infrun.c (wait_for_inferior): Put registers_changed() before
- target_wait() to speed up remote debugging.
- * Replace code that reads registers from other threads with much
- nicer looking new function calls (see changes to findvar.c).
- * Don't skip prologues if debugging assembly source.
- * lynx-nat.c (child_resume): Lynx now needs it's own version of
- child_resume to handle multi-thread debugging properly.
- * remote.c: Add O response to get console output from target.
- * (readchar): Add timeout parameter. Handle SERIAL_EOF and
- SERIAL_ERROR here to simplify callers.
- * Change static var timeout to remote_timeout.
- * (fromhex): Remove unnecessary return -1 at end of routine.
- * (remote_wait): Turn this into a big switch statement. Add
- support for O response.
- * (putpkt): Remove unnecessary handling of SERIAL_EOF/ERROR.
- * (getpkt): Split getpkt into two parts. read_frame deals with
- all formatting issues, run-length encoding, and framing. getpkt
- now handles error recovery, and frame detection.
- * ser-tcp.c (tcp_readchar): Handle EINTR from read().
- * ser-unix.c (hardwire_raw): Set CLOCAL so that we ignore modem
- control. (hardwire_readchar): Handle EINTR from read().
- * symfile.c (deduce_language_from_filename): Add support for .s
- files.
- * config/nm-lynx.h: Define CHILD_WAIT so that lynx-nat.c can
- override infptrace's child_wait.
- * config/rs6000/rs6000lynx.mh: Use xm-rs6000ly.h & nm-rs6000ly.h
- instead of XXXlynx.h.
- * config/rs6000/rs6000lynx.mt: Use tm-rs6000ly.h instead of
- tm-rs6000lynx.h.
- * nlm/gdbserve.c: Portability fixes.
-
-Tue May 31 20:35:44 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * inftarg.c (child_wait): Call proc_wait, not wait.
- (child_mourn_inferior): Call proc_remove_foreign.
- * main.c (gdb_init): Call init_proc.
- * main.c: Provide dummy versions of init_proc, proc_wait, and
- proc_remove_foreign for the gdb case (the libgdb case provides its
- own versions of these functions).
- * Makefile.in (libgdb-files): Add libproc.a.
-
-Wed Jun 1 11:08:52 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- Hardware watchpoints for Linux, from Rick Sladkey
- (jrs@world.std.com).
- * infrun.c (wait_for_inferior) [HAVE_CONTINUABLE_WATCHPOINT]: Add
- new hardware breakpoint recovery method.
- * i386v-nat.c (i386_insert_watchpoint,
- i386_insert_nonaligned_watchpoint, i386_remove_watchpoint,
- i386_stopped_by_watchpoint) [TARGET_CAN_USE_HARWARE_WATCHPOINT]:
- New functions to support the 386 hardware debugging registers.
- * config/i386/nm-linux.h (TARGET_CAN_USE_HARDWARE_WATCHPOINT,
- HAVE_CONTINUABLE_WATCHPOINT, STOPPED_BY_WATCHPOINT,
- target_insert_watchpoint, target_remove_watchpoint): Define these
- macros to use the hardware debugging functions in i386v-nat.c.
-
-Wed May 25 17:06:15 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in: Replace libgdb.a with libgdb-files. Make "all"
- build it.
-
-Thu May 19 09:56:20 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * target.c, target.h: New variables target_activity_function and
- target_activity_fd.
- * inflow.c, inferior.h: New functions set_sigio_trap and
- clear_sigio_trap.
- * inftarg.c (child_wait), procfs.c (wait_fd): Call them.
-
-Wed May 18 13:01:55 1994 Doug Evans (dje@canuck.cygnus.com)
-
- * remote-sim.h (sim_verbose): Delete.
- Document callbacks needed.
- (sim_*): Change result to void where there isn't one.
- (sim_open): Clarify argument and error response.
- (sim_close): Declare.
- (sim_load): Change bfd_handle argument to file name. Clarify result.
- (sim_create_inferior): Renamed from sim_set_args.
- (sim_set_pc): Delete.
- (sim_info): Delete printf_fn argument.
- * remote-sim.c (gdbsim_kill): Add comment describing purpose.
- (gdbsim_load): Try sim_load first.
- (gdbsim_create_inferior): Call sim_create_inferior.
- (gdbsim_open): Handle args == NULL. Update call to sim_open.
- (gdbsim_close): Call sim_close.
- (gdbsim_files_info): Update call to sim_info.
- (gdbsim_ops): Realign comments.
-
- * printcmd.c (decode_format): Allow TARGET_PTR_BIT to be non-constant.
-
-Tue May 17 16:45:20 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab): For C_FILE symbols, only use
- the auxent if the symbol's name is ".file". From David Edelsohn
- <c1dje@watson.ibm.com>.
-
-Tue May 17 11:08:22 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (breakpoint_1): Fix typo.
-
- * annotate.c (annotate_field_end): Fix typo.
-
- * Makefile.in: Move annotate.o from COMMON_OBS to OBS.
-
- * Makefile.in (TSSTART): Remove; no longer used.
-
- * utils.c (vfprintf_maybe_filtered, vfprintf_unfiltered): Call
- fputs_unfiltered and exit directly, rather than fatal. The latter
- calls vfprintf_unfiltered!
-
- * gdbtypes.h, gdbtypes.c (can_dereference): New function.
- * value.h, printcmd.c (print_value_flags): Move from here...
- * annotate.c: ...to here, and make it use can_dereference.
-
-Sat May 14 15:13:52 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * inflow.c (job_control, attach_flag, generic_mourn_inferior):
- Remove, needed for both native and cross.
- * target.c (attach_flag, generic_mourn_inferior): Put here.
- * utils.c (job_control): Put here.
- (terminal.h): Don't include anymore.
-
-Sat May 14 09:11:44 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * source.c (find_source_lines): Always use code that was #ifdef
- BROKEN_LARGE_ALLOCA. Do the cleanup before returning, rather than
- leaving it on the chain. Reindent much of this function.
- * config/sparc/{xm-sun4sol2.h,xm-sun4os4.h},
- config/i386/{xm-sun386.h,xm-i386m3.h,xm-i386mach.h},
- config/m68k/{sun3os4.h,xm-news.h,xm-hp300hpux.h},
- config/ns32k/xm-ns32km3.h: Remove all references to
- BROKEN_LARGE_ALLOCA; with the above change it is no longer needed.
- * main.c, fork-child.c, many config files: Remove all
- SET_STACK_LIMIT_HUGE code; with the above changes it should no
- longer be needed.
-
- * symtab.c (lookup_partial_symbol): Use if and abort, not assert.
- This avoids __eprintf troubles.
-
-Fri May 13 08:10:21 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c (main): Surround in #ifndef MAIN_OVERRIDE. Move
- initialization code which needs to be called even if we bypass the
- command line stuff into gdb_init.
- * utils.c (fputs_unfiltered): Surround in #ifndef
- FPUTS_UNFILTERED_OVERRIDE.
- * Makefile.in (libgdb.a): New target.
-
- * utils.c: Rearrange I/O stuff a bit so that all output goes
- through fputs_unfiltered. Use vasprintf; removes arbitrary limit
- which made %s not work with arbitrarily large strings.
- * printcmd.c (printf_command): Use printf_filtered, not
- printf_unfiltered and printf, now that arbitrary limit is gone.
-
- gcc -Wall lint:
- * breakpoint.c (watchpoint_check): Remove unused variable b.
- * stack.c (print_frame_info): Move sp and buf inside #if.
- * eval.c (evaluate_subexp): Remove unused variables pp,
- mangle_ptr, ptr, and mangle_tstr.
- * valarith.c (value_x_binop): Remove unused variables mangle_tstr
- and mangle_ptr.
- * symtab.c (lookup_symtab): Put variable copy inside #if.
- (decode_line_1): Put variable q1 inside #if 0.
- * target.h: Declare target_link.
- * infrun.c (wait_for_inferior): Remove unused variables signame.
- * remote.c (remote_resume): Remove unused variable name.
- * c-exp.y (parse_number): Parenthesize operand of shift.
- * dbxread.c (record_minimal_symbol): Parenthesize operand of &&
- (this is a semantic change, the warning seems to have detected a bug).
- * dbxread.c (end_psymtab): Move variable p1 inside #if.
- * coffread.c: Move variable temptype inside #if.
- * ch-typeprint.c (chill_type_print_base): Remove unused variable
- name.
- * ch-valprint.c: #include typeprint.h and ch-lang.h.
- (chill_val_print): Remove unused variable in_range.
- (chill_val_print): Remove statement "length > TYPE_LENGTH (type);".
- (chill_val_print): Add default case for switch.
- * stabsread.h: Declare stabsect_build_psymtabs.
- * os9kread.c (read_minimal_symbols): Make this return void.
- (os9k_symfile_read): Remove unused variables stb_exist and val.
- (os9k_symfile_init): Remove unused variable val.
- (fill_sym): Remove unused variable id.
- (read_os9k_psymtab): Put variable back_to inside #if 0. Remove
- unused variable nsl.
- Remove unused variable symfile_bfd.
- #if 0 unused variables lbrac_unmatched_complaint and
- lbrac_mismatch_complaint.
- Remove declaration for non-existent function os9k_next_symbol_text.
-
- * annotate.c, annotate.h: New files, containing a function for
- each annotation which outputs it.
- * Move breakpoints_changed from breakpoint.c to annotate.c.
- * breakpoint.c, blockframe.c, infrun.c, cp-valprint.c, main.c,
- printcmd.c, source.c, stack.c, utils.c, valprint.c:
- Use annotate.c functions to output annotations.
- * Makefile.in (OBS): Add annotate.o.
-
-Thu May 12 10:46:27 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (read_unwind_info): Make sure elf_unwind_size and
- elf_unwind_entries are always initialized.
-
- * hppa-tdep.c (skip_trampoline_code): Handle argument relocation
- stubs which return directly to the caller rather than to the stub
- itself.
-
-Wed May 11 20:11:51 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * c-exp.y (yyerror): Display a more informative error message.
- * ch-exp.y (yyerror): Ditto, don't use global yychar.
- * m2-exp.y (yyerror): Ditto.
-
-Tue May 10 11:57:53 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * inflow.c (job_control): Move definition to front of file.
-
-Tue May 10 14:42:37 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * maint.c (print_section_table): Rename SEC_SHARED_LIBRARY to
- SEC_COFF_SHARED_LIBRARY to match corresponding change in bfd.
-
-Fri May 6 13:30:22 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * Makefile.in (kdb): Remove old init.c creation commands.
- * configure.in (sparclite): Match on sparclite*.
- * sparclite/aload.c (main): Only change section addresses for
- a.out format object files.
-
-Fri May 6 13:24:04 1994 Steve Chamberlain (sac@cygnus.com)
-
- * config/i386/go32.mh: Define CC.
-
-Fri May 6 11:56:54 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * gdbserver/Makefile.in: Remove irrelevant definitions and
- comments inherited from the gdb Makefile.
- (BFD_DIR, BFD, BFD_SRC, BFD_CFLAGS): Add from gdb Makefile.
- (VERSION): Update to 4.12.3.
- (gdbserver): Remove any existing executable first.
- (distclean, realclean): Remove nm.h.
- * gdbserver/low-lynx.c: Add Sparc Lynx support.
- * gdbserver/low-sparc.c, gdbserver/low-sun3.c (sys/wait.h):
- Don't use absolute pathname.
-
-Thu May 5 12:00:22 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * rs6000-nat.c (vmap_ldinfo): Don't fail if fstat returns an
- error.
-
-Wed May 4 06:56:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (proceed, normal_stop, wait_for_inferior), breakpoint.c
- (print_it_normal): Add annotations for the inferior starting and
- stopping, and for all the various messages related to how it
- stopped.
-
- * printcmd.c (do_one_display): Annotate.
- * stack.c (print_frame_info): Annotate printing of stack frames.
-
-Wed May 4 18:15:51 1994 Stu Grossman (grossman@cygnus.com)
-
- * remote.c (get_offsets): Handle case where stub doesn't support
- qOffsets message.
-
-Wed May 4 15:30:39 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- Add partial support for g++ code compiled with -fvtable-thunks.
- * c-valprint.c (c_val_print): Add vtblprint support
- when using thunks.
- * cp-valprint.c (cp_is_vtbl_member): A vtable can be an array of
- pointers (if using thunks) as well as array of structs (otherwise).
- * cp-valprint.c (vtbl_ptr_name_old, vtbl_ptr_name): Move to global
- level, and make the latter non-static (so define_symbol can use it).
- * stabsread.c (define_symbol): If the type being defined is a
- pointer type named "__vtbl_ptr_type", set the TYPE_NAME to that name.
- * symtab.h (VTBL_PREFIX_P): Allow "_VT" as well as "_vt".
- * values.c (value_virtual_fn_field): Handle thunks.
- * values.c (value_headof): Minor efficiency hack.
- * values.c (value_headof): Incomplete thunk support. FIXME.
-
-Wed May 4 06:56:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * valprint.c (print_longest): Clarify comment about use_local.
- * printcmd.c, defs.h (print_address_numeric), callers in
- symmisc.c, symfile.c, stack.c, source.c, remote.c, infcmd.c,
- cp-valprint.c, core.c, ch-valprint.c, c-valprint.c, breakpoint.c,
- exec.c: New argument use_local.
- * source.c (identify_source_line): Use filtered output. Use
- print_address_numeric.
-
- * core.c (memory_error), symtab.c (cplusplus_hint, decode_line_1),
- language.c (type_error, range_error): Use filtered output.
- * utils.c (error_begin): Update comment to tell people to use
- filtered output.
-
- * Makefile.in (HFILES_WITH_SRCDIR): List bfd.h.
- (HFILES_NO_SRCDIR): List gdbcore.h not gdbcore_h, so as not to get
- bfd.h.
-
-Tue May 3 07:41:33 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * procfs.c (procfs_wait): Reinstate code which deduces the signal
- from the fault, #ifndef FAULTED_USE_SIGINFO.
- * config/sparc/tm-sun4sol2.h: Define FAULTED_USE_SIGINFO.
-
-Fri Apr 29 18:15:04 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (breakpoint_1): Annotate each field of the headers.
- Explicitly annotate each record.
-
-Fri Apr 29 15:56:18 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * xcoffexec.c: Reformat to standards and lint.
- (language.h): Include.
- (exec_close): Declare arg "quitting".
- (file_command): Declare arg "from_tty".
- (map_vmap): Cast xmalloc result to PTR.
- * rs6000-nat.c: Reformat to standards and lint.
- (exec_one_dummy_insn): Use char array for saved instruction.
- (fixup_breakpoints): Declare.
- (vmap_ldinfo): Be more informative in fatal error messages.
- (xcoff_relocate_symtab): Define to return void.
- * xcoffsolib.h: Reformat to standards, improve comments.
- * config/rs6000/nm-rs6000.h (xcoff_relocate_symtab): Declare.
-
-Thu Apr 28 08:40:56 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * utils.c, defs.h (error_begin): New function.
- (quit): Print annotation before printing the error message.
- * main.c (return_to_top_level): Print annotation before doing the
- longjmp.
- * symtab.c (decode_line_1): Call error not warning and then
- return_to_top_level. Call error_begin and printf_unfiltered
- rather calling warning (before calls to return_to_top_level).
- * core.c (memory_error): Use error_begin, printf_unfiltered,
- print_address_numeric and return_to_top_level instead of error.
- Cleans up a FIXME-32x64.
- * language.c (type_error, range_error): Call error_begin
- not just target_terminal_ours.
-
- * dbxread.c (stabsect_build_psymtabs): Assign to sym_stab_info
- directly, rather than via DBX_SYMFILE_INFO. A cast on the left
- side of an assignment is non-portable.
-
- * utils.c (query): Change syntax of query annotations to be
- consistent with other input annotations.
- (prompt_for_continue): Likewise for prompt-for-continue annotation.
-
-Thu Apr 28 01:20:39 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (psymtab_to_symtab_1): Do not call sort_blocks
- for stabs symtabs.
- * mips-tdep.c (mips_skip_prologue): Handle prologues for functions
- that have a stack frame size of 32k or larger (from Paul Flinders).
- Remove #if 0'd code.
-
-Wed Apr 27 16:33:51 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * lynx-nat.c (CANNOT_STORE_REGISTER): Add a fallback definition
- for Lynx platforms that need it.
- * config/nm-lynx.h (__LYNXOS): Define if not already defined.
-
-Wed Apr 27 16:01:37 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * procfs.c (procfs_wait): Use the signal from the pr_info rather
- than trying to deduce it from the fault.
-
-Wed Apr 27 12:22:46 1994 Steve Chamberlain (sac@cygnus.com)
-
- * printcmd.c (print_address_symbolic): Initialize name to empty
- string to avoid core dump if lookup fails.
- * remote-e7000.c (printf_e7000debug): Error if target not open.
-
-Tue Apr 26 22:45:24 1994 Stu Grossman (grossman at cygnus.com)
-
- * i386-nlmstub.c: Update to be more in line with PIN stub.
- * nlm/gdbserve.c (putDebugChar): Install bug fix from i386-nlmstub.
- * (hex2mem): Init ptr.
- * General cleanups to use ConsolePrintf, standard prologues, etc...
-
-Tue Apr 26 10:23:04 1994 Stu Grossman (grossman at cygnus.com)
-
- * i386-nlmstub.c: More changes to be compatible with remote.c.
-
- * dbxread.c: Move a bunch of strncmps out of process_one_symbol
- into (the far less frequently called) dbx_symfile_read.
-
- * i386-nlmstub.c: An interim version till we get PIN for the x86.
-
-Tue Apr 26 09:50:45 1994 Stu Grossman (grossman at cygnus.com)
-
- * dbxread.c (record_minimal_symbol): Record the section
- associated with the symbol to make dynmaic relocation work.
- * (dbx_symfile_read, process_one_symbol): Fixes to work around
- Solaris brain-damage which don't apply to relocatable object
- files.
- * (stabsect_build_psymtabs): New routine to read stabs out of an
- arbitrarily named section.
- * nlmread.c (nlm_symtab_read): Read ALL syms from the NLM, not just
- globals.
- * (nlm_symfile_read): Call stabsect_build_psymtabs to read the
- stabs out of the nlm.
- * partial-stabs.h (cases 'f' & 'F'): Fixes to work around Solaris
- brain-damage which don't apply to relocatable object files.
- * remote.c (putpkt): Improve error reporting and error handling.
- * (get_offsets): Temporary kludge to force data & bss sections to
- have the same relocation.
- * stabsread.c (define_symbol, scan_file_globals): Record section
- info in sym.
-
-Sat Apr 23 19:05:52 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (breakpoint_1): Annotate each field of output. Add
- FIXME-32x64 comment.
-
-Fri Apr 22 16:43:54 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (wait_for_inferior): Move call to flush_cached_frames
- to after call to target_wait. This means that flush_cached_frames
- can call target_terminal_ours if it wants to.
- * infrun.c (wait_for_inferior) [HAVE_NONSTEPPABLE_WATCHPOINT]: Add
- comment about why the code is dubious.
-
- * stabsread.c (read_type): Call read_type, not nonexistent
- os9k_read_type.
-
-Fri Apr 22 14:25:36 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * remote-os9k.c (rombug_fetch_registers): set trace mode
- correctly.
- * remote-os9k.c (rombug_read_inferior_memory): cache data in
- buffer.
- * os9kread,c (read_os9k_psymtab): process file symbol to truncate
- extra info.
- * os9kread.c (os9k_read_ofile_symtab): proper casting of args
- passed to process_one_symbol.
- * stabsread.c (read_type): process os9k functio prototype.
-
-Fri Apr 22 11:27:39 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * solib.c (symbol_add_stub): If so->textsection is NULL, don't
- dump core.
-
-Thu Apr 21 07:45:49 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * utils.c (prompt_for_continue): Annotate prompt.
- (query): Annotate query.
- * printcmd.c (print_frame_args): Change syntax of argument
- annotation to make name and value part of a single group of
- annotations, not two separate groups.
- * cp-valprint.c (cp_print_value_fields): Likewise for fields.
- * valprint.c (val_print_array_elements): Change syntax of
- annotation to be more concise.
- * main.c, defs.h (command_line_input): New argument tells what
- string to include in the annotations.
- * symtab.c (decode_line_2), main.c (read_command_lines,
- command_loop): Change callers.
-
- * breakpoint.c (watch_command): Use (CORE_ADDR)0, not NULL, for
- target null pointer.
- * blockframe.c (find_frame_addr_in_frame_chain): Likewise.
-
- * printcmd.c (output_command): Annotate things we print here too.
- * printcmd.c (print_command_1): Add "value-history-value" annotation.
- * Move declaration of print_value_flags from defs.h to value.h.
- * main.c (command_line_input): Call wrap_here as well as gdb_flush.
-
-Thu Apr 21 09:29:37 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * dbxread.c (read_dbx_dynamic_symtab): Reinstall support for sun3,
- BFD handles sun3 dynamic relocations now.
- * elfread.c (elf_symtab_read, elf_symfile_read): Handle dynamic
- symbol table.
-
-Wed Apr 20 19:41:21 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (print_command_1): Annotate the top-level expressions
- that we print.
- (print_frame_args): Annotate each argument.
- * printcmd.c, defs.h (print_value_flags): New function.
- * cp-valprint.c (cp_print_value_fields): Annotate each field.
- * valprint.c (val_print_array_elements): Annotate each array element.
-
-Wed Apr 20 13:18:41 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * findvar.c (read_var_value): Handle LOC_REPARM_ADDR case correctly,
- the register contains a pointer to the type, not the type itself.
-
-Mon Apr 11 10:44:35 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * main.c (main): Accept --annotate=N option and make --fullname
- the same as --annotate=1.
- (command_line_input): Print annotatation before and after prompt.
- * blockframe.c (flush_cached_frames): Print annotation.
- * Rename frame_file_full_name to annotation_level and move it from
- symtab.h to defs.h.
- * source.c (identify_source_line): If annotation_level > 1,
- change output format.
- * breakpoint.c: Print annotation whenever a breakpoint changes.
- * main.c: New variable server_command.
- (command_line_input): Parse "server " and set server_command.
- (dont_repeat): Check server_command.
-
-Wed Apr 20 08:37:16 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (xcoff_next_symbol_text): Don't return before
- updating raw_symbol and symnum. Return a value in the case where
- we complained.
-
- * dstread.c, coffread.c: Don't define pending_blocks; buildsym.c
- takes care of it.
- * parse.c: Don't define block_found; it is defined in symtab.c.
- * parser-defs.h: Add comment regarding block_found.
-
-Tue Apr 19 09:46:05 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (internalize_unwind_info): Delete unused indexp
- argument.
-
-Mon Apr 18 13:18:56 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * dbxread.c (read_dbx_dynamic_symtab): Relocate BFD symbols by
- section vma. Do not read dynamic relocs for sun3 executables to
- avoid BFD assertion message.
-
-Mon Apr 18 10:08:07 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * nm-hppab.h (KERNEL_U_ADDR): Define.
- (FIVE_ARG_PTRACE): Likewise.
- (CANNOT_STORE_REGISTER): Likewise.
- * nm-hppah.h (KERNEL_U_ADDR): Define.
- (FIVE_ARG_PTRACE): Likewise.
- (CANNOT_STORE_REGISTER): Likewise.
- (NEED_TEXT_START_END): Likewise.
-
- * tm-hppah.h (NEED_TEXT_START_END): Delete definition.
- * xm-hppah.h (KERNEL_U_ADDR): Delete definition.
- (FIVE_ARG_PTRACE): Likewise.
- * xm-hppab.h (KERNEL_U_ADDR): Delete definition.
- (FIVE_ARG_PTRACE): Likewise.
-
- * hppa-tdep.c (read_unwind_info): Make static.
- (restore_pc_queue): Indirect through the target vector to
- reload the register state.
-
-Sat Apr 16 22:20:51 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * paread.c (compare_unwind_entries): Delete function. It's been
- moved into hppa-tdep.c.
- (read_unwind_info): Likewise.
- (pa_symfile_read): No longer call read_unwind_info. The unwind
- tables will be read in as they are needed.
-
- * hppa-tdep.c (compare_unwind_entries): New function.
- (read_unwind_info, internalize_unwinds): Likewise.
- (find_unwind_entry): Read in unwind information on demand.
-
-Fri Apr 15 11:53:46 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * source.c (DIRNAME_SEPARATOR): New macro, replaces all references
- to : in search path processing.
- * defs.h (qsort): Rename argument in prototype.
- * symtab.h (SAYMBOL_VALUE): Rename value field, avoids bugs in
- some compilers.
- * breakpoint.c, exec.c, mdebugread.c, mipsread.c, xcoffexec.c
- (false): Eliminate usages.
-
-Fri Apr 15 11:35:19 1994 Steve Chamberlain (sac@cygnus.com)
-
- * h8500-tdep.c (initialize_h8500_tdep, large_command):
- All references to value changed to value_ptrlage_command is now
- called big_command.
- All references to value changed to value_ptr.
- * remote-e7000.c (e7000_wait): Use target_waitstatus and SETSTOP
- * remote-hms.c (hms_wait): Timeout after five seconds.
- * ser-go32.c (dosasync_read): Poll if timeout < 0.
- * config/tm/tm-h8500.h (BEFORE_MAIN_LOOP_HOOK): Deleted.
- * config/sh/tm-sh.h (BREAKPOINT): Is now sleep opcode.
-
-Thu Apr 14 07:01:56 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * procfs.c (procfs_wait): Protect watchpoint code with appropriate
- #ifdefs.
- (procfs_set_watchpoint, procfs_stopped_by_watchpoint): Likewise.
-
-Wed Apr 13 14:52:46 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * breakpoint.h (enum bptype): Add bp_hardware_watchpoint and
- bp_watchpoint_scope breakpoints.
- (struct breakpoint): Add val_chain and related_breakpoint fields
- for use by watchpoints.
-
- * breakpoint.c (within_scope): Delete. No longer used.
- (TARGET_CAN_USE_HARDWARE_WATCHPOINT): Provide default definition.
- (target_{remove,insert}_watchpoint): Likewise.
- (can_use_hardware_watchpoint): New function.
- (remove_breakpoint): New function to remove a single breakpoint
- or hardware watchpoint.
- (insert_breakpoints): Handle insertion of hardware watchpoints.
- Store a copy of the value chain derived from the watchpoint
- expression.
- (remove_breakpoints): Simplify by using remove_breakpoint.
- (delete_breakpoint): Likewise.
- (watchpoint_check): Delete the watchpoint and watchpoint scope
- breakpoints when the watchpoint goes out of scope. Save & restore
- the current frame after checking watchpoints.
- (breakpoint_init_inferior): Likewise (restarting the program
- makes all local watchpoints go out of scope).
- (bpstat_stop_status): Handle hardware watchpoints much like normal
- watchpoints. Delete the watchpoint and watchpoint scope breakpoint
- when the watchpoint goes out of scope. Remove and reinsert all
- breakpoints before returning if we stopped when a hardware watchpoint
- fired.
- (watch_command): Use a hardware watchpoint when possible. If
- watching a local expression, build a scope breakpoint too.
- (map_breakpoint_numbers): Also call given function for any
- related breakpoints.
- (disable_breakpoint): Never disable a scope breakpoint.
- (enable_breakpoint): Handle hardware breakpoints much like normal
- breakpoints, but recompute the watchpoint_scope breakpoint's
- frame and address (if we have an associated scope breakpoint).
- (read_memory_nobpt): Handle hardware watchpoints like normal
- watchpoints. When necessary handle watchpoint_scope breakpoints.
- (print_it_normal, bpstat_what, breakpoint_1, mention): Likewise.
- (clear_command, breakpoint_re_set_one, enable_command): Likewise.
- (disable_command): Likewise.
-
- * blockframe.c (find_frame_addr_in_frame_chain): New function.
- Extern prototype added to frame.h
-
- * infrun.c (wait_for_inferior): Set current_frame and select
- a frame before checking if we stopped due to a hardare watchpoint
- firing. Handle stepping over hardware watchpoints.
- (normal_stop): Remove unnecessary call to select_frame.
-
- * value.h (value_release_to_mark): Declare.
- * values.c (value_release_to_mark): New function.
-
- * procfs.c (procfs_wait): Add cases for hardware watchpoints.
- (procfs_set_watchpoint, procfs_stopped_by_watchpoint): New functions.
-
- * hppab-nat.c (hppa_set_watchpoint): New function.
-
- * config/pa/nm-hppab.h (STOPPED_BY_WATCHPOINT): Define.
- (HAVE_STEPPABLE_WATCHPOINT): Define.
- (TARGET_CAN_USE_HARDWARE_WATCHPOINT): Define.
- (target_{insert,delete}_watchpoint): Define.
-
- * config/mips/nm-irix4.h (TARGET_CAN_USE_HARDWARE_WATCHPOINT): Define.
- (STOPPED_BY_WATCHPOINT, HAVE_NONSTEPPABLE_WATCHPOINT): Likewise.
- (target_{insert,remove}_watchpoint): Likewise.
-
-Mon Apr 11 19:21:27 1994 Stu Grossman (grossman at cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab): Ignore symbols of class C_EXT,
- smtyp XTY_LD, sclass XMC_DS (external data segment label). They
- often have the same names as debug symbols for functions, and
- confuse lookup_symbol().
-
-Mon Apr 11 10:44:35 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * remote.c: Around redefinition of PBUFSIZE, adjust whitespace.
- * config/pa/tm-hppa.h (REGISTER_BYTES): Use 4 rather than
- REGISTER_RAW_SIZE (1).
- Together these changes work around a bug in HP's compiler. Both
- seem to be necessary.
-
-Mon Apr 11 09:18:24 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * paread.c (pa_symtab_read): Handle ST_STUB symbols and symbols
- with scope SS_EXTERNAL. ST_ENTRY symbols in dynamic executables
- are type mst_solib_trampoline.
-
-Fri Apr 8 17:14:37 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * config/m68k/es1800.mt: Change comments.
-
-Fri Apr 8 17:14:37 1994 Rob Savoye (rob@darkstar.cygnus.com)
-
- * config/m68k/monitor.mt (TDEPFILES): Don't include remote-es.o.
-
-Fri Apr 8 15:35:30 1994 Stu Grossman (grossman at cygnus.com)
-
- * lynx-nat.c: Restore regmap structure for SPARC. It's needed
- for core files.
-
-Fri Apr 8 14:53:35 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * values.c (unpack_long): Remove obsolete comment about using a
- switch statement.
-
- * symfile.c (symbol_file_command): Add comments about command syntax.
-
-Thu Apr 7 17:25:21 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
- Jim Kingdon (kingdon@cygnus.com)
-
- * infrun.c (IN_SOLIB_TRAMPOLINE): Correct comment, trampolines
- are in the .plt section.
- * minsyms.c (lookup_solib_trampoline_symbol_by_pc,
- find_solib_trampoline_target): New functions for handling
- stepping into -g compiled shared libraries.
- * symtab.h (lookup_solib_trampoline_symbol_by_pc,
- find_solib_trampoline_target): Add prototypes.
- * config/tm-sunos.h (IN_SOLIB_TRAMPOLINE, SKIP_TRAMPOLINE_CODE):
- Define to handle stepping into -g compiled shared libraries.
- * config/tm-sysv4.h (SKIP_TRAMPOLINE_CODE): Define to handle
- stepping into -g compiled shared libraries.
-
-Thu Apr 7 17:22:54 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * configure.in: Add mips-*-sysv4* support.
- * config/mips/mipsv4.mh, config/mips/mipsv4.mt,
- config/mips/tm-mipsv4.h, config/mips/xm-mipsv4.h, mipsv4-nat.c:
- New files for MIPS SVR4 support.
- * Makefile.in: Update for new mipsv4 files.
- * alpha-tdep.c (heuristic_proc_desc, find_proc_desc): Use
- read_next_frame_reg to obtain the frame relative stack pointer.
- * mips-tdep.c (heuristic_proc_desc): Use read_next_frame_reg to
- obtain the frame relative stack pointer.
- * mdebugread.c (parse_partial_symbols, psymtab_to_symtab1):
- Handle stStatic and stStaticProc symbols in stabs-in-ecoff output
- by entering them into the minimal symbol table.
- * printcmd.c (print_scalar_formatted): Do not try to unpack to
- a long for float formats.
- * solib.c: Include "elf/mips.h" only if DT_MIPS_RLD_MAP does not
- get defined in <link.h>.
- * solib.c (solib_add): Add shared library sections to the section
- table of the target before adding the symbols.
- * partial-stab.h: Relocate static and global functions.
- * dbxread.c (read_dbx_symtab): Remove unused variable
- end_of_text_address. Relocate text_addr when passing it
- to end_psymtab.
-
- For Alpha OSF/1 targets, enable gdb to set breakpoints in shared
- library functions before the executable is run. Retrieve dynamic
- symbols from stripped executables.
- * mipsread.c (read_alphacoff_dynamic_symtab): New function.
- * mipsread.c (mipscoff_symfile_read): Use it. Issue warning message
- if no debugging symbols were found.
- * alpha-tdep.c (alpha_skip_prologue): Silently return the unaltered
- pc if memory at the pc is not accessible and GDB_TARGET_HAS_SHARED_LIBS
- is defined.
- * config/alpha/nm-alpha.h (GDB_TARGET_HAS_SHARED_LIBS): Define,
- OSF/1 has shared libraries.
-
-Thu Apr 7 15:11:11 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * dbxread.c (read_dbx_dynamic_symtab): Adjust for recent changes
- to BFD handling of dynamic symbols.
-
-Tue Apr 5 15:29:25 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (hppa_fix_call_dummy): If FUN is a procedure label,
- then gets its real address into FUN and its GOT/DP value into %r19.
-
- * tm-hppa.h (CALL_DUMMY): Use %r20, not %r19 as a temporary.
-
- * hppa-tdep.c (frameless_function_invocation): If no unwind
- descriptor was found, then assume this was not a frameless
- function invocation.
- (frame_saved_pc): If the saved PC is in a linker stub, then
- return the return address which the linker stub will return to.
-
- * xm-hppab.h: Never define USG.
- * xm-hppah.h: Always define USG.
-
-Tue Apr 5 12:58:47 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * values.c (unpack_long, value_from_longest),
- valarith.c (value_binop): Allow TYPE_CODE_RANGE.
-
-Fri Apr 1 14:04:34 1994 Jason Merrill (jason@deneb.cygnus.com)
-
- * symfile.c (deduce_language_from_filename): .cpp is a C++ extension.
-
-Fri Apr 1 00:44:00 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- For SVR4 targets, enable gdb to set breakpoints in shared
- library functions before the executable is run.
- * elfread.c (elf_symtab_read): Handle symbols for shared library
- functions.
- * sparc-tdep.c (in_solib_trampoline): Renamed to in_plt_section
- and moved to objfiles.c.
- * objfiles.c (in_plt_section): Moved to here from sparc-tdep.
- * config/tm-sysv4.h (IN_SOLIB_TRAMPOLINE): Use new in_plt_section.
- * config/sparc/tm-sun4sol2.h (IN_SOLIB_TRAMPOLINE): Removed,
- the new generic definition from tm-sysv4.h works for Solaris.
-
-Wed Mar 30 16:14:27 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * elfread.c (elf_symtab_read): Change storage_needed,
- number_of_symbols and i to long. Rename get_symtab_upper_bound to
- bfd_get_symtab_upper_bound. Check for errors from
- bfd_get_symtab_upper_bound and bfd_canonicalize_symtab.
- * nlmread.c (nlm_symtab_read): Same changes.
-
-Wed Mar 30 11:43:29 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (xcoff_next_symbol_text): New function.
- (read_xcoff_symtab): Set next_symbol_text_func to it.
- Move raw_symbol outside of read_xcoff_symtab.
-
- * remote.c (getpkt): Remove unused "out" label.
-
-Wed Mar 30 09:15:42 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * breakpoint.c (print_it_normal): Allow GDB to notify the user
- about more than one watchpoint being triggered.
-
-Wed Mar 30 08:24:18 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/m68k/tm-dpx2.h: Include tm-m68k.h not nonexistent tm-68k.h.
-
-Wed Mar 30 00:31:49 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * blockframe.c (find_pc_partial_function): mst_file_text
- symbols do not live in the shared library transfer table.
- * ch-exp.y (decode_integer_value, match_character_literal,
- match_bitstring_literal): Guard tolower calls with isupper,
- tolower on old BSD systems blindly subtracts a constant.
- * dbxread.c (read_ofile_symtab): Check for __gnu_compiled_* as
- well when determining the producer of the object file.
- * mdebugread.c (has_opaque_xref): New function to check for
- cross reference to an opaque aggregate.
- * mdebugread.c (parse_symbol, parse_partial_symbols): Do not
- enter typedefs to opaque aggregates into the symbol tables.
- * mdebugread.c (parse_external): Remove skip_procedures argument,
- it has always been 1. Remove code that handled stProc symbols,
- it was never executed and was wrong, as the index of a
- stProc symbol points to the local symbol table and not to the
- auxiliary symbol info. Update caller.
- * mdebugread.c (parse_partial_symbols): Do not enter external
- stProc symbols into the partial symbol table, they are already
- entered into the minimal symbol table.
- * config/i386/tm-symmetry.h: Clean up, it is now only used for Dynix.
- Remove all conditionals and definitions for ptx.
- I386_REGNO_TO_SYMMETRY moved to here from symm-tdep.c.
- Fix addresses of floating point registers in REGISTER_U_ADDR.
- STORE_STRUCT_RETURN now handles cc and gcc conventions.
- FRAME_CHAIN, FRAMELESS_FUNCTION_INVOCATION, FRAME_SAVED_PC,
- IN_SIGTRAMP, SIGCONTEXT_PC_OFFSET defined to make backtracing through
- signal trampoline code work.
- * config/i386/xm-symmetry.h: Clean up, it is now only used for Dynix.
- Remove all conditionals and definitions for ptx.
- Remove KDB definitions.
- * symm-nat.c (store_inferior_registers): Fetch registers before
- storing them to obtain valid floating point control registers.
- Store fpu registers.
- * symm-nat.c (print_1167_control_word): Dynix 3.1.1 defines
- FPA_PCR_CC_C0 and FPA_PCR_CC_C1, avoid duplicate case value.
- * symm-nat.c (fetch_inferior_registers, child_xfer_memory):
- Fix typos.
- * symm-nat.c (child_resume): Update type of `signal' parameter.
- * symm-tdep.c (I386_REGNO_TO_SYMMETRY): Moved to tm-symmetry.h.
-
-Tue Mar 29 23:01:33 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (hppa_fix_call_dummy): Use an alternate method for
- calling import stubs for functions in shared libraries.
-
-Tue Mar 29 21:14:04 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * ch-exp.y: Implement SIZE(mode_name) and SIZE(expression).
-
- * ch-lang.c (chill_is_varying_struct): Magic string is
- was "<var_length>" is now "__var_length" (more portable).
-
-Tue Mar 29 19:41:34 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote.c (getpkt): If we get a timeout, actually retry rather
- than just giving up the first time it happens.
- * remote.c: Document sequence numbers.
- (remote_store_registers): Change syntax of 'P' request so that it
- never looks like a sequence number.
-
-Tue Mar 29 16:06:01 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * os9kread.c (record_minimal_symbol): add section_offset to
- relocate minimal symbol table.
- * os9kread.c (read_minimal_symbols): ditto.
- * os9kread.c (os9k_symfile_init): increase size of dbg and stb
- file names.
- * os9kread.c (read_os9k_psymtab): if there's no dbg file, just
- return. Also if file addr is 0 leave it 0, not to relocate.
- * remote-os9k.c (_initialize_remote_os9k): add 'set remotexon',
- 'set remotexoff' and 'set remotelog' commands.
-
-Tue Mar 29 12:38:45 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote.c (remote_store_registers): Add 'P' request to set an
- individual register.
- (remote_write_bytes, remote_read_bytes): Use %lx, not %x, to print
- a target address.
-
-Sat Mar 26 07:05:18 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/sparc/tm-sparc.h: Define USE_REGISTER_NOT_ARG.
- * stabsread (define_symbol): If USE_REGISTER_NOT_ARG, go back to
- combining all 'p' and 'r' pairs into a LOC_REGPARM.
-
- * command.c (do_setshow_command, case var_string): Never add a
- space to the end of the string.
- * NEWS: Document this change.
- * .gdbinit: Add a space to the "set prompt" command.
-
-Fri Mar 25 12:40:41 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * m3-nat.c, i386m3-nat.c, config/i386/i386m3.mh: Many minor
- changes to make it compile (it doesn't link yet).
-
- * buildsym.c (start_subfile, patch_subfile_names), demangle.c
- (set_demangling_style, set_demangling_command): Use savestring not
- strdup. We were not dealing properly with a NULL return from
- strdup, and were not declaring strdup (the system header may or
- may not have it).
-
- * valprint.c (val_print): Remove inaccurate comment about what
- types can be stub types.
-
- * config/i386/ptx.mh (XDEPFILES): Add coredep.o. Delete infptrace.o.
- * symm-nat.c (child_wait, _initialize_symm_nat, kill_inferior):
- Supply alternate version if ATTACH_DETACH is not defined.
- * ptx4-nat.c, config/i386/{nm-ptx4.h, ptx4.mh, ptx.mt, ptx4.mt,
- tm-ptx.h, tm-ptx4.h, xm-ptx.h, xm-ptx4.h}: New files.
- * configure.in: Recognize i[34]86-sequent-sysv4* host.
-
-Fri Mar 25 10:14:03 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (skip_prologue): Do nothing if not at the beginning
- of a function.
- (skip_trampoline_code): Rewrite and add support for argument
- relocation stubs stubs, import/export stubs, calls through
- "_sr4export" and cascaded trampolines.
-
- * hppa-tdep.c (skip_prologue): Return "pc" not zero
- if no unwind descriptor is found.
-
- * tm-hppa.h (NUM_REGS): Bump to 128 registers.
- (REGISTER_NAMES): Add entries for "right-half" of FP registers.
- (REGISTER_RAW_SIZE, MAX_REGISTER_RAW_SIZE): Do not treat FP regs
- differently. All registers are four bytes.
- (REGISTER_BYTES, REGISTER_BYTE): Simplify now that all registers are
- the same size.
- (REGISTER_VIRTUAL_TYPE): Use builtin_type_float for all FP regs.
-
- * hppa-tdep.c (pa_print_fp_reg): Update to print even numbered FP
- registers as both single and double values (fetching 2nd 32bit half
- as necessary). Annotate each register printed with its precision.
-
- * paread.c (read_unwind_info): Fix off-by-one error.
-
-Fri Mar 25 08:33:28 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c (complete_command): Deal with it if arg is NULL.
-
-Thu Mar 24 07:12:09 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/mips/tm-mips.h (SETUP_ARBITRARY_FRAME): Revise comment
- regarding using the PC--using the PC is necessary and all the
- FIXME comments in the world won't make it go away.
-
- * valops.c (value_at, value_at_lazy): Give error if we dereference
- a pointer to void.
- * gdbtypes.h: Fix comments regarding TYPE_CODE_VOID.
- * stabsread.c: Use 1, not 0, for TYPE_LENGTH of void types.
-
- * stabsread.c (patch_block_stabs): Add comment about what happens
- if the definition is in another compilation unit from the stab.
-
- * dbxread.c (end_psymtab): Add comment about empty psymtabs.
-
-Wed Mar 23 07:50:33 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c (complete_command): New command, from Rick Sladkey
- <jrs@world.std.com>.
- (symbol_completion_function): Don't declare rl_point and
- rl_line_buffer; they are now declared in readline.h.
- (show_commands): Don't declare history_base; it is declared in
- history.h.
- * command.c (lookup_cmd): Don't delete trailing whitespace.
- Reverts change of 14 May 1989.
-
-Wed Mar 23 16:14:52 1994 Stu Grossman (grossman at cygnus.com)
-
- * minsyms.c (prim_record_minimal_symbol): Move section deduction
- code from prim_record_minimal_symbol_and_info() to here. Callers
- of the latter can legitimately supply a section number of -1.
-
-Wed Mar 23 07:50:33 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbtypes.h, gdbtypes.c: Add comments regarding whether static
- member functions have an element in args for a (nonexistent) this
- pointer.
-
-Tue Mar 22 20:12:53 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * config/pa/tm-hppao.h (NO_PC_SPACE_QUEUE_RESTORE): Define.
-
- * hppa-tdep.c (hppa_pop_frame): Do not restore the PC space
- queue if NO_PC_SPACE_QUEUE_RESTORE is defined.
-
- * stabsread.c (REG_STRUCT_HAS_ADDR): Accept additional argument
- for the structure's type. All callers changed.
-
- * valops.c (call_function_by_hand): Check REG_STRUCT_HAS_ADDR
- for each structure argument rather than assuming it's either
- true or false for all structure arguments.
-
- * config/pa/tm-hppa.h (REG_STRUCT_HAS_ADDR): Depend only
- on the length structure passed, not the compiler used.
-
- * config/sparc/tm-sparc.h (REG_STRUCT_HAS_ADDR): Accept additional
- argument for the structure's type.
-
-Tue Mar 22 15:28:33 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * values.c (set_internalvar): Don't set var->value until we are
- sure there won't be an error().
-
- * remote.c (get_offsets): Reinstate comment which was in
- remote_wait about use of SECT_OFF_TEXT and so on.
-
-Mon Mar 21 13:11:30 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symmisc.c (maintenance_check_symtabs): New function to check
- consistency of psymtabs and symtabs.
- * symtab.h (maintenance_check_symtabs): Add prototype.
- * maint.c: Add new `maint check-symtabs' command.
- * config/i386/tm-i386aix.h, config/i386/tm-sun386.h,
- config/i386/tm-symmetry.h (REGISTER_CONVERT_TO_RAW): Fix typo.
- * config/i386/tm-symmetry.h: Make comment inside #if 0 a real
- comment.
- * config/i386/tm-symmetry.h (STORE_STRUCT_RETURN): Cast argument
- to write_memory to avoid warnings from gcc.
- * config/i386/xm-symmetry.h: Add missing #endif.
- * config/i386/nm-symmetry.h (NO_PTRACE_H): Add for Dynix.
- * config/i386/symmetry.mt (TDEPFILES): Add i386-tdep.o.
- * config/i386/symmetry.mh (NAT_FILE, NATDEPFILES): Add.
-
-Mon Mar 21 11:50:28 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (hppa_fix_call_dummy): Use value_ptr.
- (hppa_push_arguments): Likewise.
-
-Mon Mar 21 11:02:51 1994 Stu Grossman (grossman at cygnus.com)
-
- * alpha-tdep.c: Gobs of changes (many imported from mips-tdep) to
- improve remote debugging efficiency. Also fixed problems with
- doing function calls for programs with no entry points.
- * infcmd.c (run_stack_dummy): Use CALL_DUMMY_ADDRESS instead of
- entry_point_address.
- * inferior.h (PC_IN_CALL_DUMMY): ditto.
- * mdebugread.c (parse_symbol, parse_procedure, parse_external,
- parse_lines): Pass section_offsets info to these routines so that
- we can relocate symbol table entries upon readin.
- * (psymtab_to_symtab_1): Set symtab->primary to tell
- objfile_relocate to do relocations for our symbols.
- * (ecoff_relocate_efi): New routine to relocate adr field of PDRs
- (which hang off of the symbol table).
- * Use prim_record_minimal_symbols_and_info instead of
- prim_record_minimal_symbols to supply section info to make minimal
- symbol relocations work.
- * minsyms.c (prim_record_minimal_symbols_and_info): If section is
- -1, try to deduce it from ms_type.
- * objfiles.c (objfile_relocate): Use ALL_OBJFILE_SYMTABS where
- appropriate. Handle relocation of MIPS_EFI symbols special. Also,
- add code to relocate objfile->sections data structure.
- * remote.c (get_offsets): Use new protocol message to acquire
- section offsets from the target.
- * (remote_wait): Get rid of relocation stuff. That's all handled
- by objfile_relocate now.
- * config/alpha/alpha-nw.mt (TM_FILE): Use tm-alphanw.h.
- * config/alpha/tm-alpha.h: Define CALL_DUMMY_ADDRESS, and
- VM_MIN_ADDRESS.
- * config/alpha/tm-alphanw.h: DECR_PC_AFTER_BREAK=0, VM_MIN_ADDRESS=0.
-
-Mon Mar 21 10:09:06 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (_initialize_hpuxread): Don't call add_symtab_fns if
- HPREAD is not defined.
-
-Sun Mar 20 15:21:57 1994 Doug Evans (dje@cygnus.com)
-
- * sparc-tdep.c (sparc_frame_find_save_regs): Use REGISTER_RAW_SIZE
- instead of 4.
- * sp64-tdep.c (target_ptr_bit, set_target_ptr_bit): Deleted,
- can no longer set this at run time.
- * config/sparc/sp64.mt (SIMFILES): Use remote-sim.o now.
- (TM_CLIBS): Define to -lm, the simulator uses the sqrt() function.
- * config/sparc/tm-sp64.h (FPS_REGNUM, CPS_REGNUM): Define (so
- sparc-tdep.c compiles).
- (TARGET_PTR_BIT): Must be a constant now, fix at 64.
-
-Sat Mar 19 08:51:12 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/m68k/{cisco.mt,tm-cisco.h}: New files.
- * Makefile.in (ALLPARAM, ALLCONFIG): Add them.
- * configure.in: Recognize m68*-cisco*-*.
-
- * Makefile.in (TAGS): Use variables directly, rather than using
- find, to locate TM_FILE, XM_FILE, and NAT_FILE. This is faster
- and means that these filenames no longer need be unique across all
- the config/* directories.
- * configure.in: Put the config/*/ into TM_FILE, etc.
-
- * m68k-stub.c (computeSignal): Return SIGFPE, not SIGURG, for chk
- and trapv exceptions.
-
- * target.h (struct section_table), objfiles.h (struct obj_section):
- Change name of field sec_ptr to the_bfd_section. More mnemonic
- and avoids the (sort of, for the ptx compiler) name clash with
- the name of the typedef.
- * exec.c, xcoffexec.c, sparc-tdep.c, rs6000-nat.c, osfsolib.c,
- solib.c, irix5-nat.c, objfiles.c, remote.c: Change users.
-
- * utils.c: Include readline.h.
- * Makefile.in (utils.o): Add dependency.
-
- * remote.c (getpkt): Add support for run-length encoding.
-
-Fri Mar 18 19:11:15 1994 Steve Chamberlain (sac@jonny.cygnus.com)
-
- * utils.c (prompt_for_continue): Call readline, not gdb_readline.
-
-Fri Mar 18 10:25:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dstread.c (record_minimal_symbol): New arg objfile. Pass it to
- prim_record_minimal_symbol.
- Callers: Pass it.
-
- * regex.c (EXTEND_BUFFER): Adjust pointers within buffer by
- computing their offset from the start of the old buffer and adding
- to the new buffer, rather than by assuming we can add the
- difference between the old buffer and the new buffer (it might not
- fit in an int). Merge in cosmetic differences from emacs regex.c
- version of this macro.
-
-Wed Mar 16 15:28:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * Makefile.in (install-only): Fix use of program_transform_name.
-
-Wed Mar 16 07:18:43 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c: Remove "set print fast-symbolic-addr off" command.
- The bug which it worked around was fixed on 25 Feb 94 in coffread.c,
- so I'm nuking the command.
- * symtab.c (find_addr_symbol): Comment out, no longer used.
-
- * main.c (main): Don't init_source_path for the -cd argument. Now
- that source_path doesn't contain the current_directory from when
- GDB started up, init_source_path is no longer useful (and is
- harmful because it clobbers a source_path set in $HOME/.gdbinit).
-
- * TODO: Remove item about line numbers being off. It is useless
- and confusing without a reproducible test case (it mentions
- proceed(), but I was able to step through proceed without trouble).
-
-Tue Mar 15 13:39:23 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- For Sunos 4.x targets, enable gdb to set breakpoints in shared
- library functions before the executable is run. Retrieve dynamic
- symbols from stripped executables.
- * symtab.h (minimal_symbol_type): Add mst_solib_trampoline type.
- * parse.c (write_exp_msymbol), symmisc.c (dump_msymbols),
- symtab.c (list_symbols): Handle mst_solib_trampoline.
- * minsyms.c (lookup_minimal_symbol): Handle mst_solib_trampoline
- for all targets, remove IBM6000_TARGET dependencies.
- * dbxread.c (read_dbx_dynamic_symtab): New function.
- * dbxread.c (dbx_symfile_read): Use it.
- * dbxread.c (SET_NAMESTRING): Set namestring to
- "<bad string table index>" instead of "foo" if the string index is
- corrupt.
- * xcoffread.c (read_xcoff_symtab): Use mst_solib_trampoline instead
- of mst_unknown.
- * symtab.c (list_symbols): Take from_tty as parameter and pass it
- to break_command. Handle mst_file_* minimal symbol types.
- * config/i386/tm-i386bsd.h: Give just macro name, not args, to #undef.
-
-Tue Mar 15 11:40:43 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * c-exp.y(yylex): fix potential memory overflow.
-
-Tue Mar 15 10:33:28 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * environ.c (set_in_environ): Eliminate special handling of PATH and
- GNUTARGET.
- * putenv.c: Removed, conflicts with system declaration of
- putenv on RS/6000 running AIX 3.2.5, and above change makes it
- unnecessary.
- * Makefile.in: Change accordingly.
- * procfs.c (procfs_create_inferior): Change comment accordingly.
-
-Tue Mar 15 10:05:27 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * rs6000-tdep.c: Change value to value_ptr.
-
-Sun Mar 13 17:19:03 1994 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (read_hpux_symtab: Correctly determine the namespace
- and address class of SVAR, DVAR, TYPEDEF, TAGDEF, CONST, and
- MEMENUM symbols. Do not include function-scoped variables in
- the partial symbol table.
-
-Sun Mar 13 09:45:51 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * i386m3-nat.c: Include floatformat.h.
- (get_i387_state): Use memset not bzero.
-
- * Version 4.12.3.
-
- * Makefile.in: Enable commented out getopt_h, bfd_h, etc. Change
- ieee-float.h to floatformat.h.
-
- * valprint.c (val_print_string): Ignore error if the error
- happened after a terminating '\0'.
-
- * c-valprint.c (c_val_print): Never add 1 to return value from
- val_print_string; just return what it returns.
-
- * target.h (enum target_signal): Add TARGET_SIGNAL_FIRST, for
- looping through all of the enums.
- * infrun.c (signals_info): Use it.
-
-Fri Mar 11 08:08:50 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * main.c (main): When printing warning about bad baud rate, don't
- use warning(); it relies on current_target which isn't set up yet.
-
- * breakpoint.c (_initialize_breakpoint): Update docstring for
- tbreak to match what the code actually does. Don't mention tbreak
- in docstrings for "enable once" or "enable breakpoints once".
-
-Thu Mar 10 08:52:38 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symfile.h (ADD_PSYMBOL_VT_TO_LIST): Don't put a semicolon after
- while (0). That defeats the whole purpose of using do . . . while (0).
- * mdebugread.c (parse_partial_symbols): Don't use ?: expression as
- list for ADD_PSYMBOL_TO_LIST; the macro takes its address and
- using a ?: expression as an lvalue is not portable.
-
- * stabsread.c (define_symbol): If REG_STRUCT_HAS_ADDR, also
- convert a LOC_ARG to a LOC_REF_ARG. Update code which combines
- 'p' and 'r' symbol descriptors into a single symbol to look for a
- LOC_REF_ARG.
- * README, config/sparc/tm-sparc.h: Update comments.
-
-Wed Mar 9 21:43:24 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (parse_type): Do not complain for types with
- an `indexNil' aux index, these are simply undefined types.
- Remove indexNil check from caller of parse_type.
- * mdebugread.c (parse_partial_symbols): Do not enter
- stGlobal, scCommon symbols into the minimal symbol table, their
- value is the size of the common, not its address.
- Handle scInit, scFini, scPData and scXData sections.
- Use minimal symbol type mst_file_* for stLabel symbols, instead of
- mst_*.
- Enter stProc symbols into the global_psymbols list once, not into
- the static_psymbols_list.
- Get rid of dummy psymtab if it is empty, to allow proper detection
- of stripped executables.
- * mdebugread.c (cross_ref): Allow cross references to Fortran
- common blocks.
-
-Wed Mar 9 15:23:19 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (common_block_end, fix_common_block): Stash the
- struct pending * in the SYMBOL_TYPE, not the SYMBOL_NAMESPACE, so
- as to not assume that a pointer fits in an enum.
-
-Wed Mar 9 18:56:36 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * os9kread.c (fill_sym): check compiler verion number for pre-
- UltraC compiler.
- * os9kread.c (os9k_process_one_symbol): address of symbol is
- relative to section not module.
- * stabsread.c (define_symbol): add symbol type 's' as local
- symbol for os9k.
- * remote-os9k.c: add command 'set monitor_log' to turn on or off
- monitor logging.
- * remote-os9k.c: fix bug in delete breakpoint, single step trace.
- * remote-os9k.c: fix bug in 'set remotebaud' function.
- * remote-os9k.c (rombug_link): minimize checking so to improve
- speed.
- * symfile.c (symbol_file_command): check if failed to link, also make
- the command be able to accept more than one filenames.
- * target.c (target_link): check if failed to link with rombug.
- * config/i386/tm-i386os9k.h : add #define DECR_PC_AFTER_BREAK 0.
-
-Wed Mar 9 15:23:19 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-es.c (es1800_child_ops): Don't declare it static.
-
-Tue Mar 8 11:42:39 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * config/i386/tm-i386v4.h: Give just macro name, not args, to #undef.
-
-Tue Mar 8 06:56:13 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dbxread.c: New variable lowest_text_address.
- (record_minimal_symbol, read_dbx_symtab): Set it.
- (read_dbx_symtab): Use lowest_text_address + text_size instead of
- end_of_text_address.
- * config/gould/tm-pn.h: Add comment regarding END_OF_TEXT_DEFAULT.
-
- * dbxread.c (end_psymtab): Remove old and commented out
- capping_global and capping_static. Fix comments regarding
- N_SO_ADDRESS_MAYBE_MISSING to match the real name of the macro.
-
- * parser-defs.h: Add "extern" to start of variable declarations so
- we don't end up with commons.
- * parse.c: Define these variables.
-
- * irix5-nat.c (find_solib): Cast o_path to CORE_ADDR when using it
- as one.
-
-Mon Mar 7 13:00:50 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * alpha-tdep.c: Change value to value_ptr.
-
-Sun Mar 6 17:36:53 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * solib.c (elf_locate_base): New function to locate the address
- of the dynamic linker's runtime structure in the dynamic info section.
- * solib.c (locate_base): Use it instead of iterating over the list
- of mapped address segments.
- * solib.c (look_for_base, bfd_lookup_symbol): Removed, no longer
- necessary.
-
-Fri Mar 4 09:50:47 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (pc_in_linker_stub): Move decl to beginning of file.
- (pc_in_interrupt_handler): New function. Also add PARAM decl.
- (find_proc_framesize): Deal with HPUX setting SAVE_SP bit for
- signal trampoline and interrupt routines.
- (frame_saved_pc): Handle signal trampolines and interrupt routines.
- (frame_chain, frame_chain_valid): Likewise.
- (hppa_frame_find_saved_regs): Likewise. Also deal with special
- saved regs convention for SP.
-
- * tm-hppa[bho].h: FRAME_FIND_SAVED_PC_IN_SIGTRAMP): Define.
- (FRAME_BASE_BEFORE_SIGTRAMP): Define.
- (FRAME_FIND_SAVED_REGS_IN_SIGTRAMP): Define.
-
- * tm-hppah.h (IN_SIGTRAMP): Define.
-
-Thu Mar 3 12:41:16 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * ch-exp.y (match_simple_name_string): Accept '_' as well as an
- alphabetic character as the start of a name.
-
- * sparclite/Makefile.in (all install): Build and install aload.
-
- * configure.in: Accept i[34]86-*-*sysv32 because that is what
- config.guess and config.sub produce.
-
- * mips-tdep.c: Change value to value_ptr.
-
-Wed Mar 2 09:17:55 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * breakpoint.c, breakpoint.h, c-valprint.c, ch-valprint.c,
- cp-valprint.c, eval.c, expprint.c, findvar.c, language.c,
- objfiles.h, infcmd.c, printcmd.c, stack.c, typeprint.c,
- valarith.c, valops.c, valprint.c, value.h, values.c: Replace
- value with value_ptr. This is for the ptx compiler.
- * objfiles.h, target.h: Don't declare a "sec_ptr" field using a
- "sec_ptr" typedef.
- * symm-nat.c: Add a bunch of stuff for symmetry's ptrace stuff.
- #if 0 i386_float_info.
- * symm-tdep.c (round): Remove. Also remove sgttyb.
- * symm-tdep.c: Remove lots of stuff which duplicates stuff from
- i386-tdep.c. Remove register_addr and ptx_coff_regno_to_gdb.
- * i386-tdep.c (i386_frame_find_saved_regs): Put in
- I386_REGNO_TO_SYMMETRY check in case it is needed for Dynix
- someday.
- * config/i386/nm-symmetry.h: Change KERNEL_U_ADDR. Move
- stuff from PTRACE_READ_REGS, PTRACE_WRITE_REGS macros to
- symm-nat.c. Define CHILD_WAIT and declare child_wait().
- * config/i386/tm-symmetry.h: Remove call function stuff; stuff in
- tm-i386v.h is apparently OK.
- * config/i386/xm-symmetry.h [_SEQUENT_]: Define HAVE_TERMIOS not
- HAVE_TERMIO. Define MEM_FNS_DECLARED, NEED_POSIX_SETPGID, and
- USE_O_NOCTTY.
-
-Wed Mar 2 11:31:08 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * osfsolib.c (xfer_link_map_member): Update to use new
- target_read_string interface.
-
-Wed Mar 2 09:17:55 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * infrun.c (wait_for_inferior): In checking
- remove_breakpoints_on_following_step, check
- through_sigtramp_breakpoint as well as step_resume_breakpoint.
-
-Tue Mar 1 16:22:56 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * os9kread.c (os9k_process_one_symbol): Rename
- VARIABLES_INSIDE_BLOCK to OS9K_VARIABLES_INSIDE_BLOCK.
- * symfile.c (symbol_file_command): Check for (CORE_ADDR)-1, not
- (CORE_ADDR)0, from target_link, since that is what it uses.
- Process name at end, not during parsing (like we did before Kung's
- change), so that -readnow and -mapped can appear anywhere.
- Make text_relocation a local variable.
- * config/i386/i386os9k.mt: Fix comment.
- * Makefile.in (ALLDEPFILES): Add remote-os9k.c.
- * os9kread.c: Put "comments" after #endif inside /* */.
- * stabsread.h: Add os9k_stabs variable.
- * stabsread.c (start_stabs), os9kread.c (os9k_process_one_symbol):
- Set it.
- * stabsread.c (define_symbol): If os9k_stabs, put a 'V' symbol
- descriptor in global_symbols not local_symbols.
- (read_type): If os9k_stabs, accept 'c', 'i', and 'b' type
- descriptors.
- (read_type): If os9k_stabs, accept function parameters after 'f'
- type descriptor.
- (read_array_type): If os9k_stabs, don't expect index type and
- expect lower and upper to be separated by ',' not ';'.
- (read_enum_type): If os9k_stabs, read a number before the first
- enumeration constant.
- (os9k_init_type_vector): New function.
- (dbx_lookup_type): Call it when starting new type vector.
- * config/i386/tm-i386os9k.h: Define BELIEVE_PCC_PROMOTION.
- * (os9k_process_one_symbol): Call define_symbol not os9k_define_symbol.
- * os9kstab.c: Removed.
- * Makefile.in: Update accordingly.
- * objfiles.c (objfile_relocate_data): Removed.
- * remote-os9k.c (rombug_wait): Call objfile_relocate
- not objfile_relocate_data.
- * objfiles.h, objfiles.c: Remove find_pc_objfile.
- * remote-os9k.c (rombug_wait): Call find_pc_section not
- find_pc_objfile.
- * main.c (quit_command): Check inferior_pid; revert Kung change.
- * remote-os9k.c (rombug_create_inferior): Set inferior_pid.
-
-Tue Mar 1 14:56:14 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * os9kread.c: New file to read os9000 style symbo table.
- * os9kstab.c: new file to read os9000 style stabs.
- * remote-os9k.c: remote protocol talking to os9000 rombug monitor.
- * objfiles.c (find_pc_objfile): new function to search objfile
- from pc.
- * objfiles.c (objfile_relocate_data): new function to relocate
- data symbols in symbol table.
- * objfiles.h: Add two aux fields in struct objfile to handle
- multiple symbol table files situation like in os9000.
- * symfile.c: Change so 'symbol-file' command can handle multiple
- files. Also call target_link() to get relocation infos.
- * target.c (target_link): new function to get relocation info when
- a symbol file is requested to load.
- * main.c (quit_command): take out 'inferior_pid != 0' condition,
- because in cross mode there's no inferior pid, bit they need to
- be detached.
- Makefile.in: add os9kread.c os9kstab.c and .o's.
- configure.in: add i386os9k target.
- config/i386/i386os9k.mt: new add.
- config/i386/tm-i386os9k.h: new add.
-
-Tue Mar 1 13:16:10 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/sparc/tm-sun4sol2.h (IN_SIGTRAMP): Handle ucbsigvechandler.
- * sparc-tdep.c (sparc_frame_saved_pc): Handle ucbsigvechandler.
-
-Tue Mar 1 11:54:11 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * target.c, target.h (target_read_string): Provide error detection to
- caller. Put string in malloc'd space, so caller need not impose
- arbitrary limits.
- * solib.c (find_solib): Update to use new interface.
- * irix5-nat.c (find_solib): Read o_path from inferior
- (clear_solib): Free storage for o_path.
- * valprint.c (val_print_string): Add comments.
-
-Mon Feb 28 23:54:39 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symtab.c (decode_line_1): Handle the case when skip_quoted does not
- advance `p'.
-
-Mon Feb 28 12:40:46 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * value.h (struct value): Add modifiable field.
- * values.c (allocate_value, record_latest_value, value_copy): Set it.
- (record_latest_value): Don't mess with VALUE_LVAL of value.
- * valops.c (value_assign): Check it. Reword existing error
- message on not_lval.
-
- * mips-tdep.c (mips_step_skips_delay), config/mips/tm-mips.h
- (STEP_SKIPS_DELAY): Added.
- * infrun.c (proceed) [STEP_SKIPS_DELAY]: Check for a breakpoint in
- the delay slot.
-
- * valprint.c (val_print_string): If errcode is set, always print
- an error, regardless of force_ellipsis. In the non-EIO case,
- just print the error message rather than calling error(). Don't
- access *(bufptr-1) if bufptr points to the start of the buffer.
- When looking for '\0', don't increment bufptr and addr if bufptr
- started out already at limit. If an error happens on fetching the
- first character, don't print the string.
-
-Sun Feb 27 21:05:06 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * config/m68k/tm-apollo68b.h: Remove HAVE_68881 define; it is
- obsolete.
-
- * i387-tdep.c, i386-tdep.c i386v-nat.c, i386aix-nat.c,
- i386m3-nat.c, config/m68k/tm-m68k.h, i960-tdep.c
- config/i960/tm-i960.h, remote-nindy.c, config/m88k/tm-m88k.h,
- m88k-tdep.c: Use floatformat.h instead of ieee-float.h.
- * sparc-tdep.c: Remove now-obsolete ieee-float.h stuff
- * findvar.c: Update comment regarding ieee-float.h.
-
-Sun Feb 27 21:39:48 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/i386/tm-i386v4.h (I386V4_SIGTRAMP_SAVED_PC, IN_SIGTRAMP,
- FRAME_CHAIN, FRAMELESS_FUNCTION_INVOCATION, FRAME_SAVED_PC):
- Define to make backtracing through the various sigtramp handlers
- work.
- * i386-tdep.c (i386v4_sigtramp_saved_pc): New routine to fetch
- the saved pc from ucontext on the stack for SVR4 signal handling.
-
-Fri Feb 25 09:41:11 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * remote.c, remote-mon.c, remote-utils.c, remote-utils.h,
- target.h, remote-es.c, remote-nindy.c: Don't set baud rate if
- baud_rate is -1. Remove sr_get_baud_rate and sr_set_baud_rate;
- just use the global variable itself. When printing baud rate,
- don't print a baud rate if baud_rate is -1.
-
- * coffread.c (read_coff_symtab): Pass mst_file_* to
- record_minimal_symbol for C_STAT symbols. Put C_EXT and C_STAT
- symbols in the minimal symbols regardless of SDB_TYPE.
-
-Thu Feb 24 08:30:33 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * breakpoint.h (enum bptype): New type bp_through_sigtramp.
- (bpstat_what_main_action): New code BPSTAT_WHAT_THROUGH_SIGTRAMP.
- * breakpoint.c (bpstat_what): Return BPSTAT_WHAT_THROUGH_SIGTRAMP
- if we hit a bp_through_sigtramp breakpoint. Remove kludge which
- ignored bs->stop for a bp_step_resume breakpoint.
- * infrun.c (wait_for_inferior): Make a through_sigtramp_breakpoint
- which performs one (the check_sigtramp2 one) of the functions
- which had been handled by the step_resume_breakpoint. For each
- use of the step_resume_breakpoint, make it still use the
- step_resume_breakpoint, use the through_sigtramp_breakpoint, or
- operate on both.
- Deal with BPSTAT_WHAT_THROUGH_SIGTRAMP return from bpstat_what.
- When setting the frame address of the step resume breakpoint, set
- it to the address for frame *before* the call instruction is
- executed, not after.
-
- * mips-tdep.c (mips_print_register): Print integers using
- print_scalar_formatted rather than duplicating all the
- CC_HAS_LONG_LONG and so on.
- (mips_push_dummy_frame): Use read_register_gen rather than using
- read_register and then putting it back in target format with
- store_unsigned_integer. If registers are more than 4 bytes, give
- an error rather than have some registers overwrite other
- registers.
- #if 0 unused include of opcode/mips.h.
-
- * symfile.h: Don't declare arguments for coff_getfilename.
-
- * defs.h: Revert Kung change regarding FORCE_LONG_LONG.
-
-Thu Feb 24 08:06:52 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * configure.in (hppa*-*-osf*): New configuration.
- * config/pa/hppaosf.mt: New target makefile fragment.
- * config/pa/tm-hppao.h: New target include file.
-
-Thu Feb 24 04:29:19 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * exec.c (print_section_info): Print entry point for exec_bfd only.
- * ser-unix.c (wait_for): Fix typo in HAVE_TERMIO case.
- * dwarfread.c: Remove second inclusion of <sys/types.h>, which
- causes problems if <sys/types.h> has no multiple inclusion protection.
-
-Wed Feb 23 16:28:55 1994 Jeffrey A. Law (law@cygnus.com)
-
- * tm-hppa.h (CALL_DUMMY): Add two NOP instructions to the end of
- the call dummy to avoid kernel bugs in HPUX, BSD, and OSF1.
- (CALL_DUMMY_LENGTH): Changed accordingly.
-
-Wed Feb 23 16:21:25 1994 Stu Grossman (grossman at cygnus.com)
-
- * sparc-stub.c (trap_low): Make trap handler work for arbitrary
- numbers of register windows.
-
- * sparclite/hello.c: Add factorial function for testing.
- * salib.c: Use macros instead of constants for I/O addresses to
- make 931 support easier.
- * sparclite.h: Change constraint for LOC to "rJ" to force use of
- register in sta/lda instructions.
-
-Wed Feb 23 10:39:18 1994 Jim Kingdon (kingdon@rtl.cygnus.com)
-
- * dbxread.c (process_one_symbol): Set
- block_address_function_relative for COFF like we do for ELF and SOM.
-
-Sat Feb 19 03:17:32 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (new_psymtab): Pass in section_offsets and set
- them in the pst.
- * mdebugread.c (handle_psymbol_enumerators): New function to enter
- the enumerators of an ecoff enum into the partial symbol table.
- * mdebugread.c (parse_partial_symbols): Call it.
- * symfile.c (reread_symbols): Initialize objfile->*_psymbols.next.
- * symmisc.c (dump_psymtab): Fix typo, clean up output of section
- offsets. Cast psymtab->read_symtab to PTR before passing it to
- gdb_print_address.
- * i386-tdep.c (i386_skip_prologue): Skip over instructions that
- set up the global offset table pointer in pic compiled code.
- * config/mips/tm-mips.h (FIX_CALL_DUMMY): For big endian targets,
- error() on TYPE_CODE_FLT arguments whose size is greater than 8,
- swap all other TYPE_CODE_FLT arguments as mips_push_arguments
- ensures that floats are promoted to doubles before they are pushed
- on the stack.
-
-Fri Feb 18 23:12:59 1994 Stu Grossman (grossman at cygnus.com)
-
- * sparclite/Makefile.in, sparclite/salib.c, sparclite/sparclite.h:
- Fixup cache_on and flush_i_cache so that they work for both the
- 930 and 932 processors. Rewrite most low level funcs (uart
- access & cache stuff) to use new ASI access macros in sparclite.h.
- Also make it easy to access second serial port.
-
-Fri Feb 18 22:17:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * hp300ux-nat.c: Don't incloude <sys/dir.h>, <sys/ioctl.h>, or
- <sys/stat.h>; not needed.
-
-Fri Feb 18 08:26:29 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stack.c (print_frame_info): In "pathological" case, don't
- distrust the line number information.
-
-Fri Feb 18 16:51:14 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * mips-tdep.c (mips_print_register): handle 64 bits register.
- * valprint.c (print_longest): fix a bug in printing 64 bits value.
-
-Fri Feb 18 08:26:29 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Version 4.12.2.
-
- * Makefile.in (install): Do the sed for program_transform_name
- ourselves instead of worrying about INSTALL_XFORM. This enables
- users to override INSTALL_PROGRAM in the standard way.
-
- * Makefile.in (c-exp.tab.o, ch-exp.tab.o, m2-exp.tab.o): Don't
- depend on Makefile.in.
-
- * defs.h, valprint.c: Make longest_to_int a function not a macro.
- Only test against INT_MIN if a LONGEST is bigger than an int.
-
- * README: Change GhostScript to Ghostscript.
-
-Fri Feb 18 07:30:55 1994 Jim Kingdon (kingdon@cygnus.com)
-
- * config/rs6000/{tm-rs6000lynx.h,nm-rs6000lynx.h,xm-rs6000lynx.h}:
- Rename to tm-rs6000ly.h, nm-rs6000ly.h, xm-rs6000ly.h for 14
- character file names.
- * Makefile.in (ALLPARAM): Add these files.
-
- * config/mips/littlemips64.mt: Rename to mipsel64.mt for 14
- character file names.
- * Makefile.in: Add Kung's new mips64 files.
-
-Thu Feb 17 17:25:47 1994 Kung Hsu (kung@mexican.cygnus.com)
-
- * configure.in: add mips64-*-elf, mips64-*-ecoff, mips64el-*-elf,
- mips64el-*-ecoff and mips64-big-*.
- * defs.h: get rid of FORCE_LONG_LONG.
- * mips-tdep.c (mips_find_saved_regs): add sd and sdc1 instruction
- parsing. Change register size to be MIPS_REGSIZE.
-
-Thu Feb 17 09:30:22 1994 David J. Mackenzie (djm@thepub.cygnus.com)
-
- * corelow.c, exec.c, irix5-nat.c, mipsread.c, objfiles.c,
- osfsolib.c, rs6000-nat.c, solib.c, symfile.c, utils.c,
- xcoffexec.c: Use bfd_get_error and bfd_set_error and new error names.
-
-Fri Feb 11 21:47:24 1994 Steve Chamberlain (sac@sphagnum.cygnus.com)
-
- * remote-hms.c (readchar, hms_open, hms_fetch_register): Made more robust.
- (remove_commands, add_commands): Add/remove hms-drain when target
- is connected.
-
-Fri Feb 11 16:11:38 1994 Stu Grossman (grossman at cygnus.com)
-
- * configure.in: Add Lynx/rs6000 support.
- * lynx-nat.c: Clean up some Sparc stuff. Clean up ptrace error
- messages. Add rs6000 support. Don't try to modify unwritable
- registers.
- * rs6000-nat.c: Move lots of native dependent stuff (like core
- file support) from rs6000-tdep.c & xcoffexec.c to here.
- * rs6000-tdep.c: Move native dependent stuff to nat.c.
- * xcoffexec.c: Move native dependent stuff to nat.c.
- * config/rs6000/nm-rs6000.h: Move defs of SOLIB_* macros to here
- from tm file.
- * config/rs6000/tm-rs6000.h: Remove defs of SOLIB_* funcs, cuz they're
- really native.
- * config/rs6000/tm-rs6000lynx.h, config/rs6000/xm-rs6000lynx.h:
- New files to support Lynx/rs6000.
-
-Tue Feb 8 00:32:28 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * README: Remove note about gcc warnings on alpha, these should be
- gone now.
- * c-exp.y, ch-exp.y, core.c, corelow.c, eval.c, fork-child.c,
- m2-exp.y, minsyms.c, nlmread.c, parse.c, putenv.c, regex.c
- remote-utils.c, stabsread.c: Include <string.h>.
- * regex.c: Include "defs.h", change re_comp argument to const char *.
- * infptrace.c (fetch_register, store_inferior_registers): Change
- regaddr to type CORE_ADDR.
- * config/alpha/alpha-nw.mt, config/alpha/alpha-osf1.mt (MT_CFLAGS):
- Remove, no longer necessary now that we use bfd_vma for a CORE_ADDR.
-
-Mon Feb 7 09:21:17 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * symtab.h: Always define BYTE_BITFIELD to nothing.
-
-Mon Feb 7 08:44:17 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * config/m68k/{m68k-em.mt,tm-m68k-em.h}: Remove; no longer used.
- * configure.in: Remove comment about m68k-em.mt.
- * Makefile.in: Remove references.
-
-Mon Feb 7 08:22:42 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * defs.h [BFD64]: Use BFD_HOST_64_BIT, not nonexistent
- BFD_HOST_64_TYPE.
-
-Sun Feb 6 15:56:09 1994 Jeff Law (law@wild.cs.utah.edu)
-
- * hpread.c (hpux_symfile_init): Use obj_som_* rather than obj_* to
- access BFD private data. Search for the "$TEXT$" space rather
- than ".text".
- (hppa_sym_fns): Add bfd target flavour to initializer.
-
-Sun Feb 6 06:55:15 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * target.c (target_preopen): If target_kill doesn't remove the
- target from the stack, use pop_target to do it.
-
- * coffread.c (process_coff_symbol, case C_TPDEF): Don't set name
- of TYPE_CODE_PTR or TYPE_CODE_FUNC types. This parallels similar
- changes to stabsread.c from summer 1993.
-
- * remote-udi.c (udi_files_info): If prog_name is NULL, just skip
- printing the program, rather than passing NULL to printf.
- (udi_detach): Set udi_session_id to -1 so that udi_close doesn't
- try to call UDIDisconnect again. Print better message.
- (udi_kill): Just call UDIDisconnect ourselves, rather than doing
- it via udi_close.
- (udi_create_inferior): If udi_session_id is negative, open a new
- TIP rather than giving an error.
-
- * config/mips/mipsm3.mh, config/i386/i386m3.mh,
- config/ns32k/ns32km3.mh: Define NAT_FILE.
- * config/nm-m3.h: Change guard from _OS_MACH3_H_ and _OS_MACH3_H
- (it was inconsistent and namespace-wrong) to NM_M3_H.
- * m3-nat.c (mach_really_wait): Change parameter name to ourstatus.
- (m3_open): New function.
- (m3_ops): Use it.
- * TODO: Update Mach section.
-
- * Makefile.in: Remove "rapp" stuff; it is superseded by gdbserver.
-
-Sun Feb 6 13:26:21 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * printcmd.c (printf_command): Add missing single-letter
- backslash-escape sequences, and improve error message.
-
-Sun Feb 6 06:55:15 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * corelow.c (solib_add_stub, core_open): Pass address of from_tty
- rather than trying to shove an int into a pointer and back out
- again. This avoids compiler warnings.
-
- * defs.h (alloca): Declare as void *, not char *, on hpux.
- Don't prototype it, just declare the return type.
-
-Sun Feb 6 03:25:41 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/i386/tm-sun386.h, config/i386/tm-symmetry.h
- (REGISTER_CONVERT_TO_RAW): Add missing backslash.
-
-Sat Feb 5 08:03:41 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-mips.c (mips_fetch_registers): If regno is FP_REGNUM or
- ZERO_REGNUM, just read it as zero without talking to the board.
-
- * config/i386/tm-i386aix.h (REGISTER_CONVERT_TO_RAW): Add missing
- backslash.
- * i386-tdep.c (i386_extract_return_value): Pass TYPE_LENGTH (type)
- to store_floating, not nonexistent variable len.
-
- * remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint):
- New functions.
- (mips_store_word): Change calling convention to return errors, and
- to provide old contents if the caller wants it.
- (mips_xfer_memory): Deal with errors from mips_store_word.
- * config/mips/tm-idt.h, config/mips/tm-idtl.h: Remove BREAKPOINT
- define now that remote-mips.c doesn't use BREAKPOINT.
-
- * remote-mips.c (mips_create_inferior): Call warning if arguments
- specified, and then execute "set args" command. Call error, not
- mips_error, if executable file not specified.
-
- * remote-e7000.c: Replace "snoop" command (e7000_noecho) with
- remote_debug.
-
- * config/rs6000/tm-rs6000.h (STORE_STRUCT_RETURN): Don't cast
- to unsigned int.
-
-Sat Feb 5 05:27:05 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * value.h (print_longest): Rename "value" to "val" in prototype
- declaration because some compilers don't like arguments whose
- names are the same as types.
- * remote.c (remote_xfer_memory): Cast "myaddr" to unsigned char *
- before passing it to remote_*_bytes.
-
-Fri Feb 4 15:53:18 1994 Steve Chamberlain (sac@cygnus.com)
-
- * h8500-tdep.c (saved_pc_after_call): The size of the
- pc is memory model dependent. (segmented_command,
- unsegmented_command, _initialize_h8500_tdep): New commands to
- change memory model.
- * remote-e7000.c (_initialize_remote_e7000): Change name of snoop
- command.
- * remote-hms.c (hms_load): Remove breakpoints when loaded.
- (hms_wait): Use new status structure
- (hms_open): Push the target here. (hms_before_main_loop): Not
- here. (supply_val, hms_fetch_register, hms_store_register): Cope
- with H8/500 names too. (hms_fetch_register): Take out REGISTER_TYPE.
- * sh-tdep.c (show_regs, initialize_sh_tdep): New command to print
- all registers in a compact way.
-
-Fri Feb 4 07:41:13 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * config/rs6000/tm-rs6000.h: Declare rs6000_struct_return_address
- as CORE_ADDR to match definition in rs6000-tdep.c.
-
-Fri Feb 4 01:14:20 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * dwarfread.c (process_dies): Skip nested TAG_compile_unit DIEs.
- * dwarfread.c (add_partial_symbol): Do not enter opaque aggregate
- definitions into the psymtab.
-
-Thu Feb 3 12:38:58 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * m68k-stub.c: Treat mc68332 like mc68020 most places. Provide
- a special exceptionSize for the 68332.
-
- * remote-udi.c (udi_attach): If no arguments, print error.
-
-Thu Feb 3 17:34:05 1994 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (VERSION): Bump to 4.12.1
- * NEWS, README: Update to match 4.12 release.
-
-Thu Feb 3 12:38:58 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * command.c (empty_sfunc): New function.
- (add_set_cmd): Use it instead of not_just_help_class_command.
- (not_just_help_class_command): Change calling convention back to
- what it was before yesterday's change.
-
- * stabsread.c (read_sun_builtin_type): Skip the semicolon at the end
- of the type if present.
-
-Wed Feb 2 11:16:45 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (decode_format): Don't blithely set the size for
- an address to 'w'. Make it 'g' or 'h', depending on TARGET_PTR_BIT.
-
- * defs.h: Just typedef CORE_ADDR to bfd_vma. Include bfd.h.
- If BFD64, make a LONGEST a BFD_HOST_64_BIT.
- * defs.h (longest_to_int): Don't depend on CC_HAS_LONG_LONG; instead
- always just check against INT_MIN and INT_MAX (this also fixes things
- if sizeof (long) > sizeof (int), e.g. Alpha).
- * config/pa/tm-hppa.h, config/i386/sun386.h, config/rs6000/tm-rs6000.h:
- Don't define LONGEST or BUILTIN_TYPE_LONGEST.
- * gdbtypes.h: Remove BUILTIN_TYPE_LONGEST and
- BUILTIN_TYPE_UNSIGNED_LONGEST.
- * language.h, c-lang.c, ch-lang.c, m2-lang.c, language.c: Remove
- longest_int and longest_unsigned_int.
- * value.h (struct value): Just align to LONGEST, rather than worrying
- about CC_HAS_LONG_LONG.
- * valarith.c (value_binop): Figure out type ourself based on
- sizeof (LONGEST) rather than relying on BUILTIN_TYPE_LONGEST. The
- point is that we don't depend on CC_HAS_LONG_LONG anymore.
- * valprint.c (val_print_type_code_int): Just call
- extract_unsigned_integer directly, rather than going through
- unpack_long.
- * printcmd.c (decode_format): Remove code which would sometimes
- change 'g' size to 'w' for integers. print_scalar_formatted handles
- printing huge integers well enough, thank you.
-
- * command.c (add_set_cmd, not_just_help_class_command): Change
- to make this the sfunc, not cfunc, since that is how we call it.
- * command.h: Comment difference between sfunc and cfunc.
- * demangle.c (set_demangling_command): Add third arg since that
- is how it is called.
- (_initialize_demangler): Use sfunc, not cfunc, for
- set_demangling_command, since that is how it is called.
- Remove show_demangling_command; it has no effect.
-
- * command.c (shell_escape): Report errors correctly (with error
- message from strerror).
-
-Wed Feb 2 14:35:41 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab): Change CSECT_LEN to use
- x_scnlen.l rather than x_scnlen to match corresponding change in
- coff/internal.h.
-
-Wed Feb 2 11:16:45 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbtypes.h, ch-typeprint.c, ch-valprint.c:
- Change comments regarding TYPE_CODE_BOOL.
- * language.c (boolean_type): Always return 1 for TYPE_CODE_BOOL,
- regardless of the language.
- (value_true): Just call value_logical_not regardless of language.
- * coffread.c (coff_read_enum_type), stabsread.c (read_enum_type):
- Remove #if 0'd code which makes some enums TYPE_CODE_BOOL.
- * language.h: Improve comment for la_builtin_type_vector.
- * m2-lang.c (_initialize_m2_language): Don't add any fields to
- builtin_type_m2_bool.
-
-Tue Feb 1 17:13:32 1994 Kevin Buettner (kev@cujo.geg.mot.com)
-
- * config/m88k/{tm-delta88.h,tm-delta88v4.h}, m88k-tdep.c:
- Define IN_SIGTRAMP and backtrace correctly through signal handlers.
-
-Tue Feb 1 22:13:25 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * procfs.c (wait_fd): Handle EINTR error return from PIOCWSTOP ioctl
- by restarting the ioctl.
-
-Tue Feb 1 16:16:25 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * target.h (target_wait): Add comment about calling
- return_to_top_level.
-
-Tue Feb 1 12:21:00 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * coffread.c (read_one_sym): bfd_coff_swap_aux_in now takes
- additional arguments.
- * xcoffread.c (read_xcoff_symtab, read_symbol_lineno): Likewise.
-
-Mon Jan 31 16:10:41 1994 Stu Grossman (grossman at cygnus.com)
-
- * sparc-stub.c: Remove unnecessary #include of memory.h.
-
-Mon Jan 31 12:12:34 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * mips-tdep.c: Remove code which sets saved_regs from
- init_extra_frame_info and put it in new function mips_find_saved_regs.
- (READ_FRAME_REG): Remove macro and replace uses with the expansion.
- * mips-tdep.c, config/mips/tm-mips.h: When examining ->saved_regs,
- check if it is NULL and call mips_find_saved_regs if so.
-
- * remote-mips.c: Use unfiltered, not filtered, output most places.
-
- * blockframe.c (get_prev_frame_info): Detect and stop an infinite
- backtrace. Revise comments.
-
-Mon Jan 31 09:40:33 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (parse_procedure): Remove _sigtramp kludges for
- alpha and irix. The _sigtramp case has to be handled properly
- in the tdep files if we have no ecoff debugging info.
- * alpha-tdep.c (alpha_frame_saved_pc, alpha_frame_chain),
- mips-tdep.c (mips_frame_saved_pc): Handle signal handler frames
- without PC_REGNUM kludge.
- * mdebugread.c (fixup_sigtramp), mips-tdep.c (read_next_frame_reg):
- Clean up handling of mips sigtramp frames, improve comments.
-
-Sat Jan 29 23:25:57 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * paread.c (read_unwind_info): Fix typo.
-
- * paread.c (pa_symtab_read): Update the "check_strange_names"
- filter to match GCC's current output. Filter out section symbols
- (which the HP linker sometimes puts in the wrong place).
-
-Sat Jan 29 07:44:59 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * serial.h (SERIAL_SET_TTY_STATE): Comment return value.
-
- * Makefile.in (TAGS): Just echo one line, rather than the whole thing.
-
- * Makefile.in: Remove all references to sparcly-nat.c.
-
- * Makefile.in (HFILES_NO_SRCDIR): Include dcache.h remote-utils.h
- remote-sim.h directly, rather than via $(remote_utils_h). This avoids
- duplicating serial.h and target.h.
-
- * Makefile.in: Don't set M_INSTALL and M_UNINSTALL. These variables
- are not used anywhere (a 5 Oct 1993 change removed the uses).
-
- * config/m68k/monitor.mt (TDEPFILE): Add remote-es.o.
- * config/m68k/es1800.mt: Add comment.
- * remote-es.c: Extensive changes to update to current conventions.
-
- * ser-unix.c (wait_for, hardwire_readchar) [HAVE_TERMIO, HAVE_TERMIOS]:
- If the timeout is too big to fit in c_cc[VTIME], then do multiple reads
- to achieve the desired timeout.
- * serial.h (serial_t): Add field timeout_remaining.
-
-Fri Jan 28 08:45:02 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * c-exp.y (yylex): Reenable nested type code.
-
-Fri Jan 28 15:40:33 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * a29k-tdep.c (examine_tag): Add comment regarding argcount.
-
- * remote-mips.c (mips_ops): Fix docstring.
-
- * remote-bug.c (bug_ops): Remove spurious newline from docstring.
-
- * config/m68k/tm-monitor.h: Changes to bring this into accordance
- with the old tm-m68k-em.h:
- (GDBINIT_FILENAME, DEFAULT_PROMPT): Remove.
- (HAVE_68881): Don't undefine; HAVE_68881 is obsolete.
- (REGISTER_NAMES): Don't muck with it; what tm-m68k.h has is fine.
- Add FIXME regarding GET_LONGJMP_TARGET.
-
- * remote-udi.c (udi_close, udi_detach, udi_kill): Add comments.
- * infptrace.c (kill_inferior): Add comments.
- * main.c (quit_command): Call target_close after we kill or
- detach.
- * remote-udi.c (udi_close): Don't error() if QUITTING.
-
-Fri Jan 28 11:55:52 1994 Rob Savoye (rob@darkstar.cygnus.com)
-
- * configure.in: Make m68k-coff and aout add monitor support in
- addition to the standard serial support.
-
-Fri Jan 28 08:45:02 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * mdebugread.c (psymtab_to_symtab_1): Don't complain on stLabel with
- index indexNil.
-
-Fri Jan 28 10:40:34 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/pa/tm-hppa.h: Define macro SMASH_TEXT_ADDRESS.
- * elfread.c (record_minimal_symbol_and_info),
- dwarfread.c (process_dies), paread.c (pa_symtab_read): Use it.
-
-Thu Jan 27 15:12:23 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * i386-stub.c: Add ".text" right before "mem_fault:".
-
- * main.c (baud_rate): Add FIXME comment about printing -1 value.
-
- * remote-utils.c (usage): Fix message to be accurate and conform
- more closely to normal conventions.
-
- * remote-utils.c (gr_files_info): Have the exec_bfd test control
- whether to show information about exec_bfd, and not control whether
- to show information about device and speed.
-
- * remote-utils.c (gr_open): If sr_get_device returns NULL, give
- usage message, don't dump core.
-
- * remote-bug.c (bug_write_memory): Use alloca, not GCC extension
- for variable size array.
- (bug_fetch_register, bug_store_register): Rename "value" to
- "fpreg_buf" because some compilers don't like variables whose
- names are the same as types.
- (bug_store_register): Use a cast when converting char * to
- unsigned char *.
-
- * symmisc.c (maintenance_print_symbols): Don't refer to the name
- of the command in error message (the text was referring to the old
- name of the command).
-
- * symmisc.c (dump_symtab): Fix args to fprintf_filtered.
-
- * c-typeprint.c (c_type_print_base): Have SHOW == 0 mean to print
- full details on structure elements without names. This partially
- reverts the changes of 1 Jul 1993 and 31 Aug 1993; I think this aspect
- of those changes was accidental.
-
- * stack.c (parse_frame_specification): If SETUP_ARBITRARY_FRAME is
- defined, make it an error to specify a single argument which is not
- a frame number.
-
- * Makefile.in (version.c), main.c (print_gdb_version): Use
- host_alias and target_alias, not host_canonical and
- target_canonical, to print configuration.
-
-Wed Jan 26 10:57:21 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * parse.c (write_exp_msymbol): Use new type msymbol_addr_type instead
- of builtin_type_long. It is necessary to get a type which is
- TARGET_PTR_BIT bits in size; builtin_type_long might not be big enough.
-
- Fix many sins which will come up in 32 bit x 64 bit GDB, and
- various miscellaneous things discovered in the process:
- * printcmd.c, defs.h (print_address_numeric): New function.
- * c-valprint.c (c_val_print), ch-valprint.c (chill_val_print)
- breakpoint.c (describe_other_breakpoints, breakpoint_1, mention),
- cp-valprint.c (cplus_print_value), infcmd.c (jump_command),
- printcmd.c, stack.c, symfile.c, symmisc.c, valprint.c:
- Use it.
- * utils.c, defs.h (gdb_print_address): New function.
- * expprint (dump_expression), gdbtypes.h: Use it.
- * breakpoint.c (describe_other_breakpoints),
- symmisc.c (dump_symtab, print_symbol):
- Use filtered not unfiltered I/O.
- (remove_breakpoints): Remove BREAKPOINT_DEBUG code. Might as well
- just run gdb under a debugger for this (and it had problems with
- printing addresses, how to print b->shadow, etc.).
- * buildsym.c (make_blockvector), core.c (memory_error),
- exec.c (print_section_info), maint.c (print_section_table),
- mdebugread.c (parse_procedure), solib.c, source.c, symfile.c,
- symmisc.c, symtab.c, valops.c, valprint.c, xcoffexec.c:
- Add comments saying code is broken. Marked with "FIXME-32x64".
- * dbxread.c (process_one_symbol), partial-stab.h (default),
- remote-vx.c (vx_run_files_info):
- Don't cast int being passed to local_hex_string.
- * symmisc.c (print_symbol): Don't cast long being passed to %lx.
- * symtab.h (general_symbol_info): Add comment about SYMBOL_VALUE
- only being a long.
- * symmisc.c (print_symbol): Print "offset" in message for LOC_ARG
- and LOC_LOCAL.
- * printcmd.c (print_address): Remove #if 0 code with ADDR_BITS_REMOVE.
- * source.c: Include <sys/types.h> regardless of USG.
-
-Tue Jan 25 12:58:26 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * valops.c (value_assign): Set `type' after coercing toval.
- * c-valprint.c (c_val_print), ch-valprint.c (chill_val_print):
- Use extract_unsigned_integer to get the address of a reference.
-
-Tue Jan 25 11:31:53 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (STABS_CONTINUE, error_type), partial-stab.h:
- AIX can use ? instead of \ for continuation. Deal with it.
-
- * paread.c (read_unwind_info): Just assign to objfile->obj_private,
- not OBJ_UNWIND_INFO. Assigning to a cast is a GCC-ism which
- the HP compiler in ANSI mode doesn't like.
-
- * main.c: When defaulting HAVE_SIGSETMASK based on USG, just do it
- based on USG, rather than defining HAVE_SIGSETMASK to an
- expression containing defined. Having a macro used in #if expand
- to an expression containing "defined" is undefined according to
- ANSI, and the HP compiler in ANSI mode doesn't do what we wanted
- it to.
-
-Mon Jan 24 20:51:29 1994 John Gilmore (gnu@cygnus.com)
-
- * sparc-nat.c (fetch_inferior_registers, store_inferior_registers):
- Clean up the changes of 11 Jan, as recommended by Peter Schauer.
-
-Fri Jan 21 19:10:44 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * ch-exp.y (match_string_literal): Allow a zero-length string.
- * ch-lang.c (chill_printstr): Don't print zero-length string funny.
-
-Sat Jan 22 17:08:48 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * i386aix-nat.c (i386_float_info): Reverse order of registers before
- passing them to print_387_status.
- (print_387_status): Don't subtract top from 7 before using it.
- * i387-tdep.c: Remove comment about AIX wanting "top" subtracted
- from 7; the above explains it.
-
-Sat Jan 22 20:25:11 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mips-tdep.c (init_extra_frame_info): Use frame relative stack
- pointer value when fixing up the frame at the start of a function.
-
-Sat Jan 22 12:29:13 1994 Stu Grossman (grossman at cygnus.com)
-
- * lynx-nat.c (fetch_core_registers): Load the I & L regs for the
- Sparc from the stack.
-
-Sat Jan 22 08:30:42 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * remote-mips.c (mips_initialize): Clear mips_initializing via
- cleanup chain, not directly.
-
- * ser-unix.c (wait_for) [HAVE_TERMIO, HAVE_TERMIOS]: Make a timeout
- of -1 mean forever, like in the HAVE_SGTTY case. Warn if we are
- munging the timeout due to the limited range of c_cc[VTIME].
-
- * fork-child.c, inferior.h (fork_inferior): New argument shell_file.
- * procfs.c (procfs_create_inferior), inftarg.c (child_create_inferior),
- m3-nat.c (m3_create_inferior): Pass it.
- * procfs.c: Remove ptrace function. It was declared in a way which
- conflicted with the prototype in unistd.h on Solaris.
-
-Sat Jan 22 01:37:40 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * sparc-tdep.c (frame_saved_pc): Get the pc from the saved pc
- in the sigcontext if it is a signal trampoline frame.
- * config/sparc/tm-sun4sol2.h (IN_SIGTRAMP, SIGCONTEXT_PC_OFFSET):
- Define for Solaris2.
-
-Sat Jan 22 00:34:47 1994 Stu Grossman (grossman at cygnus.com)
-
- * sparc-tdep.c, lynx-nat.c, config/sparc/tm-sparc.h,
- config/sparc/tm-sparclynx.h: Move defs of FRAME_SAVED_I0/L0 to
- tm-sparc.h so they can be overridden if necessary.
-
-Fri Jan 21 17:49:28 1994 Stu Grossman (grossman at cygnus.com)
-
- * lynx-nat.c: Add Sparc support.
- * sparcly-nat.c: Remove. It's useless.
- * config/sparc/nm-sparclynx.h: Rewrite.
- * config/sparc/sparclynx.mh (NATDEPFILES): Replace sparcly-nat.o
- with lynx-nat.o
- * config/sparc/tm-sparclynx.h: Rewrite.
-
-Fri Jan 21 19:08:48 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * rs6000-pinsn.c: Use the new disassembler in the opcodes
- directory. Old code was discarded, since the new opcode table has
- a different format.
-
-Fri Jan 21 14:28:30 1994 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (realclean): Remove info files per make-stds.texi.
-
-Fri Jan 21 12:47:53 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dbxread.c (end_psymtab): Only patch psymtab textlow and texthigh
- if N_SO_ADDRESS_MAYBE_MISSING is defined.
- * config/sparc/tm-sun4sol2.h: Define it.
-
-Thu Jan 20 15:04:24 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * printcmd.c (print_address_symbolic): Unconditionally use msymbol
- if we did not find a symbol.
-
-Fri Jan 21 08:20:18 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * infptrace.c (child_xfer_memory): Only use if CHILD_XFER_MEMORY
- is not defined.
-
- * hppab-nat.c (call_ptrace): Delete redundant function.
- (kill_inferior, attach, detach, child_resume): Likewise.
- (child_xfer_memory): Likewise.
-
- * hppah-nat.c (call_ptrace): Delete redundant function.
- (kill_inferior, attach, detach, child_resume): Likewise.
-
- * config/pa/hppabsd.mh (NATDEPFILES): Add infptrace.o.
-
- * config/pa/hppahpux.mh (NATDEPFILES): Add infptrace.o.
-
- * config/pa/nm-hppab.h (FETCH_INFERIOR_REGISTERS): Define.
-
- * config/pa/nm-hppah.h (FETCH_INFERIOR_REGISTERS): define.
- (CHILD_XFER_MEMORY): Define.
- (PT_*): Define so that generic infptrace.c code can be used.
-
-Fri Jan 21 09:23:33 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (xcoff_symfile_read): Make second parameter a
- struct section_offsets *, not a (nonexistent) struct section_offset *.
-
- * xcoffread.c (read_xcoff_symtab): Make main_aux just a union
- internal_xcoff_symtab, not an array of one of them. Change lots of
- "main_aux" to "&main_aux" and so on.
-
- * coffread.c, xcoffread.c: Include <coff/internal.h>
- before "symfile.h".
-
-Thu Jan 20 17:30:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * coffread.c (coff_getfilename): Make it not static.
-
- * xcoffread.c (read_xcoff_symtab): complain() not abort().
-
- * xcoffread.c (struct coff_symbol): Rename c_nsyms to c_naux (removes
- a completely gratuitous difference between xcoffread.c and coffread.c).
-
-Wed Jan 19 15:09:44 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (wait_for_inferior): Don't set frame for
- step_resume_breakpoint for IN_SIGTRAMP cases.
-
- * infrun.c (wait_for_inferior), breakpoint.h (struct bpstat_what),
- breakpoint.c (bpstat_what): Move step_resume from its own field of
- the struct bpstat_what into the main_action. Make it override
- other breakpoints. This is a conservative change in the sense
- that before the step resume breakpoint was a breakpoint.c
- breakpoint, hitting the step resume breakpoint overrode even
- calling bpstat_stop_status.
-
-Wed Jan 19 12:40:25 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * infrun.c (normal_stop): Set stop_pc after popping the dummy frame
- in case execution was stopped in the called function.
- * stack.c (print_frame_info, frame_info): If backtracing through
- a call dummy, handle the starting source line number on a line
- boundary like backtracing through sigtramp.
- * sparc-tdep.c (sparc_frame_find_saved_regs): Get frame address
- for call dummy frame right. Remove old test for dummy frame,
- it has been unused at least since gdb-3.5.
- * sparc-tdep.c (sparc_push_dummy_frame): Set return address register
- of the dummy frame.
-
-Tue Jan 18 16:16:35 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infcmd.c (signal_command): Accept 0 as legitimate signal number.
-
-Tue Jan 18 14:09:25 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * infrun.c (signals_info), target.c (target_signal_from_name):
- Use ugly casts to avoid enumvar < enumvar or enumvar++.
-
-Mon Jan 17 22:00:15 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * ser-unix.c (hardwire_noflush_set_tty_state): Don't muck with ICANON.
- * inflow.c (terminal_ours_1): When discussing how to deal with the
- tty state, make note of query() as well as readline.
-
- * infrun.c (_initialize_infrun): Add TARGET_SIGNAL_POLL to list of
- signals for which stop and print are cleared by default.
-
-Mon Jan 17 20:00:51 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * config/pa/tm-hppa.h (unwind_table_entry): Use one of the
- reserved fields to hold a stub unwind entry type. Fix typo.
- (stub_unwind_entry): New structure for raw stub unwind entries.
- (stub_unwind_types): The types of stubs we may encounter.
- (UNWIND_ENTRY_SIZE, STUB_UNWIND_ENTRY_SIZE): New defines.
- * hppa-tdep.c (rp_saved): Use additional information provided
- by linker stub unwind descriptors.
- (frameless_function_invocation): Likewise.
- (frame_chain_valid): Likewise.
- * paread.c (compare_unwind_entries): New function for sorting
- unwind table entries.
- (read_unwind_info): Rewrite to remove dependency on host endianness.
- Read in data from the $UNWIND_END$ subspace which contains linker
- stub unwind descriptors. Merge that data into the basic unwind
- table.
-
- * hppab-nat.c (_initialize_kernel_u_addr): Delete unwanted functions.
-
-Mon Jan 17 22:00:15 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab, case C_FILE): Accept the name
- from either the symbol name or the auxent.
- * coffread.c, symfile.h (coff_getfilename): Renamed from getfilename,
- no longer static.
-
-Mon Jan 17 13:35:01 1994 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (ALLPARAM): Change irix5.h to nm-irix5.h.
-
-Mon Jan 17 12:35:42 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * README: Update notes for alpha port.
-
-Mon Jan 17 11:15:57 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * i960-tdep.c (i960_fault_to_signal): Return TARGET_SIGNAL_ILL
- for operation fault, constraint fault, and type fault.
-
-Sun Jan 16 12:46:01 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (init.c): Add comment explaining formatting conventions.
-
- * c-exp.y (parse_number): Assign to temporary between the right
- shifts, to work around a bug in the SCO compiler.
-
- * Makefile.in (ALLCONFIG, ALLPARAM, ALLDEPFILES, HFILES_NO_SRCDIR):
- Add various files which were added to GDB recently.
-
- * xcoffread.c (process_xcoff_symbol): Only change 'V' to 'S' if not
- within_function.
-
- * Makefile.in: Add mostlyclean target.
-
-Sat Jan 15 10:20:13 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Version 4.11.4.
-
-Sat Jan 15 18:27:34 1994 Per Bothner (bothner@kalessin.cygnus.com)
-
- * main.c (show_commands): Make return type of extern
- history_get be HIST_ENTRY, rather than struct _hist_entry.
- (The latter loses with the upcoming merged readline.)
-
-Sat Jan 15 10:20:13 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * minsyms.c (prim_record_minimal_symbol_and_info): Make tempstring
- const char *, not char *.
-
- * symtab.h (struct symbol): Make section short, not unsigned short.
-
- * symtab.c (lookup_symbol): Add comment about QUIT here.
-
- * utils.c (fputs_unfiltered): Call fputs, not fputs_maybe_filtered.
-
- * c-exp.y (parse_number): Check for overflow regardless of range
- checking. Fix overflow check to use unsigned LONGEST, not
- unsigned int.
-
- * c-exp.y (parse_number): Make it so that integer constants are
- builtin_type_long_long if builtin_type_long isn't big enough or if
- an "LL" suffix is used. Properly handle "UL" or "LU" suffixes.
-
- * c-typeprint.c (c_type_print_varspec_suffix, case TYPE_CODE_FUNC):
- Print our "()" first, then recurse for the target type.
-
-Fri Jan 14 21:55:39 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-udi.c (udi_create_inferior): Quote empty execfile argument.
-
- * gdbserver/low-lynx.c: Include <sys/wait.h> not "/usr/include/wait.h".
-
-Fri Jan 14 14:17:06 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * utils.c (request_quit): Re-establish signal handler regardless
- of USG.
-
- * config/mips/xm-irix4.h: Define HAVE_TERMIOS.
-
-Fri Jan 14 21:55:39 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * i960-tdep.c: Include target.h.
-
-Fri Jan 14 17:12:28 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * lynx-nat.c (sys/wait.h): Don't use absolute pathname.
-
-Fri Jan 14 11:06:10 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * lynx-nat.c (child_wait): Fix thinkos in struct target_waitstatus
- changes (status -> ourstatus; declare status, etc.).
- * config/nm-lynx.h: Fix child_wait prototype and include target.h.
-
-Fri Jan 14 14:17:06 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (ALLPARAM): Add config/nm-lynx.h.
-
-Fri Jan 14 11:49:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * remote-mips.c (mips_request, mips_wait): Correct prototypes.
-
-Fri Jan 14 11:37:17 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/i386/xm-linux.h: Define HAVE_TERMIOS.
-
-Fri Jan 14 01:04:36 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/alpha/tm-alpha.h (CALL_DUMMY): Improve comment.
-
-Thu Jan 13 10:32:38 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote-vx.c (vx_wait): Only call i960_fault_to_signal if I80960
- is defined. Otherwise just report TARGET_SIGNAL_UNKNOWN.
-
- * mips-tdep.c (mips_push_arguments): Byteswap struct_addr before
- writing it.
-
- Add search to target vector (#if 0'd until after 4.12):
- * target.h (to_search, target_search): Add.
- * gdbcore.h, core.c (generic_search): Add.
- * remote.c (remote_search): Add.
- * a29k-tdep.c (init_frame_info): Use target_search to find traceback
- tag.
-
- * printcmd.c (print_address_symbolic): If set print fast-symbolic-addr
- is on, call find_pc_function rather than relying just on the minimal
- symbols (probably only matters for symbol readers which don't put
- statics in the minimal symbols, but changing this strikes me as
- not conservative enough).
- Initialize name_location in all cases.
- If no symbol and no msymbol, don't print anything symbolic.
-
- * a29k-tdep.c (push_dummy_frame): Add comment about saving lr0.
-
-Wed Jan 12 20:53:16 1994 John Gilmore (gnu@cygnus.com)
-
- * printcmd.c (print_address_symbolic): Make it search the
- symtabs for variables as well as functions. Add `set print
- fast-symbolic-addr' and default it to fast (the old way).
- Print line numbers for data items as well as functions.
-
- * symtab.c (find_addr_symbol): Return the symtab and the symbol
- address, if a symbol is found (take two more args pointing to
- where to store these results).
-
- * symtab.h (find_addr_symbol): Add prototype.
-
-Wed Jan 12 19:32:11 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * objfiles.h: Fix comments to reflect the fact that the phrase
- "top of stack" always refers to where the pushing and popping takes
- place, regardless of whether it is at the highest or lowest address.
-
-Wed Jan 12 13:23:37 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (parse_symbol): Do not set TYPE_TAG_NAME for
- compiler generated tag names.
- * mdebugread.c (parse_type): Handle cross references to qualified
- aggregate types.
- * valops.c (value_struct_elt): Improve error message if the
- address of a method is requested from an object instance.
- * valops.c (search_struct_method): Make name_matched non-static
- to get it initialized correctly.
- * config/i386/nm-i386sco.h (CANNOT_STORE_REGISTER): Define to
- exclude segment register which are not writable on newer SCO versions.
-
-Wed Jan 12 14:44:45 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * go32-xdep.c: Remove unused function uerror.
- (sigsetmask): Declare return type. Declare argument (to match the
- way it is called). Explicitly return 0.
-
-Wed Jan 12 01:44:25 1994 John Gilmore (gnu@cygnus.com)
-
- * symtab.h (struct symbol, general_symbol_info, minimal_symbol,
- partial_symbol): Shrink the storage sizes of symbols, by making
- enums into 1-byte bitfields when compiled __GNUC__, moving all the
- enums and small ints to the end of each struct to improve
- alignment, and switching the section number from int to unsigned
- short.
-
-Wed Jan 12 00:16:26 1994 John Gilmore (gnu@cygnus.com)
-
- * symtab.c (find_addr_symbol): New routine that will find the nearest
- symbol associated with an address. It does so by exhaustive
- search of the symtabs, so it's slow but complete.
-
-Tue Jan 11 23:57:30 1994 John Gilmore (gnu@cygnus.com)
-
- * coffread.c (read_coff_symtab): Set PC bounds of _globals_ symtab
- to [0,0] rather than [0, end of first source file]. This avoids
- problems with other parts of GDB looking for linetables in the
- _globals_ symtab. Eliminate variables num_object_files and
- first_object_file_end.
-
-Tue Jan 11 00:53:46 1994 John Gilmore (gnu@cygnus.com)
-
- * a29k-tdep.c (init_frame_info): Cast null arg to examine_tag.
- (pop_frame): Restore PC2 and LR0 from dummy frames.
- (push_dummy_frame): Save PC2 and LR0 into dummy frames.
- (setup_arbitrary_frame): Handle 3 args and set up real frames.
- * config/a29k/tm-a29k.h (FRAME_NUM_ARGS): Update comments.
- (DUMMY_FRAME_RSIZE): Add 2 longwords for PC2 and LR0.
- (SETUP_ARBITRARY_FRAME): Define.
-
-Tue Jan 11 06:59:10 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * infrun.c, config/mips/tm-irix5.h: Remove #if 0'd AT_FUNCTION_START.
-
-Tue Jan 11 14:27:03 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * remote-udi.c (udi_resume): Correct prototype.
-
-Tue Jan 11 11:10:30 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
-
- * config/pa/tm-hppa.h (FRAME_FIND_SAVED_REGS): Call
- hppa_frame_find_saved_regs.
- * hppa-tdep.c (dig_fp_from_stack): Delete function.
- (prologue_inst_adjust_sp): New function.
- (is_branch, inst_saves_gr, inst_saves_fr): New functions.
- (skip_prologue): Completely rewrite to use unwind information.
- (hppa_frame_find_saved_regs): Likewise.
-
-Tue Jan 11 06:59:10 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * remote-mips.c (mips_wait): Use new function mips_signal_from_protocol
- to convert a signal number with appropriate bounds checking.
-
- * remote-mips.c (mips_wait): Fix typos (0x177 -> 0177, 0x377 -> 0377).
-
-Tue Jan 11 00:53:46 1994 John Gilmore (gnu@cygnus.com)
-
- * stack.c (frame_info): If FRAME_FIND_SAVED_REGS isn't defined,
- print a newline to end the display anyway.
-
- * sparc-tdep.c (sparc_pop_frame): Pop the fsr and csr (float and
- coprocessor status regs) when popping a frame. This fixes
- float exceptions that occur after calling inferior functions.
-
- * sparc-nat.c (fetch_inferior_registers, store_inferior_registers):
- Read and write the fsr (float status register) to/from the child
- process along with the float regs. Remove Peter Schauer's change
- of May 24 '93, which has higher overhead and doesn't solve the
- real problem (which was that FSR wasn't being set).
-
-Mon Jan 10 23:16:42 1994 John Gilmore (gnu@cygnus.com)
-
- * a29k-tdep.c (examine_prologue): Don't worry if the ASGEQ
- stack overflow check isn't right after the register stack
- adjustment instruction. Metaware R2.3u compiler moves other
- things in front of it. This fix isn't perfect but is what's
- running.
-
-Mon Jan 10 20:08:23 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * c-valprint.c (c_val_print): Treat TYPE_CODE_RANGE like TYPE_CODE_INT.
-
- * config/alpha/alpha-netware.mt: Rename to alpha-nw.mt for 14
- character filenames.
- * configure.in: Change accordingly.
-
-Mon Jan 10 15:48:36 1994 Tom Lord (lord@rtl.cygnus.com)
-
- * m68k-stub.c, sparc-stub.c: removed spurious introduction of
- _filtered io routines from these two files.
-
-Fri Jan 7 12:42:45 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/i386/tm-i386v.h, config/m68k/tm-m68k.h, config/mips/tm-mips.h,
- config/vax/tm-vax.h (CALL_DUMMY_BREAKPOINT_OFFSET): Define.
- * mdebugread.c (parse_symbol): Handle enum sh.type produced by
- DEC c89.
- * mdebugread.c (add_line): Handle zero linenos produced by DEC c89.
-
-Fri Jan 7 12:55:25 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * utils.c (print_sys_errmsg): Call gdb_flush (gdb_stdout) before
- printing to gdb_stderr.
-
- * remote-udi.c (udi_kill): Don't close the connection, just set
- inferior_pid to zero.
- (udi_mourn): Call remove_breakpoints.
-
- * remote-udi.c: Remove obsolete need_artificial_traps comment.
-
- * i386b-nat.c (sregmap): If sEAX, etc., not defined, use tEAX, etc.
-
-Thu Jan 6 07:17:53 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
-
- * symtab.c (lookup_symbol): Don't try adding .c to the name.
-
- * remote-bug.c: At the start of each section, reset srec_frame
- back to 160.
-
- * target.h: Add TARGET_WAITKIND_LOADED and TARGET_WAITKIND_SPURIOUS.
- * target.c (store_waitstatus): Add CHILD_SPECIAL_WAITSTATUS hook.
- * infrun.c (wait_for_inferior): Replace SIGTRAP_STOP_AFTER_LOAD with
- code which looks for those two waitkinds. Use switch statement.
- * config/rs6000/tm-rs6000.h: Replace SIGTRAP_STOP_AFTER_LOAD with
- CHILD_SPECIAL_WAITSTATUS.
-
- * procfs.c (procfs_wait): Fix argument name to match 4 Jan changes.
- * Move target_signal_from_host, target_signal_to_host, and
- store_waitstatus from inftarg.c to target.c. procfs needs them.
- * target.c: Include "wait.h" and <signal.h>.
- * target.h, infrun.c (proceed), proceed callers: Pass new code
- TARGET_SIGNAL_DEFAULT instead of -1. This avoids problems with
- enums being treated as unsigned and is cleaner.
- * infrun.c (signals_info): Don't print TARGET_SIGNAL_DEFAULT or
- TARGET_SIGNAL_0.
- * infcmd.c (signal_command), infrun.c (signals_info):
- Don't allow user to specify numeric equivalent of
- TARGET_SIGNAL_DEFAULT.
-
-Tue Jan 4 15:34:36 1994 Stu Grossman (grossman@cygnus.com)
-
- * config/alpha/alpha-netware.mt: New target support for Alpha
- running Netware.
- * configure.in: Add alpha-*-netware* target.
-
-Tue Jan 4 14:51:35 1994 Stan Shebs (shebs@andros.cygnus.com)
-
- * remote-mips.c (mips_wait): Fix ref to TARGET_WAITKIND_STOPPED.
-
-Tue Jan 4 09:47:14 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * target.h: Add enum target_waitkind, enum target_signal, and
- struct target_waitstatus. Change status argument to target_wait to
- be struct target_waitstatus * instead of int *.
- * target.h, infrun.c, all targets: Change type of signal arguments
- to resume(), proceed(), and target_resume() from int to enum
- target_signal.
- * All targets (*_wait, *_resume): Change accordingly.
- * infcmd.c (program_info, signal_command), throughout infrun.c,
- * fork-child.c, solib.c, hppa-tdep.c, osfsolib.c: Use this stuff.
- * convex-xdep.c, convex-tdep.c: Add FIXME's (getting the Convex
- signal code stuff right with the new signals would be non-trivial).
- * inferior.h (stop_signal): Make it enum target_signal not int.
- * target.c, target.h (target_signal_to_string, target_signal_to_name,
- target_signal_from_name): New functions.
- * inftarg.c, target.h (target_signal_to_host, target_signal_from_host,
- store_waitstatus): New functions.
- * procfs.c (procfs_notice_signals): Use them.
- * i960-tdep.c (i960_fault_to_signal): New function, to replace
- print_fault.
- * config/i960/tm-i960.h: Don't define PRINT_RANDOM_SIGNAL.
-
- * objfiles.c (build_objfile_section_table): Don't abort() if
- objfile->sections is already set.
-
- * objfiles.c (add_to_objfile_sections): Check SEC_ALLOC not SEC_LOAD
- to match recent change to exec.c.
-
- * Version 4.11.3.
-
- * main.c (print_gdb_version): Change year to 1994.
-
- * ChangeLog, ChangeLog-93: Split ChangeLog at 1994.
- * Makefile.in (NONSRC): Add ChangeLog-93.
-
-Mon Jan 3 11:57:29 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * stabsread.c (read_type): Allow defining several type numbers
- at once (e.g. "(1,2)=(3,4)="...).
-
- * stabsread.c (read_enum_type): Use TARGET_INT_BIT not sizeof (int).
-
- * breakpoint.c (frame_in_dummy): Check PC as well as frame.
-
-Mon Jan 3 02:47:03 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (psymtab_to_symtab_1): Only pass N_STAB symbols
- to process_one_symbol.
- * symtab.c (find_pc_psymbol): Search global_psymbols as well to
- avoid caching a bad endaddr in find_pc_partial_function.
-
-Sun Jan 2 21:41:17 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/m68k/tm-sun3.h: Don't define BELIEVE_PCC_PROMOTION.
-
-Sat Jan 1 04:35:23 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * infrun.c (wait_for_inferior): Do not step or step resume past
- the end of a one-line function we just stepped into.
-
-For older changes see ChangeLog-93
-
-Local Variables:
-mode: indented-text
-left-margin: 8
-fill-column: 74
-version-control: never
-End:
diff --git a/contrib/gdb/gdb/ChangeLog-95 b/contrib/gdb/gdb/ChangeLog-95
deleted file mode 100644
index 2265be8..0000000
--- a/contrib/gdb/gdb/ChangeLog-95
+++ /dev/null
@@ -1,4915 +0,0 @@
-Fri Dec 29 16:30:58 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * symfile.c (find_sym_fns): Add PowerMac to xcoff file recognition
- kludge.
-
-Fri Dec 22 11:05:59 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (gdb_host): Add support for DG/UX running on x86 as
- a host.
- (all x86 targets and hosts): Add support for pentium-pro machines.
-
- * configure: Rebuild.
-
- * config/i386/i386dgux.mh: New file for DG/UX running on x86 host.
-
-Thu Dec 21 19:09:20 1995 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * remote-array.c (array_wait): Poll the keyboard along with the
- serial port so users can tpye at the target while their
- application is running.
-
-Thu Dec 21 11:58:52 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in (ppcbug-rom.o, srec.o): Add dependencies.
-
- * monitor.c (monitor_debug): Take prefix, and suffix arguments.
- Print trailing newline after the suffix.
- (monitor_printf{,_noecho}): Change monitor_debug calls.
- (monitor_printf): Call monitor_expect instead of trying to do the
- expect processing locally so that if there is extra junk, it
- doesn't hang things up.
- (readchar): If MO_HANDLE_NL is set, handle \r\n pairs and convert
- them to a single \r. Use monitor_debug to print out byte read.
-
- * monitor.h (MO_HANDLE_NL): Add new flag.
-
- * ppcbug-rom.c (ppcbug_ops{1,2}): Split into two ops, one that
- uses lo 0 to load, and the other that uses lo 1. Set flag
- MO_HANDLE_NL.
- (ppcbug_open{0,1}): Clone and split to handle ppcbug_ops{1,2}.
- (_initialize_ppcbug_rom): Set up both ppcbug_open{0,1}.
-
-Wed Dec 20 10:54:41 1995 Fred Fish <fnf@cygnus.com>
-
- * defs.h: Delete extraneous whitespace at end of file.
- * symfile.h: Move #include of demangle.h outside conditional.
- * objfiles.h (struct objstats, OBJSTAT, OBJSTATS): New struct and
- macros to hold per-objfile statistics for internal
- instrumentation.
- (struct objfile): Add OBJSTATS member, which is optional.
- * buildsym.h (next_symbol_text_func): Now takes objfile argument.
- Also update copyright to 1995.
- * dbxread.c (dbx_next_symbol_text): Now takes objfile argument.
- (dbx_symfile_init, coffstab_build_psymtabs, elfstab_build_psymtabs,
- stabsect_build_psymtabs): Accumulate string table size.
- (dbx_next_symbol_text, read_dbx_symtab, read_ofile_symtab):
- Accumulate number of stabs symbols read.
- * dwarfread.c (new_symbol, symthesize_typedef):
- Accumulate number of full symbols created.
- * gdbtypes.c (alloc_type): Accumulate number of types.
- * maint.c (maintenance_print_statistics): New function.
- * mdebugread.c (mdebug_next_symbol_text): Now takes objfile
- argument.
- * minsyms.c (prim_record_minimal_symbol_and_info): Accumulate
- number of minimal symbols read.
- * os9kread.c (read_os9k_psymtab): next_symbol_text takes objfile
- arg.
- * partial-stab.h: next_symbol_text takes objfile arg.
- * stabsread.c (error_type, STABS_CONTINUE): Now takes objfile arg
- and uses it to call next_symbol_text.
- * symfile.c (add_psymbol_to_list, add_psymbol_addr_to_list):
- Accumulate number of partial symbols created.
- * symfile.h (ADD_PSYMBOL_VT_TO_LIST): Accumulate number of partial
- symbols created.
- * symmisc.c (print_objfile_statistics): Print the per-objfile
- internal instrumentation statistics gathered.
- * xcoffread.c (xcoff_next_symbol_text): Now takes objfile argument.
-
-Fri Dec 15 16:15:55 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * top.c (set_endian_from_file): Use new bfd_big_endian macro.
-
-Fri Dec 15 12:21:10 1995 Raymond Jou <rjou@mexican.cygnus.com>
-
- * mpw-make.sed: Add quotes to RIncludes reference.
-
-Fri Dec 15 13:18:55 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * remote-array.c: Remove bogus setting of baudrate to 4800. Their
- hardware has real UARTS now.
-
-Mon Dec 11 18:19:16 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * configure.in (powerpc-*-macos*): New target configuration.
- * configure: Update.
- * config/powerpc/macos.mh, config/powerpc/macos.mt,
- config/powerpc/nm-macos.h, config/powerpc/tm-macos.h, mac-nat.c:
- New files, native PowerMac debugging support.
- * Makefile.in (mac-nat.o): Add build rule.
- * mpw-config.in (enable_cflags): Add support.
- (m68k-apple-macos, powerpc-apple-macos): Fix natdepfiles to
- list object file instead of source file.
- * mpw-make.sed (@ENABLE_CFLAGS@): Don't edit out, replace with
- value of variable.
- (install, install-only): Edit MPW-specific installation into
- place of Unix shell code.
- * mac-gdb.r: Fix version resources to use symbolic version strings.
- (cfrg): New resource, code fragment for PowerMac.
-
-Mon Dec 11 14:13:03 1995 Fred Fish <fnf@amigalib.com>
-
- * dbxread.c (process_one_symbol): When looking at the next
- minimal symbol, check for end of the minimal symbol array
- (symbol with NULL pointer for name) before dereferencing it.
-
-Mon Dec 11 15:56:55 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * eval.c (evaluate_struct_tuple): Fix thinko.
-
-Mon Dec 11 06:52:02 1995 Wilfried Moser <moser@rtl.cygnus.com>
-
- * ch-typeprint.c (chill_type_print_base): Slightly change of printing
- of variant structures.
-
-Mon Dec 11 00:36:01 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * valops.c (value_cast): Handle casts to and from TYPE_CODE_CHAR.
- * ch-exp.c (match_integer_literal): Fix long long support.
- * gdbtypes.c (get_discrete_bounds): Make TYPE_LENGTH (type) ==
- sizeof (LONGEST) case work OK.
-
-Fri Dec 8 21:02:24 1995 Fred Fish <fnf@cygnus.com>
-
- * coffread.c, dbxread.c, dstread.c, objfiles.c, os9kread.c,
- symfile.c, symtab.c: Use "obstack.h" rather than <obstack.h>.
-
-Wed Dec 6 16:16:18 1995 Stu Grossman (grossman@cirdan.cygnus.com)
-
- * remote-mips.c (mips_receive_header): Allow mips_syn_garbage to be
- user-settable (via set syn-garbage-limit). Setting it to -1 makes
- it unlimited.
-
-Tue Dec 5 18:33:43 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * gdbtypes.c (check_stub_method): Make sure we get back a function
- string in the demangled name before we try to use it.
-
-Tue Dec 5 18:08:29 1995 Stu Grossman (grossman@cygnus.com)
-
- * monitor.c (monitor_expect_regexp): Make static, add prototype.
- * (monitor_read_memory_single): Call monitor_expect_regexp with
- pointer to getmem_resp_delim_pattern, not entire struct.
-
-Tue Dec 5 15:51:25 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * c-lang.h (c_op_print_tab): Don't declare, some compilers
- consider illegal if structure not defined, and only used
- in c-lang.c anyway.
-
-Sun Dec 3 12:31:03 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * eval.c (evaluate_subexp_standard case): Fix typo.
-
-Sun Dec 3 11:59:21 1995 Jeffrey A. Law <law@cygnus.com>
-
- * ch-exp.c (parse_named_record_element): Avoid aggregrate
- initializations for automatic variables.
-
- * hppa-tdep.c (hppa_alignof): Fix typo in last change.
-
-Sat Dec 2 19:32:57 1995 Fred Fish <fnf@cygnus.com>
-
- * symfile.c (global_psymbols, static_psymbols): Remove, unused.
-
-Sat Dec 2 03:02:21 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * alpha-tdep.c (heuristic_proc_desc): Add heuristic to
- determine the return address register, needed for OSF/1-3.2C.
- * config/alpha/tm-alpha.h (T7_REGNUM, T9_REGNUM): Define.
-
-Fri Dec 1 07:23:57 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * ppcbug-rom.c (ppcbug_cmds): Turn on MO_GETMEM_READ_SINGLE
- because PPCbug displays the memory as characters as well as hex.
- Fix getmem/setmem commands.
-
- * srec.c (load_srec): Fix off by one typo in last submission.
-
- * rs6000-tdep.c (push_arguments): Fix typo.
-
-Thu Nov 30 23:54:17 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * language.c (lang_bool_type), language.h: New function.
- * language.h (LA_BOOL_TYPE): New macro.
- * eval.c (evaluate_subexp_standard) Use LA_BOOL_TYPE instead
- of builtin_type_int where appropriate,
- * valarith.c (value_subscript): Likewise.
-
- * valops.c (value_slice): Implement (value) bitstring slices.
- * valprint.c (val_print): If TYPE_LENGTH is zero, don't automatically
- print "<incomplete type>" - Chill has zero-length (string) types.
-
- * gdbtypes.c (check_stub_type): Removed; no longes needed.
- * ch-exp.c (expect, parse_call): Tweak error messages.
-
-Wed Nov 29 13:35:18 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * scm-valprint.c (scm_isymnames): Remove "#@" prefix.
- (scm_scmval_print): Do not print "#@" prefix.
-
- * gdbtypes.h (enum type_code): Added TYPE_CODE_TYPEDEF.
- (check_typedef): New prototype.
- (CHECK_TYPEDEF): New macro.
- (TYPE_DUMMY_RANGE): Removed.
- * gdbtypes.c (get_discrete_bounds): Fix paren error; make more robust.
- (create_array_type): Don't force_to_range_type; users of the
- array are responsible for handling non-range index types.
- (create_set_type): Likewise.
- (force_to_range_type): Removed.
- (check_typedef): New function handles stub types and typedefs.
- (check_stub_type): Just call check_typedef. (To be removed.)
- (recursive_dump_type): Handle TYPE_CODE_TYPEDEF.
- * ch-lang.c (type_lower_upper): Use get_discrete_bounds.
- (evaluate_subexp_chill): Handle string repetition.
- Re-arrange to handle EVAL_AVOID_SIDE_EFFECTS better.
- * ch-typeprint.c (chill_type_print_base): Handle TYPE_CODE_TYPEDEF.
- Pass show=0 in recursive calls various places.
- (case TYPE_CODE_ARRAY): Don't require index type to have
- TYPE_CODE_RANGE.
- (case TYPE_CODE_RANGE): Don't need to support TYPE_DUMMY_RANGE.
- * gdbtypes.c, ch-lang.c, ch-typeprint.c (numerous places):
- Add check_typedef/CHECK_TYPEDEF as needed.
-
- * ch-exp.y: Replaced by ...
- * ch-exp.c: New file. Use recursive-descent.
- Recognize labelled array tuples and powerset ranges.
- * Makefile.in: Update for no longer using yacc for ch-exp.
-
- * c-lang.c: Make various functions non-static.
- * c-lang.h: Add bunches of prototypes.
- * cp-valprint.c (cp_print_value_fields): Also take address.
- (cp_print_value): Likewise. Use baselcass_offset.
- * stabsread.c (current_symbol): New static variable.
- (type_synonym_name): Remove.
- (read_type): If copying, make copy be a TYPE_CODE_TYPEDEF.
- (read_array_type): Don't need to handle undefined element type here.
- (cleanup_undefined_types): Ditto.
- (read_range_type): Look for Chill ranges.
- * valops.c (value_assign): Fix case lval_internalvar - don't try
- to assign into old value (which might be too small!).
- (value_coerce_array): No longer need special VALUE_REPEATED handling.
- (value_arg_coerce): Cleaner array->pointer decay mechanism.
- (search_struct_field): Use baseclass_offset rather than
- baseclass_addr.
- (value_slice): Use get_discrete_bounds.
- * value.h (COERCE_VARYING_ARRAY): Take type argumnt as well.
- * values.c (baseclass_offset): Change parameter interface.
- (baseclass_addr): Removed.
- * c-typeprint.c, c-valprint.c, ch-valprint.c, values.c, valops.c:
- Add check_typedef/CHECK_TYPEDEF as needed.
-
- * alpha-tdep.c, c-exp.y, h8500-tdep.c, f-exp.y, f-valprint.c,
- findvar.c, hppa-tdep.c, infcmd.c, language.c, printcmd.c,
- rs6000-tdep.c, symmisc.c, symtab.c, mdebugread.c:
- Add check_typedef/CHECK_TYPEDEF as needed.
-
- * f-typeprint.c, valarith.c, valprint.c, typeprint.c, eval.c:
- Add check_typedef/CHECK_TYPEDEF as needed.
- * f-typeprint.c: Various cleaning up.
- * valarith.c (value_subscript): Also subscript bitstrings (for Chill).
- * typeprint.c (print_type_scalar): Also support TYPE_CODE_RANGE.
- * eval.c (evaluate_subexp_standard case OP_ARRAY): Implement
- support for labelled array tuples and ranges in powerset tuples.
- (init_array_element): New function.
-
- * top.c (command_line_input): Only strip out an initial #-comment.
- Looking for internal comments is language-specific (breaks Scheme).
-
- * expression.h (enum exp_opcode): Add BINOP_RANGE.
- * expprint.c (dump_expression): Support BINOP_RANGE.
- * eval.c (evaluate_subexp_standard): Handle BINOP_RANGE (as error).
- (case MULTI_SUBSCRIPT): Fix broken f77 value->int ad hoc conversion.
- * ch-lang.c (chill_op_print_tab): Support BINOP_RANGE.
- (evaluate_subexp_chill): Error on BINOP_COMMA.
-
- * Makefile.in: Clean up so doc stuff stays in doc sub-dir.
-
-Wed Nov 29 16:39:50 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * monitor.c (monitor_debug): New function to print monitor debug
- output in printable fashion.
- (monitor_printf{,_noecho}): Call monitor_debug instead of
- fputs_unfiltered.
-
- * srec.c (load_srec): When printing srec debug information, do not
- print the carriage return directly, instead print \\r followed by
- a newline.
-
-Tue Nov 28 15:25:28 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * Makefile.in (target_subdir): Define.
- (CC_FOR_TARGET, CXX_FOR_TARGET): Use it to find target libraries.
- * configure.in (X_CFLAGS): Fix typo.
- (target_subdir): Set to "${target_alias}/" if cross.
- * configure: Regenerated.
-
- * dbxread.c (dbx_symfile_read): Set block_address_function_relative
- for `pe' format files.
-
-Tue Nov 28 11:17:47 1995 Fred Fish <fnf@cygnus.com>
-
- * magic.h: Renamed to gmagic.h to avoid <magic.h> conflict.
- * magic.c: Renamed to gmagic.c in sympathy.
- * eval.c, gmagic.c, config/tm-magic.h:
- Include "gmagic.h" rather than "magic.h".
-
-Sat Nov 25 02:56:38 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (handle_psymbol_enumerators, parse_symbol):
- Recognize enums from alpha cc -migrate.
- (upgrade_type): Pass correct fd to parse_symbol when parsing
- the index type of an array.
- (parse_procedure, parse_lines, psymtab_to_symtab_1): Handle
- unsorted procedure descriptors from Irix 5.x and Alpha OSF/1-3.x
- shared libraries. Use CORE_ADDR instead of `unsigned long' in
- procedure descriptor address computations.
-
- * symtab.c (decode_line_1): Prevent accidental strchr match
- of a null character with the terminating null character of
- gdb_completer_quote_characters.
- (cplusplus_hint): Make sure that only a single quote is printed
- in the hint message.
-
-Fri Nov 24 16:17:01 1995 Jeffrey A Law (law@cygnus.com)
-
- * top.c (recurse_read_control_structure): Don't make cleanups
- here. Callers handle that correctly.
-
-Tue Nov 21 15:16:34 1995 Fred Fish <fnf@rtl.cygnus.com>
-
- * config/m68k/xm-hp300hpux.h: Define MMAP_BASE_ADDRESS and MMAP_INCREMENT.
- Also force HAVE_MMAP to be defined since autoconf is currently broken
- for detecting a working mmap under hpux.
- * config/pa/xm-hppah.h (MMAP_BASE_ADDRESS): Tweak MMAP_BASE_ADDRESS
- to a better value suggested by Jeffrey A Law (law@cygnus.com).
-
-Tue Nov 21 08:48:58 1995 Fred Fish <fnf@cygnus.com>
-
- * config/pa/xm-hppah.h: Define MMAP_BASE_ADDRESS and MMAP_INCREMENT.
- Also force HAVE_MMAP to be defined since autoconf is currently broken
- for detecting a working mmap under hpux.
- * objfiles.c (map_to_address): Have gdb print a warning when it
- is compiled with HAVE_MMAP but without both MMAP_BASE_ADDRESS and
- MMAP_INCREMENT defined (thus making it appear mmap doesn't work).
-
-Mon Nov 20 14:13:53 1995 Stu Grossman (grossman@cygnus.com)
-
- * infrun.c (wait_for_inferior): Add support for dynamic function
- trampolines. These are pieces of code between the caller and the
- callee that figure out the address of the callee's code at run
- time. Upon entry, we can't figure out the callee's address, so we
- set a breakpoint within the trampoline where the address will be
- known, and continue the target. Once we hit the breakpoint, we
- break at the callee's address and proceed as usual.
-
-Mon Nov 20 11:12:34 1995 Fred Fish <fnf@cygnus.com>
-
- * objfiles.c (allocate_objfile): Change warning message about mapped
- symbol tables so that it is obvious that they are not supported on
- this particular machine rather than implying they are not supported
- at all in this version of gdb.
-
-Sun Nov 19 05:20:53 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * irix5-nat.c, osfsolib.c (solib_address): Return the name of the
- containing solib.
- * stack.c (print_frame_info): Use minimal symbol only if
- fi->pc is in a known section.
-
-Sat Nov 18 11:19:35 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
-
- * solib.c (solib_address): Return the name of the containing solib.
- * solib.h (PC_SOLIB): New macro; define using solib_address.
- * stack.c (print_frame_info) [PC_SOLIB]: If no function name, try
- PC_SOLIB on the PC value.
-
-Sat Nov 18 04:09:31 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * annotate.c (annotate_source, annotate_frame_begin): Issue
- `0x' prefix for the pc value, to remain consistent with previous
- GDB versions.
-
- * blockframe.c (find_pc_partial_function), config/pa/tm-hppa.h:
- Remove Sun shared library transfer hack and
- INHIBIT_SUNSOLIB_TRANSFER_TABLE_HACK, it is obsoleted by the
- mst_solib_trampoline minimal symbols.
-
- * blockframe.c (inside_main_func): Check main_func_*pc against
- INVALID_ENTRY_*PC, not zero.
- * symfile.c (init_entry_point_info): Initialize ei.*pc with
- INVALID_ENTRY_*PC.
- * mipsread.c (mipscoff_symfile_read): If the entry_file bounds
- are still unknown after processing the partial symbols, then try
- to set them from the minimal symbols.
-
- * infcmd.c (registers_info): Error out if selected_frame is NULL.
- * stack.c (return_command): Select new current frame silently if
- not interactive.
-
- * mipsread.c (read_alphacoff_dynamic_symtab): Ignore additional
- DT_MIPS_LOCAL_GOTNO and DT_MIPS_GOTSYM entries.
-
- * irix5-nat.c (solib_create_inferior_hook): Call solib_add only
- if auto_solib_add_at_startup is nonzero.
- (_initialize_solib): Add "set auto-solib-add" command.
- * osfsolib.c (solib_create_inferior_hook): Call solib_add only
- if auto_solib_add_at_startup is nonzero.
- (_initialize_solib): Add "set auto-solib-add" command.
-
-Wed Nov 15 17:12:04 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * utils.c: Don't include sys/ioctl.h etc if MPW is host.
-
-Tue Nov 14 17:16:46 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * config/arm/tm-arm.h (ADDITIONAL_REGISTER_NAMES): Fix r5.
- (FRAME_SAVED_PC): Minor clean up.
-
-Tue Nov 14 14:51:05 1995 Stu Grossman (grossman@cygnus.com)
-
- * monitor.c (monitor_load_srec monitor_make_srec): Move all
- S-record download code into srec.c.
- * srec.c srec.h: New files. Contain S-record loading routines
- formerly in monitor.c.
- * serial.c serial.h: New routine just like fprintf, but uses
- serial_t instead of FILE *.
- * sh-tdep.c (frame_find_saved_regs init_extra_frame_info):
- Don't add four to saved pc (makes things match manual). Also, fix
- bug where we didn't get pc from stack frame correctly.
- * config/sh/tm-sh.h (SAVED_PC_AFTER_CALL): Don't add four to
- saved pc. Real hardware does this for you.
- * sh3-rom.c (sh3_load): New routine. Sets up for download then
- calls generic S-record loader.
- * config/h8300/h8300.mt, config/h8500/h8500.mt,
- config/m68k/monitor.mt, config/pa/hppapro.mt, config/sh/sh.mt:
- Add srec.o to TDEPFILES.
-
-Tue Nov 14 15:57:36 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * ppcbug-rom.c: New file to support the Motorola PPCBUG monitor
- for PowerPC's.
-
- * config/powerpc/ppc{,le}-{eabi,sim}.mt (TDEPFILES): Include
- ppcbug-rom.o, monitor.o, and srec.o
-
- * config/i386/linux.mt (XDEPFILES): Include ser-tcp.o.
-
-Mon Nov 13 13:12:46 1995 Jeffrey A Law (law@cygnus.com)
-
- * partial-stab.h: Remove GDB_TARGET_IS_HPPA kludge.
-
-Fri Nov 10 13:08:54 1995 Jeff Law (law@kahlua.cs.utah.edu)
-
- * terminal.h (HAVE_SGTTY): Fix typo.
-
-Thu Nov 9 17:34:01 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (gdb_target): Build in the simulator for all
- PowerPC eabi targets, not just eabisim, providing
- --enable-sim-powerpc is used, or the host compiler is GCC.
-
-Thu Nov 9 14:04:05 1995 Raymond Jou (rjou@mexican.cygnus.com)
-
- * mpw-config.in: Add variable with names of SIOW libraries.
- * mpw-make.sed: Add an action to build SIOWgdb.
-
-Wed Nov 8 19:25:22 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-make.sed: Edit @ENABLE_CFLAGS@ out, mpw-configure can
- add back in if necessary.
-
-Wed Nov 8 15:59:52 1995 James G. Smith <jsmith@pasanda.cygnus.co.uk>
-
- * config/mips/vr4300.mt: Added simulator to default VR4300 build.
-
-Tue Nov 7 16:02:25 1995 Stu Grossman (grossman@cygnus.com)
-
- * remote-mips.c (mips_initialize): Fix brain damage found by
- Jamie. Basically had case statement in the wrong place...
- * (mips_load): Remove unnecessary `db tty0' command. It's all
- handled by mips_initialize now.
-
-Tue Nov 7 12:59:14 1995 Raymond Jou <rjou@mexican.cygnus.com>
-
- * mac-gdb.r: Added #ifdef Macgdb.
-
-Tue Nov 7 14:59:51 1995 James G. Smith <jsmith@pasanda.cygnus.co.uk>
-
- * remote-mips.c (mips_initialize): Updated to talk to VR4300 RISQ
- monitor board.
-
-Mon Nov 6 11:44:11 1995 James G. Smith <jsmith@pasanda.cygnus.co.uk>
-
- * config/mips/{tm-vr4300.h tm-vr4300el.h} (TARGET_MONITOR_PROMPT):
- Change into real strings.
-
- * remote-sim.c (gdbsim_open): Moved sim_open() call to after
- callback initialisation.
-
-Sun Nov 5 00:07:52 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (AC_CHECK_HEADERS): add stddef.h.
-
-Fri Nov 3 12:30:43 1995 Fred Fish <fnf@cygnus.com>
-
- * Makefile.in (COMMON_OBS): Use corefile.o rather than core.o
- * core.c: Rename to corefile.c.
- * config/pyr/tm-pyr.h, umax-xdep.c, sun386-nat.c, pyr-xdep.c,
- Makefile.in (SFILES), gould-xdep.c, coredep.c, armtdep.c,
- arm-xdep.c, altos-xdep.c: Change core.c references to corefile.c.
-
- From Graham Stoney <greyham@research.canon.oz.au>.
- * Makefile.in (remote-array.o): Add rule to build.
- (ALLDEPFILES): Add remote-array.c
- * remote-array.c (baud_rate): Remove unnecessary declaration.
- (baudrate): Remove.
- (array_files_info): Print global baud_rate not baudrate.
-
-Sat Nov 4 10:21:58 1995 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in (INTERNAL_CFLAGS): Add ENABLE_CFLAGS.
- * fork-child.c (fork_inferior): Add call to
- TARGET_CREATE_INFERIOR_HOOK to allow target specific code to get
- control just before the new process executes it's first instruction.
- * remote-mips.c (mips_initialize): Cleanup a bit. Don't try to
- receive a packet at first. This speeds up initialization a lot.
- Use TARGET_MONITOR_PROMPT instead of "<IDT>".
- (common_breakpoint): Use rresponse instead of rerrflg to inspect
- error code.
- * symfile.c (syms_from_objfile reread_symbols): Call
- TARGET_SYMFILE_POSTREAD to allow target specific code to get
- control after reading new symbols.
- * target.h: New macros TARGET_SYMFILE_POSTREAD, and
- TARGET_CREATE_INFERIOR_HOOK. See above for descriptions.
- * config/mips/{irix5.mh nm-irix5.h}: Delete nm-irix5.h. Make
- NAT_FILE point directly at ../nm-sysv4.h.
- * config/mips/{mipsm3.mh nm-m3.h}: Delete nm-m3.h. Make
- NAT_FILE point directly at ../nm-m3.h.
- * config/mips/{mipsv4.mh nm-sysv4.h}: Delete nm-sysv4.h. Make
- NAT_FILE point directly at ../nm-sysv4.h.
- * config/mips/nm-mips.h: Improve comment at top of file.
- * config/mips/tm-mips.h (TARGET_MONITOR_PROMPT): Change
- definition into a proper string.
-
-Wed Nov 1 20:18:08 1995 Fred Fish <fnf@cygnus.com>
-
- * config/i386/tm-i386.h: New file containing generic i*86 target
- definitions.
- (TARGET_BYTE_ORDER): Moved here from tm-i386v.h.
- (IEEE_FLOAT): Moved here from tm-i386v.h.
- (START_INFERIOR_TRAPS_EXPECTED): Define default as 2.
- (FUNCTION_START_OFFSET): Moved here from tm-i386v.h.
- (SKIP_PROLOGUE): Moved here from tm-i386v.h.
- (SAVED_PC_AFTER_CALL): Moved here from tm-i386v.h.
- (INNER_THAN): Moved here from tm-i386v.h.
- (BREAKPOINT): Moved here from tm-i386v.h.
- (DECR_PC_AFTER_BREAK): Moved here from tm-i386v.h.
- (ABOUT_TO_RETURN): Moved here from tm-i386v.h.
- (REGISTER_SIZE): Moved here from tm-i386v.h.
- (NUM_REGS): Moved here from tm-i386v.h.
- (REGISTER_NAMES): Moved here from tm-i386v.h.
- (EXTRACT_STRUCT_VALUE_ADDRESS): Moved here from tm-i386v.h.
- (FP_REGNUM): Moved here from tm-i386v.h.
- (SP_REGNUM): Moved here from tm-i386v.h.
- (PC_REGNUM): Moved here from tm-i386v.h.
- (PS_REGNUM): Moved here from tm-i386v.h.
- (FP0_REGNUM): Moved here from tm-i386aix.h.
- (FPC_REGNUM): Moved here from tm-sun386.h.
- (REGISTER_BYTES): Moved here from tm-i386aix.h.
- (REGISTER_BYTE): Moved here from tm-i386aix.h.
- (REGISTER_RAW_SIZE): Moved here from tm-i386aix.h.
- (MAX_REGISTER_RAW_SIZE): Moved here from tm-i386aix.h.
- (REGISTER_VIRTUAL_SIZE): Moved here from tm-i386aix.h.
- (MAX_REGISTER_VIRTUAL_SIZE): Moved here from tm-i386aix.h.
- (EXTRACT_RETURN_VALUE): Moved here from tm-i386aix.h.
- (STORE_RETURN_VALUE): Moved here from tm-i386aix.h.
- (REGISTER_VIRTUAL_TYPE): Moved here from tm-i386v.h.
- (STORE_STRUCT_RETURN): Moved here from tm-i386v.h.
- (FRAME_CHAIN): Moved here from tm-i386v4.h.
- (FRAMELESS_FUNCTION_INVOCATION): Moved here from tm-i386v4.h.
- (FRAME_SAVED_PC): Moved here from tm-i386os9k.h
- (FRAME_ARGS_ADDRESS): Moved here from tm-i386v.h.
- (FRAME_LOCALS_ADDRESS): Moved here from tm-i386v.h.
- (FRAME_NUM_ARGS): Moved here from tm-i386sun.h.
- (FRAME_ARGS_SKIP): Moved here from tm-i386v.h.
- (FRAME_FIND_SAVED_REGS): Moved here from tm-i386v.h.
- (PUSH_DUMMY_FRAME): Moved here from tm-i386v.h.
- (POP_FRAME): Moved here from tm-i386v.h.
- (CALL_DUMMY, CALL_DUMMY_LENGTH, CALL_DUMMY_START_OFFSET,
- CALL_DUMMY_BREAKPOINT_OFFSET, FIX_CALL_DUMMY): Moved here from
- tm-i386v.h
- (print_387_control_word, print_387_status_word): Declare prototypes.
- (struct frame_info, struct frame_saved_regs): Forward decls for
- prototypes.
- (SP_ARG0): Moved here from tm-i386v.h.
-
- * config/i386/tm-i386v.h:
- (i386/tm-i386.h): Include.
- (TARGET_BYTE_ORDER): Remove.
- (IEEE_FLOAT): Remove.
- (START_INFERIOR_TRAPS_EXPECTED): Undef before redefine to 4.
- (FUNCTION_START_OFFSET): Remove.
- (SKIP_PROLOGUE): Remove.
- (i386_skip_prologue): Remove prototype.
- (SAVED_PC_AFTER_CALL): Remove.
- (INNER_THAN): Remove.
- (BREAKPOINT): Remove.
- (DECR_PC_AFTER_BREAK): Remove.
- (ABOUT_TO_RETURN): Remove.
- (REGISTER_SIZE): Remove.
- (NUM_REGS): Undef before redefine to 16 (no FP support).
- (REGISTER_NAMES): Undef before redefine.
- (FP_REGNUM, SP_REGNUM, PC_REGNUM, PS_REGNUM): Remove.
- (REGISTER_BYTES): Undef before redefine.
- (REGISTER_BYTE): Undef before redefine.
- (REGISTER_RAW_SIZE): Undef before redefine.
- (REGISTER_VIRTUAL_SIZE): Undef before redefine.
- (MAX_REGISTER_RAW_SIZE): Undef before redefine.
- (MAX_REGISTER_VIRTUAL_SIZE): Undef before redefine.
- (REGISTER_VIRTUAL_TYPE): Undef before redefine.
- (STORE_STRUCT_RETURN): Undef before redefine.
- (EXTRACT_RETURN_VALUE): Undef before redefine.
- (STORE_RETURN_VALUE): Undef before redefine.
- (EXTRACT_STRUCT_VALUE_ADDRESS): Remove.
- (FRAME_CHAIN): Undef before redefine.
- (FRAMELESS_FUNCTION_INVOCATION): Undef before redefine.
- (FRAME_SAVED_PC): Undef before redefine.
- (FRAME_ARGS_ADDRESS): Remove.
- (FRAME_LOCALS_ADDRESS): Remove.
- (FRAME_NUM_ARGS): Undef before redefine.
- (FRAME_ARGS_SKIP): Remove.
- (FRAME_FIND_SAVED_REGS): Remove.
- (PUSH_DUMMY_FRAME): Remove.
- (POP_FRAME): Remove.
- (CALL_DUMMY): Remove.
- (CALL_DUMMY_LENGTH): Remove.
- (CALL_DUMMY_START_OFFSET): Remove.
- (CALL_DUMMY_BREAKPOINT_OFFSET): Remove
- (FIX_CALL_DUMMY): Remove.
- (print_387_control_word): Remove.
- (print_387_status_word): Remove.
- (SP_ARG0): Remove.
-
- * config/i386/tm-symmetry.h:
- (TM_SYMMETRY_H): Enclose file in test for define & define if needed.
- (START_INFERIOR_TRAPS_EXPECTED): Move to after inclusion of
- tm-i386v4.h or tm-i386v.h, #undef, and #define back to 2.
- (DECR_PC_AFTER_BREAK): Move to after inclusion of tm-i386v4.h
- or tm-i386v.h, #undef, and #define to 0.
- (MAX_REGISTER_RAW_SIZE): Remove.
- (FRAME_CHAIN): Remove.
- (FRAMELESS_FUNCTION_INVOCATION): Remove.
- (FRAME_SAVED_PC): Remove.
- (print_387_control_word, print_387_status_word): Remove prototypes.
-
- * config/i386/tm-ptx.h:
- (TM_PTX_H): Enclose file in test for define & define if needed.
- (START_INFERIOR_TRAPS_EXPECTED): Move to after inclusion of
- tm-i386v4.h or tm-i386v.h, #undef, and #define back to 2.
- (DECR_PC_AFTER_BREAK): Move to after inclusion of tm-i386v4.h
- or tm-i386v.h, #undef, and #define to 0.
- (SDB_REG_TO_REGNUM): Remove obsolete commented out define.
- (print_387_control_word, print_387_status_word): Remove prototypes.
-
- * config/i386/tm-linux.h:
- (TM_LINUX_H): Enclose file in test for define & define if needed.
- (i386/tm-i386.h): Include instead of tm-i386v.h.
- (START_INFERIOR_TRAPS_EXPECTED): Remove.
-
- * config/i386/tm-i386v4.h:
- (TM_I386V4_H): Enclose file in test for define & define if needed.
- (i386/tm-i386.h): Include instead of tm-i386v.h.
- (START_INFERIOR_TRAPS_EXPECTED): Remove.
- (FRAME_CHAIN): Moved to tm-i386.h.
- (FRAMELESS_FUNCTION_INVOCATION): Moved to tm-i386.h.
- (FRAME_SAVED_PC): Remove.
- (sigtramp_saved_pc): Define as i386v4_sigtramp_saved_pc.
- (FRAME_NUM_ARGS): Remove.
-
- * config/i386/tm-i386os9k.h:
- (TM_I386OS9K_H): Enclose file in test for define & define if needed.
- (i386/tm-i386.h): Include instead of tm-i386v.h.
- (START_INFERIOR_TRAPS_EXPECTED): Remove.
- (NUM_REGS): Undefine before redefining.
- (FRAME_CHAIN): Remove.
- (FRAMELESS_FUNCTION_INVOCATION): Remove.
- (FRAME_SAVED_PC): Move to tm-i386.h.
-
- * config/i386/tm-i386nw.h:
- (TM_I386NW_H): Enclose file in test for define & define if needed.
- (i386/tm-i386.h): Include instead of tm-i386v.h.
- (START_INFERIOR_TRAPS_EXPECTED): Remove.
-
- * config/i386/tm-i386bsd.h:
- (TM_I386BSD_H): Enclose file in test for define & define if needed.
- (i386/tm-i386.h): Include instead of tm-i386v.h.
- (START_INFERIOR_TRAPS_EXPECTED): Remove.
- (FRAMELESS_FUNCTION_INVOCATION): Remove.
- (FRAME_SAVED_PC): Remove.
-
- * config/i386/tm-i386aix.h:
- (i386/tm-i386.h): Include instead of tm-i386v.h.
- (START_INFERIOR_TRAPS_EXPECTED): Remove.
- (FP_REGNUM): Remove.
- (SP_REGNUM): Remove.
- (PC_REGNUM): Remove.
- (PS_REGNUM): Remove.
- (FP0_REGNUM): Moved to tm-i386.h.
- (NUM_REGS): Remove.
- (REGISTER_NAMES): Remove.
- (REGISTER_BYTES): Moved to tm-i386.h.
- (REGISTER_BYTE): Moved to tm-i386.h.
- (REGISTER_RAW_SIZE): Moved to tm-i386.h.
- (MAX_REGISTER_RAW_SIZE): Moved to tm-i386.h.
- (REGISTER_VIRTUAL_SIZE): Moved to tm-i386.h.
- (REGISTER_VIRTUAL_TYPE): Removed.
- (EXTRACT_RETURN_VALUE): Moved to tm-i386.h.
- (STORE_RETURN_VALUE): Moved to tm-i386.h.
-
- * config/i386/tm-sun386.h:
- (TM_SUN386_H): Enclose file in test for define & define if needed.
- (i386/tm-i386.h): Include.
- (TARGET_BYTE_ORDER): Remove.
- (FUNCTION_START_OFFSET): Remove.
- (SKIP_PROLOGUE): Remove.
- (SAVED_PC_AFTER_CALL): Remove.
- (INNER_THAN): Remove.
- (BREAKPOINT): Remove.
- (DECR_PC_AFTER_BREAK): Remove.
- (ABOUT_TO_RETURN): Remove.
- (REGISTER_SIZE): Remove.
- (NUM_REGS): Undefine before defining.
- (REGISTER_NAMES): Undefine before redefining.
- (REGISTER_BYTES): Undefine before redefining.
- (REGISTER_BYTE): Undefine before defining.
- (FP_REGNUM): Undefine before defining.
- (PC_REGNUM): Undefine before defining.
- (FPC_REGNUM): Undefine before defining.
- (REGISTER_RAW_SIZE): Undefine before defining.
- (FRAME_CHAIN): Undefine before defining.
- (FRAMELESS_FUNCTION_INVOCATION): Undefine before defining.
- (FRAME_SAVED_PC): Undefine before defining.
- (FRAME_NUM_ARGS): Moved to tm-i386.h.
- (MAX_REGISTER_RAW_SIZE): Remove.
- (MAX_REGISTER_VIRTUAL_SIZE): Remove.
- (STORE_STRUCT_RETURN): Remove.
- (EXTRACT_STRUCT_VALUE_ADDRESS): Remove.
- (FRAME_ARGS_ADDRESS): Remove.
- (FRAME_LOCALS_ADDRESS): Remove.
- (FRAME_NUM_ARGS): Undefine before defining.
- (FRAME_ARGS_SKIP): Remove.
- (FRAME_FIND_SAVED_REGS): Remove.
- (PUSH_DUMMY_FRAME): Remove.
- (POP_FRAME): Remove.
- (CALL_DUMMY, CALL_DUMMY_LENGTH, CALL_DUMMY_START_OFFSET): Remove.
- (struct frame_info, struct frame_saved_regs): Remove forward decls
- for prototypes.
-
- * config/i386/tm-i386lynx.h (i386/tm-i386.h): Include instead of
- tm-i386v.h.
- * config/i386/tm-i386m3.h (i386/tm-i386.h): Include instead of
- tm-i386v.h.
-
- * i386-tdep.c (i386_extract_return_value): Make function visible
- for all i386 targets, but only assume floating point values returned
- in floating point registers for I386_AIX_TARGET.
-
- * i386v-nat.c (i386_register_u_addr): Enable code to locate
- floating point regs in user struct.
-
-Wed Nov 1 15:32:57 1995 Fred Fish <fnf@cygnus.com>
-
- * breakpoint.c (breakpoint_re_set): Fix typo in comment.
- * symtab.c (in_prologue): Document func_start and when it is zero
- don't call SKIP_PROLOGUE (which typically leads unconditionally to
- an error when we try to access a prologue at address 0).
-
-Tue Oct 31 13:01:15 1995 Fred Fish <fnf@cygnus.com>
-
- * elfread.c: Include elf-bfd.h rather than libelf.h.
-
-Tue Oct 31 10:42:42 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * win32-nat.c (xlate_exception): Treat a stack overflow like a SEGV.
-
-Sun Oct 29 11:22:05 1995 Fred Fish <fnf@cygnus.com>
-
- * monitor.c: Include gnu-regex.h rather than system regex.h.
-
-Sat Oct 28 23:51:48 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * defs.h: Test on name __WIN32__ rather than WIN32.
- * inflow.c (new_tty): Likewise
- * terminal.h: Likewise.
- * utils.c (initialize_utils): Likewise.
- * win32-nat.c (child_create_inferiror): Print error code when failing.
- * config/i386/win32.mh (XM_CLIBS): Need -lkernel32.
-
-Sat Oct 28 04:52:36 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * symtab.h (enum address_class): Add LOC_UNRESOLVED for
- a location whose address has to be resolved via the minimal
- symbol table.
- * buildsym.c (finish_block), findvar.c (symbol_read_needs_frame,
- read_var_value), printcmd.c (address_info),
- symmisc.c (print_symbol, print_partial_symbol): Handle
- LOC_UNRESOLVED.
- * stabsread.c (scan_file_globals): Change unresolved LOC_STATIC
- symbols to LOC_UNRESOLVED. Remove rt_common_objfile lookup
- kludge, global common symbols are now handled by LOC_UNRESOLVED.
- (scan_file_globals_1): Move code back to scan_file_globals,
- delete.
-
-Fri Oct 27 09:54:07 1995 Stu Grossman (grossman@cygnus.com)
-
- * breakpoint.c (breakpoint_re_set): #ifdef GET_LONGJMP_TARGET
- around calls to create_longjmp_breakpoint. Why install the
- breakpoints if we can't find the longjmp target?
- * infrun.c (wait_for_inferior): Cleanup comments near call test.
- * remote-mips.c: Fixed a bunch of prototypes to avoid char/int
- complaint from picky compilers. Add comment to mips_expect.
- Replace all instances of sr_get_debug with remote_debug.
- * (mips_readchar): Don't jam init string to monitor.
- mips_initialize() handles that.
- * (mips_receive_header): Print better message when we get too
- much garbage.
- * (mips_request): Allow caller to pass in buff to allow them to
- analyze the returned message.
- * (mips_initialize): Re-do initialization to try sending a BREAK,
- a ^C, and then a download escape sequence. Cleanup protocol
- startup. Eliminate sleeps. Clear breakpoints (if using monitor
- breakpoints). Re-init frame.
- * (mips_detach): Close down target.
- * (mips_wait): Handle return status with registers, or breakpoint
- * stuff.
- * (mips_kill): Add ^C handling.
- * (mips_insert_breakpoint mips_remove_breakpoint): Call new
- breakpoint stuff if enabled.
- * (calculate_mask remote_mips_set_watchpoint
- remote_mips_remove_watchpoint remote_mips_stopped_by_watchpoint):
- Hardware watchpoint/breakpoint stuff.
- * (common_breakpoint): Common code for new monitor breakpoint commands.
- * (mips_load): Don't use `prompt'. It's a global variable.
- * top.c (dont_repeat_command): New command for use in
- user-defined commands to suppress auto-repeat (by hittin return key).
- * valops.c: Add start of auto function-call abandonment capability.
-
-Thu Oct 26 22:02:27 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-config.in: Add support for PowerMac host, add beginnings
- of native support.
- * mpw-make.sed: Disable subdir recursion, edit out useless rule.
- * mac-xdep.c (Values.h): Don't include.
- (GestaltEqu.h): Include Gestalt.h instead.
- (do_mouse_down): Comment out control tracking, needs to be
- updated to use UPP before will work on PowerMac.
- * config/xm-mpw.h: New file, all-Mac host support.
- * config/m68k/xm-mpw.h: Move most definitions into generic Mac
- support.
- * config/powerpc/xm-mpw.h: New file, PowerMac host support.
-
-Thu Oct 26 15:21:32 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * regex.h: Renamed to gnu-regex.h.
- * regex.c: Renamed to gnu-regex.c.
- * Makefile.in (POSSLIBS): Refer to gnu-regex.h and gnu-regex.c.
- (REGEX, REGEX1): Change to gnu-regex.o instead of regex.o.
- (regex.o): Renamed to gnu-regex.o; refer to gnu-regex.c.
- (irix5-nat.o, osfsolib.o, gnu-regex.o, solib.o, source.o, symtab.o):
- Likewise.
- * irix5-nat.c, osfsolib.c, gnu-regex.c, solib.c, source.c, symtab.c):
- Include "gnu-regex.h" instead of "regex.h".
- * alpha-tdep.c (in_prologue): Rename to alpha_in_prologue, to
- avoid conflicts with symtab.h.
-
-Tue Oct 24 18:30:18 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * config/pa/hppahpux.mh: Remove hardcoding of X locations.
- * Makefile.in: Use X11_CFLAGS, X11_LDFLAGS and X11_LIBS.
- * configure.in: Link X statically on Solaris, SunOS and HPUX.
-
-Tue Oct 24 12:26:14 1995 Stu Grossman (grossman@cygnus.com)
-
- * monitor.c (monitor_expect_regexp): Same as monitor_expect, but
- with the obvious extension.
- (monitor_read_memory_single): Use regexp for getmem.resp_delim
- because of parsing ambiguities caused by certain monitors.
- (monitor_read_memory): Use new regexp stuff to parse
- getmem.resp_delim.
- * monitor.h (struct memrw_cmd->resp_delim): Document this as a
- regexp.
- * sh3-rom.c: Finish off table. Use new regexp capability for
- getmem commands.
-
- * infrun.c (wait_for_inferior): Disable questionable code near
- the step range test. Replace call detection test with much
- simpler (and more efficient) test that doesn't require prologue
- examination (as often).
- * symtab.c symtab.h (in_prologue): New function that indicates
- whether or not we are in a function prologue. This uses the
- symbol table, and then falls back to prologue examination if that
- fails. It's much more efficient for remote debugging because it
- avoids examining memory, which is very slow. This is used in
- wait_for_inferior to determine if we've made a function call that
- needs to be skipped over (for next/nexti).
- * mips-tdep.c (after_prologue): New function, returns the PC
- after the prologue. Uses PDRs and the symbol table.
- (mips_find_saved_regs): Use in_prologue() to avoid costly
- prologue examination if possible.
- (mips_skip_prologue): Use after_prologue() if possible to avoid
- costly prologue examination.
-
-Mon Oct 23 16:03:33 1995 James G. Smith <jsmith@pasanda.cygnus.co.uk>
-
- * configure.in (configdirs): Added support for the VR4300 default
- builds (mips64*vr4300*el-*-elf*, mips64*vr4300*-*-elf*).
-
- * configure: Regenerated.
-
- * remote-mips.c (mips_load): Updated the prompt spotting code to
- make use of the TARGET_MONITOR_PROMPT manifest.
-
-Sat Oct 21 06:11:49 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * alpha-tdep.c, mips-tdep.c (init_extra_frame_info):
- Do not set saved registers from heuristics for a sigtramp frame.
-
- * dwarfread.c (enum_type): Determine signedness of enum type
- from enumerators.
-
- * mips-tdep.c: Include gdb_string.h, gcc -Wall lint.
-
- * rs6000-nat.c (xcoff_relocate_core): Fix typo.
-
- * valops.c (value_repeat): Fix length of memory transfer to
- match recent allocate_repeat_value change.
-
-Thu Oct 19 19:04:35 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * gdbtypes.c (get_discrete_bounds): Fix typo.
-
-Thu Oct 19 12:15:37 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * defs.h (SEEK_SET, SEEK_CUR): Add default definitions.
- * dbxread.c, mdebugread.c, os9kread.c (SEEK_SET, SEEK_CUR):
- Remove default definitions.
-
- * Makefile.in (CC-LD): Rename to CC_LD, so MPW xform works.
- (MMALLOC_SRC): Define.
- (MMALLOC_CFLAGS): Use.
- (ser-mac.o): Add rule.
- * dwarfread.c, somread.c, ultra3-nat.c, xcoffread.c: Replace L_SET
- with SEEK_SET in all calls to bfd_seek.
- * scm-tags.h (scm_tags): Remove excess comma.
-
- * mpw-config.in: Adapt to work with autoconf'ed configury;
- build config.h, add empty definitions to mk.tmp.
- (powerpc-apple-macos): Make it work.
- * mpw-make.sed: New file, sed commands to translate Unix makefile
- into MPW syntax.
- * mpw-make.in: Remove.
- * mac-gdb.r: New file, was macgdb.r, renamed for consistency
- with other tools, now includes cfrg resource.
- * macgdb.r: Remove.
- * config/m68k/xm-mpw.h: Remove most of contents, replace with
- include of include/mpw/mpw.h.
-
-Tue Oct 17 10:38:53 1995 Jeffrey A Law (law@cygnus.com)
-
- * hppa-tdep.c (frame_chain): Fix more obscure problems caused
- by system calls that core dump processes without saving all
- the register state.
-
- * config/pa/hppahpux.mt (XDEPFILES): Remove bogus definition.
- * config/pa/hppapro.mt (XDEPFILES): Likewise.
-
-Tue Oct 17 08:04:26 1995 Fred Fish <fnf@rtl.cygnus.com>
-
- * NEWS: Fix typo.
-
-Mon Oct 16 18:24:03 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * config/sh/tm-sh.h (REGISTER_VIRTUAL_TYPE): Return builtin_type_float
- for FP registers.
- (REGISTER_NAMES): Add FP register names. Remove ticks, stalls, cycles,
- insts, plr, and tlr.
- (NUM_REGS, NUM_REALREGS): Increase from 23 to 41.
- (FPUL_REGNUM, FP0_REGNUM): New macros.
-
-Mon Oct 16 11:27:06 1995 Stu Grossman (grossman@cygnus.com)
-
- * remote-mips.c: Add support for speedy (about 10x faster)
- downloads.
-
- * remote-array.c: Move baud_rate initialization from
- _initialize_array to array_open. It was forcing the baud rate of
- all targets to be 4800 baud! Seems like I've fixed this before...
- * config/mips/idt.mt (TDEPFILES): Remove remote-array.o. This
- has *nothing* to do with IDT!!!
-
-
- * Makefile.in sh3-rom.c config/sh/sh.mt config/sh/tm-sh.h: Add
- sh3 monitor support.
- * monitor.c: Cleanup regexp compilation stuff to make it easier
- to use several regexps.
- * monitor.h: Get rid of struct rom_cmd_data. It's no longer used.
- * config/m68k/tm-monitor.h: Don't redefine NUM_REGS here. It just
- causes GDB to crash.
-
- * sparcl-tdep.c: Cleanup serial error handling.
-
-Sun Oct 15 16:19:27 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * rs6000-tdep.c: Don't include a.out.h, improve some formatting.
-
-Fri Oct 13 15:27:49 1995 Stu Grossman (grossman@cygnus.com)
-
- * dcache.c: Change default value of remotecache to off. It just
- screws up too many targets.
- * sparcl-stub.c: Add prototypes to many forward decls.
- * Create private copies of strlen, strcpy, and memcpy to prevent
- chaos when user steps into them.
- * (trap_low handle_exception): Clean up DSU support code
- (hardware breakpoints). Move lots of stuff from asm-land to
- C-land (make it much easier to #ifdef if necessary). Also, use
- trap 255 to get into break mode instead of doing a DSU register
- write, which may trash the register.
- * (putpacket): Don't check return value of putDebugChar. It
- returns void...
-
-Fri Oct 13 14:16:17 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * remote-sim.h: Always include callback.h.
- (sim_set_callbacks): New declaration.
-
-Fri Oct 13 10:57:40 1995 Jeffrey A Law (law@cygnus.com)
-
- * somsolib.c (som_solib_add): Just give a warning if a file
- mentioned in the dld_list can't be found.
- * config/pa/tm-hppah.h (FRAME_SAVED_PC_IN_SIGTRAMP): Dig out
- the PC from the PC queues rather than %r31.
-
-Thu Oct 12 13:36:15 1995 Jeffrey A Law (law@cygnus.com)
-
- * corelow.c (core_open): Don't update the to_sections and
- to_sections_end fields in core_ops here. It's too late.
- * irix5-nat.c (solib_add): Update the to_sections and
- to_sections_end fields in core_ops here if needed.
- * osfsolib.c (solib_add): Likewise.
- * rs6000-nat.c (xcoff_relocate_core): Likewise.
- * solib.c (solib_add): Likewise.
- * somsolib.c (solib_add): Likewise.
-
-Wed Oct 11 17:25:59 1995 Fred Fish <fnf@rtl.cygnus.com>
-
- * Makefile.in (VERSION): Bump version to 4.15.1
-
-Tue Oct 10 15:26:39 1995 Fred Fish <fnf@cygnus.com>
-
- * Makefile.in (VERSION): Version 4.15 released.
- * README: Updated for version 4.15.
- * NEWS: Updated for 4.15 release.
-
-Tue Oct 10 13:18:50 1995 Fred Fish <fnf@cygnus.com>
-
- * configure.in: Add AC_PROG_YACC
- * configure: Regenerate
- * Makefile.in (BISON): Remove macro definition.
- (YACC): Set from autoconfig.
- (FLAGS_TO_PASS): Remove BISON.
- (TARGET_FLAGS_TO_PASS): Remove BISON.
-
-Tue Oct 10 12:25:11 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * win32-nat.c (child_create_inferior): Pass argv correctly.
- * Makefile.in (win32-nat.o): Add dependencies.
-
-Mon Oct 9 14:36:29 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * NEWS: Add information about win32 and arm code.
- * win32-nat.c: Renamed from win32.c.
- * config/i386/win32.mh: Renamed from config/i386/i386win32.mh.
- * config/i386/win32.mt: Renamed from config/i386/i386win32.mt.
- * config/i386/tm-win32.h: Renamed from config/i386/tm-i386win32.h.
- * config/i386/xm-win32.h: Renamed from config/i386/xm-i386win32.h.
- * configure.in (i[345]86-*-win32): Updated to cope with filename
- changes.
- * configure: Regenerated.
-
-Sun Oct 8 18:01:04 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * ch-exp.y (yylex): Also look for '$' following '$'.
-
-Sat Oct 7 22:52:42 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * ch-exp.y (yylex): Fix typo.
-
-Fri Oct 6 11:56:49 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * remote-sim.c (gdbsim_open): Put callback initializations here.
- (_initalize_remote_sim): Not here.
-
-Fri Oct 6 17:08:49 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * top.c (execute_control_command): Use 0/1 instead of BFD's
- true/false.
-
-Fri Oct 6 14:43:19 1995 Stu Grossman (grossman@cygnus.com)
-
- * sparcl-stub.c: Include sparclite.h to get access to register
- fondling macros.
- * (trap_low): Save and restore FP regs if necessary. Also, clean
- up save and restore of debug unit regs.
- * (hard_trap_info): Add more architecturally defined traps.
- * (set_debug_traps): Only set FP disabled trap if FP is disabled.
- * (get_in_break_mode): Clean up. Get rid of calls to
- set_hw_breakpoint_trap(). Also, use write_asi macro.
- * (handle_exception): Clean up `g' and `G' commands. Add `P'
- command.
- * (hw_breakpoint): Why was this here!? It's gone now...
-
-Fri Oct 6 11:56:49 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * callback.c (fdbad): Fix typo in comment.
- (os_close, os_isatty, os_lseek, os_read, os_write): Use if
- statements rather than || to get correct return value.
- (os_write_stdout): Pass missing first argument to os_write.
- * remote-sim.c: Include callback.h.
- (_initialize_remote_sim): Call sim_set_callbacks and then
- initialize the callbacks.
-
-Thu Oct 5 17:28:09 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * values.c (allocate_repeat_value): Allocate an array type, and
- a value of that type; use that instead of setting VALUE_REPEATED.
- * value.h (struct value): Remove fields repetitions and repeated.
- (VALUE_REPEATED, VALUE_REPETITIONS): Removed, no longer used.
- * c-valprint.c, ch-valprint.c, eval.c, printcmd.c, valops.c,
- value.h, values.c: Simplify, since now VALUE_REPEATED is never
- used.
- * valprint.c (value_print_array_elemen): Removed never-used
- function.
-
-Thu Oct 5 15:14:36 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * parse.c (write_dollar_variable): New function.
-
- * c-exp.y (yylex): Replace code for recognizing '$'
- pseudo-variables with a call to write_dollar_variable.
- Simplify grammar correspondingly.
- * f-exp.y: Likewise.
- * m2-exp.y: Likewise.
- * ch-exp.y: Likewise. (Remove function match_dollar_tokens.)
- * scm-exp.c (scm_lreadr): Call write_dollar_variable to handle '$'.
-
-Thu Oct 5 13:27:30 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * win32.c: New file; support for debugging on windows NT.
- * configure.in: (i[345]86-*-win32): New target.
- * configure: Regnerated.
- * eval.c (evaluate_subexp_standard): Remove unused name.
- * serial.c (gdb_string.h): Include.
- * source.c (value.h): Include.
- * config/i386/i386win32.mh (XDEPFILES): Add win32.o
- * config/i386/i386win32.mt: New.
- * config/i386/tm-i386win32.h: New.
-
-Wed Oct 4 18:41:34 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * expression.h (enum exp_code): Added OP_NAME.
- * expprint.c (print_subexp): Add OP_NAME support.
- * parse.c (length_of_subexp, prefixify_subexp): Likewise.
- * scm-lang.c (scm_unpack, in_eval_c, scm_lookup_name): new function.
- * scm-lang.h: Declare builtin_type_scm; other minor tweaks.
- * values.c (unpack_long): If type is SCM, call scm_unpack.
- * scm-valprint.c (scm_val_print): Use extract_signed_integer,
- instead unpack_long
- * scm-lang.c: More Scheme expression parsing from here ...
- * scm-exp.c: ... to here. New file.
- Also, provide for gdb to evaluate simple constants and names..
- * Makefile.in: Note new scm-exp.{c,o}.
-
-Wed Oct 4 17:23:03 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * gdbtypes.c (get_discrete_bounds): New function.
- (force_to_range_type): Use get_discrete_bounds.
- * gdbtypes.h (get_discrete_bounds): Add declaration.
- * valarith.c (value_bit_index): Generalize to use get_discrete_bounds.
- * ch-valprint.c (chill_val_print): Make (power)sets and bitstring
- support use get_discrete_bounds and generally be more robust.
-
-Tue Oct 3 16:54:56 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * remote-nrom.c (nrom_ops): Add value for to_thread_alive,
- add comments naming slots.
-
-Mon Oct 2 21:45:44 1995 Jeff Law (law@hurl)
-
- * top.c (build_command_line): Demand arguments for if/while
- commands.
-
-Mon Oct 2 13:08:01 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * Makefile.in (X11_CFLAGS): Set only to @X_INCDIR@.
-
-Sat Sep 30 16:13:36 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * scm-lang.c: Moved Scheme value printing code to ...
- * scm-valprint.c: ... this new file.
- Also major improvements in support for printing SCM values.
- * scm-lang.h: New file.
- * scm-tags.h: New file.
- * Makefile.in: Note new scm-valprint.{c,o}.
-
-Sat Sep 30 09:35:02 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in: X_INCDIR and X_LIBDIR added.
- * Makefile.in: @X_INCDIR@ and @X_LIBDIR@ added.
- * configure: Regnerated.
-
-Fri Sep 29 02:10:05 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * config/arm/tm-arm.h (FRAME_CHAIN, FRAME_CHAIN_VALID):
- Any pc > LOWESTPC is ok.
-
- * remote-rdp.c (rdp_init): Take out variable baud rate stuff.
- (remote_rdp_detatch): Delete.
- * breakpoint.c (ctype.h): Don't include twice.
-
- * Makefile.in (remote-rdp.o): Doesn't need remote-rdp.h
- * callback.c (os_printf_filtered): fix protos.
- * defs.h (puts_filtered, puts_unfiltered
- [v|f|]printf_[un]filtered): Make format arg const.
- * remote-rdp.c (rdp_init): Attept to sync at different
- baudrates.
- * utils.c (puts_filtered, puts_unfiltered
- [v|f|]printf_[un]filtered): Define prototypes with
- const in the right place.
-
-Thu Sep 28 17:43:39 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * defs.h (enum language): Add language_scm.
- * expression.h (enum exp_code): Added OP_EXPRSTRING.
- * scm-lang.c: Preliminary support for Guile /SCM dialect of Scheme.
- * expprint.c (print_subexp): Add OP_EXPRSTRING support.
- * parse.c (length_of_subexp, prefixify_subexp): Likewise.
- * valops.c (find_function_in_inferior): New function.
- (value_allocate_space_in_inferior): New function.
- (allocate_space_in_inferior): Redefine using previous function.
- * Makefile.in (SFILES): Add scm-lang.c.
- (COMMON_OBS): Add scm-lang.o
-
-Thu Sep 28 14:32:11 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * callback.[ch]: New files.
- * remote-rdp.c: Support for the ARM RDP monitor.
- * Makefile: Update.
- * arm-tdep.c (arm_othernames): New.
- (_initialize_arm_tdep): install 'othernames' command.
- (arm_nullified_insn, shifted_reg_val, arm_get_next_pc): New.
- * configure.in: Check for termios.h, termio.h and sgtty.h.
- (i[345]86-*-win32*): New host.
- * configure: Regenerated.
- * inflow.c: Clean up inclusions.
- * main.c (main): Check for WINGDB, not WIN32.
- * printcmd.c (do_examine): Put QUIT test in loop.
- * remote-hms.c (e7000_load): Delete.
- (hms_ops): Point to generic_load instead.
- * remote-hms.c (hms_ops): Point to generic_load.
- * remote-sim.c (sim_callback_write_stdout): Becomes
- gdbsim_write_stdout.
- (gdbsim_load): Call generic_load.
- * remote-utils.c (gr_load_image): Delete.
- * ser-unix.c (terminal.h): Include instead of havig
- own #if tree.
- (hardwire_flush_input): Reset input buffer too.
- * source.c (openp): If WIN32 then open file in binary mode.
- * terminal.h: Configure IO mechanism using autoconf defines if
- available and not overriden.
- * utils.c (quit, pollquit, notice_quit): WIN32 check becomes
- WINGDB check.
-
- * config/arm/arm.mt (TDEPFILES): Add remote-rdp.o.
- * config/arm/tm-arm.h (TARGET_BYTE_ORDER): becomes
- TARGET_BYTE_ORDER_SELECTABLE.
- (ADDR_BITS_REMOVE): New.
- (ORIGINAL_REGISTER_NAMES, ADDITIONAL_REGISTER_NAMES): New.
- (INST_xx): New.
- (FRAME_FIND_SAVED_REGS): Pass the right argument.
- (arm_get_next_pc): Declare.
-
-Wed Sep 27 10:14:36 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * valops.c (search_struct_field): Also allow "else" as a variant
- name.
- * eval.c (evaluate_struct_tuple): New function. Used to evaluate
- structure tuples. Now also handles Chill variant records.
- (get_label): New function, used by evaluate_struct_tuple.
- (evaluate_subexp_standard case OP_ARRAY): Use evaluate_struct_tuple.
- (evaluate_labeled_field_init): Removed.
-
- * valops.c (search_struct_field): Generalize to work with Chill
- variant records.
-
-Sat Sep 23 01:22:23 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (parse_partial_symbols): Reset includes_used
- and dependencies_used after finishing the partial symbol table.
-
- * rs6000-tdep.c (push_dummy_frame): Handle lr_offset of zero
- correctly.
-
- * rs6000-nat.c (xcoff_relocate_core): Don't relocate data
- addresses for the main objfile if DONT_RELOCATE_SYMFILE_OBJFILE
- is defined.
- * xcoffread.c: gcc -Wall lint. Remove traceback table reading
- code. The existing code tried to add parameter information for
- functions compiled without -g, which cannot be done properly
- for optimized code and produced misleading parameter displays.
- (ef_complaint, eb_complaint): Make a local static copy to avoid
- dependency on coffread.c.
- (read_xcoff_symtab, process_xcoff_symbol, scan_xcoff_symtab):
- Enter C_EXT/C_HIDEXT symbols into the minimal symbol table only.
- (read_xcoff_symtab): Ignore C_STAT section auxiliary entry
- symbols. Complain about unmatched .ef and .eb symbols instead of
- segfaulting.
- (process_xcoff_symbol): Determine value of C_GSYM symbols via
- the global_sym_chain mechanism in stabsread.c.
- (xcoff_new_init): Call stabsread_new_init and buildsym_new_init.
- (init_string_tab): Initialize length field bytes in the strtbl.
- (scan_xcoff_symtab): Skip symbols that start with `$' or `.$'.
- Set first_fun_line_offset for symbols with two auxents only.
-
-Wed Sep 20 21:06:35 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * op50-rom.c (op50n_cmds): Send ".\r" after the interrupt
- character.
-
-Wed Sep 20 13:12:56 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (maintainer-clean): New target, synonym for
- realclean. Add GNU standard maintainer-clean echos.
- * gdbserver/Makefile.in (maintainer-clean): New target, synonym
- for realclean.
- * nlm/Makefile.in (maintainer-clean): Likewise.
-
-Wed Sep 20 08:16:03 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * defs.h (xmalloc, xrealloc): Delete, they're declared in libiberty.h.
- (GETENV_PROVIDED, FCLOSE_PROVIDED): New.
- * doc/gdbint.texinfo (GETENV_PROVIDED, FCLOSE_PROVIDED): Document.
- * remote-sim.[ch] (sim_callback_write_stdout): New.
-
-Tue Sep 19 15:28:58 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * gdbtypes.c (create_set_type): Set TYPE_LENGTH in bytes, not bits.
- * valops.c (value_bitstring): TYPE_LENGTH is bytes, not bits.
-
- * gdbtypes.c (force_to_range_type): Calculate upper limit of
- TYPE_CODE_CHAR depending on TYPE_LENGTH (instead of just using 255).
-
-Mon Sep 18 01:43:42 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * somsolib.c (auto_solib_add_at_startup): Delete definition. No
- longer needed.
-
-Sat Sep 16 13:23:36 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/mips/tm-mips.h (UNUSED_REGNUM): Define.
- * mipsv4-nat.c (supply_gregset): Fill UNUSED_REGNUM register
- with zero.
-
-Thu Sep 14 17:35:24 1995 Stu Grossman (grossman@cygnus.com)
-
- * remote-sim.c (gdbsim_create_inferior): Back out change that
- broke all simulator configurations except the rs6000.
-
-Thu Sep 14 14:44:59 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * monitor.c (monitor_expect): Discard NULL characters.
-
-Thu Sep 14 14:12:30 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * infcmd.c: Add extern declaration for auto_solib_add_at_startup.
-
-Wed Sep 13 13:33:58 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * symfile.c: Move global variable auto_solib_add_at_startup from
- solib.c to symfile.c.
- * solib.c: ditto.
- * symfile.h: Add extern declaration of the above mentioned variable.
- * infcmd.c: Take out extern declaration, since it's in symfile.h.
-
-Thu Sep 14 12:39:35 1995 Stu Grossman (grossman@cygnus.com)
-
- * coffread.c (coff_symtab_read): Complain about unmatched .ef and
- .eb symbols instead of segfaulting.
-
-Wed Sep 13 13:33:58 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * stabsread.c (read_one_struct_field): Use subfile language instead of
- global language. Improve efficiency.
-
-Wed Sep 13 08:45:02 1995 Jeff Law (law@fast.cs.utah.edu)
-
- * somsolib.c (auto_solib_add_at_startup): Define new global variable.
- (som_solib_create_inferior_hook): Don't add libraries if
- auto_solib_add_at_startup is zero.
- (_initialize_som_solib): Add command to toggle
- auto_solib_add_at_startup.
-
-Tue Sep 12 19:37:24 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * monitor.c (monitor_make_srec): Fix thinkos in computation
- of addr_size.
-
-Tue Sep 12 15:46:18 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * stabsread.c (read_one_struct_field): Add a patch to handle cfront
- generated stabs that each field is in full mangled name.
-
- * stabsread.c: To include language.h and expression.h for the reason
- above.
-
- * infcmd.c (attach_command): Add solibs only when
- auto_solib_add_at_startup is set.
-
-Mon Sep 11 17:22:35 1995 Fred Fish <fnf@cygnus.com>
-
- * NEWS: Add information about remote target caching.
-
-Sun Sep 10 15:36:21 1995 Fred Fish <fnf@cygnus.com>
-
- * defs.h: Only include mmalloc.h if NO_MMALLOC is not
- defined.
-
-Sun Sep 10 10:24:48 1995 Michael Tiemann <tiemann@axon.cygnus.com>
-
- * tm-ppc-eabi.h (PC_IN_CALL_DUMMY): Redefine this to work with the
- simulator. FIXME.
-
- * rs6000-tdep.c (push_dummy_frame): Calculate the correct link
- register offset from the current frame (don't assume it is always 8).
- (push_dummy_frame): Add comment about having only 4096 bytes of
- stack space in the simulator (by default).
-
- * remote-sim.c (gdbsim_create_inferior): Call
- `add_text_to_loadinfo' so that gdb can find TOC entries when
- calling functions in the inferior.
-
-Sun Sep 10 09:00:28 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * sparc-tdep.c (fill_fpregset): Fix incorrect FP_MAX_REGNUM
- substitution.
- (supply_fpregset): Use FP_MAX_REGNUM.
-
-Sat Sep 9 08:21:52 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * stabsread.c (read_enum_type): Exit loop for putting pending
- enum symbols into the enum type correctly if we had no pending
- symbols on entry to read_enum_type.
-
-Fri Sep 8 12:57:41 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * inferior.h: Add extern declaration of inferior_environ.
- * solib.c (solib_map_sections): To get inferior's env instead of
- gdb's for LD_LIBRARY_PATH, same for PATH.
-
- * solib.c (solib_map_sections): Copy full path name into so_list
- structure so that symbol_file_add can find it.
-
-Tue Sep 5 17:47:53 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * config/sparc/tm-sp64.h (REGISTER_RAW_SIZE): Lower 32 fp regs
- have size 4.
- (REGISTER_VIRTUAL_SIZE): Likewise.
- (REGISTER_VIRTUAL_TYPE): Lower 32 fp regs have type float.
- Upper 32 fp regs have type double.
- * sparc-tdep.c (NUM_SPARC_FPREGS): Replace with
- (FP_REGISTER_BYTES): this, and update all uses.
- (FP_MAX_REGNUM): Define if not already.
- (get_saved_register): Handle new sparc64 fp regs.
- (sparc_frame_find_saved_regs): Likewise.
- (sparc_print_register_hook): Only print fp regs < 32 as doubles.
- Add code to handle long doubles when gdb does.
- (_initialize_sparc_tdep): Use print_insn_sparc64 if sparc64.
-
-Sat Sep 2 06:41:26 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * configure.in: Explicitly `exit 0' for broken shells.
- * configure: Rebuilt.
-
- * symtab.c (list_symbols): Add missing blank after
- `<function, no debug info>' output.
-
- * valops.c (value_assign): Handle truncation when assigning
- to bitfields. Use value_copy to construct the return value
- from toval.
- * values.c (value_copy): Copy VALUE_FRAME and VALUE_OPTIMIZED_OUT.
-
-Fri Sep 1 08:25:50 1995 James G. Smith <jsmith@beauty.cygnus.com>
-
- * configure (mips64*vr4300*-*-elf): Support added.
- * remote-mips.c (mips_readchar): Change to allow build-time prompt
- string.
- * config/mips/tm-mips.h: Added TARGET_MONITOR_PROMPT.
- * config/mips/{vr4300.mt, vr4300el.mt, tm-vr4300.h,
- tm-vr4300el.h}: Added.
-
-Thu Aug 31 12:48:04 1995 Jim Wilson <wilson@chestnut.cygnus.com>
-
- * config/sh/sh.mt (SIM): Add -lm.
-
-Wed Aug 30 18:10:57 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * rmote-nindy.c (non_dle, nidy_resume, nindy_wait): Changes to
- conform to GNU coding standards.
-
- * solib.c (match_main): Modify to follow GNU coding conventions.
-
-Mon Aug 28 17:07:26 1995 Kung Hsu <kung@lisa.cygnus.com>
-
- * remote.c (remote_wait): Revert 19 July my change which should be
- customer specific.
-
-Sat Aug 26 00:26:11 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (parse_symbol): Handle sh.value of zero for enums.
- Determine signedness of enum type from enumerators.
- (parse_type): Handle btIndirect types, handle fBitfield for
- some non-member types.
- (upgrade_type): Use TYPE_FLAG_TARGET_STUB for arrays with
- unknown length.
- (cross_ref): Handle stIndirect forward reference to btTypedef.
-
- * stabsread.c (read_enum_type): Determine signedness of enum
- type from enumerators.
-
- * top.c (execute_command): Remove trailing whitespace from
- command arguments, except for `set' and `complete' commands.
- (validate_comname): Allow underscores in user defined command
- names.
-
- * values.c (modify_field): Change `Value does not fit in %d bits'
- error to a warning. Exclude sign extension bits of negative field
- values from fit check.
-
-Fri Aug 25 11:31:29 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (powerpc*-*-eabisim*): Only link in the simulator
- if the target is powerpc{,le}-*-eabisim*, since the simulator
- needs GCC to build.
- * config/powerpc/ppc{,le}-sim.mt: Cloned from ppc{,le}-eabi.mt.
- * config/powerpc/ppc{,le}-eabi.mt: Remove simulator support.
- * config/powerpc/tm-ppc{,le}-sim.mt: Include tm-ppc{,le}-sim.h.
-
-Wed Aug 23 16:55:35 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config/powerpc/ppc{,le}-eabi.mt (SIM_OBJS, SIM): Link in the
- PowerPC simulator.
-
-Tue Aug 22 02:00:47 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * tm-hppa.h (EXTRACT_RETURN_VALUE): Fix for FP values.
-
- * tm-hppa.h (STORE_RETURN_VALUE): Fix to work with -msoft-float
- calling conventions too. Use the TYPE of the return value, not
- its length to determine if it should also be copied into the
- floating point registers.
-
- * tm-hppa.h (PROLOGUE_FIRSTLINE_OVERLAP): Delete. Causes more
- problems than it fixes.
- * hppa-tdep.c (skip_prologue): If we exit the main loop without
- finding all the register saves, retry again without looking for
- the registers we could not find the first time.
-
-Mon Aug 21 23:39:56 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (frame_chain_valid): Handle systems where "$START$"
- calls "main" directly.
- (skip_prologue): Always assume arguments were saved into the stack
- since GCC will do so without setting the magic Args_Saved bit in
- the unwind descriptor.
-
-Mon Aug 21 11:49:17 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * remote-udi.c (udi_wait): Mask off high bits of stop reason.
- * remote-udi.c (fetch_register): For unfetchable regs, pretend it's
- done. Fix a bug.
-
-Mon Aug 21 00:45:17 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * Makefile.in (install): Remove "brokensed" hack, unnecessary now
- that we're using autoconf.
- (uninstall): Likewise.
-
-
-Sat Aug 19 01:19:34 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * gdbtypes.c (recursive_dump_type): Add dont_print_type_obstack
- to inhibit infinite recursion when printing aggregate types.
-
-Fri Aug 18 17:48:55 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * dcache.c (dcache_write_line): Write dirty lines right.
-
-Fri Aug 18 06:26:56 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * sparc-tdep.c (isbranch): Fix typo which caused wrong
- target addresses for annulled branches.
-
-Wed Aug 16 21:54:39 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * config/pa/tm-hppa.h (PROLOGUE_FIRSTLINE_OVERLAP): Define.
-
-Tue Aug 15 07:51:21 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * remote.c (remote_write_bytes): Chop up large transfers.
-
-Mon Aug 14 17:56:36 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * gcc.patch: Remove, relevant only to long-ago versions of GCC.
-
-Mon Aug 14 13:43:01 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * config/sparc/tm-sparclite.h: Define FRAME_CHAIN_VALID_ALTERNATE.
- * blockframe.c (inside_main_func): If main func addr range not set,
- try to set it now.
-
-Sat Aug 12 15:34:54 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * config/powerpc/xm-aix.h (FIVE_ARG_PTRACE): Define.
- * config/rs6000/xm-rs6000.h (FIVE_ARG_PTRACE): Likewise.
-
- * configure.in: Recognize aix4 specially as some aspects
- of aix4 need different handling than aix3.
- * configure: Updated.
- * config/powerpc/{aix4.mh,aix4.mt,tm-ppc-aix4.h}: New files
- specific to aix4 support on the power pc.
- * config/powerpc/tm-ppc-aix.h (DONT_RELOCATE_SYMFILE_OBJFILE): Do
- not defined. The aix4 specific target files will do that.
- * config/rs6000/{aix4,mh,aix4,mt,tm-rs6000-aix4.h}: New files
- specific to aix4 support on the rs6000.
-
- * config/rs6000/tm-rs6000.h (CONVERT_FROM_FUNC_PTR_ADDR): Don't
- do the conversion if the pointer is not a magic aix function
- pointer.
- * rs6000-tdep.c: Include objfiles.h and symtab.h.
- (is_magic_function_pointer): New function.
-
- * rs6000-tdep.c (skip_prologue): Refine check for frameless
- functions. Handle b .+4 emitted by aix4 compilers. Only
- allow one load of a minimal toc pointer. Handle aix4 compiler's
- code for alloca.
-
- * rs6000-tdep.c (find_toc_address): Report an error if no toc was
- found rather than possibly core dumping.
-
- * partial-stab.h: Handle extra field generated by the aix4 compiler
- for enumerations.
- * stabsread.c (read_enum_type): Likewise.
-
-Sat Aug 12 03:18:04 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * rs6000-tdep.c (extract_return_value): Fix returning of values
- whose length is less than the register size for big endian targets.
-
-Fri Aug 11 13:04:32 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * symtab.c (list_symbols): if break command set breakpoint on
- matched symbol.
-
-Wed Aug 9 18:59:05 1995 Fred Fish <fnf@cygnus.com>
-
- * defs.h (strchr, strrchr, strstr, strtok, strerror): Enclose in
- #ifndefs to protect against previous definitions as macros.
-
-Wed Aug 9 14:51:36 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * xcoffread.c (xcoff_symfile_offset): Revert an unwanted change
- that got in accidentally with Aug 1 change.
-
-Sat Aug 5 09:07:28 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * remote-hms.c (hms_cmds): Get reg term right.
- * monitor.c (monitor_fetch_register): If we see
- a non-hex digit, just stop reading.
- * remote.c (remote_wait): Change way $O is handled.
-
-Wed Aug 9 11:42:36 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * configure.in (powerpc-*-aix*): Recognize as a new gdb host
- and target.
- (powerpc-*-eabi*): Don't set configdirs.
- (powerpcle-*-eabi*): Likewise.
- * configure: Updated.
- * rs6000-nat.c (vmap_ldinfo): Don't relocate data addresses
- for the main objfile if DONT_RELOCATE_SYMFILE_OBJFILE is
- defined.
- * config/powerpc/{aix.mh,aix.mh}: Host and target makefile fragments
- for powerpc running aix4.
- * config/powerpc/{nm-aix.h, tm-ppc-aix.h, xm-aix.h}: Native, target
- and host include files for powerpc running aix4.
-
-Wed Aug 9 08:11:45 1995 Stan Shebs <shebs@cygnus.com>
-
- * top.c (target_output_hook): Really make it match defs.h (char *
- is not the same as unsigned char *).
-
-Tue Aug 8 15:13:05 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * Makefile.in (CXX_FOR_TARGET): Don't use ${rootme}/../gcc/xgcc
- unless it is present.
-
-Tue Aug 8 10:50:15 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * top.c (target_output_hook): Make declaration match the one
- in defs.h.
-
- * symfile.c (add_psymbol_to_list): Initialize SYMBOL_SECTION.
- (add_psymbol_addr_to_list): Likewise.
- * symfile.h (ADD_PSYMBOL_VT_TO_LIST): Likewise.
-
-Mon Aug 7 15:34:29 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * top.c (target_output_hook): New definition.
- * stack.c (gdb_string.h): Include after defs.h
- * defs.h (target_output_hook): New declaration.
- * source.c (mod_path): Fix Win32 \ handling.
-
-Sun Aug 6 22:14:25 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (frame_saved_pc): Don't try to dig a return pointer
- out of a long branch stub.
-
-Fri Aug 4 13:37:31 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * xcoffread.c (process_linenos): Fix typo in last change.
-
-Thu Aug 3 22:01:26 1995 Fred Fish <fnf@rtl.cygnus.com>
-
- * ch-exp.y (write_lower_upper_value): Add prototype so bison
- generated parser will insert prototype before first func usage.
- Bison and byacc order the output sections differently. Also
- make function static.
-
-Thu Aug 3 10:45:37 1995 Fred Fish <fnf@cygnus.com>
-
- * Update all FSF addresses except those in COPYING* files.
-
-Thu Aug 3 01:38:45 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/alpha/tm-alpha.h (EXTRA_FRAME_INFO): Add pc_reg field.
- (SKIP_TRAMPOLINE_CODE): Define.
- * alpha-tdep.c (alpha_frame_saved_pc): Use pc_reg field from
- frame to find the saved pc register.
- (alpha_saved_pc_after_call): Skip over shared library trampoline
- before trying to find the saved pc register.
- (find_proc_desc): Copy PROC_PC_REG from found proc_desc
- to heuristic proc_desc.
- (init_extra_frame_info): Initialize pc_reg field in frame.
-
-Wed Aug 2 18:00:36 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * configure.in (m68*-est-*): Use monitor target config.
- * configure: Update.
- * config/m68k/est.mt, config/m68k/tm-est.h: Delete.
- * config/m68k/monitor.mt, config/m68k/tm-monitor.h: Fix comments.
-
-Tue Aug 1 22:52:53 1995 Fred Fish <fnf@cygnus.com>
-
- * Makefile.in (VERSION): Bump to 4.14.2
-
-Tue Aug 1 16:04:36 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * xcoffread.c (process_linenos): The value in include file symbol
- should point to line number table. Currently this value is not
- set correctly by AIX ld. A fix to get around this bug.
-
-Tue Aug 1 11:44:53 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in: Check for working mmap, ansi headers, string.h,
- strings.h, and memory.h.
- * configure: Regenerated.
-
- * gdb_stat.h: New file, "portable" <sys/stat.h>.
- * gdb_string.h: New file, "portable" <string.h>.
-
- * altos-xdep.c, arm-tdep.c, arm-xdep.c, convex-tdep.c,
- convex-xdep.c, coredep.c, cxux-nat.c, dbxread.c, exec.c,
- gould-xdep.c, hppa-tdep.c, i386aix-nat.c, i386b-nat.c,
- i386mach-nat.c, i386v-nat.c, infptrace.c, m88k-nat.c, main.c,
- mdebugread.c, objfiles.c, os9kread.c, procfs.c, pyr-xdep.c,
- rs6000-nat.c, source.c, standalone.c, stuff.c, sun386-nat.c,
- symfile.c, symm-nat.c, symm-tdep.c, symtab.c, top.c, ultra3-nat.c,
- ultra3-xdep.c, umax-xdep.c, xcoffread.c: Include "gdb_stat.h"
- instead of <sys/stat.h>.
-
- * alpha-tdep.c, breakpoint.c, buildsym.c, c-typeprint.c,
- ch-typeprint.c, coffread.c, command.c, core-sol2.c, core-svr4.c,
- core.c, corelow.c, cp-valprint.c, dbxread.c, dcache.c, demangle.c,
- dpx2-nat.c, dstread.c, dwarfread.c, elfread.c, environ.c, eval.c,
- exec.c, f-lang.c, f-typeprint.c, f-valprint.c, findvar.c,
- fork-child.c, gdbtypes.c, hpread.c, i386-tdep.c, infcmd.c,
- inflow.c, infptrace.c, infrun.c, irix5-nat.c, language.c,
- m2-typeprint.c, main.c, mdebugread.c, minsyms.c, mipsread.c,
- monitor.c, nlmread.c, objfiles.c, os9kread.c, osfsolib.c, parse.c,
- printcmd.c, procfs.c, regex.c, remote-adapt.c,
- remote-array.c, remote-bug.c, remote-e7000.c, remote-eb.c,
- remote-es.c, remote-hms.c, remote-mm.c, remote-os9k.c,
- remote-pa.c, remote-sim.c, remote-st.c, remote-udi.c,
- remote-utils.c, remote-vx.c, remote-vx29k.c, remote-vx68.c,
- remote-vx960.c, remote-vxmips.c, remote-vxsparc.c, remote.c,
- solib.c, somread.c, source.c, stabsread.c, stack.c, symfile.c,
- symmisc.c, symtab.c, target.c, top.c, typeprint.c, utils.c,
- valarith.c, valops.c, valprint.c, values.c, xcoffread.c: Include
- "gdb_string.h" instead of <string.h>.
-
- * config/xm-sysv4.h, i386/xm-ptx.h, m68k/xm-sun3os4.h,
- sparc/xm-sun4os4.h (HAVE_MMAP): Removed.
-
- * config/xm-lynx.h, config/i386/xm-ptx.h,
- config/m68k/nm-apollo68b.h, config/m68k/xm-hp300hpux.h,
- config/mips/xm-irix3.h, config/mips/xm-mips.h,
- config/mips/xm-news-mips.h, config/mips/xm-riscos.h,
- config/pa/hppah.h, config/rs6000/xm-rs6000.h,
- config/sparc/xm-sun4os4.h, config/sparc/xm-sun4sol2.h,
- config/vax/xm-vaxbsd.h, config/vax/xm-vaxult.h,
- config/vax/xm-vaxult2.h (MEM_FNS_DECLARED): Removed.
- * config/mips/xm-irix3.h, config/mips/xm-mips.h,
- config/pa/xm-hppah.h (memcpy, memset): Removed declarations.
-
-Tue Aug 1 02:08:30 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mips-tdep.c (mips_extract_return_value): Fix returning of
- values whose length is less than the register size for big endian
- targets.
- * alpha-tdep.c (alpha_extract_return_value,
- alpha_store_return_value): Use alpha_convert_register_to_*
- to handle functions returning "float" correctly.
-
-Mon Jul 31 19:12:48 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * h8500-tdep.c: General linting and cleanup.
- (opcodes/h8500-opc.h): Don't include.
- (code_size, data_size): Make static.
- (frame_locals_address, frame_args_address): Remove.
- (h8300_pop_frame): Rename to h8500_pop_frame.
- (big_command, medium_command, compact_command, small_command):
- Define as regular functions rather than with macro trickery.
- (tm_print_insn): Set to correct disassembler function.
- * config/h8500/tm-h8500.h: Minor cleanup, add prototypes.
- (ABOUT_TO_RETURN): #if 0 out.
- (FRAME_ARGS_ADDRESS, FRAME_LOCALS_ADDRESS): Use usual define.
- (GDB_TARGET_IS_H8500): Remove duplicate definition.
- (regoff): Remove, never used.
- * config/h8500/h8500.mt (TDEPFILES): Add monitor.o.
-
-Mon Jul 31 14:32:30 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in: Check for unistd.h.
- * configure: Regenerated.
-
- * command.c, cp-valprint.c, fork-child.c, i386-tdep.c,
- i386b-nat.c, inflow.c, main.c, maint.c, objfiles.c, solib.c,
- source.c, stack.c, symfile.c, top.c, utils.c: Include strings.h
- and/or unistd.h to bring prototypes into scope.
-
-Sun Jul 30 01:40:11 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * rs6000-tdep.c (frame_saved_pc): Check for signal handler caller
- before trying to determine the start of the function.
- (skip_prologue): Skip subroutine call which might save the
- floating point registers only if it is within the first three
- instructions.
- Reinstate setting of alloca_reg if setup of a gcc frame pointer
- is found.
- (frame_get_cache_fsr): Use new fields in rs6000_framedata.
-
-Sat Jul 29 14:43:35 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * sparclite: Removed subdirectory. aload and eload are now in
- utils/sparclite, low-level library is in libgloss.
- * configure.in (sparclite*): Don't configure sparclite subdir.
- * configure: Update.
- * Makefile.in (TARDIRS): Remove, no longer used.
-
-Sat Jul 29 01:45:56 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * procfs.c (unconditionally_kill_inferior): Clear current signal
- if PROCFS_NEED_CLEAR_CURSIG_FOR_KILL is defined.
- * config/alpha/nm-osf3.h (PROCFS_NEED_CLEAR_CURSIG_FOR_KILL): Define.
-
- * alpha-tdep.c: Move sigtramp handling of saved registers from
- read_next_frame_reg to alpha_find_saved_regs, handle saved
- floating point registers.
- * mips-tdep.c: Move sigtramp handling of saved registers from
- read_next_frame_reg to mips_find_saved_regs, handle saved
- floating point registers.
- * config/mips/tm-irix3.h, config/mips/tm-irix5.h,
- config/mips/tm-mipsv4.h (SIGFRAME_FPREGSAVE_OFF): Define.
-
- * sparc-tdep.c (sparc_pc_adjust): Fix check for `unimp'
- instruction to handle functions returning structures with
- large sizes properly.
-
-Fri Jul 28 11:50:17 1995 steve chamberlain <sac@slash.cygnus.com>
-
- * configure, configure.in (z8k-*-sim): deleted.
-
-Thu Jul 27 12:49:28 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * lynx-nat.c (child_wait): Handle threads exiting.
-
-Thu Jul 27 07:47:50 1995 Michael Meissner <meissner@cygnus.com>
-
- * rs6000-tdep.c (skip_prologue): Don't assume the update stack
- instruction is the last in the prologue, since xlc stores the lr
- after the stack update. Make sure offset is correct sign for
- large frames.
- (frame_saved_pc): Move test for signal before frameless.
-
- * config/rs6000/tm-rs6000.h (DEFAULT_LR_SAVE): Define.
- * config/powerpc/tm-ppc-eabi.h (DEFAULT_LR_SAVE): Redefine.
-
-Thu Jul 27 01:22:08 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * hppa-tdep.c (hppa_fix_call_dummy): Rewrite code for calling
- into shared libraries.
-
-Wed Jul 26 23:33:34 1995 Michael Meissner <meissner@cygnus.com>
-
- * config/rs6000/tm-rs6000.h (rs6000_framedata): Add offsets the
- gprs, fprs, lr, and cr is stored at.
- (FRAME_FIND_SAVED_REGS): Use new fields in rs6000_framedata.
- (function_frame_info): Delete declaration.
- (SKIP_PROLOGUE): Skip_prologue is now passed a rs6000_framedata
- structure to fill in.
- (FRAMELESS_FUNCTION_INVOCATION): Function now longer takes a
- second argument.
- (FRAME_SAVED_PC): Call frame_saved_pc.
-
- * rs6000-tdep.c (skip_prologue): Recognize V.4 prologues as well
- as AIX style. Fill in rs6000_framedata structure. Remember where
- the gprs, fprs, cr, and lr are saved.
- (pop_frame): Use skip_prologue, not function_frame_info, and use
- new rs6000_framedata fields.
- (function_frame_info): Function deleted.
- (frameless_function_invocation): Separate frame_saved_pc support
- to new function. Recognize V.4 frames.
- (frame_saved_pc): New function.
- (frame_get_cache_fsr): Use skip_prologue, not function_frame_info.
- (frame_initial_stack_address): Ditto.
-
-Wed Jul 26 01:00:37 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * remote.c: Add documentation for extended protocol operations
- and for thread_alive change from a couple weeks ago.
- (extended_remote_ops): Declare and define a new target vector
- for the extended remote protocol.
- (extended_remote_restart): New function to restart the remote
- server & process.
- (remote_open): Just a stub routine.
- (extended_remote_open): New function to start a remote session
- using the extended gdb remote protocol.
- (remote_open_1): New function containing code common to both
- remote_open and extended_remote_open.
- (remote_mourn, extended_remote_mourn, remote_mourn_1): Similarly.
- (extended_remote_create_inferior): New function for the extended
- remote target.
- (initialize_remote): Add the extended_remote_ops target vector.
- * gdbserver/server.c (main, case '!'): Set extended_protocol.
- (main, case 'k'): If the extended protocol is in use, kill the
- inferior then start a new one.
- (main, case 'R'): New command to restart the remote server and
- inferior process. Only supported when using the extended
- protocol.
- (main, server loop): If the inferior terminates while using the
- extended protocol then start a new one. If getpkt fails when
- using the extended protocol then exit.
-
-Tue Jul 25 11:43:44 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mdebugread.c (psymtab_to_symtab_1): Relocate encoded stab
- line numbers using the psymtab's section offsets.
-
-Tue Jul 25 10:43:27 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config/rs6000/tm-rs6000.h (rs6000_framedata): Rename from
- aix_framedata. Change all uses.
- * rs6000-tdep.c: Change all aix_framedata -> rs6000_framedata.
-
-Sat Jul 22 23:44:18 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * defs.h (ATTR_FORMAT): Disable if ANSI_PROTOTYPES is not defined.
-
-Fri Jul 21 16:50:28 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * lynx-nat.c (child_thread_alive): New function. Somehow I
- forgot to check this in with all the other thread_alive changes.
-
-Thu Jul 20 22:22:34 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * somread.c (som_symtab_read): Add unsatisfied common symbols to
- the minimal symbol table. All common symbols are "unsatisfied"
- when -E is passed to the linker.
-
-Thu Jul 20 15:04:57 1995 Fred Fish <fnf@cygnus.com>
-
- * top.c (show_endian): Cast first arg of printf_unfiltered to
- correct type of "char *".
-
-Thu Jul 20 14:18:51 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * lynx-nat.c (child_wait): A thread_id of zero from wait apparently
- means the process is single threaded, so there's no need to add
- it to the thread list. Handle case where multi-threaded process
- reverts back to a single-threaded process.
-
- * gdbserver/low-hppabsd.c: Remove error declaration.
- * gdbserver/low-sparc.c: Likewise.
- * gdbserver/low-sun3.c: Likewise.
- * gdbserver/server.h: Remove error and fatal declaration.
- * gdbserver/utils.c (error): Update to be compatable with recent
- changes in defs.h.
- (fatal): Likewise.
-
-Wed Jul 19 22:42:43 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/m68k/tm-m68kv4.h (DWARF_REG_TO_REGNUM): Define to
- correctly map floating point registers numbers.
-
- * dwarfread.c (locval, new_symbol): Handle variables that are
- optimized out.
-
- * mdebugread.c: Replace all uses of builtin_type_* with
- mdebug_type_*. Define and initialize mdebug_type_*.
-
- * serial.h (serial_close): Add additional argument `really_close'.
- (SERIAL_CLOSE): Update serial_close call accordingly.
- (SERIAL_UN_FDOPEN): Use serial_close to handle refcnt properly.
- * serial.c (serial_close): Handle `really_close'.
- * serial.h (scb_base): Moved to serial.c, made static.
-
- * valops.c (value_addr): Don't coerce arrays.
- (typecmp): Coerce arrays instead of calling value_addr if necessary.
-
-Wed Jul 19 18:19:28 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- From Richard Earnshaw (rearnsha@armltd.co.uk):
- * infrun.c (wait_for_inferior): Set the convenience variable
- $_exitcode to the termination code of the inferior.
- * top.c (quit_command): Accept optional expression to use
- as parameter to exit().
-
-Wed Jul 19 13:15:32 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * remote.c (remote_wait): When getting registers, check endianess and
- do conversion if necessary.
-
-Tue Jul 18 00:41:31 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * gdbserver/low-hppabsd.c: New file.
- * gdbserver/Makefile.in (SFILES): Add low-hppabsd.c.
- * config/pa/hppabsd.mh (XDEPFILES): Add ser-tcp.o.
- (GDBSERVER_DEPFILES): Add low-hppabsd.o.
- * config/pa/hppaosf.mh: Likewise.
-
-Mon Jul 17 21:35:18 1995 Fred Fish <fnf@cygnus.com>
-
- * dache.c (struct dcache_block): Change data member from unsigned
- char to char, since everything passed in and out of dcache is char
- or casted to appropriate type anyway.
- (dcache_alloc): Move assignment of db out of test and combine
- separate tests into if-else.
- (dcache_peek_byte): Change ptr from unsigned char* to char*.
- (dcache_peek_byte): Remove now unnecessary cast in read_memory call.
- (dcache_peek): Change cast of incoming data arg.
- (dcache_poke): Change cast of addr of incoming data arg.
- (dcache_info): Mask data passed to printf_filtered to lsbyte only.
- (dcache_info): Change printf_filtered arg from "% 2x" to " %2x".
- * target.c (debug_to_thread_alive): Change return type to int and
- return zero, for type compatibility with other *_thread_alive
- funcs.
- (cleanup_target): Change cast of ignore function to match type of the
- to_thread_alive member.
- * defs.h (error_hook): Add ATTR_NORETURN.
- * defs.h (NORETURN, ATTR_NORETURN): Switch from volatile to
- __attribute__ method with gcc 2.7, to avoid gcc 2.6.3 bug.
- * remote.c (remote_wait): Cast first arg to strtol, strchr, and
- strncmp to "const char *" from "unsigned char *".
- (remote_wait): Cast arg to putpkt and strcpy from "unsigned char *"
- to "char *".
- (remote_wait): Change printf format for long arg from "%d" to "%ld".
- (getpkt): Remove unused variable "bp".
- (remote_fetch_word, remote_store_word): Ifdef out apparently unused
- functions.
- * breakpoint.c (watchpoint_check): Removed unused variables
- "saved_level" and "saved_frame".
- * valops.c (value_arg_coerce): Add other enum TYPE_CODE_* and
- default cases to switch for completeness.
- * infrun.c (wait_for_inferior): Enclose "have_waited" label
- in #ifdef that matches the one in which it is referenced.
- * ser-unix.c (hardwire_noflush_set_tty_state): Enclose otherwise
- unused variable "state" in #ifdef that matches one in which it is
- referenced.
- * eval.c (evaluate_subexp_standard): Remove unused variable "var".
- * eval.c (evaluate_subexp_standard): Remove unused variable
- "tmp_symbol".
- * valarith.c (value_subscript): Remove unused variable
- "lowerbound", which is redeclared in a nested scope prior to use.
- * printcmd.c (print_frame_nameless_args): Use "%ld" to print long
- arg, not "%d".
- * {mem-break.c, remote-pa.c, remote.c, saber.suppress}:
- Remove unused static var "check_break_insn_size".
- * buildsym.c (finish_block): Add other enum LOC_* and default
- cases to switch for completeness.
- ch-lang.c (type_lower_upper): Removed unused label "retry".
- Add other enum TYPE_* and default cases to switch for completeness.
- * f-typeprint.c (f_type_print_args): Ifdef out unused function
- that may be used someday when Fortran support is complete.
- * ch-valprint.c (chill_print_type_scalar): Add other enum
- TYPE_* and default cases to switch for completeness.
- (chill_val_print): Remove unused local var "high_bound" that
- is redeclared in a nested scope prior to use.
- (chill_var_print): Use "%ld" to print long arg, not "%d".
- * regex.c (re_compile_fastmap, re_match_2): Add remaining enum
- types and default to switches for completeness.
- * minsyms.c (lookup_minimal_symbol_text): Delete unused variable
- "trampoline_symbol".
- (prim_record_minimal_symbol_and_info): Return NULL rather than
- trash.
- * elfread.c (elf_symtab_read): Don't dereference NULL returns from
- record_minimal_symbol_and_info.
- * f-lang.c (saved_function_list_end): Ifdef out unused variable
- that may be used someday.
- * f-valprint.c (f_val_print): Remove unused local "straddr".
-
-Mon Jul 17 13:08:00 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * stabsread.h (struct stab_section_list): Define.
- (coffstab_build_psymtabs): Remove staboff and stabsize parameters.
- Add textaddr, textsize, and stabs parameters.
- * gdb-stabs.h (struct dbx_symfile_info): Remove text_sect field.
- Add text_addr and text_size fields.
- (DBX_TEXT_SECT): Don't define.
- (DBX_TEXT_ADDR, DBX_TEXT_SIZE): Define.
- * coffread.c: Include <ctype.h>.
- (struct coff_symfile_info): Remove stabsect and stabindexsect
- fields. Add textaddr, textsize, and stabsects fields.
- (coff_locate_sections): Record the address of the .text section,
- and total the sizes of all sections with names beginning with
- ".text". Don't bother to record a .stab.index section (COFF
- doesn't use them). Make a linked list of all sections with names
- beginning with ".stab".
- (coff_symfile_read): Adjust call to coffstab_build_psymtabs for
- new parameters.
- * dbxread.c (dbx_symfile_read): Use DBX_TEXT_ADDR and
- DBX_TEXT_SIZE, rather than getting both from DBX_TEXT_SECT.
- (dbx_symfile_init): Set DBX_TEXT_ADDR and DBX_TEXT_SIZE, not
- DBX_TEXT_SECT.
- (elfstab_build_psymtabs): Likewise.
- (stabsect_build_psymtabs): Likewise.
- (symbuf_sections, symbuf_left, symbuf_read): New static variables.
- (fill_symbuf): If symbuf_sections is not NULL, read symbols from
- multiple sections.
- (coffstab_build_psymtabs): Remove staboffset and stabsize
- parameters. Add textaddr, textsize, and stabsects parameters.
- Set DBX_TEXT_ADDR and DBX_TEXT_SIZE, not DBX_TEXT_SECT. Handle
- multiple stabs sections.
- * os9kread.c (os9k_symfile_read): Use DBX_TEXT_ADDR and
- DBX_TEXT_SIZE, rather than getting both from DBX_TEXT_SECT.
- (os9k_symfile_init): Set DBX_TEXT_ADDR and DBX_TEXT_SIZE, not
- DBX_TEXT_SECT.
-
- * remote-vx.c (vx_ops, vx_run_ops): Initialize new to_thread_alive
- field.
-
-Sat Jul 15 01:02:53 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * config/alpha/alpha-osf3.mh, config/alpha/nm-osf3.h: New files
- for OSF/1-3.x procfs support.
- * configure.in (alpha-dec-osf): Use them when configuring
- for OSF/1-3.x.
- * configure: Updated.
- * target.c: Include <string.h>.
-
-Fri Jul 14 16:16:56 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * Makefile.in, configure.in: Use one variable, frags, to hold
- pathnames of makefile fragments.
- * configure: regenerated.
-
-Fri Jul 14 09:49:47 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * procfs.c (procfs_ops): Fix typo in last change.
-
-Thu Jul 13 13:42:38 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * inftarg.c (child_thread_alive): New function to see if a
- particular thread is still running.
- (child_ops): Add child_thread_alive entry.
- * remote.c (remote_thread_alive): New function to see if a
- particular thread is still alive.
- (remote_ops): Add remote_thread_alive.
- * target.c (dummy_target): Add dummy entry for thread_alive.
- (cleanup_target): de_fault thread_alive too.
- (update_current_target): INHERIT thread_alive too.
- (debug_to_thread_alive): New function.
- (setup_target_debug): Add debug_to_thread_alive.
- * target.h (struct target_ops): Add to_thread_alive.
- (target_thread_alive): Define.
- * thread.c (info_threads_command): Don't call kill; use
- target_thread_alive instead.
- * config/nm-lynx.h (CHILD_THREAD_ALIVE): Define.
- * gdbserver/low-lynx.c (mythread_alive): New function.
- (mywait): Don't restart any threads after a new thread notification,
- let the generic code handle it.
- * gdbserver/low-sparc.c (mythread_alive): Dummy version.
- * gdbserver/low-sun3.c (mythread_alive): Likewise.
- * gdbserver/server.c (main): Handle thread_alive requests.
- * gdbserver/server.h (mythread_alive): Declare.
- * corelow.c (core_ops): Add dummy entry for thread_alive.
- * exec.c (exec_ops): Likewise.
- * m3-nat.c (m3_ops): Likewise.
- * monitor.c (monitor_ops): Likewise.
- * procfs.c (procfs_ops): Likewise.
- * remote-array.c (array_ops): Likewise.
- * remote-e7000.c (e7000_ops): Likewise.
- * remote-es.c (es1800_ops, es1800_child_ops): Likewise.
- * remote-mips.c (mips_ops): Likewise.
- * remote-pa.c (remote_hppro_ops): Likewise.
- * remote-sim.c (gdbsim_ops): Likewise.
- * sparcl-tdep.c (sparclite_ops): Likewise.
-
-Tue Jul 11 11:15:55 1995 Kung Hsu <kung@rtl.cygnus.com>
-
- * solib.c: Add _DYNAMIC__MGC base symbol for Mentor Graphics Inc.
- * solib.c (match_main): New function for checking name of main.
- * solib.c (solib_add): Not to add if solib match main.
-
-Fri Jul 7 14:41:56 1995 Kung Hsu <kung@rtl.cygnus.com>
-
- * elfread.c (elf_symtab_read): Fix a bug ignoring compiler
- generated internal labels ($LM...).
-
-Wed Jul 5 11:38:36 1995 Kung Hsu <kung@rtl.cygnus.com>
-
- * defs.h: if __GO32__ or WIN32 the directory separating symbol should
- be '\' not '/'.
-
- * remote-nindy (nindy_wait): Use infinite timeout reading after
- esacpe character.
-
-Tue Jul 4 10:30:22 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * infrun.c (wait_for_inferior): When switching from one thread to
- another, save infrun's state for the old thread and load infrun's
- previous state for the new thread.
- * thread.c (struct thread_info): Add new fields for thread specific
- state saved/restored in infrun.c.
- (add_thread): Initialize new fields.
- (load_infrun_state): New function.
- (save_infrun_state): New function.
- * thread.h (load_infrun_state): Provide external decl.
- (save_infrun_state): Likewise.
-
- * infrun.c (wait_for_inferior): When we hit a breakpoint for the
- wrong thread, make sure to write the fixed PC value into the thread
- that stopped. Restart all threads after single stepping over a
- breakpoint for a different thread.
- * breakpoint.c (set_momentary_breakpoint): Make momentary
- breakpoints thread specific in a multi-threaded program.
- * lynx-nat.c (child_resume): Add some comments. Correctly
- choose between the single and multi-threaded step and continue
- ptrace calls.
-
-Fri Jun 30 16:15:36 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * config/h8300/h8300.mt: Renamed from h8300hms.mt.
- * config/h8500/h8500.mt: Renamed from h8500hms.mt.
- * config/z8k/z8k.mt: Renamed from z8ksim.mt.
- * configure, configure.in: Update to reflect renamings.
-
- * remote-sim.c (sim): New command, passes commands to simulator.
- (simulator_command): New function.
- (gdbsim_ops): Clean up.
- * remote-sim.h (sim_do_command): Declare.
- * sh-tdep.c (memory_size): Remove command.
-
- * Makefile.in (SIM, SIM_OBS): New variables.
- (CLIBS, CDEPS): Add value of SIM.
- (DEPFILES): Add value of SIM_OBS
-
- * config/arm/arm.mt, config/h8300/h8300.mt, config/h8500/h8500.mt,
- config/sh/sh.mt, config/sparc/sp64sim.mt, config/w65/w65.mt,
- config/z8k/z8k.mt: Remove simulator files from TDEPFILES,
- define in SIM_OBS and SIM.
- config/sparc/sp64sim.mt (SIMFILES): Remove.
-
- * remote-z8k.c: Remove, was superseded by remote-sim.c
- * Makefile.in, mpw-make.in: Remove references to remote-z8k.c.
-
-Sun Jun 25 15:30:43 1995 Stan Shebs <shebs@cygnus.com>
-
- * remote.c (remote_read_bytes, remote_write_bytes): Second arg
- should be char *, not unsigned char *.
- * dcache.h (memxferfunc): Ditto.
- * monitor.c (monitor_write_memory, monitor_read_memory_single):
- Ditto.
- (monitor_make_srec): Let compiler figure size of hextab.
-
-Sat Jun 24 19:27:37 1995 Jeffrey A. Law <law@rtl.cygnus.com>
-
- * lynx-nat.c (child_wait): Don't restart new threads and loop
- to the top of child_wait; let the machine independent code in
- wait_for_inferior deal with new thread notifications.
-
-Fri Jun 23 11:51:58 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * remote-nindy (nindy_load): Put in target specific load, it's
- 20 times faster.
-
-Thu Jun 22 20:21:59 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * utils.c (error): Move local `args' outside conditional,
- move local `string1' inside, declare function as void if
- non-ANSI compiler, dereference error_hook when calling.
-
- * mac-xdep.c (stdarg.h): Don't include.
-
-Thu Jun 22 13:12:33 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * remote-nindy.c (nindy_wait): Change timeout in SERIAL_READCHAR.
-
-Wed Jun 21 13:24:41 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * hppam3-nat.c: Change HP800_THREAD_STATE to TRACE_FLAVOR and
- HP800_THREAD_STATE_COUNT to TRACE_FLAVOR_SIZE.
-
-Wed Jun 21 05:57:56 1995 Steve Chamberlain <sac@slash.cygnus.com>
-
- * monitor.c: Turn on caching.
- (monitor_printf): If a ^C was sent, don't expect to see its
- echo.
- (monitor_open): Enable caching.
- (monitor_resume, monitor_load): Flush cache.
- (monitor_xfer_memory): Call cache routine.
- (monitor_dump_regs): New.
- (monitor_fetch_registers): If monitor_dump_regs available
- then use it.
- (monitor_load): Don't ref exec_bfd if it's NULL.
- (monitor_load_srec): Use new monitor_make_srec calling convention.
- (monitor_make_srec): Rewrite to cope with two, three and four byte
- addresses.
- * remote-hms.c (hms_cmds): Initialze end-of-command delim.
- * dcache.h, dcache.h: Rewritten.
- * remote.c: Reenable caching.
- (getpkt): Reduce MAX_TRIES to 3.
- (remote_xfer_memory): Use dcache_xfer_memory.
- * defs.h (error_hook): New.
- * top.c (error_hook): New definition.
- * utils.c (error): Use error_hook if initialized.
- * sparcl-tdep.c (HAVE_SOCKETS): Don't define if GO32 or WIN32. Use
- HAVE_SOCKETS in place of #ifndef GO32.
-
-Tue Jun 20 22:17:44 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * config/pa/tm-hppa.h (PSW_*): Define processor status word masks.
- (INSTRUCTION_NULLIFIED): Allow specific targets to override.
- * config/pa/tm-hppao.h (INSTRUCTION_NULLIFIED): Define to work
- around losing mach kernel behavior.
-
-Tue Jun 20 12:03:36 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * monitor.c (monitor_wait): Don't use the watchdog timeout
- if its value is 0.
- * w89k-rom.c (w89k_open): Define to be static.
-
-
-Sat Jun 17 10:17:16 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * somsolib.c (som_solib_add): Validate regexp argument.
- Don't assume the first entry on dld's library list is the main
- program. Don't load the same library more than once and don't
- consider the main program a shared library.
- (som_solib_sharedlibrary_command): New function
- (_initialize_som_solib): Add "sharedlibrary" command.
-
-Thu Jun 15 14:54:58 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * array-rom.c: Remove, no longer used.
-
- * remote-hms.c (hms_open): Make static.
-
- * mpw-config.in (MacSerial.h): Copy from version in {CIncludes},
- not {MPW}Interfaces:CIncludes.
- * ser-mac.c (mac_baud_rate_table): Fix value for 38400 baud.
-
-Wed Jun 14 14:27:07 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * ch-exp.y: Remove lots of unsupported productions and names.
- Add support for IF-expressions, ORIF, ANDIF, NUM, and ADDR.
-
-Tue Jun 13 21:40:11 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * parser-defs.h (enum precedence): Added PREC_BUILTIN_FUNCTION.
- * expression.h (enum exp_opcode): Added UNOP_LOWER, UNOP_UPPER,
- UNUP_LENGTH.
- * expprint.c (dump_expression): Handle the new exp_opcodes.
- (print_subexp): Handle PREC_BUILTIN_FUNCTION.
- (print_simple_m2_func): Removed.
- (print_subexp): Remove support for Modula2 builtin functions.
- * m2-lang.c (m2_op_print_tab): Add support for builtin functions.
- * ch-exp.y: Parse LOWER, UPPER, and LENGTH builtins.
- (write_lower_upper_value): Convenience function for LOWER and UPPER.
- (upper_lower_argument, length_argument): Removed non-terminals.
- * ch-lang.c (chill_op_print_tab): Entries for UPPER, LOWER, LENGTH.
- (type_lower_upper): New function. Calculate LOWER/UPPER of type.
- (value_chill_length): New function. Calcalate LENGTH of ARRAY/STRING.
- (evaluate_subexp_chill): Handle UNOP_LOWER, UNOP_UPPER, UNOP_LENGTH.
-
-Mon Jun 12 12:48:13 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- Windows support bits from Steve Chamberlain <sac@slash.cygnus.com>.
- * defs.h: Don't declare strchr and friends if WIN32.
- (DIRNAME_SEPARATOR): Move here from source.c.
- (SLASH_P, SLASH_CHAR, SLASH_STRING, ROOTED_P): New macros,
- symbolic definitions for filename bits.
- * top.c (cd_command): Use these.
- * source.c (mod_path, openp): Ditto.
- * terminal.h: Disable termio/sgtty definitions if WIN32.
- * findvar.c (registers_changed): Call registers_changed_hook
- if it is defined.
-
-Mon Jun 12 12:22:05 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * Makefile.in (distclean, realclean): Remove config.cache and
- config.log.
-
-Mon Jun 12 00:21:59 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * somsolib.c: Include gdb-stabs.h.
- (som_solib_section_offsets): Use SECT_OFF_XXX rather than 0, 1,
- etc. Initialize offsets for RODATA & BSS too.
-
-Sat Jun 10 17:59:11 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * hppa-tdep.c (frame_chain): Try to compensate for incomplete
- register information in core files when backtracing.
-
-Fri Jun 9 14:51:38 1995 Stu Grossman (grossman@cygnus.com)
-
- * remote-nrom.c: Remove everything but download code. More
- cleanups.
-
-Thu Jun 8 15:06:00 1995 Stu Grossman (grossman@cygnus.com)
-
- * defs.h maint.c monitor.c remote-mips.c remote.c: Add support
- for `watchdog' variable. This allows the user to put an upper
- limit on the amount of time that GDB will wait for the target to
- return from a step or continue operation. This will primarily be
- used for the testsuite, where it is difficult to come up with a
- reasonable timeout for things like function calls, which can take
- as long as three minutes under some circumstances. If the
- watchdog timer expires, GDB will generate an error that looks like
- `Watchdog has expired.', and will detach from the target.
-
- * remote-mips.c (mips_open): Setup initial frame from target.
- Print it out so that user is told where the program is stopped
- when they attach.
-
- * remote-nrom.c: Loads of cleanups. Use serial code to open
- network connections. Use expect() to wait for response to
- download command.
-
- * ser-tcp.c (tcp_open): Retry connection if we get ECONNREFUSED.
-
- * serial.c serial.h (serial_open serial_fdopen serial_close):
- Allow users to open the same device multiple times. They all get
- to share the same serial_t. This is about the only way to have
- multiple active targets use the same device (for download and
- debug).
-
- * sparcl-tdep.c: Keep #include <unistd.h> away from GO32.
-
- * target.c: Add `targetdebug' variable. If this is non-zero,
- then a special target is put at the top of the target stack which
- will cause all calls through the target vector to have their args
- and results printed out.
-
-Wed Jun 7 17:40:37 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * ch-exp.y: Handle <primitive_value> "->" <modename>.
-
-Wed Jun 7 17:46:33 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * mem-break.c (LITTLE_BREAKPOINT): If BREAKPOINT and
- {LITTLE,BIG}_BREAKPOINT are all defined, don't redefine.
- (BIG_BREAKPOINT): Ditto.
-
- * config/rs6000/tm-rs6000.h (BREAKPOINT): Define as either
- BIG_BREAKPOINT or LITTLE_BREAKPOINT depending on the target byte
- order.
-
-Wed Jun 7 12:41:42 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * somsolib.c (som_solib_section_offsets): Handle relative pathnames.
-
- * hppa-tdep.c (frame_saved_pc): Handle backtracing through signal
- handler in dynamically linked executables.
-
-Tue Jun 6 10:44:25 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- From Andrew Cagney <cagney@highland.com.au>
- * rs6000-tdep.c (single_step): Handle both little and big endian
- breakpoints.
- (gdb_print_insn_powerpc): Deal with disassembling both little and
- big endian PowerPC systems.
- (_initialize_rs6000_tdep): Use gdb_print_insn_powerpc to handle
- disassembly, rather that assuming big endian order.
-
- * config/rs6000/tm-rs6000.h (BREAKPOINT): Delete.
- (BIG_BREAKPOINT): Define, big endian breakpoint instruction.
- (LITTLE_BREAKPOINT): Define, little endian breakpoint instruction.
-
-Sat Jun 3 01:54:56 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * README: Add note about Unixware 2.x.
-
- * dbxread.c (process_one_symbol): Check for exact symbol name
- match when fixing up N_GSYM and N_STSYM symbols from Sun acc.
-
- * valprint.c (value_print_array_elements): Use
- fprintf_filtered to put out `<repeats %u times>',
- from schwab@issan.informatik.uni-dortmund.de (Andreas Schwab).
-
- * value.h (struct value): Change `repetitions' field from
- `short' to `int' type.
-
-Fri Jun 2 11:17:23 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * arc-tdep.c (arc_bfd_mach_type): New static global.
- (codestream_fill): Handle byte order differences.
- (setup_prologue_scan): Don't read stdarg function's "sub sp,sp,N".
- (arc_get_frame_setup): Read it here.
- (arc_frame_saved_pc): And here.
- (arc_print_insn): New function.
- (arc_set_cpu_type): Set arc_bfd_mach_type. Don't set tm_print_insn.
- (_initialize_arc_tdep): Set tm_print_insn to arc_print_insn.
-
-Wed May 31 12:04:01 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * nlm/{configure.in, Makefile.in}: Converted to use autoconf.
- * nlm/configure: New file, generated with autoconf 2.3.
-
- * nlm/configure.in: Use sed instead of awk to get the value of
- cpufile. Awk is not a utility required by the GNU coding
- standards. This change also fixes the rigid whitespace
- requirements that were required for awk.
-
- * sparclite/aload.c: Use a file descriptor instead of a stdio
- stream for i/o with target board.
- Use #error if HAVE_TERMIOS is not defined.
-
- * sparclite/{Makefile.in, configure.in}: Converted to use
- autoconf.
- * sparclite/configure: New file, generated with autoconf 2.3.
-
-Sun May 28 23:10:07 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * defs.h: Include either varargs.h or stdarg.h (for va_list).
- Fix stupid thinko in last change ("..." -> "va_list").
-
- * defs.h (vprintf_filtered declaration): Add PARAMS prototype;
- gcc-2.5 chokes on format attributes for unprototyped functions.
- (vfprintf_filtered declaration): Likewise.
- (vprintf_unfiltered declaration): Likewise.
- (vfprintf_unfiltered). Likewise.
-
-Sat May 27 23:54:17 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * configure.in: Use sed instead of awk to get the values of
- hostfile, targetfile and nativefile. Awk is not a utility
- required by the GNU coding standards. This change also
- fixes the rigid whitespace requirements that were required
- for awk.
- * configure: regenerated.
-
-Sat May 27 16:24:04 1995 Angela Marie Thomas <angela@cirdan.cygnus.com>
-
- * sparclite/{Makefile,configure}.in: Add hooks for building with
- -lsocket & -lnsl for solaris2. Don't build aload/eload for DOS.
-
-Thu May 25 12:46:37 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdbserver/remote-utils.c (prepare_resume_reply): Add FIXME
- comment regarding signal numbering.
-
-Wed May 24 15:49:47 1995 Steve Chamberlain <sac@slash.cygnus.com>
-
- * arm-tdep.c (_initialize_arm_tdep): Use print_insn_little_arm
- now.
-
- * arm-tdep.c (convert_from_extended, convert_to_extended):
- New.
- * coffread.c (enter_linenos): Return if linetab 0.
- * config/arm/arm.mt (TDEPFILES): Add simulator support.
- * config/arm/tm-arm.h (FRAME_FIND_SAVED_REGS): Fix prototypes.
-
-Mon May 22 19:37:21 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * config/idt.mt: replace monitor and array-rom with the new
- remote-array.
-
-Mon May 22 15:38:25 1995 Stu Grossman (grossman@cygnus.com)
-
- * remote-nindy.c: Install Kung patch for PR 6820. I have no idea
- what this does...
-
- * breakpoint.c: Move defaults of watchpoint related macros into
- target.h.
- * target.h: Macros from breakpoint.c. Conditionalize based on
- TARGET_HAS_HARDWARE_WATCHPOINTS.
- * i386v-nat.c procfs.c: Use TARGET_HAS_HARDWARE_WATCHPOINTS
- instead of TARGET_CAN_USE_HARDWARE_WATCHPOINT to enable watchpoint
- code.
- * config/i386/nm-linux.h, config/mips/nm-irix4.h,
- config/pa/nm-hppab.h, config/sparc/tm-sparclite.h: #define
- TARGET_HAS_HARDWARE_WATCHPOINTS to enable watchpoint code.
-
-Mon May 22 06:47:30 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c, target.h: Move defaults of watchpoint related
- macros back to breakpoint.c. Required to get GDB compiling
- on Solaris again.
-
-Fri May 19 14:49:37 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * defs.h (ATTR_FORMAT): New macro, expands to gcc's format
- attribute when compiled by gcc.
- * defs.h, language.h, monitor.h: Changed many function
- declarations to use ATTR_FORMAT.
-
- * breakpoint.c (delete_command); source.c (directory_command);
- top.c (define_command): Changed call to query() that had too
- many arguments.
- * printcmd.c (address_info): Changed call to printf_filtered()
- that had too many arguments.
-
-Fri May 19 09:52:07 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (wait_for_inferior): Move assignments to stop_signal
- and stop_pc, and STOPPED_BY_WATCHPOINT code, back where they
- were--after the switch statement on w.kind. You can't read the
- registers of an inferior which has exited. Use a goto in the
- STOPPED_BY_WATCHPOINT code.
- * infrun.c (wait_for_inferior): Reinstate
- HAVE_STEPPABLE_WATCHPOINT and HAVE_CONTINUABLE_WATCHPOINT code.
-
-Fri May 19 06:15:40 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * utils.c, complaints.c, language.c, monitor.c, remote-array.c,
- remote-mips.c, remote-os9k.c, remote-st.c: Conditionalize use of
- stdarg rather than varargs on ANSI_PROTOTYPES not __STDC__; it
- must match the definition of PARAMS.
-
-Thu May 18 15:58:46 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * utils.c (fprintf_filtered, fprintf_unfiltered, fprintfi_filtered,
- printf_filtered, printf_unfiltered, printfi_filtered, query, warning,
- error, fatal, fatal_dump_core): Use stdarg.h macros when compiling
- with an ANSI compiler.
- * complaints.c (complain): Likewise.
- * language.c (type_error, range_error): Likewise.
- * monitor.c (monitor_printf, monitor_printf_noecho): Likewise.
- * remote-array.c (printf_monitor, debuglogs): Likewise.
- * remote-mips.c (mips_error): Likewise.
- * remote-os9k.c (printf_monitor): Likewise.
- * remote-st.c (printf_stdebug): Likewise.
-
- * defs.h, complaints.h, language.h, monitor.h: Add prototypes to
- match above changes.
-
- * printcmd.c: Remove uneeded #include <varargs.h>.
- * remote-e7000.c: Likewise.
-
- * f-typeprint.c (f_type_print_base): Fix typo found by above
- changes.
-
-Wed May 17 11:21:32 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * Makefile.in (xcoffread.o): Depend on partial-stab.h.
-
- * xcoffsolib.c (sharedlibrary_command): New command.
- * xcoffsolib.c (solib_info): Call xcoff_relocate_symtab.
- * xcoffsolib.c: Miscellaneous cleanups.
-
- * partial-stab.h: Ignore symbol descriptor '-' (for local
- variables with negative type numbers) without complaint.
-
- * rs6000-nat.c (vmap_ldinfo): Use bfd_stat rather than our own
- local emulation thereof. Remove unused variable ostart.
-
-Wed May 17 15:55:53 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * Makefile.in (config.status): changed target so that
- config.status --recheck is executed if configure script changes.
-
- * monitor.c (monitor_printf): Changed format specification in
- error message to work with pre-ansi compilers.
- (monitor_load_srec): reduced length of s-records from 128 to 32
- bytes so download is more reliable with the rom68k monitor.
-
- * rom68k-rom.c: Added trailing space to prompt string.
-
- * config/i386/xm-i386sco.h (HAVE_STRSTR): Removed.
- * config/i386/xm-go32.h, mswin/xm.h (SYS_SIGLIST_MISSING):
- Removed.
- * defs.h, config/{xm-lynx.h, xm-nbsd.h},
- config/i386/{xm-i386bsd.h, xm-linux.h},
- config/m68k/xm-hp300bsd.h, config/mips/xm-irix4.h,
- config/ns32k/xm-ns32km3.h, doc/gdbint.texinfo
- (PSIGNAL_IN_SIGNAL_H): Removed.
-
-Tue May 16 13:16:06 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * Makefile.in (Makefile): Added config.status to dependency list.
-
- * configure.in: Added INIT-CMDS argument to AC_OUTPUT which sets
- gdb_host_cpu, gdb_target_cpu and nativefile.
- * configure: regenerated.
-
-Mon May 15 23:50:51 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (parse_symbol): Do not relocate stBlock/scText
- symbols, their value is the displacement from the procedure address.
- * top.c (init_main): Add missing newlines to help strings for
- `if' and `while' commands, fix help string for `show commands'.
-
-Mon May 15 18:37:56 1995 Stu Grossman (grossman@cygnus.com)
-
- * breakpoint.c: Move defaults of watchpoint related macros into
- target.h. Use BP_TEMPFLAG and BP_HARDWAREFLAG instead of
- constants.
- * infrun.c (wait_for_inferior): Enhance comment near
- STOPPED_BY_WATCHPOINT.
- * target.h: Macros from breakpoint.c.
-
-Mon May 15 17:11:38 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * config/i386/{i386sol2.mh, i386v4.mh, ncr3000.mh},
- config/m68k/m68kv4.mh, config/mips/{irix4.mh, irix5.mh,
- mipsv4.mh}, config/sparc/sun4so2.mh (INSTALL): Removed, figured
- out by autoconf.
- * config/apollo68v.mh (RANLIB): Removed, figured out by autoconf.
-
- * Makefile.in, configure.in: Converted to use autoconf
- * aclocal.m4: New file, local autoconf macro definitions.
- * configure: New file, generated with autoconf 2.3.
-
-Mon May 15 14:46:41 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * remote.c (remote_kill): Add prototype.
- * cpu32bug-rom.c (cpu32bug_open): Properly define as static.
- * config/h8300/h8300hms.mt (TDEPFILES): Add monitor.o.
-
-Mon May 15 12:12:34 1995 Stu Grossman (grossman@cygnus.com)
-
- * sparclite/salib.c (win_ovf win_unf): Make window size constant
- into a variable (__WINSIZE) so that it can be controlled via the
- .h file.
- * sparclite/sparclite.h: Add SL933 #ifdef to set __WINSIZE to 6
- for the 933 board.
-
- * infrun.c: Add #ifdef HP_OS_BUG to all references to
- trap_expected_after_continue.
- * (wait_for_inferior): Fix for remote watchpoints. Don't try to
- insert breakpoints while target is running (this only works on
- *some* native targets). This may also speed up native watchpoints
- considerably.
-
-Sat May 13 13:55:04 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dwarfread.c (struct dwfinfo), dbxread.c (struct symloc),
- mdebugread.c (struct symloc), hpread.c (struct symloc),
- xcoffread.c (struct symloc): Fix inaccurate comment introduced
- 20 Apr 1995.
-
-Sat May 13 13:34:18 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * rs6000-tdep.c (find_toc_address): Revise comment.
- * symfile.c, symfile.h (init_psymbol_list): New function;
- consolidate duplicated copies from os9kread.c, dbxread.c
- and dwarfread.c.
- * defs.h: Declare info_verbose.
- * xcoffread.c: Extensive changes to support psymtabs.
-
-Fri May 12 13:48:41 1995 Stu Grossman (grossman@andros.cygnus.com)
-
- * cpu32bug-rom.c remote-est.c rom68k-rom.c: Update line_term element.
-
-Fri May 12 06:39:30 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * partial-stab.h: Expand comments.
-
-Thu May 11 19:01:37 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * Support debugging using native MACH primitives on hppa*-*-osf*.
- * configure.in: hppa*-*-osf* != hppa*-*-bsd* anymore.
- * config/pa/hppaosf.mh: New file.
- * config/pa/nm-hppao.h: Likewise.
- * hppam3-nat.c: Likewise.
- * config/pa/tm-hppao.h (PSW_SS): Define for single-stepping.
- (MACHINE_CPROC_*_OFFSET): Define.
- (TRACE_*): Define.
- (START_INFERIOR_TRAPS_EXPECTED): Delete definition.
-
-Wed May 10 18:59:26 1995 Stu Grossman (grossman@andros.cygnus.com)
-
- * hppa-tdep.c (read_unwind_info): Cosmetic cleanup.
- * (unwind_command): Clean it up and make it print things out
- nicer.
- * monitor.c: Add ^C handling capability (mostly ripped off from
- remote.c).
- * (monitor_printf): Make it check the command echo.
- * (monitor_printf_noecho): Similar to above, but doesn't check
- for echo.
- * (monitor_stop): No longer waits for prompt. That is the job of
- the caller. This makes things work much better for monitor_wait,
- which waits for the prompt itself.
- * (monitor_open): Deal with new monitor_stop semantics. Also,
- flush input after sending init strings to get rid of junk that may
- be output. Also, don't always send \r to remote. Use
- monitor_ops->line_term cuz proper character isn't always \r.
- * (monitor_fetch_register): Switch to completely different
- algorithm to deal with lame-ass monitors which put spaces in the
- middle of numbers, and prompt with a space!!!!!
- * (monitor_read_memory_single): New routine to be used with
- monitors that can only return one byte/short/long at a time. This
- is selected via MO_GETMEM_READ_SINGLE.
- * (monitor_load_srec): Use monitor_printf_noecho for sending S
- records. Most targets don't echo them.
- * (monitor.h): Get rid of cmd_delim. Add line_delim.
- * op50n-rom.c (op50n_cmds): Fill it up. Make it work.
- * w89k-rom.c: Change all eols from \r to \n. Change load_resp to
- ^Q to prevent error message.
- * config/pa/tm-hppa.h (CALL_DUMMY (for hppro)): Add special
- instruction sequence at end to make restore_pc_queue happy.
-
-Wed May 10 15:59:00 1995 Torbjorn Granlund <tege@adder.cygnus.com>
-
- * remote-est.c (est_open): Make static to match prototype.
-
-Tue May 9 16:58:50 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in: Add little endian PowerPC support.
- * config/powerpc/ppcle-eabi.mt: New file for little endian PowerPC
- support.
- * config/powerpc/tm-ppcle-eabi.h: ditto.
-
-Mon May 8 12:11:38 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * nlm/configure.in (gdb_host, gdb_host_cpu, gdb_target): Removed.
- These variables not used.
-
- * config/m68k/monitor.mt (TDEPFILES): Added cpu32bug-rom.o.
-
-Wed May 3 17:54:47 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * monitor.c (monitor_command): Don't use PROMPT until monitor
- target is known to be open.
- (monitor_make_srec): Don't define size of hextab.
-
-Tue May 2 18:32:24 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * configure.in (--enable-netrom): New configuration option.
- * Makefile.in (REMOTE_OBS): Rename from REMOTE_O, append
- value of NETROM_OBS.
- (NETROM_OBS): New variable.
- * remote-nrom.c: New file, NetROM target support.
- * config/a29k/a29k-udi.mt, config/i960/vxworks960.mt: Use
- REMOTE_OBS instead of REMOTE_O.
- * config/arc/arc.mt: Ditto.
-
-Fri Apr 28 23:30:00 1995 Stu Grossman (grossman@cygnus.com)
-
- * array-rom.c (_initialize_array array_open): Move baud_rate
- initialization from _initxxx to array_open to fix bug with
- overriding -b command line option.
-
-Thu Apr 27 20:29:34 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * Makefile.in (RUNTEST): Fix reference of `srcdir'.
-
-Wed Apr 26 19:01:08 1995 Steve Chamberlain <sac@slash.cygnus.com>
-
- * remote-hms.c: Rewrite to use new monitor conventions.
-
-Tue Apr 25 11:27:14 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dbxread.c: Add comment explaining lowest_text_address.
- Add comment regarding stringtab_global and psymtabs.
-
-Sat Apr 22 01:26:29 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * config/pa/tm-hppa.h (EXTRACT_STRUCT_VALUE_ADDRESS): Fix.
-
- * config/pa/tm-hppa.h (EXTRACT_RETURN_VALUE): Rewrite to correctly
- handle "short", "int" and small structures returned in registers.
-
-Fri Apr 21 12:57:53 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * minsyms.c: add new function lookup_minimal_symbol_text, to look
- for text symbol only.
- * breakpoint.c (create_longjmp_breakpoint): call
- lookup_minimal_symbol_text instead of lookup_minimal_symbol.
- * symtab.h: add lookup_minimal_symbol_text prototype.
-
-Fri Apr 21 12:03:44 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * sh-tdep.c (sh-opc.h): Don't include.
- (gdbcore.h): Include.
- (frame_find_saved_regs): Remove unused local.
-
-Thu Apr 20 10:12:21 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * dwarfread.c (struct dwfinfo), dbxread.c (struct symloc),
- mdebugread.c (struct symloc), hpread.c (struct symloc): Clean
- up comments.
-
-Wed Apr 19 16:58:11 1995 Stu Grossman (grossman@andros.cygnus.com)
-
- * hppa-tdep.c (deposit_17): New routine to deposit 17 bit
- constants into PA instructions.
- * Put #ifdefs around all signal handling code. Not generally
- needed for embedded boards.
- * (hppa_fix_call_dummy): Parameterize offsets into call dummy to
- allow different dummys to be used by this code. Use
- INSTRUCTION_SIZE instead of REGISTER_SIZE for things.
- Conditionalize setup of _sr4export fixup. Improve comments.
- * config/pa/tm-hppa.h: Define INSTRUCTION_SIZE. Use a different
- call dummy if PA_LEVEL_0 is defined. Better comments for call
- dummys. Define offsets for LDIL/LDO instructions which load
- function addresses.
- * config/pa/tm-pro.h: Get rid of signal handling stuff. Define
- PA_LEVEL_0 to disable mucking with space regs and such.
-
-Mon Apr 17 15:37:08 1995 Stu Grossman (grossman@andros.cygnus.com)
-
- * cpu32bug-rom.c monitor.h op50-rom.c remote-est.c rom68k-rom.c
- w89k-rom.c: Remove loadtypes, loadprotos and baudrates.
- * op50-rom.c: Fix copyrights and add load routine to op50n_cmds.
- * rom68k-rom.c (_initialize_rom68k): Don't set baud rate.
- * w89k-rom.c: Fix copyrights.
-
-Sun Apr 16 14:00:55 1995 Stu Grossman (grossman@andros.cygnus.com)
-
- * monitor.c: Move all xmodem stuff into xmodem.[ch]. Remove
- unnecessary remoteloadprotocol and remoteloadtype support.
- * (expect expect_prompt): Change names to monitor_expect and
- monitor_expect_prompt. Make them global.
- * (printf_monitor): Change name to monitor_printf. Make global.
- * (monitor_read_memory): Flush command echo to avoid parsing
- ambiguity with CPU32Bug monitor.
- * (monitor_load): Remove remoteloadprotocol and remoteloadtype
- support. Call target_ops->load_routine, default to
- monitor_load_srec.
- * (monitor_load_srec): Remove everything but S-record support.
- * monitor.h (monitor_ops): Add load_routine to provide monitor
- specific download capability.
- * remote-est.c: Clean up copyrights and comments.
- * w89k-rom.c: Use new xmodem support.
- * xmodem.c xmodem.h: New files to support xmodem downloads.
- * rom68k-rom.c remote-est.c: Fix copyrights, add load_routine
- entry to monitor_ops.
- * cpu32bug-rom.c: New file to support Moto BCC debuggers.
- * config/m68k/est.mt (TDEPFILES): Add cpu32bug.o.
- * config/pa/hppapro.mt (TDEPFILES): Add xmodem.o.
-
-Sat Apr 15 18:00:15 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * rem-multi.shar: Removed; superceded by gdbserver.
-
-Fri Apr 14 12:10:24 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * xcoffread.c (xcoff_sym_fns): Revise comment about merging this
- with coffread.c.
-
- * breakpoint.c (fixup_breakpoints): Removed.
- * rs6000-nat.c (vmap_symtab): Don't call fixup_breakpoints.
- (vmap_ldinfo, xcoff_relocate_core): Call breakpoint_re_set.
-
- * coffread.c (coff_symfile_offsets): Allocate SECT_OFF_MAX
- sections, not just SECT_OFF_MAX-1.
-
- * rs6000-nat.c (vmap_symtab), xcoffread.c: Re-do section offsets
- to be indexed by SECT_OFF_* instead of xcoff section numbers.
- * objfiles.c, remote.c: Remove comments regarding SECT_OFF_*.
- * symtab.h: Revise comment about block_line_section.
- * rs6000-nat.c (vmap_symtab): Don't relocate objfile->sections.
-
-Sat Apr 15 14:15:14 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * mpw-make.in (init.c): Don't try to do symbolic {o} in sed
- command, not allowed by some version of MPW Make.
- * ser-mac.c (mac-setbaudrate): Make it actually set baud rates.
-
-Sat Apr 15 14:05:09 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * alpha-tdep.c (alpha_push_arguments): Fix typo (TYPE_VALUE ->
- VALUE_TYPE). Do the cast for TYPE_CODE_BOOL, TYPE_CODE_CHAR,
- TYPE_CODE_ENUM, and TYPE_CODE_RANGE as well as TYPE_CODE_INT.
-
-Sat Apr 15 14:04:32 1995 Per Bothner <bothner@cygnus.com>
-
- * alpha-tdep.c (alpha_push_arguments): Only cast to long for
- TYPE_CODE_INT.
-
-
-Thu Apr 13 16:17:04 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * remote-array.c: New file for Array Tech LSI33k based controller
- board.
-
-Thu Apr 13 12:23:31 1995 Kung Hsu <kung@rtl.cygnus.com>
-
- * a29k-tdep.c (get_longjmp_target): Replace SWAP_TARGET_AND_HOST with
- extract_address.
- * remote-vxsparc.c: New file, preliminary check in, this configuration
- not supported yet.
- * remote-vxmips.c: ditto.
-
-Thu Apr 13 12:10:14 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * rs6000-tdep.c (xcoff_add_toc_to_loadinfo): Don't use a prototype
- to declare the function.
-
-Wed Apr 12 16:40:20 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * monitor.h (init_monitor_ops): Declare.
- * rom68k-rom.c: Clarify some comments.
- (rom68k_open): Define as static, to match decl.
-
-Wed Apr 12 16:36:44 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * gdb.gdb: New file.
- * .gdbinit: Move list-objfiles to gdb.gdb.
-
- * values.c (set_internalvar): Set modifiable flag of newval.
-
-Wed Apr 12 14:34:31 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * xcoffread.c: Call complain() rather than error() or printing a
- warning.
-
-Wed Apr 12 08:15:27 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * arc-tdep.c: #include "gdbcmd.h".
- (codestream_seek): Pass CORE_ADDR.
- (arc_cpu_type, tmp_arc_cpu_type, arc_cpu_type_table): New globals.
- (debug_pipeline_p): Likewise.
- (X_...): Instruction field access macros.
- (BUILD_INSN): Define.
- (codestream_tell): Allow for stream elements > 1 byte.
- (codestream_fill): Likewise.
- (setup_prologue_scan): New function.
- (arc_get_frame_setup): Call it. Update to current spec
- regarding prologues. Use BUILD_INSN.
- (skip_prologue): New argument `frameless_p'. Use BUILD_INSN.
- (arc_frame_saved_pc): New function.
- (frame_find_saved_regs): Use BUILD_INSN.
- (get_insn_type, single_step): New functions.
- (one_stepped): New global.
- (arc_set_cpu_type_command, arc_show_cpu_type_command): New functions.
- (arc_set_cpu_type): New function.
- (_initialize_arc_tdep): Define new `set' commands `cpu',
- `displaypipeline', and `debugpipeline'.
- * arc/tm-arc.h (TARGET_BYTE_ORDER): Delete.
- (TARGET_BYTE_ORDER_SELECTABLE): Define.
- (DEFAULT_ARC_CPU_TYPE): Define.
- (SKIP_PROLOGUE_FRAMELESS_P): Define.
- (BREAKPOINT): Delete.
- (BIG_BREAKPOINT, LITTLE_BREAKPOINT): Define.
- (DECR_PC_AFTER_BREAK): Change to 8.
- (NO_SINGLE_STEP): Define.
- (ARC_PC_TO_REAL_ADDRESS): Define.
- (SAVED_PC_AFTER_CALL): Use it.
- (NUM_REGS, REGISTER_BYTES): Fix.
- (FRAME_SAVED_PC): Call arc_frame_saved_pc.
- (FRAME_LOCALS_ADDRESS): Fix.
-
-Tue Apr 11 16:42:37 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * top.c, utils.c, defs.h: Remove error_hook. It is currently
- unused and would need to hook into error_begin()/return_to_top_level(),
- instead of error(), if it were to be used.
-
-Tue Apr 11 13:46:25 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * utils.c, defs.h (warning_begin): Renamed from warning_setup, for
- consistency with error_begin. Also print warning_pre_print.
- Document it better.
- * utils.c (warning): Use it.
- * utils.c (error_begin): Doc fix.
- * rs6000-nat.c (vmap_ldinfo): If we don't find ldinfo for the
- symfile_objfile, nuke it.
-
-Tue Apr 11 09:35:20 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * printcmd.c (print_address_numeric): Pass use_local to
- print_longest, rather than always passing 1.
-
- * nlm/Makefile.in: Remove comments discussing munch.
-
-
-Mon Apr 10 18:31:57 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- Merge in support for Mac MPW as a host.
- (Old change descriptions retained for informational value.)
-
- * mpw-config.in (i386-unknown-go32): Change from aout.
- (sh-hitachi-hms): New target.
- * mpw-make.in (BISON): Use byacc instead of bison.
- (VERSION): Bump to 4.14.1.
- (*-pinsn.*): Remove mentions everywhere.
- (all): Don't build MacGDB.
- (gdb, SiowGDB): Depend on Version.r.
- (Version.r): Generate from version info.
- * main.c (main): Pass program name to START_PROGRESS, END_PROGRESS.
- (main) [MPW]: Remove debugging hook.
- * mac-xdep.c (debug_openp): New flag.
- (mac_init): Set flag if env variable defined.
- * ser-mac.c (mac_open): Clarify error message.
- (mac_readchar): Call PROGRESS while looping.
- (mac_write): Call sleep instead of sec_sleep.
- (sec_sleep): Remove.
- * source.c (openp) [MPW]: Only print debugging info if debugging.
- * utils.c (query) [MPW]: Clarify that behavior is a bug.
-
- * mpw-make.in (init.c): Use open-brace instead of mpw-open-brace.
-
- * main.c, source.c: Remove hacks that replace long strings
- with shorter ones, now solved portably.
-
- * config/m68k/xm-mpw.h (spin.h): Include.
- (ALMOST_STDC): Only define if MPW_C.
- * config/m68k/tm-mac.h: New file, Mac target definitions.
-
- * mpw-config.in (m68k-apple-macos, ppc-apple-macos,
- i386-unknown-aout): New targets.
- (mk.tmp): Add *DEPFILES definitions.
- * mpw-make.in: Remove gC rules, clean up definitions for other
- include files, bump version, fix bogus \ that should be \Option-d.
- (init.c): Build correctly.
-
- * mpw-make.in (HFILES_NO_SRCDIR): Add somsolib.h
- (ALLDEPFILES): Add somsolib.c.
- (somsolib.o): Add some dependencies.
-
- * mpw-config.in: Use nm-empty.h if host is not target.
- (xdepfiles): Add mac-xdep.c.o.
- (xm_file): Remove.
- * mpw-make.in: Add Fortran files.
- (XDEPFILES): Remove.
-
- * mpw-config.in (MacSerial.h): Duplicate from standard Serial.h.
- * ser-mac.c (MacSerial.h): Include instead of Serial.h.
-
- * mpw-make.in: Use {s} instead of {srcdir} everywhere.
- (bindir, libdir): Remove extra colon.
- (source.c): Compile with C instead of gC.
- (c-exp.tab.c, ch-exp.tab.c, m2-exp.tab.c): Add {o}.
- (install-only): Don't install MacGDB.
- * source.c (openp) [MPW]: Add a debugging display.
- (open_source_file) [MPW]: Use MPW basename finders.
- [MPW_C]: Briefer versions of help for line and list commands.
-
- * mpw-make.in: Change references from paread.c to somread.c
-
- * mpw-make.in (VERSION): Update to 4.12.3.
- (SiowGDB): New target, GDB using SIOW library.
- (init-new.c): New target, attempt to generate init.c from sources.
- (main.c.o, top.c.o): Put each in its own segment.
- * main.c (main) [MPW]: Always call mac_init.
- * utils.c (query) [MPW]: Always return "yes" if in MacGDB, output
- an extra newline otherwise.
- * mac-xdep.c: More comments in various places, remove junk.
- (mac_init): Add tests for MPW and SIOW.
- (use_wne, has_color_qd): Renamed.
- (use_color_qd): New variable.
- (grow_window): Only do console resizing to console window,
- call resize_console_window.
- (zoom_window): Call resize_console_window.
- (resize_console_window, scroll_text): New functions.
- (adjust_console_sizes): Always align viewrect to even multiples of
- text lines.
- (adjust_console_text): Always scroll by whole lines.
- (hacked_vfprintf, hacked_puts, hacked_fputc, hacked_putc): Force a
- recalculation of scroll positions if a newline was output.
- (hacked_fflush): Similarly, for flushing.
- (hacked_fgetc): New function, aborts if called in MacGDB.
- * ser-mac.c (mac_readchar): Rename starttime to start_time,
- remove debugging printf.
- (mac_write): Sleep on first 4 writes.
- (sec_sleep): New function, works like standard sleep.
- * macgdb.r: Adjust positioning and contents of About box.
- Set minimum size to 2000K, preferred size to 5000K.
- * config/m68k/xm-mpw.h (fgetc): Define as a macro.
-
- * mpw-make.in (.c.o, .gc.o): Prefix segment names with gdb_.
- (top.c.o, annotate.c.o): Add build rules.
- * macgdb.r (SysTypes.r): Include.
- ('vers'): New resource, version info.
- (mFile, mEdit, mDebug): Enable all menu items.
- (mDebug): Add key equivalents for continue, step, next.
- (wConsole): Add zoom and close boxes to window.
- * mac-xdep.c (new_console_window): New function, code taken from
- mac_init.
- (mac_command_loop): Use GetCaretTime for wait interval, call
- do_idle on null events.
- (do_idle): New function.
- (zoom_window): Implement zooming.
- (v_scroll_proc): New function, handles vertical scrolling.
- (activate_window): Do activation of console window.
- (do_menu_command): Implement items of file, edit, and debug menus.
- (do_keyboard_command): Fix command extraction.
- (adjust_console_sizes, adjust_console_text): New functions.
- (hacked_fprintf, hacked_vfprintf, hacked_fputs, hacked_fputc,
- hacked_putc): Don't call draw_console.
- * ser-mac.c (mac_open): Add an error message for invalid ports.
- (first_mac_write): New global.
- (mac_write): Use first_mac_write to sleep on first several writes.
-
- * mpw-make.in (INCLUDE_CFLAGS): Add readline source dir.
- (READLINE_CFLAGS, READLINE_SRC, READLINE_DIR): Uncomment.
- (TSOBS): Don't compile inflow.c.
- (all, install): Add MacGDB.
- * main.c (main): Do Mac-specific init and command loop if a
- standalone app, skip full option help message if compiling
- with MPW C.
- (gdb_readline): If MPW, add a newline after the (gdb) prompt.
- * utils.c (_initialize_utils): If MPW, don't try to use termcap to
- compute the window size.
- * config/m68k/xm-mpw.h (printf, fprintf, fputs, fputc, putc,
- fflush): Define as macros that expand into hacked_... versions.
- (StandAlone, mac_app): Declare.
- * macgdb.r (SIZE): Set the default partition to 4000K.
- * mac-xdep.c (readline.h, history.h): Include.
- (terminal.h): Don't include.
- (mac_app): Define.
- (gdb_has_a_terminal): Define Mac-specific version.
- (do_keyboard_command): Simplify search for command string.
- (readline): Define as gdb_readline.
- Add other history/readline stubs to make main gdb link.
- (hacked_fprintf, hacked_printf, hacked_vfprintf, hacked_fputs,
- hacked_fputc, hacked_fflush): New functions, intercept output to
- stdout and stderr, send to console window.
-
- * mpw-make.in (MacGDB): New target, standalone Mac-hosted gdb.
- (XDEPFILES): Define.
- (main.c.o): Compile with gC instead of C.
- * mac-defs.h: New file, menu etc definitions shared between
- C and Rez files.
- * macgdb.r: New file, Rez (resource compiler) resource
- definitions.
- * mac-xdep.c: New file, Mac host interface code.
- * config/m68k/xm-mpw.h (PATHNAME_SEPARATOR): Rename to
- DIRNAME_SEPARATOR.
- (PATHNAME_SEPARATOR_STRING): Remove.
- (SIGQUIT, SIGHUP): Define.
- (fileno, R_OK): Define.
-
- * mpw-config.in: New file, MPW configuration fragment.
- * mpw-make.in: New file, MPW makefile fragment.
- * config/m68k/xm-mpw.h: New file, MPW host definitions.
- * ser-mac.c: New file, Mac serial interface.
-
-Mon Apr 10 16:47:57 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * valprint.c (print_longest): Fix a syntax error in #ifdef
- PRINTF_HAS_LONG_LONG.
-
- * config/mips/xm-irix5.h: turn on CC_HAS_LONG_LONG and
- PRINTF_HAS_LONG_LONG.
- * config/mips/tm-irix5.h: turn on FORCE_LONG_LONG.
-
-Sat Apr 8 02:47:45 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (parse_symbol): Use new variable
- nodebug_var_symbol_type as type of variables which don't have any
- ecoff debug info associated with them.
- (parse_symbol, parse_procedure): Use heuristics to determine if
- functions were compiled without debugging info and change their
- type to nodebug_function_symbol_type.
- (_initialize_mdebugread): Initialize nodebug_*_symbol_type.
-
- * source.c (line_info): Clear sal.pc for `info line' without
- arguments.
-
-Fri Apr 7 17:43:01 1995 Stu Grossman (grossman@andros.cygnus.com)
-
- * monitor.c: make_xmodem_packet and print_xmodem_packet go away.
- send_xmodem_packet shows up to do the obvious. Lots of fixes to
- xmodem downloads including resetting of block number at start of
- new transfers, fix for buffer overrun problem, addition of CRC
- generation code.
- * (monitor_open): loadtype_str and loadproto_str now default to
- first entry in monitor_ops->loadtypes.
- * (monitor_wait): Lengthen register dump buf, because of verbose
- Winbond monitor.
- * (monitor_fetch_register): Report unimplemented registers as 0.
- * (monitor_read_memory): Only do 16 byte aligned transfers
- because of formatting weirdness with the Winbond monitor. Also,
- ignore non-hex, non-whitespace formatting between bytes (same
- monitor).
- * (monitor_load): Clean up logic.
- * (monitor_load_srec): Re-do xmodem support. Move lots of it
- into send_xmodem_packet.
- * (getacknak): Get rid of polls and timeouts. Handle CRC
- requests from receiver.
- * (monitor_make_srec): Efficiency improvements. Don't call
- sprintf to output two digit hex numbers.
- * (crcinit, docrc): New, CRC-16 support routines.
- * (send_xmodem_packet): New routine to generate either CRC-16 or
- checksummed xmodem packets.
-
- * remote-est.c (est_loadtypes), rom68k-rom.c (rom68k_loadtypes):
- Reduce tables down to only the load types supported by each
- monitor.
-
- * w89k-rom.c (w89k_supply_register): Parses output of Winbond
- register dumps.
- * (w89k_loadtypes, w89k_loadprotos): Reduce to just srec/xmodem.
- * (w89k_cmds): Add clear all breakpoints, memory fill, and dump
- registers commands.
-
- * config/pa/tm-hppa.h: Define lots register offsets needed by
- w89k-rom.c.
-
-
-Thu Apr 6 17:00:46 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * Makefile.in (X11_INCLUDES): Define as empty.
- (X11_CFLAGS): Define as including $(X11_INCLUDES).
- (X11_LIB_SWITCHES): Define as empty.
- (X11_LIBS): Define as -lX11.
-
-
-Wed Apr 5 19:57:38 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * mips-tdep.c (mips_print_register): Remove unused variable
- our_type and call to init_type. Fixes memory leak. Reindent function.
-
- * mips-tdep.c (mips_print_register), findvar.c
- (write_register_bytes): Make buffer char[] instead of unsigned
- char[].
-
-Mon Apr 3 19:28:14 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * top.c, utils.c, main.c, defs.h: Replace error_pre_print with two
- variables: error_pre_print (for RETURN_ERROR) and quit_pre_print
- (for RETURN_QUIT). Fixes a bug whereby typing ^C (e.g. in "maint
- print sym") could output extraneous stuff.
- * objfiles.c: Don't declare error_pre_print; defs.h does it.
-
-Mon Apr 3 13:48:28 1995 Stu Grossman (grossman@andros.cygnus.com)
-
- * monitor.h: Add MO_GETMEM_NEEDS_RANGE flag.
- * monitor.c (monitor_read_memory): Use previously mentioned flag
- to send proper format memory examine commands to the w89k monitor.
- Also, try to handle bizarre format of memory dump...
-
- * op50-rom.c w89k-rom.c: Update to new monitor.[ch] conventions.
-
-Sat Apr 1 03:22:20 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * dbxread.c (process_one_symbol) [SOFUN_ADDRESS_MAYBE_MISSING]:
- Handle relocated symbol address.
- * partial-stab.h, case N_SO, SOFUN_ADDRESS_MAYBE_MISSING:
- Do not relocate a zero address.
-
-Thu Mar 30 19:46:36 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/a29k/tm-a29k.h: Nuke obsolete define CONTROL_END_ADDR; it
- is nowhere used.
-
- * stabsread.c (read_range_type): Remove FIXME comment about
- type-id (I presume this meant a number followed by = followed by a
- type) versus type number; Per fixed it.
-
-Wed Mar 29 09:56:04 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in: sparc-*-sunos5* is same as sparc-*-solaris2*.
-
-Wed Mar 29 18:30:03 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * remote-e7000.c (why_stop): Add new kinds of strings to expect
- from the emulator.
- (e7000_wait): Add interpretations for more stop reasons,
- including warnings for write protect and cycle address errors.
-
-Wed Mar 29 17:09:29 1995 Stu Grossman (grossman@cygnus.com)
-
- * monitor.c monitor.h remote-est.c rom68k-rom.c: Add start of
- support for interrupting target.
- * monitor.c (monitor_open): Send stop command before doing
- anything else.
- * (monitor_load_srec): Fix record size calculation to prevent end
- of segment from getting trashed.
- * rom68k-rom.c: Update to latest version of struct monitor_ops.
- * config/sparc/tm-sparc.h (FIX_CALL_DUMMY): Fix byte-order
- problems. Makes DOS hosted function calling work.
- * sparclite/crt0.s: Define _start to make COFF happy.
-
-Wed Mar 29 09:11:51 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * defs.h (atof): Don't provide an external declaration if atof is
- a macro.
-
-Wed Mar 29 00:01:07 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * rs6000-tdep.c (skip_prologue): Skip saving of LR and CR in
- the stack frame, fix typos in `st rx,NUM(r1)' and `stu r1,NUM(r1)'
- tests.
-
-Tue Mar 28 17:04:04 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * gdbtypes.c (create_range_type): If indextype has TYPE_FLAG_STUB
- set, set TYPE_FLAG_TARGET_STUB.
- (check_stub_type): Recalculate TYPE_LENGTH for range type.
- * stabsread.c (read_range_type): If index type number is followed
- by '=', back up, call read_type. and assume we have a true range.
- * gdbtypes.h (TYPE_FLAG_TARGET_STUB): Update comment.
-
-Mon Mar 27 22:51:54 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * alpha-nat.c, irix4-nat.c, irix5-nat.c, mipsv4-nat.c,
- sparc-tdep.c (supply_gregset, supply_fpregset): Fill inaccessible
- registers with zero to handle recent read_register_bytes change.
- * irix4-nat.c, irix5-nat.c, mipsv4-nat.c (supply_gregset,
- fill_gregset): Fix handling of CAUSE_REGNUM.
- * mips-nat.c (store_inferior_registers): Handle unwritable
- registers when storing a single register.
- * config/mips/tm-irix3.h (CAUSE_REGNUM, BADVADDR_REGNUM):
- Fix definitions.
-
- * mdebugread.c (parse_symbol, psymtab_to_symtab_1): Clear
- allocated mips_extra_func_info, if the debug info is corrupt,
- the PDR to fill it in might be missing.
-
-Mon Mar 27 14:43:00 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * vx-share/regPacket.h: a new file interfacing with vxworks.
-
-Sun Mar 26 13:22:47 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (bpstat_do_actions): Once we've executed the
- commands, set bs->commands to NULL.
-
-Sat Mar 25 01:16:10 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * buildsym.c (patch_subfile_name): Update last_source_file
- with the real source file name.
- * dbxread.c (end_psymtab): Handle static functions in the
- SOFUN_ADDRESS_MAYBE_MISSING case by passing pst->filename
- to lookup_minimal_symbol.
- (process_one_symbol): Ignore extra outermost context from
- SunPRO cc and acc.
- * stabsread.c (define_symbol): Do not complain for SunPRO
- static variable encoding if STATIC_TRANSFORM_NAME is defined.
- * sparc-tdep.c, config/sparc/tm-sun4sol2.h
- (sunpro_static_transform_name): Renamed from
- solaris_static_transform_name.
- * config/sparc/tm-sun4os4.h (STATIC_TRANSFORM_NAME):
- Define to sunpro_static_transform_name for acc 3.0 compiled
- executables.
- * procfs.c, config/alpha/nm-osf2.h (PROCFS_DONT_TRACE_FAULTS):
- Renamed from PROCFS_DONT_TRACE_IFAULT, don't trace any faults
- if defined.
- * procfs.c (info_proc_siginfo): Cast sip->si_addr to
- `unsigned long' and use `lx' format for printing it.
-
-Fri Mar 24 15:45:42 1995 Stu Grossman (grossman@cygnus.com)
-
- * configure.in: Move test for m68*-est-* before m68*-*-coff*.
- * findvar.c: Move default def of CANNOT_STORE_REGISTER closer to
- the beginning of the code.
- * (write_register_gen): New routine. Analogous to
- read_register_gen.
- * (write_register_bytes): Another rewrite! Make it smarter about
- not updating regs with the same value.
- * monitor.c (printf_monitor readchar): Use stderr instead of
- stdout to output debug info. Also cleanup readchar a little.
- * (expect): Make sure that excessive responses are null
- terminated.
- * (monitor_open): Check for magic number in monitor_ops struct.
- Allow multiple commands as init strings. Also, clear all
- breakpoints.
- * (monitor_resume monitor_wait): Send a command to dump all the
- regs for those targets which don't do so when waking up after a
- continue command.
- * (monitor_wait): Handle excessive response output better.
- * (monitor_write_memory): Use block fill, word, and long word
- commands (if they exist) to write memory more efficiently.
- * General cleanups to use flag bits instead of individual flag
- words in monitor_ops struct.
- * (monitor_command): Return output from command.
- * (monitor_load_srec): Allocate buffer only once. Use alloca.
- Wait for load response string instead of using a timeout to start
- sending S-records. Fix bug where value of srec_frame shrinks. If
- hashmark is set, print `-' for retransmissions. General cleanups.
- * (monitor_make_srec): Get rid of S-record default type kludge.
- * monitor.h: Use seperate struct for memory and register
- read/write commands. Memory commands can come in byte, word,
- long, and longlong forms.
- * (monitor_ops): Change lots of fields. Generalize some stuff.
- Put all flags into flags word. Allow init to be a list of commands.
- Add command for clearing all breakpoints, block fill, dumping all
- registers.
- * remote-est.c: Rewrite to use new monitor conventions.
- * config/m68k/est.mt (TDEPFILES): Add monitor.o.
- * config/m68k/tm-est.h: Set NUM_REGS to 18.
- * testsuite/gdb.base/break.exp: Lots of cleanups. Use gdb_test
- more thoroughly.
-
-Thu Mar 23 23:20:00 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * somsolib.c (som_solib_add): Handle case where a shared library
- referenced by a core file has sections without the SEC_ALLOC bit
- set (eg stabs sections).
-
-Thu Mar 23 15:07:08 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * breakpoint.c (bpstat_do_actions): For each element in the bpstat
- chain, do all the commands regardless of whether they run the
- inferior.
-
-Wed Mar 22 19:17:06 1995 Doug Evans <dje@cygnus.com>
-
- * mem-break.c (LITTLE_BREAKPOINT, BIG_BREAKPOINT): Define as
- BREAKPOINT if mono-endian.
- (break_insn): Deleted.
- (big_break_insn, little_break_insn): Define.
- (memory_insert_breakpoint): Handle bi-endian cpus.
- (BREAKPOINT_LEN): Define.
- (memory_remove_breakpoint): Use it.
- (memory_breakpoint_size): Likewise.
-
-Tue Mar 21 17:03:17 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * sparc-stub.c: add nop after 'bg good_wim'.
- * sparcl-stub.c: ditto.
-
-Tue Mar 21 13:34:12 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (handle_command): Don't print TARGET_SIGNAL_0,
- TARGET_SIGNAL_UNKNOWN, or TARGET_SIGNAL_DEFAULT.
-
-Mon Mar 20 10:09:59 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * hppab-nat.c (store_inferior_registers): Sync with HPUX version.
-
-Mon Mar 20 07:34:48 1995 Stu Grossman (grossman@cygnus.com)
-
- * hppah-nat.c (store_inferior_registers): Move check for
- CANNOT_STORE_REGISTER to a better place. Fixes ptrace I/O errors
- found by test suite during function calls, which attempts to write
- unwritable registers.
-
-Sat Mar 18 02:02:24 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * mdebugread.c (parse_symbol): If finishing a function without
- known parameter type info, set that from parameter symbols.
- Remove commented-out add_param_to_type support.
-
-Thu Mar 16 16:38:03 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (process_linenos): Make sure filename we pass to
- start_subfile will cause deduce_language_from_filename to return
- the correct thing. Reindent function to GNU standards.
-
-Thu Mar 16 15:54:00 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * nlm/gdbserve.c (handle_exception): #if out call to StopBell,
- as it is not available on NetWare 3 or PIN.
- * nlm/ppc.c (StopBell): Removed.
-
-Thu Mar 16 12:14:41 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (read_xcoff_symtab): When creating a dummy parameter
- inferred from the traceback tags, give its type the name
- "<non-float parameter>".
-
- * stabsread.c (rs6000_builtin_type): Recognize types -31 to -34.
-
-Wed Mar 15 15:09:29 1995 Stu Grossman (grossman@cygnus.com)
-
- * findvar.c (read_register_bytes write_register_bytes): Make
- these routines much smarter about updating registers from the
- target, only doing so when absolutely necessary. This really
- speeds up register modification on some remote targets.
-
- * monitor.c: More cleanups. Get rid of monitor_load_ascii_srec.
- BFD makes this unnecessary. Lots of debugging speedups.
- * (expect): NULL terminate return string.
- * (monitor_open monitor_supply_register parse_register_dump
- monitor_wait monitor_fetch_register): Switch to using GNU regexp
- library to parse multi-register displays.
- * (monitor_read_memory): Read multiple bytes (up to 16) at once.
- * (monitor_create_inferior): Call clear_proceed_status to make run
- command notice first breakpoint.
- * (monitor_load): Clean up. Reset inferior_pid, set pc to start
- address and reset symbol table stuff to make loads put things into
- a fresh state.
- * (monitor_load_srec): Lower sleep time to 1 second.
-
- * monitor.h (struct monitor_ops): Add register_pattern and
- supply_register to monitor_ops.
-
- * rom68k-rom.c: Add new support for handling register dumps.
- * config/m68k/tm-m68k.h: Define D0_REGNUM and A0_REGNUM for register
- dump handling.
-
-Wed Mar 15 15:18:27 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * utils.c, defs.h (putchar_unfiltered, fputc_unfiltered): Make
- argument be an int, not a char. Using a prototype followed by an
- old-style function definition in a case where an argument is
- widened is a GCC-ism not supported by the native AIX compiler.
-
-Wed Mar 15 12:22:35 1995 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * nlmstub.def: Removed, this was moved to nlm/gdbserve.def
- long ago.
-
- * configure.in (alpha-*-netware*): Removed configuration.
- * config/alpha/{alpha-nw.mt, gdbserve.mt, tm-alphanw.h}: Removed.
- * nlm/{README-ALPHA-NETWARE, aio.h, alpha-io.S, alpha-regdef.h,
- alpha.c, alpha.h, altdebug.h}: Removed.
-
- * nlm/gdbserve.c (main): Add support for processing BOARD=
- argument, deprecate NODE=.
-
-Wed Mar 15 10:58:26 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * c-exp.y (yylex): Make an empty character constant an error.
-
-Tue Mar 14 15:00:54 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * valops.c (value_arg_coerce): Do possible value_coerce_array
- before determining type argument to value_cast.
-
-Tue Mar 14 10:41:41 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * remote-es.c: Replace ignore with 0.
-
-Tue Mar 14 05:52:36 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * valops.c (value_repeat), eval.c (evaluate_subexp_standard):
- If VALUE_REPEATED is already set, just error out.
-
- * valops.c (value_cast, value_slice), parse.c (follow_types): Add
- FIXME-type-allocation comments.
-
- * gdbtypes.h (struct type): Fix comment about what units the
- TYPE_LENGTH is in.
-
-Mon Mar 13 18:27:25 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * ch-valprint.c (annotate.h): Include.
- * eval.c (evaluate_subexp_standard): Remove unused variable.
- (calc_f77_array_dims): Add parens to expression.
- * f-exp.y (yylex): Add parens to expression, remove unused label.
- * f-lang.h (calc_f77_array_dims): Declare.
- * f-valprint.c (f_val_print): Remove unused variables.
-
-Mon Mar 13 15:25:47 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * alpha-tdep.c (find_proc_desc): If pdr.framereg field is -1, don't
- use the PDR, just examine prologues instead.
-
-Fri Mar 10 16:13:18 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * config/arc/tm-arc.h: Change arc register names.
-
-Fri Mar 10 02:49:40 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- Fix problems with infinite recursion when printing a class
- that contains a static instance of the class.
- * cp-valprint.c (dont_print_vb_obstack): Renamed from
- dont_print_obstack, made static.
- (dont_print_statmem_obstack): New obstack, controls printing
- of static member classes.
- (_initialize_cp_valprint): Initialize it.
- (cp_print_static_field): New function, handles printing of
- static members.
- (cp_print_value_fields): New parameter dont_print_statmem to
- handle recursive printing of static member classes, use
- cp_print_static_field to handle printing of static members.
- * c-valprint.c (cp_print_value_fields): Update prototype and
- call to include additional dont_print_statmem parameter.
- * c-valprint.c, f-valprint.c (dont_print_obstack): Remove unused
- extern declaration.
-
- * alpha-tdep.c, findvar.c, infptrace.c: Include <string.h>.
-
- * config/alpha/tm-alpha.h (FRAME_FIND_SAVED_REGS): Call
- alpha_find_saved_regs if fi->saved_regs is still NULL.
-
- * elfread.c (elf_symtab_read): Ensure that the filename field
- of a minsym is nonempty. Ignore solib trampoline symbols from
- the main symbol table, they might have a bogus value.
-
- * procfs.c (set_proc_siginfo), config/alpha/alpha-osf2.mh:
- Fix typos in comments.
-
-Thu Mar 9 17:19:47 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * mdebugread.c (parse_symbol, psymtab_to_symtab_1): Initialize
- pdr.framereg field of MIPS_EFI_SYMBOL_NAME symbol to -1. That way
- we know whether the PDR ever got set.
- * mips-tdep.c (find_proc_desc): If pdr.framereg field is -1, don't
- use the PDR, just examine prologues instead.
-
-Wed Mar 8 23:35:10 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * somsolib.c (som_solib_section_offsets): Get offset of text
- section right.
-
-Wed Mar 8 16:12:21 1995 Stu Grossman (grossman@cygnus.com)
-
-
- * source.c (forward_search_command reverse_search_command): Set
- convenience variable $_ to be the line # of the match.
- * symtab.c (decode_line_1): Allow convenience variables to be
- used in line specs (for breakpoints and such).
-
-Wed Mar 8 12:51:00 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * Makefile.in (VERSION): Bump to 4.14.1.
- * NEWS, README: Update for 4.14.
- * i386v-nat.c (i386_insert_aligned_watchpoint): Fix declaration.
- (i386_insert_nonaligned_watchpoint): Call aligned instead of
- generic watchpoint insertion.
-
-Tue Mar 7 19:26:10 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * valops.c (value_slice): Do COERCE_VARYING_ARRAY.
-
-Tue Mar 7 00:23:47 1995 Stu Grossman (grossman@cygnus.com)
-
- * monitor.c, array-rom.c, monitor.h, rom68k-rom.c: Move target_ops
- into monitor.c.
- * monitor.c (monitor_create_inferior): Allow run command to start
- program.
-
- * monitor.c (monitor_load): Set PC to start address when done
- loading.
-
- * array-rom.c, monitor.h, rom68k-rom.c: Clean up target_ops.
- Remove ref to monitor_create_inferior.
-
- * monitor.c: More general cleanups. Add prototypes, remove
- unused routines. Fix bug with wrong number of args to error().
-
- * main.c (main): Don't start up GUI when running under gdb mode
- in emacs.
-
- * Makefile.in: Add rules for monitor.o and rom68k-rom.o to make
- Sun make (with VPATH) work...
-
- * monitor.c, monitor.h, rom68k-rom.c: Serious cleanup to make IDP
- (rom68k) target work right.
- * array-rom.c, op50-rom.c, w89k-rom.c: Partial updates to new
- monitor.c interface. More work needs to be done here.
- * config/m68k/tm-monitor.h: Change DECR_PC_AFTER_BREAK to 0 to
- match the IDP monitor. Also, set NUM_REGS to 18 cuz there's no
- floating-point for this card.
-
- * serial.h, ser-go32.c, ser-mac.c, ser-tcp.c, ser-unix.c: Add
- SERIAL_SETSTOPBITS to set the number of stopbits (needed for IDP
- board?!?!?).
-
- * defs.h, utils.c, remote-hms.c, remote-pa.c, remote.c: Fix defs
- and usage of fputc_unfiltered and putchar_unfiltered. Eliminate
- putc_unfiltered (it's superfluous).
-
- * command.h, command.c, top.c: Add var_enum command type. It's
- like var_string but allows only only one of the specified strings.
-
-Mon Mar 6 15:03:59 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * valops.c (value_cast): Don't use backslash newline--pre-ANSI
- compilers (such as SunOS4 /bin/cc) don't generally support it
- except in some contexts.
-
-Fri Mar 3 17:42:48 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * valops.c (value_cast): Check for cast to array type *before*
- we coerce array to pointer (in case arg2 is already array).
-
- * valops.c (call_function_by_hand): Set using_gcc to 2 if using
- gcc2. Needed for REG_STRUCT_HAS_ADDR to work on sparc.
- Also check REG_STRUCT_HAS_ADDR for union, array and string types.
-
- * valops.c (call_function_by_hand): Re-arrange code for pushing
- paramaters on the stack so we can do better STACK_ALIGN.
-
- * valops.c (call_function_by_hand): Call error if the number
- of arguments is fewer than parameter types in function type.
-
-Fri Mar 3 17:13:05 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * sparc-tdep.c (sparc_extract_struct_value_address): Move
- sparc64 support to here.
- (sparc64_extract_struct_value_address): Deleted.
- (dump_ccreg): Add a prototype so long long arg -> int.
- * sparc/tm-sp64.h (USE_STRUCT_CONVENTION): Define.
- (EXTRACT_STRUCT_VALUE_ADDRESS): Delete.
-
-Fri Mar 3 15:12:12 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (hpread_record_lines): New argument "offset". All
- callers changed. Use it to handle dynamic address relocation.
- (hpread_build_psymtabs): Adjust texthigh as we read each function
- debug symbol. Fix computation of texthigh.
- (hpread_read_subrange_type): Work around macro bugs in HP's
- compilers.
- (hpread_process_one_debug_symbol): Correctly map source lines.
-
- * somread.c (check_strange_names): Filter names emitted by the HP
- compiler when generating PIC code.
-
- * valops.c (value_struct_elt_for_reference): Work around macro
- bugs in HP's compilers.
- * c-exp.y (block): Likewise.
-
-Fri Mar 3 12:27:28 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * rs6000-tdep.c (push_dummy_frame): Fix order of arguments to
- store_address.
-
- * utils.c [_AIX]: Include stddef.h instead of #defining size_t.
-
-Fri Mar 3 12:33:24 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * rs6000-tdep.c (skip_prologue): Skip multiple stores of the saved
- registers that GCC emits on the PowerPC by default in addition to
- the store multiple instruction used on the Power series.
-
-Fri Mar 3 00:54:58 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * sparc-tdep.c (decode_asi): New function.
- (sparc_print_register_hook): Pretty print more v9 registers.
- * sparc/tm-sp64.h (REGISTER_NAMES): Fix some typos.
-
-Thu Mar 2 22:20:22 1995 Doug Evans <dje@canuck.cygnus.com>
-
- * dwarfread.c (struct dieinfo): Use CORE_ADDR for at_{low,high}_pc.
- (target_to_host): Change result type to CORE_ADDR.
-
-Thu Mar 2 15:13:04 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * rs6000-tdep.c: Fix byte-swapping sins.
-
-Thu Mar 2 16:48:45 1995 Michael Meissner <meissner@cygnus.com>
-
- * rs6000-tdep.c (branch_dest): Minor code cleanup, don't share
- code between branch unconditional and branch conditional cases.
-
-Wed Mar 1 09:41:26 1995 Doug Evans <dje@canuck.cygnus.com>
-
- Various changes for sparc64.
- * sparc-tdep.c (NUM_SPARC_FPREGS): Define.
- (SPARC_INTREG_SIZE): Define.
- (*): Use SPARC_INTREG_SIZE instead of REGISTER_RAW_SIZE (intreg)
- where appropriate.
- (enum branch_type): New value `done_retry'.
- (isbranch): Renamed from isannulled. All callers changed.
- Support new sparc64 branch insns.
- (single_step): Handle done_retry.
- (sparc_extract_struct_value_address): Don't assume 4 byte regs.
- (get_saved_register): Likewise.
- (sparc_push_dummy_frame): Likewise.
- (sparc_frame_find_saved_regs): Likewise.
- (sparc_pop_frame): Likewise. Don't refer to FPS_REGNUM, CPS_REGNUM,
- or PS_REGNUM if not sparc64. sparc64 has 64 fp regs.
- (sparc64_extract_struct_value_address): New function.
- (dump_ccreg, sparc_print_register_hook): Likewise.
- * sp64-tdep.c: Deleted.
- * sparc/tm-sp64.h (GDB_TARGET_IS_SPARC64): Define.
- (NUM_REGS): Reduce by 2, cle/tle are in the pstate reg.
- (CC_HAS_LONG_LONG): Define.
- (REGISTER_NAMES): Delete cle/tle and reorganize.
- (PS_REGNUM, FPS_REGNUM, CPS_REGNUM): Delete, they're ifdef'd out of
- sparc-tdep.c now.
- (REGISTER_BYTES): Update.
- (REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW): Delete.
- (EXTRACT_RETURN_VALUE): Delete. Use definition in tm-sparc.h.
- (NO_SINGLE_STEP): Likewise.
- * sparc/tm-sparc.h (EXTRACT_VALUE_RETURN): Don't assume 4 byte regs.
- * sparc/sp64.mt: Move simulator support ...
- * sparc/sp64sim.mt: ... to here.
-
-Wed Mar 1 13:14:42 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * remote-vx960.c: new file for target specific register packaging.
- * remote-vx68.c: ditto.
- * config/i960/vxworks960.mt: add remote-vx960.o.
- * config/m68k/vxworks68.mt: add remote-vx68.o.
-
-Wed Mar 1 13:42:49 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * remote.c (remote_wait): Make calls to strtol be type correct by
- passing the address of a char * pointer instead of an unsigned
- char *.
-
- * rs6000-tdep.c (push_dummy_frame): Cast sp to char * when calling
- write_memory to make things type correct.
-
-Wed Mar 1 12:17:31 1995 Michael Meissner <meissner@cygnus.com>
-
- * ch-exp.y, c-exp.y, f-exp.y, m2-exp.y (yy defines): Support the
- standard Linux yacc by adding more names to be redefined with a
- prefix.
-
-Tue Feb 28 22:55:47 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * hppa-tdep.c (pa_print_registers), monitor.c: Use
- extract_unsigned_integer and friends, not SWAP_TARGET_AND_HOST.
- * defs.h, findvar.c: Move SWAP_TARGET_AND_HOST back to findvar.c.
- Rename it to SWAP_FLOATING to make it clear it is no longer for
- integers.
-
-Tue Feb 28 14:38:39 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * defs.h (SWAP_TARGET_AND_HOST): check endianess at runtime not
- compile time.
- * arc-tdep.c (_initialize_arc_tdep): set tm_print_insn according to
- processor.
-
- * vx-share/ptrace.h: merge in WRS new ptrace requests.
-
- * defs.h: fix a syntax error.
-
- * a29k-tdep.c (get_longjmp_target): add this function, from WRS.
- * remote-vx.c: move read_register and write_register out to
- target specific files.
- * remote-vx29k.c (get_fp_contnets): add this function, from WRS.
-
- * defs.h: define SWAP_TARGET_AND_HOST macro.
- * findvar.c, monitor.c, hppa-tdep.c: remove definition of
- SWAP_TARGET_AND_HOST.
-
-Tue Feb 28 08:31:40 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * alpha-tdep.c (find_proc_desc): Only attempt to set
- PROC_LOCALOFF (found_heuristic) if found_heuristic is non-NULL.
-
-Mon Feb 27 11:56:32 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * monitor.c: General gcc -Wall lint cleanup and reformat.
- (monitor_command): If no args, send an empty command.
-
-Thu Feb 23 21:07:25 1995 Stu Grossman (grossman@cygnus.com)
-
- * monitor.c (monitor_load_ascii_srec): Add a one second sleep
- after send LOAD_CMD to prevent loss of first S-record.
-
-Tue Feb 21 20:48:42 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * valops.c (call_function_by_hand): Set using_gcc to 2 if gcc-2.
- Call error if too few arguments.
- If REG_STRUCT_HAS_ADDR (structs passed by invisible reference),
- copy and convert to reference *before* we calculate alignment.
- Also, make sure structs allocated for return values and invisible
- reference don't violate STACK_ALIGN.
-
-Tue Feb 21 23:29:59 1995 Per Bothner <bothner@rtl.cygnus.com>
-
- * ch-exp.y (expression_conversion): Recognize 'ARRAY () TYPE (EXPR)'
- (same as C's '(TYPE[])EXPR')
-
-Tue Feb 21 11:47:26 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * top.c (print_gdb_version): Update the year.
-
-Sun Feb 19 14:31:57 1995 Jim Kingdon <kingdon@rtl.cygnus.com>
-
- * Makefile.in (CC_FOR_TARGET, CXX_FOR_TARGET): Look for newlib in
- `..' not in `../..'.
-
-Sun Feb 19 11:05:28 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * procfs.c (unconditionally_kill_inferior): Don't issue a PIOCKILL
- in addition to a PIOCSSIG to kill the inferior.
-
-Thu Feb 16 15:06:12 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * parse.c (follow_types): Given (TYPE[]) (i.e. with no length),
- create a 0-length array type, and set BOUND_CANNOT_BE_DETERMINED.
- * valops.c (value_cast): If a cast like (TYPE[])VALUE (i.e. array
- of unknown length) use sizeof(VALUE)/sizeof(TYPE) as the length.
- * c-typeprint.c (c_type_print_varspec_suffix): If array length
- is 0, print it, but not if upper_bound is BOUND_CANNOT_BE_DETERMINED.
-
-Thu Feb 16 16:06:50 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * dcache.c (insque, remque): Rewrite Linux support.
-
-Wed Feb 15 12:33:20 1995 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * config/powerpc/tm-ppc-eabi.h (TEXT_SEGMENT_BASE): Define as 1.
-
- * dcache.c (insque, remque): If compiling in standard C on Linux,
- protect insque and remque with macros to cast the pointer
- arguments to the proper type.
-
-Tue Feb 14 17:16:41 1995 Stu Grossman (grossman@cygnus.com)
-
- * annotate.c, breakpoint.c, defs.h, top.c: Replace
- enable/disable_breakpoint_hook with modify_breakpoint_hook.
-
-Tue Feb 14 16:58:07 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * expression.h: Move declaration of evaluate_subexp_with_coercion
- from here...
- * value.h: ...to here.
- * expression.h: Don't include value.h
-
-Tue Feb 14 11:46:07 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * expression.h: Move include of value.h until after declaration of
- enum exp_opcode.
-
-Sun Feb 12 13:47:30 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * remote-e7000.c: Comprehensive cleanup; removal of dead code,
- simplify code, declare things, format to standards.
- (inferior.h, value.h, command.h, remote-utils.h): Include.
- (e7000_login): Rename to e7000_login_command.
- (e7000_ftp): Rename to e7000_ftp_command.
- (e7000_drain): Rename to e7000_drain_command.
-
- * irix5-nat.c (string.h): Include near beginning of file.
-
-Sun Feb 12 12:36:38 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * valops.c (value_arg_coerce): Use VALUE_TYPE not SYMBOL_TYPE on
- arg, it is a value not a symbol.
-
- gcc -Wall lint:
- * eval.c: Move declaration of evaluate_subexp_with_coercion from here..
- * expression.h: ..to here.
- * expression.h: Include value.h.
- * ch-lang.c (evaluate_subexp_chill): Add default case in switch.
-
-Sun Feb 12 11:03:47 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * language.h (struct language_defn): New field evaluate_exp.
- * c-lang.c (c_language_defn, cplus_language_defn, asm_langauge_defn),
- f-lang.c (f_language_defn), language.c (unknown_language_defn,
- auto_language_defn, local_language_defn), m2-lang.c (m2_language_defn):
- Set evaluate_exp to evaluate_subexp_standard.
- * ch-lang.c (evaluate_subexp_chill): New function. Chill-specific
- support for MULTI_SUBSCRIPT.
- (chill_language_defn): Set evaluate_exp to evaluate_subexp_chill.
- * eval.c (enum noside): Move from here ....
- * expression.h (enum noside): ... to here.
- (evaluate_subexp_standard): New prototype.
- * eval.c (evaluate_subexp): Renamed to evaluate_subexp_standard.
- Removed lo-longer-needed test for chill_varying_type.
- (evaluate_subexp): New. Calls exp->language_defn->evaluate_exp.
-
- * ch-exp.y (maybe_expression_list): New non-terminal.
- (primitive_value): Allow empty parameter list.
-
-Sun Feb 12 10:02:16 1995 Per Bothner <bothner@cygnus.com>
-
- * buildsym.c (finish_block): If finishing a function without known
- parameter type info, set that from parameter symbols.
- * c-typeprint.c (c_type_print_varspec_suffix): For TYPE_CODE_FUNC,
- print parameter types, if available.
- * ch-typeprint.c (chill_type_print_base): Likewise.
-
- * gdbtypes.h (struct type): Remove function type field.
- (TYPE_FUNCTION_TYPE): Remove macro. We can't as simply re-use
- function types now that we're also storing parameter types.
- And the payoff is much less.
- * gdbtypes.c (make_function_type): Don't use/set TYPE_FUNCTION_TYPE.
- (recursive_dump_type): Don't print TYPE_FUNCTION_TYPE.
- * dwarfread.c (read_subroutine_type): Don't set TYPE_FUNCTION_TYPE.
-
- * valops.c (value_arg_coerce): Now takes param_type argument.
- (call_function_by_hand): Convert arguments with value_arg_coerce
- early, and overwrite original args with converted args.
- No longer need multiple calls to value_arg_coerce.
- (value_arg_push): Removed.
- * hppa-tdep.c (hppa_push_arguments): No longer call value_arg_coerce.
- * mips-tdep.c (mips_push_arguments): Likewise.
- * alpha-tdep.c (alpha_push_arguments): Likewise.
- * rs6000-tdep.c (push_arguments, ran_out_of_registers_for_arguments):
- Likewise.
- * value.h (value_arg_coerce): Remove declaration. (It's now static.)
-
- * valops.c (value_cast): Do COERCE_VARYING_ARRAY after COERCE_REF.
-
- * symtab.c (add_param_to_type): Remove (commented-out) function,
- since that functionality has been re-written.
- * coffread.c: Remove commented-out add_param_to_type support.
- * mdebugread.c (parse_symbol): Likewise.
- * stabsread.c (define_symbol): Likewise.
-
-Sun Feb 12 09:03:47 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * buildsym.c (start_subfile): Set language for f2c like for cfront.
-
-Thu Feb 9 20:20:11 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * op50n-rom.c: Add the control registers.
-
-Thu Feb 9 15:46:39 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * Makefile.in (CLIBS): Add $(LIBIBERTY) before, in addition to
- after, any host/target/native libraries.
- * dcache.c (insque, remque): Remove declarations.
- * gdbtypes.h (type_code): Remove trailing comma.
-
- From Peter Schauer:
- * xcoffread.c (read_xcoff_symtab) [C_HIDEXT]: Move #ifdef
- STATIC_NODEBUG_VARS inside case.
-
-Thu Feb 9 07:43:41 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * config/sparc/tm-sun4sol2.h: Define STATIC_TRANSFORM_NAME.
- * partial-stab.h: Call it.
- * stabsread.c (define_symbol) [STATIC_TRANSFORM_NAME]: Call
- STATIC_TRANSFORM_NAME to get the name and use minimal symbols to
- get the address.
- * sparc-tdep.c (solaris_static_transform_name): New function.
-
-Thu Feb 9 12:09:09 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * somread.c (som_symtab_read): Handle dynamic relocation for both
- text and data symbols.
- (som_symfile_offsets): If objfile is a shared library, then get
- text and data offsets from the shared library structures.
- * somsolib.c (som_solib_add): Copy the bfd pointer from the
- objfile rather than reopening the file again.
- (som_solib_section_offsets): New function.
- * somsolib.h (som_solib_section_offsets): Declare.
-
-Wed Feb 8 20:32:18 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * config/sparc/tm-sun4sol2.h, dbxread.c: Rename
- N_SO_ADDRESS_MAYBE_MISSING to SOFUN_ADDRESS_MAYBE_MISSING.
- * symtab.h (minimal_symbol) [SOFUN_ADDRESS_MAYBE_MISSING]: Add
- filename field.
- * elfread.c (record_minimal_symbol_and_info),
- minsyms.c, symtab.h (prim_record_minimal_symbol_and_info): Return
- newly created symbol.
- * elfread.c (elf_symtab_read) [SOFUN_ADDRESS_MAYBE_MISSING]:
- Set filename field of minimal symbol.
- * symmisc.c (dump_msymbols) [SOFUN_ADDRESS_MAYBE_MISSING]:
- Print filename field.
- * minsyms.c, symtab.h (lookup_minimal_symbol): New arg sfile.
- * symm-tdep.c, somsolib.c, hppa-tdep.c, c-exp.y, f-exp.y,
- m2-exp.y, nindy-tdep.c, m3-nat.c, irix5-nat.c, hpread.c,
- os9kread.c, breakpoint.c, alpha-tdep.c, valops.c, symtab.c,
- printcmd.c, dbxread.c: Change callers to pass NULL for sfile.
- * dbxread.c (process_one_symbol) [SOFUN_ADDRESS_MAYBE_MISSING]:
- Find address of function from minimal symbols.
- * partial-stab.h, case 'f', 'F': Call find_stab_function_addr
- instead of getting pst->textlow from the stab.
- * minsyms.c (find_stab_function_addr): New function.
-
-Wed Feb 8 19:19:56 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * monitor.c: Fix so all the output shows up in the GUI command
- window.
-
-Mon Feb 6 18:50:59 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * i386-tdep.c (_initialize_i386_tdep): Put void decl on separate
- line, so init.c generation works correctly.
- * arc-tdep.c (_initialize_arc_tdep): Ditto.
-
-Mon Feb 6 14:44:36 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * config/mips/idt.mt: Add support for the lsi33k target.
- * config/sparc/sun4sol2.mh: Add support for ser-tcp.
- * array-rom.c: Finish the rest of the support commands needed by
- GDB.
- * mips-tdep.c: Add LSI33k register names and processor type.
-
-Sat Feb 4 13:29:52 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * config/m68k/est.mt (TDEPFILES): Remove m68k-pinsn.o.
-
-Fri Feb 3 11:19:20 1995 Stu Grossman (grossman@cygnus.com)
-
- * core.c (dis_asm_read_memory), defs.h, top.c: Get rid of
- dis_asm_read_memory_hook. We can now call the disassemblers
- directly and have no need for this hook anymore.
- * defs.h, printcmd.c: Make print_insn be static.
-
- * ser-go32.c (dos_comisr): Make this 8 bit clean.
- * (dos_open dos_close): Allow multiple opens to the same device.
- Use a ref count to prevent unwanted deallocations.
- * sparcl-tdep.c: Put #ifdefs around all socket stuff to make GO32
- happy.
- * (sparclite_ops): Switch to download_stratum.
- * target.h (enum strata): Move download_stratum before
- process_stratum so that executable targets get pushed on top of
- download targets.
-
-Thu Feb 2 19:02:45 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * array-rom.c: Remove the non GDB remote protocol config stuff.
-
- * monitor.c: All reading/writing functions for memory and
- registers work.
-
-Thu Feb 2 16:11:04 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * config/arc/arc.mt: new target makefile for arc processor.
- * config/arc/tm-arc.h: new target header for arc processor.
- * config/arc/go32.mh: new go32 host makefile for arc processor.
- * config/arc/xm-go32.h: new go32 host header for arc processor.
- * arc-tdep.c: new target dependent codes for arc processor.
-
-Thu Feb 2 13:58:40 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * Makefile.in (VERSION): Bump to 4.13.2.
-
-Thu Feb 2 07:27:56 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- Fix compiler warnings:
- * remote-e7000.c (printf_e7000debug): Rename to puts_e7000debug
- and have the caller do the sprintf. Saves us from varargs hell.
- (normal): Define before use.
- * remote-e7000.c: Reindent a few things.
-
-Wed Feb 1 21:16:42 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * f-typeprint.c (f_type_print_varspec_suffix): Print array index
- ranges in reverse order.
- * f-valprint.c (f77_create_arrayprint_offset_tbl): Fix calculation.
-
- * eval.c (evaluate_subscript): Don't call value_subscript, since
- it adjusts for lower bound and enforces ranges.
-
- * expression.h (exp_code): Remove MULTI_F77_SUBSCRIPT, OP_F77_SUBSTR.
- * eval.c, parse.c: Removed uses of removed opcodes.
- * eval.c (evaluate_subexp): Clean up handling of
- OP_UNDETERMINED_ARGLIST (no backtracking, more general).
-
- * f-valprint.c (f_val_print): Print TYPE_CODE_STRING using
- LA_PRINT_STRING, and not val_print_string (which reads from inferior).
-
- * ch-lang.c (chill_is_varying_struct), ch-lang.h: Remve function
- duplicate function made redundant by chill_varying_type.
-
- Re-write of f77 string and complex number support:
-
- * language.h (struct language_defn): New fields string_lower_bound
- and string_char_type.
- * c-lang.c (c_language_defn, cplus_language_defn, asm_language_defn),
- language.c (unknown_language_defn, auto_language_defn,
- local_language_defn), m2-lang.c (m2_language_defn), f-lang.c
- (f_language_defn), ch-lang.c (chill_language_defn): Set new fields.
- * gdbtypes.c (create_string_type): Use new string_char_type field.
- * valops.c (value_string): Use new string_lower_bound field.
-
- * defs.h (TARGET_COMPLEX_BIT, TARGET_DOUBLE_COMPLEX_BIT): Removed.
- * f-lang.c (f_create_fundamental_type, _initialize_f_language),
- m2-lang.c (m2_create_fundamental_type),
- gdbtypes.c (_initialize_gdbtypes): Set TYPE_TARGET_TYPE of complex
- types. Set their TYPE_CODEs to TYPE_CODE_COMPLEX.
- * mdebugread.c (mdebug_type_complex, mdebug_type_double_complex):
- Removed. Use builtin_type_complex and builtin_type_double_complex.
-
- * gdbtypes.h (enum type_code): Removed TYPE_CODE_LITERAL_STRING
- and TYPE_CODE_LITERAL_COMPLEX.
- * c-typeprint.c, f-typeprint.c, f-valprint.c, eval.c: Removed uses of
- TYPE_CODE_LITERAL_STRING and TYPE_CODE_LITERAL_COMPLEX.
- * gdbtypes.c, gdbtypes.h (f77_create_literal_complex_type,
- f77_create_literal_string_type): Removed.
- * value.h (VALUE_LITERAL_DATA, VALUE_SUBSTRING_MEMADDR,
- VALUE_SUBSTRING_MYADDR): Removed.
-
- * expression.h (enum exp_opcode): Rename OP_F77_LITERAL_COMPLEX to
- OP_COMPLEX.
- * parse.c: Update accordingly.
-
- * f-valprint.c (f77_print_cmplx): Removed.
- (f_val_print case TYPE_CODE_COMPLEX): Re-write to use print_floating.
-
- * f-exp.y (STRING_LITERAL): Use OP_STRING instead of OP_ARRAY.
- * eval.c (evaluate_subexp): For case OP_ARRAY, don't call
- f77_value_literal_string.
- * valops.c, value.h (f77_value_literal_string, f77_value_substring,
- f77_assign_from_literal_string, f77_assign_from_literal_complex):
- Removed.
- (value_assign): No longer need to handle literal types.
- * valops.c (f77_value_literal_complex), value.h: Re-written and
- renamed to value_literal_complex. Last arg is now a (complex) type.
- * valops.c (f77_cast_into_complex): Re-written and renamed to
- cast_into_complex.
- * eval.c (evaluate_subexp): Update accordingly.
-
- * ch-valprint.c (chill_val_print): On TYPE_CODE_STRING, don't
- print address for non-'s'-formats.
- * ch-typeprint.c, ch-valprint.c: Use chill_varying_type instead
- of chill_is_varying_struct.
-
-Wed Feb 1 13:27:33 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- gcc -Wall lint.
- * alpha-tdep.c (alpha_in_lenient_prologue): Comment out.
- (after_prologue): Remove unused local b.
- * procfs.c (thread.h): Include.
- (pr_flag_table, pr_why_table, faults_table, siginfo_table): Use
- nested braces in initializer.
- * top.c (initialize_targets, initialize_utils): Declare.
- (locate_arg, insert_args): Add parens around tested assignments.
- * remote-utils.c (sr_scan_args): Remove decl of strtol.
- * remote.c (thread.h): Include.
- (remote_wait): Remove unused local p2.
- * sparc-tdep.c (fill_gregset, fill_fpregset): Remove decls of
- registers array.
-
- defs.h (stdlib.h): Include.
- (exit, perror, atoi, qsort, memcpy, memcmp): Don't declare.
- (fclose, atof, malloc, realloc, free, strchr, strrchr, strstr,
- strtok, strerror): Don't specify parameter types in declaration.
-
-Wed Feb 1 12:23:57 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * ch-exp.y (value_string_element, string_primitive_value,
- start_element, left_element, right_element, slice_size,
- lower_element, upper_element, first_element): Removed.
- (value_string_slice, value_array_slice): Replaced by ...
- (slice): New non-terminal, with working slice support.
- (primitive_value_lparen, rparen): New non-terminals.
- (maybe_tuple_elements): New non-terminal, to allow empty tuples.
- (idtokentab): Added "up".
-
- * value.h (COERCE_VARYING_ARRAY): New macro.
- * valarith.c (value_subscript): Use it.
- * valops.c (value_cast): Likewise. Also, do nothing if already
- correct type, and allow converting from/to range to/from scalar.
-
- * valops.c, value.h (varying_to_slice, value_slice): New functions.
- * eval.c (OP_ARRAY): Add cast for array element.
- * expression.h (TERNOP_SLICE, TERNOP_SLICE_COUNT): New exp_opcodes.
- * valops.c (chill_varying_type): Moved function frp, here ...
- * gdbtypes.c (chill_varying_type), gdbtypes.h: ... to here.
- * parse.c (length_of_subexp, prefixify_subexp): Add support
- for TERNOP_SLICE, TERNOP_SLICE_COUNT.
- * expprint.c (print_subexp, dump_expression): Likewise.
- * eval.c (evaluate_subexp): Likewise.
-
- * eval.c (evaluate_subexp case MULTI_SUBSCRIPT): Don't call
- value_x_binop on a Chill varying string.
-
-Tue Jan 31 13:51:53 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * config/m68k/monitor.mt,
- config/pa/{hppabsd.mt,hppahpux.mt,hppaosf.mt,hppapro.mt}: Put
- depfiles in TDEPFILES not REMOTE_O.
-
-Tue Jan 31 11:14:44 1995 Steve Chamberlain <sac@splat>
-
- From nigel@algor.co.uk.
- * ser-go32.c (dos_close): Don't crash if scb null.
- (dos_sendbreak): New function.
- (dos_ops): Point to dos_sendbreak.
- (dos_info): Calculate COM number correctly.
-
-Tue Jan 31 09:40:11 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * xcoffread.c (process_xcoff_symbol): Use new variables
- func_symbol_type and var_symbol_type as type of functions and
- variables which don't have any stabs associated with them.
- Reindent most of function.
- (_initialize_xcoffread): Initialize *_symbol_type.
-
- * xcoffread.c (read_xcoff_symtab): Reindent most of function.
- Put C_HIDEXT symbols in the minimal symbols, rather than ignoring
- them (this part commented out as I didn't quite get it to work).
- (cs_to_section, find_targ_sec): New functions, to support above code.
- * xcoffread.c (RECORD_MINIMAL_SYMBOL): Only skip '.' if it is
- actually present.
-
-Mon Jan 30 17:34:24 1995 Stu Grossman (grossman@cygnus.com)
- * sparcl-tdep.c: Add `sparclite' target for doing serial and udp
- downloads to SPARClite demo boards.
-
-Sun Jan 29 09:43:22 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * remote.c, remote-pa.c: Remove #if 0'd icache code. It has had
- no hope of working as is for a long time (in particular, shebs' 27
- Jan 95 change confuses the issue further--target_read_memory and
- xfer_core_file do *not* do the same thing in this context).
- Revise comment.
-
-Sat Jan 28 13:40:46 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * elfread.c (elf_symtab_read): Do not test BSF_GLOBAL for
- procedure linkage table symbols, it is no longer set due to the
- Jan 6 BFD change in bfd/elfcode.h.
-
-Fri Jan 27 17:08:06 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * top.c (use_windows): Clarify comments.
-
- * convex-tdep.c (xfer_core_file): Comment out.
- * config/convex/tm-convex.h (XFER_CORE_FILE): Remove.
- * remote.c, remote-pa.c (remote_fetch_word): Change xfer_core_file
- references to target_read_memory.
- * gdbcore.h (xfer_core_file, core_open, core_detach): Remove
- declarations.
- * corelow.c (core_open, core_detach): Make static.
-
- * arm-tdep.c: Make it compile.
- (exec_file_command, xfer_core_file): Comment out.
- (arm_print_insn): Remove, now in libopcodes.
- (skip_prologue): Comment out most of body.
- (arm_frame_find_saved_regs): Move here from tm-arm.h.
- (_initialize_arm_tdep): Set tm_print_insn.
- * config/arm/tm-arm.h: Remove old refs to first_object_file_end.
- (XFER_CORE_FILE): Remove.
- (FRAME_FIND_SAVED_REGS): Call arm_frame_find_saved_regs.
-
-Fri Jan 27 08:48:28 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (CHILL_LIB): Define as in testsuite/Makefile.in.
-
-Thu Jan 26 18:24:41 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * symtab.c (find_pc_line): When subtracting one to get a line
- number, make sure not to end up with zero.
-
- * remote-vx.c: Revert all of Kung's changes of 16 Jan. The
- problems with those changes were (a) the file didn't compile, (b)
- they changed memset to bzero--memset is correct, (c) they took out
- code to deal with boards lacking floating point, (d) who knows
- what I didn't discover in a quick read.
-
-Thu Jan 26 17:32:54 1995 Stu Grossman (grossman@cygnus.com)
-
- * sparcl-tdep.c: Clean up formatting and indentation.
-
-Thu Jan 26 10:49:59 1995 Steve Chamberlain <sac@splat>
-
- * remote-hms.c (hms_ops): Change ref of hr_load_image
- to gr_load_image.
- (dcache_flush, dcache_hit, dcache_value, dcache_fetch,
- dcache_poke, dcache_init): Deleted.
- (hms_open, hms_resume, hms_fetch_word, hms_store_word):
- Use dcache routines provided by remote-util.h
-
-Thu Jan 26 12:08:31 1995 Michael Meissner <meissner@cygnus.com>
-
- * configure.in: Add support for powerpc-*-eabi.
-
- * powerpc/tm-ppc-eabi.h, powerpc/pcc-eabi.mt: New files for
- PowerPC support.
-
-Wed Jan 25 18:13:14 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * language.h (struct language_defn): New field c_style_arrays.
- * language.c (unknown_language_defn, auto_language_defn,
- local_language_defn), c-lang.c (c_language_defn, cplus_language_defn,
- asm_language_defn): Set c_style_arrays to true.
- * m2-lang.c (m2_language_defn), ch-lang.c (chill_language_defn),
- f-lang.c (f_language_defn): Set c_style_arrays to false.
- * valops.c (value_string): If c_style_array is not set,
- allocate string in gdb (not inferior) using allocate_value.
-
- * value.h (COERCE_ARRAY), valops.c (value_addr, value_arg_coerce):
- Only call value_coerce_array if current_language->c_style_arrays.
- * values.c: Add #include "language.h". (Needed for COERCE_ARRAY.)
-
- * valops.c (chill_varying_type): New predicate.
- * valops.c (value_cast): Support assigning a fixed string or array
- to a variable string/array structure.
-
- * valarith.c (value_subscripted_rvalue): Extra parameter lowerbound.
- Check index>=lowerbound, and then add lowerbound to index here,
- instead of in caller. Generalize to arbitrary lval_types.
- (value_subscript): Use enhanced value_subscripted_rvalue if
- c_style_arrays is false (and index is in range).
-
-
-Wed Jan 25 18:13:14 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * eval.c (evaluate_subexp case OP_ARRAY): Fix calls to memset:
- TYPE_LENGTH is length in bytes, not bits.
-
-Wed Jan 25 08:19:35 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * infrun.c (proceed): Flush stdout before resuming inferior.
- * infcmd.c (step_1), annotate.c (annotate_starting):
- Don't bother to flush here.
-
-Wed Jan 25 01:11:21 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * hpread.c (hpread_process_one_debug_symbol): Fix lines garbled
- by an ill-advised global search and replace.
-
-Mon Jan 23 13:11:46 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- Add support for Chill bitstring literals (e.h. H'FF00').
- * ch-exp.y (match_bitstring_literal): Fix for proper endianness.
- * expprint.c (print_subexp): Don't call error on OP_BITSTRING,
- just print B'<unimlemented>'.
- * gdbtypes.c (create_set_type): Fix bug in length calculation.
- * valops.c, value.h (value_bitstring): New function.
- * eval.c (evaluate_subexp): Implement support for OP_BITSTRING.
-
- * ch-typeprint.c (chill_type_print_base): For TYPE_CODE_FUNC,
- check that return type is non-void, and print in proper Chill syntax.
-
-Mon Jan 23 12:20:34 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * Makefile.in: Remove references to remote-mon.c.
- * remote-mon.c: remove. Replaced by rom68k-rom.c.
- * rom68k-rom.c: Support for Rom68k monitor.
-
-Mon Jan 23 10:50:57 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * Makefile.in (CHILL_FOR_TARGET): Update -L argument to point to
- gcc/ch/runtime not chillrt, since that is where the chill runtime
- lives now.
-
-Mon Jan 23 00:06:57 1995 Steve Chamberlain <sac@splat>
-
- * remote-hms.c (hms_load): Delete.
- (target_ops): Use hr_load_image.
-
- * remote-e7000.c, remote-z8k.c, remote-nindy.c (target_ops):
- Define memory_insert/remove_breakpoint.
- * xm-go32.h: Remove redundant SIGs.
-
-Thu Jan 19 20:26:58 1995 Steve Chamberlain <sac@splat>
-
- * ser-go32.c: Rewritten by nigel@algor.co.uk.
-
-Fri Jan 20 15:23:55 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * expression.h (OP_LABELED): New operator, for Chill
- labeled structre tuples.
- * ch-exp.y (tuple_element, named_record_element, tuple_elements):
- New non-terminals, to handle labeled structure tuples.
- (tuple): Re-define using tuple_elements.
- * eval.c (evaluate_labeled_field_init): New function, to handle
- initialization of structure fields, possibly using OP_LABELED.
- (evaluate_subexp): Use it.
- * expprint.c (print_subexp case): For OP_ARRAY, use Chill syntax
- for Chill. Handled OP_LABELED.
- * parse.c (length_of_subexp, prefixify_subexp): Handle OP_LABELED.
-
- * eval.c (evaluate_subexp): Handle Chill Powerset tuples.
- * valarith.c (value_bit_index): Just treat bitstring as represented
- by an array of bytes. Alignment is handled by compiler.
-
-Wed Jan 18 19:00:29 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * h8300-tdep.c (gdb_print_insn_h8300): Fix typo (&info -> info).
- * sh-tdep.c (gdb_print_insn_sh): Ditto.
-
-Wed Jan 18 11:25:43 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * remote-os9k.c (rombug_open): Fix a bug in exception handling
- command.
- * remote-os9k.c (rombug_write_inferior_memory): reset buffer after
- write.
-
-Tue Jan 17 09:48:38 1995 Jim Kingdon <kingdon@lioth.cygnus.com>
-
- * parse.c (_initialize_parse): Improve wording of names of
- msym_*_symbol_type.
-
-Tue Jan 17 14:00:58 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * config/mips/tm-mips.h (enum mips_fpu_type): New enum.
- (mips_fpu): Change type to enum mips_fpu_type.
- (FIX_CALL_DUMMY): Handle mips_fpu == MIPS_FPU_SINGLE.
- * mips-tdep.c (mips_fpu): Change type to enum mips_fpu_type.
- Don't initialize.
- (mips_fpu_string): New static variable.
- (mips_push_dummy_frame): Handle mips_fpu == MIPS_FPU_SINGLE.
- (mips_pop_frame): Likewise.
- (mips_extract_return_value): Likewise.
- (mips_store_return_value): Likewise.
- (mips_set_fpu_command): New static function.
- (mips_show_fpu_command): New static function.
- (_initialize_mips_tdep): Change handling of set/show mipsfpu.
-
-Tue Jan 17 09:48:38 1995 Jim Kingdon <kingdon@lioth.cygnus.com>
-
- * a29k-tdep.c (gdb_print_insn_a29k): Fix typo (&info -> info).
-
- * parse.c (write_exp_msymbol): Use new variables
- msym_*_symbol_type as type of msymbol expression.
- (_initialize_parse): Initialize them.
-
-Mon Jan 16 18:11:03 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- General cleanup and simplication of disassembler interface.
- * a29k-pinsn.c, arm-pinsn.c, convex-pinsn.c, gould-pinsn.c,
- hppa-pinsn.c, i386-pinsn.c, i960-pinsn.c, m68k-pinsn.c,
- m88k-pinsn.c, mips-pinsn.c, ns32k-pinsn.c, pyr-pinsn.c,
- rs6000-pinsn.c, sparc-pinsn.c, tahoe-pinsn.c, vax-pinsn.c: Remove.
- * gould-tdep.c, ns32k-tdep.c, tahoe-tdep.c, vax-tdep.c: New files,
- had been -pinsn.c files.
- * Makefile.in (ALLDEPFILES): Remove removed files.
- (a29k-pinsn.o, arm-pinsn.o, convex-pinsn.o, gould-pinsn.o,
- hppa-pinsn.o, i386-pinsn.o, i960-pinsn.o, m68k-pinsn.o,
- m88k-pinsn.o, mips-pinsn.o, ns32k-pinsn.o, pyr-pinsn.o,
- rs6000-pinsn.o, sparc-pinsn.o, tahoe-pinsn.o, vax-pinsn.o):
- Remove compile actions.
- * arm-tdep.o, gould-tdep.o, ns32k-tdep.o, tahoe-tdep.o,
- vax-tdep.o: Add compile actions.
- * defs.h (tm_print_insn): New global.
- * a29k-tdep.c (gdb_print_insn_a29k): New function.
- (_initialize_a29k_tdep): Rename from _initialize_29k,
- set tm_print_insn.
- * alpha-tdep.c (print_insn): Remove.
- (_initialize_alpha_tdep): Set tm_print_insn.
- * arm-tdep.c (arm_print_insn): New function, was print_insn
- in arm-pinsn.c.
- * convex-tdep.c (convex_print_insn): New function, was print_insn
- in convex-pinsn.c.
- * h8300-tdep.c (print_insn): Remove.
- (gdb_print_insn_h8300): New function.
- (_initialize_h8300_tdep): New function.
- * h8500-tdep.c (print_insn): Remove.
- (_initialize_h8500_tdep): New function.
- * hppa-tdep.c (_initialize_hppa_tdep): Set tm_print_insn.
- * i386-tdep.c (_initialize_i386_tdep): New function.
- * i960-tdep.c (mem, next_insn): New functions, were in
- i960-pinsn.c.
- (_initialize_i960_tdep): Set tm_print_insn.
- * m68k-tdep.c (_initialize_m68k_tdep): New function.
- * m88k-tdep.c (_initialize_m88k_tdep): New function.
- * mips-tdep.c (gdb_print_insn_mips): New function.
- (_initialize_mips_tdep): Set tm_print_insn.
- * pyr-tdep.c (pyr_print_insn): New function, was print_insn
- in pyr-pinsn.c.
- * rs6000-tdep.c (_initialize_rs6000_tdep): New function.
- * sh-tdep.c (print_insn): Remove.
- (gdb_print_insn_sh): New function.
- (_initialize_sh_tdep): Set tm_print_insn.
- * sparc-tdep.c (_initialize_sparc_tdep): New function.
- * w65-tdep.c (print_insn): Remove.
- (_initialize_w65_tdep): New function.
- * z8k-tdep.c (print_insn): Remove.
- (gdb_print_insn_z8k): New function.
- (_initialize_z8k_tdep): Set tm_print_insn.
- * printcmd.c (print_insn): New function, generic disassembler.
- * config/*/*.mt (TDEPFILES): Remove refs to *-pinsn.o.
-
-Mon Jan 16 15:43:29 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * Makefile.in: add new files remote-vx29k.c, config/a29k/tm-vx29k.h,
- and config/a29k/vx29k.mt.
- * configure.in: add new configuration a29k-*-vxworks.
- * remote-vx29k.c: new file merged from WRS.
- * remote-vx.c: merge changes from WRS.
- * config/a29k/vx29k.mt: new file for new configuration.
- * config/a29k/tm-vx29k.h: new header file for newconfiguration.
-
-Sun Jan 15 14:36:19 1995 Steve Chamberlain <sac@splat>
-
- * breakpoint.h (disable_breakpoint, enable_breakpoint):
- New declarations.
- (enum bpdisp): Change name of 'delete' member to 'del'.
- (struct bpstat): Changed name to 'bpstats'.
- * breakpoint.c (disable_breakpoint, enable_breakpoint,
- breakpoint_chain): Made globally visible.
- (bpstat_stop_status): Use new name for bpstat.
- (break_command_1, watch_command_1, catch_command_1,
- breakpoint_auto_delete, denable_delete_breakpoint): Use 'del'
- instead of 'delete'.
- (set_breakpoint_sal): New function.
- * defs.h (registers_changed_hook): New declaration.
- * infcmd.c (run_stack_dummy): 'delete' is now 'del'.
- * inflow.c (new_tty): Treat WIN32 in same way as __GO32__
- * main.c (main): Don't scan options when in WIN32 and exit
- without entering main loop.
- * m2-exp.y (m2_elx): Member 'class' is now 'aclass'.
- * symtab.h (struct symbol, struct partial_symbol): Changed name of
- member 'class' to 'aclass'.
- (SYMBOL_CLASS, PSYMBOL_CLASS): Reflect change.
- * top.c (registers_changed_hook): New definition.
- * utils.c (quit, notice_quit, initialize_utils): Treate WIN32
- in same way as __GO32__.
- * value.h (c_typedef_print): Rename 'new' argument.
-
- * w65-tdep.c, config/tm-w65.h, config/w65.mt: New files.
- * configure.in: Suppprt for w65,
-
-
-Sat Jan 14 11:18:11 1995 Jim Kingdon <kingdon@lioth.cygnus.com>
-
- * infcmd.c (signal_command): For "signal 0", pass (CORE_ADDR)-1,
- not stop_pc, to proceed.
-
- * eval.c (evaluate_subexp): Clear expect_type except for C++ and CHILL.
-
-Fri Jan 13 17:52:57 1995 Jim Kingdon <kingdon@lioth.cygnus.com>
-
- * infcmd.c (signal_command): Accept "signal 0"; the change to not
- accept it was accidental. "handle 0" and "info signal 0" remain
- illegal, though.
-
-Fri Jan 13 15:19:01 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * Makefile.in (all): Don't make libgdb-files.
- (libgdb): New action, makes libgdb-files.
-
-Thu Jan 12 21:23:25 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * stabsread.c (read_enum_type): When pending enum symbols are
- put into the enum type, they must be inserted in "backwards
- order, in case we've overflowed a struct pending buffer.
-
-
-Thu Jan 12 09:33:24 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * README: Add note about SPARCworks cc release 3.0 and higher.
-
- Add procfs support for Alpha OSF/1-2.x.
- * config/alpha/nm-osf.h: Renamed from nm-alpha.h, generic
- OSF/1 native support.
- * config/alpha/alpha-osf1.mh (NAT_FILE): Changed accordingly.
- (MUNCH_DEFINE): Removed.
- * config/alpha/alpha-osf2.mh, config/alpha/nm-osf2.h: New files
- for procfs support.
- * configure.in (alpha-dec-osf*): Use alpha-osf2.mh for OSF/1
- release 2.x and higher, else alpha-osf1.mh, as the procfs support
- in release 1.x is incomplete.
- * Makefile.in (ALLCONFIG): Add config/alpha/alpha-osf2.mh.
- * alpha-nat.c (supply_gregset, fill_gregset, supply_fpgregset,
- fill_fpgregset): New routines for procfs support.
- * inftarg.c (_initialize_inftarg): Don't add ptrace support
- if we have an optional procfs and /proc is accessible.
- * procfs.c: Include sys/fault.h and sys/syscall.h before
- including sys/procfs.h.
- (unconditionally_kill_inferior): If PROCFS_NEED_PIOCSSIG_FOR_KILL
- is defined, additionally perform a PIOCSSIG to really terminate
- the inferior.
- (create_procinfo): Always return a result.
- (create_procinfo, do_attach): Don't trace T_IFAULT faults if
- PROCFS_DONT_TRACE_IFAULT is defined.
- (procfs_init_inferior): Use START_INFERIOR_TRAPS_EXPECTED as
- argument to startup_inferior if it is defined.
- (proc_set_exec_trap): If PIOCSSPCACT is defined, use it instead
- of tracing exits from exec system calls. Needed for the user level
- loader under Alpha OSF/1.
- (do_detach): Clear any pending signal if we want to detach from
- a process without a signal.
- (set_proc_siginfo): If PROCFS_DONT_PIOCSSIG_CURSIG is defined,
- don't issue a PIOCSSIG if pr_cursig already contains the signal we
- intend to set.
- (info_proc_signals): If PROCFS_SIGPEND_OFFSET is defined, the
- pending signals are numbered from 1 instead of 0.
- (info_proc_mappings): Increase size of output format for addresses
- if BFD_HOST_64_BIT is defined.
- (procfs_stop): Renamed from child_stop.
- (_initialize_procfs): Don't add procfs support if we have an
- optional procfs and /proc is not accessible.
-
-
-Wed Jan 11 17:53:26 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * array-rom.c: Add support for most commands.
-
- * monitor.c: Add GDB remote protocol for the hybrid environment on
- the Array board.
-
-Wed Jan 11 00:44:01 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * command.c (show_user_1): Use print_command_line to show a user
- defined command (including control structures).
-
- * top.c (init_main): Change documentation for user defined
- commands to indicate they may accept up to ten arguments.
-
-Tue Jan 10 16:22:41 1995 Jim Kingdon <kingdon@lioth.cygnus.com>
-
- * mips-tdep.c (mips_skip_prologue): Accept or as well as addu for
- `move $s8, $sp' instruction.
-
-Sun Jan 8 12:45:34 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
-
- * target.c, target.h (target_signal_from_command): New function.
- * infrun.c (handle_command, signals_info), infcmd.c
- (signal_command): Use it.
- * infrun.c, infcmd.c: Update docstrings for these commands.
-
- * target.h (enum target_signal), target.c (signals), target.c
- (target_signal_from_host, target_signal_to_host): Add
- TARGET_SIGNAL_REALTIME_* and TARGET_SIGNAL_PRIO for lynx.
- * config/tm-lynx.h: Define signal numbers for realtime events.
-
-Sat Jan 7 07:23:53 1995 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
-
- * dbxread.c (process_one_symbol): Handle N_FUN symbols
- for Sun acc 3.0 under SunOS4.
-
- Changes to improve handling of runtime common symbols
- under SunOS4.
- * minsyms.c (get_symbol_leading_char): New routine to determine
- the leading symbol character for an objfile.
- (prim_record_minimal_symbol_and_info, install_minimal_symbols):
- Use it.
- * objfiles.h (rt_common_objfile): New global, points to objfile
- containing the runtime common minimal symbols.
- * objfiles.c (free_objfile): Mark rt_common_objfile as
- unallocated before freeing it.
- * solib.c (allocate_rt_common_objfile): New routine to allocate
- an objfile for the runtime common minimal symbols.
- (solib_add_common_symbols): Allocate an objfile for the runtime
- common symbols if necessary and put common symbols into it.
- Clean up code and comments.
- (solib_add, special_symbol_handling): Cleanup comments regarding
- runtime common symbols.
- * stabsread.c (scan_file_globals_1): New routine, contains
- old scan_file_globals code. Checks if there are any unresolved
- global symbols before starting the expensive minimal symbol table
- search.
- (scan_file_globals): Now calls scan_file_globals_1 for the passed
- objfile and eventually for the runtime common objfile. Complains
- about any unresolved global symbols and removes them from the
- global symbol chain to avoid dangling pointers into the symbol
- table if the symbol table is reread.
-
-Thu Jan 5 17:38:29 1995 Stu Grossman (grossman@cygnus.com)
-
- * Makefile.in (install_only uninstall): Indent for clarity.
-
- * core.c (dis_asm_read_memory): Add call to
- dis_asm_read_memory_hook to provide alternate way for disassembler
- to read memory.
-
- * defs.h: Protect from multiple inclusion. Add decl for
- dis_asm_read_memory_hook.
-
- * top.c: Make window startup be the default.
- * Add dis_asm_read_memory_hook.
-
-
-Thu Jan 5 01:16:40 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * stabsread.c (define_symbol): Handle `a' symbol type used for
- reference parameter passed in a register.
-
-
-Wed Jan 4 12:27:29 1995 Kung Hsu <kung@mexican.cygnus.com>
-
- * defs.h: move include tm.h up, so that the type LONGEST can
- also based on the target requirement to determine. In this case
- target mips64.
-
- * remote-os9k.c (rombug_open): catch exception e in rombug.
- * remote-os9k.c (rombug_wait): print message before register display
- from rombug.
-
-Wed Jan 4 09:18:27 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
-
- * top.c (locate_arg): Call strchr not index.
-
-Tue Jan 3 16:52:03 1995 Per Bothner <bothner@kalessin.cygnus.com>
-
- * ch-exp.y (literal): Recognize NULL.
- (tuple): Parse simple unlabelled tuples.
- * eval.c (evaluate_subexp case OP_ARRAY): Use expect_type to
- evaluate brace-initializer-expressions depending on context.
- (evaluate_subexp case UNOP_CAST): Pass the target type as
- expected type when evaluating the expression.
-
- * ch-typeprint.c (chill_type_print_base): Get names of PTR and
- BOOL from TYPE_NAME.
- * ch-valprint.c (chill_print_type_scalar): New function, to handle
- TYPE_CODE_RANGE better than print_type_scalar does.
- (chill_val_print_array_elements): Use above new function.
-
-Mon Jan 2 15:02:51 1995 Stan Shebs <shebs@andros.cygnus.com>
-
- * remote-udi.c (udi_load): Tell symbol_file_add that the
- program being loaded is the main program.
-
-For older changes see ChangeLog-94
-
-Local Variables:
-mode: indented-text
-left-margin: 8
-fill-column: 74
-version-control: never
-End:
diff --git a/contrib/gdb/gdb/acconfig.h b/contrib/gdb/gdb/acconfig.h
deleted file mode 100644
index 9ad5020..0000000
--- a/contrib/gdb/gdb/acconfig.h
+++ /dev/null
@@ -1,95 +0,0 @@
-
-/* Whether malloc must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_MALLOC
-
-/* Whether realloc must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_REALLOC
-
-/* Whether free must be declared even if <stdlib.h> is included. */
-#undef NEED_DECLARATION_FREE
-
-/* Whether strerror must be declared even if <string.h> is included. */
-#undef NEED_DECLARATION_STRERROR
-@TOP@
-
-/* Define if pstatus_t type is available */
-#undef HAVE_PSTATUS_T
-
-/* Define if prrun_t type is available */
-#undef HAVE_PRRUN_T
-
-/* Define if fpregset_t type is available. */
-#undef HAVE_FPREGSET_T
-
-/* Define if gregset_t type is available. */
-#undef HAVE_GREGSET_T
-
-/* Define if ioctl argument PIOCSET is available. */
-#undef HAVE_PROCFS_PIOCSET
-
-/* /proc PID entries are directories containing the files
- ctl as map status */
-#undef HAVE_MULTIPLE_PROC_FDS
-
-/* Define if the `long long' type works. */
-#undef CC_HAS_LONG_LONG
-
-/* Define if the "ll" format works to print long long ints. */
-#undef PRINTF_HAS_LONG_LONG
-
-/* Define if the "%Lg" format works to print long doubles. */
-#undef PRINTF_HAS_LONG_DOUBLE
-
-/* Define if the "%Lg" format works to scan long doubles. */
-#undef SCANF_HAS_LONG_DOUBLE
-
-/* Define if using Solaris thread debugging. */
-#undef HAVE_THREAD_DB_LIB
-
-/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */
-#undef START_INFERIOR_TRAPS_EXPECTED
-#undef sys_quotactl
-
-/* Define if you have HPUX threads */
-#undef HAVE_HPUX_THREAD_SUPPORT
-
-/* Define if you want to use the memory mapped malloc package (mmalloc). */
-#undef USE_MMALLOC
-
-/* Define if the runtime uses a routine from mmalloc before gdb has a chance
- to initialize mmalloc, and we want to force checking to be used anyway.
- This may cause spurious memory corruption messages if the runtime tries
- to explicitly deallocate that memory when gdb calls exit. */
-#undef MMCHECK_FORCE
-
-/* Define to 1 if NLS is requested. */
-#undef ENABLE_NLS
-
-/* Define as 1 if you have catgets and don't want to use GNU gettext. */
-#undef HAVE_CATGETS
-
-/* Define as 1 if you have gettext and don't want to use GNU gettext. */
-#undef HAVE_GETTEXT
-
-/* Define as 1 if you have the stpcpy function. */
-#undef HAVE_STPCPY
-
-/* Define if your locale.h file contains LC_MESSAGES. */
-#undef HAVE_LC_MESSAGES
-
-/* Define if you want to use the full-screen terminal user interface. */
-#undef TUI
-
-/* Define if <proc_service.h> on solaris uses int instead of
- size_t, and assorted other type changes. */
-#undef PROC_SERVICE_IS_OLD
-
-/* If you want to specify a default CPU variant, define this to be its
- name, as a C string. */
-#undef TARGET_CPU_DEFAULT
-
-/* Set to true if the save_state_t structure is present */
-#define HAVE_STRUCT_SAVE_STATE_T 0
-
-/* Set to true if the save_state_t structure has the ss_wide member */
-#define HAVE_STRUCT_MEMBER_SS_WIDE 0
diff --git a/contrib/gdb/gdb/alpha-nat.c b/contrib/gdb/gdb/alpha-nat.c
deleted file mode 100644
index 59bd0d8..0000000
--- a/contrib/gdb/gdb/alpha-nat.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/* Low level Alpha interface, for GDB when running native.
- Copyright 1993, 1995, 1996, 1998 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "gdbcore.h"
-#include "target.h"
-#include <sys/ptrace.h>
-#ifdef __linux__
-# include <asm/reg.h>
-# include <alpha/ptrace.h>
-#else
-# include <machine/reg.h>
-#endif
-#include <sys/user.h>
-
-/* Prototypes for local functions. */
-
-static void fetch_osf_core_registers PARAMS ((char *,
- unsigned, int, CORE_ADDR));
-static void fetch_elf_core_registers PARAMS ((char *,
- unsigned, int, CORE_ADDR));
-
-/* Size of elements in jmpbuf */
-
-#define JB_ELEMENT_SIZE 8
-
-/* The definition for JB_PC in machine/reg.h is wrong.
- And we can't get at the correct definition in setjmp.h as it is
- not always available (eg. if _POSIX_SOURCE is defined which is the
- default). As the defintion is unlikely to change (see comment
- in <setjmp.h>, define the correct value here. */
-
-#undef JB_PC
-#define JB_PC 2
-
-/* Figure out where the longjmp will land.
- We expect the first arg to be a pointer to the jmp_buf structure from which
- we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
- This routine returns true on success. */
-
-int
-get_longjmp_target (pc)
- CORE_ADDR *pc;
-{
- CORE_ADDR jb_addr;
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
-
- jb_addr = read_register(A0_REGNUM);
-
- if (target_read_memory(jb_addr + JB_PC * JB_ELEMENT_SIZE, raw_buffer,
- sizeof(CORE_ADDR)))
- return 0;
-
- *pc = extract_address (raw_buffer, sizeof(CORE_ADDR));
- return 1;
-}
-
-/* Extract the register values out of the core file and store
- them where `read_register' will find them.
-
- 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.
- */
-
-static void
-fetch_osf_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr;
-{
- register int regno;
- register int addr;
- int bad_reg = -1;
-
- /* Table to map a gdb regnum to an index in the core register section.
- The floating point register values are garbage in OSF/1.2 core files. */
- static int core_reg_mapping[NUM_REGS] =
- {
-#define EFL (EF_SIZE / 8)
- EF_V0, EF_T0, EF_T1, EF_T2, EF_T3, EF_T4, EF_T5, EF_T6,
- EF_T7, EF_S0, EF_S1, EF_S2, EF_S3, EF_S4, EF_S5, EF_S6,
- EF_A0, EF_A1, EF_A2, EF_A3, EF_A4, EF_A5, EF_T8, EF_T9,
- EF_T10, EF_T11, EF_RA, EF_T12, EF_AT, EF_GP, EF_SP, -1,
- EFL+0, EFL+1, EFL+2, EFL+3, EFL+4, EFL+5, EFL+6, EFL+7,
- EFL+8, EFL+9, EFL+10, EFL+11, EFL+12, EFL+13, EFL+14, EFL+15,
- EFL+16, EFL+17, EFL+18, EFL+19, EFL+20, EFL+21, EFL+22, EFL+23,
- EFL+24, EFL+25, EFL+26, EFL+27, EFL+28, EFL+29, EFL+30, EFL+31,
- EF_PC, -1
- };
- static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0};
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- if (CANNOT_FETCH_REGISTER (regno))
- {
- supply_register (regno, zerobuf);
- continue;
- }
- addr = 8 * core_reg_mapping[regno];
- if (addr < 0 || 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.", REGISTER_NAME (bad_reg));
- }
-}
-
-static void
-fetch_elf_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr;
-{
- if (core_reg_size < 32*8)
- {
- error ("Core file register section too small (%u bytes).", core_reg_size);
- return;
- }
-
- if (which == 2)
- {
- /* The FPU Registers. */
- memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], core_reg_sect, 31*8);
- memset (&registers[REGISTER_BYTE (FP0_REGNUM+31)], 0, 8);
- memset (&register_valid[FP0_REGNUM], 1, 32);
- }
- else
- {
- /* The General Registers. */
- memcpy (&registers[REGISTER_BYTE (V0_REGNUM)], core_reg_sect, 31*8);
- memcpy (&registers[REGISTER_BYTE (PC_REGNUM)], core_reg_sect+31*8, 8);
- memset (&registers[REGISTER_BYTE (ZERO_REGNUM)], 0, 8);
- memset (&register_valid[V0_REGNUM], 1, 32);
- register_valid[PC_REGNUM] = 1;
- }
-}
-
-
-/* Map gdb internal register number to a ptrace ``address''.
- These ``addresses'' are defined in <sys/ptrace.h> */
-
-#define REGISTER_PTRACE_ADDR(regno) \
- (regno < FP0_REGNUM ? GPR_BASE + (regno) \
- : regno == PC_REGNUM ? PC \
- : regno >= FP0_REGNUM ? FPR_BASE + ((regno) - FP0_REGNUM) \
- : 0)
-
-/* Return the ptrace ``address'' of register REGNO. */
-
-CORE_ADDR
-register_addr (regno, blockend)
- int regno;
- CORE_ADDR blockend;
-{
- return REGISTER_PTRACE_ADDR (regno);
-}
-
-int
-kernel_u_size ()
-{
- return (sizeof (struct user));
-}
-
-#if defined(USE_PROC_FS) || defined(HAVE_GREGSET_T)
-#include <sys/procfs.h>
-
-/*
- * See the comment in m68k-tdep.c regarding the utility of these functions.
- */
-
-void
-supply_gregset (gregsetp)
- gregset_t *gregsetp;
-{
- register int regi;
- register long *regp = ALPHA_REGSET_BASE (gregsetp);
- static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0};
-
- for (regi = 0; regi < 31; regi++)
- supply_register (regi, (char *)(regp + regi));
-
- supply_register (PC_REGNUM, (char *)(regp + 31));
-
- /* Fill inaccessible registers with zero. */
- supply_register (ZERO_REGNUM, zerobuf);
- supply_register (FP_REGNUM, zerobuf);
-}
-
-void
-fill_gregset (gregsetp, regno)
- gregset_t *gregsetp;
- int regno;
-{
- int regi;
- register long *regp = ALPHA_REGSET_BASE (gregsetp);
-
- for (regi = 0; regi < 31; regi++)
- if ((regno == -1) || (regno == regi))
- *(regp + regi) = *(long *) &registers[REGISTER_BYTE (regi)];
-
- if ((regno == -1) || (regno == PC_REGNUM))
- *(regp + 31) = *(long *) &registers[REGISTER_BYTE (PC_REGNUM)];
-}
-
-/*
- * Now we do the same thing for floating-point registers.
- * Again, see the comments in m68k-tdep.c.
- */
-
-void
-supply_fpregset (fpregsetp)
- fpregset_t *fpregsetp;
-{
- register int regi;
- register long *regp = ALPHA_REGSET_BASE (fpregsetp);
-
- for (regi = 0; regi < 32; regi++)
- supply_register (regi + FP0_REGNUM, (char *)(regp + regi));
-}
-
-void
-fill_fpregset (fpregsetp, regno)
- fpregset_t *fpregsetp;
- int regno;
-{
- int regi;
- register long *regp = ALPHA_REGSET_BASE (fpregsetp);
-
- for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++)
- {
- if ((regno == -1) || (regno == regi))
- {
- *(regp + regi - FP0_REGNUM) =
- *(long *) &registers[REGISTER_BYTE (regi)];
- }
- }
-}
-#endif
-
-
-/* Register that we are able to handle alpha core file formats. */
-
-static struct core_fns alpha_osf_core_fns =
-{
- /* This really is bfd_target_unknown_flavour. */
-
- bfd_target_unknown_flavour,
- fetch_osf_core_registers,
- NULL
-};
-
-static struct core_fns alpha_elf_core_fns =
-{
- bfd_target_elf_flavour,
- fetch_elf_core_registers,
- NULL
-};
-
-void
-_initialize_core_alpha ()
-{
- add_core_fns (&alpha_osf_core_fns);
- add_core_fns (&alpha_elf_core_fns);
-}
diff --git a/contrib/gdb/gdb/alpha-tdep.c b/contrib/gdb/gdb/alpha-tdep.c
deleted file mode 100644
index 0201016..0000000
--- a/contrib/gdb/gdb/alpha-tdep.c
+++ /dev/null
@@ -1,1410 +0,0 @@
-/* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
- Copyright 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "symtab.h"
-#include "value.h"
-#include "gdbcmd.h"
-#include "gdbcore.h"
-#include "dis-asm.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "gdb_string.h"
-
-/* FIXME: Some of this code should perhaps be merged with mips-tdep.c. */
-
-/* Prototypes for local functions. */
-
-static alpha_extra_func_info_t push_sigtramp_desc PARAMS ((CORE_ADDR low_addr));
-
-static CORE_ADDR read_next_frame_reg PARAMS ((struct frame_info *, int));
-
-static CORE_ADDR heuristic_proc_start PARAMS ((CORE_ADDR));
-
-static alpha_extra_func_info_t heuristic_proc_desc PARAMS ((CORE_ADDR,
- CORE_ADDR,
- struct frame_info *));
-
-static alpha_extra_func_info_t find_proc_desc PARAMS ((CORE_ADDR,
- struct frame_info *));
-
-#if 0
-static int alpha_in_lenient_prologue PARAMS ((CORE_ADDR, CORE_ADDR));
-#endif
-
-static void reinit_frame_cache_sfunc PARAMS ((char *, int,
- struct cmd_list_element *));
-
-static CORE_ADDR after_prologue PARAMS ((CORE_ADDR pc,
- alpha_extra_func_info_t proc_desc));
-
-static int alpha_in_prologue PARAMS ((CORE_ADDR pc,
- alpha_extra_func_info_t proc_desc));
-
-/* Heuristic_proc_start may hunt through the text section for a long
- time across a 2400 baud serial line. Allows the user to limit this
- search. */
-static unsigned int heuristic_fence_post = 0;
-
-/* Layout of a stack frame on the alpha:
-
- | |
- pdr members: | 7th ... nth arg, |
- | `pushed' by caller. |
- | |
-----------------|-------------------------------|<-- old_sp == vfp
- ^ ^ ^ ^ | |
- | | | | | |
- | |localoff | Copies of 1st .. 6th |
- | | | | | argument if necessary. |
- | | | v | |
- | | | --- |-------------------------------|<-- FRAME_LOCALS_ADDRESS
- | | | | |
- | | | | Locals and temporaries. |
- | | | | |
- | | | |-------------------------------|
- | | | | |
- |-fregoffset | Saved float registers. |
- | | | | F9 |
- | | | | . |
- | | | | . |
- | | | | F2 |
- | | v | |
- | | -------|-------------------------------|
- | | | |
- | | | Saved registers. |
- | | | S6 |
- |-regoffset | . |
- | | | . |
- | | | S0 |
- | | | pdr.pcreg |
- | v | |
- | ----------|-------------------------------|
- | | |
- frameoffset | Argument build area, gets |
- | | 7th ... nth arg for any |
- | | called procedure. |
- v | |
- -------------|-------------------------------|<-- sp
- | |
-*/
-
-#define PROC_LOW_ADDR(proc) ((proc)->pdr.adr) /* least address */
-#define PROC_HIGH_ADDR(proc) ((proc)->pdr.iline) /* upper address bound */
-#define PROC_DUMMY_FRAME(proc) ((proc)->pdr.iopt) /* frame for CALL_DUMMY */
-#define PROC_FRAME_OFFSET(proc) ((proc)->pdr.frameoffset)
-#define PROC_FRAME_REG(proc) ((proc)->pdr.framereg)
-#define PROC_REG_MASK(proc) ((proc)->pdr.regmask)
-#define PROC_FREG_MASK(proc) ((proc)->pdr.fregmask)
-#define PROC_REG_OFFSET(proc) ((proc)->pdr.regoffset)
-#define PROC_FREG_OFFSET(proc) ((proc)->pdr.fregoffset)
-#define PROC_PC_REG(proc) ((proc)->pdr.pcreg)
-#define PROC_LOCALOFF(proc) ((proc)->pdr.localoff)
-#define PROC_SYMBOL(proc) (*(struct symbol**)&(proc)->pdr.isym)
-#define _PROC_MAGIC_ 0x0F0F0F0F
-#define PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym == _PROC_MAGIC_)
-#define SET_PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym = _PROC_MAGIC_)
-
-struct linked_proc_info
-{
- struct alpha_extra_func_info info;
- struct linked_proc_info *next;
-} *linked_proc_desc_table = NULL;
-
-
-/* Under GNU/Linux, signal handler invocations can be identified by the
- designated code sequence that is used to return from a signal
- handler. In particular, the return address of a signal handler
- points to the following sequence (the first instruction is quadword
- aligned):
-
- bis $30,$30,$16
- addq $31,0x67,$0
- call_pal callsys
-
- Each instruction has a unique encoding, so we simply attempt to
- match the instruction the pc is pointing to with any of the above
- instructions. If there is a hit, we know the offset to the start
- of the designated sequence and can then check whether we really are
- executing in a designated sequence. If not, -1 is returned,
- otherwise the offset from the start of the desingated sequence is
- returned.
-
- There is a slight chance of false hits: code could jump into the
- middle of the designated sequence, in which case there is no
- guarantee that we are in the middle of a sigreturn syscall. Don't
- think this will be a problem in praxis, though.
-*/
-
-long
-alpha_linux_sigtramp_offset (CORE_ADDR pc)
-{
- unsigned int i[3], w;
- long off;
-
- if (read_memory_nobpt(pc, (char *) &w, 4) != 0)
- return -1;
-
- off = -1;
- switch (w)
- {
- case 0x47de0410: off = 0; break; /* bis $30,$30,$16 */
- case 0x43ecf400: off = 4; break; /* addq $31,0x67,$0 */
- case 0x00000083: off = 8; break; /* call_pal callsys */
- default: return -1;
- }
- pc -= off;
- if (pc & 0x7)
- {
- /* designated sequence is not quadword aligned */
- return -1;
- }
-
- if (read_memory_nobpt(pc, (char *) i, sizeof(i)) != 0)
- return -1;
-
- if (i[0] == 0x47de0410 && i[1] == 0x43ecf400 && i[2] == 0x00000083)
- return off;
-
- return -1;
-}
-
-
-/* Under OSF/1, the __sigtramp routine is frameless and has a frame
- size of zero, but we are able to backtrace through it. */
-CORE_ADDR
-alpha_osf_skip_sigtramp_frame (frame, pc)
- struct frame_info *frame;
- CORE_ADDR pc;
-{
- char *name;
- find_pc_partial_function (pc, &name, (CORE_ADDR *)NULL, (CORE_ADDR *)NULL);
- if (IN_SIGTRAMP (pc, name))
- return frame->frame;
- else
- return 0;
-}
-
-
-/* Dynamically create a signal-handler caller procedure descriptor for
- the signal-handler return code starting at address LOW_ADDR. The
- descriptor is added to the linked_proc_desc_table. */
-
-static alpha_extra_func_info_t
-push_sigtramp_desc (low_addr)
- CORE_ADDR low_addr;
-{
- struct linked_proc_info *link;
- alpha_extra_func_info_t proc_desc;
-
- link = (struct linked_proc_info *)
- xmalloc (sizeof (struct linked_proc_info));
- link->next = linked_proc_desc_table;
- linked_proc_desc_table = link;
-
- proc_desc = &link->info;
-
- proc_desc->numargs = 0;
- PROC_LOW_ADDR (proc_desc) = low_addr;
- PROC_HIGH_ADDR (proc_desc) = low_addr + 3 * 4;
- PROC_DUMMY_FRAME (proc_desc) = 0;
- PROC_FRAME_OFFSET (proc_desc) = 0x298; /* sizeof(struct sigcontext_struct) */
- PROC_FRAME_REG (proc_desc) = SP_REGNUM;
- PROC_REG_MASK (proc_desc) = 0xffff;
- PROC_FREG_MASK (proc_desc) = 0xffff;
- PROC_PC_REG (proc_desc) = 26;
- PROC_LOCALOFF (proc_desc) = 0;
- SET_PROC_DESC_IS_DYN_SIGTRAMP (proc_desc);
- return (proc_desc);
-}
-
-
-/* Guaranteed to set frame->saved_regs to some values (it never leaves it
- NULL). */
-
-void
-alpha_find_saved_regs (frame)
- struct frame_info *frame;
-{
- int ireg;
- CORE_ADDR reg_position;
- unsigned long mask;
- alpha_extra_func_info_t proc_desc;
- int returnreg;
-
- frame_saved_regs_zalloc (frame);
-
- /* If it is the frame for __sigtramp, the saved registers are located
- in a sigcontext structure somewhere on the stack. __sigtramp
- passes a pointer to the sigcontext structure on the stack.
- If the stack layout for __sigtramp changes, or if sigcontext offsets
- change, we might have to update this code. */
-#ifndef SIGFRAME_PC_OFF
-#define SIGFRAME_PC_OFF (2 * 8)
-#define SIGFRAME_REGSAVE_OFF (4 * 8)
-#define SIGFRAME_FPREGSAVE_OFF (SIGFRAME_REGSAVE_OFF + 32 * 8 + 8)
-#endif
- if (frame->signal_handler_caller)
- {
- CORE_ADDR sigcontext_addr;
-
- sigcontext_addr = SIGCONTEXT_ADDR (frame);
- for (ireg = 0; ireg < 32; ireg++)
- {
- reg_position = sigcontext_addr + SIGFRAME_REGSAVE_OFF + ireg * 8;
- frame->saved_regs[ireg] = reg_position;
- }
- for (ireg = 0; ireg < 32; ireg++)
- {
- reg_position = sigcontext_addr + SIGFRAME_FPREGSAVE_OFF + ireg * 8;
- frame->saved_regs[FP0_REGNUM + ireg] = reg_position;
- }
- frame->saved_regs[PC_REGNUM] = sigcontext_addr + SIGFRAME_PC_OFF;
- return;
- }
-
- proc_desc = frame->proc_desc;
- if (proc_desc == NULL)
- /* I'm not sure how/whether this can happen. Normally when we can't
- find a proc_desc, we "synthesize" one using heuristic_proc_desc
- and set the saved_regs right away. */
- return;
-
- /* Fill in the offsets for the registers which gen_mask says
- were saved. */
-
- reg_position = frame->frame + PROC_REG_OFFSET (proc_desc);
- mask = PROC_REG_MASK (proc_desc);
-
- returnreg = PROC_PC_REG (proc_desc);
-
- /* Note that RA is always saved first, regardless of its actual
- register number. */
- if (mask & (1 << returnreg))
- {
- frame->saved_regs[returnreg] = reg_position;
- reg_position += 8;
- mask &= ~(1 << returnreg); /* Clear bit for RA so we
- don't save again later. */
- }
-
- for (ireg = 0; ireg <= 31 ; ++ireg)
- if (mask & (1 << ireg))
- {
- frame->saved_regs[ireg] = reg_position;
- reg_position += 8;
- }
-
- /* Fill in the offsets for the registers which float_mask says
- were saved. */
-
- reg_position = frame->frame + PROC_FREG_OFFSET (proc_desc);
- mask = PROC_FREG_MASK (proc_desc);
-
- for (ireg = 0; ireg <= 31 ; ++ireg)
- if (mask & (1 << ireg))
- {
- frame->saved_regs[FP0_REGNUM+ireg] = reg_position;
- reg_position += 8;
- }
-
- frame->saved_regs[PC_REGNUM] = frame->saved_regs[returnreg];
-}
-
-static CORE_ADDR
-read_next_frame_reg(fi, regno)
- struct frame_info *fi;
- int regno;
-{
- for (; fi; fi = fi->next)
- {
- /* We have to get the saved sp from the sigcontext
- if it is a signal handler frame. */
- if (regno == SP_REGNUM && !fi->signal_handler_caller)
- return fi->frame;
- else
- {
- if (fi->saved_regs == NULL)
- alpha_find_saved_regs (fi);
- if (fi->saved_regs[regno])
- return read_memory_integer(fi->saved_regs[regno], 8);
- }
- }
- return read_register(regno);
-}
-
-CORE_ADDR
-alpha_frame_saved_pc(frame)
- struct frame_info *frame;
-{
- alpha_extra_func_info_t proc_desc = frame->proc_desc;
- /* We have to get the saved pc from the sigcontext
- if it is a signal handler frame. */
- int pcreg = frame->signal_handler_caller ? PC_REGNUM : frame->pc_reg;
-
- if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc))
- return read_memory_integer(frame->frame - 8, 8);
-
- return read_next_frame_reg(frame, pcreg);
-}
-
-CORE_ADDR
-alpha_saved_pc_after_call (frame)
- struct frame_info *frame;
-{
- CORE_ADDR pc = frame->pc;
- CORE_ADDR tmp;
- alpha_extra_func_info_t proc_desc;
- int pcreg;
-
- /* Skip over shared library trampoline if necessary. */
- tmp = SKIP_TRAMPOLINE_CODE (pc);
- if (tmp != 0)
- pc = tmp;
-
- proc_desc = find_proc_desc (pc, frame->next);
- pcreg = proc_desc ? PROC_PC_REG (proc_desc) : RA_REGNUM;
-
- if (frame->signal_handler_caller)
- return alpha_frame_saved_pc (frame);
- else
- return read_register (pcreg);
-}
-
-
-static struct alpha_extra_func_info temp_proc_desc;
-static struct frame_saved_regs temp_saved_regs;
-
-/* Nonzero if instruction at PC is a return instruction. "ret
- $zero,($ra),1" on alpha. */
-
-static int
-alpha_about_to_return (pc)
- CORE_ADDR pc;
-{
- return read_memory_integer (pc, 4) == 0x6bfa8001;
-}
-
-
-
-/* This fencepost looks highly suspicious to me. Removing it also
- seems suspicious as it could affect remote debugging across serial
- lines. */
-
-static CORE_ADDR
-heuristic_proc_start(pc)
- CORE_ADDR pc;
-{
- CORE_ADDR start_pc = pc;
- CORE_ADDR fence = start_pc - heuristic_fence_post;
-
- if (start_pc == 0) return 0;
-
- if (heuristic_fence_post == UINT_MAX
- || fence < VM_MIN_ADDRESS)
- fence = VM_MIN_ADDRESS;
-
- /* search back for previous return */
- for (start_pc -= 4; ; start_pc -= 4)
- if (start_pc < fence)
- {
- /* It's not clear to me why we reach this point when
- stop_soon_quietly, but with this test, at least we
- don't print out warnings for every child forked (eg, on
- decstation). 22apr93 rich@cygnus.com. */
- if (!stop_soon_quietly)
- {
- static int blurb_printed = 0;
-
- if (fence == VM_MIN_ADDRESS)
- warning("Hit beginning of text section without finding");
- else
- warning("Hit heuristic-fence-post without finding");
-
- warning("enclosing function for address 0x%lx", pc);
- if (!blurb_printed)
- {
- printf_filtered ("\
-This warning occurs if you are debugging a function without any symbols\n\
-(for example, in a stripped executable). In that case, you may wish to\n\
-increase the size of the search with the `set heuristic-fence-post' command.\n\
-\n\
-Otherwise, you told GDB there was a function where there isn't one, or\n\
-(more likely) you have encountered a bug in GDB.\n");
- blurb_printed = 1;
- }
- }
-
- return 0;
- }
- else if (alpha_about_to_return (start_pc))
- break;
-
- start_pc += 4; /* skip return */
- return start_pc;
-}
-
-static alpha_extra_func_info_t
-heuristic_proc_desc(start_pc, limit_pc, next_frame)
- CORE_ADDR start_pc, limit_pc;
- struct frame_info *next_frame;
-{
- CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM);
- CORE_ADDR cur_pc;
- int frame_size;
- int has_frame_reg = 0;
- unsigned long reg_mask = 0;
- int pcreg = -1;
-
- if (start_pc == 0)
- return NULL;
- memset (&temp_proc_desc, '\0', sizeof(temp_proc_desc));
- memset (&temp_saved_regs, '\0', sizeof(struct frame_saved_regs));
- PROC_LOW_ADDR (&temp_proc_desc) = start_pc;
-
- if (start_pc + 200 < limit_pc)
- limit_pc = start_pc + 200;
- frame_size = 0;
- for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += 4)
- {
- char buf[4];
- unsigned long word;
- int status;
-
- status = read_memory_nobpt (cur_pc, buf, 4);
- if (status)
- memory_error (status, cur_pc);
- word = extract_unsigned_integer (buf, 4);
-
- if ((word & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */
- {
- if (word & 0x8000)
- frame_size += (-word) & 0xffff;
- else
- /* Exit loop if a positive stack adjustment is found, which
- usually means that the stack cleanup code in the function
- epilogue is reached. */
- break;
- }
- else if ((word & 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */
- && (word & 0xffff0000) != 0xb7fe0000) /* reg != $zero */
- {
- int reg = (word & 0x03e00000) >> 21;
- reg_mask |= 1 << reg;
- temp_saved_regs.regs[reg] = sp + (short)word;
-
- /* Starting with OSF/1-3.2C, the system libraries are shipped
- without local symbols, but they still contain procedure
- descriptors without a symbol reference. GDB is currently
- unable to find these procedure descriptors and uses
- heuristic_proc_desc instead.
- As some low level compiler support routines (__div*, __add*)
- use a non-standard return address register, we have to
- add some heuristics to determine the return address register,
- or stepping over these routines will fail.
- Usually the return address register is the first register
- saved on the stack, but assembler optimization might
- rearrange the register saves.
- So we recognize only a few registers (t7, t9, ra) within
- the procedure prologue as valid return address registers.
- If we encounter a return instruction, we extract the
- the return address register from it.
-
- FIXME: Rewriting GDB to access the procedure descriptors,
- e.g. via the minimal symbol table, might obviate this hack. */
- if (pcreg == -1
- && cur_pc < (start_pc + 80)
- && (reg == T7_REGNUM || reg == T9_REGNUM || reg == RA_REGNUM))
- pcreg = reg;
- }
- else if ((word & 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */
- pcreg = (word >> 16) & 0x1f;
- else if (word == 0x47de040f) /* bis sp,sp fp */
- has_frame_reg = 1;
- }
- if (pcreg == -1)
- {
- /* If we haven't found a valid return address register yet,
- keep searching in the procedure prologue. */
- while (cur_pc < (limit_pc + 80) && cur_pc < (start_pc + 80))
- {
- char buf[4];
- unsigned long word;
-
- if (read_memory_nobpt (cur_pc, buf, 4))
- break;
- cur_pc += 4;
- word = extract_unsigned_integer (buf, 4);
-
- if ((word & 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */
- && (word & 0xffff0000) != 0xb7fe0000) /* reg != $zero */
- {
- int reg = (word & 0x03e00000) >> 21;
- if (reg == T7_REGNUM || reg == T9_REGNUM || reg == RA_REGNUM)
- {
- pcreg = reg;
- break;
- }
- }
- else if ((word & 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */
- {
- pcreg = (word >> 16) & 0x1f;
- break;
- }
- }
- }
-
- if (has_frame_reg)
- PROC_FRAME_REG(&temp_proc_desc) = GCC_FP_REGNUM;
- else
- PROC_FRAME_REG(&temp_proc_desc) = SP_REGNUM;
- PROC_FRAME_OFFSET(&temp_proc_desc) = frame_size;
- PROC_REG_MASK(&temp_proc_desc) = reg_mask;
- PROC_PC_REG(&temp_proc_desc) = (pcreg == -1) ? RA_REGNUM : pcreg;
- PROC_LOCALOFF(&temp_proc_desc) = 0; /* XXX - bogus */
- return &temp_proc_desc;
-}
-
-/* This returns the PC of the first inst after the prologue. If we can't
- find the prologue, then return 0. */
-
-static CORE_ADDR
-after_prologue (pc, proc_desc)
- CORE_ADDR pc;
- alpha_extra_func_info_t proc_desc;
-{
- struct symtab_and_line sal;
- CORE_ADDR func_addr, func_end;
-
- if (!proc_desc)
- proc_desc = find_proc_desc (pc, NULL);
-
- if (proc_desc)
- {
- if (PROC_DESC_IS_DYN_SIGTRAMP (proc_desc))
- return PROC_LOW_ADDR (proc_desc); /* "prologue" is in kernel */
-
- /* If function is frameless, then we need to do it the hard way. I
- strongly suspect that frameless always means prologueless... */
- if (PROC_FRAME_REG (proc_desc) == SP_REGNUM
- && PROC_FRAME_OFFSET (proc_desc) == 0)
- return 0;
- }
-
- if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end))
- return 0; /* Unknown */
-
- sal = find_pc_line (func_addr, 0);
-
- if (sal.end < func_end)
- return sal.end;
-
- /* The line after the prologue is after the end of the function. In this
- case, tell the caller to find the prologue the hard way. */
-
- return 0;
-}
-
-/* Return non-zero if we *might* be in a function prologue. Return zero if we
- are definitively *not* in a function prologue. */
-
-static int
-alpha_in_prologue (pc, proc_desc)
- CORE_ADDR pc;
- alpha_extra_func_info_t proc_desc;
-{
- CORE_ADDR after_prologue_pc;
-
- after_prologue_pc = after_prologue (pc, proc_desc);
-
- if (after_prologue_pc == 0
- || pc < after_prologue_pc)
- return 1;
- else
- return 0;
-}
-
-static alpha_extra_func_info_t
-find_proc_desc (pc, next_frame)
- CORE_ADDR pc;
- struct frame_info *next_frame;
-{
- alpha_extra_func_info_t proc_desc;
- struct block *b;
- struct symbol *sym;
- CORE_ADDR startaddr;
-
- /* Try to get the proc_desc from the linked call dummy proc_descs
- if the pc is in the call dummy.
- This is hairy. In the case of nested dummy calls we have to find the
- right proc_desc, but we might not yet know the frame for the dummy
- as it will be contained in the proc_desc we are searching for.
- So we have to find the proc_desc whose frame is closest to the current
- stack pointer. */
-
- if (PC_IN_CALL_DUMMY (pc, 0, 0))
- {
- struct linked_proc_info *link;
- CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM);
- alpha_extra_func_info_t found_proc_desc = NULL;
- long min_distance = LONG_MAX;
-
- for (link = linked_proc_desc_table; link; link = link->next)
- {
- long distance = (CORE_ADDR) PROC_DUMMY_FRAME (&link->info) - sp;
- if (distance > 0 && distance < min_distance)
- {
- min_distance = distance;
- found_proc_desc = &link->info;
- }
- }
- if (found_proc_desc != NULL)
- return found_proc_desc;
- }
-
- b = block_for_pc(pc);
-
- find_pc_partial_function (pc, NULL, &startaddr, NULL);
- if (b == NULL)
- sym = NULL;
- else
- {
- if (startaddr > BLOCK_START (b))
- /* This is the "pathological" case referred to in a comment in
- print_frame_info. It might be better to move this check into
- symbol reading. */
- sym = NULL;
- else
- sym = lookup_symbol (MIPS_EFI_SYMBOL_NAME, b, LABEL_NAMESPACE,
- 0, NULL);
- }
-
- /* If we never found a PDR for this function in symbol reading, then
- examine prologues to find the information. */
- if (sym && ((mips_extra_func_info_t) SYMBOL_VALUE (sym))->pdr.framereg == -1)
- sym = NULL;
-
- if (sym)
- {
- /* 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 "heuristic" proc_desc (by analyzing
- * the actual code) to replace the "official" proc_desc.
- */
- proc_desc = (alpha_extra_func_info_t)SYMBOL_VALUE(sym);
- if (next_frame == NULL)
- {
- if (PROC_DESC_IS_DUMMY (proc_desc) || alpha_in_prologue (pc, proc_desc))
- {
- alpha_extra_func_info_t found_heuristic =
- heuristic_proc_desc (PROC_LOW_ADDR (proc_desc),
- pc, next_frame);
- if (found_heuristic)
- {
- PROC_LOCALOFF (found_heuristic) =
- PROC_LOCALOFF (proc_desc);
- PROC_PC_REG (found_heuristic) = PROC_PC_REG (proc_desc);
- proc_desc = found_heuristic;
- }
- }
- }
- }
- else
- {
- long offset;
-
- /* Is linked_proc_desc_table really necessary? It only seems to be used
- by procedure call dummys. However, the procedures being called ought
- to have their own proc_descs, and even if they don't,
- heuristic_proc_desc knows how to create them! */
-
- 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;
-
- /* If PC is inside a dynamically generated sigtramp handler,
- create and push a procedure descriptor for that code: */
- offset = DYNAMIC_SIGTRAMP_OFFSET (pc);
- if (offset >= 0)
- return push_sigtramp_desc (pc - offset);
-
- /* If heuristic_fence_post is non-zero, determine the procedure
- start address by examining the instructions.
- This allows us to find the start address of static functions which
- have no symbolic information, as startaddr would have been set to
- the preceding global function start address by the
- find_pc_partial_function call above. */
- if (startaddr == 0 || heuristic_fence_post != 0)
- startaddr = heuristic_proc_start (pc);
-
- proc_desc =
- heuristic_proc_desc (startaddr, pc, next_frame);
- }
- return proc_desc;
-}
-
-alpha_extra_func_info_t cached_proc_desc;
-
-CORE_ADDR
-alpha_frame_chain(frame)
- struct frame_info *frame;
-{
- alpha_extra_func_info_t proc_desc;
- CORE_ADDR saved_pc = FRAME_SAVED_PC(frame);
-
- if (saved_pc == 0 || inside_entry_file (saved_pc))
- return 0;
-
- proc_desc = find_proc_desc(saved_pc, frame);
- if (!proc_desc)
- return 0;
-
- cached_proc_desc = proc_desc;
-
- /* Fetch the frame pointer for a dummy frame from the procedure
- descriptor. */
- if (PROC_DESC_IS_DUMMY(proc_desc))
- return (CORE_ADDR) PROC_DUMMY_FRAME(proc_desc);
-
- /* If no frame pointer and frame size is zero, we must be at end
- of stack (or otherwise hosed). If we don't check frame size,
- we loop forever if we see a zero size frame. */
- if (PROC_FRAME_REG (proc_desc) == SP_REGNUM
- && PROC_FRAME_OFFSET (proc_desc) == 0
- /* The previous frame from a sigtramp frame might be frameless
- and have frame size zero. */
- && !frame->signal_handler_caller)
- return FRAME_PAST_SIGTRAMP_FRAME (frame, saved_pc);
- else
- return read_next_frame_reg(frame, PROC_FRAME_REG(proc_desc))
- + PROC_FRAME_OFFSET(proc_desc);
-}
-
-void
-init_extra_frame_info (frame)
- struct frame_info *frame;
-{
- /* Use proc_desc calculated in frame_chain */
- alpha_extra_func_info_t proc_desc =
- frame->next ? cached_proc_desc : find_proc_desc(frame->pc, frame->next);
-
- frame->saved_regs = NULL;
- frame->localoff = 0;
- frame->pc_reg = RA_REGNUM;
- frame->proc_desc = proc_desc == &temp_proc_desc ? 0 : proc_desc;
- if (proc_desc)
- {
- /* Get the locals offset and the saved pc register from the
- procedure descriptor, they are valid even if we are in the
- middle of the prologue. */
- frame->localoff = PROC_LOCALOFF(proc_desc);
- frame->pc_reg = PROC_PC_REG(proc_desc);
-
- /* Fixup frame-pointer - only needed for top frame */
-
- /* Fetch the frame pointer for a dummy frame from the procedure
- descriptor. */
- if (PROC_DESC_IS_DUMMY(proc_desc))
- frame->frame = (CORE_ADDR) PROC_DUMMY_FRAME(proc_desc);
-
- /* This may not be quite right, if proc has a real frame register.
- Get the value of the frame relative sp, procedure might have been
- interrupted by a signal at it's very start. */
- else if (frame->pc == PROC_LOW_ADDR (proc_desc)
- && !PROC_DESC_IS_DYN_SIGTRAMP (proc_desc))
- frame->frame = read_next_frame_reg (frame->next, SP_REGNUM);
- else
- frame->frame = read_next_frame_reg (frame->next, PROC_FRAME_REG (proc_desc))
- + PROC_FRAME_OFFSET (proc_desc);
-
- if (proc_desc == &temp_proc_desc)
- {
- char *name;
-
- /* Do not set the saved registers for a sigtramp frame,
- alpha_find_saved_registers will do that for us.
- We can't use frame->signal_handler_caller, it is not yet set. */
- find_pc_partial_function (frame->pc, &name,
- (CORE_ADDR *)NULL,(CORE_ADDR *)NULL);
- if (!IN_SIGTRAMP (frame->pc, name))
- {
- frame->saved_regs = (CORE_ADDR*)
- frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS);
- memcpy (frame->saved_regs, temp_saved_regs.regs, SIZEOF_FRAME_SAVED_REGS);
- frame->saved_regs[PC_REGNUM]
- = frame->saved_regs[RA_REGNUM];
- }
- }
- }
-}
-
-/* ALPHA stack frames are almost impenetrable. When execution stops,
- we basically have to look at symbol information for the function
- that we stopped in, which tells us *which* register (if any) is
- the base of the frame pointer, and what offset from that register
- the frame itself is at.
-
- This presents a problem when trying to examine a stack in memory
- (that isn't executing at the moment), using the "frame" command. We
- don't have a PC, nor do we have any registers except SP.
-
- This routine takes two arguments, SP and PC, and tries to make 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. */
-
-struct frame_info *
-setup_arbitrary_frame (argc, argv)
- int argc;
- CORE_ADDR *argv;
-{
- if (argc != 2)
- error ("ALPHA frame specifications require two arguments: sp and pc");
-
- return create_new_frame (argv[0], argv[1]);
-}
-
-/* The alpha passes the first six arguments in the registers, the rest on
- the stack. The register arguments are eventually transferred to the
- argument transfer area immediately below the stack by the called function
- anyway. So we `push' at least six arguments on the stack, `reload' the
- argument registers and then adjust the stack pointer to point past the
- sixth argument. This algorithm simplifies the passing of a large struct
- which extends from the registers to the stack.
- If the called function is returning a structure, the address of the
- structure to be returned is passed as a hidden first argument. */
-
-CORE_ADDR
-alpha_push_arguments (nargs, args, sp, struct_return, struct_addr)
- int nargs;
- value_ptr *args;
- CORE_ADDR sp;
- int struct_return;
- CORE_ADDR struct_addr;
-{
- register i;
- int accumulate_size = struct_return ? 8 : 0;
- int arg_regs_size = ALPHA_NUM_ARG_REGS * 8;
- struct alpha_arg { char *contents; int len; int offset; };
- struct alpha_arg *alpha_args =
- (struct alpha_arg*)alloca (nargs * sizeof (struct alpha_arg));
- register struct alpha_arg *m_arg;
- char raw_buffer[sizeof (CORE_ADDR)];
- int required_arg_regs;
-
- for (i = 0, m_arg = alpha_args; i < nargs; i++, m_arg++)
- {
- value_ptr arg = args[i];
- struct type *arg_type = check_typedef (VALUE_TYPE (arg));
- /* Cast argument to long if necessary as the compiler does it too. */
- switch (TYPE_CODE (arg_type))
- {
- case TYPE_CODE_INT:
- case TYPE_CODE_BOOL:
- case TYPE_CODE_CHAR:
- case TYPE_CODE_RANGE:
- case TYPE_CODE_ENUM:
- if (TYPE_LENGTH (arg_type) < TYPE_LENGTH (builtin_type_long))
- {
- arg_type = builtin_type_long;
- arg = value_cast (arg_type, arg);
- }
- break;
- default:
- break;
- }
- m_arg->len = TYPE_LENGTH (arg_type);
- m_arg->offset = accumulate_size;
- accumulate_size = (accumulate_size + m_arg->len + 7) & ~7;
- m_arg->contents = VALUE_CONTENTS(arg);
- }
-
- /* Determine required argument register loads, loading an argument register
- is expensive as it uses three ptrace calls. */
- required_arg_regs = accumulate_size / 8;
- if (required_arg_regs > ALPHA_NUM_ARG_REGS)
- required_arg_regs = ALPHA_NUM_ARG_REGS;
-
- /* Make room for the arguments on the stack. */
- if (accumulate_size < arg_regs_size)
- accumulate_size = arg_regs_size;
- sp -= accumulate_size;
-
- /* Keep sp aligned to a multiple of 16 as the compiler does it too. */
- sp &= ~15;
-
- /* `Push' arguments on the stack. */
- for (i = nargs; m_arg--, --i >= 0; )
- write_memory(sp + m_arg->offset, m_arg->contents, m_arg->len);
- if (struct_return)
- {
- store_address (raw_buffer, sizeof (CORE_ADDR), struct_addr);
- write_memory (sp, raw_buffer, sizeof (CORE_ADDR));
- }
-
- /* Load the argument registers. */
- for (i = 0; i < required_arg_regs; i++)
- {
- LONGEST val;
-
- val = read_memory_integer (sp + i * 8, 8);
- write_register (A0_REGNUM + i, val);
- write_register (FPA0_REGNUM + i, val);
- }
-
- return sp + arg_regs_size;
-}
-
-void
-alpha_push_dummy_frame()
-{
- int ireg;
- struct linked_proc_info *link;
- alpha_extra_func_info_t proc_desc;
- CORE_ADDR sp = read_register (SP_REGNUM);
- CORE_ADDR save_address;
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
- unsigned long mask;
-
- link = (struct linked_proc_info *) xmalloc(sizeof (struct linked_proc_info));
- link->next = linked_proc_desc_table;
- linked_proc_desc_table = link;
-
- proc_desc = &link->info;
-
- /*
- * The registers we must save are all those not preserved across
- * procedure calls.
- * In addition, we must save the PC and RA.
- *
- * Dummy frame layout:
- * (high memory)
- * Saved PC
- * Saved F30
- * ...
- * Saved F0
- * Saved R29
- * ...
- * Saved R0
- * Saved R26 (RA)
- * Parameter build area
- * (low memory)
- */
-
-/* MASK(i,j) == (1<<i) + (1<<(i+1)) + ... + (1<<j)). Assume i<=j<31. */
-#define MASK(i,j) ((((LONGEST)1 << ((j)+1)) - 1) ^ (((LONGEST)1 << (i)) - 1))
-#define GEN_REG_SAVE_MASK (MASK(0,8) | MASK(16,29))
-#define GEN_REG_SAVE_COUNT 24
-#define FLOAT_REG_SAVE_MASK (MASK(0,1) | MASK(10,30))
-#define FLOAT_REG_SAVE_COUNT 23
- /* The special register is the PC as we have no bit for it in the save masks.
- alpha_frame_saved_pc knows where the pc is saved in a dummy frame. */
-#define SPECIAL_REG_SAVE_COUNT 1
-
- PROC_REG_MASK(proc_desc) = GEN_REG_SAVE_MASK;
- PROC_FREG_MASK(proc_desc) = FLOAT_REG_SAVE_MASK;
- /* PROC_REG_OFFSET is the offset from the dummy frame to the saved RA,
- but keep SP aligned to a multiple of 16. */
- PROC_REG_OFFSET(proc_desc) =
- - ((8 * (SPECIAL_REG_SAVE_COUNT
- + GEN_REG_SAVE_COUNT
- + FLOAT_REG_SAVE_COUNT)
- + 15) & ~15);
- PROC_FREG_OFFSET(proc_desc) =
- PROC_REG_OFFSET(proc_desc) + 8 * GEN_REG_SAVE_COUNT;
-
- /* Save general registers.
- The return address register is the first saved register, all other
- registers follow in ascending order.
- The PC is saved immediately below the SP. */
- save_address = sp + PROC_REG_OFFSET(proc_desc);
- store_address (raw_buffer, 8, read_register (RA_REGNUM));
- write_memory (save_address, raw_buffer, 8);
- save_address += 8;
- mask = PROC_REG_MASK(proc_desc) & 0xffffffffL;
- for (ireg = 0; mask; ireg++, mask >>= 1)
- if (mask & 1)
- {
- if (ireg == RA_REGNUM)
- continue;
- store_address (raw_buffer, 8, read_register (ireg));
- write_memory (save_address, raw_buffer, 8);
- save_address += 8;
- }
-
- store_address (raw_buffer, 8, read_register (PC_REGNUM));
- write_memory (sp - 8, raw_buffer, 8);
-
- /* Save floating point registers. */
- save_address = sp + PROC_FREG_OFFSET(proc_desc);
- mask = PROC_FREG_MASK(proc_desc) & 0xffffffffL;
- for (ireg = 0; mask; ireg++, mask >>= 1)
- if (mask & 1)
- {
- store_address (raw_buffer, 8, read_register (ireg + FP0_REGNUM));
- write_memory (save_address, raw_buffer, 8);
- save_address += 8;
- }
-
- /* Set and save the frame address for the dummy.
- This is tricky. The only registers that are suitable for a frame save
- are those that are preserved across procedure calls (s0-s6). But if
- a read system call is interrupted and then a dummy call is made
- (see testsuite/gdb.t17/interrupt.exp) the dummy call hangs till the read
- is satisfied. Then it returns with the s0-s6 registers set to the values
- on entry to the read system call and our dummy frame pointer would be
- destroyed. So we save the dummy frame in the proc_desc and handle the
- retrieval of the frame pointer of a dummy specifically. The frame register
- is set to the virtual frame (pseudo) register, it's value will always
- be read as zero and will help us to catch any errors in the dummy frame
- retrieval code. */
- PROC_DUMMY_FRAME(proc_desc) = sp;
- PROC_FRAME_REG(proc_desc) = FP_REGNUM;
- PROC_FRAME_OFFSET(proc_desc) = 0;
- sp += PROC_REG_OFFSET(proc_desc);
- write_register (SP_REGNUM, sp);
-
- PROC_LOW_ADDR(proc_desc) = CALL_DUMMY_ADDRESS ();
- PROC_HIGH_ADDR(proc_desc) = PROC_LOW_ADDR(proc_desc) + 4;
-
- SET_PROC_DESC_IS_DUMMY(proc_desc);
- PROC_PC_REG(proc_desc) = RA_REGNUM;
-}
-
-void
-alpha_pop_frame()
-{
- register int regnum;
- struct frame_info *frame = get_current_frame ();
- CORE_ADDR new_sp = frame->frame;
-
- alpha_extra_func_info_t proc_desc = frame->proc_desc;
-
- write_register (PC_REGNUM, FRAME_SAVED_PC(frame));
- if (frame->saved_regs == NULL)
- alpha_find_saved_regs (frame);
- if (proc_desc)
- {
- for (regnum = 32; --regnum >= 0; )
- if (PROC_REG_MASK(proc_desc) & (1 << regnum))
- write_register (regnum,
- read_memory_integer (frame->saved_regs[regnum],
- 8));
- for (regnum = 32; --regnum >= 0; )
- if (PROC_FREG_MASK(proc_desc) & (1 << regnum))
- write_register (regnum + FP0_REGNUM,
- read_memory_integer (frame->saved_regs[regnum + FP0_REGNUM], 8));
- }
- write_register (SP_REGNUM, new_sp);
- flush_cached_frames ();
-
- if (proc_desc && (PROC_DESC_IS_DUMMY(proc_desc)
- || PROC_DESC_IS_DYN_SIGTRAMP (proc_desc)))
- {
- struct linked_proc_info *pi_ptr, *prev_ptr;
-
- for (pi_ptr = linked_proc_desc_table, prev_ptr = NULL;
- pi_ptr != NULL;
- prev_ptr = pi_ptr, pi_ptr = pi_ptr->next)
- {
- if (&pi_ptr->info == proc_desc)
- break;
- }
-
- if (pi_ptr == NULL)
- error ("Can't locate dummy extra frame info\n");
-
- if (prev_ptr != NULL)
- prev_ptr->next = pi_ptr->next;
- else
- linked_proc_desc_table = pi_ptr->next;
-
- free (pi_ptr);
- }
-}
-
-/* To skip prologues, I use this predicate. Returns either PC itself
- if the code at PC does not look like a function prologue; otherwise
- returns an address that (if we're lucky) follows the prologue. If
- LENIENT, then we must skip everything which is involved in setting
- up the frame (it's OK to skip more, just so long as we don't skip
- anything which might clobber the registers which are being saved.
- Currently we must not skip more on the alpha, but we might the lenient
- stuff some day. */
-
-CORE_ADDR
-alpha_skip_prologue (pc, lenient)
- CORE_ADDR pc;
- int lenient;
-{
- unsigned long inst;
- int offset;
- CORE_ADDR post_prologue_pc;
- char buf[4];
-
-#ifdef GDB_TARGET_HAS_SHARED_LIBS
- /* Silently return the unaltered pc upon memory errors.
- This could happen on OSF/1 if decode_line_1 tries to skip the
- prologue for quickstarted shared library functions when the
- shared library is not yet mapped in.
- Reading target memory is slow over serial lines, so we perform
- this check only if the target has shared libraries. */
- if (target_read_memory (pc, buf, 4))
- return pc;
-#endif
-
- /* See if we can determine the end of the prologue via the symbol table.
- If so, then return either PC, or the PC after the prologue, whichever
- is greater. */
-
- post_prologue_pc = after_prologue (pc, NULL);
-
- if (post_prologue_pc != 0)
- return max (pc, post_prologue_pc);
-
- /* Can't determine prologue from the symbol table, need to examine
- instructions. */
-
- /* Skip the typical prologue instructions. These are the stack adjustment
- instruction and the instructions that save registers on the stack
- or in the gcc frame. */
- for (offset = 0; offset < 100; offset += 4)
- {
- int status;
-
- status = read_memory_nobpt (pc + offset, buf, 4);
- if (status)
- memory_error (status, pc + offset);
- inst = extract_unsigned_integer (buf, 4);
-
- /* The alpha has no delay slots. But let's keep the lenient stuff,
- we might need it for something else in the future. */
- if (lenient && 0)
- continue;
-
- if ((inst & 0xffff0000) == 0x27bb0000) /* ldah $gp,n($t12) */
- continue;
- if ((inst & 0xffff0000) == 0x23bd0000) /* lda $gp,n($gp) */
- continue;
- if ((inst & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */
- continue;
- else if ((inst & 0xfc1f0000) == 0xb41e0000
- && (inst & 0xffff0000) != 0xb7fe0000)
- continue; /* stq reg,n($sp) */
- /* reg != $zero */
- else if ((inst & 0xfc1f0000) == 0x9c1e0000
- && (inst & 0xffff0000) != 0x9ffe0000)
- continue; /* stt reg,n($sp) */
- /* reg != $zero */
- else if (inst == 0x47de040f) /* bis sp,sp,fp */
- continue;
- else
- break;
- }
- return pc + offset;
-}
-
-#if 0
-/* Is address PC in the prologue (loosely defined) for function at
- STARTADDR? */
-
-static int
-alpha_in_lenient_prologue (startaddr, pc)
- CORE_ADDR startaddr;
- CORE_ADDR pc;
-{
- CORE_ADDR end_prologue = alpha_skip_prologue (startaddr, 1);
- return pc >= startaddr && pc < end_prologue;
-}
-#endif
-
-/* The alpha needs a conversion between register and memory format if
- the register is a floating point register and
- memory format is float, as the register format must be double
- or
- memory format is an integer with 4 bytes or less, as the representation
- of integers in floating point registers is different. */
-void
-alpha_register_convert_to_virtual (regnum, valtype, raw_buffer, virtual_buffer)
- int regnum;
- struct type *valtype;
- char *raw_buffer;
- char *virtual_buffer;
-{
- if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum))
- {
- memcpy (virtual_buffer, raw_buffer, REGISTER_VIRTUAL_SIZE (regnum));
- return;
- }
-
- if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
- {
- double d = extract_floating (raw_buffer, REGISTER_RAW_SIZE (regnum));
- store_floating (virtual_buffer, TYPE_LENGTH (valtype), d);
- }
- else if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 4)
- {
- ULONGEST l;
- l = extract_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (regnum));
- l = ((l >> 32) & 0xc0000000) | ((l >> 29) & 0x3fffffff);
- store_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype), l);
- }
- else
- error ("Cannot retrieve value from floating point register");
-}
-
-void
-alpha_register_convert_to_raw (valtype, regnum, virtual_buffer, raw_buffer)
- struct type *valtype;
- int regnum;
- char *virtual_buffer;
- char *raw_buffer;
-{
- if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum))
- {
- memcpy (raw_buffer, virtual_buffer, REGISTER_RAW_SIZE (regnum));
- return;
- }
-
- if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
- {
- double d = extract_floating (virtual_buffer, TYPE_LENGTH (valtype));
- store_floating (raw_buffer, REGISTER_RAW_SIZE (regnum), d);
- }
- else if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 4)
- {
- ULONGEST l;
- if (TYPE_UNSIGNED (valtype))
- l = extract_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype));
- else
- l = extract_signed_integer (virtual_buffer, TYPE_LENGTH (valtype));
- l = ((l & 0xc0000000) << 32) | ((l & 0x3fffffff) << 29);
- store_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (regnum), l);
- }
- else
- error ("Cannot store value in floating point register");
-}
-
-/* Given a return value in `regbuf' with a type `valtype',
- extract and copy its value into `valbuf'. */
-
-void
-alpha_extract_return_value (valtype, regbuf, valbuf)
- struct type *valtype;
- char regbuf[REGISTER_BYTES];
- char *valbuf;
-{
- if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
- alpha_register_convert_to_virtual (FP0_REGNUM, valtype,
- regbuf + REGISTER_BYTE (FP0_REGNUM),
- valbuf);
- else
- memcpy (valbuf, regbuf + REGISTER_BYTE (V0_REGNUM), TYPE_LENGTH (valtype));
-}
-
-/* Given a return value in `regbuf' with a type `valtype',
- write its value into the appropriate register. */
-
-void
-alpha_store_return_value (valtype, valbuf)
- struct type *valtype;
- char *valbuf;
-{
- char raw_buffer[MAX_REGISTER_RAW_SIZE];
- int regnum = V0_REGNUM;
- int length = TYPE_LENGTH (valtype);
-
- if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
- {
- regnum = FP0_REGNUM;
- length = REGISTER_RAW_SIZE (regnum);
- alpha_register_convert_to_raw (valtype, regnum, valbuf, raw_buffer);
- }
- else
- memcpy (raw_buffer, valbuf, length);
-
- write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, length);
-}
-
-/* Just like reinit_frame_cache, but with the right arguments to be
- callable as an sfunc. */
-
-static void
-reinit_frame_cache_sfunc (args, from_tty, c)
- char *args;
- int from_tty;
- struct cmd_list_element *c;
-{
- reinit_frame_cache ();
-}
-
-/* This is the definition of CALL_DUMMY_ADDRESS. It's a heuristic that is used
- to find a convenient place in the text segment to stick a breakpoint to
- detect the completion of a target function call (ala call_function_by_hand).
- */
-
-CORE_ADDR
-alpha_call_dummy_address ()
-{
- CORE_ADDR entry;
- struct minimal_symbol *sym;
-
- entry = entry_point_address ();
-
- if (entry != 0)
- return entry;
-
- sym = lookup_minimal_symbol ("_Prelude", NULL, symfile_objfile);
-
- if (!sym || MSYMBOL_TYPE (sym) != mst_text)
- return 0;
- else
- return SYMBOL_VALUE_ADDRESS (sym) + 4;
-}
-
-void
-_initialize_alpha_tdep ()
-{
- struct cmd_list_element *c;
-
- tm_print_insn = print_insn_alpha;
-
- /* Let the user set the fence post for heuristic_proc_start. */
-
- /* We really would like to have both "0" and "unlimited" work, but
- command.c doesn't deal with that. So make it a var_zinteger
- because the user can always use "999999" or some such for unlimited. */
- c = add_set_cmd ("heuristic-fence-post", class_support, var_zinteger,
- (char *) &heuristic_fence_post,
- "\
-Set the distance searched for the start of a function.\n\
-If you are debugging a stripped executable, GDB needs to search through the\n\
-program for the start of a function. This command sets the distance of the\n\
-search. The only need to set it is when debugging a stripped executable.",
- &setlist);
- /* We need to throw away the frame cache when we set this, since it
- might change our ability to get backtraces. */
- c->function.sfunc = reinit_frame_cache_sfunc;
- add_show_from_set (c, &showlist);
-}
diff --git a/contrib/gdb/gdb/arm-convert.s b/contrib/gdb/gdb/arm-convert.s
deleted file mode 100644
index 416132b..0000000
--- a/contrib/gdb/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/contrib/gdb/gdb/arm-tdep.c b/contrib/gdb/gdb/arm-tdep.c
deleted file mode 100644
index 607dc8f..0000000
--- a/contrib/gdb/gdb/arm-tdep.c
+++ /dev/null
@@ -1,1626 +0,0 @@
-/* Target-dependent code for the Acorn Risc Machine, for GDB, the GNU Debugger.
- Copyright (C) 1988, 1989, 1991, 1992, 1993, 1995, 1996, 1998, 1999
- Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "gdbcmd.h"
-#include "gdbcore.h"
-#include "symfile.h"
-#include "gdb_string.h"
-#include "coff/internal.h" /* Internal format of COFF symbols in BFD */
-
-/*
- The following macros are actually wrong. Neither arm nor thumb can
- or should set the lsb on addr.
- The thumb addresses are mod 2, so (addr & 2) would be a good heuristic
- to use when checking for thumb (see arm_pc_is_thumb() below).
- Unfortunately, something else depends on these (incorrect) macros, so
- fixing them actually breaks gdb. I didn't have time to investigate. Z.R.
-*/
-/* Thumb function addresses are odd (bit 0 is set). Here are some
- macros to test, set, or clear bit 0 of addresses. */
-#define IS_THUMB_ADDR(addr) ((addr) & 1)
-#define MAKE_THUMB_ADDR(addr) ((addr) | 1)
-#define UNMAKE_THUMB_ADDR(addr) ((addr) & ~1)
-
-/* Macros to round N up or down to the next A boundary; A must be
- a power of two. */
-#define ROUND_DOWN(n,a) ((n) & ~((a) - 1))
-#define ROUND_UP(n,a) (((n) + (a) - 1) & ~((a) - 1))
-
-/* Should call_function allocate stack space for a struct return? */
-/* The system C compiler uses a similar structure return convention to gcc */
-int
-arm_use_struct_convention (gcc_p, type)
- int gcc_p;
- struct type *type;
-{
- return (TYPE_LENGTH (type) > 4);
-}
-
-int
-arm_frame_chain_valid (chain, thisframe)
- CORE_ADDR chain;
- struct frame_info *thisframe;
-{
-#define LOWEST_PC 0x20 /* the first 0x20 bytes are the trap vectors. */
- return (chain != 0 && (FRAME_SAVED_PC (thisframe) >= LOWEST_PC));
-}
-
-/* Set to true if the 32-bit mode is in use. */
-
-int arm_apcs_32 = 1;
-
-/* Flag set by arm_fix_call_dummy that tells whether the target function
- is a Thumb function. This flag is checked by arm_push_arguments.
- FIXME: Change the PUSH_ARGUMENTS macro (and its use in valops.c) to
- pass the function address as an additional parameter. */
-
-static int target_is_thumb;
-
-/* Flag set by arm_fix_call_dummy that tells whether the calling function
- is a Thumb function. This flag is checked by arm_pc_is_thumb
- and arm_call_dummy_breakpoint_offset. */
-
-static int caller_is_thumb;
-
-/* Tell if the program counter value in MEMADDR is in a Thumb function. */
-
-int
-arm_pc_is_thumb (memaddr)
- bfd_vma memaddr;
-{
- struct minimal_symbol * sym;
- CORE_ADDR sp;
-
- /* If bit 0 of the address is set, assume this is a Thumb address. */
- if (IS_THUMB_ADDR (memaddr))
- return 1;
-
- /* Thumb function have a "special" bit set in minimal symbols */
- sym = lookup_minimal_symbol_by_pc (memaddr);
- if (sym)
- {
- return (MSYMBOL_IS_SPECIAL(sym));
- }
- else
- return 0;
-}
-
-/* Tell if the program counter value in MEMADDR is in a call dummy that
- is being called from a Thumb function. */
-
-int
-arm_pc_is_thumb_dummy (memaddr)
- bfd_vma memaddr;
-{
- CORE_ADDR sp = read_sp();
-
- if (PC_IN_CALL_DUMMY (memaddr, sp, sp+64))
- return caller_is_thumb;
- else
- return 0;
-}
-
-CORE_ADDR
-arm_addr_bits_remove (val)
- CORE_ADDR val;
-{
- if (arm_pc_is_thumb (val))
- return (val & (arm_apcs_32 ? 0xfffffffe : 0x03fffffe));
- else
- return (val & (arm_apcs_32 ? 0xfffffffc : 0x03fffffc));
-}
-
-CORE_ADDR
-arm_saved_pc_after_call (frame)
- struct frame_info *frame;
-{
- return ADDR_BITS_REMOVE (read_register (LR_REGNUM));
-}
-
-/* A typical Thumb prologue looks like this:
- push {r7, lr}
- add sp, sp, #-28
- add r7, sp, #12
- Sometimes the latter instruction may be replaced by:
- mov r7, sp
-*/
-
-static CORE_ADDR
-thumb_skip_prologue (pc)
- CORE_ADDR pc;
-{
- CORE_ADDR current_pc;
-
- for (current_pc = pc; current_pc < pc + 20; current_pc += 2)
- {
- unsigned short insn = read_memory_unsigned_integer (current_pc, 2);
-
- if ( (insn & 0xfe00) != 0xb400 /* push {..., r7, lr} */
- && (insn & 0xff00) != 0xb000 /* add sp, #simm */
- && (insn & 0xff00) != 0xaf00 /* add r7, sp, #imm */
- && insn != 0x466f /* mov r7, sp */
- && (insn & 0xffc0) != 0x4640) /* mov r0-r7, r8-r15 */
- break;
- }
-
- return current_pc;
-}
-
-/* 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
-arm_skip_prologue (pc)
- CORE_ADDR pc;
-{
- unsigned long inst;
- CORE_ADDR skip_pc;
- CORE_ADDR func_addr, func_end;
- struct symtab_and_line sal;
-
- /* See what the symbol table says. */
- if (find_pc_partial_function (pc, NULL, & func_addr, & func_end))
- {
- sal = find_pc_line (func_addr, 0);
- if (sal.line != 0 && sal.end < func_end)
- return sal.end;
- }
-
- /* Check if this is Thumb code. */
- if (arm_pc_is_thumb (pc))
- return thumb_skip_prologue (pc);
-
- /* Can't find the prologue end in the symbol table, try it the hard way
- by disassembling the instructions. */
- skip_pc = pc;
- inst = read_memory_integer (skip_pc, 4);
- if (inst != 0xe1a0c00d) /* mov ip, sp */
- return pc;
-
- skip_pc += 4;
- inst = read_memory_integer (skip_pc, 4);
- if ((inst & 0xfffffff0) == 0xe92d0000) /* stmfd sp!,{a1,a2,a3,a4} */
- {
- skip_pc += 4;
- inst = read_memory_integer (skip_pc, 4);
- }
-
- if ((inst & 0xfffff800) != 0xe92dd800) /* stmfd sp!,{...,fp,ip,lr,pc} */
- return pc;
-
- skip_pc += 4;
- inst = read_memory_integer (skip_pc, 4);
-
- /* Any insns after this point may float into the code, if it makes
- for better instruction scheduling, so we skip them only if
- we find them, but still consdier the function to be frame-ful */
-
- /* We may have either one sfmfd instruction here, or several stfe insns,
- depending on the version of floating point code we support. */
- if ((inst & 0xffbf0fff) == 0xec2d0200) /* sfmfd fn, <cnt>, [sp]! */
- {
- skip_pc += 4;
- inst = read_memory_integer (skip_pc, 4);
- }
- else
- {
- while ((inst & 0xffff8fff) == 0xed6d0103) /* stfe fn, [sp, #-12]! */
- {
- skip_pc += 4;
- inst = read_memory_integer (skip_pc, 4);
- }
- }
-
- if ((inst & 0xfffff000) == 0xe24cb000) /* sub fp, ip, #nn */
- skip_pc += 4;
-
- return skip_pc;
-}
-
-
-
-/* Function: thumb_scan_prologue (helper function for arm_scan_prologue)
- This function decodes a Thumb function prologue to determine:
- 1) the size of the stack frame
- 2) which registers are saved on it
- 3) the offsets of saved regs
- 4) the offset from the stack pointer to the frame pointer
- This information is stored in the "extra" fields of the frame_info.
-
- A typical Thumb function prologue might look like this:
- push {r7, lr}
- sub sp, #28,
- add r7, sp, #12
- Which would create this stack frame (offsets relative to FP)
- old SP -> 24 stack parameters
- 20 LR
- 16 R7
- R7 -> 0 local variables (16 bytes)
- SP -> -12 additional stack space (12 bytes)
- The frame size would thus be 36 bytes, and the frame offset would be
- 12 bytes. The frame register is R7. */
-
-static void
-thumb_scan_prologue (fi)
- struct frame_info * fi;
-{
- CORE_ADDR prologue_start;
- CORE_ADDR prologue_end;
- CORE_ADDR current_pc;
- int saved_reg[16]; /* which register has been copied to register n? */
- int i;
-
- if (find_pc_partial_function (fi->pc, NULL, & prologue_start, & prologue_end))
- {
- struct symtab_and_line sal = find_pc_line (prologue_start, 0);
-
- if (sal.line == 0) /* no line info, use current PC */
- prologue_end = fi->pc;
- else if (sal.end < prologue_end) /* next line begins after fn end */
- prologue_end = sal.end; /* (probably means no prologue) */
- }
- else
- prologue_end = prologue_start + 40; /* We're in the boondocks: allow for */
- /* 16 pushes, an add, and "mv fp,sp" */
-
- prologue_end = min (prologue_end, fi->pc);
-
- /* Initialize the saved register map. When register H is copied to
- register L, we will put H in saved_reg[L]. */
- for (i = 0; i < 16; i++)
- saved_reg[i] = i;
-
- /* Search the prologue looking for instructions that set up the
- frame pointer, adjust the stack pointer, and save registers. */
-
- fi->framesize = 0;
- for (current_pc = prologue_start; current_pc < prologue_end; current_pc += 2)
- {
- unsigned short insn;
- int regno;
- int offset;
-
- insn = read_memory_unsigned_integer (current_pc, 2);
-
- if ((insn & 0xfe00) == 0xb400) /* push { rlist } */
- {
- /* Bits 0-7 contain a mask for registers R0-R7. Bit 8 says
- whether to save LR (R14). */
- int mask = (insn & 0xff) | ((insn & 0x100) << 6);
-
- /* Calculate offsets of saved R0-R7 and LR. */
- for (regno = LR_REGNUM; regno >= 0; regno--)
- if (mask & (1 << regno))
- {
- fi->framesize += 4;
- fi->fsr.regs[saved_reg[regno]] = -(fi->framesize);
- saved_reg[regno] = regno; /* reset saved register map */
- }
- }
- else if ((insn & 0xff00) == 0xb000) /* add sp, #simm */
- {
- offset = (insn & 0x7f) << 2; /* get scaled offset */
- if (insn & 0x80) /* is it signed? */
- offset = -offset;
- fi->framesize -= offset;
- }
- else if ((insn & 0xff00) == 0xaf00) /* add r7, sp, #imm */
- {
- fi->framereg = THUMB_FP_REGNUM;
- fi->frameoffset = (insn & 0xff) << 2; /* get scaled offset */
- }
- else if (insn == 0x466f) /* mov r7, sp */
- {
- fi->framereg = THUMB_FP_REGNUM;
- fi->frameoffset = 0;
- saved_reg[THUMB_FP_REGNUM] = SP_REGNUM;
- }
- else if ((insn & 0xffc0) == 0x4640) /* mov r0-r7, r8-r15 */
- {
- int lo_reg = insn & 7; /* dest. register (r0-r7) */
- int hi_reg = ((insn >> 3) & 7) + 8; /* source register (r8-15) */
- saved_reg[lo_reg] = hi_reg; /* remember hi reg was saved */
- }
- else
- break; /* anything else isn't prologue */
- }
-}
-
-/* Function: check_prologue_cache
- Check if prologue for this frame's PC has already been scanned.
- If it has, copy the relevant information about that prologue and
- return non-zero. Otherwise do not copy anything and return zero.
-
- The information saved in the cache includes:
- * the frame register number;
- * the size of the stack frame;
- * the offsets of saved regs (relative to the old SP); and
- * the offset from the stack pointer to the frame pointer
-
- The cache contains only one entry, since this is adequate
- for the typical sequence of prologue scan requests we get.
- When performing a backtrace, GDB will usually ask to scan
- the same function twice in a row (once to get the frame chain,
- and once to fill in the extra frame information).
-*/
-
-static struct frame_info prologue_cache;
-
-static int
-check_prologue_cache (fi)
- struct frame_info * fi;
-{
- int i;
-
- if (fi->pc == prologue_cache.pc)
- {
- fi->framereg = prologue_cache.framereg;
- fi->framesize = prologue_cache.framesize;
- fi->frameoffset = prologue_cache.frameoffset;
- for (i = 0; i <= NUM_REGS; i++)
- fi->fsr.regs[i] = prologue_cache.fsr.regs[i];
- return 1;
- }
- else
- return 0;
-}
-
-
-/* Function: save_prologue_cache
- Copy the prologue information from fi to the prologue cache.
-*/
-
-static void
-save_prologue_cache (fi)
- struct frame_info * fi;
-{
- int i;
-
- prologue_cache.pc = fi->pc;
- prologue_cache.framereg = fi->framereg;
- prologue_cache.framesize = fi->framesize;
- prologue_cache.frameoffset = fi->frameoffset;
-
- for (i = 0; i <= NUM_REGS; i++)
- prologue_cache.fsr.regs[i] = fi->fsr.regs[i];
-}
-
-
-/* Function: arm_scan_prologue
- This function decodes an ARM function prologue to determine:
- 1) the size of the stack frame
- 2) which registers are saved on it
- 3) the offsets of saved regs
- 4) the offset from the stack pointer to the frame pointer
- This information is stored in the "extra" fields of the frame_info.
-
- A typical Arm function prologue might look like this:
- mov ip, sp
- stmfd sp!, {fp, ip, lr, pc}
- sub fp, ip, #4
- sub sp, sp, #16
- Which would create this stack frame (offsets relative to FP):
- IP -> 4 (caller's stack)
- FP -> 0 PC (points to address of stmfd instruction + 12 in callee)
- -4 LR (return address in caller)
- -8 IP (copy of caller's SP)
- -12 FP (caller's FP)
- SP -> -28 Local variables
- The frame size would thus be 32 bytes, and the frame offset would be
- 28 bytes. */
-
-static void
-arm_scan_prologue (fi)
- struct frame_info * fi;
-{
- int regno, sp_offset, fp_offset;
- CORE_ADDR prologue_start, prologue_end, current_pc;
-
- /* Check if this function is already in the cache of frame information. */
- if (check_prologue_cache (fi))
- return;
-
- /* Assume there is no frame until proven otherwise. */
- fi->framereg = SP_REGNUM;
- fi->framesize = 0;
- fi->frameoffset = 0;
-
- /* Check for Thumb prologue. */
- if (arm_pc_is_thumb (fi->pc))
- {
- thumb_scan_prologue (fi);
- save_prologue_cache (fi);
- return;
- }
-
- /* Find the function prologue. If we can't find the function in
- the symbol table, peek in the stack frame to find the PC. */
- if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end))
- {
- /* Assume the prologue is everything between the first instruction
- in the function and the first source line. */
- struct symtab_and_line sal = find_pc_line (prologue_start, 0);
-
- if (sal.line == 0) /* no line info, use current PC */
- prologue_end = fi->pc;
- else if (sal.end < prologue_end) /* next line begins after fn end */
- prologue_end = sal.end; /* (probably means no prologue) */
- }
- else
- {
- /* Get address of the stmfd in the prologue of the callee; the saved
- PC is the address of the stmfd + 12. */
- prologue_start = (read_memory_integer (fi->frame, 4) & 0x03fffffc) - 12;
- prologue_end = prologue_start + 40; /* FIXME: should be big enough */
- }
-
- /* Now search the prologue looking for instructions that set up the
- frame pointer, adjust the stack pointer, and save registers. */
-
- sp_offset = fp_offset = 0;
- for (current_pc = prologue_start; current_pc < prologue_end; current_pc += 4)
- {
- unsigned int insn = read_memory_unsigned_integer (current_pc, 4);
-
- if ((insn & 0xffff0000) == 0xe92d0000) /* stmfd sp!, {..., r7, lr} */
- {
- int mask = insn & 0xffff;
-
- /* Calculate offsets of saved registers. */
- for (regno = PC_REGNUM; regno >= 0; regno--)
- if (mask & (1 << regno))
- {
- sp_offset -= 4;
- fi->fsr.regs[regno] = sp_offset;
- }
- }
- else if ((insn & 0xfffff000) == 0xe24cb000) /* sub fp, ip #n */
- {
- unsigned imm = insn & 0xff; /* immediate value */
- unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */
- imm = (imm >> rot) | (imm << (32-rot));
- fp_offset = -imm;
- fi->framereg = FP_REGNUM;
- }
- else if ((insn & 0xfffff000) == 0xe24dd000) /* sub sp, sp #n */
- {
- unsigned imm = insn & 0xff; /* immediate value */
- unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */
- imm = (imm >> rot) | (imm << (32-rot));
- sp_offset -= imm;
- }
- else if ((insn & 0xffff7fff) == 0xed6d0103) /* stfe f?, [sp, -#c]! */
- {
- sp_offset -= 12;
- regno = F0_REGNUM + ((insn >> 12) & 0x07);
- fi->fsr.regs[regno] = sp_offset;
- }
- else if (insn == 0xe1a0c00d) /* mov ip, sp */
- continue;
- else
- break; /* not a recognized prologue instruction */
- }
-
- /* The frame size is just the negative of the offset (from the original SP)
- of the last thing thing we pushed on the stack. The frame offset is
- [new FP] - [new SP]. */
- fi->framesize = -sp_offset;
- fi->frameoffset = fp_offset - sp_offset;
-
- save_prologue_cache (fi);
-}
-
-
-/* Function: find_callers_reg
- Find REGNUM on the stack. Otherwise, it's in an active register. One thing
- we might want to do here is to check REGNUM against the clobber mask, and
- somehow flag it as invalid if it isn't saved on the stack somewhere. This
- would provide a graceful failure mode when trying to get the value of
- caller-saves registers for an inner frame. */
-
-static CORE_ADDR
-arm_find_callers_reg (fi, regnum)
- struct frame_info * fi;
- int regnum;
-{
- for (; fi; fi = fi->next)
-
-#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
- if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
- return generic_read_register_dummy (fi->pc, fi->frame, regnum);
- else
-#endif
- if (fi->fsr.regs[regnum] != 0)
- return read_memory_integer (fi->fsr.regs[regnum],
- REGISTER_RAW_SIZE(regnum));
- return read_register (regnum);
-}
-
-
-/* Function: 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.
- For ARM, we save the frame size when we initialize the frame_info.
-
- The original definition of this function was a macro in tm-arm.h:
- { 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 >= LOWEST_PC ? \
- read_memory_integer ((thisframe)->frame - 12, 4) :\
- 0)
-*/
-
-CORE_ADDR
-arm_frame_chain (fi)
- struct frame_info * fi;
-{
-#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
- CORE_ADDR fn_start, callers_pc, fp;
-
- /* is this a dummy frame? */
- if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
- return fi->frame; /* dummy frame same as caller's frame */
-
- /* is caller-of-this a dummy frame? */
- callers_pc = FRAME_SAVED_PC(fi); /* find out who called us: */
- fp = arm_find_callers_reg (fi, FP_REGNUM);
- if (PC_IN_CALL_DUMMY (callers_pc, fp, fp))
- return fp; /* dummy frame's frame may bear no relation to ours */
-
- if (find_pc_partial_function (fi->pc, 0, &fn_start, 0))
- if (fn_start == entry_point_address ())
- return 0; /* in _start fn, don't chain further */
-#endif
- CORE_ADDR caller_pc, fn_start;
- struct frame_info caller_fi;
- int framereg = fi->framereg;
-
- if (fi->pc < LOWEST_PC)
- return 0;
-
- /* If the caller is the startup code, we're at the end of the chain. */
- caller_pc = FRAME_SAVED_PC (fi);
- if (find_pc_partial_function (caller_pc, 0, &fn_start, 0))
- if (fn_start == entry_point_address ())
- return 0;
-
- /* If the caller is Thumb and the caller is ARM, or vice versa,
- the frame register of the caller is different from ours.
- So we must scan the prologue of the caller to determine its
- frame register number. */
- if (arm_pc_is_thumb (caller_pc) != arm_pc_is_thumb (fi->pc))
- {
- memset (& caller_fi, 0, sizeof (caller_fi));
- caller_fi.pc = caller_pc;
- arm_scan_prologue (& caller_fi);
- framereg = caller_fi.framereg;
- }
-
- /* If the caller used a frame register, return its value.
- Otherwise, return the caller's stack pointer. */
- if (framereg == FP_REGNUM || framereg == THUMB_FP_REGNUM)
- return arm_find_callers_reg (fi, framereg);
- else
- return fi->frame + fi->framesize;
-}
-
-/* Function: init_extra_frame_info
- This function actually figures out the frame address for a given pc and
- sp. This is tricky because we sometimes don't use an explicit
- frame pointer, and the previous stack pointer isn't necessarily recorded
- on the stack. The only reliable way to get this info is to
- examine the prologue. */
-
-void
-arm_init_extra_frame_info (fi)
- struct frame_info * fi;
-{
- int reg;
-
- if (fi->next)
- fi->pc = FRAME_SAVED_PC (fi->next);
-
- memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs);
-
-#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
- if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
- {
- /* We need to setup fi->frame here because run_stack_dummy gets it wrong
- by assuming it's always FP. */
- fi->frame = generic_read_register_dummy (fi->pc, fi->frame, SP_REGNUM);
- fi->framesize = 0;
- fi->frameoffset = 0;
- return;
- }
- else
-#endif
- {
- arm_scan_prologue (fi);
-
- if (!fi->next) /* this is the innermost frame? */
- fi->frame = read_register (fi->framereg);
- else /* not the innermost frame */
- /* If we have an FP, the callee saved it. */
- if (fi->framereg == FP_REGNUM || fi->framereg == THUMB_FP_REGNUM)
- if (fi->next->fsr.regs[fi->framereg] != 0)
- fi->frame = read_memory_integer (fi->next->fsr.regs[fi->framereg],
- 4);
-
- /* Calculate actual addresses of saved registers using offsets determined
- by arm_scan_prologue. */
- for (reg = 0; reg < NUM_REGS; reg++)
- if (fi->fsr.regs[reg] != 0)
- fi->fsr.regs[reg] += fi->frame + fi->framesize - fi->frameoffset;
- }
-}
-
-
-/* Function: frame_saved_pc
- Find the caller of this frame. We do this by seeing if LR_REGNUM is saved
- in the stack anywhere, otherwise we get it from the registers.
-
- The old definition of this function was a macro:
- #define FRAME_SAVED_PC(FRAME) \
- ADDR_BITS_REMOVE (read_memory_integer ((FRAME)->frame - 4, 4))
-*/
-
-CORE_ADDR
-arm_frame_saved_pc (fi)
- struct frame_info * fi;
-{
-#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */
- if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
- return generic_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
- else
-#endif
- {
- CORE_ADDR pc = arm_find_callers_reg (fi, LR_REGNUM);
- return IS_THUMB_ADDR (pc) ? UNMAKE_THUMB_ADDR (pc) : pc;
- }
-}
-
-
-/* Return the frame address. On ARM, it is R11; on Thumb it is R7.
- Examine the Program Status Register to decide which state we're in. */
-
-CORE_ADDR
-arm_target_read_fp ()
-{
- if (read_register (PS_REGNUM) & 0x20) /* Bit 5 is Thumb state bit */
- return read_register (THUMB_FP_REGNUM); /* R7 if Thumb */
- else
- return read_register (FP_REGNUM); /* R11 if ARM */
-}
-
-
-/* Calculate the frame offsets of the saved registers (ARM version). */
-void
-arm_frame_find_saved_regs (fi, regaddr)
- struct frame_info *fi;
- struct frame_saved_regs *regaddr;
-{
- memcpy (regaddr, &fi->fsr, sizeof (struct frame_saved_regs));
-}
-
-
-void
-arm_push_dummy_frame ()
-{
- CORE_ADDR old_sp = read_register (SP_REGNUM);
- CORE_ADDR sp = old_sp;
- CORE_ADDR fp, prologue_start;
- int regnum;
-
- /* Push the two dummy prologue instructions in reverse order,
- so that they'll be in the correct low-to-high order in memory. */
- /* sub fp, ip, #4 */
- sp = push_word (sp, 0xe24cb004);
- /* stmdb sp!, {r0-r10, fp, ip, lr, pc} */
- prologue_start = sp = push_word (sp, 0xe92ddfff);
-
- /* push a pointer to the dummy prologue + 12, because when
- stm instruction stores the PC, it stores the address of the stm
- instruction itself plus 12. */
- fp = sp = push_word (sp, prologue_start + 12);
- sp = push_word (sp, read_register (PC_REGNUM)); /* FIXME: was PS_REGNUM */
- sp = push_word (sp, old_sp);
- sp = push_word (sp, read_register (FP_REGNUM));
-
- for (regnum = 10; regnum >= 0; regnum --)
- sp = push_word (sp, read_register (regnum));
-
- write_register (FP_REGNUM, fp);
- write_register (THUMB_FP_REGNUM, fp);
- write_register (SP_REGNUM, sp);
-}
-
-/* Fix up the call dummy, based on whether the processor is currently
- in Thumb or ARM mode, and whether the target function is Thumb
- or ARM. There are three different situations requiring three
- different dummies:
-
- * ARM calling ARM: uses the call dummy in tm-arm.h, which has already
- been copied into the dummy parameter to this function.
- * ARM calling Thumb: uses the call dummy in tm-arm.h, but with the
- "mov pc,r4" instruction patched to be a "bx r4" instead.
- * Thumb calling anything: uses the Thumb dummy defined below, which
- works for calling both ARM and Thumb functions.
-
- All three call dummies expect to receive the target function address
- in R4, with the low bit set if it's a Thumb function.
-*/
-
-void
-arm_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p)
- char * dummy;
- CORE_ADDR pc;
- CORE_ADDR fun;
- int nargs;
- value_ptr * args;
- struct type * type;
- int gcc_p;
-{
- static short thumb_dummy[4] =
- {
- 0xf000, 0xf801, /* bl label */
- 0xdf18, /* swi 24 */
- 0x4720, /* label: bx r4 */
- };
- static unsigned long arm_bx_r4 = 0xe12fff14; /* bx r4 instruction */
-
- /* Set flag indicating whether the current PC is in a Thumb function. */
- caller_is_thumb = arm_pc_is_thumb (read_pc());
-
- /* If the target function is Thumb, set the low bit of the function address.
- And if the CPU is currently in ARM mode, patch the second instruction
- of call dummy to use a BX instruction to switch to Thumb mode. */
- target_is_thumb = arm_pc_is_thumb (fun);
- if (target_is_thumb)
- {
- fun |= 1;
- if (!caller_is_thumb)
- store_unsigned_integer (dummy + 4, sizeof (arm_bx_r4), arm_bx_r4);
- }
-
- /* If the CPU is currently in Thumb mode, use the Thumb call dummy
- instead of the ARM one that's already been copied. This will
- work for both Thumb and ARM target functions. */
- if (caller_is_thumb)
- {
- int i;
- char *p = dummy;
- int len = sizeof (thumb_dummy) / sizeof (thumb_dummy[0]);
-
- for (i = 0; i < len; i++)
- {
- store_unsigned_integer (p, sizeof (thumb_dummy[0]), thumb_dummy[i]);
- p += sizeof (thumb_dummy[0]);
- }
- }
-
- /* Put the target address in r4; the call dummy will copy this to the PC. */
- write_register (4, fun);
-}
-
-
-/* Return the offset in the call dummy of the instruction that needs
- to have a breakpoint placed on it. This is the offset of the 'swi 24'
- instruction, which is no longer actually used, but simply acts
- as a place-holder now.
-
- This implements the CALL_DUMMY_BREAK_OFFSET macro.
-*/
-
-int
-arm_call_dummy_breakpoint_offset ()
-{
- if (caller_is_thumb)
- return 4;
- else
- return 8;
-}
-
-
-CORE_ADDR
-arm_push_arguments(nargs, args, sp, struct_return, struct_addr)
- int nargs;
- value_ptr * args;
- CORE_ADDR sp;
- int struct_return;
- CORE_ADDR struct_addr;
-{
- int argreg;
- int float_argreg;
- int argnum;
- int stack_offset;
- struct stack_arg {
- char *val;
- int len;
- int offset;
- };
- struct stack_arg *stack_args =
- (struct stack_arg*)alloca (nargs * sizeof (struct stack_arg));
- int nstack_args = 0;
-
-
- /* Initialize the integer and float register pointers. */
- argreg = A1_REGNUM;
- float_argreg = F0_REGNUM;
-
- /* the struct_return pointer occupies the first parameter-passing reg */
- if (struct_return)
- write_register (argreg++, struct_addr);
-
- /* The offset onto the stack at which we will start copying parameters
- (after the registers are used up) begins at 16 in the old ABI.
- This leaves room for the "home" area for register parameters. */
- stack_offset = REGISTER_SIZE * 4;
-
- /* Process args from left to right. Store as many as allowed in
- registers, save the rest to be pushed on the stack */
- for(argnum = 0; argnum < nargs; argnum++)
- {
- char * val;
- value_ptr arg = args[argnum];
- struct type * arg_type = check_typedef (VALUE_TYPE (arg));
- struct type * target_type = TYPE_TARGET_TYPE (arg_type);
- int len = TYPE_LENGTH (arg_type);
- enum type_code typecode = TYPE_CODE (arg_type);
- CORE_ADDR regval;
- int newarg;
-
- val = (char *) VALUE_CONTENTS (arg);
-
- /* If the argument is a pointer to a function, and it's a Thumb
- function, set the low bit of the pointer. */
- if (typecode == TYPE_CODE_PTR
- && target_type != NULL
- && TYPE_CODE (target_type) == TYPE_CODE_FUNC)
- {
- regval = extract_address (val, len);
- if (arm_pc_is_thumb (regval))
- store_address (val, len, MAKE_THUMB_ADDR (regval));
- }
-
-#define MAPCS_FLOAT 0 /* --mapcs-float not implemented by the compiler yet */
-#if MAPCS_FLOAT
- /* Up to four floating point arguments can be passed in floating
- point registers on ARM (not on Thumb). */
- if (typecode == TYPE_CODE_FLT
- && float_argreg <= ARM_LAST_FP_ARG_REGNUM
- && !target_is_thumb)
- {
- /* This is a floating point value that fits entirely
- in a single register. */
- regval = extract_address (val, len);
- write_register (float_argreg++, regval);
- }
- else
-#endif
- {
- /* Copy the argument to general registers or the stack in
- register-sized pieces. Large arguments are split between
- registers and stack. */
- while (len > 0)
- {
- if (argreg <= ARM_LAST_ARG_REGNUM)
- {
- int partial_len = len < REGISTER_SIZE ? len : REGISTER_SIZE;
- regval = extract_address (val, partial_len);
-
- /* It's a simple argument being passed in a general
- register. */
- write_register (argreg, regval);
- argreg++;
- len -= partial_len;
- val += partial_len;
- }
- else
- {
- /* keep for later pushing */
- stack_args[nstack_args].val = val;
- stack_args[nstack_args++].len = len;
- break;
- }
- }
- }
- }
- /* now do the real stack pushing, process args right to left */
- while(nstack_args--)
- {
- sp -= stack_args[nstack_args].len;
- write_memory(sp, stack_args[nstack_args].val,
- stack_args[nstack_args].len);
- }
-
- /* Return adjusted stack pointer. */
- return sp;
-}
-
-void
-arm_pop_frame ()
-{
- struct frame_info *frame = get_current_frame();
- int regnum;
-
- for (regnum = 0; regnum < NUM_REGS; regnum++)
- if (frame->fsr.regs[regnum] != 0)
- write_register (regnum,
- read_memory_integer (frame->fsr.regs[regnum], 4));
-
- write_register (PC_REGNUM, FRAME_SAVED_PC (frame));
- write_register (SP_REGNUM, read_register (frame->framereg));
-
- flush_cached_frames ();
-}
-
-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);
-}
-
-static char *original_register_names[] =
-{ "a1", "a2", "a3", "a4", /* 0 1 2 3 */
- "v1", "v2", "v3", "v4", /* 4 5 6 7 */
- "v5", "v6", "sl", "fp", /* 8 9 10 11 */
- "ip", "sp", "lr", "pc", /* 12 13 14 15 */
- "f0", "f1", "f2", "f3", /* 16 17 18 19 */
- "f4", "f5", "f6", "f7", /* 20 21 22 23 */
- "fps","ps" } /* 24 25 */;
-
-/* These names are the ones which gcc emits, and
- I find them less confusing. Toggle between them
- using the `othernames' command. */
-static char *additional_register_names[] =
-{ "r0", "r1", "r2", "r3", /* 0 1 2 3 */
- "r4", "r5", "r6", "r7", /* 4 5 6 7 */
- "r8", "r9", "sl", "fp", /* 8 9 10 11 */
- "ip", "sp", "lr", "pc", /* 12 13 14 15 */
- "f0", "f1", "f2", "f3", /* 16 17 18 19 */
- "f4", "f5", "f6", "f7", /* 20 21 22 23 */
- "fps","ps" } /* 24 25 */;
-
-char **arm_register_names = original_register_names;
-
-
-static void
-arm_othernames ()
-{
- static int toggle;
- arm_register_names = (toggle
- ? additional_register_names
- : original_register_names);
- toggle = !toggle;
-}
-
-/* FIXME: Fill in with the 'right thing', see asm
- template in arm-convert.s */
-
-void
-convert_from_extended (ptr, dbl)
- void * ptr;
- double * dbl;
-{
- *dbl = *(double*)ptr;
-}
-
-void
-convert_to_extended (dbl, ptr)
- void * ptr;
- double * dbl;
-{
- *(double*)ptr = *dbl;
-}
-
-static int
-condition_true (cond, status_reg)
- unsigned long cond;
- unsigned long status_reg;
-{
- if (cond == INST_AL || cond == INST_NV)
- return 1;
-
- switch (cond)
- {
- case INST_EQ:
- return ((status_reg & FLAG_Z) != 0);
- case INST_NE:
- return ((status_reg & FLAG_Z) == 0);
- case INST_CS:
- return ((status_reg & FLAG_C) != 0);
- case INST_CC:
- return ((status_reg & FLAG_C) == 0);
- case INST_MI:
- return ((status_reg & FLAG_N) != 0);
- case INST_PL:
- return ((status_reg & FLAG_N) == 0);
- case INST_VS:
- return ((status_reg & FLAG_V) != 0);
- case INST_VC:
- return ((status_reg & FLAG_V) == 0);
- case INST_HI:
- return ((status_reg & (FLAG_C | FLAG_Z)) == FLAG_C);
- case INST_LS:
- return ((status_reg & (FLAG_C | FLAG_Z)) != FLAG_C);
- case INST_GE:
- return (((status_reg & FLAG_N) == 0) == ((status_reg & FLAG_V) == 0));
- case INST_LT:
- return (((status_reg & FLAG_N) == 0) != ((status_reg & FLAG_V) == 0));
- case INST_GT:
- return (((status_reg & FLAG_Z) == 0) &&
- (((status_reg & FLAG_N) == 0) == ((status_reg & FLAG_V) == 0)));
- case INST_LE:
- return (((status_reg & FLAG_Z) != 0) ||
- (((status_reg & FLAG_N) == 0) != ((status_reg & FLAG_V) == 0)));
- }
- return 1;
-}
-
-#define submask(x) ((1L << ((x) + 1)) - 1)
-#define bit(obj,st) (((obj) >> (st)) & 1)
-#define bits(obj,st,fn) (((obj) >> (st)) & submask ((fn) - (st)))
-#define sbits(obj,st,fn) \
- ((long) (bits(obj,st,fn) | ((long) bit(obj,fn) * ~ submask (fn - st))))
-#define BranchDest(addr,instr) \
- ((CORE_ADDR) (((long) (addr)) + 8 + (sbits (instr, 0, 23) << 2)))
-#define ARM_PC_32 1
-
-static unsigned long
-shifted_reg_val (inst, carry, pc_val, status_reg)
- unsigned long inst;
- int carry;
- unsigned long pc_val;
- unsigned long status_reg;
-{
- unsigned long res, shift;
- int rm = bits (inst, 0, 3);
- unsigned long shifttype = bits (inst, 5, 6);
-
- if (bit(inst, 4))
- {
- int rs = bits (inst, 8, 11);
- shift = (rs == 15 ? pc_val + 8 : read_register (rs)) & 0xFF;
- }
- else
- shift = bits (inst, 7, 11);
-
- res = (rm == 15
- ? ((pc_val | (ARM_PC_32 ? 0 : status_reg))
- + (bit (inst, 4) ? 12 : 8))
- : read_register (rm));
-
- switch (shifttype)
- {
- case 0: /* LSL */
- res = shift >= 32 ? 0 : res << shift;
- break;
-
- case 1: /* LSR */
- res = shift >= 32 ? 0 : res >> shift;
- break;
-
- case 2: /* ASR */
- if (shift >= 32) shift = 31;
- res = ((res & 0x80000000L)
- ? ~((~res) >> shift) : res >> shift);
- break;
-
- case 3: /* ROR/RRX */
- shift &= 31;
- if (shift == 0)
- res = (res >> 1) | (carry ? 0x80000000L : 0);
- else
- res = (res >> shift) | (res << (32-shift));
- break;
- }
-
- return res & 0xffffffff;
-}
-
-
-/* Return number of 1-bits in VAL. */
-
-static int
-bitcount (val)
- unsigned long val;
-{
- int nbits;
- for (nbits = 0; val != 0; nbits++)
- val &= val - 1; /* delete rightmost 1-bit in val */
- return nbits;
-}
-
-
-static CORE_ADDR
-thumb_get_next_pc (pc)
- CORE_ADDR pc;
-{
- unsigned long pc_val = ((unsigned long)pc) + 4; /* PC after prefetch */
- unsigned short inst1 = read_memory_integer (pc, 2);
- CORE_ADDR nextpc = pc + 2; /* default is next instruction */
- unsigned long offset;
-
- if ((inst1 & 0xff00) == 0xbd00) /* pop {rlist, pc} */
- {
- CORE_ADDR sp;
-
- /* Fetch the saved PC from the stack. It's stored above
- all of the other registers. */
- offset = bitcount (bits (inst1, 0, 7)) * REGISTER_SIZE;
- sp = read_register (SP_REGNUM);
- nextpc = (CORE_ADDR) read_memory_integer (sp + offset, 4);
- nextpc = ADDR_BITS_REMOVE (nextpc);
- if (nextpc == pc)
- error ("Infinite loop detected");
- }
- else if ((inst1 & 0xf000) == 0xd000) /* conditional branch */
- {
- unsigned long status = read_register (PS_REGNUM);
- unsigned long cond = bits (inst1, 8, 11);
- if (cond != 0x0f && condition_true (cond, status)) /* 0x0f = SWI */
- nextpc = pc_val + (sbits (inst1, 0, 7) << 1);
- }
- else if ((inst1 & 0xf800) == 0xe000) /* unconditional branch */
- {
- nextpc = pc_val + (sbits (inst1, 0, 10) << 1);
- }
- else if ((inst1 & 0xf800) == 0xf000) /* long branch with link */
- {
- unsigned short inst2 = read_memory_integer (pc + 2, 2);
- offset = (sbits (inst1, 0, 10) << 12) + (bits (inst2, 0, 10) << 1);
- nextpc = pc_val + offset;
- }
-
- return nextpc;
-}
-
-
-CORE_ADDR
-arm_get_next_pc (pc)
- CORE_ADDR pc;
-{
- unsigned long pc_val;
- unsigned long this_instr;
- unsigned long status;
- CORE_ADDR nextpc;
-
- if (arm_pc_is_thumb (pc))
- return thumb_get_next_pc (pc);
-
- pc_val = (unsigned long) pc;
- this_instr = read_memory_integer (pc, 4);
- status = read_register (PS_REGNUM);
- nextpc = (CORE_ADDR) (pc_val + 4); /* Default case */
-
- if (condition_true (bits (this_instr, 28, 31), status))
- {
- switch (bits (this_instr, 24, 27))
- {
- case 0x0: case 0x1: /* data processing */
- case 0x2: case 0x3:
- {
- unsigned long operand1, operand2, result = 0;
- unsigned long rn;
- int c;
-
- if (bits (this_instr, 12, 15) != 15)
- break;
-
- if (bits (this_instr, 22, 25) == 0
- && bits (this_instr, 4, 7) == 9) /* multiply */
- error ("Illegal update to pc in instruction");
-
- /* Multiply into PC */
- c = (status & FLAG_C) ? 1 : 0;
- rn = bits (this_instr, 16, 19);
- operand1 = (rn == 15) ? pc_val + 8 : read_register (rn);
-
- if (bit (this_instr, 25))
- {
- unsigned long immval = bits (this_instr, 0, 7);
- unsigned long rotate = 2 * bits (this_instr, 8, 11);
- operand2 = ((immval >> rotate) | (immval << (32-rotate)))
- & 0xffffffff;
- }
- else /* operand 2 is a shifted register */
- operand2 = shifted_reg_val (this_instr, c, pc_val, status);
-
- switch (bits (this_instr, 21, 24))
- {
- case 0x0: /*and*/
- result = operand1 & operand2;
- break;
-
- case 0x1: /*eor*/
- result = operand1 ^ operand2;
- break;
-
- case 0x2: /*sub*/
- result = operand1 - operand2;
- break;
-
- case 0x3: /*rsb*/
- result = operand2 - operand1;
- break;
-
- case 0x4: /*add*/
- result = operand1 + operand2;
- break;
-
- case 0x5: /*adc*/
- result = operand1 + operand2 + c;
- break;
-
- case 0x6: /*sbc*/
- result = operand1 - operand2 + c;
- break;
-
- case 0x7: /*rsc*/
- result = operand2 - operand1 + c;
- break;
-
- case 0x8: case 0x9: case 0xa: case 0xb: /* tst, teq, cmp, cmn */
- result = (unsigned long) nextpc;
- break;
-
- case 0xc: /*orr*/
- result = operand1 | operand2;
- break;
-
- case 0xd: /*mov*/
- /* Always step into a function. */
- result = operand2;
- break;
-
- case 0xe: /*bic*/
- result = operand1 & ~operand2;
- break;
-
- case 0xf: /*mvn*/
- result = ~operand2;
- break;
- }
- nextpc = (CORE_ADDR) ADDR_BITS_REMOVE (result);
-
- if (nextpc == pc)
- error ("Infinite loop detected");
- break;
- }
-
- case 0x4: case 0x5: /* data transfer */
- case 0x6: case 0x7:
- if (bit (this_instr, 20))
- {
- /* load */
- if (bits (this_instr, 12, 15) == 15)
- {
- /* rd == pc */
- unsigned long rn;
- unsigned long base;
-
- if (bit (this_instr, 22))
- error ("Illegal update to pc in instruction");
-
- /* byte write to PC */
- rn = bits (this_instr, 16, 19);
- base = (rn == 15) ? pc_val + 8 : read_register (rn);
- if (bit (this_instr, 24))
- {
- /* pre-indexed */
- int c = (status & FLAG_C) ? 1 : 0;
- unsigned long offset =
- (bit (this_instr, 25)
- ? shifted_reg_val (this_instr, c, pc_val)
- : bits (this_instr, 0, 11));
-
- if (bit (this_instr, 23))
- base += offset;
- else
- base -= offset;
- }
- nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) base,
- 4);
-
- nextpc = ADDR_BITS_REMOVE (nextpc);
-
- if (nextpc == pc)
- error ("Infinite loop detected");
- }
- }
- break;
-
- case 0x8: case 0x9: /* block transfer */
- if (bit (this_instr, 20))
- {
- /* LDM */
- if (bit (this_instr, 15))
- {
- /* loading pc */
- int offset = 0;
-
- if (bit (this_instr, 23))
- {
- /* up */
- unsigned long reglist = bits (this_instr, 0, 14);
- offset = bitcount (reglist) * 4;
- if (bit (this_instr, 24)) /* pre */
- offset += 4;
- }
- else if (bit (this_instr, 24))
- offset = -4;
-
- {
- unsigned long rn_val =
- read_register (bits (this_instr, 16, 19));
- nextpc =
- (CORE_ADDR) read_memory_integer ((CORE_ADDR) (rn_val
- + offset),
- 4);
- }
- nextpc = ADDR_BITS_REMOVE (nextpc);
- if (nextpc == pc)
- error ("Infinite loop detected");
- }
- }
- break;
-
- case 0xb: /* branch & link */
- case 0xa: /* branch */
- {
- nextpc = BranchDest (pc, this_instr);
-
- nextpc = ADDR_BITS_REMOVE (nextpc);
- if (nextpc == pc)
- error ("Infinite loop detected");
- break;
- }
-
- case 0xc: case 0xd:
- case 0xe: /* coproc ops */
- case 0xf: /* SWI */
- break;
-
- default:
- fprintf (stderr, "Bad bit-field extraction\n");
- return (pc);
- }
- }
-
- return nextpc;
-}
-
-#include "bfd-in2.h"
-#include "libcoff.h"
-
-static int
-gdb_print_insn_arm (memaddr, info)
- bfd_vma memaddr;
- disassemble_info * info;
-{
- if (arm_pc_is_thumb (memaddr))
- {
- static asymbol * asym;
- static combined_entry_type ce;
- static struct coff_symbol_struct csym;
- static struct _bfd fake_bfd;
- static bfd_target fake_target;
-
- if (csym.native == NULL)
- {
- /* Create a fake symbol vector containing a Thumb symbol. This is
- solely so that the code in print_insn_little_arm() and
- print_insn_big_arm() in opcodes/arm-dis.c will detect the presence
- of a Thumb symbol and switch to decoding Thumb instructions. */
-
- fake_target.flavour = bfd_target_coff_flavour;
- fake_bfd.xvec = & fake_target;
- ce.u.syment.n_sclass = C_THUMBEXTFUNC;
- csym.native = & ce;
- csym.symbol.the_bfd = & fake_bfd;
- csym.symbol.name = "fake";
- asym = (asymbol *) & csym;
- }
-
- memaddr = UNMAKE_THUMB_ADDR (memaddr);
- info->symbols = & asym;
- }
- else
- info->symbols = NULL;
-
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
- return print_insn_big_arm (memaddr, info);
- else
- return print_insn_little_arm (memaddr, info);
-}
-
-/* Sequence of bytes for breakpoint instruction. */
-#define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes */
-#define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE}
-#define THUMB_LE_BREAKPOINT {0xfe,0xdf}
-#define THUMB_BE_BREAKPOINT {0xdf,0xfe}
-
-/* The following has been superseded by BREAKPOINT_FOR_PC, but
- is defined merely to keep mem-break.c happy. */
-#define LITTLE_BREAKPOINT ARM_LE_BREAKPOINT
-#define BIG_BREAKPOINT ARM_BE_BREAKPOINT
-
-/* This function implements the BREAKPOINT_FROM_PC macro. It uses the program
- counter value to determine whether a 16- or 32-bit breakpoint should be
- used. It returns a pointer to a string of bytes that encode a breakpoint
- instruction, stores the length of the string to *lenptr, and adjusts pc
- (if necessary) to point to the actual memory location where the
- breakpoint should be inserted. */
-
-unsigned char *
-arm_breakpoint_from_pc (pcptr, lenptr)
- CORE_ADDR * pcptr;
- int * lenptr;
-{
- if (arm_pc_is_thumb (*pcptr) || arm_pc_is_thumb_dummy (*pcptr))
- {
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
- {
- static char thumb_breakpoint[] = THUMB_BE_BREAKPOINT;
- *pcptr = UNMAKE_THUMB_ADDR (*pcptr);
- *lenptr = sizeof (thumb_breakpoint);
- return thumb_breakpoint;
- }
- else
- {
- static char thumb_breakpoint[] = THUMB_LE_BREAKPOINT;
- *pcptr = UNMAKE_THUMB_ADDR (*pcptr);
- *lenptr = sizeof (thumb_breakpoint);
- return thumb_breakpoint;
- }
- }
- else
- {
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
- {
- static char arm_breakpoint[] = ARM_BE_BREAKPOINT;
- *lenptr = sizeof (arm_breakpoint);
- return arm_breakpoint;
- }
- else
- {
- static char arm_breakpoint[] = ARM_LE_BREAKPOINT;
- *lenptr = sizeof (arm_breakpoint);
- return arm_breakpoint;
- }
- }
-}
-/* Return non-zero if the PC is inside a call thunk (aka stub or trampoline).
- This implements the IN_SOLIB_CALL_TRAMPOLINE macro. */
-
-int
-arm_in_call_stub (pc, name)
- CORE_ADDR pc;
- char * name;
-{
- CORE_ADDR start_addr;
-
- /* Find the starting address of the function containing the PC. If the
- caller didn't give us a name, look it up at the same time. */
- if (find_pc_partial_function (pc, name ? NULL : &name, &start_addr, NULL) == 0)
- return 0;
-
- return strncmp (name, "_call_via_r", 11) == 0;
-}
-
-
-/* If PC is in a Thumb call or return stub, return the address of the target
- PC, which is in a register. The thunk functions are called _called_via_xx,
- where x is the register name. The possible names are r0-r9, sl, fp, ip,
- sp, and lr. */
-
-CORE_ADDR
-arm_skip_stub (pc)
- CORE_ADDR pc;
-{
- char * name;
- CORE_ADDR start_addr;
-
- /* Find the starting address and name of the function containing the PC. */
- if (find_pc_partial_function (pc, &name, &start_addr, NULL) == 0)
- return 0;
-
- /* Call thunks always start with "_call_via_". */
- if (strncmp (name, "_call_via_", 10) == 0)
- {
- /* Use the name suffix to determine which register contains
- the target PC. */
- static char *table[15] =
- { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
- "r8", "r9", "sl", "fp", "ip", "sp", "lr"
- };
- int regno;
-
- for (regno = 0; regno <= 14; regno++)
- if (strcmp (&name[10], table[regno]) == 0)
- return read_register (regno);
- }
- return 0; /* not a stub */
-}
-
-
-void
-_initialize_arm_tdep ()
-{
- tm_print_insn = gdb_print_insn_arm;
-
- add_com ("othernames", class_obscure, arm_othernames,
- "Switch to the other set of register names.");
-
- /* ??? Maybe this should be a boolean. */
- add_show_from_set (add_set_cmd ("apcs32", no_class,
- var_zinteger, (char *)&arm_apcs_32,
- "Set usage of ARM 32-bit mode.\n", &setlist),
- & showlist);
-
-}
-
-/* Test whether the coff symbol specific value corresponds to a Thumb function */
-int
-coff_sym_is_thumb(int val)
-{
- return (val == C_THUMBEXT ||
- val == C_THUMBSTAT ||
- val == C_THUMBEXTFUNC ||
- val == C_THUMBSTATFUNC ||
- val == C_THUMBLABEL);
-}
diff --git a/contrib/gdb/gdb/arm-xdep.c b/contrib/gdb/gdb/arm-xdep.c
deleted file mode 100644
index f0d806e..0000000
--- a/contrib/gdb/gdb/arm-xdep.c
+++ /dev/null
@@ -1,559 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "arm-opcode.h"
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <sys/ptrace.h>
-#include <machine/reg.h>
-
-#define N_TXTADDR(hdr) 0x8000
-#define N_DATADDR(hdr) (hdr.a_text + 0x8000)
-
-#include "gdbcore.h"
-
-#include <sys/user.h> /* After a.out.h */
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-#include <errno.h>
-
-void
-fetch_inferior_registers (regno)
- int regno; /* Original value discarded */
-{
- 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, (PTRACE_ARG3_TYPE) 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,
- (PTRACE_ARG3_TYPE) 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,
- (PTRACE_ARG3_TYPE) (offset + PC*4), 0);
- 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, (PTRACE_ARG3_TYPE) 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,
- (PTRACE_ARG3_TYPE) (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). */
-
-void
-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, (PTRACE_ARG3_TYPE) 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, (PTRACE_ARG3_TYPE) 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, (PTRACE_ARG3_TYPE) 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 corefile.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 program 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 (REGISTER_NAME (regno))
- + 30);
- strcpy (buffer, "Reading register ");
- strcat (buffer, REGISTER_NAME (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);
- }
-
- flush_cached_frames ();
- select_frame (get_current_frame (), 0);
- validate_files ();
- }
- else if (from_tty)
- printf ("No core file now.\n");
-}
-
-#if 0
-/* Work with core dump and executable files, for GDB.
- This code would be in corefile.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 executable file now.\n");
-
- /* Tell display code (if any) about the changed file name. */
- if (exec_file_display_hook)
- (*exec_file_display_hook) (filename);
-}
-#endif
-
-#if 0
-/* 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
- {
- memset (myaddr, '\0', i);
- returnval = EIO;
- }
-
- memaddr += i;
- myaddr += i;
- len -= i;
- }
- return returnval;
-}
-#endif
diff --git a/contrib/gdb/gdb/c-exp.tab.c b/contrib/gdb/gdb/c-exp.tab.c
deleted file mode 100644
index c9395fa..0000000
--- a/contrib/gdb/gdb/c-exp.tab.c
+++ /dev/null
@@ -1,2796 +0,0 @@
-
-/* A Bison parser, made from c-exp.y
- by GNU Bison version 1.25
- */
-
-#define YYBISON 1 /* Identify Bison output. */
-
-#define INT 258
-#define FLOAT 259
-#define STRING 260
-#define NAME 261
-#define TYPENAME 262
-#define NAME_OR_INT 263
-#define STRUCT 264
-#define CLASS 265
-#define UNION 266
-#define ENUM 267
-#define SIZEOF 268
-#define UNSIGNED 269
-#define COLONCOLON 270
-#define TEMPLATE 271
-#define ERROR 272
-#define SIGNED_KEYWORD 273
-#define LONG 274
-#define SHORT 275
-#define INT_KEYWORD 276
-#define CONST_KEYWORD 277
-#define VOLATILE_KEYWORD 278
-#define DOUBLE_KEYWORD 279
-#define VARIABLE 280
-#define ASSIGN_MODIFY 281
-#define THIS 282
-#define TRUEKEYWORD 283
-#define FALSEKEYWORD 284
-#define ABOVE_COMMA 285
-#define OROR 286
-#define ANDAND 287
-#define EQUAL 288
-#define NOTEQUAL 289
-#define LEQ 290
-#define GEQ 291
-#define LSH 292
-#define RSH 293
-#define UNARY 294
-#define INCREMENT 295
-#define DECREMENT 296
-#define ARROW 297
-#define BLOCKNAME 298
-#define FILENAME 299
-
-#line 38 "c-exp.y"
-
-
-#include "defs.h"
-#include "gdb_string.h"
-#include <ctype.h>
-#include "expression.h"
-#include "value.h"
-#include "parser-defs.h"
-#include "language.h"
-#include "c-lang.h"
-#include "bfd.h" /* Required by objfiles.h. */
-#include "symfile.h" /* Required by objfiles.h. */
-#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
-
-/* Flag indicating we're dealing with HP-compiled objects */
-extern int hp_som_som_object_present;
-
-/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
- as well as gratuitiously global symbol names, so we can have multiple
- yacc generated parsers in gdb. Note that these are only the variables
- produced by yacc. If other parser generators (bison, byacc, etc) produce
- additional global names that conflict at link time, then those parser
- generators need to be fixed instead of adding those names to this list. */
-
-#define yymaxdepth c_maxdepth
-#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 yy_yys c_yys
-#define yystate c_state
-#define yytmp c_tmp
-#define yyv c_v
-#define yy_yyv c_yyv
-#define yyval c_val
-#define yylloc c_lloc
-#define yyreds c_reds /* With YYDEBUG defined */
-#define yytoks c_toks /* With YYDEBUG defined */
-#define yylhs c_yylhs
-#define yylen c_yylen
-#define yydefred c_yydefred
-#define yydgoto c_yydgoto
-#define yysindex c_yysindex
-#define yyrindex c_yyrindex
-#define yygindex c_yygindex
-#define yytable c_yytable
-#define yycheck c_yycheck
-
-#ifndef YYDEBUG
-#define YYDEBUG 0 /* Default to no yydebug support */
-#endif
-
-int
-yyparse PARAMS ((void));
-
-static int
-yylex PARAMS ((void));
-
-void
-yyerror PARAMS ((char *));
-
-
-#line 120 "c-exp.y"
-typedef union
- {
- LONGEST lval;
- struct {
- LONGEST val;
- struct type *type;
- } typed_val_int;
- struct {
- DOUBLEST dval;
- struct type *type;
- } typed_val_float;
- 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;
-#line 145 "c-exp.y"
-
-/* YYSTYPE gets defined by %union */
-static int
-parse_number PARAMS ((char *, int, int, YYSTYPE *));
-#include <stdio.h>
-
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
-#endif
-#endif
-
-
-
-#define YYFINAL 214
-#define YYFLAG -32768
-#define YYNTBASE 69
-
-#define YYTRANSLATE(x) ((unsigned)(x) <= 299 ? yytranslate[x] : 91)
-
-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, 62, 2, 2, 2, 52, 38, 2, 59,
- 65, 50, 48, 30, 49, 57, 51, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 68, 2, 41,
- 32, 42, 33, 47, 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,
- 58, 2, 64, 37, 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, 66, 36, 67, 63, 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, 29, 31, 34, 35, 39, 40, 43,
- 44, 45, 46, 53, 54, 55, 56, 60, 61
-};
-
-#if YYDEBUG != 0
-static const short yyprhs[] = { 0,
- 0, 2, 4, 6, 8, 12, 15, 18, 21, 24,
- 27, 30, 33, 36, 39, 42, 46, 50, 55, 59,
- 63, 68, 73, 74, 80, 82, 83, 85, 89, 91,
- 95, 100, 105, 109, 113, 117, 121, 125, 129, 133,
- 137, 141, 145, 149, 153, 157, 161, 165, 169, 173,
- 177, 181, 185, 191, 195, 199, 201, 203, 205, 207,
- 209, 214, 216, 218, 220, 222, 224, 226, 230, 234,
- 238, 243, 245, 248, 250, 252, 255, 258, 261, 265,
- 269, 271, 274, 276, 279, 281, 285, 288, 290, 293,
- 295, 298, 302, 305, 309, 311, 315, 317, 319, 321,
- 323, 326, 330, 333, 337, 341, 346, 349, 353, 355,
- 358, 361, 364, 367, 370, 373, 375, 378, 380, 386,
- 389, 392, 394, 396, 398, 400, 402, 406, 408, 410,
- 412, 414, 416
-};
-
-static const short yyrhs[] = { 71,
- 0, 70, 0, 85, 0, 72, 0, 71, 30, 72,
- 0, 50, 72, 0, 38, 72, 0, 49, 72, 0,
- 62, 72, 0, 63, 72, 0, 54, 72, 0, 55,
- 72, 0, 72, 54, 0, 72, 55, 0, 13, 72,
- 0, 72, 56, 89, 0, 72, 56, 79, 0, 72,
- 56, 50, 72, 0, 72, 57, 89, 0, 72, 57,
- 79, 0, 72, 57, 50, 72, 0, 72, 58, 71,
- 64, 0, 0, 72, 59, 73, 75, 65, 0, 66,
- 0, 0, 72, 0, 75, 30, 72, 0, 67, 0,
- 74, 75, 76, 0, 74, 85, 76, 72, 0, 59,
- 85, 65, 72, 0, 59, 71, 65, 0, 72, 47,
- 72, 0, 72, 50, 72, 0, 72, 51, 72, 0,
- 72, 52, 72, 0, 72, 48, 72, 0, 72, 49,
- 72, 0, 72, 45, 72, 0, 72, 46, 72, 0,
- 72, 39, 72, 0, 72, 40, 72, 0, 72, 43,
- 72, 0, 72, 44, 72, 0, 72, 41, 72, 0,
- 72, 42, 72, 0, 72, 38, 72, 0, 72, 37,
- 72, 0, 72, 36, 72, 0, 72, 35, 72, 0,
- 72, 34, 72, 0, 72, 33, 72, 68, 72, 0,
- 72, 32, 72, 0, 72, 26, 72, 0, 3, 0,
- 8, 0, 4, 0, 78, 0, 25, 0, 13, 59,
- 85, 65, 0, 5, 0, 27, 0, 28, 0, 29,
- 0, 60, 0, 61, 0, 77, 15, 89, 0, 77,
- 15, 89, 0, 86, 15, 89, 0, 86, 15, 63,
- 89, 0, 79, 0, 15, 89, 0, 90, 0, 86,
- 0, 86, 22, 0, 86, 23, 0, 86, 81, 0,
- 86, 22, 81, 0, 86, 23, 81, 0, 50, 0,
- 50, 81, 0, 38, 0, 38, 81, 0, 82, 0,
- 59, 81, 65, 0, 82, 83, 0, 83, 0, 82,
- 84, 0, 84, 0, 58, 64, 0, 58, 3, 64,
- 0, 59, 65, 0, 59, 88, 65, 0, 80, 0,
- 86, 15, 50, 0, 7, 0, 21, 0, 19, 0,
- 20, 0, 19, 21, 0, 14, 19, 21, 0, 19,
- 19, 0, 19, 19, 21, 0, 14, 19, 19, 0,
- 14, 19, 19, 21, 0, 20, 21, 0, 14, 20,
- 21, 0, 24, 0, 19, 24, 0, 9, 89, 0,
- 10, 89, 0, 11, 89, 0, 12, 89, 0, 14,
- 87, 0, 14, 0, 18, 87, 0, 18, 0, 16,
- 89, 41, 85, 42, 0, 22, 86, 0, 23, 86,
- 0, 7, 0, 21, 0, 19, 0, 20, 0, 85,
- 0, 88, 30, 85, 0, 6, 0, 60, 0, 7,
- 0, 8, 0, 6, 0, 60, 0
-};
-
-#endif
-
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
- 230, 231, 234, 241, 242, 247, 250, 253, 257, 261,
- 265, 269, 273, 277, 281, 285, 291, 299, 303, 309,
- 317, 321, 325, 329, 335, 339, 342, 346, 350, 353,
- 360, 366, 372, 378, 382, 386, 390, 394, 398, 402,
- 406, 410, 414, 418, 422, 426, 430, 434, 438, 442,
- 446, 450, 454, 458, 462, 468, 475, 486, 493, 496,
- 500, 508, 533, 538, 545, 554, 562, 568, 579, 595,
- 608, 632, 633, 667, 725, 731, 732, 733, 735, 737,
- 741, 743, 745, 747, 749, 752, 754, 759, 766, 768,
- 772, 774, 778, 780, 792, 793, 798, 800, 802, 804,
- 806, 808, 810, 812, 814, 816, 818, 820, 822, 824,
- 826, 829, 832, 835, 838, 840, 842, 844, 849, 856,
- 857, 860, 861, 867, 873, 882, 887, 894, 895, 896,
- 897, 900, 901
-};
-#endif
-
-
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
-
-static const char * const yytname[] = { "$","error","$undefined.","INT","FLOAT",
-"STRING","NAME","TYPENAME","NAME_OR_INT","STRUCT","CLASS","UNION","ENUM","SIZEOF",
-"UNSIGNED","COLONCOLON","TEMPLATE","ERROR","SIGNED_KEYWORD","LONG","SHORT","INT_KEYWORD",
-"CONST_KEYWORD","VOLATILE_KEYWORD","DOUBLE_KEYWORD","VARIABLE","ASSIGN_MODIFY",
-"THIS","TRUEKEYWORD","FALSEKEYWORD","','","ABOVE_COMMA","'='","'?'","OROR","ANDAND",
-"'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'","'>'","LEQ","GEQ","LSH","RSH","'@'",
-"'+'","'-'","'*'","'/'","'%'","UNARY","INCREMENT","DECREMENT","ARROW","'.'",
-"'['","'('","BLOCKNAME","FILENAME","'!'","'~'","']'","')'","'{'","'}'","':'",
-"start","type_exp","exp1","exp","@1","lcurly","arglist","rcurly","block","variable",
-"qualified_name","ptype","abs_decl","direct_abs_decl","array_mod","func_mod",
-"type","typebase","typename","nonempty_typelist","name","name_not_typename", NULL
-};
-#endif
-
-static const short yyr1[] = { 0,
- 69, 69, 70, 71, 71, 72, 72, 72, 72, 72,
- 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
- 72, 72, 73, 72, 74, 75, 75, 75, 76, 72,
- 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
- 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
- 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
- 72, 72, 72, 72, 72, 77, 77, 77, 78, 79,
- 79, 78, 78, 78, 80, 80, 80, 80, 80, 80,
- 81, 81, 81, 81, 81, 82, 82, 82, 82, 82,
- 83, 83, 84, 84, 85, 85, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
- 86, 87, 87, 87, 87, 88, 88, 89, 89, 89,
- 89, 90, 90
-};
-
-static const short yyr2[] = { 0,
- 1, 1, 1, 1, 3, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 3, 3, 4, 3, 3,
- 4, 4, 0, 5, 1, 0, 1, 3, 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,
- 4, 1, 1, 1, 1, 1, 1, 3, 3, 3,
- 4, 1, 2, 1, 1, 2, 2, 2, 3, 3,
- 1, 2, 1, 2, 1, 3, 2, 1, 2, 1,
- 2, 3, 2, 3, 1, 3, 1, 1, 1, 1,
- 2, 3, 2, 3, 3, 4, 2, 3, 1, 2,
- 2, 2, 2, 2, 2, 1, 2, 1, 5, 2,
- 2, 1, 1, 1, 1, 1, 3, 1, 1, 1,
- 1, 1, 1
-};
-
-static const short yydefact[] = { 0,
- 56, 58, 62, 132, 97, 57, 0, 0, 0, 0,
- 0, 116, 0, 0, 118, 99, 100, 98, 0, 0,
- 109, 60, 63, 64, 65, 0, 0, 0, 0, 0,
- 0, 133, 67, 0, 0, 25, 2, 1, 4, 26,
- 0, 59, 72, 95, 3, 75, 74, 128, 130, 131,
- 129, 111, 112, 113, 114, 0, 15, 0, 122, 124,
- 125, 123, 115, 73, 0, 124, 125, 117, 103, 101,
- 110, 107, 120, 121, 7, 8, 6, 11, 12, 0,
- 0, 9, 10, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 13, 14, 0, 0,
- 0, 23, 27, 0, 0, 0, 0, 76, 77, 83,
- 81, 0, 0, 78, 85, 88, 90, 0, 0, 105,
- 102, 108, 0, 104, 33, 0, 5, 55, 54, 0,
- 52, 51, 50, 49, 48, 42, 43, 46, 47, 44,
- 45, 40, 41, 34, 38, 39, 35, 36, 37, 130,
- 0, 17, 16, 0, 20, 19, 0, 26, 0, 29,
- 30, 0, 69, 96, 0, 70, 79, 80, 84, 82,
- 0, 91, 93, 0, 126, 75, 0, 0, 87, 89,
- 61, 106, 0, 32, 0, 18, 21, 22, 0, 28,
- 31, 71, 92, 86, 0, 0, 94, 119, 53, 24,
- 127, 0, 0, 0
-};
-
-static const short yydefgoto[] = { 212,
- 37, 80, 39, 168, 40, 114, 171, 41, 42, 43,
- 44, 124, 125, 126, 127, 185, 58, 63, 187, 176,
- 47
-};
-
-static const short yypact[] = { 205,
--32768,-32768,-32768,-32768,-32768,-32768, 46, 46, 46, 46,
- 269, 57, 46, 46, 100, 134, -14,-32768, 228, 228,
--32768,-32768,-32768,-32768,-32768, 205, 205, 205, 205, 205,
- 205, 21,-32768, 205, 205,-32768,-32768, -16, 504, 205,
- 22,-32768,-32768,-32768,-32768, 107,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,-32768,-32768, 205, 14, 23,-32768, 7,
- 24,-32768,-32768,-32768, 10,-32768,-32768,-32768, 34,-32768,
--32768,-32768,-32768,-32768, 14, 14, 14, 14, 14, -26,
- -21, 14, 14, 205, 205, 205, 205, 205, 205, 205,
- 205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
- 205, 205, 205, 205, 205, 205,-32768,-32768, 419, 438,
- 205,-32768, 504, -25, -2, 46, 53, 8, 8, 8,
- 8, -1, 359,-32768, -41,-32768,-32768, 9, 42, 54,
--32768,-32768, 228,-32768,-32768, 205, 504, 504, 504, 467,
- 556, 580, 603, 625, 646, 665, 665, 254, 254, 254,
- 254, 124, 124, 356, 416, 416, 14, 14, 14, 89,
- 205,-32768,-32768, 205,-32768,-32768, -17, 205, 205,-32768,
--32768, 205, 93,-32768, 46,-32768,-32768,-32768,-32768,-32768,
- 45,-32768,-32768, 50,-32768, 146, -22, 128,-32768,-32768,
- 333,-32768, 68, 14, 205, 14, 14,-32768, -3, 504,
- 14,-32768,-32768,-32768, 67, 228,-32768,-32768, 531,-32768,
--32768, 125, 126,-32768
-};
-
-static const short yypgoto[] = {-32768,
--32768, 3, -5,-32768,-32768, -44, 12,-32768,-32768, -76,
--32768, 79,-32768, 11, 16, 1, 0, 113,-32768, 2,
--32768
-};
-
-
-#define YYLAST 724
-
-
-static const short yytable[] = { 46,
- 45, 181, 38, 84, 169, 57, 72, 206, 52, 53,
- 54, 55, 84, 84, 64, 65, 122, 188, 73, 74,
- 75, 76, 77, 78, 79, 130, 169, 131, 82, 83,
- 46, 81, 162, 165, 113, -66, 116, 129, 135, 46,
- 115, 170, 207, 136, 132, 120, 198, 48, 49, 50,
- 133, 48, 49, 50, 134, 46, 128, 121, 48, 49,
- 50, 210, 182, 59, 170, 122, 123, 107, 108, 109,
- 110, 111, 112, 191, 192, 60, 61, 62, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
- 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
- 159, 51, 174, -97, 175, 51, 59, -68, 203, 208,
- 163, 166, 51, 167, 204, 175, 174, 173, 66, 67,
- 62, 117, 186, 199, 213, 214, 172, 68, 118, 119,
- 194, 0, 186, 193, 5, 189, 7, 8, 9, 10,
- 190, 12, 0, 14, 120, 15, 16, 17, 18, 19,
- 20, 21, 69, 0, 70, 196, 121, 71, 197, 0,
- 205, 0, 113, 200, 122, 123, 201, 118, 119, 0,
- 101, 102, 103, 104, 105, 106, 202, 107, 108, 109,
- 110, 111, 112, 120, 0, 194, 0, 186, 0, 209,
- 0, 0, 183, 0, 0, 121, 177, 178, 179, 180,
- 0, 184, 0, 122, 123, 186, 211, 1, 2, 3,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 0, 15, 16, 17, 18, 19, 20, 21, 22,
- 0, 23, 24, 25, 5, 0, 7, 8, 9, 10,
- 0, 12, 26, 14, 0, 15, 16, 17, 18, 19,
- 20, 21, 0, 27, 28, 0, 0, 0, 29, 30,
- 0, 0, 0, 31, 32, 33, 34, 35, 0, 0,
- 36, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 0, 15, 16, 17, 18,
- 19, 20, 21, 22, 0, 23, 24, 25, 99, 100,
- 101, 102, 103, 104, 105, 106, 26, 107, 108, 109,
- 110, 111, 112, 0, 0, 0, 0, 27, 28, 0,
- 0, 0, 29, 30, 0, 0, 0, 56, 32, 33,
- 34, 35, 0, 0, 36, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11, 12, 13, 14, 0,
- 15, 16, 17, 18, 19, 20, 21, 22, 0, 23,
- 24, 25, 0, 0, 0, 5, 0, 7, 8, 9,
- 10, 0, 12, 0, 14, 0, 15, 16, 17, 18,
- 19, 20, 21, 0, 0, 0, 29, 30, 0, 0,
- 0, 31, 32, 33, 34, 35, 120, 0, 36, 0,
- 0, 0, 0, 102, 103, 104, 105, 106, 121, 107,
- 108, 109, 110, 111, 112, 0, 122, 123, 0, 0,
- 0, 0, 0, 183, 48, 160, 50, 7, 8, 9,
- 10, 0, 12, 0, 14, 0, 15, 16, 17, 18,
- 19, 20, 21, 48, 160, 50, 7, 8, 9, 10,
- 0, 12, 0, 14, 0, 15, 16, 17, 18, 19,
- 20, 21, 0, 0, 0, 104, 105, 106, 161, 107,
- 108, 109, 110, 111, 112, 0, 0, 0, 51, 0,
- 0, 0, 0, 0, 0, 0, 0, 164, 0, 0,
- 0, 0, 85, 0, 0, 0, 0, 51, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
- 98, 99, 100, 101, 102, 103, 104, 105, 106, 0,
- 107, 108, 109, 110, 111, 112, 0, 0, 0, 85,
- 0, 0, 0, 0, 195, 86, 87, 88, 89, 90,
- 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
- 101, 102, 103, 104, 105, 106, 0, 107, 108, 109,
- 110, 111, 112, 87, 88, 89, 90, 91, 92, 93,
- 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
- 104, 105, 106, 0, 107, 108, 109, 110, 111, 112,
- 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
- 99, 100, 101, 102, 103, 104, 105, 106, 0, 107,
- 108, 109, 110, 111, 112, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
- 105, 106, 0, 107, 108, 109, 110, 111, 112, 91,
- 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
- 102, 103, 104, 105, 106, 0, 107, 108, 109, 110,
- 111, 112, 92, 93, 94, 95, 96, 97, 98, 99,
- 100, 101, 102, 103, 104, 105, 106, 0, 107, 108,
- 109, 110, 111, 112, 93, 94, 95, 96, 97, 98,
- 99, 100, 101, 102, 103, 104, 105, 106, 0, 107,
- 108, 109, 110, 111, 112, 95, 96, 97, 98, 99,
- 100, 101, 102, 103, 104, 105, 106, 0, 107, 108,
- 109, 110, 111, 112
-};
-
-static const short yycheck[] = { 0,
- 0, 3, 0, 30, 30, 11, 21, 30, 7, 8,
- 9, 10, 30, 30, 13, 14, 58, 59, 19, 20,
- 26, 27, 28, 29, 30, 19, 30, 21, 34, 35,
- 31, 31, 109, 110, 40, 15, 15, 15, 65, 40,
- 40, 67, 65, 65, 21, 38, 64, 6, 7, 8,
- 41, 6, 7, 8, 21, 56, 56, 50, 6, 7,
- 8, 65, 64, 7, 67, 58, 59, 54, 55, 56,
- 57, 58, 59, 65, 21, 19, 20, 21, 84, 85,
- 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
- 106, 60, 50, 15, 63, 60, 7, 15, 64, 42,
- 109, 110, 60, 111, 65, 63, 50, 116, 19, 20,
- 21, 15, 123, 168, 0, 0, 115, 15, 22, 23,
- 136, -1, 133, 133, 7, 125, 9, 10, 11, 12,
- 125, 14, -1, 16, 38, 18, 19, 20, 21, 22,
- 23, 24, 19, -1, 21, 161, 50, 24, 164, -1,
- 15, -1, 168, 169, 58, 59, 172, 22, 23, -1,
- 47, 48, 49, 50, 51, 52, 175, 54, 55, 56,
- 57, 58, 59, 38, -1, 191, -1, 188, -1, 195,
- -1, -1, 65, -1, -1, 50, 118, 119, 120, 121,
- -1, 123, -1, 58, 59, 206, 206, 3, 4, 5,
- 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, -1, 18, 19, 20, 21, 22, 23, 24, 25,
- -1, 27, 28, 29, 7, -1, 9, 10, 11, 12,
- -1, 14, 38, 16, -1, 18, 19, 20, 21, 22,
- 23, 24, -1, 49, 50, -1, -1, -1, 54, 55,
- -1, -1, -1, 59, 60, 61, 62, 63, -1, -1,
- 66, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, -1, 18, 19, 20, 21,
- 22, 23, 24, 25, -1, 27, 28, 29, 45, 46,
- 47, 48, 49, 50, 51, 52, 38, 54, 55, 56,
- 57, 58, 59, -1, -1, -1, -1, 49, 50, -1,
- -1, -1, 54, 55, -1, -1, -1, 59, 60, 61,
- 62, 63, -1, -1, 66, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15, 16, -1,
- 18, 19, 20, 21, 22, 23, 24, 25, -1, 27,
- 28, 29, -1, -1, -1, 7, -1, 9, 10, 11,
- 12, -1, 14, -1, 16, -1, 18, 19, 20, 21,
- 22, 23, 24, -1, -1, -1, 54, 55, -1, -1,
- -1, 59, 60, 61, 62, 63, 38, -1, 66, -1,
- -1, -1, -1, 48, 49, 50, 51, 52, 50, 54,
- 55, 56, 57, 58, 59, -1, 58, 59, -1, -1,
- -1, -1, -1, 65, 6, 7, 8, 9, 10, 11,
- 12, -1, 14, -1, 16, -1, 18, 19, 20, 21,
- 22, 23, 24, 6, 7, 8, 9, 10, 11, 12,
- -1, 14, -1, 16, -1, 18, 19, 20, 21, 22,
- 23, 24, -1, -1, -1, 50, 51, 52, 50, 54,
- 55, 56, 57, 58, 59, -1, -1, -1, 60, -1,
- -1, -1, -1, -1, -1, -1, -1, 50, -1, -1,
- -1, -1, 26, -1, -1, -1, -1, 60, 32, 33,
- 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, 50, 51, 52, -1,
- 54, 55, 56, 57, 58, 59, -1, -1, -1, 26,
- -1, -1, -1, -1, 68, 32, 33, 34, 35, 36,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 49, 50, 51, 52, -1, 54, 55, 56,
- 57, 58, 59, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, -1, 54, 55, 56, 57, 58, 59,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, -1, 54,
- 55, 56, 57, 58, 59, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, -1, 54, 55, 56, 57, 58, 59, 37,
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, -1, 54, 55, 56, 57,
- 58, 59, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, -1, 54, 55,
- 56, 57, 58, 59, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, -1, 54,
- 55, 56, 57, 58, 59, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 50, 51, 52, -1, 54, 55,
- 56, 57, 58, 59
-};
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/stone/jimb/main-98r2/share/bison.simple"
-
-/* Skeleton output parser for bison,
- Copyright (C) 1984, 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, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-#ifndef alloca
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
-#include <alloca.h>
-#else /* not sparc */
-#if defined (MSDOS) && !defined (__TURBOC__)
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
- #pragma alloca
-#else /* not MSDOS, __TURBOC__, or _AIX */
-#ifdef __hpux
-#ifdef __cplusplus
-extern "C" {
-void *alloca (unsigned int);
-};
-#else /* not __cplusplus */
-void *alloca ();
-#endif /* not __cplusplus */
-#endif /* __hpux */
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#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
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval, &yylloc)
-#endif
-#else /* not YYLSP_NEEDED */
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval)
-#endif
-#endif /* not YYLSP_NEEDED */
-#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
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-int yyparse (void);
-#endif
-
-#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
-#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
-#else /* not GNU C or C++ */
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (to, from, count)
- char *to;
- char *from;
- 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_memcpy (char *to, char *from, int count)
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#endif
-#endif
-
-#line 196 "/stone/jimb/main-98r2/share/bison.simple"
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
-
-#ifdef YYPARSE_PARAM
-#ifdef __cplusplus
-#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL
-#else /* not __cplusplus */
-#define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-#endif /* not __cplusplus */
-#else /* not YYPARSE_PARAM */
-#define YYPARSE_PARAM_ARG
-#define YYPARSE_PARAM_DECL
-#endif /* not YYPARSE_PARAM */
-
-int
-yyparse(YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
-{
- 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 = 0; /* 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 xreallocate them elsewhere */
-
-#ifdef YYLSP_NEEDED
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
-
-#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
-#else
-#define YYPOPSTACK (yyvsp--, yyssp--)
-#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.
- The wasted elements are never initialized. */
-
- 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 xreallocate 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. */
-#ifdef YYLSP_NEEDED
- /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro. */
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yyls1, size * sizeof (*yylsp),
- &yystacksize);
-#else
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yystacksize);
-#endif
-
- 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_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
- yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1, 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
-
- goto yybackup;
- 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", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
-#ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
-#endif
- fprintf (stderr, ")\n");
- }
-#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];
- if (yylen > 0)
- 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 symbols 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 235 "c-exp.y"
-{ write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type(yyvsp[0].tval);
- write_exp_elt_opcode(OP_TYPE);;
- break;}
-case 5:
-#line 243 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_COMMA); ;
- break;}
-case 6:
-#line 248 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_IND); ;
- break;}
-case 7:
-#line 251 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_ADDR); ;
- break;}
-case 8:
-#line 254 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_NEG); ;
- break;}
-case 9:
-#line 258 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); ;
- break;}
-case 10:
-#line 262 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_COMPLEMENT); ;
- break;}
-case 11:
-#line 266 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_PREINCREMENT); ;
- break;}
-case 12:
-#line 270 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_PREDECREMENT); ;
- break;}
-case 13:
-#line 274 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_POSTINCREMENT); ;
- break;}
-case 14:
-#line 278 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_POSTDECREMENT); ;
- break;}
-case 15:
-#line 282 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_SIZEOF); ;
- break;}
-case 16:
-#line 286 "c-exp.y"
-{ write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string (yyvsp[0].sval);
- write_exp_elt_opcode (STRUCTOP_PTR); ;
- break;}
-case 17:
-#line 292 "c-exp.y"
-{ /* exp->type::name becomes exp->*(&type::name) */
- /* Note: this doesn't work if name is a
- static member! FIXME */
- write_exp_elt_opcode (UNOP_ADDR);
- write_exp_elt_opcode (STRUCTOP_MPTR); ;
- break;}
-case 18:
-#line 300 "c-exp.y"
-{ write_exp_elt_opcode (STRUCTOP_MPTR); ;
- break;}
-case 19:
-#line 304 "c-exp.y"
-{ write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string (yyvsp[0].sval);
- write_exp_elt_opcode (STRUCTOP_STRUCT); ;
- break;}
-case 20:
-#line 310 "c-exp.y"
-{ /* exp.type::name becomes exp.*(&type::name) */
- /* Note: this doesn't work if name is a
- static member! FIXME */
- write_exp_elt_opcode (UNOP_ADDR);
- write_exp_elt_opcode (STRUCTOP_MEMBER); ;
- break;}
-case 21:
-#line 318 "c-exp.y"
-{ write_exp_elt_opcode (STRUCTOP_MEMBER); ;
- break;}
-case 22:
-#line 322 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_SUBSCRIPT); ;
- break;}
-case 23:
-#line 328 "c-exp.y"
-{ start_arglist (); ;
- break;}
-case 24:
-#line 330 "c-exp.y"
-{ write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL); ;
- break;}
-case 25:
-#line 336 "c-exp.y"
-{ start_arglist (); ;
- break;}
-case 27:
-#line 343 "c-exp.y"
-{ arglist_len = 1; ;
- break;}
-case 28:
-#line 347 "c-exp.y"
-{ arglist_len++; ;
- break;}
-case 29:
-#line 351 "c-exp.y"
-{ yyval.lval = end_arglist () - 1; ;
- break;}
-case 30:
-#line 354 "c-exp.y"
-{ write_exp_elt_opcode (OP_ARRAY);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
- write_exp_elt_opcode (OP_ARRAY); ;
- break;}
-case 31:
-#line 361 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_MEMVAL);
- write_exp_elt_type (yyvsp[-2].tval);
- write_exp_elt_opcode (UNOP_MEMVAL); ;
- break;}
-case 32:
-#line 367 "c-exp.y"
-{ write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (yyvsp[-2].tval);
- write_exp_elt_opcode (UNOP_CAST); ;
- break;}
-case 33:
-#line 373 "c-exp.y"
-{ ;
- break;}
-case 34:
-#line 379 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_REPEAT); ;
- break;}
-case 35:
-#line 383 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_MUL); ;
- break;}
-case 36:
-#line 387 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_DIV); ;
- break;}
-case 37:
-#line 391 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_REM); ;
- break;}
-case 38:
-#line 395 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_ADD); ;
- break;}
-case 39:
-#line 399 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_SUB); ;
- break;}
-case 40:
-#line 403 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_LSH); ;
- break;}
-case 41:
-#line 407 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_RSH); ;
- break;}
-case 42:
-#line 411 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_EQUAL); ;
- break;}
-case 43:
-#line 415 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_NOTEQUAL); ;
- break;}
-case 44:
-#line 419 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_LEQ); ;
- break;}
-case 45:
-#line 423 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_GEQ); ;
- break;}
-case 46:
-#line 427 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_LESS); ;
- break;}
-case 47:
-#line 431 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_GTR); ;
- break;}
-case 48:
-#line 435 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_BITWISE_AND); ;
- break;}
-case 49:
-#line 439 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_BITWISE_XOR); ;
- break;}
-case 50:
-#line 443 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_BITWISE_IOR); ;
- break;}
-case 51:
-#line 447 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_LOGICAL_AND); ;
- break;}
-case 52:
-#line 451 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_LOGICAL_OR); ;
- break;}
-case 53:
-#line 455 "c-exp.y"
-{ write_exp_elt_opcode (TERNOP_COND); ;
- break;}
-case 54:
-#line 459 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_ASSIGN); ;
- break;}
-case 55:
-#line 463 "c-exp.y"
-{ write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode (yyvsp[-1].opcode);
- write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); ;
- break;}
-case 56:
-#line 469 "c-exp.y"
-{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (yyvsp[0].typed_val_int.type);
- write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val_int.val));
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 57:
-#line 476 "c-exp.y"
-{ YYSTYPE val;
- parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (val.typed_val_int.type);
- write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
- write_exp_elt_opcode (OP_LONG);
- ;
- break;}
-case 58:
-#line 487 "c-exp.y"
-{ write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type (yyvsp[0].typed_val_float.type);
- write_exp_elt_dblcst (yyvsp[0].typed_val_float.dval);
- write_exp_elt_opcode (OP_DOUBLE); ;
- break;}
-case 61:
-#line 501 "c-exp.y"
-{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_int);
- CHECK_TYPEDEF (yyvsp[-1].tval);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 62:
-#line 509 "c-exp.y"
-{ /* C strings are converted into array constants with
- an explicit null byte added at the end. Thus
- the array upper bound is the string length.
- There is no such thing in C as a completely empty
- string. */
- char *sp = yyvsp[0].sval.ptr; int count = yyvsp[0].sval.length;
- while (count-- > 0)
- {
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_char);
- write_exp_elt_longcst ((LONGEST)(*sp++));
- write_exp_elt_opcode (OP_LONG);
- }
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_char);
- write_exp_elt_longcst ((LONGEST)'\0');
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_opcode (OP_ARRAY);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_longcst ((LONGEST) (yyvsp[0].sval.length));
- write_exp_elt_opcode (OP_ARRAY); ;
- break;}
-case 63:
-#line 534 "c-exp.y"
-{ write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS); ;
- break;}
-case 64:
-#line 539 "c-exp.y"
-{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_bool);
- write_exp_elt_longcst ((LONGEST) 1);
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 65:
-#line 546 "c-exp.y"
-{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_bool);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 66:
-#line 555 "c-exp.y"
-{
- if (yyvsp[0].ssym.sym)
- yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym);
- else
- error ("No file or function \"%s\".",
- copy_name (yyvsp[0].ssym.stoken));
- ;
- break;}
-case 67:
-#line 563 "c-exp.y"
-{
- yyval.bval = yyvsp[0].bval;
- ;
- break;}
-case 68:
-#line 569 "c-exp.y"
-{ struct symbol *tem
- = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
- VAR_NAMESPACE, (int *) NULL,
- (struct symtab **) 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 69:
-#line 580 "c-exp.y"
-{ struct symbol *sym;
- sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
- VAR_NAMESPACE, (int *) NULL,
- (struct symtab **) NULL);
- if (sym == 0)
- error ("No symbol \"%s\" in specified context.",
- copy_name (yyvsp[0].sval));
-
- write_exp_elt_opcode (OP_VAR_VALUE);
- /* block_found is set by lookup_symbol. */
- write_exp_elt_block (block_found);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE); ;
- break;}
-case 70:
-#line 596 "c-exp.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 71:
-#line 609 "c-exp.y"
-{
- struct type *type = yyvsp[-3].tval;
- struct stoken tmp_token;
- 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));
-
- tmp_token.ptr = (char*) alloca (yyvsp[0].sval.length + 2);
- tmp_token.length = yyvsp[0].sval.length + 1;
- tmp_token.ptr[0] = '~';
- memcpy (tmp_token.ptr+1, yyvsp[0].sval.ptr, yyvsp[0].sval.length);
- tmp_token.ptr[tmp_token.length] = 0;
-
- /* Check for valid destructor name. */
- destructor_name_p (tmp_token.ptr, type);
- write_exp_elt_opcode (OP_SCOPE);
- write_exp_elt_type (type);
- write_exp_string (tmp_token);
- write_exp_elt_opcode (OP_SCOPE);
- ;
- break;}
-case 73:
-#line 634 "c-exp.y"
-{
- char *name = copy_name (yyvsp[0].sval);
- struct symbol *sym;
- struct minimal_symbol *msymbol;
-
- sym =
- lookup_symbol (name, (const struct block *) NULL,
- VAR_NAMESPACE, (int *) NULL,
- (struct symtab **) NULL);
- if (sym)
- {
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
- break;
- }
-
- msymbol = lookup_minimal_symbol (name, NULL, NULL);
- if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
- else
- if (!have_full_symbols () && !have_partial_symbols ())
- error ("No symbol table is loaded. Use the \"file\" command.");
- else
- error ("No symbol \"%s\" in current context.", name);
- ;
- break;}
-case 74:
-#line 668 "c-exp.y"
-{ struct symbol *sym = yyvsp[0].ssym.sym;
-
- if (sym)
- {
- if (symbol_read_needs_frame (sym))
- {
- if (innermost_block == 0 ||
- contained_in (block_found,
- innermost_block))
- innermost_block = block_found;
- }
-
- write_exp_elt_opcode (OP_VAR_VALUE);
- /* We want to use the selected frame, not
- another more inner frame which happens to
- be in the same block. */
- write_exp_elt_block (NULL);
- 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
- {
- struct minimal_symbol *msymbol;
- register char *arg = copy_name (yyvsp[0].ssym.stoken);
-
- msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
- if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
- else if (!have_full_symbols () && !have_partial_symbols ())
- 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 78:
-#line 734 "c-exp.y"
-{ yyval.tval = follow_types (yyvsp[-1].tval); ;
- break;}
-case 79:
-#line 736 "c-exp.y"
-{ yyval.tval = follow_types (yyvsp[-2].tval); ;
- break;}
-case 80:
-#line 738 "c-exp.y"
-{ yyval.tval = follow_types (yyvsp[-2].tval); ;
- break;}
-case 81:
-#line 742 "c-exp.y"
-{ push_type (tp_pointer); yyval.voidval = 0; ;
- break;}
-case 82:
-#line 744 "c-exp.y"
-{ push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; ;
- break;}
-case 83:
-#line 746 "c-exp.y"
-{ push_type (tp_reference); yyval.voidval = 0; ;
- break;}
-case 84:
-#line 748 "c-exp.y"
-{ push_type (tp_reference); yyval.voidval = yyvsp[0].voidval; ;
- break;}
-case 86:
-#line 753 "c-exp.y"
-{ yyval.voidval = yyvsp[-1].voidval; ;
- break;}
-case 87:
-#line 755 "c-exp.y"
-{
- push_type_int (yyvsp[0].lval);
- push_type (tp_array);
- ;
- break;}
-case 88:
-#line 760 "c-exp.y"
-{
- push_type_int (yyvsp[0].lval);
- push_type (tp_array);
- yyval.voidval = 0;
- ;
- break;}
-case 89:
-#line 767 "c-exp.y"
-{ push_type (tp_function); ;
- break;}
-case 90:
-#line 769 "c-exp.y"
-{ push_type (tp_function); ;
- break;}
-case 91:
-#line 773 "c-exp.y"
-{ yyval.lval = -1; ;
- break;}
-case 92:
-#line 775 "c-exp.y"
-{ yyval.lval = yyvsp[-1].typed_val_int.val; ;
- break;}
-case 93:
-#line 779 "c-exp.y"
-{ yyval.voidval = 0; ;
- break;}
-case 94:
-#line 781 "c-exp.y"
-{ free ((PTR)yyvsp[-1].tvec); yyval.voidval = 0; ;
- break;}
-case 96:
-#line 794 "c-exp.y"
-{ yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); ;
- break;}
-case 97:
-#line 799 "c-exp.y"
-{ yyval.tval = yyvsp[0].tsym.type; ;
- break;}
-case 98:
-#line 801 "c-exp.y"
-{ yyval.tval = builtin_type_int; ;
- break;}
-case 99:
-#line 803 "c-exp.y"
-{ yyval.tval = builtin_type_long; ;
- break;}
-case 100:
-#line 805 "c-exp.y"
-{ yyval.tval = builtin_type_short; ;
- break;}
-case 101:
-#line 807 "c-exp.y"
-{ yyval.tval = builtin_type_long; ;
- break;}
-case 102:
-#line 809 "c-exp.y"
-{ yyval.tval = builtin_type_unsigned_long; ;
- break;}
-case 103:
-#line 811 "c-exp.y"
-{ yyval.tval = builtin_type_long_long; ;
- break;}
-case 104:
-#line 813 "c-exp.y"
-{ yyval.tval = builtin_type_long_long; ;
- break;}
-case 105:
-#line 815 "c-exp.y"
-{ yyval.tval = builtin_type_unsigned_long_long; ;
- break;}
-case 106:
-#line 817 "c-exp.y"
-{ yyval.tval = builtin_type_unsigned_long_long; ;
- break;}
-case 107:
-#line 819 "c-exp.y"
-{ yyval.tval = builtin_type_short; ;
- break;}
-case 108:
-#line 821 "c-exp.y"
-{ yyval.tval = builtin_type_unsigned_short; ;
- break;}
-case 109:
-#line 823 "c-exp.y"
-{ yyval.tval = builtin_type_double; ;
- break;}
-case 110:
-#line 825 "c-exp.y"
-{ yyval.tval = builtin_type_long_double; ;
- break;}
-case 111:
-#line 827 "c-exp.y"
-{ yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
- expression_context_block); ;
- break;}
-case 112:
-#line 830 "c-exp.y"
-{ yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
- expression_context_block); ;
- break;}
-case 113:
-#line 833 "c-exp.y"
-{ yyval.tval = lookup_union (copy_name (yyvsp[0].sval),
- expression_context_block); ;
- break;}
-case 114:
-#line 836 "c-exp.y"
-{ yyval.tval = lookup_enum (copy_name (yyvsp[0].sval),
- expression_context_block); ;
- break;}
-case 115:
-#line 839 "c-exp.y"
-{ yyval.tval = lookup_unsigned_typename (TYPE_NAME(yyvsp[0].tsym.type)); ;
- break;}
-case 116:
-#line 841 "c-exp.y"
-{ yyval.tval = builtin_type_unsigned_int; ;
- break;}
-case 117:
-#line 843 "c-exp.y"
-{ yyval.tval = lookup_signed_typename (TYPE_NAME(yyvsp[0].tsym.type)); ;
- break;}
-case 118:
-#line 845 "c-exp.y"
-{ yyval.tval = builtin_type_int; ;
- break;}
-case 119:
-#line 850 "c-exp.y"
-{ yyval.tval = lookup_template_type(copy_name(yyvsp[-3].sval), yyvsp[-1].tval,
- expression_context_block);
- ;
- break;}
-case 120:
-#line 856 "c-exp.y"
-{ yyval.tval = yyvsp[0].tval; ;
- break;}
-case 121:
-#line 857 "c-exp.y"
-{ yyval.tval = yyvsp[0].tval; ;
- break;}
-case 123:
-#line 862 "c-exp.y"
-{
- yyval.tsym.stoken.ptr = "int";
- yyval.tsym.stoken.length = 3;
- yyval.tsym.type = builtin_type_int;
- ;
- break;}
-case 124:
-#line 868 "c-exp.y"
-{
- yyval.tsym.stoken.ptr = "long";
- yyval.tsym.stoken.length = 4;
- yyval.tsym.type = builtin_type_long;
- ;
- break;}
-case 125:
-#line 874 "c-exp.y"
-{
- yyval.tsym.stoken.ptr = "short";
- yyval.tsym.stoken.length = 5;
- yyval.tsym.type = builtin_type_short;
- ;
- break;}
-case 126:
-#line 883 "c-exp.y"
-{ yyval.tvec = (struct type **) xmalloc (sizeof (struct type *) * 2);
- yyval.ivec[0] = 1; /* Number of types in vector */
- yyval.tvec[1] = yyvsp[0].tval;
- ;
- break;}
-case 127:
-#line 888 "c-exp.y"
-{ int len = sizeof (struct type *) * (++(yyvsp[-2].ivec[0]) + 1);
- yyval.tvec = (struct type **) xrealloc ((char *) yyvsp[-2].tvec, len);
- yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval;
- ;
- break;}
-case 128:
-#line 894 "c-exp.y"
-{ yyval.sval = yyvsp[0].ssym.stoken; ;
- break;}
-case 129:
-#line 895 "c-exp.y"
-{ yyval.sval = yyvsp[0].ssym.stoken; ;
- break;}
-case 130:
-#line 896 "c-exp.y"
-{ yyval.sval = yyvsp[0].tsym.stoken; ;
- break;}
-case 131:
-#line 897 "c-exp.y"
-{ yyval.sval = yyvsp[0].ssym.stoken; ;
- break;}
-}
- /* the action file gets copied in in place of this dollarsign */
-#line 498 "/stone/jimb/main-98r2/share/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;
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- size += strlen(yytname[x]) + 15, count++;
- msg = (char *) xmalloc(size + 15);
- if (msg != 0)
- {
- strcpy(msg, "parse error");
-
- if (count < 5)
- {
- count = 0;
- for (x = (yyn < 0 ? -yyn : 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
- yyerror ("parse error; also virtual memory exceeded");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror("parse error");
- }
-
- goto yyerrlab1;
-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 911 "c-exp.y"
-
-
-/* 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;
-{
- /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
- here, and we do kind of silly things like cast to unsigned. */
- register LONGEST n = 0;
- register LONGEST prevn = 0;
- ULONGEST un;
-
- register int i = 0;
- register int c;
- register int base = input_radix;
- int unsigned_p = 0;
-
- /* Number of "L" suffixes encountered. */
- int long_p = 0;
-
- /* We have found a "L" or "U" suffix. */
- int found_suffix = 0;
-
- ULONGEST high_bit;
- struct type *signed_type;
- struct type *unsigned_type;
-
- if (parsed_float)
- {
- /* It's a float since it contains a point or an exponent. */
- char c;
- int num = 0; /* number of tokens scanned by scanf */
- char saved_char = p[len];
-
- p[len] = 0; /* null-terminate the token */
- if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
- num = sscanf (p, "%g%c", (float *) &putithere->typed_val_float.dval,&c);
- else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
- num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval,&c);
- else
- {
-#ifdef SCANF_HAS_LONG_DOUBLE
- num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval,&c);
-#else
- /* Scan it into a double, then assign it to the long double.
- This at least wins with values representable in the range
- of doubles. */
- double temp;
- num = sscanf (p, "%lg%c", &temp,&c);
- putithere->typed_val_float.dval = temp;
-#endif
- }
- p[len] = saved_char; /* restore the input stream */
- if (num != 1) /* check scanf found ONLY a float ... */
- return ERROR;
- /* See if it has `f' or `l' suffix (float or long double). */
-
- c = tolower (p[len - 1]);
-
- if (c == 'f')
- putithere->typed_val_float.type = builtin_type_float;
- else if (c == 'l')
- putithere->typed_val_float.type = builtin_type_long_double;
- else if (isdigit (c) || c == '.')
- putithere->typed_val_float.type = builtin_type_double;
- else
- return ERROR;
-
- 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')
- {
- if (found_suffix)
- return ERROR;
- n += i = c - '0';
- }
- else
- {
- if (base > 10 && c >= 'a' && c <= 'f')
- {
- if (found_suffix)
- return ERROR;
- n += i = c - 'a' + 10;
- }
- else if (c == 'l')
- {
- ++long_p;
- found_suffix = 1;
- }
- else if (c == 'u')
- {
- unsigned_p = 1;
- found_suffix = 1;
- }
- else
- return ERROR; /* Char not a digit */
- }
- if (i >= base)
- return ERROR; /* Invalid digit in this base */
-
- /* Portably test for overflow (only works for nonzero values, so make
- a second check for zero). FIXME: Can't we just make n and prevn
- unsigned and avoid this? */
- if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
- unsigned_p = 1; /* Try something unsigned */
-
- /* Portably test for unsigned overflow.
- FIXME: This check is wrong; for example it doesn't find overflow
- on 0x123456789 when LONGEST is 32 bits. */
- if (c != 'l' && c != 'u' && n != 0)
- {
- if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
- error ("Numeric constant too large.");
- }
- prevn = n;
- }
-
- /* An integer constant is an int, a long, or a long long. An L
- suffix forces it to be long; an LL suffix forces it to be long
- long. If not forced to a larger size, it gets the first type of
- the above that it fits in. To figure out whether it fits, we
- shift it right and see whether anything remains. Note that we
- can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
- operation, because many compilers will warn about such a shift
- (which always produces a zero result). Sometimes TARGET_INT_BIT
- or TARGET_LONG_BIT will be that big, sometimes not. To deal with
- the case where it is we just always shift the value more than
- once, with fewer bits each time. */
-
- un = (ULONGEST)n >> 2;
- if (long_p == 0
- && (un >> (TARGET_INT_BIT - 2)) == 0)
- {
- high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1);
-
- /* A large decimal (not hex or octal) constant (between INT_MAX
- and UINT_MAX) is a long or unsigned long, according to ANSI,
- never an unsigned int, but this code treats it as unsigned
- int. This probably should be fixed. GCC gives a warning on
- such constants. */
-
- unsigned_type = builtin_type_unsigned_int;
- signed_type = builtin_type_int;
- }
- else if (long_p <= 1
- && (un >> (TARGET_LONG_BIT - 2)) == 0)
- {
- high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1);
- unsigned_type = builtin_type_unsigned_long;
- signed_type = builtin_type_long;
- }
- else
- {
- int shift;
- if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
- /* A long long does not fit in a LONGEST. */
- shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
- else
- shift = (TARGET_LONG_LONG_BIT - 1);
- high_bit = (ULONGEST) 1 << shift;
- unsigned_type = builtin_type_unsigned_long_long;
- signed_type = builtin_type_long_long;
- }
-
- putithere->typed_val_int.val = n;
-
- /* If the high bit of the worked out type is set then this number
- has to be unsigned. */
-
- if (unsigned_p || (n & high_bit))
- {
- putithere->typed_val_int.type = unsigned_type;
- }
- else
- {
- putithere->typed_val_int.type = signed_type;
- }
-
- return INT;
-}
-
-struct token
-{
- char *operator;
- int token;
- enum exp_opcode opcode;
-};
-
-static const struct token tokentab3[] =
- {
- {">>=", ASSIGN_MODIFY, BINOP_RSH},
- {"<<=", ASSIGN_MODIFY, BINOP_LSH}
- };
-
-static const 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_BITWISE_IOR},
- {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
- {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
- {"++", INCREMENT, BINOP_END},
- {"--", DECREMENT, BINOP_END},
- {"->", ARROW, BINOP_END},
- {"&&", ANDAND, BINOP_END},
- {"||", OROR, 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. */
-
-static int
-yylex ()
-{
- int c;
- int namelen;
- unsigned int i;
- char *tokstart;
- char *tokptr;
- int tempbufindex;
- static char *tempbuf;
- static int tempbufsize;
- struct symbol * sym_class = NULL;
- char * token_string = NULL;
- int class_prefix = 0;
- int unquoted_expr;
-
- retry:
-
- unquoted_expr = 1;
-
- tokstart = lexptr;
- /* See if it is a special token of length 3. */
- for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
- if (STREQN (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 (STREQN (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 '\'':
- /* We either have a character constant ('0' or '\177' for example)
- or we have a quoted symbol reference ('foo(int,int)' in C++
- for example). */
- lexptr++;
- c = *lexptr++;
- if (c == '\\')
- c = parse_escape (&lexptr);
- else if (c == '\'')
- error ("Empty character constant.");
-
- yylval.typed_val_int.val = c;
- yylval.typed_val_int.type = builtin_type_char;
-
- c = *lexptr++;
- if (c != '\'')
- {
- namelen = skip_quoted (tokstart) - tokstart;
- if (namelen > 2)
- {
- lexptr = tokstart + namelen;
- unquoted_expr = 0;
- if (lexptr[-1] != '\'')
- error ("Unmatched single quote.");
- namelen -= 2;
- tokstart++;
- goto tryname;
- }
- error ("Invalid character constant.");
- }
- return INT;
-
- 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)
- {
- /* This test includes !hex because 'e' is a valid hex digit
- and thus does not indicate a floating point number when
- the radix is hex. */
- if (!hex && !got_e && (*p == 'e' || *p == 'E'))
- got_dot = got_e = 1;
- /* This test does not include !hex, because a '.' always indicates
- a decimal floating point number regardless of the radix. */
- 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;
- /* 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);
-
- memcpy (err_copy, tokstart, 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 '"':
-
- /* Build the gdb internal form of the input string in tempbuf,
- translating any standard C escape forms seen. Note that the
- buffer is null byte terminated *only* for the convenience of
- debugging gdb itself and printing the buffer contents when
- the buffer contains no embedded nulls. Gdb does not depend
- upon the buffer being null byte terminated, it uses the length
- string instead. This allows gdb to handle C strings (as well
- as strings in other languages) with embedded null bytes */
-
- tokptr = ++tokstart;
- tempbufindex = 0;
-
- do {
- /* Grow the static temp buffer if necessary, including allocating
- the first one on demand. */
- if (tempbufindex + 1 >= tempbufsize)
- {
- tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64);
- }
- switch (*tokptr)
- {
- case '\0':
- case '"':
- /* Do nothing, loop will terminate. */
- break;
- case '\\':
- tokptr++;
- c = parse_escape (&tokptr);
- if (c == -1)
- {
- continue;
- }
- tempbuf[tempbufindex++] = c;
- break;
- default:
- tempbuf[tempbufindex++] = *tokptr++;
- break;
- }
- } while ((*tokptr != '"') && (*tokptr != '\0'));
- if (*tokptr++ != '"')
- {
- error ("Unterminated string in expression.");
- }
- tempbuf[tempbufindex] = '\0'; /* See note above */
- yylval.sval.ptr = tempbuf;
- yylval.sval.length = tempbufindex;
- lexptr = tokptr;
- 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 == '<');)
- {
- /* Template parameter lists are part of the name.
- FIXME: This mishandles `print $a<4&&$a>3'. */
-
- if (c == '<')
- {
- if (hp_som_som_object_present)
- {
- /* Scan ahead to get rest of the template specification. Note
- that we look ahead only when the '<' adjoins non-whitespace
- characters; for comparison expressions, e.g. "a < b > c",
- there must be spaces before the '<', etc. */
-
- char * p = find_template_name_end (tokstart + namelen);
- if (p)
- namelen = p - tokstart;
- break;
- }
- else
- {
- int i = namelen;
- int nesting_level = 1;
- while (tokstart[++i])
- {
- if (tokstart[i] == '<')
- nesting_level++;
- else if (tokstart[i] == '>')
- {
- if (--nesting_level == 0)
- break;
- }
- }
- if (tokstart[i] == '>')
- namelen = i;
- else
- break;
- }
- }
- 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;
-
- tryname:
-
- /* Catch specific keywords. Should be done with a data structure. */
- switch (namelen)
- {
- case 8:
- if (STREQN (tokstart, "unsigned", 8))
- return UNSIGNED;
- if (current_language->la_language == language_cplus
- && STREQN (tokstart, "template", 8))
- return TEMPLATE;
- if (STREQN (tokstart, "volatile", 8))
- return VOLATILE_KEYWORD;
- break;
- case 6:
- if (STREQN (tokstart, "struct", 6))
- return STRUCT;
- if (STREQN (tokstart, "signed", 6))
- return SIGNED_KEYWORD;
- if (STREQN (tokstart, "sizeof", 6))
- return SIZEOF;
- if (STREQN (tokstart, "double", 6))
- return DOUBLE_KEYWORD;
- break;
- case 5:
- if (current_language->la_language == language_cplus)
- {
- if (STREQN (tokstart, "false", 5))
- return FALSEKEYWORD;
- if (STREQN (tokstart, "class", 5))
- return CLASS;
- }
- if (STREQN (tokstart, "union", 5))
- return UNION;
- if (STREQN (tokstart, "short", 5))
- return SHORT;
- if (STREQN (tokstart, "const", 5))
- return CONST_KEYWORD;
- break;
- case 4:
- if (STREQN (tokstart, "enum", 4))
- return ENUM;
- if (STREQN (tokstart, "long", 4))
- return LONG;
- if (current_language->la_language == language_cplus)
- {
- if (STREQN (tokstart, "true", 4))
- return TRUEKEYWORD;
-
- if (STREQN (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, (int *) NULL,
- (struct symtab **) NULL))
- return THIS;
- }
- }
- break;
- case 3:
- if (STREQN (tokstart, "int", 3))
- return INT_KEYWORD;
- break;
- default:
- break;
- }
-
- yylval.sval.ptr = tokstart;
- yylval.sval.length = namelen;
-
- if (*tokstart == '$')
- {
- write_dollar_variable (yylval.sval);
- return VARIABLE;
- }
-
- /* Look ahead and see if we can consume more of the input
- string to get a reasonable class/namespace spec or a
- fully-qualified name. This is a kludge to get around the
- HP aCC compiler's generation of symbol names with embedded
- colons for namespace and nested classes. */
- if (unquoted_expr)
- {
- /* Only do it if not inside single quotes */
- sym_class = parse_nested_classes_for_hpacc (yylval.sval.ptr, yylval.sval.length,
- &token_string, &class_prefix, &lexptr);
- if (sym_class)
- {
- /* Replace the current token with the bigger one we found */
- yylval.sval.ptr = token_string;
- yylval.sval.length = strlen (token_string);
- }
- }
-
- /* 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 : (int *) NULL,
- (struct symtab **) NULL);
- /* Call lookup_symtab, not lookup_partial_symtab, in case there are
- no psymtabs (coff, xcoff, or some future change to blow away the
- psymtabs once once symbols are read). */
- if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
- {
- yylval.ssym.sym = sym;
- yylval.ssym.is_a_field_of_this = is_a_field_of_this;
- return BLOCKNAME;
- }
- else if (!sym)
- { /* See if it's a file name. */
- struct symtab *symtab;
-
- symtab = lookup_symtab (tmp);
-
- if (symtab)
- {
- yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
- return FILENAME;
- }
- }
-
- if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- {
-#if 1
- /* Despite the following flaw, we need to keep this code enabled.
- Because we can get called from check_stub_method, if we don't
- handle nested types then it screws many operations in any
- program which uses nested types. */
- /* In "A::x", if x is a member function of A and there happens
- to be a type (nested or not, since the stabs don't make that
- distinction) named x, then this code incorrectly thinks we
- are dealing with nested types rather than a member function. */
-
- char *p;
- char *namestart;
- struct symbol *best_sym;
-
- /* Look ahead to detect nested types. This probably should be
- done in the grammar, but trying seemed to introduce a lot
- of shift/reduce and reduce/reduce conflicts. It's possible
- that it could be done, though. Or perhaps a non-grammar, but
- less ad hoc, approach would work well. */
-
- /* Since we do not currently have any way of distinguishing
- a nested type from a non-nested one (the stabs don't tell
- us whether a type is nested), we just ignore the
- containing type. */
-
- p = lexptr;
- best_sym = sym;
- while (1)
- {
- /* Skip whitespace. */
- while (*p == ' ' || *p == '\t' || *p == '\n')
- ++p;
- if (*p == ':' && p[1] == ':')
- {
- /* Skip the `::'. */
- p += 2;
- /* Skip whitespace. */
- while (*p == ' ' || *p == '\t' || *p == '\n')
- ++p;
- namestart = p;
- while (*p == '_' || *p == '$' || (*p >= '0' && *p <= '9')
- || (*p >= 'a' && *p <= 'z')
- || (*p >= 'A' && *p <= 'Z'))
- ++p;
- if (p != namestart)
- {
- struct symbol *cur_sym;
- /* As big as the whole rest of the expression, which is
- at least big enough. */
- char *ncopy = alloca (strlen (tmp)+strlen (namestart)+3);
- char *tmp1;
-
- tmp1 = ncopy;
- memcpy (tmp1, tmp, strlen (tmp));
- tmp1 += strlen (tmp);
- memcpy (tmp1, "::", 2);
- tmp1 += 2;
- memcpy (tmp1, namestart, p - namestart);
- tmp1[p - namestart] = '\0';
- cur_sym = lookup_symbol (ncopy, expression_context_block,
- VAR_NAMESPACE, (int *) NULL,
- (struct symtab **) NULL);
- if (cur_sym)
- {
- if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
- {
- best_sym = cur_sym;
- lexptr = p;
- }
- else
- break;
- }
- else
- break;
- }
- else
- break;
- }
- else
- break;
- }
-
- yylval.tsym.type = SYMBOL_TYPE (best_sym);
-#else /* not 0 */
- yylval.tsym.type = SYMBOL_TYPE (sym);
-#endif /* not 0 */
- 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;
- }
- }
-
- /* 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 ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
-}
diff --git a/contrib/gdb/gdb/callback.c b/contrib/gdb/gdb/callback.c
index d59ecda..c5224c6 100644
--- a/contrib/gdb/gdb/callback.c
+++ b/contrib/gdb/gdb/callback.c
@@ -248,7 +248,12 @@ os_time (p, t)
host_callback *p;
long *t;
{
- return wrap (p, time (t));
+ time_t now;
+
+ wrap (p, (int) time (&now));
+ if (t != NULL)
+ *t = (long) now;
+ return (long) now;
}
diff --git a/contrib/gdb/gdb/coff-solib.c b/contrib/gdb/gdb/coff-solib.c
deleted file mode 100644
index 6be6869..0000000
--- a/contrib/gdb/gdb/coff-solib.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Handle COFF SVR3 shared libraries for GDB, the GNU Debugger.
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#include "defs.h"
-
-#include "frame.h"
-#include "bfd.h"
-#include "gdbcore.h"
-#include "symtab.h"
-
-/*
-
-GLOBAL FUNCTION
-
- coff_solib_add -- add a shared library files to the symtab list. We
- examine the `.lib' section of the exec file and determine the names of
- the shared libraries.
-
- This function is responsible for discovering those names and
- addresses, and saving sufficient information about them to allow
- their symbols to be read at a later time.
-
-SYNOPSIS
-
- void coff_solib_add (char *arg_string, int from_tty,
- struct target_ops *target)
-
-DESCRIPTION
-
-*/
-
-void
-coff_solib_add (arg_string, from_tty, target)
- char *arg_string;
- int from_tty;
- struct target_ops *target;
-{
- asection *libsect;
-
- libsect = bfd_get_section_by_name (exec_bfd, ".lib");
-
- if (libsect)
- {
- int libsize;
- unsigned char *lib;
- struct libent
- {
- bfd_byte len[4];
- bfd_byte nameoffset[4];
- };
-
- libsize = bfd_section_size (exec_bfd, libsect);
-
- lib = (unsigned char *) alloca (libsize);
-
- bfd_get_section_contents (exec_bfd, libsect, lib, 0, libsize);
-
- while (libsize > 0)
- {
- struct libent *ent;
- struct objfile *objfile;
- int len, nameoffset;
- char *filename;
-
- ent = (struct libent *)lib;
-
- len = bfd_get_32 (exec_bfd, ent->len);
-
- nameoffset = bfd_get_32 (exec_bfd, ent->nameoffset);
-
- if (len <= 0)
- break;
-
- filename = (char *)ent + nameoffset * 4;
-
- objfile = symbol_file_add (filename, from_tty,
- 0, /* addr */
- 0, /* not mainline */
- 0, /* not mapped */
- 0, /* Not readnow */
- 0, /* Not user loaded */
- 1); /* Is a solib */
-
- libsize -= len * 4;
- lib += len * 4;
- }
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- reinit_frame_cache ();
- }
-}
-
-/*
-
-GLOBAL FUNCTION
-
- coff_solib_create_inferior_hook -- shared library startup support
-
-SYNOPSIS
-
- void coff_solib_create_inferior_hook()
-
-DESCRIPTION
-
- When gdb starts up the inferior, the kernel maps in the shared
- libraries. We get here with the target stopped at it's first
- instruction, and the libraries already mapped. At this point, this
- function gets called via expansion of the macro
- SOLIB_CREATE_INFERIOR_HOOK.
- */
-
-void
-coff_solib_create_inferior_hook()
-{
- coff_solib_add ((char *) 0, 0, (struct target_ops *) 0);
-}
diff --git a/contrib/gdb/gdb/coff-solib.h b/contrib/gdb/gdb/coff-solib.h
deleted file mode 100644
index 43375cc..0000000
--- a/contrib/gdb/gdb/coff-solib.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* COFF (SVR3) Shared library declarations for GDB, the GNU Debugger.
- Copyright (C) 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifdef __STDC__ /* Forward decl's for prototypes */
-struct target_ops;
-#endif
-
-/* Called when we free all symtabs, to free the shared library information
- as well. */
-
-#if 0
-#define CLEAR_SOLIB coff_clear_solib
-
-extern void
-coff_clear_solib PARAMS ((void));
-#endif
-
-/* Called to add symbols from a shared library to gdb's symbol table. */
-
-#define SOLIB_ADD(filename, from_tty, targ) \
- coff_solib_add (filename, from_tty, targ)
-
-extern void
-coff_solib_add PARAMS ((char *, int, struct target_ops *));
-
-/* Function to be called when the inferior starts up, to discover the names
- of shared libraries that are dynamically linked, the base addresses to
- which they are linked, and sufficient information to read in their symbols
- at a later time. */
-
-#define SOLIB_CREATE_INFERIOR_HOOK(PID) coff_solib_create_inferior_hook()
-
-extern void
-coff_solib_create_inferior_hook PARAMS((void)); /* solib.c */
-
-/* Function to be called to remove the connection between debugger and
- dynamic linker that was established by SOLIB_CREATE_INFERIOR_HOOK.
- (This operation does not remove shared library information from
- the debugger, as CLEAR_SOLIB does.)
-
- This functionality is presently not implemented for this target.
- */
-#define SOLIB_REMOVE_INFERIOR_HOOK(PID) (0)
-
-/* This function is called by the "catch load" command. It allows
- the debugger to be notified by the dynamic linker when a specified
- library file (or any library file, if filename is NULL) is loaded.
-
- Presently, this functionality is not implemented.
- */
-#define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
- error("catch of library loads/unloads not yet implemented on this platform")
-
-/* This function is called by the "catch unload" command. It allows
- the debugger to be notified by the dynamic linker when a specified
- library file (or any library file, if filename is NULL) is unloaded.
-
- Presently, this functionality is not implemented.
- */
-#define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid,tempflag,filename,cond_string) \
- error("catch of library loads/unloads not yet implemented on this platform")
-
-/* This function returns TRUE if the dynamic linker has just reported
- a load of a library.
-
- This function must be used only when the inferior has stopped in
- the dynamic linker hook, or undefined results are guaranteed.
-
- Presently, this functionality is not implemented.
- */
-/*
-#define SOLIB_HAVE_LOAD_EVENT(pid) \
- error("catch of library loads/unloads not yet implemented on this platform")
-*/
-
-#define SOLIB_HAVE_LOAD_EVENT(pid) \
-(0)
-
-/* This function returns a pointer to the string representation of the
- pathname of the dynamically-linked library that has just been loaded.
-
- This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
- or undefined results are guaranteed.
-
- This string's contents are only valid immediately after the inferior
- has stopped in the dynamic linker hook, and becomes invalid as soon
- as the inferior is continued. Clients should make a copy of this
- string if they wish to continue the inferior and then access the string.
-
- Presently, this functionality is not implemented.
- */
-
-/*
-#define SOLIB_LOADED_LIBRARY_PATHNAME(pid) \
- error("catch of library loads/unloads not yet implemented on this platform")
-*/
-
-#define SOLIB_LOADED_LIBRARY_PATHNAME(pid) \
-(0)
-
-/* This function returns TRUE if the dynamic linker has just reported
- an unload of a library.
-
- This function must be used only when the inferior has stopped in
- the dynamic linker hook, or undefined results are guaranteed.
-
- Presently, this functionality is not implemented.
- */
-/*
-#define SOLIB_HAVE_UNLOAD_EVENT(pid) \
- error("catch of library loads/unloads not yet implemented on this platform")
-*/
-
-#define SOLIB_HAVE_UNLOAD_EVENT(pid) \
-(0)
-
-/* This function returns a pointer to the string representation of the
- pathname of the dynamically-linked library that has just been unloaded.
-
- This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is TRUE,
- or undefined results are guaranteed.
-
- This string's contents are only valid immediately after the inferior
- has stopped in the dynamic linker hook, and becomes invalid as soon
- as the inferior is continued. Clients should make a copy of this
- string if they wish to continue the inferior and then access the string.
-
- Presently, this functionality is not implemented.
- */
-/*
-#define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) \
- error("catch of library loads/unloads not yet implemented on this platform")
-*/
-
-#define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) \
-(0)
-
-/* This function returns TRUE if pc is the address of an instruction that
- lies within the dynamic linker (such as the event hook, or the dld
- itself).
-
- This function must be used only when a dynamic linker event has been
- caught, and the inferior is being stepped out of the hook, or undefined
- results are guaranteed.
-
- Presently, this functionality is not implemented.
- */
-
-/*
-#define SOLIB_IN_DYNAMIC_LINKER(pid,pc) \
- error("catch of library loads/unloads not yet implemented on this platform")
-*/
-
-#define SOLIB_IN_DYNAMIC_LINKER(pid,pc) \
-(0)
-
-/* This function must be called when the inferior is killed, and the program
- restarted. This is not the same as CLEAR_SOLIB, in that it doesn't discard
- any symbol tables.
-
- Presently, this functionality is not implemented.
- */
-#define SOLIB_RESTART() \
- (0)
-
-/* If we can't set a breakpoint, and it's in a shared library, just
- disable it. */
-
-#if 0
-#define DISABLE_UNSETTABLE_BREAK(addr) coff_solib_address(addr)
-
-extern int
-solib_address PARAMS ((CORE_ADDR)); /* solib.c */
-#endif
diff --git a/contrib/gdb/gdb/config/nm-empty.h b/contrib/gdb/gdb/config/nm-empty.h
deleted file mode 100644
index 7069d8c..0000000
--- a/contrib/gdb/gdb/config/nm-empty.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* This is just a dummy file to symlink to when GDB is configured as a
- cross-only debugger. */
diff --git a/contrib/gdb/gdb/config/nm-gnu.h b/contrib/gdb/gdb/config/nm-gnu.h
deleted file mode 100644
index f59a2dc..0000000
--- a/contrib/gdb/gdb/config/nm-gnu.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Common declarations for the GNU Hurd
-
- Copyright (C) 1995 Free Software Foundation, Inc.
-
- Written by Miles Bader <miles@gnu.ai.mit.edu>
-
- The GNU Hurd is free software; you can redistribute 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 GNU Hurd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the 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 __NM_GNU_H__
-#define __NM_GNU_H__
-
-#include <unistd.h>
-#include <mach.h>
-#include <mach/exception.h>
-
-#include "solib.h" /* Support for shared libraries. */
-
-#undef target_pid_to_str
-#define target_pid_to_str(pid) gnu_target_pid_to_str(pid)
-extern char *gnu_target_pid_to_str (int pid);
-
-/* Before storing, we need to read all the registers. */
-#define CHILD_PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES)
-
-/* Don't do wait_for_inferior on attach. */
-#define ATTACH_NO_WAIT
-
-/* Use SVR4 style shared library support */
-#define SVR4_SHARED_LIBS
-#define NO_CORE_OPS
-
-#define MAINTENANCE_CMDS 1
-
-#endif /* __NM_GNU_H__ */
diff --git a/contrib/gdb/gdb/config/nm-lynx.h b/contrib/gdb/gdb/config/nm-lynx.h
deleted file mode 100644
index 8781a9a..0000000
--- a/contrib/gdb/gdb/config/nm-lynx.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Native-dependent definitions for LynxOS.
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef NM_LYNX_H
-#define NM_LYNX_H
-
-#include <sys/conf.h>
-#include <sys/kernel.h>
-/* sys/kernel.h should define this, but doesn't always, sigh. */
-#ifndef __LYNXOS
-#define __LYNXOS
-#endif
-#include <sys/mem.h>
-#include <sys/signal.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/itimer.h>
-#include <sys/file.h>
-#include <sys/proc.h>
-#include "thread.h"
-
-/* 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 USRSTACK
-
-#undef FLOAT_INFO /* No float info yet */
-
-/* As of LynxOS 2.2.2 (beta 8/15/94), this is int. Previous versions seem to
- have had no prototype, so I'm not sure why GDB used to define this to
- char *. */
-#define PTRACE_ARG3_TYPE int
-
-/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */
-
-#define FETCH_INFERIOR_REGISTERS
-
-/* Thread ID of stopped thread. */
-
-#define WIFTID(x) (((union wait *)&x)->w_tid)
-
-/* Override child_wait in inftarg.c */
-
-#define CHILD_WAIT
-
-/* Override child_resume in infptrace.c */
-
-#define CHILD_RESUME
-
-/* Override child_thread_alive in intarg.c */
-
-#define CHILD_THREAD_ALIVE
-
-#include "target.h"
-
-extern int child_wait PARAMS ((int pid, struct target_waitstatus *status));
-
-/* Lynx needs a special definition of this so that we can
- print out the pid and thread number seperatly. */
-
-#undef target_pid_to_str
-
-#define target_pid_to_str(PID) lynx_pid_to_str (PID)
-
-extern char *lynx_pid_to_str PARAMS ((int pid));
-
-#endif /* NM_LYNX_H */
diff --git a/contrib/gdb/gdb/config/nm-m3.h b/contrib/gdb/gdb/config/nm-m3.h
deleted file mode 100644
index 6ea5256..0000000
--- a/contrib/gdb/gdb/config/nm-m3.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Mach 3.0 common definitions and global vars.
-
- Copyright (C) 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef NM_M3_H
-#define NM_M3_H
-
-#include <mach.h>
-
-/* Mach3 doesn't declare errno in <errno.h>. */
-extern int errno;
-
-/* Task port of our debugged inferior. */
-
-extern task_t inferior_task;
-
-/* Thread port of the current thread in the inferior. */
-
-extern thread_t current_thread;
-
-/* If nonzero, we must suspend/abort && resume threads
- * when setting or getting the state.
- */
-extern int must_suspend_thread;
-
-#define PREPARE_TO_PROCEED(select_it) mach3_prepare_to_proceed(select_it)
-
-/* Try to get the privileged host port for authentication to machid
- *
- * If you can get this, you may debug anything on this host.
- *
- * If you can't, gdb gives it's own task port as the
- * authentication port
- */
-#define mach_privileged_host_port() task_by_pid(-1)
-
-/*
- * This is the MIG ID number of the emulator/server bsd_execve() RPC call.
- *
- * It SHOULD never change, but if it does, gdb `run'
- * command won't work until you fix this define.
- *
- */
-#define MIG_EXEC_SYSCALL_ID 101000
-
-/* If our_message_port gets a msg with this ID,
- * GDB suspends it's inferior and enters command level.
- * (Useful at least if ^C does not work)
- */
-#define GDB_MESSAGE_ID_STOP 0x41151
-
-/* wait3 WNOHANG is defined in <sys/wait.h> but
- * for some reason gdb does not want to include
- * that file.
- *
- * If your system defines WNOHANG differently, this has to be changed.
- */
-#define WNOHANG 1
-
-/* Before storing, we need to read all the registers. */
-
-#define CHILD_PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES)
-
-/* Check if the inferior exists */
-#define MACH_ERROR_NO_INFERIOR \
- do if (!MACH_PORT_VALID (inferior_task)) \
- error ("Inferior task does not exist."); while(0)
-
-/* Error handler for mach calls */
-#define CHK(str,ret) \
- do if (ret != KERN_SUCCESS) \
- error ("Gdb %s [%d] %s : %s\n",__FILE__,__LINE__,str, \
- mach_error_string(ret)); while(0)
-
-/* This is from POE9 emulator/emul_stack.h
- */
-/*
- * Top of emulator stack holds link and reply port.
- */
-struct emul_stack_top {
- struct emul_stack_top *link;
- mach_port_t reply_port;
-};
-
-#define EMULATOR_STACK_SIZE (4096*4)
-
-#define THREAD_ALLOWED_TO_BREAK(mid) mach_thread_for_breakpoint (mid)
-
-#define THREAD_PARSE_ID(arg) mach_thread_parse_id (arg)
-
-#define THREAD_OUTPUT_ID(mid) mach_thread_output_id (mid)
-
-#define ATTACH_TO_THREAD attach_to_thread
-
-/* Don't do wait_for_inferior on attach. */
-#define ATTACH_NO_WAIT
-
-/* Do Mach 3 dependent operations when ^C or a STOP is requested */
-#define DO_QUIT() mach3_quit ()
-
-#if 0
-/* This is bogus. It is NOT OK to quit out of target_wait. */
-/* If in mach_msg() and ^C is typed set immediate_quit */
-#define REQUEST_QUIT() mach3_request_quit ()
-#endif
-
-#endif /* NM_M3_H */
diff --git a/contrib/gdb/gdb/config/nm-nbsd.h b/contrib/gdb/gdb/config/nm-nbsd.h
deleted file mode 100644
index bc1d6a6..0000000
--- a/contrib/gdb/gdb/config/nm-nbsd.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Native-dependent definitions for NetBSD.
- Copyright 1994, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This is the amount to subtract from u.u_ar0
- to get the offset in the core file of the register values. */
-
-#include <machine/vmparam.h>
-
-#define KERNEL_U_ADDR USRSTACK
-
-#define PTRACE_ARG3_TYPE char*
-
-#define FETCH_INFERIOR_REGISTERS
-
-#define ATTACH_DETACH
-
-#include "solib.h" /* Support for shared libraries. */
-
-/* make structure definitions match up with those expected in solib.c */
-#define link_object sod
-#define lo_name sod_name
-#define lo_library sod_library
-#define lo_unused sod_reserved
-#define lo_major sod_major
-#define lo_minor sod_minor
-#define lo_next sod_next
-
-#define link_map so_map
-#define lm_addr som_addr
-#define lm_name som_path
-#define lm_next som_next
-#define lm_lop som_sod
-#define lm_lob som_sodbase
-#define lm_rwt som_write
-#define lm_ld som_dynamic
-#define lm_lpd som_spd
-
-#define link_dynamic_2 section_dispatch_table
-#define ld_loaded sdt_loaded
-#define ld_need sdt_sods
-#define ld_rules sdt_filler1
-#define ld_got sdt_got
-#define ld_plt sdt_plt
-#define ld_rel sdt_rel
-#define ld_hash sdt_hash
-#define ld_stab sdt_nzlist
-#define ld_stab_hash sdt_filler2
-#define ld_buckets sdt_buckets
-#define ld_symbols sdt_strings
-#define ld_symb_size sdt_str_sz
-#define ld_text sdt_text_sz
-#define ld_plt_sz sdt_plt_sz
-
-#define rtc_symb rt_symbol
-#define rtc_sp rt_sp
-#define rtc_next rt_next
-
-#define ld_debug so_debug
-#define ldd_version dd_version
-#define ldd_in_debugger dd_in_debugger
-#define ldd_sym_loaded dd_sym_loaded
-#define ldd_bp_addr dd_bpt_addr
-#define ldd_bp_inst dd_bpt_shadow
-#define ldd_cp dd_cc
-
-#define link_dynamic _dynamic
-#define ld_version d_version
-#define ldd d_debug
-#define ld_un d_un
-#define ld_2 d_sdt
diff --git a/contrib/gdb/gdb/config/nm-sysv4.h b/contrib/gdb/gdb/config/nm-sysv4.h
deleted file mode 100644
index e4978d0..0000000
--- a/contrib/gdb/gdb/config/nm-sysv4.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Definitions for running gdb on a host machine running any flavor of SVR4.
- Copyright 1991, 1992 Free Software Foundation, Inc.
- Written by Fred Fish at Cygnus Support (fnf@cygnus.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "solib.h" /* Support for shared libraries. */
-
-/* Use SVR4 style shared library support */
-
-#define SVR4_SHARED_LIBS
-
-/* SVR4 has /proc support, so use it instead of ptrace. */
-
-#define USE_PROC_FS
-
-/* SVR4 machines can easily do attach and detach via /proc (procfs.c)
- support */
-
-#define ATTACH_DETACH
diff --git a/contrib/gdb/gdb/config/tm-lynx.h b/contrib/gdb/gdb/config/tm-lynx.h
deleted file mode 100644
index 7107241..0000000
--- a/contrib/gdb/gdb/config/tm-lynx.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Macro definitions for LynxOS targets.
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef TM_LYNX_H
-#define TM_LYNX_H
-
-/* Override number of expected traps from sysv. */
-#define START_INFERIOR_TRAPS_EXPECTED 2
-
-#include "coff-solib.h" /* COFF shared library support */
-
-/* Lynx's signal.h doesn't seem to have any macros for what signal numbers
- the real-time events are. */
-#define REALTIME_LO 33
-/* One more than the last one. */
-#define REALTIME_HI 64
-
-#endif /* TM_LYNX_H */
diff --git a/contrib/gdb/gdb/config/tm-nbsd.h b/contrib/gdb/gdb/config/tm-nbsd.h
deleted file mode 100644
index e295d85..0000000
--- a/contrib/gdb/gdb/config/tm-nbsd.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Target machine sub-description for NetBSD.
- This is included by other tm-*.h files to specify NetBSD-specific stuff.
- Copyright 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
diff --git a/contrib/gdb/gdb/config/tm-sunos.h b/contrib/gdb/gdb/config/tm-sunos.h
deleted file mode 100644
index 26ec3cf..0000000
--- a/contrib/gdb/gdb/config/tm-sunos.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Target machine sub-description for SunOS version 4.
- This is included by other tm-*.h files to specify SunOS-specific stuff.
- Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "solib.h" /* Support for shared libraries. */
-
-/* Return non-zero if we are in a shared library trampoline code stub. */
-
-#define IN_SOLIB_CALL_TRAMPOLINE(pc, name) \
- lookup_solib_trampoline_symbol_by_pc (pc)
-
-/* If PC is in a shared library trampoline code, return the PC
- where the function itself actually starts. If not, return 0. */
-
-#define SKIP_TRAMPOLINE_CODE(pc) find_solib_trampoline_target (pc)
diff --git a/contrib/gdb/gdb/config/tm-sysv4.h b/contrib/gdb/gdb/config/tm-sysv4.h
deleted file mode 100644
index 2c08541..0000000
--- a/contrib/gdb/gdb/config/tm-sysv4.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Macro definitions for GDB on all SVR4 target systems.
- Copyright 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
- Written by Fred Fish at Cygnus Support (fnf@cygnus.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* For SVR4 shared libraries, each call to a library routine goes through
- a small piece of trampoline code in the ".plt" section.
- The horribly ugly wait_for_inferior() routine uses this macro to detect
- when we have stepped into one of these fragments.
- We do not use lookup_solib_trampoline_symbol_by_pc, because
- we cannot always find the shared library trampoline symbols
- (e.g. on Irix5). */
-
-#define IN_SOLIB_CALL_TRAMPOLINE(pc, name) in_plt_section((pc), (name))
-extern int in_plt_section PARAMS ((CORE_ADDR, char *));
-
-/* If PC is in a shared library trampoline code, return the PC
- where the function itself actually starts. If not, return 0. */
-
-#define SKIP_TRAMPOLINE_CODE(pc) find_solib_trampoline_target (pc)
-
-/* It is unknown which, if any, SVR4 assemblers do not accept dollar signs
- in identifiers. The default in G++ is to use dots instead, for all SVR4
- systems, so we make that our default also. FIXME: There should be some
- way to get G++ to tell us what CPLUS_MARKER it is using, perhaps by
- stashing it in the debugging information as part of the name of an
- invented symbol ("gcc_cplus_marker$" for example). */
-
-#undef CPLUS_MARKER
-#define CPLUS_MARKER '.'
diff --git a/contrib/gdb/gdb/config/xm-aix4.h b/contrib/gdb/gdb/config/xm-aix4.h
deleted file mode 100644
index 31bb6da..0000000
--- a/contrib/gdb/gdb/config/xm-aix4.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Parameters for hosting on an PowerPC, for GDB, the GNU debugger.
- Copyright 1995 Free Software Foundation, Inc.
- Contributed by Cygnus 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. */
-
-/* The following text is taken from config/rs6000.mh:
- * # The IBM version of /usr/include/rpc/rpc.h has a bug -- it says
- * # `extern fd_set svc_fdset;' without ever defining the type fd_set.
- * # Unfortunately this occurs in the vx-share code, which is not configured
- * # like the rest of GDB (e.g. it doesn't include "defs.h").
- * # We circumvent this bug by #define-ing fd_set here, but undefining it in
- * # the xm-rs6000.h file before ordinary modules try to use it. FIXME, IBM!
- * MH_CFLAGS='-Dfd_set=int'
- * So, here we do the undefine...which has to occur before we include
- * <sys/select.h> below.
- */
-#undef fd_set
-
-#include <sys/select.h>
-
-/* Big end is at the low address */
-
-#define HOST_BYTE_ORDER BIG_ENDIAN
-
-/* At least as of AIX 3.2, we have termios. */
-#define HAVE_TERMIOS 1
-/* #define HAVE_TERMIO 1 */
-
-#define USG 1
-#define HAVE_SIGSETMASK 1
-
-#define FIVE_ARG_PTRACE
-
-/* AIX declares the mem functions differently than defs.h does. AIX is
- right, but defs.h works on more old systems. For now, override it. */
-
-#define MEM_FNS_DECLARED 1
-
-/* This system requires that we open a terminal with O_NOCTTY for it to
- not become our controlling terminal. */
-
-#define USE_O_NOCTTY
-
-/* 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
-
-/* There is no vfork. */
-
-#define vfork fork
-
-/* Signal handler for SIGWINCH `window size changed'. */
-
-#define SIGWINCH_HANDLER aix_resizewindow
-extern void aix_resizewindow ();
-
-/* `lines_per_page' and `chars_per_line' are local to utils.c. Rectify this. */
-
-#define SIGWINCH_HANDLER_BODY \
- \
-/* Respond to SIGWINCH `window size changed' signal, and reset GDB's \
- window settings approproatelt. */ \
- \
-void \
-aix_resizewindow () \
-{ \
- int fd = fileno (stdout); \
- if (isatty (fd)) { \
- int val; \
- \
- val = atoi (termdef (fd, 'l')); \
- if (val > 0) \
- lines_per_page = val; \
- val = atoi (termdef (fd, 'c')); \
- if (val > 0) \
- chars_per_line = val; \
- } \
-}
diff --git a/contrib/gdb/gdb/config/xm-lynx.h b/contrib/gdb/gdb/config/xm-lynx.h
deleted file mode 100644
index 6f19abd..0000000
--- a/contrib/gdb/gdb/config/xm-lynx.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Host-dependent definitions for any CPU running LynxOS.
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* for INT_MIN, to avoid "INT_MIN redefined" warnings from defs.h */
-
-#include <limits.h>
diff --git a/contrib/gdb/gdb/config/xm-mpw.h b/contrib/gdb/gdb/config/xm-mpw.h
deleted file mode 100644
index 0c473d7..0000000
--- a/contrib/gdb/gdb/config/xm-mpw.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Macro definitions for running GDB on Apple Macintoshes.
- Copyright (C) 1994, 1995 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "mpw.h"
-
-#include "fopen-bin.h"
-
-#include "spin.h"
-
-#define CANT_FORK
-
-/* Map these standard functions to versions that can do I/O in a console
- window. */
-
-#define printf hacked_printf
-#define fprintf hacked_fprintf
-#define vprintf hacked_vfprintf
-#define fputs hacked_fputs
-#define fputc hacked_fputc
-#undef putc
-#define putc hacked_putc
-#define fflush hacked_fflush
-
-#define fgetc hacked_fgetc
-
-#define POSIX_UTIME
-
-/* No declaration of strdup in MPW's string.h, oddly enough. */
-
-char *strdup (char *s1);
-
-/* '.' indicates drivers on the Mac, so we need a different filename. */
-
-#define GDBINIT_FILENAME "_gdbinit"
-
-/* Commas are more common to separate dirnames in a path on Macs. */
-
-#define DIRNAME_SEPARATOR ','
-
-/* This is a real crufty hack. */
-
-#define HAVE_TERMIO
-
-/* Addons to the basic MPW-supported signal list. */
-
-#ifndef SIGQUIT
-#define SIGQUIT (1<<6)
-#endif
-#ifndef SIGHUP
-#define SIGHUP (1<<7)
-#endif
-
-/* If __STDC__ is on, then this definition will be missing. */
-
-#ifndef fileno
-#define fileno(p) (p)->_file
-#endif
-
-#ifndef R_OK
-#define R_OK 4
-#endif
-
-extern int StandAlone;
-
-extern int mac_app;
diff --git a/contrib/gdb/gdb/config/xm-nbsd.h b/contrib/gdb/gdb/config/xm-nbsd.h
deleted file mode 100644
index 5d52270..0000000
--- a/contrib/gdb/gdb/config/xm-nbsd.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Host-dependent definitions for any CPU running NetBSD.
- Copyright 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* We have to include these files now, so that GDB will not make
- competing definitions in defs.h. */
-#include <limits.h>
-
-#include <machine/endian.h>
-#if BYTE_ORDER == BIG_ENDIAN
-#define HOST_BYTE_ORDER BIG_ENDIAN
-#else
-#define HOST_BYTE_ORDER LITTLE_ENDIAN
-#endif
-
-/* NetBSD has termios facilities. */
-#define HAVE_TERMIOS
-
-#if 0
-#define CC_HAS_LONG_LONG 1
-#define PRINTF_HAS_LONG_LONG 1
-#endif
diff --git a/contrib/gdb/gdb/config/xm-sysv4.h b/contrib/gdb/gdb/config/xm-sysv4.h
deleted file mode 100644
index 1ffe8fa..0000000
--- a/contrib/gdb/gdb/config/xm-sysv4.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Definitions for running gdb on a host machine running any flavor of SVR4.
- Copyright 1991, 1992 Free Software Foundation, Inc.
- Written by Fred Fish at Cygnus Support (fnf@cygnus.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* SVR4 has termios facilities. */
-
-#undef HAVE_TERMIO
-#define HAVE_TERMIOS
-
-/* SVR4 is a derivative of System V Release 3 (USG) */
-
-#define USG
-
-/* Use setpgid(0,0) to run inferior in a separate process group */
-
-#define NEED_POSIX_SETPGID
-
-/* We have to include these files now, so that GDB will not make
- competing definitions in defs.h. */
-#include <limits.h>
diff --git a/contrib/gdb/gdb/core-aout.c b/contrib/gdb/gdb/core-aout.c
index 3c1d499..ce3a95a 100644
--- a/contrib/gdb/gdb/core-aout.c
+++ b/contrib/gdb/gdb/core-aout.c
@@ -1,5 +1,5 @@
/* Extract registers from a "standard" core file, for GDB.
- Copyright (C) 1988-1998 Free Software Foundation, Inc.
+ Copyright (C) 1988-1995 Free Software Foundation, Inc.
This file is part of GDB.
@@ -23,15 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
more machine specific. */
#include "defs.h"
-
-#ifdef HAVE_PTRACE_H
-# include <ptrace.h>
-#else
-# ifdef HAVE_SYS_PTRACE_H
-# include <sys/ptrace.h>
-# endif
-#endif
-
#include <sys/types.h>
#include <sys/param.h>
#include "gdbcore.h"
@@ -40,10 +31,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* These are needed on various systems to expand REGISTER_U_ADDR. */
#ifndef USG
-#include <sys/dir.h>
#include <sys/file.h>
#include "gdb_stat.h"
#include <sys/user.h>
+#ifndef NO_PTRACE_H
+# ifdef PTRACE_IN_WRONG_PLACE
+# include <ptrace.h>
+# else /* !PTRACE_IN_WRONG_PLACE */
+# include <sys/ptrace.h>
+# endif /* !PTRACE_IN_WRONG_PLACE */
+#endif /* NO_PTRACE_H */
#endif
#ifndef CORE_REGISTER_ADDR
@@ -54,10 +51,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <sys/core.h>
#endif
-static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
-
-void _initialize_core_aout PARAMS ((void));
-
/* Extract the register values out of the core file and store
them where `read_register' will find them.
@@ -73,15 +66,15 @@ void _initialize_core_aout PARAMS ((void));
static void
fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr;
+ char *core_reg_sect;
+ unsigned core_reg_size;
+ int which;
+ CORE_ADDR reg_addr;
{
- int regno;
- CORE_ADDR addr;
+ register int regno;
+ register CORE_ADDR addr;
int bad_reg = -1;
- CORE_ADDR reg_ptr = -reg_addr; /* Original u.u_ar0 is -reg_addr. */
+ register CORE_ADDR reg_ptr = -reg_addr; /* Original u.u_ar0 is -reg_addr. */
int numregs = ARCH_NUM_REGS;
/* If u.u_ar0 was an absolute address in the core file, relativize it now,
@@ -96,15 +89,17 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
for (regno = 0; regno < numregs; regno++)
{
addr = CORE_REGISTER_ADDR (regno, reg_ptr);
- if (addr >= core_reg_size
- && bad_reg < 0)
- bad_reg = regno;
- else
- supply_register (regno, core_reg_sect + addr);
+ 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.", REGISTER_NAME (bad_reg));
+ {
+ error ("Register %s not found in core file.", reg_names[bad_reg]);
+ }
}
@@ -113,10 +108,10 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
/* Return the address in the core dump or inferior of register REGNO.
BLOCKEND is the address of the end of the user structure. */
-CORE_ADDR
+unsigned int
register_addr (regno, blockend)
int regno;
- CORE_ADDR blockend;
+ int blockend;
{
CORE_ADDR addr;
diff --git a/contrib/gdb/gdb/core-regset.c b/contrib/gdb/gdb/core-regset.c
index d925abe..68b0845 100644
--- a/contrib/gdb/gdb/core-regset.c
+++ b/contrib/gdb/gdb/core-regset.c
@@ -1,5 +1,5 @@
/* Machine independent GDB support for core files on systems using "regsets".
- Copyright 1993-1998 Free Software Foundation, Inc.
+ Copyright 1993-1996 Free Software Foundation, Inc.
This file is part of GDB.
@@ -47,10 +47,6 @@ regardless of whether or not the actual target has floating point hardware.
#include "command.h"
#include "gdbcore.h"
-static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
-
-void _initialize_core_regset PARAMS ((void));
-
/*
GLOBAL FUNCTION
@@ -61,7 +57,7 @@ SYNOPSIS
void fetch_core_registers (char *core_reg_sect,
unsigned core_reg_size,
- int which, CORE_ADDR reg_addr)
+ int which, unsigned in reg_addr)
DESCRIPTION
@@ -81,7 +77,7 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
char *core_reg_sect;
unsigned core_reg_size;
int which;
- CORE_ADDR reg_addr; /* Unused in this version */
+ unsigned int reg_addr; /* Unused in this version */
{
#if defined (HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T)
gregset_t gregset;
diff --git a/contrib/gdb/gdb/core-sol2.c b/contrib/gdb/gdb/core-sol2.c
deleted file mode 100644
index 3c69e63..0000000
--- a/contrib/gdb/gdb/core-sol2.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Machine independent support for Solaris 2 core files for GDB.
- Copyright 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-/* Solaris comes with two flavours of core files, cores generated by
- an ELF executable and cores generated by programs that were
- run under BCP (the part of Solaris which allows it to run SunOS4
- a.out files).
- This file combines the core register fetching from core-regset.c
- and sparc-nat.c to be able to read both flavours. */
-
-#include "defs.h"
-#include <time.h>
-#include <sys/types.h>
-#include <sys/regset.h>
-#include <sys/procfs.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "gdb_string.h"
-
-#include "inferior.h"
-#include "target.h"
-#include "command.h"
-#include "gdbcore.h"
-
-static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
-
-static void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr; /* Unused in this version */
-{
- prgregset_t prgregset;
- prfpregset_t prfpregset;
-
- if (which == 0)
- {
- if (core_reg_size == sizeof (prgregset))
- {
- memcpy ((char *) &prgregset, core_reg_sect, sizeof (prgregset));
- supply_gregset (&prgregset);
- }
- else if (core_reg_size == sizeof (struct regs))
- {
-#define gregs ((struct regs *)core_reg_sect)
- /* G0 *always* holds 0. */
- *(int *)&registers[REGISTER_BYTE (0)] = 0;
-
- /* The globals and output registers. */
- memcpy (&registers[REGISTER_BYTE (G1_REGNUM)], &gregs->r_g1,
- 15 * REGISTER_RAW_SIZE (G1_REGNUM));
- *(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps;
- *(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc;
- *(int *)&registers[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc;
- *(int *)&registers[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 *)&registers[REGISTER_BYTE (SP_REGNUM)];
- if (0 != target_read_memory (sp,
- &registers[REGISTER_BYTE (L0_REGNUM)],
- 16 * REGISTER_RAW_SIZE (L0_REGNUM)))
- {
- warning ("couldn't read input and local registers from core file\n");
- }
- }
- }
- else
- {
- warning ("wrong size gregset struct in core file");
- }
- }
- else if (which == 2)
- {
- if (core_reg_size == sizeof (prfpregset))
- {
- memcpy ((char *) &prfpregset, core_reg_sect, sizeof (prfpregset));
- supply_fpregset (&prfpregset);
- }
- else if (core_reg_size >= sizeof (struct fpu))
- {
-#define fpuregs ((struct fpu *) core_reg_sect)
- memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &fpuregs->fpu_fr,
- sizeof (fpuregs->fpu_fr));
- memcpy (&registers[REGISTER_BYTE (FPS_REGNUM)], &fpuregs->fpu_fsr,
- sizeof (FPU_FSR_TYPE));
- }
- else
- {
- warning ("wrong size fpregset struct in core file");
- }
- }
-}
-
-
-/* Register that we are able to handle solaris core file formats. */
-
-static struct core_fns solaris_core_fns =
-{
- bfd_target_elf_flavour,
- fetch_core_registers,
- NULL
-};
-
-void
-_initialize_core_solaris ()
-{
- add_core_fns (&solaris_core_fns);
-}
diff --git a/contrib/gdb/gdb/cpu32bug-rom.c b/contrib/gdb/gdb/cpu32bug-rom.c
deleted file mode 100644
index 758c8ca..0000000
--- a/contrib/gdb/gdb/cpu32bug-rom.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* Remote debugging interface for CPU32Bug Rom monitor for GDB, the GNU debugger.
- Copyright 1995 Free Software Foundation, Inc.
-
- Written by Stu Grossman of Cygnus Support
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "monitor.h"
-#include "serial.h"
-
-static void cpu32bug_open PARAMS ((char *args, int from_tty));
-
-static void
-cpu32bug_supply_register (regname, regnamelen, val, vallen)
- char *regname;
- int regnamelen;
- char *val;
- int vallen;
-{
- int regno;
-
- if (regnamelen != 2)
- return;
-
- switch (regname[0])
- {
- case 'S':
- if (regname[1] != 'R')
- return;
- regno = PS_REGNUM;
- break;
- case 'P':
- if (regname[1] != 'C')
- return;
- regno = PC_REGNUM;
- break;
- case 'D':
- if (regname[1] < '0' || regname[1] > '7')
- return;
- regno = regname[1] - '0' + D0_REGNUM;
- break;
- case 'A':
- if (regname[1] < '0' || regname[1] > '7')
- return;
- regno = regname[1] - '0' + A0_REGNUM;
- break;
- default:
- return;
- }
-
- monitor_supply_register (regno, val);
-}
-
-/*
- * This array of registers needs to match the indexes used by GDB. The
- * whole reason this exists is because the various ROM monitors use
- * different names than GDB does, and don't support all the
- * registers either. So, typing "info reg sp" becomes an "A7".
- */
-
-static char *cpu32bug_regnames[NUM_REGS] =
-{
- "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
- "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
- "SR", "PC",
-};
-
-/*
- * Define the monitor command strings. Since these are passed directly
- * through to a printf style function, we need can include formatting
- * strings. We also need a CR or LF on the end.
- */
-
-static struct target_ops cpu32bug_ops;
-
-static char *cpu32bug_inits[] = {"\r", NULL};
-
-static struct monitor_ops cpu32bug_cmds ;
-
-static void
-init_cpu32bug_cmds(void)
-{
- cpu32bug_cmds.flags = MO_CLR_BREAK_USES_ADDR;
- cpu32bug_cmds.init = cpu32bug_inits; /* Init strings */
- cpu32bug_cmds.cont = "g\r"; /* continue command */
- cpu32bug_cmds.step = "t\r"; /* single step */
- cpu32bug_cmds.stop = NULL; /* interrupt command */
- cpu32bug_cmds.set_break = "br %x\r"; /* set a breakpoint */
- cpu32bug_cmds.clr_break = "nobr %x\r"; /* clear a breakpoint */
- cpu32bug_cmds.clr_all_break = "nobr\r"; /* clear all breakpoints */
- cpu32bug_cmds.fill = "bf %x:%x %x;b\r"; /* fill (start count val) */
- cpu32bug_cmds.setmem.cmdb = "ms %x %02x\r"; /* setmem.cmdb (addr, value) */
- cpu32bug_cmds.setmem.cmdw = "ms %x %04x\r"; /* setmem.cmdw (addr, value) */
- cpu32bug_cmds.setmem.cmdl = "ms %x %08x\r"; /* setmem.cmdl (addr, value) */
- cpu32bug_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
- cpu32bug_cmds.setmem.resp_delim = NULL; /* setreg.resp_delim */
- cpu32bug_cmds.setmem.term = NULL; /* setreg.term */
- cpu32bug_cmds.setmem.term_cmd = NULL; /* setreg.term_cmd */
- cpu32bug_cmds.getmem.cmdb = "md %x:%x;b\r"; /* getmem.cmdb (addr, len) */
- cpu32bug_cmds.getmem.cmdw = "md %x:%x;b\r"; /* getmem.cmdw (addr, len) */
- cpu32bug_cmds.getmem.cmdl = "md %x:%x;b\r"; /* getmem.cmdl (addr, len) */
- cpu32bug_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */
- cpu32bug_cmds.getmem.resp_delim = " "; /* getmem.resp_delim */
- cpu32bug_cmds.getmem.term = NULL; /* getmem.term */
- cpu32bug_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
- cpu32bug_cmds.setreg.cmd = "rs %s %x\r"; /* setreg.cmd (name, value) */
- cpu32bug_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */
- cpu32bug_cmds.setreg.term = NULL; /* setreg.term */
- cpu32bug_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
- cpu32bug_cmds.getreg.cmd = "rs %s\r"; /* getreg.cmd (name) */
- cpu32bug_cmds.getreg.resp_delim = "="; /* getreg.resp_delim */
- cpu32bug_cmds.getreg.term = NULL; /* getreg.term */
- cpu32bug_cmds.getreg.term_cmd = NULL ; /* getreg.term_cmd */
- cpu32bug_cmds.dump_registers = "rd\r"; /* dump_registers */
- cpu32bug_cmds.register_pattern = "\\(\\w+\\) +=\\([0-9a-fA-F]+\\b\\)"; /* register_pattern */
- cpu32bug_cmds.supply_register = cpu32bug_supply_register; /* supply_register */
- cpu32bug_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
- cpu32bug_cmds.load = "lo\r"; /* download command */
- cpu32bug_cmds.loadresp = "\n"; /* load response */
- cpu32bug_cmds.prompt = "CPU32Bug>"; /* monitor command prompt */
- cpu32bug_cmds.line_term = "\r"; /* end-of-line terminator */
- cpu32bug_cmds.cmd_end = NULL; /* optional command terminator */
- cpu32bug_cmds.target = &cpu32bug_ops; /* target operations */
- cpu32bug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- cpu32bug_cmds.regnames = cpu32bug_regnames; /* registers names */
- cpu32bug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
-}; /* init_cpu32bug_cmds */
-
-static void
-cpu32bug_open(args, from_tty)
- char *args;
- int from_tty;
-{
- monitor_open (args, &cpu32bug_cmds, from_tty);
-}
-
-void
-_initialize_cpu32bug_rom ()
-{
- init_cpu32bug_cmds() ;
- init_monitor_ops (&cpu32bug_ops);
-
- cpu32bug_ops.to_shortname = "cpu32bug";
- cpu32bug_ops.to_longname = "CPU32Bug monitor";
- cpu32bug_ops.to_doc = "Debug via the CPU32Bug monitor.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
- cpu32bug_ops.to_open = cpu32bug_open;
-
- add_target (&cpu32bug_ops);
-}
diff --git a/contrib/gdb/gdb/cxux-nat.c b/contrib/gdb/gdb/cxux-nat.c
deleted file mode 100644
index 2c4b6f1..0000000
--- a/contrib/gdb/gdb/cxux-nat.c
+++ /dev/null
@@ -1,523 +0,0 @@
-/* Native support for Motorola 88k running Harris CX/UX.
- Copyright 1988, 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include "gdbcore.h"
-#include <sys/user.h>
-
-#include "bfd.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "symtab.h"
-
-#ifndef USER /* added to support BCS ptrace_user */
-#define USER ptrace_user
-#endif
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-#include "symtab.h"
-#include "setjmp.h"
-#include "value.h"
-
-#include <sys/ptrace.h>
-
-/* CX/UX provides them already, but as word offsets instead of char offsets */
-#define SXIP_OFFSET (PT_SXIP * 4)
-#define SNIP_OFFSET (PT_SNIP * 4)
-#define SFIP_OFFSET (PT_SFIP * 4)
-#define PSR_OFFSET (PT_PSR * sizeof(int))
-#define FPSR_OFFSET (PT_FPSR * sizeof(int))
-#define FPCR_OFFSET (PT_FPCR * sizeof(int))
-
-#define XREGADDR(r) (((char *)&u.pt_x0-(char *)&u) + \
- ((r)-X0_REGNUM)*sizeof(X_REGISTER_RAW_TYPE))
-
-extern int have_symbol_file_p();
-
-extern jmp_buf stack_jmp;
-
-extern int errno;
-extern char registers[REGISTER_BYTES];
-
-void
-fetch_inferior_registers (regno)
- int regno; /* Original value discarded */
-{
- 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, (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
- for (regno = 0; regno < PC_REGNUM; 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,
- (PTRACE_ARG3_TYPE) regaddr, 0);
- regaddr += sizeof (int);
- }
- supply_register (regno, buf);
- }
- /* now load up registers 32-37; special pc registers */
- *(int *) &buf[0] = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) PSR_OFFSET,0);
- supply_register (PSR_REGNUM, buf);
- *(int *) &buf[0] = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) FPSR_OFFSET,0);
- supply_register (FPSR_REGNUM, buf);
- *(int *) &buf[0] = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) FPCR_OFFSET,0);
- supply_register (FPCR_REGNUM, buf);
- *(int *) &buf[0] = ptrace (3,inferior_pid,
- (PTRACE_ARG3_TYPE) SXIP_OFFSET ,0);
- supply_register (SXIP_REGNUM, buf);
- *(int *) &buf[0] = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) SNIP_OFFSET,0);
- supply_register (SNIP_REGNUM, buf);
- *(int *) &buf[0] = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) SFIP_OFFSET,0);
- supply_register (SFIP_REGNUM, buf);
-
- if (target_is_m88110)
- {
- for (regaddr = XREGADDR(X0_REGNUM), regno = X0_REGNUM;
- regno < NUM_REGS;
- regno++, regaddr += 16)
- {
- X_REGISTER_RAW_TYPE xval;
-
- *(int *) &xval.w1 = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) regaddr, 0);
- *(int *) &xval.w2 = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) (regaddr+4), 0);
- *(int *) &xval.w3 = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) (regaddr+8), 0);
- *(int *) &xval.w4 = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) (regaddr+12), 0);
- supply_register(regno, (void *)&xval);
- }
- }
-}
-
-/* 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];
-
- struct USER u;
-
- unsigned int offset = (char *) &u.pt_r0 - (char *) &u;
-
- regaddr = offset;
-
- /* Don't try to deal with EXIP_REGNUM or ENIP_REGNUM, because I think either
- svr3 doesn't run on an 88110, or the kernel isolates the different (not
- completely sure this is true, but seems to be. */
- if (regno >= 0)
- {
- /* regaddr = register_addr (regno, offset); */
- if (regno < PC_REGNUM)
- {
- regaddr = offset + regno * sizeof (int);
- errno = 0;
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) regaddr, read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
- else if (regno == PSR_REGNUM)
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) PSR_OFFSET, read_register(regno));
- else if (regno == FPSR_REGNUM)
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) FPSR_OFFSET, read_register(regno));
- else if (regno == FPCR_REGNUM)
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) FPCR_OFFSET, read_register(regno));
- else if (regno == SXIP_REGNUM)
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) SXIP_OFFSET, read_register(regno));
- else if (regno == SNIP_REGNUM)
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) SNIP_OFFSET, read_register(regno));
- else if (regno == SFIP_REGNUM)
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) SFIP_OFFSET, read_register(regno));
- else if (target_is_m88110 && regno < NUM_REGS)
- {
- X_REGISTER_RAW_TYPE xval;
-
- read_register_bytes(REGISTER_BYTE(regno), (char *)&xval,
- sizeof(X_REGISTER_RAW_TYPE));
- regaddr = XREGADDR(regno);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, xval.w1);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr+4, xval.w2);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr+8, xval.w3);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr+12, xval.w4);
- }
- else
- printf_unfiltered ("Bad register number for store_inferior routine\n");
- }
- else
- {
- for (regno = 0; regno < PC_REGNUM; regno++)
- {
- /* regaddr = register_addr (regno, offset); */
- errno = 0;
- regaddr = offset + regno * sizeof (int);
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) regaddr, read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) PSR_OFFSET, read_register(regno));
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) FPSR_OFFSET,read_register(regno));
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) FPCR_OFFSET,read_register(regno));
- ptrace (6,inferior_pid,
- (PTRACE_ARG3_TYPE) SXIP_OFFSET,read_register(SXIP_REGNUM));
- ptrace (6,inferior_pid,
- (PTRACE_ARG3_TYPE) SNIP_OFFSET,read_register(SNIP_REGNUM));
- ptrace (6,inferior_pid,
- (PTRACE_ARG3_TYPE) SFIP_OFFSET,read_register(SFIP_REGNUM));
- if (target_is_m88110)
- {
- for (regno = X0_REGNUM; regno < NUM_REGS; regno++)
- {
- X_REGISTER_RAW_TYPE xval;
-
- read_register_bytes(REGISTER_BYTE(regno), (char *)&xval,
- sizeof(X_REGISTER_RAW_TYPE));
- regaddr = XREGADDR(regno);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, xval.w1);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr+4), xval.w2);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr+8), xval.w3);
- ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr+12), xval.w4);
- }
- }
- }
-}
-
-/* blockend is the address of the end of the user structure */
-
-m88k_register_u_addr (blockend, regnum)
- int blockend, regnum;
-{
- struct USER u;
- int ustart = blockend - sizeof (struct USER);
-
- if (regnum < PSR_REGNUM)
- return (ustart + ((int) &u.pt_r0 - (int) &u) +
- REGISTER_SIZE * regnum);
- else if (regnum == PSR_REGNUM)
- return (ustart + ((int) &u.pt_psr) - (int) &u);
- else if (regnum == FPSR_REGNUM)
- return (ustart + ((int) &u.pt_fpsr) - (int) &u);
- else if (regnum == FPCR_REGNUM)
- return (ustart + ((int) &u.pt_fpcr) - (int) &u);
- else if (regnum == SXIP_REGNUM)
- return (ustart + SXIP_OFFSET);
- else if (regnum == SNIP_REGNUM)
- return (ustart + SNIP_OFFSET);
- else if (regnum == SFIP_REGNUM)
- return (ustart + SFIP_OFFSET);
- else if (target_is_m88110)
- return (ustart + ((int) &u.pt_x0 - (int) &u) + /* Must be X register */
- sizeof(u.pt_x0) * (regnum - X0_REGNUM));
- else
- return (blockend + REGISTER_SIZE * regnum);
-}
-
-#ifdef USE_PROC_FS
-
-#include <sys/procfs.h>
-
-/* 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 regi;
- register greg_t *regp = (greg_t *) gregsetp;
-
- for (regi=0; regi <= SP_REGNUM; regi++)
- supply_register (regi, (char *) (regp + regi));
-
- supply_register (SXIP_REGNUM, (char *) (regp + R_XIP));
- supply_register (SNIP_REGNUM, (char *) (regp + R_NIP));
- supply_register (SFIP_REGNUM, (char *) (regp + R_FIP));
- supply_register (PSR_REGNUM, (char *) (regp + R_PSR));
- supply_register (FPSR_REGNUM, (char *) (regp + R_FPSR));
- supply_register (FPCR_REGNUM, (char *) (regp + R_FPCR));
-}
-
-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_R31 ; regi++)
- if ((regno == -1) || (regno == regi))
- *(regp + regi) = *(int *) &registers[REGISTER_BYTE(regi)];
-
- if ((regno == -1) || (regno == SXIP_REGNUM))
- *(regp + R_XIP) = *(int *) &registers[REGISTER_BYTE(SXIP_REGNUM)];
- if ((regno == -1) || (regno == SNIP_REGNUM))
- *(regp + R_NIP) = *(int *) &registers[REGISTER_BYTE(SNIP_REGNUM)];
- if ((regno == -1) || (regno == SFIP_REGNUM))
- *(regp + R_FIP) = *(int *) &registers[REGISTER_BYTE(SFIP_REGNUM)];
- if ((regno == -1) || (regno == PSR_REGNUM))
- *(regp + R_PSR) = *(int *) &registers[REGISTER_BYTE(PSR_REGNUM)];
- if ((regno == -1) || (regno == FPSR_REGNUM))
- *(regp + R_FPSR) = *(int *) &registers[REGISTER_BYTE(FPSR_REGNUM)];
- if ((regno == -1) || (regno == FPCR_REGNUM))
- *(regp + R_FPCR) = *(int *) &registers[REGISTER_BYTE(FPCR_REGNUM)];
-}
-
-#endif /* USE_PROC_FS */
-
-/* This support adds the equivalent of adb's % command. When
- the `add-shared-symbol-files' command is given, this routine scans
- the dynamic linker's link map and reads the minimal symbols
- from each shared object file listed in the map. */
-
-struct link_map {
- unsigned long l_addr; /* address at which object is mapped */
- char *l_name; /* full name of loaded object */
- void *l_ld; /* dynamic structure of object */
- struct link_map *l_next; /* next link object */
- struct link_map *l_prev; /* previous link object */
-};
-
-#define LINKS_MAP_POINTER "_ld_tail"
-#define LIBC_FILE "/usr/lib/libc.so.1"
-#define SHARED_OFFSET 0xf0001000
-
-#ifndef PATH_MAX
-#define PATH_MAX 1023 /* maximum size of path name on OS */
-#endif
-
-void
-add_shared_symbol_files ()
-{
- void *desc;
- struct link_map *ld_map, *lm, lms;
- struct minimal_symbol *minsym;
- struct objfile *objfile;
- char *path_name;
-
- if (! inferior_pid)
- {
- warning ("The program has not yet been started.");
- return;
- }
-
- objfile = symbol_file_add (LIBC_FILE, 0, 0, 0, 0, 1, 0, 0);
- minsym = lookup_minimal_symbol (LINKS_MAP_POINTER, objfile);
-
- ld_map = (struct link_map *)
- read_memory_integer (((int)SYMBOL_VALUE_ADDRESS(minsym) + SHARED_OFFSET), 4);
- lm = ld_map;
- while (lm)
- {
- int local_errno = 0;
-
- read_memory ((CORE_ADDR)lm, (char*)&lms, sizeof (struct link_map));
- if (lms.l_name)
- {
- if (target_read_string ((CORE_ADDR)lms.l_name, &path_name,
- PATH_MAX, &local_errno))
- {
- symbol_file_add (path_name, 1, lms.l_addr, 0, 0, 0, 0, 0);
- free(path_name);
- }
- }
- /* traverse links in reverse order so that we get the
- the symbols the user actually gets. */
- lm = lms.l_prev;
- }
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- reinit_frame_cache ();
-}
-
-#if defined(_ES_MP)
-
-#include <sys/regset.h>
-
-unsigned int
-m88k_harris_core_register_addr (regno, reg_ptr)
- int regno, reg_ptr;
-{
- unsigned int word_offset;
-
- switch (regno)
- {
- case PSR_REGNUM:
- word_offset = R_EPSR;
- break;
- case FPSR_REGNUM:
- word_offset = R_FPSR;
- break;
- case FPCR_REGNUM:
- word_offset = R_FPCR;
- break;
- case SXIP_REGNUM:
- word_offset = R_EXIP;
- break;
- case SNIP_REGNUM:
- word_offset = R_ENIP;
- break;
- case SFIP_REGNUM:
- word_offset = R_EFIP;
- break;
- default:
- if (regno <= FP_REGNUM)
- word_offset = regno;
- else
- word_offset = ((regno - X0_REGNUM) * 4);
- }
- return (word_offset * 4);
-}
-
-#endif /* _ES_MP */
-
-void
-_initialize_m88k_nat()
-{
-#ifdef _ES_MP
- /* Enable 88110 support, as we don't support the 88100 under ES/MP. */
-
- target_is_m88110 = 1;
-#elif defined(_CX_UX)
- /* Determine whether we're running on an 88100 or an 88110. */
- target_is_m88110 = (sinfo(SYSMACHINE,0) == SYS5800);
-#endif /* _CX_UX */
-}
-
-#ifdef _ES_MP
-/* 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 regi;
- register greg_t *regp = (greg_t *) gregsetp;
-
- for (regi = 0 ; regi < R_R31 ; regi++)
- {
- supply_register (regi, (char *) (regp + regi));
- }
- supply_register (PSR_REGNUM, (char *) (regp + R_EPSR));
- supply_register (FPSR_REGNUM, (char *) (regp + R_FPSR));
- supply_register (FPCR_REGNUM, (char *) (regp + R_FPCR));
- supply_register (SXIP_REGNUM, (char *) (regp + R_EXIP));
- supply_register (SNIP_REGNUM, (char *) (regp + R_ENIP));
- supply_register (SFIP_REGNUM, (char *) (regp + R_EFIP));
-}
-
-/* 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 regi;
- char *from;
-
- for (regi = FP0_REGNUM ; regi <= FPLAST_REGNUM ; regi++)
- {
- from = (char *) &((*fpregsetp)[regi-FP0_REGNUM]);
- supply_register (regi, from);
- }
-}
-
-#endif /* _ES_MP */
-
-#ifdef _CX_UX
-
-#include <sys/regset.h>
-
-unsigned int m88k_harris_core_register_addr(int regno, int reg_ptr)
-{
- unsigned int word_offset;
-
- switch (regno) {
- case PSR_REGNUM : word_offset = R_PSR; break;
- case FPSR_REGNUM : word_offset = R_FPSR; break;
- case FPCR_REGNUM : word_offset = R_FPCR; break;
- case SXIP_REGNUM : word_offset = R_XIP; break;
- case SNIP_REGNUM : word_offset = R_NIP; break;
- case SFIP_REGNUM : word_offset = R_FIP; break;
- default :
- if (regno <= FP_REGNUM)
- word_offset = regno;
- else
- word_offset = ((regno - X0_REGNUM) * 4) + R_X0;
- }
- return (word_offset * 4);
-}
-
-#endif /* _CX_UX */
diff --git a/contrib/gdb/gdb/doc/gdb.texinfo b/contrib/gdb/gdb/doc/gdb.texinfo
index fc920bb..1bde79c 100644
--- a/contrib/gdb/gdb/doc/gdb.texinfo
+++ b/contrib/gdb/gdb/doc/gdb.texinfo
@@ -1,5 +1,5 @@
\input texinfo @c -*-texinfo-*-
-@c Copyright 1988-1999
+@c Copyright 1988 1989 1990 1991 1992 1993 1994 1995
@c Free Software Foundation, Inc.
@c
@c %**start of header
@@ -15,6 +15,7 @@
@ifclear GENERIC
@settitle Debugging with @value{GDBN} (@value{TARGET})
@end ifclear
+@clear RENAMED
@setchapternewpage odd
@c %**end of header
@@ -30,10 +31,14 @@
@syncodeindex vr cp
@c !!set GDB manual's edition---not the same as GDB version!
-@set EDITION Seventh
+@set EDITION 4.12
@c !!set GDB manual's revision date
-@set DATE February 1999
+@set DATE January 1994
+
+@c 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)
@c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly.
@@ -42,7 +47,7 @@
@c manuals to an info tree. zoo@cygnus.com is developing this facility.
@format
START-INFO-DIR-ENTRY
-* Gdb: (gdb). The @sc{gnu} debugger.
+* Gdb: (gdb). The @sc{gnu} debugger.
END-INFO-DIR-ENTRY
@end format
@end ifinfo
@@ -52,11 +57,12 @@ END-INFO-DIR-ENTRY
This file documents the @sc{gnu} debugger @value{GDBN}.
-This is the @value{EDITION} Edition, @value{DATE},
+This is Edition @value{EDITION}, @value{DATE},
of @cite{Debugging with @value{GDBN}: the @sc{gnu} Source-Level Debugger}
for @value{GDBN} Version @value{GDBVN}.
-Copyright (C) 1988-1999 Free Software Foundation, Inc.
+Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
+Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -85,45 +91,28 @@ into another language, under the above conditions for modified versions.
@subtitle (@value{TARGET})
@end ifclear
@sp 1
-@ifclear HPPA
-@subtitle @value{EDITION} Edition, for @value{GDBN} version @value{GDBVN}
-@subtitle @value{DATE}
-@author Richard M. Stallman and Roland H. Pesch
-@end ifclear
-@ifset HPPA
-@subtitle Edition @value{EDITION}, for @value{HPVER} (based on @value{GDBN} @value{GDBVN})
+@subtitle Edition @value{EDITION}, for @value{GDBN} version @value{GDBVN}
@subtitle @value{DATE}
-@author Richard M. Stallman and Roland H. Pesch (modified by HP)
-@end ifset
+@author Richard M. Stallman and Cygnus Support
@page
-@ifclear HPPA
@tex
{\parskip=0pt
\hfill (Send bugs and comments on @value{GDBN} to bug-gdb\@prep.ai.mit.edu.)\par
\hfill {\it Debugging with @value{GDBN}}\par
\hfill \TeX{}info \texinfoversion\par
+\hfill doc\@cygnus.com\par
}
@end tex
-@end ifclear
-@ifset HPPA
-@tex
-{\parskip=0pt
-\hfill {\it Debugging with @value{GDBN}}\par
-\hfill \TeX{}info \texinfoversion\par
-}
-@end tex
-@end ifset
@vskip 0pt plus 1filll
-Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
+Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
+Free Software Foundation, Inc.
@sp 2
-@ifclear HPPA
Published by the Free Software Foundation @*
59 Temple Place - Suite 330, @*
Boston, MA 02111-1307 USA @*
Printed copies are available for $20 each. @*
ISBN 1-882114-11-6 @*
-@end ifclear
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -140,15 +129,14 @@ into another language, under the above conditions for modified versions.
@page
@ifinfo
-@node Top, Summary, (dir), (dir)
+@node Top
@top Debugging with @value{GDBN}
This file describes @value{GDBN}, the @sc{gnu} symbolic debugger.
-This is the @value{EDITION} Edition, @value{DATE}, for @value{GDBN} Version
+This is Edition @value{EDITION}, @value{DATE}, for @value{GDBN} Version
@value{GDBVN}.
-Copyright (C) 1988-1999 Free Software Foundation, Inc.
@menu
* Summary:: Summary of @value{GDBN}
@ifclear BARETARGET
@@ -165,10 +153,10 @@ Copyright (C) 1988-1999 Free Software Foundation, Inc.
@ifclear CONLY
* Languages:: Using @value{GDBN} with different languages
@end ifclear
-
@ifset CONLY
* C:: C language support
@end ifset
+@c remnant makeinfo bug, blank line needed after two end-ifs?
* Symbols:: Examining the symbol table
* Altering:: Altering execution
@@ -181,269 +169,21 @@ Copyright (C) 1988-1999 Free Software Foundation, Inc.
@end ifclear
* GDB Bugs:: Reporting bugs in @value{GDBN}
-
+* Command Line Editing:: Facilities of the readline library
+* Using History Interactively::
+@c @ifset NOVEL
+@c * Renamed Commands::
+@c @end ifset
@ifclear PRECONFIGURED
-@ifclear HPPA
* Formatting Documentation:: How to format and print @value{GDBN} documentation
-@end ifclear
-
-@end ifclear
-
-* Command Line Editing:: Command Line Editing
-* Using History Interactively:: Using History Interactively
* Installing GDB:: Installing GDB
-* Index:: Index
-
- --- The Detailed Node Listing ---
-
-Summary of @value{GDBN}
-
-* Free Software:: Freely redistributable software
-* Contributors:: Contributors to GDB
-
-Getting In and Out of @value{GDBN}
-
-* Invoking GDB:: How to start @value{GDBN}
-* Quitting GDB:: How to quit @value{GDBN}
-* Shell Commands:: How to use shell commands inside @value{GDBN}
-
-Invoking @value{GDBN}
-
-* File Options:: Choosing files
-* Mode Options:: Choosing modes
-
-@value{GDBN} Commands
-
-* Command Syntax:: How to give commands to @value{GDBN}
-* Completion:: Command completion
-* Help:: How to ask @value{GDBN} for help
-
-Running Programs Under @value{GDBN}
-
-* Compilation:: Compiling for debugging
-* Starting:: Starting your program
-@ifclear BARETARGET
-* Arguments:: Your program's arguments
-* Environment:: Your program's environment
-@end ifclear
-
-* 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
-@ifclear HPPA
-* Process Information:: Additional process information
@end ifclear
-* Threads:: Debugging programs with multiple threads
-* Processes:: Debugging programs with multiple processes
-
-Stopping and Continuing
-
-* Breakpoints:: Breakpoints, watchpoints, and catchpoints
-* Continuing and Stepping:: Resuming execution
-@ifset POSIX
-* Signals:: Signals
-@end ifset
-@ifclear BARETARGET
-* Thread Stops:: Stopping and starting multi-thread programs
-@end ifclear
-
-Breakpoints and watchpoints
-
-* Set Breaks:: Setting breakpoints
-* Set Watchpoints:: Setting watchpoints
-* Set Catchpoints:: Setting catchpoints
-* Delete Breaks:: Deleting breakpoints
-* Disabling:: Disabling breakpoints
-* Conditions:: Break conditions
-* Break Commands:: Breakpoint command lists
-@ifclear CONLY
-* Breakpoint Menus:: Breakpoint menus
-@end ifclear
-
-Examining the Stack
-
-* Frames:: Stack frames
-* Backtrace:: Backtraces
-* Selection:: Selecting a frame
-* Frame Info:: Information on a frame
-* Alpha/MIPS Stack:: Alpha and MIPS machines and the function stack
-
-Examining Source Files
-
-* List:: Printing source lines
-@ifclear DOSHOST
-* Search:: Searching source files
-@end ifclear
-* 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
-@ifclear HAVE-FLOAT
-* Floating Point Hardware:: Floating point hardware
-@end ifclear
-
-Using @value{GDBN} with Different Languages
-
-* Setting:: Switching between source languages
-* Show:: Displaying the language
-@ifset MOD2
-* Checks:: Type and range checks
-@end ifset
-
-* Support:: Supported languages
-
-Switching between source languages
-
-* Filenames:: Filename extensions and languages.
-* Manually:: Setting the working language manually
-* Automatically:: Having @value{GDBN} infer the source language
-
-@ifset MOD2
-Type and range checking
-
-* Type Checking:: An overview of type checking
-* Range Checking:: An overview of range checking
-@end ifset
-
-Supported languages
-
-@ifset MOD2
-* C:: C and C++
-
-C Language Support
-
-* C Operators:: C operators
-
-C Language Support
-@end ifset
-
-* C Operators:: C and C++ operators
-* C Constants:: C and C++ constants
-* Cplus expressions:: C++ expressions
-* C Defaults:: Default settings for C and C++
-@ifset MOD2
-* C Checks:: C and C++ type and range checks
-@end ifset
-* Debugging C:: @value{GDBN} and C
-* Debugging C plus plus:: @value{GDBN} features for C++
-
-@ifset MOD2
-Modula-2
-
-* M2 Operators:: Built-in operators
-* Built-In 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:: @value{GDBN} and Modula-2
-@end ifset
-
-Altering Execution
-
-* Assignment:: Assignment to variables
-* Jumping:: Continuing at a different address
-@ifclear BARETARGET
-* Signaling:: Giving your program a signal
-@end ifclear
-* Returning:: Returning from a function
-* Calling:: Calling your program's functions
-* Patching:: Patching your program
-
-@value{GDBN} 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
-@ifclear HPPA
-* Byte Order:: Choosing target byte order
-* Remote:: Remote debugging
-
-Remote debugging
-@end ifclear
-
-@ifset REMOTESTUB
-* Remote Serial:: @value{GDBN} remote serial protocol
-@end ifset
-
-@ifset I960
-* i960-Nindy Remote:: @value{GDBN} with a remote i960 (Nindy)
-@end ifset
-
-@ifset AMD29K
-* UDI29K Remote:: The UDI protocol for AMD29K
-* EB29K Remote:: The EBMON protocol for AMD29K
-@end ifset
-
-@ifset VXWORKS
-* VxWorks Remote:: @value{GDBN} and VxWorks
-@end ifset
-
-@ifset ST2000
-* ST2000 Remote:: @value{GDBN} with a Tandem ST2000
-@end ifset
-
-@ifset H8
-* Hitachi Remote:: @value{GDBN} and Hitachi Microprocessors
-@end ifset
-
-@ifset MIPS
-* MIPS Remote:: @value{GDBN} and MIPS boards
-@end ifset
-
-@ifset SIMS
-* Simulator:: Simulated CPU target
-@end ifset
-
-Controlling @value{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
-* Hooks:: User-defined command hooks
-* Command Files:: Command files
-* Output:: Commands for controlled output
-
-Reporting Bugs in @value{GDBN}
-
-* Bug Criteria:: Have you found a bug?
-* Bug Reporting:: How to report bugs
-
-Installing @value{GDBN}
-
-* Separate Objdir:: Compiling @value{GDBN} in another directory
-* Config Names:: Specifying names for hosts and targets
-* Configure Options:: Summary of options for configure
+* Index:: Index
@end menu
-
@end ifinfo
-@node Summary, Sample Session, Top, Top
+@node Summary
@unnumbered Summary of @value{GDBN}
The purpose of a debugger such as @value{GDBN} is to allow you to see what is
@@ -484,8 +224,8 @@ see @ref{Modula-2,,Modula-2}. There is no further documentation on Chill yet.
Debugging Pascal programs which use sets, subranges, file variables, or nested
functions does not currently work. @value{GDBN} does not support
entering expressions, printing values, or similar features using Pascal syntax.
-@end ifset
+@end ifset
@ifset FORTRAN
@cindex Fortran
@value{GDBN} can be used to debug programs written in Fortran, although
@@ -495,21 +235,12 @@ some variables with a trailing underscore.
@end ifset
@end ifclear
-@ifset HPPA
-This version of the manual documents HP Wildebeest (WDB) Version 0.75,
-implemented on HP 9000 systems running Release 10.20, 10.30, or 11.0 of
-the HP-UX operating system. HP WDB 0.75 can be used to debug code
-generated by the HP ANSI C and HP ANSI C++ compilers as well as the
-@sc{gnu} C and C++ compilers. It does not support the debugging of
-Fortran, Modula-2, or Chill programs.
-@end ifset
-
@menu
* Free Software:: Freely redistributable software
* Contributors:: Contributors to GDB
@end menu
-@node Free Software, Contributors, Summary, Summary
+@node Free Software
@unnumberedsec Free software
@value{GDBN} is @dfn{free software}, protected by the @sc{gnu}
@@ -525,16 +256,16 @@ Fundamentally, the General Public License is a license which says that
you have these freedoms and that you cannot take these freedoms away
from anyone else.
-@node Contributors, , Free Software, Summary
+@node Contributors
@unnumberedsec Contributors to GDB
-Richard Stallman was the original author of GDB, and of many other
-@sc{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
+Richard Stallman was the original author of GDB, and of many other @sc{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 @value{GDBN} distribution approximates a
-blow-by-blow account.
+@file{ChangeLog} in the @value{GDBN} distribution approximates a blow-by-blow
+account.
Changes much prior to version 2.0 are lost in the mists of time.
@@ -544,17 +275,17 @@ or your friends (or enemies, to 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 many labors as thankless, we
-particularly thank those who shepherded @value{GDBN} through major
-releases:
-Jim Blandy (release 4.18);
-Jason Molenda (release 4.17);
-Stan Shebs (release 4.14);
-Fred Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, and 4.9);
-Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4);
+So that they may not regard their long labor as thankless, we
+particularly thank those who shepherded GDB through major releases:
+Stan Shebs (release 4.14),
+Fred Fish (releases 4.13, 4.12, 4.11, 4.10, and 4.9),
+Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4),
John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9);
Jim Kingdon (releases 3.5, 3.4, and 3.3);
and Randy Smith (releases 3.2, 3.1, and 3.0).
+As major maintainer of @value{GDBN} for some period, each
+contributed significantly to the structure, stability, and capabilities
+of the entire debugger.
Richard Stallman, assisted at various times by Peter TerMaat, Chris
Hanson, and Richard Mlynarik, handled releases through 2.8.
@@ -573,8 +304,6 @@ 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.
-Brent Benson of Harris Computer Systems contributed DWARF 2 support.
-
Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
support.
@@ -594,18 +323,15 @@ Tim Tucker contributed support for the Gould NP1 and Gould Powernode.
Pace Willison contributed Intel 386 support.
Jay Vosburgh contributed Symmetry support.
-Andreas Schwab contributed M68K Linux support.
-
Rich Schaefer and Peter Schauer helped with support of SunOS shared
libraries.
-Jay Fenlason and Roland McGrath ensured that @value{GDBN} and GAS agree
-about several machine instruction sets.
+Jay Fenlason and Roland McGrath ensured that @value{GDBN} and GAS agree about
+several machine instruction sets.
-Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop
-remote debugging. Intel Corporation, Wind River Systems, AMD, and ARM
-contributed remote debugging modules for the i960, VxWorks, A29K UDI,
-and RDI targets, respectively.
+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.
@@ -622,56 +348,18 @@ He also enhanced the command-completion support to cover C++ overloaded
symbols.
@end ifclear
-Hitachi America, Ltd. sponsored the support for H8/300, H8/500, and
-Super-H processors.
-
-NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx processors.
-
-Mitsubishi sponsored the support for D10V, D30V, and M32R/D processors.
-
-Toshiba sponsored the support for the TX39 Mips processor.
-
-Matsushita sponsored the support for the MN10200 and MN10300 processors.
-
-Fujitsu sponsored the support for SPARClite and FR30 processors
+Hitachi America, Ltd. sponsored the support for Hitachi microprocessors.
Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware
watchpoints.
-Michael Snyder added support for tracepoints.
-
Stu Grossman wrote gdbserver.
Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made
nearly innumerable bug fixes and cleanups throughout GDB.
-The following people at the Hewlett-Packard Company contributed
-support for the PA-RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0
-(narrow mode), HP's implementation of kernel threads, HP's aC++
-compiler, and the terminal user interface: Ben Krepp, Richard Title,
-John Bishop, Susan Macchia, Kathy Mann, Satish Pai, India Paul, Steve
-Rehrauer, and Elena Zannoni. Kim Haase provided HP-specific
-information in this manual.
-
-Cygnus Solutions has sponsored GDB maintenance and much of its
-development since 1991. Cygnus engineers who have worked on GDB
-fulltime include Mark Alexander, Jim Blandy, Per Bothner, Edith Epstein,
-Chris Faylor, Fred Fish, Martin Hunt, Jim Ingham, John Gilmore, Stu
-Grossman, Kung Hsu, Jim Kingdon, John Metzler, Fernando Nasser, Geoffrey
-Noer, Dawn Perchik, Rich Pixley, Zdenek Radouch, Keith Seitz, Stan
-Shebs, David Taylor, and Elena Zannoni. In addition, Dave Brolley, Ian
-Carmichael, Steve Chamberlain, Nick Clifton, JT Conklin, Stan Cox, DJ
-Delorie, Ulrich Drepper, Frank Eigler, Doug Evans, Sean Fagan, David
-Henkel-Wallace, Richard Henderson, Jeff Holcomb, Jeff Law, Jim Lemke,
-Tom Lord, Bob Manson, Michael Meissner, Jason Merrill, Catherine Moore,
-Drew Moseley, Ken Raeburn, Gavin Romig-Koch, Rob Savoye, Jamie Smith,
-Mike Stump, Ian Taylor, Angela Thomas, Michael Tiemann, Tom Tromey, Ron
-Unrau, Jim Wilson, and David Zuhn have made contributions both large
-and small.
-
-
@ifclear BARETARGET
-@node Sample Session, Invocation, Summary, Top
+@node Sample Session
@chapter A Sample @value{GDBN} Session
You can use this manual at your leisure to read all about @value{GDBN}.
@@ -718,7 +406,6 @@ m4: End of input: 0: fatal error: EOF in string
@noindent
Let us use @value{GDBN} to try to see what is going on.
-@ifclear HPPA
@smallexample
$ @b{@value{GDBP} m4}
@c FIXME: this falsifies the exact text played out, to permit smallbook
@@ -729,24 +416,9 @@ $ @b{@value{GDBP} m4}
There is absolutely no warranty for @value{GDBN}; type "show warranty"
for details.
-@value{GDBN} @value{GDBVN}, Copyright 1999 Free Software Foundation, Inc...
-(@value{GDBP})
-@end smallexample
-@end ifclear
-@ifset HPPA
-@smallexample
-$ @b{@value{GDBP} m4}
-Wildebeest 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 Wildebeest; type "show warranty"
-for details.
-
-Hewlett-Packard Wildebeest 0.75 (based on GDB 4.16)
-(built for PA-RISC 1.1 or 2.0, HP-UX 10.20)
-Copyright 1996, 1997 Free Software Foundation, Inc.
+@value{GDBN} @value{GDBVN}, Copyright 1995 Free Software Foundation, Inc...
(@value{GDBP})
@end smallexample
-@end ifset
@noindent
@value{GDBN} reads only enough symbol data to know where to find the
@@ -958,7 +630,7 @@ session with the @value{GDBN} @code{quit} command.
@end smallexample
@end ifclear
-@node Invocation, Commands, Sample Session, Top
+@node Invocation
@chapter Getting In and Out of @value{GDBN}
This chapter discusses how to start @value{GDBN}, and how to get out of it.
@@ -972,11 +644,11 @@ type @kbd{quit} or @kbd{C-d} to exit.
@menu
* Invoking GDB:: How to start @value{GDBN}
-* Quitting GDB:: How to quit @value{GDBN}
+* Quitting GDB:: How to quit @value{GDBN}
* Shell Commands:: How to use shell commands inside @value{GDBN}
@end menu
-@node Invoking GDB, Quitting GDB, Invocation, Invocation
+@node Invoking GDB
@section Invoking @value{GDBN}
@ifset H8EXCLUSIVE
@@ -1024,19 +696,17 @@ to debug a running process:
would attach @value{GDBN} to process @code{1234} (unless you also have a file
named @file{1234}; @value{GDBN} does check for a core file first).
-@ifclear HPPA
Taking advantage of the second command-line argument requires a fairly
complete operating system; when you use @value{GDBN} as a remote debugger
attached to a bare board, there may not be any notion of ``process'',
and there is often no way to get a core dump.
@end ifclear
-@end ifclear
You can run @code{gdb} without printing the front material, which describes
@value{GDBN}'s non-warranty, by specifying @code{-silent}:
@smallexample
-@value{GDBP} -silent
+@value{GDBP} @var{-silent}
@end smallexample
@noindent
@@ -1083,9 +753,6 @@ in sequential order. The order makes a difference when the
@ifset MIPS
* MIPS Remote:: @value{GDBN} and MIPS boards
@end ifset
-@ifset SPARCLET
-* Sparclet Remote:: @value{GDBN} and Sparclet boards
-@end ifset
@ifset SIMS
* Simulator:: Simulated CPU target
@end ifset
@@ -1097,10 +764,8 @@ in sequential order. The order makes a difference when the
@end menu
@ifclear GENERIC
-@ifclear HPPA
@include remote.texi
@end ifclear
-@end ifclear
@node File Options
@subsection Choosing files
@@ -1168,7 +833,6 @@ Files,, Command files}.
Add @var{directory} to the path to search for source files.
@ifclear BARETARGET
-@ifclear HPPA
@item -m
@itemx -mapped
@emph{Warning: this option depends on operating system facilities that are not
@@ -1186,32 +850,27 @@ The @file{.syms} file is specific to the host machine where @value{GDBN}
is run. It holds an exact image of the internal @value{GDBN} symbol
table. It cannot be shared across multiple host platforms.
@end ifclear
-@end ifclear
-@ifclear HPPA
@item -r
@itemx -readnow
Read each symbol file's entire symbol table immediately, rather than
the default, which is to read it incrementally as it is needed.
This makes startup slower, but makes future operations faster.
-@end ifclear
@end table
@ifclear BARETARGET
-@ifclear HPPA
The @code{-mapped} and @code{-readnow} options are typically combined in
order to build a @file{.syms} file that contains complete symbol
-information. (@xref{Files,,Commands to specify files}, for
-information on @file{.syms} files.) A simple GDB invocation to do
-nothing but build a @file{.syms} file for future use is:
+information. (@xref{Files,,Commands to specify files}, for information
+
+a @file{.syms} file for future use is:
@example
gdb -batch -nx -mapped -readnow programname
@end example
@end ifclear
-@end ifclear
-@node Mode Options, , File Options, Invoking GDB
+@node Mode Options
@subsection Choosing modes
You can run @value{GDBN} in various alternative modes---for example, in
@@ -1221,9 +880,9 @@ batch mode or quiet mode.
@item -nx
@itemx -n
Do not execute commands from any initialization files (normally called
-@file{.gdbinit}, or @file{gdb.ini} on PCs). Normally, the commands in
-these files are executed after all the command options and arguments
-have been processed. @xref{Command Files,,Command files}.
+@file{@value{GDBINIT}}). Normally, the commands in these files are
+executed after all the command options and arguments have been
+processed. @xref{Command Files,,Command files}.
@item -quiet
@itemx -q
@@ -1253,6 +912,16 @@ terminates) is not issued when running in batch mode.
Run @value{GDBN} using @var{directory} as its working directory,
instead of the current directory.
+@ifset LUCID
+@item -context @var{authentication}
+When the Energize programming system starts up @value{GDBN}, it uses this
+option to trigger an alternate mode of interaction.
+@var{authentication} is a pair of numeric codes that identify @value{GDBN}
+as a client in the Energize environment. Avoid this option when you run
+@value{GDBN} directly from the command line. See @ref{Energize,,Using
+@value{GDBN} with Energize} for more discussion of using @value{GDBN} with Energize.
+@end ifset
+
@ifclear DOSHOST
@item -fullname
@itemx -f
@@ -1267,34 +936,17 @@ a signal to display the source code for the frame.
@end ifclear
@ifset SERIAL
-@ifclear HPPA
@item -b @var{bps}
Set the line speed (baud rate or bits per second) of any serial
interface used by @value{GDBN} for remote debugging.
-@end ifclear
@item -tty @var{device}
Run using @var{device} for your program's standard input and output.
@c FIXME: kingdon thinks there is more to -tty. Investigate.
@end ifset
-
-@ifset HPPA
-@item -tui
-Use a Terminal User Interface. For information, use your Web browser to
-read the file @file{TUI.html}, which is usually installed in the
-directory @code{/opt/langtools/wdb/doc} on HP-UX systems. Do not use
-this option if you run @value{GDBN} from Emacs (see @pxref{Emacs, ,Using
-@value{GDBN} under @sc{gnu} Emacs}).
-
-@item -xdb
-Run in XDB compatibility mode, allowing the use of certain XDB commands.
-For information, see the file @file{xdb_trans.html}, which is usually
-installed in the directory @code{/opt/langtools/wdb/doc} on HP-UX
-systems.
-@end ifset
@end table
-@node Quitting GDB, Shell Commands, Invoking GDB, Invocation
+@node Quitting GDB
@section Quitting @value{GDBN}
@cindex exiting @value{GDBN}
@cindex leaving @value{GDBN}
@@ -1322,7 +974,7 @@ device, you can release it with the @code{detach} command
(@pxref{Attach, ,Debugging an already-running process}).
@end ifclear
-@node Shell Commands, , Quitting GDB, Invocation
+@node Shell Commands
@section Shell commands
If you need to execute occasional shell commands during your
@@ -1333,7 +985,7 @@ just use the @code{shell} command.
@kindex shell
@cindex shell escape
@item shell @var{command string}
-Invoke a standard shell to execute @var{command string}.
+Invoke a the standard shell to execute @var{command string}.
@ifclear DOSHOST
If it exists, the environment variable @code{SHELL} determines which
shell to run. Otherwise @value{GDBN} uses @code{/bin/sh}.
@@ -1352,7 +1004,7 @@ Execute the @code{make} program with the specified
arguments. This is equivalent to @samp{shell make @var{make-args}}.
@end table
-@node Commands, Running, Invocation, Top
+@node Commands
@chapter @value{GDBN} Commands
You can abbreviate a @value{GDBN} command to the first few letters of the command
@@ -1367,7 +1019,7 @@ show you the alternatives available, if there is more than one possibility).
* Help:: How to ask @value{GDBN} for help
@end menu
-@node Command Syntax, Completion, Commands, Commands
+@node Command Syntax
@section Command syntax
A @value{GDBN} command is a single line of input. There is no limit on
@@ -1410,7 +1062,7 @@ Any text from a @kbd{#} to the end of the line is a comment; it does
nothing. This is useful mainly in command files (@pxref{Command
Files,,Command files}).
-@node Completion, Help, Command Syntax, Commands
+@node Completion
@section Command completion
@cindex completion
@@ -1526,15 +1178,10 @@ place:
In general, @value{GDBN} can tell that a quote is needed (and inserts it) if
you have not yet started typing the argument list when you ask for
completion on an overloaded symbol.
-
-For more information about overloaded functions, @pxref{Cplus
-expressions, ,C++ expressions}. You can use the command @code{set
-overload-resolution off} to disable overload resolution;
-@pxref{Debugging C plus plus, ,@value{GDBN} features for C++}.
@end ifclear
-@node Help, , Completion, Commands
+@node Help
@section Getting help
@cindex online documentation
@kindex help
@@ -1612,11 +1259,9 @@ complete i
@noindent results in:
@smallexample
-@group
info
inspect
ignore
-@end group
@end smallexample
@noindent This is intended for use by @sc{gnu} Emacs.
@@ -1643,7 +1288,7 @@ You can get a complete list of the @code{info} sub-commands with
@kindex set
@item set
-You can assign the result of an expression to an environment variable with
+You can assign the result of an expresson to an environment variable with
@code{set}. For example, you can set the @value{GDBN} prompt to a $-sign with
@code{set prompt $}.
@@ -1689,7 +1334,7 @@ Display information about permission for copying @value{GDBN}.
Display the @sc{gnu} ``NO WARRANTY'' statement.
@end table
-@node Running, Stopping, Commands, Top
+@node Running
@chapter Running Programs Under @value{GDBN}
When you run a program under @value{GDBN}, you must first generate
@@ -1706,21 +1351,17 @@ already running process, or kill a child process.
@ifclear BARETARGET
* Arguments:: Your program's arguments
* Environment:: Your program's environment
-@end ifclear
-
* 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
-@ifclear HPPA
* Process Information:: Additional process information
-@end ifclear
-
-* Threads:: Debugging programs with multiple threads
+* Threads:: Debugging programs with multiple threads
* Processes:: Debugging programs with multiple processes
+@end ifclear
@end menu
-@node Compilation, Starting, Running, Running
+@node Compilation
@section Compiling for debugging
In order to debug a program effectively, you need to generate
@@ -1736,13 +1377,7 @@ 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.
-@ifclear HPPA
@value{NGCC}, the @sc{gnu} C compiler, supports @samp{-g} with or without
-@end ifclear
-@ifset HPPA
-The HP ANSI C and C++ compilers, as well as @value{NGCC}, the @sc{gnu} C
-compiler, support @samp{-g} with or without
-@end ifset
@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 your program is correct, but there is no sense in pushing
@@ -1767,7 +1402,7 @@ Older versions of the @sc{gnu} C compiler permitted a variant option
format; if your @sc{gnu} C compiler has this option, do not use it.
@need 2000
-@node Starting, Arguments, Compilation, Running
+@node Starting
@section Starting your program
@cindex starting
@cindex running
@@ -1806,10 +1441,9 @@ 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, ,Your program's arguments}.
+the arguments. In Unix systems, you can control which shell is used
+with the @code{SHELL} environment variable. @xref{Arguments, ,Your
+program's arguments}.
@item The @emph{environment.}
Your program normally inherits its environment from @value{GDBN}, but you can
@@ -1849,17 +1483,16 @@ table, and reads it again. When it does this, @value{GDBN} tries to retain
your current breakpoints.
@ifclear BARETARGET
-@node Arguments, Environment, Starting, Running
+@node Arguments
@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 your program. Your
-@code{SHELL} environment variable (if it exists) specifies what shell
-@value{GDBN} uses. If you do not define @code{SHELL}, @value{GDBN} uses
-@code{/bin/sh}.
+@code{run} command. They are passed to a shell, which expands wildcard
+characters and performs redirection of I/O, and thence to your program.
+Your @code{SHELL} environment variable (if it exists) specifies what
+shell @value{GDBN} uses. If you do not define @code{SHELL},
+@value{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.
@@ -1878,7 +1511,7 @@ it again without arguments.
Show the arguments to give your program when it is started.
@end table
-@node Environment, Working Directory, Arguments, Running
+@node Environment
@section Your program's environment
@cindex environment (of your program)
@@ -1959,7 +1592,7 @@ your program. You may wish to move setting of environment variables to
files that are only run when you sign on, such as @file{.login} or
@file{.profile}.
-@node Working Directory, Input/Output, Environment, Running
+@node Working Directory
@section Your program's working directory
@cindex working directory (of your program)
@@ -1983,7 +1616,7 @@ Set the @value{GDBN} working directory to @var{directory}.
Print the @value{GDBN} working directory.
@end table
-@node Input/Output, Attach, Working Directory, Running
+@node Input/Output
@section Your program's input and output
@cindex redirection
@@ -2037,7 +1670,7 @@ 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 @value{GDBN} still comes from your terminal.
-@node Attach, Kill Process, Input/Output, Running
+@node Attach
@section Debugging an already-running process
@kindex attach
@cindex attach
@@ -2059,23 +1692,14 @@ which supports processes; for example, @code{attach} does not work for
programs on bare-board targets that lack an operating system. You must
also have permission to send the process a signal.
-When you use @code{attach}, the debugger finds the program running in
-the process first by looking in the current working directory, then (if
-the program is not found) by using the source file search path
-(@pxref{Source Path, ,Specifying source directories}). You can also use
-the @code{file} command to load the program. @xref{Files, ,Commands to
-Specify Files}.
+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, ,Commands to Specify Files}.
The first thing @value{GDBN} does after arranging to debug the specified
process is to stop it. You can examine and modify an attached process
with all the @value{GDBN} commands that are ordinarily available when you start
-@ifclear HPPA
processes with @code{run}. You can insert breakpoints; you can step and
-@end ifclear
-@ifset HPPA
-processes with @code{run}. You can insert breakpoints (except in shared
-libraries); you can step and
-@end ifset
continue; you can modify storage. If you would rather the process
continue running, you may use the @code{continue} command after
attaching @value{GDBN} to the process.
@@ -2099,14 +1723,9 @@ control whether or not you need to confirm by using the @code{set
confirm} command (@pxref{Messages/Warnings, ,Optional warnings and
messages}).
-@ifset HPPA
-@node Kill Process, Threads, Attach, Running
-@section Killing the child process
-@end ifset
-@ifclear HPPA
-@node Kill Process, Process Information, Attach, Running
+@node Kill Process
+@c @group
@section Killing the child process
-@end ifclear
@table @code
@kindex kill
@@ -2117,6 +1736,7 @@ Kill the child process in which your program is running under @value{GDBN}.
This command is useful if you wish to debug a core dump instead of a
running process. @value{GDBN} ignores any core dump file while your program
is running.
+@c @end group
On some operating systems, a program cannot be executed outside @value{GDBN}
while you have breakpoints set on it inside @value{GDBN}. You can use the
@@ -2130,8 +1750,7 @@ next type @code{run}, @value{GDBN} notices that the file has changed, and
reads the symbol table again (while trying to preserve your current
breakpoint settings).
-@ifclear HPPA
-@node Process Information, Threads, Kill Process, Running
+@node Process Information
@section Additional process information
@kindex /proc
@@ -2172,27 +1791,20 @@ received.
@item info proc all
Show all the above information about the process.
@end table
-@end ifclear
-@ifset HPPA
-@node Threads, Processes, Kill Process, Running
+@node Threads
@section Debugging programs with multiple threads
-@end ifset
-@ifclear HPPA
-@node Threads, Processes, Process Information, Running
-@section Debugging programs with multiple threads
-@end ifclear
@cindex threads of execution
@cindex multiple threads
@cindex switching threads
-In some operating systems, such as HP-UX and Solaris, a single program
-may have more than one @dfn{thread} of execution. The precise semantics
-of threads differ from one operating system to another, but in general
-the threads of a single program are akin to multiple processes---except
-that they share one address space (that is, they can all examine and
-modify the same variables). On the other hand, each thread has its own
-registers and execution stack, and perhaps private memory.
+In some operating systems, a single program may have more than one
+@dfn{thread} of execution. The precise semantics of threads differ from
+one operating system to another, but in general the threads of a single
+program are akin to multiple processes---except that they share one
+address space (that is, they can all examine and modify the same
+variables). On the other hand, each thread has its own registers and
+execution stack, and perhaps private memory.
@value{GDBN} provides these facilities for debugging multi-thread
programs:
@@ -2206,7 +1818,6 @@ a command to apply a command to a list of threads
@item thread-specific breakpoints
@end itemize
-@ifclear HPPA
@quotation
@emph{Warning:} These facilities are not yet available on every
@value{GDBN} configuration where the operating system supports threads.
@@ -2224,7 +1835,6 @@ see the IDs of currently known threads.
@c FIXME to implementors: how hard would it be to say "sorry, this GDB
@c doesn't support threads"?
@end quotation
-@end ifclear
@cindex focus of debugging
@cindex current thread
@@ -2234,7 +1844,6 @@ control, one thread in particular is always the focus of debugging.
This thread is called the @dfn{current thread}. Debugging commands show
program information from the perspective of the current thread.
-@ifclear HPPA
@kindex New @var{systag}
@cindex thread identifier (system)
@c FIXME-implementors!! It would be more helpful if the [New...] message
@@ -2297,62 +1906,6 @@ For example,
* 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
at threadtest.c:68
@end smallexample
-@end ifclear
-@ifset HPPA
-
-@cindex thread number
-@cindex thread identifier (GDB)
-For debugging purposes, @value{GDBN} associates its own thread
-number---a small integer assigned in thread-creation order---with each
-thread in your program.
-
-@kindex New @var{systag}
-@cindex thread identifier (system)
-@c FIXME-implementors!! It would be more helpful if the [New...] message
-@c included GDB's numeric thread handle, so you could just go to that
-@c thread without first checking `info threads'.
-Whenever @value{GDBN} detects a new thread in your program, it displays
-both @value{GDBN}'s thread number and the target system's identification for the thread with a message in the
-form @samp{[New @var{systag}]}. @var{systag} is a thread identifier
-whose form varies depending on the particular system. For example, on
-HP-UX, you see
-
-@example
-[New thread 2 (system thread 26594)]
-@end example
-
-@noindent
-when @value{GDBN} notices a new thread.
-
-@table @code
-@kindex info threads
-@item info threads
-Display a summary of all threads currently in your
-program. @value{GDBN} displays for each thread (in this order):
-
-@enumerate
-@item the thread number assigned by @value{GDBN}
-
-@item the target system's thread identifier (@var{systag})
-
-@item the current stack frame summary for that thread
-@end enumerate
-
-@noindent
-An asterisk @samp{*} to the left of the @value{GDBN} thread number
-indicates the current thread.
-
-For example,
-@end table
-@c end table here to get a little more width for example
-
-@example
-(@value{GDBP}) info threads
- * 3 system thread 26607 worker (wptr=0x7b09c318 "@@") at quicksort.c:137
- 2 system thread 26606 0x7b0030d8 in __ksleep () from /usr/lib/libc.2
- 1 system thread 27905 0x7b003498 in _brk () from /usr/lib/libc.2
-@end example
-@end ifset
@table @code
@kindex thread @var{threadno}
@@ -2366,12 +1919,7 @@ you selected, and its current stack frame summary:
@smallexample
@c FIXME!! This example made up; find a @value{GDBN} w/threads and get real one
(@value{GDBP}) thread 2
-@ifclear HPPA
[Switching to process 35 thread 23]
-@end ifclear
-@ifset HPPA
-[Switching to thread 2 (system thread 26594)]
-@end ifset
0x34e5 in sigpause ()
@end smallexample
@@ -2407,8 +1955,7 @@ programs with multiple threads.
watchpoints in programs with multiple threads.
@end ifclear
-@ifclear HPPA
-@node Processes, , Threads, Running
+@node Processes
@section Debugging programs with multiple processes
@cindex fork, debugging programs which call
@@ -2431,68 +1978,8 @@ get its process ID. Then tell @value{GDBN} (a new invocation of
@value{GDBN} if you are also debugging the parent process) to attach to
the child process (see @ref{Attach}). From that point on you can debug
the child process just like any other process which you attached to.
-@end ifclear
-@ifset HPPA
-@node Processes, , Threads, Running
-@section Debugging programs with multiple processes
-@cindex fork, debugging programs which call
-@cindex multiple processes
-@cindex processes, multiple
-
-@value{GDBN} provides support for debugging programs that create
-additional processes using the @code{fork} or @code{vfork} function.
-
-By default, when a program forks, @value{GDBN} will continue to debug
-the parent process and the child process will run unimpeded.
-
-If you want to follow the child process instead of the parent process,
-use the command @w{@code{set follow-fork-mode}}.
-
-@table @code
-@kindex set follow-fork-mode
-@item set follow-fork-mode @var{mode}
-Set the debugger response to a program call of @code{fork} or
-@code{vfork}. A call to @code{fork} or @code{vfork} creates a new
-process. The @var{mode} can be:
-
-@table @code
-@item parent
-The original process is debugged after a fork. The child process runs
-unimpeded.
-
-@item child
-The new process is debugged after a fork. The parent process runs
-unimpeded.
-
-@item ask
-The debugger will ask for one of the above choices.
-@end table
-
-@item show follow-fork-mode
-Display the current debugger response to a fork or vfork call.
-@end table
-
-If you ask to debug a child process and a @code{vfork} is followed by an
-@code{exec}, @value{GDBN} executes the new target up to the first
-breakpoint in the new target. If you have a breakpoint set on
-@code{main} in your original program, the breakpoint will also be set on
-the child process's @code{main}.
-
-When a child process is spawned by @code{vfork}, you cannot debug the
-child or parent until an @code{exec} call completes.
-
-If you issue a @code{run} command to @value{GDBN} after an @code{exec}
-call executes, the new target restarts. To restart the parent process,
-use the @code{file} command with the parent executable name as its
-argument.
-
-You can use the @code{catch} command to make @value{GDBN} stop whenever
-a @code{fork}, @code{vfork}, or @code{exec} call is made. @xref{Set
-Catchpoints, ,Setting catchpoints}.
-@end ifset
-
-@node Stopping, Stack, Running, Top
+@node Stopping
@chapter Stopping and Continuing
The principal purposes of using a debugger are so that you can stop your
@@ -2523,36 +2010,51 @@ and why it stopped.
@end table
@menu
-* Breakpoints:: Breakpoints, watchpoints, and catchpoints
+@ifclear CONLY
+* Breakpoints:: Breakpoints, watchpoints, and exceptions
+@end ifclear
+@ifset CONLY
+* Breakpoints:: Breakpoints and watchpoints
+@end ifset
+@c Remnant makeinfo bug requires blank line after *successful* end-if in menu:
+
* Continuing and Stepping:: Resuming execution
@ifset POSIX
* Signals:: Signals
@end ifset
-
@ifclear BARETARGET
-* Thread Stops:: Stopping and starting multi-thread programs
+* Thread Stops:: Stopping and starting multi-thread programs
@end ifclear
-
@end menu
-@node Breakpoints, Continuing and Stepping, Stopping, Stopping
-@section Breakpoints, watchpoints, and catchpoints
+@c makeinfo node-defaulting requires adjacency of @node and sectioning cmds
+@c ...hence distribute @node Breakpoints over two possible @if expansions.
+@c
+@ifclear CONLY
+@node Breakpoints
+@section Breakpoints, watchpoints, and exceptions
+@end ifclear
+@ifset CONLY
+@node Breakpoints
+@section Breakpoints and watchpoints
+@end ifset
@cindex breakpoints
A @dfn{breakpoint} makes your program stop whenever a certain point in
-the program is reached. For each breakpoint, you can add conditions to
-control in finer detail whether your program stops. You can set
-breakpoints with the @code{break} command and its variants (@pxref{Set
-Breaks, ,Setting breakpoints}), to specify the place where your program
-should stop by line number, function name or exact address in the
-program.
+the program is reached. For each breakpoint, you can add
+conditions to control in finer detail whether your program stops.
+You can set breakpoints with the @code{break} command and its variants
+(@pxref{Set Breaks, ,Setting breakpoints}), to specify the place where
+your program should stop by line number, function name or exact address
+in the program.
+@ifclear CONLY
+In languages with exception handling (such as @sc{gnu} C++), you can also set
+breakpoints where an exception is raised (@pxref{Exception Handling,,
+Breakpoints and exceptions}).
+@end ifclear
-In HP-UX, SunOS 4.x, SVR4, and Alpha OSF/1 configurations, you can set
-breakpoints in shared libraries before the executable is run. There is
-a minor limitation on HP-UX systems: you must wait until the executable
-is run in order to set breakpoints in shared library routines that are
-not called directly by the program (for example, routines that are
-arguments in a @code{pthread_create} call).
+In SunOS 4.x, SVR4, and Alpha OSF/1 configurations, you can now set
+breakpoints in shared libraries before the executable is run.
@cindex watchpoints
@cindex memory tracing
@@ -2569,30 +2071,22 @@ You can arrange to have values from your program displayed automatically
whenever @value{GDBN} stops at a breakpoint. @xref{Auto Display,,
Automatic display}.
-@cindex catchpoints
-@cindex breakpoint on events
-A @dfn{catchpoint} is another special breakpoint that stops your program
-when a certain kind of event occurs, such as the throwing of a C++
-exception or the loading of a library. As with watchpoints, you use a
-different command to set a catchpoint (@pxref{Set Catchpoints, ,Setting
-catchpoints}), but aside from that, you can manage a catchpoint like any
-other breakpoint. (To stop when your program receives a signal, use the
-@code{handle} command; @pxref{Signals, ,Signals}.)
-
@cindex breakpoint numbers
@cindex numbers for breakpoints
-@value{GDBN} assigns a number to each breakpoint, watchpoint, or
-catchpoint when you create it; 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 your program until you
-enable it again.
+@value{GDBN} assigns a number to each breakpoint or watchpoint when you
+create it; 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 your program until you enable it again.
@menu
* Set Breaks:: Setting breakpoints
* Set Watchpoints:: Setting watchpoints
-* Set Catchpoints:: Setting catchpoints
+@ifclear CONLY
+* Exception Handling:: Breakpoints and exceptions
+@end ifclear
+
* Delete Breaks:: Deleting breakpoints
* Disabling:: Disabling breakpoints
* Conditions:: Break conditions
@@ -2600,13 +2094,12 @@ enable it again.
@ifclear CONLY
* Breakpoint Menus:: Breakpoint menus
@end ifclear
-
@c @ifclear BARETARGET
@c * Error in Breakpoints:: ``Cannot insert breakpoints''
@c @end ifclear
@end menu
-@node Set Breaks, Set Watchpoints, Breakpoints, Breakpoints
+@node Set Breaks
@subsection Setting breakpoints
@c FIXME LMB what does GDB do if no code on line of breakpt?
@@ -2693,7 +2186,6 @@ same as for the @code{break} command, and the breakpoint is set in the same
way, but the breakpoint is automatically deleted after the first time your
program stops there. @xref{Disabling, ,Disabling breakpoints}.
-@ifclear HPPA
@kindex hbreak
@item hbreak @var{args}
Set a hardware-assisted breakpoint. @var{args} are the same as for the
@@ -2703,10 +2195,10 @@ have this support. The main purpose of this is EPROM/ROM code
debugging, so you can set a breakpoint at an instruction without
changing the instruction. This can be used with the new trap-generation
provided by SPARClite DSU. DSU will generate traps when a program accesses
-some data or instruction address that is assigned to the debug registers.
+some date or instruction address that is assigned to the debug registers.
However the hardware breakpoint registers can only take two data breakpoints,
and @value{GDBN} will reject this command if more than two are used.
-Delete or disable unused hardware breakpoints before setting
+Delete or disable usused hardware breakpoints before setting
new ones. @xref{Conditions, ,Break conditions}.
@kindex thbreak
@@ -2719,7 +2211,6 @@ first time your program stops there. Also, like the @code{hbreak}
command, the breakpoint requires hardware support and some target hardware
may not have this support. @xref{Disabling, ,Disabling breakpoints}.
Also @xref{Conditions, ,Break conditions}.
-@end ifclear
@kindex rbreak
@cindex regular expression
@@ -2744,13 +2235,13 @@ classes.
@item info breakpoints @r{[}@var{n}@r{]}
@itemx info break @r{[}@var{n}@r{]}
@itemx info watchpoints @r{[}@var{n}@r{]}
-Print a table of all breakpoints, watchpoints, and catchpoints set and
-not deleted, with the following columns for each breakpoint:
+Print a table of all breakpoints and watchpoints set and not
+deleted, with the following columns for each breakpoint:
@table @emph
@item Breakpoint Numbers
@item Type
-Breakpoint, watchpoint, or catchpoint.
+Breakpoint or watchpoint.
@item Disposition
Whether the breakpoint is marked to be disabled or deleted when hit.
@item Enabled or Disabled
@@ -2776,12 +2267,12 @@ the @code{x} command are set to the address of the last breakpoint
listed (@pxref{Memory, ,Examining memory}).
@noindent
-@code{info break} displays a count of the number of times the breakpoint
-has been hit. This is especially useful in conjunction with the
-@code{ignore} command. You can ignore a large number of breakpoint
-hits, look at the breakpoint info to see how many times the breakpoint
-was hit, and then run again, ignoring one less than that number. This
-will get you quickly to the last hit of that breakpoint.
+@code{info break} now displays a count of the number of times the
+breakpoint has been hit. This is especially useful in conjunction with
+the @code{ignore} command. You can ignore a large number of breakpoint
+hits, look at the breakpoint info to see how many times the
+breakpoint was hit, and then run again, ignoring one less than that
+number. This will get you quickly to the last hit of that breakpoint.
@end table
@value{GDBN} allows you to set any number of breakpoints at the same place in
@@ -2827,45 +2318,50 @@ Temporary internal breakpoint used by the @value{GDBN} @code{until} command.
@item finish
Temporary internal breakpoint used by the @value{GDBN} @code{finish} command.
-
-@ifset HPPA
-@item shlib events
-Shared library events.
-@end ifset
@end table
+
@end table
-@node Set Watchpoints, Set Catchpoints, Set Breaks, Breakpoints
+@node Set Watchpoints
@subsection Setting watchpoints
-
@cindex setting watchpoints
-@cindex software watchpoints
-@cindex hardware 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.
-
-Depending on your system, watchpoints may be implemented in software or
-hardware. GDB does software watchpointing by single-stepping your
-program and testing the variable's value each time, which is hundreds of
-times slower than normal execution. (But this may still be worth it, to
-catch errors where you have no clue what part of your program is the
-culprit.)
-
-On some systems, such as HP-UX and Linux, GDB includes support for
-hardware watchpoints, which do not slow down the running of your
-program.
+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 be well worth it to catch errors where
+you have no clue what part of your program is the culprit.
+
+@c FIXME - did Stan mean to @ignore this out?
+@ignore
+Some processors provide special hardware to support watchpoint
+evaluation; @value{GDBN} will use such hardware if it is available,
+and if the support code has been added for that configuration.
+@end ignore
@table @code
@kindex watch
@item watch @var{expr}
Set a watchpoint for an expression. @value{GDBN} will break when @var{expr}
is written into by the program and its value changes.
+This can be used with the new trap-generation provided by
+SPARClite DSU. DSU will generate traps when a program accesses
+some date or instruction address that is assigned to the debug registers.
+For the data addresses, DSU facilitates the @code{watch} command.
+However the hardware breakpoint registers can only take two data watchpoints,
+and both watchpoints must be the same kind. For example, you can set two
+watchpoints with @code{watch} commands, two with @code{rwatch}
+commands, @strong{or} two with @code{awatch} commands, but you cannot set one
+watchpoint with one command and the other with a different command.
+@value{GBDN} will reject the command if you try to mix watchpoints.
+Delete or disable unused watchpoint commands before setting new ones.
@kindex rwatch
@item rwatch @var{expr}
-Set a watchpoint that will break when watch @var{expr} is read by the program.
+Set a watchpoint that will break when watch @var{args} is read by the program.
If you use both watchpoints, both must be set with the @code{rwatch}
command.
@@ -2877,47 +2373,15 @@ by the program. If you use both watchpoints, both must be set with the
@kindex info watchpoints
@item info watchpoints
-This command prints a list of watchpoints, breakpoints, and catchpoints;
-it is the same as @code{info break}.
+This command prints a list of watchpoints and breakpoints; it is the
+same as @code{info break}.
@end table
-@value{GDBN} sets a @dfn{hardware watchpoint} if possible. Hardware
-watchpoints execute very quickly, and the debugger reports a change in
-value at the exact instruction where the change occurs. If @value{GDBN}
-cannot set a hardware watchpoint, it sets a software watchpoint, which
-executes more slowly and reports the change in value at the next
-statement, not the instruction, after the change occurs.
-
-When you issue the @code{watch} command, @value{GDBN} reports
-
-@example
-Hardware watchpoint @var{num}: @var{expr}
-@end example
-
-@noindent
-if it was able to set a hardware watchpoint.
-
-The SPARClite DSU will generate traps when a program accesses
-some data or instruction address that is assigned to the debug registers.
-For the data addresses, DSU facilitates the @code{watch} command.
-However the hardware breakpoint registers can only take two data watchpoints,
-and both watchpoints must be the same kind. For example, you can set two
-watchpoints with @code{watch} commands, two with @code{rwatch}
-commands, @strong{or} two with @code{awatch} commands, but you cannot set one
-watchpoint with one command and the other with a different command.
-@value{GDBN} will reject the command if you try to mix watchpoints.
-Delete or disable unused watchpoint commands before setting new ones.
-
-If you call a function interactively using @code{print} or @code{call},
-any watchpoints you have set will be inactive until GDB reaches another
-kind of breakpoint or the call completes.
-
@ifclear BARETARGET
@quotation
@cindex watchpoints and threads
@cindex threads and watchpoints
-@ifclear HPPA
-@emph{Warning:} In multi-thread programs, watchpoints have only limited
+@emph{Warning:} in multi-thread programs, watchpoints have only limited
usefulness. With the current watchpoint implementation, @value{GDBN}
can only watch the value of an expression @emph{in a single thread}. If
you are confident that the expression can only change due to the current
@@ -2925,90 +2389,40 @@ thread's activity (and if you are also confident that no other thread
can become current), then you can use watchpoints as usual. However,
@value{GDBN} may not notice when a non-current thread's activity changes
the expression.
-@end ifclear
-@ifset HPPA
-@emph{Warning:} In multi-thread programs, software watchpoints have only
-limited usefulness. If @value{GDBN} creates a software watchpoint, it
-can only watch the value of an expression @emph{in a single thread}. If
-you are confident that the expression can only change due to the current
-thread's activity (and if you are also confident that no other thread
-can become current), then you can use software watchpoints as usual.
-However, @value{GDBN} may not notice when a non-current thread's
-activity changes the expression. (Hardware watchpoints, in contrast,
-watch an expression in all threads.)
-@end ifset
@end quotation
@end ifclear
-@node Set Catchpoints, Delete Breaks, Set Watchpoints, Breakpoints
-@subsection Setting catchpoints
-@cindex catchpoints
+@ifclear CONLY
+@node Exception Handling
+@subsection Breakpoints and exceptions
@cindex exception handlers
-@cindex event handling
-You can use @dfn{catchpoints} to cause the debugger to stop for certain
-kinds of program events, such as C++ exceptions or the loading of a
-shared library. Use the @code{catch} command to set a catchpoint.
+Some languages, such as @sc{gnu} C++, implement exception handling. You can
+use @value{GDBN} to examine what caused your program to raise an exception,
+and to list the exceptions your program is prepared to handle at a
+given point in time.
@table @code
@kindex catch
-@item catch @var{event}
-Stop when @var{event} occurs. @var{event} can be any of the following:
-@table @code
-@item throw
-@kindex catch throw
-The throwing of a C++ exception.
-
-@item catch
-@kindex catch catch
-The catching of a C++ exception.
-
-@item exec
-@kindex catch exec
-A call to @code{exec}. This is currently only available for HP-UX.
-
-@item fork
-@kindex catch fork
-A call to @code{fork}. This is currently only available for HP-UX.
-
-@item vfork
-@kindex catch vfork
-A call to @code{vfork}. This is currently only available for HP-UX.
-
-@item load
-@itemx load @var{libname}
-@kindex catch load
-The dynamic loading of any shared library, or the loading of the library
-@var{libname}. This is currently only available for HP-UX.
-
-@item unload
-@itemx unload @var{libname}
-@kindex catch unload
-The unloading of any dynamically loaded shared library, or the unloading
-of the library @var{libname}. This is currently only available for HP-UX.
+@item catch @var{exceptions}
+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
-@item tcatch @var{event}
-Set a catchpoint that is enabled only for one stop. The catchpoint is
-automatically deleted after the first time the event is caught.
+You can use @code{info catch} to list active exception handlers.
+@xref{Frame Info, ,Information about a frame}.
-@end table
-
-Use the @code{info break} command to list the current catchpoints.
-
-There are currently some limitations to C++ exception handling
-(@code{catch throw} and @code{catch catch}) in @value{GDBN}:
+There are currently some limitations to exception handling in @value{GDBN}:
@itemize @bullet
@item
If you call a function interactively, @value{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 you and cause your program either to abort or to
-simply continue running until it hits a breakpoint, catches a signal
-that @value{GDBN} is listening for, or exits. This is the case even if
-you set a catchpoint for the exception; catchpoints on exceptions are
-disabled within interactive calls.
+returns control to you and cause your program to simply continue
+running until it hits a breakpoint, catches a signal that @value{GDBN} is
+listening for, or exits.
@item
You cannot raise an exception interactively.
@@ -3046,30 +2460,30 @@ 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 your program when any of a number of exceptions are
raised.
+@end ifclear
-
-@node Delete Breaks, Disabling, Set Catchpoints, Breakpoints
+@node Delete Breaks
@subsection Deleting breakpoints
-@cindex clearing breakpoints, watchpoints, catchpoints
-@cindex deleting breakpoints, watchpoints, catchpoints
-It is often necessary to eliminate a breakpoint, watchpoint, or
-catchpoint once it has done its job and you no longer want your program
-to stop there. This is called @dfn{deleting} the breakpoint. A
-breakpoint that has been deleted no longer exists; it is forgotten.
+@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 your 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 your program. With the @code{delete} command you can
-delete individual breakpoints, watchpoints, or catchpoints by specifying
-their breakpoint numbers.
+delete individual breakpoints or watchpoints by specifying their
+breakpoint numbers.
It is not necessary to delete a breakpoint to proceed past it. @value{GDBN}
automatically ignores breakpoints on the first instruction to be executed
when you continue execution without changing the execution address.
@table @code
-@kindex clear
@item clear
+@kindex clear
Delete any breakpoints at the next instruction to be executed in the
selected stack frame (@pxref{Selection, ,Selecting a frame}). When
the innermost frame is selected, this is a good way to delete a
@@ -3087,30 +2501,30 @@ Delete any breakpoints set at or within the code of the specified line.
@kindex delete
@kindex d
@item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
-Delete the breakpoints, watchpoints, or catchpoints of the numbers
-specified as arguments. If no argument is specified, delete all
-breakpoints (@value{GDBN} asks confirmation, unless you have @code{set
-confirm off}). You can abbreviate this command as @code{d}.
+Delete the breakpoints or watchpoints of the numbers specified as
+arguments. If no argument is specified, delete all breakpoints (@value{GDBN}
+asks confirmation, unless you have @code{set confirm off}). You
+can abbreviate this command as @code{d}.
@end table
-@node Disabling, Conditions, Delete Breaks, Breakpoints
+@node Disabling
@subsection Disabling breakpoints
@kindex disable breakpoints
@kindex enable breakpoints
-Rather than deleting a breakpoint, watchpoint, or catchpoint, 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.
+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, watchpoints, and catchpoints 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, watchpoints, and
-catchpoints if you do not know which numbers to use.
+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
+do not know which numbers to use.
-A breakpoint, watchpoint, or catchpoint can have any of four different
-states of enablement:
+A breakpoint or watchpoint can have any of four different states of
+enablement:
@itemize @bullet
@item
@@ -3127,8 +2541,8 @@ Enabled for deletion. The breakpoint stops your program, but
immediately after it does so it is deleted permanently.
@end itemize
-You can use the following commands to enable or disable breakpoints,
-watchpoints, and catchpoints:
+You can use the following commands to enable or disable breakpoints and
+watchpoints:
@table @code
@kindex disable breakpoints
@@ -3164,7 +2578,7 @@ breakpoint of its own, but it does not change the state of your other
breakpoints; see @ref{Continuing and Stepping, ,Continuing and
stepping}.)
-@node Conditions, Break Commands, Disabling, Breakpoints
+@node Conditions
@subsection Break conditions
@cindex conditional breakpoints
@cindex breakpoint conditions
@@ -3204,31 +2618,20 @@ purpose of performing side effects when a breakpoint is reached
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, ,Setting breakpoints}. They can also be changed at any time
-with the @code{condition} command.
-@ifclear HPPA
-@c The watch command now seems to recognize the if keyword.
-@c catch doesn't, though.
-The @code{watch} command does not recognize the @code{if} keyword;
-@code{condition} is the only way to impose a further condition on a
-watchpoint.
-@end ifclear
-@ifset HPPA
-You can also use the @code{if} keyword with the @code{watch} command.
-The @code{catch} command does not recognize the @code{if} keyword;
-@code{condition} is the only way to impose a further condition on a
-catchpoint.
-@end ifset
+with the @code{condition} command. The @code{watch} command does not
+recognize the @code{if} keyword; @code{condition} is the only way to
+impose a further condition on a watchpoint.
@table @code
@kindex condition
@item condition @var{bnum} @var{expression}
-Specify @var{expression} as the break condition for breakpoint,
-watchpoint, or catchpoint number @var{bnum}. After you set a condition,
-breakpoint @var{bnum} stops your program only if the value of
-@var{expression} is true (nonzero, in C). When you use
-@code{condition}, @value{GDBN} checks @var{expression} immediately for
-syntactic correctness, and to determine whether symbols in it have
-referents in the context of your breakpoint.
+Specify @var{expression} as the break condition for breakpoint or
+watchpoint number @var{bnum}. After you set a condition, breakpoint
+@var{bnum} stops your program only if the value of @var{expression} is
+true (nonzero, in C). When you use @code{condition}, @value{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 is no referent? Moreover, what
@c about watchpoints?
@value{GDBN} does
@@ -3278,17 +2681,14 @@ is decremented each time. @xref{Convenience Vars, ,Convenience
variables}.
@end table
-Ignore counts apply to breakpoints, watchpoints, and catchpoints.
-
-
-@node Break Commands, Breakpoint Menus, Conditions, Breakpoints
+@node Break Commands
@subsection Breakpoint command lists
@cindex breakpoint commands
-You can give any breakpoint (or watchpoint or catchpoint) a series of
-commands to execute when your program stops due to that breakpoint. For
-example, you might want to print the values of certain expressions, or
-enable other breakpoints.
+You can give any breakpoint (or watchpoint) a series of commands to
+execute when your program stops due to that breakpoint. For example, you
+might want to print the values of certain expressions, or enable other
+breakpoints.
@table @code
@kindex commands
@@ -3304,8 +2704,8 @@ 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, watchpoint, or catchpoint set (not to the breakpoint most
-recently encountered).
+breakpoint or watchpoint set (not to the breakpoint most recently
+encountered).
@end table
Pressing @key{RET} as a means of repeating the last @value{GDBN} command is
@@ -3363,7 +2763,7 @@ end
@end example
@ifclear CONLY
-@node Breakpoint Menus, , Break Commands, Breakpoints
+@node Breakpoint Menus
@subsection Breakpoint menus
@cindex overloading
@cindex symbol overloading
@@ -3388,7 +2788,6 @@ We choose three particular definitions of that function name:
@c FIXME! This is likely to change to show arg type lists, at least
@smallexample
-@group
(@value{GDBP}) b String::after
[0] cancel
[1] all
@@ -3406,7 +2805,6 @@ Multiple breakpoints were set.
Use the "delete" command to delete unwanted
breakpoints.
(@value{GDBP})
-@end group
@end smallexample
@end ifclear
@@ -3440,7 +2838,7 @@ Use the "delete" command to delete unwanted
@c @end enumerate
@c @end ifclear
-@node Continuing and Stepping, Signals, Breakpoints, Stopping
+@node Continuing and Stepping
@section Continuing and stepping
@cindex stepping
@@ -3488,11 +2886,17 @@ calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a
different address}) to go to an arbitrary location in your program.
A typical technique for using stepping is to set a breakpoint
-(@pxref{Breakpoints, ,Breakpoints; watchpoints; and catchpoints}) at the
-beginning of the function or the section of your program where a problem
-is believed to lie, run your 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.
+@ifclear CONLY
+(@pxref{Breakpoints, ,Breakpoints; watchpoints; and exceptions})
+@end ifclear
+@ifset CONLY
+(@pxref{Breakpoints, ,Breakpoints and watchpoints})
+@end ifset
+at the
+beginning of the function or the section of your program where a
+problem is believed to lie, run your 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
@kindex step
@@ -3557,7 +2961,7 @@ An argument @var{count} is a repeat count, as for @code{step}.
The @code{next} command now only stops at the first instruction of a
source line. This prevents the multiple stops that used to occur in
-switch statements, for loops, etc.
+swtch statements, for loops, etc.
@kindex finish
@item finish
@@ -3568,9 +2972,9 @@ Contrast this with the @code{return} command (@pxref{Returning,
,Returning from a function}).
@kindex until
+@itemx u
@kindex u
@item until
-@itemx 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}
@@ -3646,7 +3050,7 @@ An argument is a repeat count, as in @code{next}.
@end table
@ifset POSIX
-@node Signals, Thread Stops, Continuing and Stepping, Stopping
+@node Signals
@section Signals
@cindex signals
@@ -3742,7 +3146,7 @@ program a signal}.
@end ifset
@ifclear BARETARGET
-@node Thread Stops, , Signals, Stopping
+@node Thread Stops
@section Stopping and starting multi-thread programs
When your program has multiple threads (@pxref{Threads,, Debugging
@@ -3804,32 +3208,9 @@ You might even find your program stopped in another thread after
continuing or even single-stepping. This happens whenever some other
thread runs into a breakpoint, a signal, or an exception before the
first thread completes whatever you requested.
-
-On some OSes, you can lock the OS scheduler and thus allow only a single
-thread to run.
-
-@table @code
-@item set scheduler-locking @var{mode}
-Set the scheduler locking mode. If it is @code{off}, then there is no
-locking and any thread may run at any time. If @code{on}, then only the
-current thread may run when the inferior is resumed. The @code{step}
-mode optimizes for single-stepping. It stops other threads from
-``seizing the prompt'' by preempting the current thread while you are
-stepping. Other threads will only rarely (or never) get a chance to run
-when you step. They are more likely to run when you ``next'' over a
-function call, and they are completely free to run when you use commands
-like ``continue'', ``until'', or ``finish''. However, unless another
-thread hits a breakpoint during its timeslice, they will never steal the
-GDB prompt away from the thread that you are debugging.
-
-@item show scheduler-locking
-Display the current scheduler locking mode.
-@end table
-
@end ifclear
-
-@node Stack, Source, Stopping, Top
+@node Stack
@chapter Examining the Stack
When your program has stopped, the first thing you need to know is where it
@@ -3865,11 +3246,12 @@ currently executing frame and describes it briefly, similar to the
* Backtrace:: Backtraces
* Selection:: Selecting a frame
* Frame Info:: Information on a frame
-* Alpha/MIPS Stack:: Alpha and MIPS machines and the function stack
-
+@ifset MIPS
+* MIPS Stack:: MIPS machines and the function stack
+@end ifset
@end menu
-@node Frames, Backtrace, Stack, Stack
+@node Frames
@section Stack frames
@cindex frame
@@ -3925,7 +3307,7 @@ no provision for frameless functions elsewhere in the stack.
@item frame @var{args}
The @code{frame} command allows you to move from one stack frame to another,
and to print the stack frame you select. @var{args} may be either the
-address of the frame or the stack frame number. Without an argument,
+address of the frame of the stack frame number. Without an argument,
@code{frame} prints the current stack frame.
@kindex select-frame
@@ -3935,12 +3317,9 @@ to another without printing the frame. This is the silent version of
@code{frame}.
@end table
-@node Backtrace, Selection, Frames, Stack
+@node Backtrace
@section Backtraces
-@cindex backtraces
-@cindex tracebacks
-@cindex stack traces
A backtrace is a summary of how your 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
@@ -3998,7 +3377,7 @@ The display for frame zero does not begin with a program counter
value, indicating that your program has stopped at the beginning of the
code for line @code{993} of @code{builtin.c}.
-@node Selection, Frame Info, Backtrace, Stack
+@node Selection
@section Selecting a frame
Most commands for examining the stack and other data in your program work on
@@ -4025,7 +3404,6 @@ addition, this can be useful when your program has multiple stacks and
switches between them.
@ifclear H8EXCLUSIVE
-@ifclear HPPA
On the SPARC architecture, @code{frame} needs two addresses to
select an arbitrary frame: a frame pointer and a stack pointer.
@@ -4038,7 +3416,6 @@ pointer, a program counter, and a memory stack pointer.
@c SETUP_ARBITRARY_FRAME in the tm-*.h files. The above is up to date
@c as of 27 Jan 1994.
@end ifclear
-@end ifclear
@kindex up
@item up @var{n}
@@ -4088,7 +3465,7 @@ in @value{GDBN} command scripts, where the output might be unnecessary and
distracting.
@end table
-@node Frame Info, Alpha/MIPS Stack, Selection, Stack
+@node Frame Info
@section Information about a frame
There are several other commands to print information about the selected
@@ -4150,7 +3527,6 @@ line. These are all variables (declared either static or automatic)
accessible at the point of execution of the selected frame.
@ifclear CONLY
-@ifclear HPPA
@kindex info catch
@cindex catch exceptions
@cindex exception handlers
@@ -4159,21 +3535,19 @@ 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{Set Catchpoints, , Setting catchpoints}.
-@end ifclear
+@xref{Exception Handling, ,Breakpoints and exceptions}.
@end ifclear
@end table
-@node Alpha/MIPS Stack, , Frame Info, Stack
-@section MIPS/Alpha machines and the function stack
+@ifset MIPS
+@node MIPS Stack
+@section MIPS machines and the function stack
-@cindex stack on Alpha
@cindex stack on MIPS
-@cindex Alpha stack
@cindex MIPS stack
-Alpha- and MIPS-based computers use an unusual stack frame, which
-sometimes requires @value{GDBN} to search backward in the object code to
-find the beginning of a function.
+MIPS based computers use an unusual stack frame, which sometimes
+requires @value{GDBN} to search backward in the object code to find the
+beginning of a function.
@cindex response time, MIPS debugging
To improve response time (especially for embedded applications, where
@@ -4182,7 +3556,7 @@ you may want to limit the size of this search, using one of these
commands:
@table @code
-@cindex @code{heuristic-fence-post} (Alpha,MIPS)
+@cindex @code{heuristic-fence-post} (MIPS)
@item set heuristic-fence-post @var{limit}
Restrict @value{GDBN} to examining at most @var{limit} bytes in its search
for the beginning of a function. A value of @var{0} (the default)
@@ -4196,10 +3570,10 @@ Display the current limit.
@noindent
These commands are available @emph{only} when @value{GDBN} is configured
-for debugging programs on Alpha or MIPS processors.
-
+for debugging programs on MIPS processors.
+@end ifset
-@node Source, Data, Stack, Top
+@node Source
@chapter Examining Source Files
@value{GDBN} can print parts of your program's source, since the debugging
@@ -4226,7 +3600,7 @@ Emacs facilities to view source; @pxref{Emacs, ,Using @value{GDBN} under @sc{gnu
* Machine Code:: Source and machine code
@end menu
-@node List, Search, Source, Source
+@node List
@section Printing source lines
@kindex list
@@ -4344,7 +3718,7 @@ Specifies the line containing the program address @var{address}.
@end table
@ifclear DOSHOST
-@node Search, Source Path, List, Source
+@node Search
@section Searching source files
@cindex searching
@kindex reverse-search
@@ -4371,7 +3745,7 @@ this command as @code{rev}.
@end table
@end ifclear
-@node Source Path, Machine Code, Search, Source
+@node Source Path
@section Specifying source directories
@cindex source path
@@ -4451,7 +3825,7 @@ directories you want in the source path. You can add all the
directories in one command.
@end enumerate
-@node Machine Code, , Source Path, Source
+@node Machine Code
@section Source and machine code
You can use the command @code{info line} to map source lines to program
@@ -4511,20 +3885,22 @@ surrounding this value. Two arguments specify a range of addresses
@end table
@ifclear H8EXCLUSIVE
-The following example shows the disassembly of a range of addresses of
-HP PA-RISC 2.0 code:
+We can use @code{disassemble} to inspect the object code
+range shown in the last @code{info line} example (the example
+shows SPARC machine instructions):
+
@smallexample
-(@value{GDBP}) disas 0x32c4 0x32e4
-Dump of assembler code from 0x32c4 to 0x32e4:
-0x32c4 <main+204>: addil 0,dp
-0x32c8 <main+208>: ldw 0x22c(sr0,r1),r26
-0x32cc <main+212>: ldil 0x3000,r31
-0x32d0 <main+216>: ble 0x3f8(sr4,r31)
-0x32d4 <main+220>: ldo 0(r31),rp
-0x32d8 <main+224>: addil -0x800,dp
-0x32dc <main+228>: ldo 0x588(r1),r26
-0x32e0 <main+232>: ldil 0x3000,r31
+(@value{GDBP}) disas 0x63e4 0x6404
+Dump of assembler code from 0x63e4 to 0x6404:
+0x63e4 <builtin_init+5340>: ble 0x63f8 <builtin_init+5360>
+0x63e8 <builtin_init+5344>: sethi %hi(0x4c00), %o0
+0x63ec <builtin_init+5348>: ld [%i1+4], %o0
+0x63f0 <builtin_init+5352>: b 0x63fc <builtin_init+5364>
+0x63f4 <builtin_init+5356>: ld [%o0+4], %o0
+0x63f8 <builtin_init+5360>: or %o0, 0x1a4, %o0
+0x63fc <builtin_init+5364>: call 0x9288 <path_search>
+0x6400 <builtin_init+5368>: nop
End of assembler dump.
@end smallexample
@end ifclear
@@ -4550,26 +3926,7 @@ to 0x808c:
@end smallexample
@end ifset
-Some architectures have more than one commonly-used set of instruction
-mnemonics or other syntax.
-
-@table @code
-@kindex set assembly-language
-@cindex assembly instructions
-@cindex instructions, assembly
-@cindex machine instructions
-@cindex listing machine instructions
-@item set assembly-language @var{instruction-set}
-Select the instruction set to use when disassembling the
-program via the @code{disassemble} or @code{x/i} commands.
-
-Currently this command is only defined for the Intel x86 family. You
-can set @var{instruction-set} to either @code{i386} or @code{i8086}.
-The default is @code{i386}.
-@end table
-
-
-@node Data, Languages, Source, Top
+@node Data
@chapter Examining Data
@cindex printing data
@@ -4629,10 +3986,9 @@ command rather than @code{print}. @xref{Symbols, ,Examining the Symbol Table}.
@ifclear HAVE-FLOAT
* Floating Point Hardware:: Floating point hardware
@end ifclear
-
@end menu
-@node Expressions, Variables, Data, Data
+@node Expressions
@section Expressions
@cindex expressions
@@ -4687,7 +4043,7 @@ a cast). This construct is allowed regardless of what kind of data is
normally supposed to reside at @var{addr}.
@end table
-@node Variables, Arrays, Expressions, Data
+@node Variables
@section Program variables
The most common kind of expression to use is the name of a variable
@@ -4698,7 +4054,7 @@ Variables in expressions are understood in the selected stack frame
@itemize @bullet
@item
-global (or file-static)
+global (or static)
@end itemize
@noindent or
@@ -4783,11 +4139,7 @@ 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.
-This may also happen when the compiler does significant optimizations.
-To be sure of always seeing accurate values, turn off all optimization
-when compiling.
-
-@node Arrays, Output Formats, Variables, Data
+@node Arrays
@section Artificial arrays
@cindex artificial array
@@ -4859,7 +4211,7 @@ p dtab[$i++]->fv
@dots{}
@end example
-@node Output Formats, Memory, Arrays, Data
+@node Output Formats
@section Output formats
@cindex formatted output
@@ -4928,7 +4280,7 @@ 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
+@node Memory
@section Examining memory
You can use the command @code{x} (for ``examine'') to examine memory in
@@ -5033,7 +4385,7 @@ 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
+@node Auto Display
@section Automatic display
@cindex automatic display
@cindex display of expressions
@@ -5129,7 +4481,7 @@ there is no variable @code{last_char}---the display is disabled
automatically. 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
+@node Print Settings
@section Print settings
@cindex format options
@@ -5425,12 +4777,7 @@ Allow @value{GDBN} to choose a decoding style by inspecting your program.
@item gnu
Decode based on the @sc{gnu} C++ compiler (@code{g++}) encoding algorithm.
-@ifclear HPPA
This is the default.
-@end ifclear
-
-@item hp
-Decode based on the HP ANSI C++ (@code{aCC}) encoding algorithm.
@item lucid
Decode based on the Lucid C++ compiler (@code{lcc}) encoding algorithm.
@@ -5441,8 +4788,9 @@ Decode using the algorithm in the @cite{C++ Annotated Reference Manual}.
debugging @code{cfront}-generated executables. @value{GDBN} would
require further enhancement to permit that.
+@item foo
+Show the list of formats.
@end table
-If you omit @var{style}, you will see a list of possible formats.
@kindex show demangle-style
@item show demangle-style
@@ -5475,15 +4823,10 @@ Do not print static members when displaying a C++ object.
@item show print static-members
Show whether C++ static members are printed, or not.
-@c These don't work with HP ANSI C++ yet.
@kindex set print vtbl
@item set print vtbl
@itemx set print vtbl on
Pretty print C++ virtual function tables. The default is off.
-@ifset HPPA
-(The @code{vtbl} commands do not work on programs compiled with the HP
-ANSI C++ compiler (@code{aCC}).)
-@end ifset
@item set print vtbl off
Do not pretty print C++ virtual function tables.
@@ -5494,7 +4837,7 @@ Show whether C++ virtual function tables are pretty printed, or not.
@end table
@end ifclear
-@node Value History, Convenience Vars, Print Settings, Data
+@node Value History
@section Value history
@cindex value history
@@ -5571,7 +4914,7 @@ values are available, @code{show values +} produces no display.
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
+@node Convenience Vars
@section Convenience variables
@cindex convenience variables
@@ -5652,13 +4995,7 @@ The variable @code{$_exitcode} is automatically set to the exit code when
the program being debugged terminates.
@end table
-@ifset HPPA
-If you refer to a function or variable name that begins with a dollar
-sign, @value{GDBN} searches for a user or system name first, before it
-searches for a convenience variable.
-@end ifset
-
-@node Registers, Floating Point Hardware, Convenience Vars, Data
+@node Registers
@section Registers
@cindex registers
@@ -5780,7 +5117,7 @@ processors.
@end ifset
@ifclear HAVE-FLOAT
-@node Floating Point Hardware, , Registers, Data
+@node Floating Point Hardware
@section Floating point hardware
@cindex floating point
@@ -5798,7 +5135,7 @@ the ARM and x86 machines.
@end ifclear
@ifclear CONLY
-@node Languages, Symbols, Data, Top
+@node Languages
@chapter Using @value{GDBN} with Different Languages
@cindex languages
@@ -5829,7 +5166,7 @@ language}.
* Support:: Supported languages
@end menu
-@node Setting, Show, Languages, Languages
+@node Setting
@section Switching between source languages
There are two ways to control the working language---either have @value{GDBN}
@@ -5861,40 +5198,33 @@ program, and will display that source code, not the generated C code.
* Automatically:: Having @value{GDBN} infer the source language
@end menu
-@node Filenames, Manually, Setting, Setting
+@node Filenames
@subsection List of filename extensions and languages
If a source file name ends in one of the following extensions, then
@value{GDBN} infers that its language is the one indicated.
@table @file
+@ifset MOD2
+@item .mod
+Modula-2 source file
+@end ifset
@item .c
C source file
@item .C
@itemx .cc
-@itemx .cp
-@itemx .cpp
@itemx .cxx
+@itemx .cpp
+@itemx .cp
@itemx .c++
C++ source file
-@item .f
-@itemx .F
-Fortran source file
-
-@ifclear HPPA
@item .ch
@itemx .c186
@itemx .c286
CHILL source file.
-@end ifclear
-
-@ifset MOD2
-@item .mod
-Modula-2 source file
-@end ifset
@item .s
@itemx .S
@@ -5902,10 +5232,7 @@ Assembler source file. This actually behaves almost like C, but
@value{GDBN} does not skip over function prologues when stepping.
@end table
-In addition, you may set the language associated with a filename
-extension. @xref{Show, , Displaying the language}.
-
-@node Manually, Automatically, Filenames, Setting
+@node Manually
@subsection Setting the working language
If you allow @value{GDBN} to set the language automatically,
@@ -5924,13 +5251,6 @@ a language, such as
@end ifset
For a list of the supported languages, type @samp{set language}.
-@ifclear MOD2
-Setting the language manually prevents @value{GDBN} from updating the
-working language automatically. For example, if you used the @code{c}
-setting to debug a C++ program, names might not be demangled properly,
-overload resolution would not work, user-defined operators might not be
-interpreted correctly, and so on.
-@end ifclear
@ifset MOD2
Setting the language manually prevents @value{GDBN} from updating the working
language automatically. This can lead to confusion if you try
@@ -5951,7 +5271,7 @@ 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.
@end ifset
-@node Automatically, , Manually, Setting
+@node Automatically
@subsection Having @value{GDBN} infer the source language
To have @value{GDBN} set the working language automatically, use
@@ -5970,14 +5290,8 @@ 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.
-@ifset MOD2
-@node Show, Checks, Setting, Languages
-@section Displaying the language
-@end ifset
-@ifclear MOD2
-@node Show, Support, Setting, Languages
+@node Show
@section Displaying the language
-@end ifclear
The following commands help you find out which language is the
working language, and also what language source files were written in.
@@ -6003,23 +5317,8 @@ Display the source language of this source file.
information listed here.
@end table
-In unusual circumstances, you may have source files with extensions
-not in the standard list. You can then set the extension associated
-with a language explicitly:
-
-@kindex set extension-language
-@kindex info extensions
-@table @code
-@item set extension-language @var{.ext} @var{language}
-Set source files with extension @var{.ext} to be assumed to be in
-the source language @var{language}.
-
-@item info extensions
-List all the filename extensions and the associated languages.
-@end table
-
@ifset MOD2
-@node Checks, Support, Show, Languages
+@node Checks
@section Type and range checking
@quotation
@@ -6052,7 +5351,7 @@ for the default settings of supported languages.
@cindex type checking
@cindex checks, type
-@node Type Checking, Range Checking, Checks, Checks
+@node Type Checking
@subsection An overview of type checking
Some languages, such as Modula-2, are strongly typed, meaning that the
@@ -6123,7 +5422,7 @@ is setting it automatically.
@cindex range checking
@cindex checks, range
-@node Range Checking, , Type Checking, Checks
+@node Range Checking
@subsection An overview of range checking
In some languages (such as Modula-2), it is an error to exceed the
@@ -6183,20 +5482,14 @@ being set automatically by @value{GDBN}.
@end table
@end ifset
-@ifset MOD2
-@node Support, , Checks, Languages
-@section Supported languages
-@end ifset
-@ifclear MOD2
-@node Support, , Show, Languages
+@node Support
@section Supported languages
-@end ifclear
@ifset MOD2
-@value{GDBN} supports C, C++, Fortran, Chill, assembly, and Modula-2.
+@value{GDBN} 4 supports C, C++, and Modula-2.
@end ifset
@ifclear MOD2
-@value{GDBN} supports C, C++, Fortran, Chill, and assembly.
+@value{GDBN} 4 supports C, and C++.
@end ifclear
Some @value{GDBN} features may be used in expressions regardless of the
language you use: the @value{GDBN} @code{@@} and @code{::} operators,
@@ -6218,70 +5511,50 @@ language reference or tutorial.
* Modula-2:: Modula-2
@end menu
-@node C, Modula-2, , Support
+@node C
@subsection C and C++
@cindex C and C++
@cindex expressions in C or C++
-@end ifset
Since C and C++ are so closely related, many features of @value{GDBN} apply
to both languages. Whenever this is the case, we discuss those languages
together.
-
+@end ifset
@ifclear MOD2
@c Cancel this below, under same condition, at end of this chapter!
@raisesections
@end ifclear
-@ifclear HPPA
@cindex C++
@kindex g++
@cindex @sc{gnu} C++
-The C++ debugging facilities are jointly implemented by the C++
+The C++ debugging facilities are jointly implemented by the @sc{gnu} C++
compiler and @value{GDBN}. Therefore, to debug your C++ code
-effectively, you must compile your C++ programs with a supported
-C++ compiler, such as @sc{gnu} @code{g++}, or the HP ANSI C++
-compiler (@code{aCC}).
+effectively, you must compile your C++ programs with the @sc{gnu} C++
+compiler, @code{g++}.
-For best results when using @sc{gnu} C++, use the stabs debugging
+For best results when debugging C++ programs, use the stabs debugging
format. You can select that format explicitly with the @code{g++}
command-line options @samp{-gstabs} or @samp{-gstabs+}. See
-@ref{Debugging Options,,Options for Debugging Your Program or @sc{gnu}
-CC, gcc.info, Using @sc{gnu} CC}, for more information.
-@end ifclear
-@ifset HPPA
-@cindex C++
-@kindex g++
-@cindex @sc{gnu} C++
-You can use @value{GDBN} to debug C programs compiled with either the HP
-C compiler (@code{cc}) or the GNU C compiler (@code{gcc}), and to debug
-programs compiled with either the HP ANSI C++ compiler (@code{aCC}) or
-the @sc{gnu} C++ compiler (@code{g++}).
-
-If you compile with the @sc{gnu} C++ compiler, use the stabs debugging
-format for best results when debugging. You can select that format
-explicitly with the @code{g++} command-line options @samp{-gstabs} or
-@samp{-gstabs+}. See @ref{Debugging Options,,Options for Debugging Your
-Program or @sc{gnu} CC, gcc.info, Using @sc{gnu} CC}, for more
-information.
-@end ifset
+@ref{Debugging Options,,Options for Debugging Your Program or @sc{gnu} CC,
+gcc.info, Using @sc{gnu} CC}, for more information.
@end ifclear
-
@ifset CONLY
-@node C, Symbols, Data, Top
+@node C
@chapter C Language Support
@cindex C language
@cindex expressions in C
Information specific to the C language is built into @value{GDBN} so that you
-can use C expressions while debugging. This also permits @value{GDBN} to
+can use C expressions while degugging. This also permits @value{GDBN} to
output values in a manner consistent with C conventions.
@menu
* C Operators:: C operators
+* C Constants:: C constants
+* Debugging C:: @value{GDBN} and C
@end menu
@end ifset
-
@ifclear CONLY
@menu
* C Operators:: C and C++ operators
@@ -6293,18 +5566,18 @@ output values in a manner consistent with C conventions.
@end ifset
* Debugging C:: @value{GDBN} and C
-* Debugging C plus plus:: @value{GDBN} features for C++
+* Debugging C plus plus:: Special features for C++
@end menu
@end ifclear
@ifclear CONLY
@cindex C and C++ operators
-@node C Operators, C Constants, , C
+@node C Operators
@subsubsection C and C++ operators
@end ifclear
@ifset CONLY
@cindex C operators
-@node C Operators, C Constants, C, C
+@node C Operators
@section C operators
@end ifset
@@ -6318,14 +5591,8 @@ For the purposes of C and C++, the following definitions hold:
@itemize @bullet
@item
-@ifclear HPPA
@emph{Integral types} include @code{int} with any of its storage-class
specifiers; @code{char}; and @code{enum}.
-@end ifclear
-@ifset HPPA
-@emph{Integral types} include @code{int} with any of its storage-class
-specifiers; @code{char}; @code{enum}; and, for C++, @code{bool}.
-@end ifset
@item
@emph{Floating-point types} include @code{float} and @code{double}.
@@ -6443,11 +5710,6 @@ Structure member, and pointer-to-structure member. For convenience,
pointer based on the stored type information.
Defined on @code{struct} and @code{union} data.
-@ifset HPPA
-@item .*@r{, }->*
-Dereferences of pointers to members.
-@end ifset
-
@item []
Array indexing. @code{@var{a}[@var{i}]} is defined as
@code{*(@var{a}+@var{i})}. Same precedence as @code{->}.
@@ -6473,33 +5735,17 @@ Same precedence as @code{::}, above.
@end ifclear
@end table
-@ifset HPPA
-If an operator is redefined in the user code, @value{GDBN} usually
-attempts to invoke the redefined version instead of using the operator's
-predefined meaning.
-@end ifset
-
@ifclear CONLY
-@menu
-* C Constants::
-@end menu
-
-@ifset MOD2
-@node C Constants, Cplus expressions, C Operators, C
-@subsubsection C and C++ constants
-@end ifset
-@ifclear MOD2
-@node C Constants, Cplus expressions, C Operators, Support
+@cindex C and C++ constants
+@node C Constants
@subsubsection C and C++ constants
-@end ifclear
-@cindex C and C++ constants
@value{GDBN} allows you to express the constants of C and C++ in the
following ways:
@end ifclear
@ifset CONLY
@cindex C constants
-@node C Constants, Debugging C, C Operators, C
+@node C Constants
@section C constants
@value{GDBN} allows you to express the constants of C in the
@@ -6551,29 +5797,13 @@ and @samp{@{&"hi", &"there", &"fred"@}} is a three-element array of pointers.
@end itemize
@ifclear CONLY
-@menu
-* Cplus expressions::
-* C Defaults::
-@ifset MOD2
-* C Checks::
-@end ifset
-
-* Debugging C::
-@end menu
-
-@ifset MOD2
-@node Cplus expressions, C Defaults, C Constants, C
-@subsubsection C++ expressions
-@end ifset
-@ifclear MOD2
-@node Cplus expressions, C Defaults, C Constants, Support
+@node Cplus expressions
@subsubsection C++ expressions
-@end ifclear
@cindex expressions in C++
-@value{GDBN} expression handling can interpret most C++ expressions.
+@value{GDBN} expression handling has a number of extensions to
+interpret a significant subset of C++ expressions.
-@ifclear HPPA
@cindex C++ support, not in @sc{coff}
@cindex @sc{coff} versus C++
@cindex C++ and object formats
@@ -6586,18 +5816,18 @@ and @samp{@{&"hi", &"there", &"fred"@}} is a three-element array of pointers.
@c FIXME!! GDB may eventually be able to debug C++ using DWARF; check
@c periodically whether this has happened...
@quotation
-@emph{Warning:} @value{GDBN} can only debug C++ code if you use the
-proper compiler. Typically, C++ debugging depends on the use of
+@emph{Warning:} @value{GDBN} can only debug C++ code if you compile with
+the @sc{gnu} C++ compiler. Moreover, C++ debugging depends on the use of
additional debugging information in the symbol table, and thus requires
-special support. In particular, if your compiler generates a.out, MIPS
-@sc{ecoff}, RS/6000 @sc{xcoff}, or @sc{elf} with stabs extensions to the
-symbol table, these facilities are all available. (With @sc{gnu} CC,
+special support. @value{GDBN} has this support @emph{only} with the
+stabs debug format. In particular, if your compiler generates a.out,
+MIPS @sc{ecoff}, RS/6000 @sc{xcoff}, or @sc{elf} with stabs extensions
+to the symbol table, these facilities are all available. (With @sc{gnu} CC,
you can use the @samp{-gstabs} option to request stabs debugging
extensions explicitly.) Where the object code format is standard
@sc{coff} or @sc{dwarf} in @sc{elf}, on the other hand, most of the C++
support in @value{GDBN} does @emph{not} work.
@end quotation
-@end ifclear
@enumerate
@@ -6617,7 +5847,6 @@ expressions have the same namespace available as the member function;
that is, @value{GDBN} allows implicit references to the class instance
pointer @code{this} following the same rules as C++.
-@ifclear HPPA
@cindex call overloaded functions
@cindex type conversions in C++
@item
@@ -6626,38 +5855,6 @@ call to the right definition, with one restriction---you must use
arguments of the type required by the function that you want to call.
@value{GDBN} does not perform conversions requiring constructors or
user-defined type operators.
-@end ifclear
-@ifset HPPA
-@cindex call overloaded functions
-@cindex overloaded functions
-@cindex type conversions in C++
-@item
-You can call overloaded functions; @value{GDBN} resolves the function
-call to the right definition, with some restrictions. GDB does not
-perform overload resolution involving user-defined type conversions,
-calls to constructors, or instantiations of templates that do not exist
-in the program. It also cannot handle ellipsis argument lists or
-default arguments.
-
-It does perform integral conversions and promotions, floating-point
-promotions, arithmetic conversions, pointer conversions, conversions of
-class objects to base classes, and standard conversions such as those of
-functions or arrays to pointers; it requires an exact match on the
-number of function arguments.
-
-Overload resolution is always performed, unless you have specified
-@code{set overload-resolution off}. @xref{Debugging C plus plus,
-,@value{GDBN} features for C++}.
-
-You must specify@code{set overload-resolution off} in order to use an
-explicit function signature to call an overloaded function, as in
-@smallexample
-p 'foo(char,int)'('x', 13)
-@end smallexample
-The @value{GDBN} command-completion facility can simplify this;
-@pxref{Completion, ,Command completion}.
-
-@end ifset
@cindex reference declarations
@item
@@ -6681,41 +5878,27 @@ resolving name scope by reference to source files, in both C and C++
debugging (@pxref{Variables, ,Program variables}).
@end enumerate
-@ifset HPPA
-In addition, @value{GDBN} supports calling virtual functions correctly,
-printing out virtual bases of objects, calling functions in a base
-subobject, casting objects, and invoking user-defined operators.
-@end ifset
-
-@ifset MOD2
-@node C Defaults, C Checks, Cplus expressions, C
+@node C Defaults
@subsubsection C and C++ defaults
-@end ifset
-@ifclear MOD2
-@node C Defaults, Debugging C, Cplus expressions, Support
-@subsubsection C and C++ defaults
-@end ifclear
@cindex C and C++ defaults
-@ifclear HPPA
If you allow @value{GDBN} to set type and range checking automatically, they
both default to @code{off} whenever the working language changes to
C or C++. This happens regardless of whether you or @value{GDBN}
selects the working language.
-@end ifclear
-If you allow @value{GDBN} to set the language automatically, it
-recognizes source files whose names end with @file{.c}, @file{.C}, or
-@file{.cc}, etc, and when @value{GDBN} enters code compiled from one of
-these files, it sets the working language to C or C++.
-@xref{Automatically, ,Having @value{GDBN} infer the source language},
-for further details.
+If you allow @value{GDBN} to set the language automatically, it recognizes
+source files whose names end with @file{.c}, @file{.C}, or @file{.cc}, and
+when @value{GDBN} enters code compiled from one of these files,
+it sets the working language to C or C++.
+@xref{Automatically, ,Having @value{GDBN} infer the source language}, for
+further details.
@ifset MOD2
@c Type checking is (a) primarily motivated by Modula-2, and (b)
@c unimplemented. If (b) changes, it might make sense to let this node
@c appear even if Mod-2 does not, but meanwhile ignore it. roland 16jul93.
-@node C Checks, Debugging C, C Defaults, C Constants
+@node C Checks
@subsubsection C and C++ type and range checks
@cindex C and C++ checks
@@ -6749,17 +5932,11 @@ that is not itself an array.
@end ifclear
@ifclear CONLY
-@ifset MOD2
-@node Debugging C, Debugging C plus plus, C Checks, C
-@subsubsection @value{GDBN} and C
-@end ifset
-@ifclear MOD2
-@node Debugging C, Debugging C plus plus, C Defaults, Support
+@node Debugging C
@subsubsection @value{GDBN} and C
@end ifclear
-@end ifclear
@ifset CONLY
-@node Debugging C, , C Constants, C
+@node Debugging C
@section @value{GDBN} and C
@end ifset
@@ -6777,18 +5954,8 @@ with pointers and a memory allocation function. @xref{Expressions,
,Expressions}.
@ifclear CONLY
-@menu
-* Debugging C plus plus::
-@end menu
-
-@ifset MOD2
-@node Debugging C plus plus, , Debugging C, C
-@subsubsection @value{GDBN} features for C++
-@end ifset
-@ifclear MOD2
-@node Debugging C plus plus, , Debugging C, Support
+@node Debugging C plus plus
@subsubsection @value{GDBN} features for C++
-@end ifclear
@cindex commands for C++
Some @value{GDBN} commands are particularly useful with C++, and some are
@@ -6809,10 +5976,10 @@ classes.
@xref{Set Breaks, ,Setting breakpoints}.
@cindex C++ exception handling
-@item catch throw
-@itemx catch catch
-Debug C++ exception handling using these commands. @xref{Set
-Catchpoints, , Setting catchpoints}.
+@item catch @var{exceptions}
+@itemx info catch
+Debug C++ exception handling using these commands. @xref{Exception
+Handling, ,Breakpoints and exceptions}.
@cindex inheritance
@item ptype @var{typename}
@@ -6838,29 +6005,6 @@ Choose whether to print derived (actual) or declared types of objects.
@itemx show print vtbl
Control the format for printing virtual function tables.
@xref{Print Settings, ,Print settings}.
-@ifset HPPA
-(The @code{vtbl} commands do not work on programs compiled with the HP
-ANSI C++ compiler (@code{aCC}).)
-
-@kindex set overload-resolution
-@cindex overloaded functions
-@item set overload-resolution on
-Enable overload resolution for C++ expression evaluation. The default
-is on. For overloaded functions, @value{GDBN} evaluates the arguments
-and searches for a function whose signature matches the argument types,
-using the standard C++ conversion rules (@pxref{Cplus expressions, ,C++
-expressions} for details). If it cannot find a match, it emits a
-message.
-
-@item set overload-resolution off
-Disable overload resolution for C++ expression evaluation. For
-overloaded functions that are not class member functions, @value{GDBN}
-chooses the first function of the specified name that it finds in the
-symbol table, whether or not its arguments are of the correct type. For
-overloaded functions that are class member functions, @value{GDBN}
-searches for a function whose signature @emph{exactly} matches the
-argument types.
-@end ifset
@item @r{Overloaded symbol names}
You can specify a particular definition of an overloaded symbol, using
@@ -6876,7 +6020,7 @@ available choices, or to finish the type list for you.
@end ifclear
@ifset MOD2
-@node Modula-2, ,C , Support
+@node Modula-2
@subsection Modula-2
@cindex Modula-2
@@ -6890,7 +6034,7 @@ table.
@cindex expressions in Modula-2
@menu
* M2 Operators:: Built-in operators
-* Built-In Func/Proc:: Built-in functions and procedures
+* Built-In 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
@@ -6899,7 +6043,7 @@ table.
* GDB/M2:: @value{GDBN} and Modula-2
@end menu
-@node M2 Operators, Built-In Func/Proc, Modula-2, Modula-2
+@node M2 Operators
@subsubsection Operators
@cindex Modula-2 operators
@@ -7023,7 +6167,7 @@ treats the use of the operator @code{IN}, or the use of operators
@end quotation
@cindex Modula-2 built-ins
-@node Built-In Func/Proc, M2 Constants, M2 Operators, Modula-2
+@node Built-In Func/Proc
@subsubsection Built-in functions and procedures
Modula-2 also makes available several built-in procedures and functions.
@@ -7135,7 +6279,7 @@ an error.
@end quotation
@cindex Modula-2 constants
-@node M2 Constants, M2 Defaults, Built-In Func/Proc, Modula-2
+@node M2 Constants
@subsubsection Constants
@value{GDBN} allows you to express the constants of Modula-2 in the following
@@ -7184,7 +6328,7 @@ Pointer constants consist of integral values only.
Set constants are not yet supported.
@end itemize
-@node M2 Defaults, Deviations, M2 Constants, Modula-2
+@node M2 Defaults
@subsubsection Modula-2 defaults
@cindex Modula-2 defaults
@@ -7198,7 +6342,7 @@ code compiled from a file whose name ends with @file{.mod} sets the
working language to Modula-2. @xref{Automatically, ,Having @value{GDBN} set
the language automatically}, for further details.
-@node Deviations, M2 Checks, M2 Defaults, Modula-2
+@node Deviations
@subsubsection Deviations from standard Modula-2
@cindex Modula-2, deviations from
@@ -7228,7 +6372,7 @@ argument.
All built-in procedures both modify @emph{and} return their argument.
@end itemize
-@node M2 Checks, M2 Scope, Deviations, Modula-2
+@node M2 Checks
@subsubsection Modula-2 type and range checks
@cindex Modula-2 checks
@@ -7256,7 +6400,7 @@ whose types are not equivalent is an error.
Range checking is done on all mathematical operations, assignment, array
index bounds, and all built-in functions and procedures.
-@node M2 Scope, GDB/M2, M2 Checks, Modula-2
+@node M2 Scope
@subsubsection The scope operators @code{::} and @code{.}
@cindex scope
@kindex .
@@ -7296,7 +6440,7 @@ 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
+@node GDB/M2
@subsubsection @value{GDBN} and Modula-2
Some @value{GDBN} commands have little use when debugging Modula-2 programs.
@@ -7319,7 +6463,7 @@ interpreted as the beginning of a comment. Use @code{<>} instead.
@end ifset
@end ifclear
-@node Symbols, Altering, Languages, Top
+@node Symbols
@chapter Examining the Symbol Table
The commands described in this section allow you to inquire about the
@@ -7473,7 +6617,6 @@ from the @code{ptype} command can be overwhelming and hard to use. The
which match the regular-expression @var{regexp}.
@end ignore
-@ifclear HPPA
@cindex reloading symbols
Some systems allow individual object files that make up your program to
be replaced without stopping and restarting your program.
@@ -7502,31 +6645,6 @@ different directories or libraries) with the same name.
@item show symbol-reloading
Show the current @code{on} or @code{off} setting.
@end table
-@end ifclear
-
-@ifset HPPA
-@kindex set opaque-type-resolution
-@item set opaque-type-resolution on
-Tell @value{GDBN} to resolve opaque types. An opaque type is a type
-declared as a pointer to a @code{struct}, @code{class}, or
-@code{union}---for example, @code{struct MyType *}---that is used in one
-source file although the full declaration of @code{struct MyType} is in
-another source file. The default is on.
-
-A change in the setting of this subcommand will not take effect until
-the next time symbols for a file are loaded.
-
-@item set opaque-type-resolution off
-Tell @value{GDBN} not to resolve opaque types. In this case, the type
-is printed as follows:
-@smallexample
-@{<no data fields>@}
-@end smallexample
-
-@kindex show opaque-type-resolution
-@item show opaque-type-resolution
-Show whether opaque types are resolved or not.
-@end ifset
@kindex maint print symbols
@cindex symbol dump
@@ -7551,7 +6669,7 @@ required for each object file from which @value{GDBN} has read some symbols.
@value{GDBN} reads symbols (in the description of @code{symbol-file}).
@end table
-@node Altering, GDB Files, Symbols, Top
+@node Altering
@chapter Altering Execution
Once you think you have found an error in your program, you might want to
@@ -7582,7 +6700,7 @@ at a different address, or even return prematurely from a function.
* Patching:: Patching your program
@end menu
-@node Assignment, Jumping, Altering, Altering
+@node Assignment
@section Assignment to variables
@cindex assignment
@@ -7610,14 +6728,13 @@ 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,
,Value history}). The expression is evaluated only for its effects.
-@ifclear HPPA
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, if your
-program has a variable @code{width}, you get an error if you try to set
-a new value with just @samp{set width=13}, because @value{GDBN} has the
-command @code{set width}:
+to @code{set} except for its lack of subcommands. For example, if
+your program has a variable @code{width}, you get
+an error if you try to set a new value with just @samp{set width=13},
+because @value{GDBN} has the command @code{set width}:
@example
(@value{GDBP}) whatis width
@@ -7635,43 +6752,6 @@ order to actually set the program's variable @code{width}, use
@example
(@value{GDBP}) set var width=47
@end example
-@end ifclear
-@ifset HPPA
-Because the @code{set} command has many subcommands that can conflict
-with the names of program variables, it is a good idea to use the
-@code{set variable} command instead of just @code{set}. For example, if
-your program has a variable @code{g}, you run into problems if you try
-to set a new value with just @samp{set g=4}, because @value{GDBN} has
-the command @code{set gnutarget}, abbreviated @code{set g}:
-
-@example
-@group
-(@value{GDBP}) whatis g
-type = double
-(@value{GDBP}) p g
-$1 = 1
-(@value{GDBP}) set g=4
-(gdb) p g
-$2 = 1
-(@value{GDBP}) r
-The program being debugged has been started already.
-Start it from the beginning? (y or n) y
-Starting program: /home/smith/cc_progs/a.out
-"/home/smith/cc_progs/a.out": can't open to read symbols: Invalid bfd target.
-(@value{GDBP}) show g
-The current BFD target is "=4".
-@end group
-@end example
-
-@noindent
-The program variable @code{g} did not change, and you silently set the
-@code{gnutarget} to an invalid value. In order to set the variable
-@code{g}, use
-
-@example
-(@value{GDBP}) set var g=4
-@end example
-@end ifset
@value{GDBN} allows more implicit conversions in assignments than C; you can
freely store an integer value into a pointer variable or vice versa,
@@ -7693,7 +6773,7 @@ set @{int@}0x83040 = 4
@noindent
stores the value 4 into that memory location.
-@node Jumping, Signaling, Assignment, Altering
+@node Jumping
@section Continuing at a different address
Ordinarily, when you continue your program, you do so at the place where
@@ -7706,9 +6786,7 @@ an address of your own choosing, with the following commands:
Resume execution at line @var{linespec}. Execution stops again
immediately if there is a breakpoint there. @xref{List, ,Printing
source lines}, for a description of the different forms of
-@var{linespec}. It is common practice to use the @code{tbreak} command
-in conjunction with @code{jump}. @xref{Set Breaks, ,Setting
-breakpoints}.
+@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
@@ -7724,8 +6802,6 @@ well acquainted with the machine-language code of your program.
Resume execution at the instruction at address @var{address}.
@end table
-@ifclear HPPA
-@c Doesn't work on HP-UX; have to set $pcoqh and $pcoqt.
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 your program running; it only changes the address of where it
@@ -7739,16 +6815,14 @@ set $pc = 0x485
makes the next @code{continue} command or stepping command execute at
address @code{0x485}, rather than at the address where your program stopped.
@xref{Continuing and Stepping, ,Continuing and stepping}.
-@end ifclear
-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.
+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.
@ifclear BARETARGET
@c @group
-@node Signaling, Returning, Jumping, Altering
+@node Signaling
@section Giving your program a signal
@table @code
@@ -7778,7 +6852,7 @@ passes the signal directly to your program.
@end ifclear
-@node Returning, Calling, Signaling, Altering
+@node Returning
@section Returning from a function
@table @code
@@ -7809,7 +6883,7 @@ returned. In contrast, the @code{finish} command (@pxref{Continuing
and Stepping, ,Continuing and stepping}) resumes execution until the
selected stack frame returns naturally.
-@node Calling, Patching, Returning, Altering
+@node Calling
@section Calling program functions
@cindex calling functions
@@ -7825,15 +6899,13 @@ execute a function from your program, but without cluttering the output
with @code{void} returned values. If the result is not void, it
is printed and saved in the value history.
-@ifclear HPPA
-For the A29K, a user-controlled variable @code{call_scratch_address},
-specifies the location of a scratch area to be used when @value{GDBN}
-calls a function in the target. This is necessary because the usual
-method of putting the scratch area on the stack does not work in systems
-that have separate instruction and data spaces.
-@end ifclear
+A new user-controlled variable, @var{call_scratch_address}, specifies
+the location of a scratch area to be used when @value{GDBN} calls a
+function in the target. This is necessary because the usual method
+of putting the scratch area on the stack does not work in systems that
+have separate instruction and data spaces.
-@node Patching, , Calling, Altering
+@node Patching
@section Patching programs
@cindex patching binaries
@cindex writing into executables
@@ -7883,7 +6955,7 @@ and core files
are opened for writing as well as reading.
@end table
-@node GDB Files, Targets, Altering, Top
+@node GDB Files
@chapter @value{GDBN} Files
@value{GDBN} needs to know the file name of the program to be debugged, both in
@@ -7898,7 +6970,7 @@ the name of the core dump file.
* Symbol Errors:: Errors reading symbol files
@end menu
-@node Files, Symbol Errors, GDB Files, GDB Files
+@node Files
@section Commands to specify files
@cindex symbol table
@@ -7933,7 +7005,6 @@ 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 @value{GDBN}
and your program, using the @code{path} command.
-@ifclear HPPA
On systems with memory-mapped files, an auxiliary file
@file{@var{filename}.syms} may hold symbol table information for
@var{filename}. If so, @value{GDBN} maps in the symbol table from
@@ -7942,7 +7013,6 @@ descriptions of the file options @samp{-mapped} and @samp{-readnow}
(available on the command line, and with the commands @code{file},
@code{symbol-file}, or @code{add-symbol-file}, described below),
for more information.
-@end ifclear
@item file
@code{file} with no argument makes @value{GDBN} discard any information it
@@ -7976,32 +7046,26 @@ executing it once.
When @value{GDBN} is configured for a particular environment, it
understands debugging information in whatever format is the standard
generated for that environment; you may use either a @sc{gnu} compiler, or
-other compilers that adhere to the local conventions.
-@ifclear HPPA
-Best results are usually obtained from @sc{gnu} compilers; for example,
-using @code{@value{GCC}} you can generate debugging information for
-optimized code.
-@end ifclear
-
-For most kinds of object files, with the exception of old SVR3 systems
-using COFF, the @code{symbol-file} command does not normally 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, as they are needed.
+other compilers that adhere to the local conventions. Best results are
+usually obtained from @sc{gnu} compilers; for example, using @code{@value{GCC}}
+you can generate debugging information for optimized code.
+
+On some kinds of object files, the @code{symbol-file} command does not
+normally 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,
+as they are needed.
+
+The purpose of this two-stage reading strategy is to make @value{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, ,Optional warnings
+and messages}.)
-The purpose of this two-stage reading strategy is to make @value{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, ,Optional
-warnings and messages}.)
-
-@ifclear HPPA
We have not implemented the two-stage strategy for COFF yet. When the
symbol table is stored in COFF format, @code{symbol-file} reads the
-symbol table data in full right away. Note that ``stabs-in-COFF''
-still does the two-stage strategy, since the debug info is actually
-in stabs format.
+symbol table data in full right away.
@kindex readnow
@cindex reading symbols immediately
@@ -8015,10 +7079,8 @@ You can override the @value{GDBN} two-stage strategy for reading symbol
tables by using the @samp{-readnow} option with any of the commands that
load symbol table information, if you want to be sure @value{GDBN} has the
entire symbol table available.
-@end ifclear
@ifclear BARETARGET
-@ifclear HPPA
If memory-mapped files are available on your system through the
@code{mmap} system call, you can use another option, @samp{-mapped}, to
cause @value{GDBN} to write the symbols for your program into a reusable
@@ -8040,7 +7102,6 @@ needed.
The @file{.syms} file is specific to the host machine where you run
@value{GDBN}. It holds an exact image of the internal @value{GDBN}
symbol table. It cannot be shared across multiple host platforms.
-@end ifclear
@c FIXME: for now no mention of directories, since this seems to be in
@c flux. 13mar1992 status is that in theory GDB would look either in
@@ -8068,8 +7129,54 @@ program is running. To do this, use the @code{kill} command
(@pxref{Kill Process, ,Killing the child process}).
@end ifclear
+@kindex load @var{filename}
+@item load @var{filename}
+@ifset GENERIC
+Depending on what remote debugging facilities are configured into
+@value{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 the @var{filename} symbol table in @value{GDBN}, like
+the @code{add-symbol-file} command.
+
+If your @value{GDBN} does not have a @code{load} command, attempting to
+execute it gets the error message ``@code{You can't do that when your
+target is @dots{}}''
+@end ifset
+
+The file is loaded at whatever address is specified in the executable.
+For some object file formats, you can specify the load address when you
+link the program; for other formats, like a.out, the object file format
+specifies a fixed address.
+@c FIXME! This would be a good place for an xref to the GNU linker doc.
+
+@ifset VXWORKS
+On VxWorks, @code{load} links @var{filename} dynamically on the
+current target system as well as adding its symbols in @value{GDBN}.
+@end ifset
+
+@ifset I960
+@cindex download to Nindy-960
+With the Nindy interface to an Intel 960 board, @code{load}
+downloads @var{filename} to the 960 as well as adding its symbols in
+@value{GDBN}.
+@end ifset
+
+@ifset H8
+@cindex download to H8/300 or H8/500
+@cindex H8/300 or H8/500 download
+@cindex download to Hitachi SH
+@cindex Hitachi SH download
+When you select remote debugging to a Hitachi SH, H8/300, or H8/500 board
+(@pxref{Hitachi Remote,,@value{GDBN} and Hitachi Microprocessors}),
+the @code{load} command downloads your program to the Hitachi board and also
+opens it as the current executable target for @value{GDBN} on your host
+(like the @code{file} command).
+@end ifset
+
+@code{load} does not repeat if you press @key{RET} again after using it.
+
@ifclear BARETARGET
-@ifclear HPPA
@kindex add-symbol-file
@cindex dynamic linking
@item add-symbol-file @var{filename} @var{address}
@@ -8100,9 +7207,7 @@ operating system for the Motorola 88k. @value{GDBN} automatically looks for
shared libraries, however if @value{GDBN} does not find yours, you can run
@code{add-shared-symbol-file}. It takes no arguments.
@end ifclear
-@end ifclear
-@ifclear HPPA
@kindex section
@item section
The @code{section} command changes the base address of section SECTION of
@@ -8111,7 +7216,6 @@ section addresses, (such as in the a.out format), or when the addresses
specified in the file itself are wrong. Each section must be changed
separately. The ``info files'' command lists all the sections and their
addresses.
-@end ifclear
@kindex info files
@kindex info target
@@ -8137,23 +7241,12 @@ name and remembers it that way.
@ifclear BARETARGET
@cindex shared libraries
-@ifclear HPPA
-@c added HP-UX -- Kim (HP writer)
-@value{GDBN} supports HP-UX, SunOS, SVr4, Irix 5, and IBM RS/6000 shared
-libraries.
-@end ifclear
-@ifset HPPA
-@value{GDBN} supports HP-UX shared libraries.
-@end ifset
+@value{GDBN} supports SunOS, SVr4, Irix 5, and IBM RS/6000 shared libraries.
@value{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, @value{GDBN} does not understand
references to a function in a shared library, however---unless you are
debugging a core file).
-@ifset HPPA
-If the program loads a library explicitly, @value{GDBN} automatically
-loads the symbols at the time of the @code{shl_load} call.
-@end ifset
@c FIXME: some @value{GDBN} release may permit some refs to undef
@c FIXME...symbols---eg in a break cmd---assuming they are from a shared
@c FIXME...lib; check this from time to time when updating manual
@@ -8177,39 +7270,9 @@ 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
-
-@ifset HPPA
-@value{GDBN} detects the loading of a shared library and automatically
-reads in symbols from the newly loaded library, up to a threshold that
-is initially set but that you can modify if you wish.
-
-Beyond that threshold, symbols from shared libraries must be explicitly
-loaded. To load these symbols, use the command @code{sharedlibrary}
-@var{filename}. The base address of the shared library is determined
-automatically by @value{GDBN} and need not be specified.
-
-To display or set the threshold, use the commands:
-
-@table @code
-@kindex set auto-solib-add
-@item set auto-solib-add @var{threshold}
-Set the autoloading size threshold, in megabytes. If @var{threshold} is
-nonzero, symbols from all shared object libraries will be loaded
-automatically when the inferior begins execution or when the dynamic
-linker informs @value{GDBN} that a new library has been loaded, until
-the symbol table of the program and libraries exceeds this threshold.
-Otherwise, symbols must be loaded manually, using the
-@code{sharedlibrary} command. The default threshold is 100 megabytes.
-
-@kindex show auto-solib-add
-@item show auto-solib-add
-Display the current autoloading size threshold, in megabytes.
-@end table
-@end ifset
-
@end ifclear
-@node Symbol Errors, , Files, GDB Files
+@node Symbol Errors
@section Errors reading symbol files
While reading a symbol file, @value{GDBN} occasionally encounters problems,
@@ -8305,13 +7368,12 @@ for it.
@value{GDBN} could not parse a type specification output by the compiler.
@end table
-@node Targets, Controlling GDB, GDB Files, Top
+@node Targets
@chapter Specifying a Debugging Target
@cindex debugging target
@kindex target
A @dfn{target} is the execution environment occupied by your program.
-@ifclear HPPA
@ifclear BARETARGET
Often, @value{GDBN} runs in the same host environment as your program; in
that case, the debugging target is specified as a side effect when you
@@ -8320,29 +7382,6 @@ flexibility---for example, running @value{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
@end ifclear
-@end ifclear
-@ifset HPPA
-On HP-UX systems, @value{GDBN} has been configured to support debugging
-of processes running on the PA-RISC architecture. This means that the
-only possible targets are:
-
-@itemize @bullet
-@item
-An executable that has been compiled and linked to run on HP-UX
-
-@item
-A live HP-UX process, either started by @value{GDBN} (with the
-@code{run} command) or started outside of @value{GDBN} and attached to
-(with the @code{attach} command)
-
-@item
-A core file generated by an HP-UX process that previously aborted
-execution
-@end itemize
-
-@value{GDBN} on HP-UX has not been configured to support remote
-debugging, or to support programs running on other platforms. You
-@end ifset
@ifset BARETARGET
You
@end ifset
@@ -8353,14 +7392,10 @@ targets}).
@menu
* Active Targets:: Active targets
* Target Commands:: Commands for managing targets
-@ifset REMOTESTUB
-* Byte Order:: Choosing target byte order
* Remote:: Remote debugging
-@end ifset
-
@end menu
-@node Active Targets, Target Commands, Targets, Targets
+@node Active Targets
@section Active targets
@cindex stacking targets
@cindex active targets
@@ -8406,7 +7441,7 @@ the @code{attach} command (@pxref{Attach, ,Debugging an
already-running process}).
@end ifclear
-@node Target Commands, Byte Order, Active Targets, Targets
+@node Target Commands
@section Commands for managing targets
@table @code
@@ -8440,14 +7475,14 @@ select it.
@kindex set gnutarget
@item set gnutarget @var{args}
-@value{GDBN} uses its own library BFD to read your files. @value{GDBN}
+@value{GDBN}uses its own library BFD to read your files. @value{GDBN}
knows whether it is reading an @dfn{executable},
-a @dfn{core}, or a @dfn{.o} file; however, you can specify the file format
+a @dfn{core}, or a @dfn{.o} file, however you can specify the file format
with the @code{set gnutarget} command. Unlike most @code{target} commands,
with @code{gnutarget} the @code{target} refers to a program, not a machine.
@emph{Warning:} To specify a file format with @code{set gnutarget},
-you must know the actual BFD name.
+you must know the actual BFD name.
@noindent @xref{Files, , Commands to specify files}.
@@ -8455,17 +7490,12 @@ you must know the actual BFD name.
@item show gnutarget
Use the @code{show gnutarget} command to display what file format
@code{gnutarget} is set to read. If you have not set @code{gnutarget},
-@value{GDBN} will determine the file format for each file automatically,
-and @code{show gnutarget} displays @samp{The current BDF target is "auto"}.
+@value{GDBN} will determine the file format for each file automatically
+and @code{show gnutarget} displays @code{The current BDF target is "auto"}.
@end table
-@ifclear HPPA
Here are some common targets (available, or not, depending on the GDB
configuration):
-@end ifclear
-@ifset HPPA
-These are the valid targets on HP-UX systems:
-@end ifset
@table @code
@kindex target exec
@@ -8480,6 +7510,7 @@ A core dump file. @samp{target core @var{filename}} is the same as
@samp{core-file @var{filename}}.
@end ifclear
+@ifset REMOTESTUB
@kindex target remote
@item target remote @var{dev}
Remote serial target in GDB-specific protocol. The argument @var{dev}
@@ -8488,27 +7519,20 @@ specifies what serial device to use for the connection (e.g.
now supports the @code{load} command. This is only useful if you have
some other way of getting the stub to the target system, and you can put
it somewhere in memory where it won't get clobbered by the download.
+@end ifset
-@ifclear HPPA
+@ifset SIMS
@kindex target sim
@item target sim
CPU simulator. @xref{Simulator,,Simulated CPU Target}.
-@end ifclear
-@end table
-
-The following targets are all CPU-specific, and only available for
-specific configurations.
-@c should organize by CPU
-
-@table @code
-
-@kindex target abug
-@item target abug @var{dev}
-ABug ROM monitor for M68K.
+@end ifset
-@kindex target adapt
-@item target adapt @var{dev}
-Adapt monitor for A29K.
+@ifset AMD29K
+@kindex target udi
+@item target udi @var{keyword}
+Remote AMD29K target, using the AMD UDI protocol. The @var{keyword}
+argument specifies which 29K board or simulator to use. @xref{UDI29K
+Remote,,The UDI protocol for AMD29K}.
@kindex target amd-eb
@item target amd-eb @var{dev} @var{speed} @var{PROG}
@@ -8519,127 +7543,27 @@ Remote PC-resident AMD EB29K board, attached over serial lines.
name of the program to be debugged, as it appears to DOS on the PC.
@xref{EB29K Remote, ,The EBMON protocol for AMD29K}.
-@kindex target array
-@item target array @var{dev}
-Array Tech LSI33K RAID controller board.
-
-@kindex target bug
-@item target bug @var{dev}
-BUG monitor, running on a MVME187 (m88k) board.
-
-@kindex target cpu32bug
-@item target cpu32bug @var{dev}
-CPU32BUG monitor, running on a CPU32 (M68K) board.
-
-@kindex target dbug
-@item target dbug @var{dev}
-dBUG ROM monitor for Motorola ColdFire.
-
-@kindex target ddb
-@item target ddb @var{dev}
-NEC's DDB monitor for Mips Vr4300.
-
-@kindex target dink32
-@item target dink32 @var{dev}
-DINK32 ROM monitor for PowerPC.
-
-@kindex target e7000
-@item target e7000 @var{dev}
-E7000 emulator for Hitachi H8 and SH.
-
-@kindex target es1800
-@item target es1800 @var{dev}
-ES-1800 emulator for M68K.
-
-@kindex target est
-@item target est @var{dev}
-EST-300 ICE monitor, running on a CPU32 (M68K) board.
-
+@end ifset
+@ifset H8
@kindex target hms
@item target hms @var{dev}
A Hitachi SH, H8/300, or H8/500 board, attached via serial line to your host.
@ifclear H8EXCLUSIVE
Use special commands @code{device} and @code{speed} to control the serial
line and the communications speed used.
+@end ifclear
@xref{Hitachi Remote,,@value{GDBN} and Hitachi Microprocessors}.
-@kindex target lsi
-@item target lsi @var{dev}
-LSI ROM monitor for Mips.
-
-@kindex target m32r
-@item target m32r @var{dev}
-Mitsubishi M32R/D ROM monitor.
-
-@kindex target mips
-@item target mips @var{dev}
-IDT/SIM ROM monitor for Mips.
-
-@kindex target mon960
-@item target mon960 @var{dev}
-MON960 monitor for Intel i960.
-
+@end ifset
+@ifset I960
@kindex target nindy
@item target nindy @var{devicename}
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, ,@value{GDBN} with a remote i960 (Nindy)}.
-@kindex target nrom
-@item target nrom @var{dev}
-NetROM ROM emulator. This target only supports downloading.
-
-@kindex target op50n
-@item target op50n @var{dev}
-OP50N monitor, running on an OKI HPPA board.
-
-@kindex target pmon
-@item target pmon @var{dev}
-PMON ROM monitor for Mips.
-
-@kindex target ppcbug
-@item target ppcbug @var{dev}
-@kindex target ppcbug1
-@item target ppcbug1 @var{dev}
-PPCBUG ROM monitor for PowerPC.
-
-@kindex target r3900
-@item target r3900 @var{dev}
-Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips.
-
-@kindex target rdi
-@item target rdi @var{dev}
-ARM Angel monitor, via RDI library interface.
-
-@kindex target rdp
-@item target rdp @var{dev}
-ARM Demon monitor.
-
-@kindex target rom68k
-@item target rom68k @var{dev}
-ROM 68K monitor, running on an M68K IDP board.
-
-@kindex target rombug
-@item target rombug @var{dev}
-ROMBUG ROM monitor for OS/9000.
-
-@kindex target sds
-@item target sds @var{dev}
-SDS monitor, running on a PowerPC board (such as Motorola's ADS).
-
-@kindex target sparclite
-@item target sparclite @var{dev}
-Fujitsu sparclite boards, used only for the purpose of loading.
-You must use an additional command to debug the program.
-For example: target remote @var{dev} using @value{GDBN} standard
-remote protocol.
-
-@kindex target sh3
-@kindex target sh3e
-@item target sh3 @var{dev}
-@item target sh3e @var{dev}
-Hitachi SH-3 and SH-3E target systems.
-
+@end ifset
+@ifset ST2000
@kindex target st2000
@item target st2000 @var{dev} @var{speed}
A Tandem ST2000 phone switch, running Tandem's STDBUG protocol. @var{dev}
@@ -8647,86 +7571,53 @@ is the name of the device attached to the ST2000 serial line;
@var{speed} is the communication line speed. The arguments are not used
if @value{GDBN} is configured to connect to the ST2000 using TCP or Telnet.
@xref{ST2000 Remote,,@value{GDBN} with a Tandem ST2000}.
+@end ifset
-@kindex target udi
-@item target udi @var{keyword}
-Remote AMD29K target, using the AMD UDI protocol. The @var{keyword}
-argument specifies which 29K board or simulator to use. @xref{UDI29K
-Remote,,The UDI protocol for AMD29K}.
-
+@ifset VXWORKS
@kindex target vxworks
@item target vxworks @var{machinename}
A VxWorks system, attached via TCP/IP. The argument @var{machinename}
is the target system's machine name or IP address.
@xref{VxWorks Remote, ,@value{GDBN} and VxWorks}.
+@end ifset
+
+@kindex target cpu32bug
+@item target cpu32bug @var{dev}
+CPU32BUG monitor, running on a CPU32 (M68K) board.
+
+@kindex target op50n
+@item target op50n @var{dev}
+OP50N monitor, running on an OKI HPPA board.
@kindex target w89k
@item target w89k @var{dev}
W89K monitor, running on a Winbond HPPA board.
-@end ifclear
-@end table
+@kindex target est
+@item target est @var{dev}
+EST-300 ICE monitor, running on a CPU32 (M68K) board.
-@ifset GENERIC
-Different targets are available on different configurations of @value{GDBN};
-your configuration may have more or fewer targets.
-@end ifset
+@kindex target rom68k
+@item target rom68k @var{dev}
+ROM 68K monitor, running on an IDP board.
-Many remote targets require you to download the executable's code
-once you've successfully established a connection.
+@kindex target array
+@item target array @var{dev}
+Array Tech LSI33K RAID controller board.
-@table @code
+@kindex target sparclite
+@item target sparclite @var{dev}
+Fujitsu sparclite boards, used only for the purpose of loading.
+You must use an additional command to debug the program.
+For example: target remote @var{dev} using @value{GDBN} standard
+remote protocol.
+@end table
-@kindex load @var{filename}
-@item load @var{filename}
@ifset GENERIC
-Depending on what remote debugging facilities are configured into
-@value{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 the @var{filename} symbol table in @value{GDBN}, like
-the @code{add-symbol-file} command.
-
-If your @value{GDBN} does not have a @code{load} command, attempting to
-execute it gets the error message ``@code{You can't do that when your
-target is @dots{}}''
-@end ifset
-
-The file is loaded at whatever address is specified in the executable.
-For some object file formats, you can specify the load address when you
-link the program; for other formats, like a.out, the object file format
-specifies a fixed address.
-@c FIXME! This would be a good place for an xref to the GNU linker doc.
-
-@ifset VXWORKS
-On VxWorks, @code{load} links @var{filename} dynamically on the
-current target system as well as adding its symbols in @value{GDBN}.
-@end ifset
-
-@ifset I960
-@cindex download to Nindy-960
-With the Nindy interface to an Intel 960 board, @code{load}
-downloads @var{filename} to the 960 as well as adding its symbols in
-@value{GDBN}.
-@end ifset
-
-@ifset H8
-@cindex download to H8/300 or H8/500
-@cindex H8/300 or H8/500 download
-@cindex download to Hitachi SH
-@cindex Hitachi SH download
-When you select remote debugging to a Hitachi SH, H8/300, or H8/500 board
-(@pxref{Hitachi Remote,,@value{GDBN} and Hitachi Microprocessors}),
-the @code{load} command downloads your program to the Hitachi board and also
-opens it as the current executable target for @value{GDBN} on your host
-(like the @code{file} command).
+Different targets are available on different configurations of @value{GDBN};
+your configuration may have more or fewer targets.
@end ifset
-@code{load} does not repeat if you press @key{RET} again after using it.
-@end table
-
-@ifset REMOTESTUB
-@node Byte Order, Remote, Target Commands, Targets
@section Choosing target byte order
@cindex choosing target byte order
@cindex target byte order
@@ -8735,37 +7626,17 @@ opens it as the current executable target for @value{GDBN} on your host
@kindex set endian auto
@kindex show endian
-Some types of processors, such as the MIPS, PowerPC, and Hitachi SH,
-offer the ability to run either big-endian or little-endian byte
-orders. Usually the executable or symbol will include a bit to
-designate the endian-ness, and you will not need to worry about
-which to use. However, you may still find it useful to adjust
-GDB's idea of processor endian-ness manually.
-
-@table @code
-@kindex set endian big
-@item set endian big
-Instruct @value{GDBN} to assume the target is big-endian.
-
-@kindex set endian little
-@item set endian little
-Instruct @value{GDBN} to assume the target is little-endian.
-
-@kindex set endian auto
-@item set endian auto
-Instruct @value{GDBN} to use the byte order associated with the
-executable.
-
-@item show endian
-Display @value{GDBN}'s current idea of the target byte order.
-
-@end table
-
-Note that these commands merely adjust interpretation of symbolic
-data on the host, and that they have absolutely no effect on the
-target system.
+You can now choose which byte order to use with a target system.
+Use the @code{set endian big} and @code{set endian little} commands.
+Use the @code{set endian auto} command to instruct
+@value{GDBN} to use the byte order associated with the executable.
+You can see the current setting for byte order with the @code{show endian}
+command.
+
+@emph{Warning:} Currently, only embedded MIPS configurations support
+dynamic selection of target byte order.
-@node Remote, , Byte Order, Targets
+@node Remote
@section Remote debugging
@cindex remote debugging
@@ -8784,7 +7655,6 @@ communicate with @value{GDBN}.
Other remote targets may be available in your
configuration of @value{GDBN}; use @code{help target} to list them.
-@end ifset
@ifset GENERIC
@c Text on starting up GDB in various specific cases; it goes up front
@@ -8813,9 +7683,6 @@ configuration of @value{GDBN}; use @code{help target} to list them.
@ifset MIPS
* MIPS Remote:: @value{GDBN} and MIPS boards
@end ifset
-@ifset SPARCLET
-* Sparclet Remote:: @value{GDBN} and Sparclet boards
-@end ifset
@ifset SIMS
* Simulator:: Simulated CPU target
@end ifset
@@ -8841,7 +7708,7 @@ here.
* Messages/Warnings:: Optional warnings and messages
@end menu
-@node Prompt, Editing, Controlling GDB, Controlling GDB
+@node Prompt
@section Prompt
@cindex prompt
@@ -8867,7 +7734,7 @@ Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth.
Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
@end table
-@node Editing, History, Prompt, Controlling GDB
+@node Editing
@section Command editing
@cindex readline
@cindex command line editing
@@ -8897,7 +7764,7 @@ Disable command line editing.
Show whether command line editing is enabled.
@end table
-@node History, Screen Size, Editing, Controlling GDB
+@node History
@section Command history
@value{GDBN} can keep track of the commands you type during your
@@ -8993,7 +7860,7 @@ Print ten commands centered on command number @var{n}.
Print ten commands just after the commands last printed.
@end table
-@node Screen Size, Numbers, History, Controlling GDB
+@node Screen Size
@section Screen size
@cindex size of screen
@cindex pauses in output
@@ -9034,7 +7901,7 @@ Likewise, you can specify @samp{set width 0} to prevent @value{GDBN}
from wrapping its output.
@end table
-@node Numbers, Messages/Warnings, Screen Size, Controlling GDB
+@node Numbers
@section Numbers
@cindex number representation
@cindex entering numbers
@@ -9080,7 +7947,7 @@ Display the current default base for numeric input.
Display the current default base for numeric display.
@end table
-@node Messages/Warnings, , Numbers, Controlling GDB
+@node Messages/Warnings
@section Optional warnings and messages
By default, @value{GDBN} is silent about its inner workings. If you are running
@@ -9151,7 +8018,7 @@ Enables confirmation requests (the default).
Displays state of confirmation requests.
@end table
-@node Sequences, Emacs, Controlling GDB, Top
+@node Sequences
@chapter Canned Sequences of Commands
Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint
@@ -9160,12 +8027,12 @@ for execution as a unit: user-defined commands and command files.
@menu
* Define:: User-defined commands
-* Hooks:: User-defined command hooks
+* Hooks:: User-defined command hooks
* Command Files:: Command files
* Output:: Commands for controlled output
@end menu
-@node Define, Hooks, Sequences, Sequences
+@node Define
@section User-defined commands
@cindex user-defined command
@@ -9254,7 +8121,7 @@ without asking when used inside a user-defined command. Many @value{GDBN}
commands that normally print messages to say what they are doing omit the
messages when used in a user-defined command.
-@node Hooks, Command Files, Define, Sequences
+@node Hooks
@section User-defined command hooks
@cindex command files
@@ -9300,7 +8167,7 @@ If an error occurs during the execution of your hook, execution of
If you try to define a hook which does not match any known command, you
get a warning from the @code{define} command.
-@node Command Files, Output, Hooks, Sequences
+@node Command Files
@section Command files
@cindex command files
@@ -9310,24 +8177,25 @@ 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}
+@cindex @file{@value{GDBINIT}}
When you start @value{GDBN}, it automatically executes commands from its
-@dfn{init files}. These are files named @file{.gdbinit} on Unix, or
-@file{gdb.ini} on DOS/Windows. @value{GDBN} reads the init file (if
-any) in your home directory, then processes command line options and
-operands, and then reads the init file (if any) in the current working
-directory. This is so the init file in your home directory can set
-options (such as @code{set complaints}) which affect the processing of
-the command line options and operands. The init files are not executed
-if you use the @samp{-nx} option; @pxref{Mode Options, ,Choosing modes}.
+@dfn{init files}. These are files named @file{@value{GDBINIT}}.
+@value{GDBN} reads the init file (if any) in your home directory, then
+processes command line options and operands, and then reads the init
+file (if any) in the current working directory. This is so the init
+file in your home directory can set options (such as @code{set
+complaints}) which affect the processing of the command line options and
+operands. The init files are not executed if you use the @samp{-nx}
+option; @pxref{Mode Options, ,Choosing modes}.
@ifset GENERIC
@cindex init file name
On some configurations of @value{GDBN}, the init file is known by a
different name (these are typically environments where a specialized
-form of @value{GDBN} may need to coexist with other forms, hence a
-different name for the specialized version's init file). These are the
-environments with special init file names:
+form of @value{GDBN} may need to coexist with other forms,
+hence a different name
+for the specialized version's init file). These are the environments
+with special init file names:
@kindex .vxgdbinit
@itemize @bullet
@@ -9362,7 +8230,7 @@ without asking when used in a command file. Many @value{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
+@node Output
@section Commands for controlled output
During the execution of a command file or a user-defined command, normal
@@ -9439,7 +8307,7 @@ letter.
@end table
@ifclear DOSHOST
-@node Emacs, GDB Bugs, Sequences, Top
+@node Emacs
@chapter Using @value{GDBN} under @sc{gnu} Emacs
@cindex Emacs
@@ -9452,9 +8320,6 @@ 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
@value{GDBN} as a subprocess of Emacs, with input and output through a newly
created Emacs buffer.
-@ifset HPPA
-(Do not use the @code{-tui} option to run @value{GDBN} from Emacs.)
-@end ifset
Using @value{GDBN} under Emacs is just like using @value{GDBN} normally except for two
things:
@@ -9616,9 +8481,36 @@ each value is printed in its own window.
@end ignore
@end ifclear
+@ifset LUCID
+@node Energize
+@chapter Using @value{GDBN} with Energize
+
+@cindex Energize
+The Energize Programming System is an integrated development environment
+that includes a point-and-click interface to many programming tools.
+When you use @value{GDBN} in this environment, you can use the standard
+Energize graphical interface to drive @value{GDBN}; you can also, if you
+choose, type @value{GDBN} commands as usual in a debugging window. Even if
+you use the graphical interface, the debugging window (which uses Emacs,
+and resembles the standard @sc{gnu} Emacs interface to
+@value{GDBN}) displays the
+equivalent commands, so that the history of your debugging session is
+properly reflected.
+
+When Energize starts up a @value{GDBN} session, it uses one of the
+command-line options @samp{-energize} or @samp{-cadillac} (``cadillac''
+is the name of the communications protocol used by the Energize system).
+This option makes @value{GDBN} run as one of the tools in the Energize Tool
+Set: it sends all output to the Energize kernel, and accept input from
+it as well.
+
+See the user manual for the Energize Programming System for
+information on how to use the Energize graphical interface and the other
+development tools that Energize integrates with @value{GDBN}.
+
+@end ifset
+
@node GDB Bugs
-@c links whacked to pacify makeinfo
-@c , Command Line Editing, Emacs, Top
@chapter Reporting Bugs in @value{GDBN}
@cindex bugs in @value{GDBN}
@cindex reporting bugs in @value{GDBN}
@@ -9638,7 +8530,7 @@ information that enables us to fix the bug.
* Bug Reporting:: How to report bugs
@end menu
-@node Bug Criteria, Bug Reporting, GDB Bugs, GDB Bugs
+@node Bug Criteria
@section Have you found a bug?
@cindex bug criteria
@@ -9654,9 +8546,7 @@ If the debugger gets a fatal signal, for any input whatever, that is a
@cindex error on valid input
@item
-If @value{GDBN} produces an error message for valid input, that is a
-bug. (Note that if you're cross debugging, the problem may also be
-somewhere in the connection to the target.)
+If @value{GDBN} produces an error message for valid input, that is a bug.
@cindex invalid input
@item
@@ -9670,12 +8560,11 @@ If you are an experienced user of debugging tools, your suggestions
for improvement of @value{GDBN} are welcome in any case.
@end itemize
-@node Bug Reporting, , Bug Criteria, GDB Bugs
+@node Bug Reporting
@section How to report bugs
@cindex bug reports
@cindex @value{GDBN} bugs, reporting
-@ifclear HPPA
A number of companies and individuals offer support for @sc{gnu} products.
If you obtained @value{GDBN} from a support organization, we recommend you
contact that organization first.
@@ -9683,19 +8572,18 @@ contact that organization first.
You can find contact information for many support companies and
individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
distribution.
-@c should add a web page ref...
-In any event, we also recommend that you send bug reports for
-@value{GDBN} to this addresses:
+In any event, we also recommend that you send bug reports for @value{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 @value{GDBN} do
-not want to receive bug reports. Those that do have arranged to receive
-@samp{bug-gdb}.
+@samp{help-gdb}, or to any newsgroups.} Most users of @value{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
@@ -9715,15 +8603,6 @@ Free Software Foundation Inc.
Boston, MA 02111-1307
USA
@end example
-@end ifclear
-
-@ifset HPPA
-If you obtained HP GDB as part of your HP ANSI C or HP ANSI C++ compiler
-kit, report problems to your HP Support Representative.
-
-If you obtained HP GDB from the Hewlett-Packard Web site, report
-problems by electronic mail to @code{wdb-www@@ch.hp.com}.
-@end ifset
The fundamental principle of reporting bugs usefully is this:
@strong{report all the facts}. If you are not sure whether to state a
@@ -9739,10 +8618,16 @@ 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. It may be that the bug has been reported previously, but neither
-you nor we can know that unless your bug report is complete and
-self-contained.
+Keep in mind that the purpose of a bug report is to enable us to fix
+the bug if it is new to us.
+@c
+@c FIX ME!!--What the heck does the following sentence mean,
+@c in the context of the one above?
+@c
+@c It is not as important as what happens if the bug is already known.
+@c
+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
@@ -9753,9 +8638,8 @@ To enable us to fix the bug, you should include all these things:
@itemize @bullet
@item
-The version of @value{GDBN}. @value{GDBN} announces it if you start
-with no arguments; you can also print it at any time using @code{show
-version}.
+The version of @value{GDBN}. @value{GDBN} announces it if you start with no
+arguments; you can also print it at any time using @code{show version}.
Without this, we will not know whether there is any point in looking for
the bug in the current version of @value{GDBN}.
@@ -9764,18 +8648,13 @@ the bug in the current version of @value{GDBN}.
The type of machine you are using, and the operating system name and
version number.
-@ifclear HPPA
@item
What compiler (and its version) was used to compile @value{GDBN}---e.g.
-``@value{GCC}--2.8.1''.
-@end ifclear
+``@value{GCC}--2.0''.
@item
-What compiler (and its version) was used to compile the program you are
-debugging---e.g. ``@value{GCC}--2.8.1'', or ``HP92453-01 A.10.32.03 HP
-C Compiler''. For GCC, you can say @code{gcc --version} to get this
-information; for other compilers, see the documentation for those
-compilers.
+What compiler (and its version) was used to compile the program you
+are debugging---e.g. ``@value{GCC}--2.0''.
@item
The command arguments you gave the compiler to compile your example and
@@ -9794,21 +8673,20 @@ reproduce the bug.
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 @value{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. You might as well not give us
-a chance to make a mistake.
+Of course, if the bug is that @value{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. 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 @value{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.
-
-@ifclear HPPA
+say so explicitly. Suppose something strange is going on, such as,
+your copy of @value{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 @value{GDBN} source, send us context
diffs. If you even discuss something in the @value{GDBN} source, refer to
@@ -9816,7 +8694,6 @@ it by context, not by line number.
The line numbers in our development sources will not match those in your
sources. Your line numbers would convey no useful information to us.
-@end ifclear
@end itemize
Here are some things that are not necessary:
@@ -9875,12 +8752,129 @@ things without first using the debugger to find the facts.
@include rluser.texinfo
@include inc-hist.texi
+@ifset NOVEL
+@ifset RENAMED
+@node Renamed Commands
+@appendix Renamed Commands
+
+The following commands were renamed in @value{GDBN} 4, 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
+@end ifset
+@end ifset
@ifclear PRECONFIGURED
-@ifclear HPPA
@node Formatting Documentation
-@c links whacked to pacify makeinfo
-@c , Installing GDB, Renamed Commands, Top
@appendix Formatting Documentation
@cindex @value{GDBN} reference card
@@ -9914,22 +8908,22 @@ on-line information and a printed manual. You can use one of the Info
formatting commands to create the on-line version of the documentation
and @TeX{} (or @code{texi2roff}) to typeset the printed version.
-@value{GDBN} includes an already formatted copy of the on-line Info
-version of this manual in the @file{gdb} subdirectory. The main Info
-file is @file{gdb-@value{GDBVN}/gdb/gdb.info}, and it refers to
+@value{GDBN} includes an already formatted copy of the on-line Info version of
+this manual in the @file{gdb} subdirectory. The main Info file is
+@file{gdb-@r{version-number}/gdb/gdb.info}, and it refers to
subordinate files matching @samp{gdb.info*} in the same directory. If
necessary, you can print out these files, or read them with any editor;
-but they are easier to read using the @code{info} subsystem in @sc{gnu}
-Emacs or the standalone @code{info} program, available as part of the
-@sc{gnu} Texinfo distribution.
+but they are easier to read using the @code{info} subsystem in @sc{gnu} Emacs
+or the standalone @code{info} program, available as part of the @sc{gnu}
+Texinfo distribution.
If you want to format these Info files yourself, you need one of the
Info formatting programs, such as @code{texinfo-format-buffer} or
@code{makeinfo}.
-If you have @code{makeinfo} installed, and are in the top level
-@value{GDBN} source directory (@file{gdb-@value{GDBVN}}, in the case of
-version @value{GDBVN}), you can make the Info file by typing:
+If you have @code{makeinfo} installed, and are in the top level @value{GDBN}
+source directory (@file{gdb-@value{GDBVN}}, in the case of version @value{GDBVN}), you can
+make the Info file by typing:
@example
cd gdb
@@ -9958,50 +8952,17 @@ directory.
If you have @TeX{} and a @sc{dvi} printer program installed, you can
typeset and print this manual. First switch to the the @file{gdb}
subdirectory of the main source directory (for example, to
-@file{gdb-@value{GDBVN}/gdb}) and type:
+@file{gdb-@value{GDBVN}/gdb}) and then type:
@example
make gdb.dvi
@end example
-Then give @file{gdb.dvi} to your @sc{dvi} printing program.
-@end ifclear
-
-@node Installing GDB, Index, Using History Interactively, Top
+@node Installing GDB
@appendix Installing @value{GDBN}
@cindex configuring @value{GDBN}
@cindex installation
-@ifset HPPA
-If you obtain @value{GDBN} (HP WDB 0.75) as part of your HP ANSI C or
-HP ANSI C++ Developer's Kit at HP-UX Release 11.0, you do not have to
-take any special action to build or install @value{GDBN}.
-
-If you obtain @value{GDBN} (HP WDB 0.75) from an HP web site, you may
-download either a @code{swinstall}-able package or a source tree, or
-both.
-
-Most customers will want to install the @value{GDBN} binary that is part
-of the @code{swinstall}-able package. To do so, use a command of the
-form
-
-@smallexample
-/usr/sbin/swinstall -s @var{package-name} WDB
-@end smallexample
-
-Alternatively, it is possible to build @value{GDBN} from the source
-distribution. Sophisticated customers who want to modify the debugger
-sources to tailor @value{GDBN} to their their needs may wish to do this.
-The source distribution consists of a @code{tar}'ed source tree rooted
-at @file{gdb-4.16/...}. The instructions that follow describe how to
-build a @file{gdb} executable from this source tree. HP believes that
-these instructions apply to the WDB source tree that it distributes.
-However, HP does not explicitly support building a @file{gdb} for any
-non-HP platform from the WDB source tree. It may work, but HP has not
-tested it for any platforms other than those described in the WDB 0.75
-Release Notes.
-@end ifset
-
@value{GDBN} comes with a @code{configure} script that automates the process
of preparing @value{GDBN} for installation; you can then use @code{make} to
build the @code{gdb} program.
@@ -10114,10 +9075,10 @@ let @value{GDBN} debug child processes whose programs are not readable.
@menu
* Separate Objdir:: Compiling @value{GDBN} in another directory
* Config Names:: Specifying names for hosts and targets
-* Configure Options:: Summary of options for configure
+* configure Options:: Summary of options for configure
@end menu
-@node Separate Objdir, Config Names, Installing GDB, Installing GDB
+@node Separate Objdir
@section Compiling @value{GDBN} in another directory
If you want to run @value{GDBN} versions for several host or target machines,
@@ -10178,7 +9139,7 @@ directories, 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.
-@node Config Names, Configure Options, Separate Objdir, Installing GDB
+@node Config Names
@section Specifying names for hosts and targets
The specifications used for hosts and targets in the @code{configure}
@@ -10202,25 +9163,25 @@ script, if you wish, or you can use it to test your guesses on
abbreviations---for example:
@smallexample
-% sh config.sub i386-linux
-i386-pc-linux-gnu
-% sh config.sub alpha-linux
-alpha-unknown-linux-gnu
-% sh config.sub hp9k700
-hppa1.1-hp-hpux
% sh config.sub sun4
sparc-sun-sunos4.1.1
% sh config.sub sun3
m68k-sun-sunos4.1.1
-% sh config.sub i986v
-Invalid configuration `i986v': machine `i986v' not recognized
+% sh config.sub decstation
+mips-dec-ultrix4.2
+% sh config.sub hp300bsd
+m68k-hp-bsd
+% sh config.sub i386v
+i386-unknown-sysv
+% sh config.sub i786v
+Invalid configuration `i786v': machine `i786v' not recognized
@end smallexample
@noindent
@code{config.sub} is also distributed in the @value{GDBN} source
directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}).
-@node Configure Options, , Config Names, Installing GDB
+@node configure Options
@section @code{configure} options
Here is a summary of the @code{configure} options and arguments that
@@ -10231,11 +9192,9 @@ Does,,configure.info}, for a full explanation of @code{configure}.
@example
configure @r{[}--help@r{]}
@r{[}--prefix=@var{dir}@r{]}
- @r{[}--exec-prefix=@var{dir}@r{]}
@r{[}--srcdir=@var{dirname}@r{]}
@r{[}--norecursion@r{]} @r{[}--rm@r{]}
- @r{[}--target=@var{target}@r{]}
- @var{host}
+ @r{[}--target=@var{target}@r{]} @var{host}
@end example
@noindent
@@ -10247,14 +9206,10 @@ You may introduce options with a single @samp{-} rather than
@item --help
Display a quick summary of how to invoke @code{configure}.
-@item --prefix=@var{dir}
+@item -prefix=@var{dir}
Configure the source to install programs and files under directory
@file{@var{dir}}.
-@item --exec-prefix=@var{dir}
-Configure the source to install programs under directory
-@file{@var{dir}}.
-
@c avoid splitting the warning from the explanation:
@need 2000
@item --srcdir=@var{dirname}
@@ -10273,6 +9228,16 @@ the working directory in parallel to the source directories below
Configure only the directory level where @code{configure} is executed; do not
propagate configuration to subdirectories.
+@item --rm
+@emph{Remove} files otherwise built during configuration.
+
+@c This does not work (yet if ever). FIXME.
+@c @item --parse=@var{lang} @dots{}
+@c Configure the @value{GDBN} expression parser to parse the listed languages.
+@c @samp{all} configures @value{GDBN} for all supported languages. To get a
+@c list of all supported languages, omit the argument. Without this
+@c option, @value{GDBN} is configured to parse all supported languages.
+
@item --target=@var{target}
Configure @value{GDBN} for cross-debugging programs running on the specified
@var{target}. Without this option, @value{GDBN} is configured to debug
@@ -10286,12 +9251,13 @@ Configure @value{GDBN} to run on the specified @var{host}.
There is no convenient way to generate a list of all available hosts.
@end table
-There are many other options available as well, but they are generally
-needed for special purposes only.
+@noindent
+@code{configure} accepts other options, for compatibility with
+configuring other @sc{gnu} tools recursively; but these are the only
+options that affect @value{GDBN} or its supporting libraries.
@end ifclear
-
-@node Index, , Installing GDB, Top
+@node Index
@unnumbered Index
@printindex cp
diff --git a/contrib/gdb/gdb/doc/refcard.dvi b/contrib/gdb/gdb/doc/refcard.dvi
deleted file mode 100644
index e152395..0000000
--- a/contrib/gdb/gdb/doc/refcard.dvi
+++ /dev/null
Binary files differ
diff --git a/contrib/gdb/gdb/doc/stabs.texinfo b/contrib/gdb/gdb/doc/stabs.texinfo
index 1eb9d15..b51d611 100644
--- a/contrib/gdb/gdb/doc/stabs.texinfo
+++ b/contrib/gdb/gdb/doc/stabs.texinfo
@@ -6,7 +6,7 @@
@ifinfo
@format
START-INFO-DIR-ENTRY
-* Stabs: (stabs). The "stabs" debugging information format.
+* Stabs: (stabs). The "stabs" debugging information format.
END-INFO-DIR-ENTRY
@end format
@end ifinfo
@@ -14,7 +14,7 @@ END-INFO-DIR-ENTRY
@ifinfo
This document describes the stabs debugging symbol tables.
-Copyright 1992, 93, 94, 95, 97, 1998 Free Software Foundation, Inc.
+Copyright 1992, 1993 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
and David MacKenzie.
@@ -43,7 +43,7 @@ regarded as a program in the language TeX).
@page
@tex
\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
-\xdef\manvers{\$Revision: 2.128 $} % For use in headers, footers too
+\xdef\manvers{\$Revision: 2.125 $} % For use in headers, footers too
{\parskip=0pt
\hfill Cygnus Support\par
\hfill \manvers\par
@@ -52,7 +52,7 @@ regarded as a program in the language TeX).
@end tex
@vskip 0pt plus 1filll
-Copyright @copyright{} 1992, 93, 94, 95, 97, 1998 Free Software Foundation, Inc.
+Copyright @copyright{} 1992, 1993 Free Software Foundation, Inc.
Contributed by Cygnus Support.
Permission is granted to make and distribute verbatim copies of
@@ -80,6 +80,8 @@ This document describes the stabs debugging format.
* Type Descriptors:: Table of type descriptors
* Expanded Reference:: Reference information by stab type
* Questions:: Questions and anomolies
+* Sun Differences:: Differences between GNU stabs and Sun
+ native stabs
* Stab Sections:: In some object file formats, stabs are
in sections.
* Symbol Types Index:: Index of symbolic stab symbol type names.
@@ -238,18 +240,6 @@ type is about to be defined. Any other values following the
a number follows the @samp{=} then the number is a @var{type-reference}.
For a full description of types, @ref{Types}.
-A @var{type-number} is often a single number. The GNU and Sun tools
-additionally permit a @var{type-number} to be a pair
-(@var{file-number},@var{filetype-number}) (the parentheses appear in the
-string, and serve to distinguish the two cases). The @var{file-number}
-is a number starting with 1 which is incremented for each seperate
-source file in the compilation (e.g., in C, each header file gets a
-different number). The @var{filetype-number} is a number starting with
-1 which is incremented for each new type defined in the file.
-(Separating the file number and the type number permits the
-@code{N_BINCL} optimization to succeed more often; see @ref{Include
-Files}).
-
There is an AIX extension for type attributes. Following the @samp{=}
are any number of type attributes. Each one starts with @samp{@@} and
ends with @samp{;}. Debuggers, including AIX's dbx and GDB 4.10, skip
@@ -473,7 +463,7 @@ the start of this one. To specify the main source file again, use an
@findex N_EXCL
The @code{N_BINCL} approach works as follows. An @code{N_BINCL} symbol
specifies the start of an include file. In an object file, only the
-string is significant; the linker puts data into some of the other
+string is significant; the Sun linker puts data into some of the other
fields. The end of the include file is marked by an @code{N_EINCL}
symbol (which has no string field). In an object file, there is no
significant data in the @code{N_EINCL} symbol. @code{N_BINCL} and
@@ -483,17 +473,16 @@ If the linker detects that two source files have identical stabs between
an @code{N_BINCL} and @code{N_EINCL} pair (as will generally be the case
for a header file), then it only puts out the stabs once. Each
additional occurance is replaced by an @code{N_EXCL} symbol. I believe
-the GNU linker and the Sun (both SunOS4 and Solaris) linker are the only
-ones which supports this feature.
-
-A linker which supports this feature will set the value of a
-@code{N_BINCL} symbol to the total of all the characters in the stabs
-strings included in the header file, omitting any file numbers. The
-value of an @code{N_EXCL} symbol is the same as the value of the
-@code{N_BINCL} symbol it replaces. This information can be used to
-match up @code{N_EXCL} and @code{N_BINCL} symbols which have the same
-filename. The @code{N_EINCL} value, and the values of the other and
-description fields for all three, appear to always be zero.
+the Sun (SunOS4, not sure about Solaris) linker is the only one which
+supports this feature.
+
+The SunOS4 linker sets the value of a @code{N_BINCL} symbol to the total
+of all the characters in the stabs strings included in the header file,
+omitting the file number. The value of an @code{N_EXCL} symbol is the
+same as the value of the @code{N_BINCL} symbol it replaces. I do not
+know if this information is used by anything. The @code{N_EINCL} value,
+and the values of the other and description fields for all three, appear
+to always be zero.
@findex C_BINCL
@findex C_EINCL
@@ -643,15 +632,6 @@ group of other stabs describing elements of the procedure. These other
stabs describe the procedure's parameters, its block local variables, and
its block structure.
-If functions can appear in different sections, then the debugger may not
-be able to find the end of a function. Recent versions of GCC will mark
-the end of a function with an @code{N_FUN} symbol with an empty string
-for the name. The value is the address of the end of the current
-function. Without such a symbol, there is no indication of the address
-of the end of a function, and you must assume that it ended at the
-starting address of the next function or at the end of the text section
-for the program.
-
@node Nested Procedures
@section Nested Procedures
@@ -2080,8 +2060,7 @@ For example,
@end example
specifies that @code{s_typedef} refers to type number 16. Such stabs
-have symbol type @code{N_LSYM} (or @code{C_DECL} for XCOFF). (The Sun
-documentation mentions using @code{N_GSYM} in some cases).
+have symbol type @code{N_LSYM} (or @code{C_DECL} for XCOFF).
If you are specifying the tag name for a structure, union, or
enumeration, use the @samp{T} symbol descriptor instead. I believe C is
@@ -2690,21 +2669,16 @@ pointer.
@node Method Type Descriptor
@section The @samp{#} Type Descriptor
-This is used to describe a class method. This is a function which takes
-an extra argument as its first argument, for the @code{this} pointer.
-
-If the @samp{#} is immediately followed by another @samp{#}, the second
-one will be followed by the return type and a semicolon. The class and
-argument types are not specified, and must be determined by demangling
-the name of the method if it is available.
-
-Otherwise, the single @samp{#} is followed by the class type, a comma,
-the return type, a comma, and zero or more parameter types separated by
-commas. The list of arguments is terminated by a semicolon. In the
-debugging output generated by gcc, a final argument type of @code{void}
-indicates a method which does not take a variable number of arguments.
-If the final argument type of @code{void} does not appear, the method
-was declared with an ellipsis.
+This is like the @samp{f} type descriptor for functions (@pxref{Function
+Types}), except that a function which uses the @samp{#} type descriptor
+takes an extra argument as its first argument, for the @code{this}
+pointer. The @samp{#} type descriptor is optionally followed by the
+types of the arguments, then another @samp{#}. If the types of the
+arguments are omitted, so that the second @samp{#} immediately follows
+the @samp{#} which is the type descriptor, the arguments are being
+omitted (to save space) and can be deduced from the mangled name of the
+method. After the second @samp{#} there is type information for the
+return type of the method and a semicolon.
Note that although such a type will normally be used to describe fields
in structures, unions, or classes, for at least some versions of the
@@ -3867,6 +3841,25 @@ What ends the procedure scope? Is it the proc block's @code{N_RBRAC} or the
next @code{N_FUN}? (I believe its the first.)
@end itemize
+@node Sun Differences
+@appendix Differences Between GNU Stabs and Sun Native Stabs
+
+@c FIXME: Merge all this stuff into the main body of the document.
+
+@itemize @bullet
+@item
+GNU C stabs define @emph{all} types, file or procedure scope, as
+@code{N_LSYM}. Sun doc talks about using @code{N_GSYM} too.
+
+@item
+Sun C stabs use type number pairs in the format
+(@var{file-number},@var{type-number}) where @var{file-number} is a
+number starting with 1 and incremented for each sub-source file in the
+compilation. @var{type-number} is a number starting with 1 and
+incremented for each new type defined in the compilation. GNU C stabs
+use the type number alone, with no source file number.
+@end itemize
+
@node Stab Sections
@appendix Using Stabs in Their Own Sections
@@ -3935,25 +3928,17 @@ header @code{sh_type} member set to @code{SHT_STRTAB} to mark it as a
string table. SOM and COFF have no way of linking the sections together
or marking them as string tables.
-For COFF, the @code{.stab} and @code{.stabstr} sections may be simply
+For COFF, the @code{.stab} and @code{.stabstr} sections are simply
concatenated by the linker. GDB then uses the @code{n_desc} fields to
figure out the extent of the original sections. Similarly, the
@code{n_value} fields of the header symbols are added together in order
to get the actual position of the strings in a desired @code{.stabstr}
-section. Although this design obviates any need for the linker to
-relocate or otherwise manipulate @code{.stab} and @code{.stabstr}
-sections, it also requires some care to ensure that the offsets are
-calculated correctly. For instance, if the linker were to pad in
-between the @code{.stabstr} sections before concatenating, then the
-offsets to strings in the middle of the executable's @code{.stabstr}
-section would be wrong.
-
-The GNU linker is able to optimize stabs information by merging
-duplicate strings and removing duplicate header file information
-(@pxref{Include Files}). When some versions of the GNU linker optimize
-stabs in sections, they remove the leading @code{N_UNDF} symbol and
-arranges for all the @code{n_strx} fields to be relative to the start of
-the @code{.stabstr} section.
+section. Although this design obviates any need for the linker to relocate
+or otherwise manipulate @code{.stab} and @code{.stabstr} sections, it also
+requires some care to ensure that the offsets are calculated correctly.
+For instance, if the linker were to pad in between the @code{.stabstr}
+sections before concatenating, then the offsets to strings in the middle
+of the executable's @code{.stabstr} section would be wrong.
@node ELF Linker Relocation
@appendixsec Having the Linker Relocate Stabs in ELF
diff --git a/contrib/gdb/gdb/exec.c b/contrib/gdb/gdb/exec.c
index 87aed01..4d3a307 100644
--- a/contrib/gdb/gdb/exec.c
+++ b/contrib/gdb/gdb/exec.c
@@ -1,6 +1,5 @@
/* Work with executable files, for GDB.
- Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1997, 1998
- Free Software Foundation, Inc.
+ Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of GDB.
@@ -31,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <sys/types.h>
#endif
+#include <sys/param.h>
#include <fcntl.h>
#include "gdb_string.h"
@@ -46,8 +46,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
struct vmap *map_vmap PARAMS ((bfd *, bfd *));
-void (*file_changed_hook) PARAMS ((char *));
-
/* Prototypes for local functions */
static void add_to_section_table PARAMS ((bfd *, sec_ptr, PTR));
@@ -60,20 +58,8 @@ static void set_section_command PARAMS ((char *, int));
static void exec_files_info PARAMS ((struct target_ops *));
-static void bfdsec_to_vmap PARAMS ((bfd *, sec_ptr, PTR));
-
-static int ignore PARAMS ((CORE_ADDR, char *));
-
-static void init_exec_ops PARAMS ((void));
-
-void _initialize_exec PARAMS ((void));
-
extern int info_verbose;
-/* The target vector for executable files. */
-
-struct target_ops exec_ops;
-
/* The Binary File Descriptor handle for the executable file. */
bfd *exec_bfd = NULL;
@@ -84,14 +70,17 @@ int write_files = 0;
/* Text start and end addresses (KLUDGE) if needed */
-#ifndef NEED_TEXT_START_END
-#define NEED_TEXT_START_END (0)
-#endif
+#ifdef NEED_TEXT_START_END
CORE_ADDR text_start = 0;
CORE_ADDR text_end = 0;
+#endif
struct vmap *vmap;
+/* Forward decl */
+
+extern struct target_ops exec_ops;
+
/* ARGSUSED */
static void
exec_close (quitting)
@@ -151,29 +140,20 @@ exec_close (quitting)
/* Process the first arg in ARGS as the new exec file.
- This function is intended to be behave essentially the same
- as exec_file_command, except that the latter will detect when
- a target is being debugged, and will ask the user whether it
- should be shut down first. (If the answer is "no", then the
- new file is ignored.)
-
- This file is used by exec_file_command, to do the work of opening
- and processing the exec file after any prompting has happened.
-
- And, it is used by child_attach, when the attach command was
- given a pid but not a exec pathname, and the attach command could
- figure out the pathname from the pid. (In this case, we shouldn't
- ask the user whether the current target should be shut down --
- we're supplying the exec pathname late for good reason.) */
+ Note that we have to explicitly ignore additional args, since we can
+ be called from file_command(), which also calls symbol_file_command()
+ which can take multiple args. */
void
-exec_file_attach (args, from_tty)
+exec_file_command (args, from_tty)
char *args;
int from_tty;
{
char **argv;
char *filename;
+ target_preopen (from_tty);
+
/* Remove any previous exec file. */
unpush_target (&exec_ops);
@@ -191,7 +171,7 @@ exec_file_attach (args, from_tty)
if (argv == NULL)
nomem (0);
- make_cleanup ((make_cleanup_func) freeargv, (char *) argv);
+ make_cleanup (freeargv, (char *) argv);
for (; (*argv != NULL) && (**argv == '-'); argv++) {;}
if (*argv == NULL)
@@ -203,17 +183,9 @@ exec_file_attach (args, from_tty)
scratch_chan = openp (getenv ("PATH"), 1, filename,
write_files? O_RDWR|O_BINARY: O_RDONLY|O_BINARY, 0,
&scratch_pathname);
-#if defined(__GO32__) || defined(_WIN32)
- if (scratch_chan < 0)
- {
- char *exename = alloca (strlen (filename) + 5);
- strcat (strcpy (exename, filename), ".exe");
- scratch_chan = openp (getenv ("PATH"), 1, exename, write_files ?
- O_RDWR|O_BINARY : O_RDONLY|O_BINARY, 0, &scratch_pathname);
- }
-#endif
if (scratch_chan < 0)
perror_with_name (filename);
+ fcntl (scratch_chan, F_SETFD, 1);
exec_bfd = bfd_fdopenr (scratch_pathname, gnutarget, scratch_chan);
if (!exec_bfd)
@@ -262,34 +234,37 @@ exec_file_attach (args, from_tty)
scratch_pathname, bfd_errmsg (bfd_get_error ()));
}
+#ifdef NEED_TEXT_START_END
+
/* text_end is sometimes used for where to put call dummies. A
few ports use these for other purposes too. */
- if (NEED_TEXT_START_END)
- {
- struct section_table *p;
-
- /* Set text_start to the lowest address of the start of any
- readonly code section and set text_end to the highest
- address of the end of any readonly code section. */
- /* FIXME: The comment above does not match the code. The
- code checks for sections with are either code *or*
- readonly. */
- text_start = ~(CORE_ADDR)0;
- text_end = (CORE_ADDR)0;
- for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++)
- if (bfd_get_section_flags (p->bfd, p->the_bfd_section)
- & (SEC_CODE | SEC_READONLY))
- {
- if (text_start > p->addr)
- text_start = p->addr;
- if (text_end < p->endaddr)
- text_end = p->endaddr;
- }
- }
+
+ {
+ struct section_table *p;
+
+ /* Set text_start to the lowest address of the start of any
+ readonly code section and set text_end to the highest
+ address of the end of any readonly code section. */
+ /* FIXME: The comment above does not match the code. The code
+ checks for sections with are either code *or* readonly. */
+
+ text_start = ~(CORE_ADDR)0;
+ text_end = (CORE_ADDR)0;
+ for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++)
+ if (bfd_get_section_flags (p->bfd, p->the_bfd_section)
+ & (SEC_CODE | SEC_READONLY))
+ {
+ if (text_start > p->addr)
+ text_start = p->addr;
+ if (text_end < p->endaddr)
+ text_end = p->endaddr;
+ }
+ }
+#endif
validate_files ();
- set_gdbarch_from_file (exec_bfd);
+ set_endian_from_file (exec_bfd);
push_target (&exec_ops);
@@ -298,26 +273,7 @@ exec_file_attach (args, from_tty)
(*exec_file_display_hook) (filename);
}
else if (from_tty)
- printf_unfiltered ("No executable file now.\n");
-}
-
-/* Process the first arg in ARGS as the new exec file.
-
- Note that we have to explicitly ignore additional args, since we can
- be called from file_command(), which also calls symbol_file_command()
- which can take multiple args. */
-
-void
-exec_file_command (args, from_tty)
- char *args;
- int from_tty;
-{
- char **argv;
- char *filename;
-
- target_preopen (from_tty);
-
- exec_file_attach (args, from_tty);
+ printf_unfiltered ("No exec file now.\n");
}
/* Set both the exec file and the symbol file, in one command.
@@ -333,8 +289,6 @@ file_command (arg, from_tty)
the exec file, but that's rough. */
exec_file_command (arg, from_tty);
symbol_file_command (arg, from_tty);
- if (file_changed_hook)
- file_changed_hook (arg);
}
@@ -401,16 +355,20 @@ bfdsec_to_vmap(abfd, sect, arg3)
if (STREQ (bfd_section_name (abfd, sect), ".text"))
{
- vp->tstart = bfd_section_vma (abfd, sect);
+ vp->tstart = 0;
vp->tend = vp->tstart + bfd_section_size (abfd, sect);
- vp->tvma = bfd_section_vma (abfd, sect);
- vp->toffs = sect->filepos;
+
+ /* When it comes to this adjustment value, in contrast to our previous
+ belief shared objects should behave the same as the main load segment.
+ This is the offset from the beginning of text section to the first
+ real instruction. */
+
+ vp->tadj = sect->filepos - bfd_section_vma (abfd, sect);
}
else if (STREQ (bfd_section_name (abfd, sect), ".data"))
{
- vp->dstart = bfd_section_vma (abfd, sect);
+ vp->dstart = 0;
vp->dend = vp->dstart + bfd_section_size (abfd, sect);
- vp->dvma = bfd_section_vma (abfd, sect);
}
/* Silently ignore other types of sections. (FIXME?) */
}
@@ -475,79 +433,25 @@ xfer_memory (memaddr, myaddr, len, write, target)
struct section_table *p;
CORE_ADDR nextsectaddr, memend;
boolean (*xfer_fn) PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
- asection *section;
if (len <= 0)
abort();
- if (overlay_debugging)
- {
- section = find_pc_overlay (memaddr);
- if (pc_in_unmapped_range (memaddr, section))
- memaddr = overlay_mapped_address (memaddr, section);
- }
-
memend = memaddr + len;
xfer_fn = write ? bfd_set_section_contents : bfd_get_section_contents;
nextsectaddr = memend;
-#if 0 /* Stu's implementation */
-/* If a section has been specified, try to use it. Note that we cannot use the
- specified section directly. This is because it usually comes from the
- symbol file, which may be different from the exec or core file. Instead, we
- have to lookup the specified section by name in the bfd associated with
- to_sections. */
-
- if (target_memory_bfd_section)
- {
- asection *s;
- bfd *abfd;
- asection *target_section;
- bfd *target_bfd;
-
- s = target_memory_bfd_section;
- abfd = s->owner;
-
- target_bfd = target->to_sections->bfd;
- target_section = bfd_get_section_by_name (target_bfd, bfd_section_name (abfd, s));
-
- if (target_section)
- {
- bfd_vma sec_addr;
- bfd_size_type sec_size;
-
- sec_addr = bfd_section_vma (target_bfd, target_section);
- sec_size = target_section->_raw_size;
-
- /* Make sure the requested memory starts inside the section. */
-
- if (memaddr >= sec_addr
- && memaddr < sec_addr + sec_size)
- {
- /* Cut back length in case request overflows the end of the section. */
- len = min (len, sec_addr + sec_size - memaddr);
-
- res = xfer_fn (target_bfd, target_section, myaddr, memaddr - sec_addr, len);
-
- return res ? len : 0;
- }
- }
- }
-#endif /* 0, Stu's implementation */
for (p = target->to_sections; p < target->to_sections_end; p++)
{
- if (overlay_debugging && section && p->the_bfd_section &&
- strcmp (section->name, p->the_bfd_section->name) != 0)
- continue; /* not the section we need */
- if (memaddr >= p->addr)
- if (memend <= p->endaddr)
+ if (p->addr <= memaddr)
+ if (p->endaddr >= memend)
{
/* Entire transfer is within this section. */
res = xfer_fn (p->bfd, p->the_bfd_section, myaddr,
memaddr - p->addr, len);
return (res != 0) ? len : 0;
}
- else if (memaddr >= p->endaddr)
+ else if (p->endaddr <= memaddr)
{
/* This section ends before the transfer starts. */
continue;
@@ -560,8 +464,8 @@ xfer_memory (memaddr, myaddr, len, write, target)
memaddr - p->addr, len);
return (res != 0) ? len : 0;
}
- else
- nextsectaddr = min (nextsectaddr, p->addr);
+ else if (p->addr < nextsectaddr)
+ nextsectaddr = p->addr;
}
if (nextsectaddr >= memend)
@@ -682,8 +586,7 @@ set_section_command (args, from_tty)
}
/* If mourn is being called in all the right places, this could be say
- `gdb internal error' (since generic_mourn calls
- breakpoint_init_inferior). */
+ `gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
static int
ignore (addr, contents)
@@ -693,50 +596,63 @@ ignore (addr, contents)
return 0;
}
-/* Fill in the exec file target vector. Very few entries need to be
- defined. */
-
-void
-init_exec_ops ()
-{
- exec_ops.to_shortname = "exec";
- exec_ops.to_longname = "Local exec file";
- exec_ops.to_doc = "Use an executable file as a target.\n\
-Specify the filename of the executable file.";
- exec_ops.to_open = exec_file_command;
- exec_ops.to_close = exec_close;
- exec_ops.to_attach = find_default_attach;
- exec_ops.to_require_attach = find_default_require_attach;
- exec_ops.to_require_detach = find_default_require_detach;
- exec_ops.to_xfer_memory = xfer_memory;
- exec_ops.to_files_info = exec_files_info;
- exec_ops.to_insert_breakpoint = ignore;
- exec_ops.to_remove_breakpoint = ignore;
- exec_ops.to_create_inferior = find_default_create_inferior;
- exec_ops.to_clone_and_follow_inferior = find_default_clone_and_follow_inferior;
- exec_ops.to_stratum = file_stratum;
- exec_ops.to_has_memory = 1;
- exec_ops.to_magic = OPS_MAGIC;
-}
+struct target_ops exec_ops = {
+ "exec", /* to_shortname */
+ "Local exec file", /* to_longname */
+ "Use an executable file as a target.\n\
+Specify the filename of the executable file.", /* to_doc */
+ exec_file_command, /* to_open */
+ exec_close, /* to_close */
+ find_default_attach, /* to_attach */
+ 0, /* to_detach */
+ 0, /* to_resume */
+ 0, /* to_wait */
+ 0, /* to_fetch_registers */
+ 0, /* to_store_registers */
+ 0, /* to_prepare_to_store */
+ xfer_memory, /* to_xfer_memory */
+ exec_files_info, /* to_files_info */
+ ignore, /* to_insert_breakpoint */
+ ignore, /* to_remove_breakpoint */
+ 0, /* to_terminal_init */
+ 0, /* to_terminal_inferior */
+ 0, /* to_terminal_ours_for_output */
+ 0, /* to_terminal_ours */
+ 0, /* to_terminal_info */
+ 0, /* to_kill */
+ 0, /* to_load */
+ 0, /* to_lookup_symbol */
+ find_default_create_inferior, /* to_create_inferior */
+ 0, /* to_mourn_inferior */
+ 0, /* to_can_run */
+ 0, /* to_notice_signals */
+ 0, /* to_thread_alive */
+ 0, /* to_stop */
+ file_stratum, /* to_stratum */
+ 0, /* to_next */
+ 0, /* to_has_all_memory */
+ 1, /* to_has_memory */
+ 0, /* to_has_stack */
+ 0, /* to_has_registers */
+ 0, /* to_has_execution */
+ 0, /* to_sections */
+ 0, /* to_sections_end */
+ OPS_MAGIC, /* to_magic */
+};
void
-_initialize_exec ()
+_initialize_exec()
{
struct cmd_list_element *c;
- init_exec_ops ();
-
- if (!dbx_commands)
- {
- c = add_cmd ("file", class_files, file_command,
- "Use FILE as program to be debugged.\n\
+ c = add_cmd ("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.", &cmdlist);
- c->completer = filename_completer;
- }
+ c->completer = filename_completer;
c = add_cmd ("exec-file", class_files, exec_file_command,
"Use FILE as program for getting contents of pure memory.\n\
diff --git a/contrib/gdb/gdb/f-exp.tab.c b/contrib/gdb/gdb/f-exp.tab.c
deleted file mode 100644
index ef7d25e..0000000
--- a/contrib/gdb/gdb/f-exp.tab.c
+++ /dev/null
@@ -1,2086 +0,0 @@
-
-/* A Bison parser, made from f-exp.y
- by GNU Bison version 1.25
- */
-
-#define YYBISON 1 /* Identify Bison output. */
-
-#define INT 258
-#define FLOAT 259
-#define STRING_LITERAL 260
-#define BOOLEAN_LITERAL 261
-#define NAME 262
-#define TYPENAME 263
-#define NAME_OR_INT 264
-#define SIZEOF 265
-#define ERROR 266
-#define INT_KEYWORD 267
-#define INT_S2_KEYWORD 268
-#define LOGICAL_S1_KEYWORD 269
-#define LOGICAL_S2_KEYWORD 270
-#define LOGICAL_KEYWORD 271
-#define REAL_KEYWORD 272
-#define REAL_S8_KEYWORD 273
-#define REAL_S16_KEYWORD 274
-#define COMPLEX_S8_KEYWORD 275
-#define COMPLEX_S16_KEYWORD 276
-#define COMPLEX_S32_KEYWORD 277
-#define BOOL_AND 278
-#define BOOL_OR 279
-#define BOOL_NOT 280
-#define CHARACTER 281
-#define VARIABLE 282
-#define ASSIGN_MODIFY 283
-#define ABOVE_COMMA 284
-#define EQUAL 285
-#define NOTEQUAL 286
-#define LESSTHAN 287
-#define GREATERTHAN 288
-#define LEQ 289
-#define GEQ 290
-#define LSH 291
-#define RSH 292
-#define UNARY 293
-
-#line 43 "f-exp.y"
-
-
-#include "defs.h"
-#include "gdb_string.h"
-#include "expression.h"
-#include "value.h"
-#include "parser-defs.h"
-#include "language.h"
-#include "f-lang.h"
-#include "bfd.h" /* Required by objfiles.h. */
-#include "symfile.h" /* Required by objfiles.h. */
-#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
-
-/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
- as well as gratuitiously global symbol names, so we can have multiple
- yacc generated parsers in gdb. Note that these are only the variables
- produced by yacc. If other parser generators (bison, byacc, etc) produce
- additional global names that conflict at link time, then those parser
- generators need to be fixed instead of adding those names to this list. */
-
-#define yymaxdepth f_maxdepth
-#define yyparse f_parse
-#define yylex f_lex
-#define yyerror f_error
-#define yylval f_lval
-#define yychar f_char
-#define yydebug f_debug
-#define yypact f_pact
-#define yyr1 f_r1
-#define yyr2 f_r2
-#define yydef f_def
-#define yychk f_chk
-#define yypgo f_pgo
-#define yyact f_act
-#define yyexca f_exca
-#define yyerrflag f_errflag
-#define yynerrs f_nerrs
-#define yyps f_ps
-#define yypv f_pv
-#define yys f_s
-#define yy_yys f_yys
-#define yystate f_state
-#define yytmp f_tmp
-#define yyv f_v
-#define yy_yyv f_yyv
-#define yyval f_val
-#define yylloc f_lloc
-#define yyreds f_reds /* With YYDEBUG defined */
-#define yytoks f_toks /* With YYDEBUG defined */
-#define yylhs f_yylhs
-#define yylen f_yylen
-#define yydefred f_yydefred
-#define yydgoto f_yydgoto
-#define yysindex f_yysindex
-#define yyrindex f_yyrindex
-#define yygindex f_yygindex
-#define yytable f_yytable
-#define yycheck f_yycheck
-
-#ifndef YYDEBUG
-#define YYDEBUG 1 /* Default to no yydebug support */
-#endif
-
-int yyparse PARAMS ((void));
-
-static int yylex PARAMS ((void));
-
-void yyerror PARAMS ((char *));
-
-static void growbuf_by_size PARAMS ((int));
-
-static int match_string_literal PARAMS ((void));
-
-
-#line 122 "f-exp.y"
-typedef union
- {
- LONGEST lval;
- struct {
- LONGEST val;
- struct type *type;
- } typed_val;
- DOUBLEST 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;
-#line 144 "f-exp.y"
-
-/* YYSTYPE gets defined by %union */
-static int parse_number PARAMS ((char *, int, int, YYSTYPE *));
-#include <stdio.h>
-
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
-#endif
-#endif
-
-
-
-#define YYFINAL 125
-#define YYFLAG -32768
-#define YYNTBASE 55
-
-#define YYTRANSLATE(x) ((unsigned)(x) <= 293 ? yytranslate[x] : 71)
-
-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, 2, 2, 2, 2, 49, 35, 2, 51,
- 52, 47, 45, 29, 46, 2, 48, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 54, 2, 2,
- 31, 2, 32, 44, 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, 34, 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, 33, 2, 53, 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, 36, 37, 38, 39, 40, 41,
- 42, 43, 50
-};
-
-#if YYDEBUG != 0
-static const short yyprhs[] = { 0,
- 0, 2, 4, 6, 10, 13, 16, 19, 22, 25,
- 28, 29, 35, 36, 38, 40, 44, 48, 52, 56,
- 61, 65, 69, 73, 77, 81, 85, 89, 93, 97,
- 101, 105, 109, 113, 117, 121, 125, 129, 133, 137,
- 141, 145, 147, 149, 151, 153, 155, 160, 162, 164,
- 166, 168, 170, 173, 175, 178, 180, 183, 185, 189,
- 192, 194, 197, 201, 203, 205, 207, 209, 211, 213,
- 215, 217, 219, 221, 223, 225, 227, 229, 231, 235,
- 237, 239, 241
-};
-
-static const short yyrhs[] = { 57,
- 0, 56, 0, 63, 0, 51, 57, 52, 0, 47,
- 57, 0, 35, 57, 0, 46, 57, 0, 25, 57,
- 0, 53, 57, 0, 10, 57, 0, 0, 57, 51,
- 58, 59, 52, 0, 0, 57, 0, 60, 0, 59,
- 29, 57, 0, 57, 54, 57, 0, 57, 29, 57,
- 0, 51, 61, 52, 0, 51, 63, 52, 57, 0,
- 57, 44, 57, 0, 57, 47, 57, 0, 57, 48,
- 57, 0, 57, 49, 57, 0, 57, 45, 57, 0,
- 57, 46, 57, 0, 57, 42, 57, 0, 57, 43,
- 57, 0, 57, 36, 57, 0, 57, 37, 57, 0,
- 57, 40, 57, 0, 57, 41, 57, 0, 57, 38,
- 57, 0, 57, 39, 57, 0, 57, 35, 57, 0,
- 57, 34, 57, 0, 57, 33, 57, 0, 57, 23,
- 57, 0, 57, 24, 57, 0, 57, 31, 57, 0,
- 57, 28, 57, 0, 3, 0, 9, 0, 4, 0,
- 62, 0, 27, 0, 10, 51, 63, 52, 0, 6,
- 0, 5, 0, 70, 0, 64, 0, 68, 0, 68,
- 65, 0, 47, 0, 47, 65, 0, 35, 0, 35,
- 65, 0, 66, 0, 51, 65, 52, 0, 66, 67,
- 0, 67, 0, 51, 52, 0, 51, 69, 52, 0,
- 8, 0, 12, 0, 13, 0, 26, 0, 16, 0,
- 15, 0, 14, 0, 17, 0, 18, 0, 19, 0,
- 20, 0, 21, 0, 22, 0, 8, 0, 63, 0,
- 69, 29, 63, 0, 7, 0, 8, 0, 9, 0,
- 7, 0
-};
-
-#endif
-
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
- 221, 222, 225, 231, 236, 239, 242, 246, 250, 254,
- 263, 265, 271, 274, 278, 281, 285, 290, 294, 298,
- 306, 310, 314, 318, 322, 326, 330, 334, 338, 342,
- 346, 350, 354, 358, 362, 366, 370, 374, 379, 383,
- 387, 393, 400, 409, 416, 419, 422, 430, 437, 445,
- 489, 492, 493, 536, 538, 540, 542, 544, 547, 549,
- 551, 555, 557, 562, 564, 566, 568, 570, 572, 574,
- 576, 578, 580, 582, 584, 586, 590, 594, 599, 606,
- 608, 610, 614
-};
-#endif
-
-
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
-
-static const char * const yytname[] = { "$","error","$undefined.","INT","FLOAT",
-"STRING_LITERAL","BOOLEAN_LITERAL","NAME","TYPENAME","NAME_OR_INT","SIZEOF",
-"ERROR","INT_KEYWORD","INT_S2_KEYWORD","LOGICAL_S1_KEYWORD","LOGICAL_S2_KEYWORD",
-"LOGICAL_KEYWORD","REAL_KEYWORD","REAL_S8_KEYWORD","REAL_S16_KEYWORD","COMPLEX_S8_KEYWORD",
-"COMPLEX_S16_KEYWORD","COMPLEX_S32_KEYWORD","BOOL_AND","BOOL_OR","BOOL_NOT",
-"CHARACTER","VARIABLE","ASSIGN_MODIFY","','","ABOVE_COMMA","'='","'?'","'|'",
-"'^'","'&'","EQUAL","NOTEQUAL","LESSTHAN","GREATERTHAN","LEQ","GEQ","LSH","RSH",
-"'@'","'+'","'-'","'*'","'/'","'%'","UNARY","'('","')'","'~'","':'","start",
-"type_exp","exp","@1","arglist","substring","complexnum","variable","type","ptype",
-"abs_decl","direct_abs_decl","func_mod","typebase","nonempty_typelist","name_not_typename", NULL
-};
-#endif
-
-static const short yyr1[] = { 0,
- 55, 55, 56, 57, 57, 57, 57, 57, 57, 57,
- 58, 57, 59, 59, 59, 59, 60, 61, 57, 57,
- 57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
- 57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
- 57, 57, 57, 57, 57, 57, 57, 57, 57, 62,
- 63, 64, 64, 65, 65, 65, 65, 65, 66, 66,
- 66, 67, 67, 68, 68, 68, 68, 68, 68, 68,
- 68, 68, 68, 68, 68, 68, -1, 69, 69, -1,
- -1, -1, 70
-};
-
-static const short yyr2[] = { 0,
- 1, 1, 1, 3, 2, 2, 2, 2, 2, 2,
- 0, 5, 0, 1, 1, 3, 3, 3, 3, 4,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 1, 1, 1, 1, 1, 4, 1, 1, 1,
- 1, 1, 2, 1, 2, 1, 2, 1, 3, 2,
- 1, 2, 3, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
- 1, 1, 1
-};
-
-static const short yydefact[] = { 0,
- 42, 44, 49, 48, 83, 64, 43, 0, 65, 66,
- 70, 69, 68, 71, 72, 73, 74, 75, 76, 0,
- 67, 46, 0, 0, 0, 0, 0, 2, 1, 45,
- 3, 51, 52, 50, 0, 10, 8, 6, 7, 5,
- 0, 0, 0, 9, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 11, 56, 54, 0, 53,
- 58, 61, 0, 0, 4, 19, 0, 38, 39, 41,
- 40, 37, 36, 35, 29, 30, 33, 34, 31, 32,
- 27, 28, 21, 25, 26, 22, 23, 24, 13, 57,
- 55, 62, 78, 0, 0, 0, 60, 47, 18, 20,
- 14, 0, 15, 59, 0, 63, 0, 0, 12, 79,
- 17, 16, 0, 0, 0
-};
-
-static const short yydefgoto[] = { 123,
- 28, 41, 99, 112, 113, 42, 30, 103, 32, 70,
- 71, 72, 33, 105, 34
-};
-
-static const short yypact[] = { 75,
--32768,-32768,-32768,-32768,-32768,-32768,-32768, 126,-32768,-32768,
--32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 135,
--32768,-32768, 135, 135, 135, 75, 135,-32768, 309,-32768,
--32768,-32768, -34,-32768, 75, -49, -49, -49, -49, -49,
- 279, -46, -45, -49, 135, 135, 135, 135, 135, 135,
- 135, 135, 135, 135, 135, 135, 135, 135, 135, 135,
- 135, 135, 135, 135, 135,-32768, -34, -34, 206,-32768,
- -42,-32768, -36, 135,-32768,-32768, 135, 355, 336, 309,
- 309, 390, 407, 161, 221, 221, -11, -11, -11, -11,
- 22, 22, 58, -37, -37, -49, -49, -49, 135,-32768,
--32768,-32768,-32768, -33, -26, 230,-32768, 186, 309, -49,
- 250, -24,-32768,-32768, 397,-32768, 135, 135,-32768,-32768,
- 309, 309, 15, 18,-32768
-};
-
-static const short yypgoto[] = {-32768,
--32768, 0,-32768,-32768,-32768,-32768,-32768, 4,-32768, -25,
--32768, -50,-32768,-32768,-32768
-};
-
-
-#define YYLAST 458
-
-
-static const short yytable[] = { 29,
- 67, 66, 115, 31, 118, 76, 77, 36, 106, 63,
- 64, 65, 68, 66, 124, 108, 69, 125, 114, 37,
- 107, 0, 38, 39, 40, 116, 44, 119, 0, 43,
- 58, 59, 60, 61, 62, 63, 64, 65, 73, 66,
- 0, 100, 101, 104, 78, 79, 80, 81, 82, 83,
- 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
- 94, 95, 96, 97, 98, 60, 61, 62, 63, 64,
- 65, 0, 66, 109, 0, 0, 110, 1, 2, 3,
- 4, 5, 6, 7, 8, 0, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 0, 111, 20,
- 21, 22, 61, 62, 63, 64, 65, 110, 66, 23,
- 0, 0, 0, 0, 0, 0, 121, 122, 120, 0,
- 24, 25, 0, 0, 0, 26, 0, 27, 1, 2,
- 3, 4, 5, 0, 7, 8, 0, 1, 2, 3,
- 4, 5, 0, 7, 8, 0, 0, 0, 0, 0,
- 20, 0, 22, 0, 0, 0, 0, 0, 0, 20,
- 23, 22, 0, 0, 0, 0, 0, 0, 0, 23,
- 0, 24, 25, 0, 0, 0, 35, 0, 27, 0,
- 24, 25, 0, 0, 0, 26, 0, 27, 1, 2,
- 3, 4, 5, 0, 7, 8, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 20, 66, 22, 6, 0, 0, 0, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19, 0, 0,
- 0, 21, 0, 0, 0, 0, 26, 6, 27, 0,
- 67, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 68, 0, 0, 21, 69, 102, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 0, 66, 45, 46, 0, 0, 0, 47, 0, 0,
- 48, 102, 49, 50, 51, 52, 53, 54, 55, 56,
- 57, 58, 59, 60, 61, 62, 63, 64, 65, 0,
- 66, 45, 46, 117, 0, 0, 47, 74, 0, 48,
- 0, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 0, 66,
- 75, 45, 46, 0, 0, 0, 47, 0, 0, 48,
- 0, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 45, 66,
- 0, 0, 0, 0, 0, 0, 0, 0, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 0, 66, 49, 50, 51,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 6, 66, 0, 0, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 0,
- 0, 0, 21, 50, 51, 52, 53, 54, 55, 56,
- 57, 58, 59, 60, 61, 62, 63, 64, 65, 0,
- 66, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 0, 66
-};
-
-static const short yycheck[] = { 0,
- 35, 51, 29, 0, 29, 52, 52, 8, 51, 47,
- 48, 49, 47, 51, 0, 52, 51, 0, 52, 20,
- 71, -1, 23, 24, 25, 52, 27, 52, -1, 26,
- 42, 43, 44, 45, 46, 47, 48, 49, 35, 51,
- -1, 67, 68, 69, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
- 61, 62, 63, 64, 65, 44, 45, 46, 47, 48,
- 49, -1, 51, 74, -1, -1, 77, 3, 4, 5,
- 6, 7, 8, 9, 10, -1, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, -1, 99, 25,
- 26, 27, 45, 46, 47, 48, 49, 108, 51, 35,
- -1, -1, -1, -1, -1, -1, 117, 118, 115, -1,
- 46, 47, -1, -1, -1, 51, -1, 53, 3, 4,
- 5, 6, 7, -1, 9, 10, -1, 3, 4, 5,
- 6, 7, -1, 9, 10, -1, -1, -1, -1, -1,
- 25, -1, 27, -1, -1, -1, -1, -1, -1, 25,
- 35, 27, -1, -1, -1, -1, -1, -1, -1, 35,
- -1, 46, 47, -1, -1, -1, 51, -1, 53, -1,
- 46, 47, -1, -1, -1, 51, -1, 53, 3, 4,
- 5, 6, 7, -1, 9, 10, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 25, 51, 27, 8, -1, -1, -1, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, -1, -1,
- -1, 26, -1, -1, -1, -1, 51, 8, 53, -1,
- 35, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 47, -1, -1, 26, 51, 52, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- -1, 51, 23, 24, -1, -1, -1, 28, -1, -1,
- 31, 52, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, -1,
- 51, 23, 24, 54, -1, -1, 28, 29, -1, 31,
- -1, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, -1, 51,
- 52, 23, 24, -1, -1, -1, 28, -1, -1, 31,
- -1, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 23, 51,
- -1, -1, -1, -1, -1, -1, -1, -1, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, -1, 51, 33, 34, 35,
- 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
- 46, 47, 48, 49, 8, 51, -1, -1, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
- -1, -1, 26, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, -1,
- 51, 35, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 46, 47, 48, 49, -1, 51
-};
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/stone/jimb/main-98r2/share/bison.simple"
-
-/* Skeleton output parser for bison,
- Copyright (C) 1984, 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, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-#ifndef alloca
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
-#include <alloca.h>
-#else /* not sparc */
-#if defined (MSDOS) && !defined (__TURBOC__)
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
- #pragma alloca
-#else /* not MSDOS, __TURBOC__, or _AIX */
-#ifdef __hpux
-#ifdef __cplusplus
-extern "C" {
-void *alloca (unsigned int);
-};
-#else /* not __cplusplus */
-void *alloca ();
-#endif /* not __cplusplus */
-#endif /* __hpux */
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#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
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval, &yylloc)
-#endif
-#else /* not YYLSP_NEEDED */
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval)
-#endif
-#endif /* not YYLSP_NEEDED */
-#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
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-int yyparse (void);
-#endif
-
-#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
-#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
-#else /* not GNU C or C++ */
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (to, from, count)
- char *to;
- char *from;
- 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_memcpy (char *to, char *from, int count)
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#endif
-#endif
-
-#line 196 "/stone/jimb/main-98r2/share/bison.simple"
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
-
-#ifdef YYPARSE_PARAM
-#ifdef __cplusplus
-#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL
-#else /* not __cplusplus */
-#define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-#endif /* not __cplusplus */
-#else /* not YYPARSE_PARAM */
-#define YYPARSE_PARAM_ARG
-#define YYPARSE_PARAM_DECL
-#endif /* not YYPARSE_PARAM */
-
-int
-yyparse(YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
-{
- 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 = 0; /* 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 xreallocate them elsewhere */
-
-#ifdef YYLSP_NEEDED
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
-
-#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
-#else
-#define YYPOPSTACK (yyvsp--, yyssp--)
-#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.
- The wasted elements are never initialized. */
-
- 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 xreallocate 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. */
-#ifdef YYLSP_NEEDED
- /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro. */
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yyls1, size * sizeof (*yylsp),
- &yystacksize);
-#else
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yystacksize);
-#endif
-
- 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_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
- yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1, 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
-
- goto yybackup;
- 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", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
-#ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
-#endif
- fprintf (stderr, ")\n");
- }
-#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];
- if (yylen > 0)
- 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 symbols 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 226 "f-exp.y"
-{ write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type(yyvsp[0].tval);
- write_exp_elt_opcode(OP_TYPE); ;
- break;}
-case 4:
-#line 232 "f-exp.y"
-{ ;
- break;}
-case 5:
-#line 237 "f-exp.y"
-{ write_exp_elt_opcode (UNOP_IND); ;
- break;}
-case 6:
-#line 240 "f-exp.y"
-{ write_exp_elt_opcode (UNOP_ADDR); ;
- break;}
-case 7:
-#line 243 "f-exp.y"
-{ write_exp_elt_opcode (UNOP_NEG); ;
- break;}
-case 8:
-#line 247 "f-exp.y"
-{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); ;
- break;}
-case 9:
-#line 251 "f-exp.y"
-{ write_exp_elt_opcode (UNOP_COMPLEMENT); ;
- break;}
-case 10:
-#line 255 "f-exp.y"
-{ write_exp_elt_opcode (UNOP_SIZEOF); ;
- break;}
-case 11:
-#line 264 "f-exp.y"
-{ start_arglist (); ;
- break;}
-case 12:
-#line 266 "f-exp.y"
-{ write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST); ;
- break;}
-case 14:
-#line 275 "f-exp.y"
-{ arglist_len = 1; ;
- break;}
-case 15:
-#line 279 "f-exp.y"
-{ arglist_len = 2;;
- break;}
-case 16:
-#line 282 "f-exp.y"
-{ arglist_len++; ;
- break;}
-case 17:
-#line 286 "f-exp.y"
-{ ;
- break;}
-case 18:
-#line 291 "f-exp.y"
-{ ;
- break;}
-case 19:
-#line 295 "f-exp.y"
-{ write_exp_elt_opcode(OP_COMPLEX); ;
- break;}
-case 20:
-#line 299 "f-exp.y"
-{ write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (yyvsp[-2].tval);
- write_exp_elt_opcode (UNOP_CAST); ;
- break;}
-case 21:
-#line 307 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_REPEAT); ;
- break;}
-case 22:
-#line 311 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_MUL); ;
- break;}
-case 23:
-#line 315 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_DIV); ;
- break;}
-case 24:
-#line 319 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_REM); ;
- break;}
-case 25:
-#line 323 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_ADD); ;
- break;}
-case 26:
-#line 327 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_SUB); ;
- break;}
-case 27:
-#line 331 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_LSH); ;
- break;}
-case 28:
-#line 335 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_RSH); ;
- break;}
-case 29:
-#line 339 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_EQUAL); ;
- break;}
-case 30:
-#line 343 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_NOTEQUAL); ;
- break;}
-case 31:
-#line 347 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_LEQ); ;
- break;}
-case 32:
-#line 351 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_GEQ); ;
- break;}
-case 33:
-#line 355 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_LESS); ;
- break;}
-case 34:
-#line 359 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_GTR); ;
- break;}
-case 35:
-#line 363 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_BITWISE_AND); ;
- break;}
-case 36:
-#line 367 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_BITWISE_XOR); ;
- break;}
-case 37:
-#line 371 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_BITWISE_IOR); ;
- break;}
-case 38:
-#line 375 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_LOGICAL_AND); ;
- break;}
-case 39:
-#line 380 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_LOGICAL_OR); ;
- break;}
-case 40:
-#line 384 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_ASSIGN); ;
- break;}
-case 41:
-#line 388 "f-exp.y"
-{ write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode (yyvsp[-1].opcode);
- write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); ;
- break;}
-case 42:
-#line 394 "f-exp.y"
-{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (yyvsp[0].typed_val.type);
- write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val.val));
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 43:
-#line 401 "f-exp.y"
-{ YYSTYPE val;
- parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (val.typed_val.type);
- write_exp_elt_longcst ((LONGEST)val.typed_val.val);
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 44:
-#line 410 "f-exp.y"
-{ write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type (builtin_type_f_real_s8);
- write_exp_elt_dblcst (yyvsp[0].dval);
- write_exp_elt_opcode (OP_DOUBLE); ;
- break;}
-case 47:
-#line 423 "f-exp.y"
-{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_f_integer);
- CHECK_TYPEDEF (yyvsp[-1].tval);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 48:
-#line 431 "f-exp.y"
-{ write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
- write_exp_elt_opcode (OP_BOOL);
- ;
- break;}
-case 49:
-#line 438 "f-exp.y"
-{
- write_exp_elt_opcode (OP_STRING);
- write_exp_string (yyvsp[0].sval);
- write_exp_elt_opcode (OP_STRING);
- ;
- break;}
-case 50:
-#line 446 "f-exp.y"
-{ struct symbol *sym = yyvsp[0].ssym.sym;
-
- if (sym)
- {
- if (symbol_read_needs_frame (sym))
- {
- if (innermost_block == 0 ||
- contained_in (block_found,
- innermost_block))
- innermost_block = block_found;
- }
- write_exp_elt_opcode (OP_VAR_VALUE);
- /* We want to use the selected frame, not
- another more inner frame which happens to
- be in the same block. */
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
- break;
- }
- else
- {
- struct minimal_symbol *msymbol;
- register char *arg = copy_name (yyvsp[0].ssym.stoken);
-
- msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
- if (msymbol != NULL)
- {
- write_exp_msymbol (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
- else if (!have_full_symbols () && !have_partial_symbols ())
- 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 53:
-#line 494 "f-exp.y"
-{
- /* This is where the interesting stuff happens. */
- int done = 0;
- int array_size;
- struct type *follow_type = yyvsp[-1].tval;
- struct type *range_type;
-
- 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)
- {
- range_type =
- create_range_type ((struct type *) NULL,
- builtin_type_f_integer, 0,
- array_size - 1);
- follow_type =
- create_array_type ((struct type *) NULL,
- follow_type, range_type);
- }
- 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 54:
-#line 537 "f-exp.y"
-{ push_type (tp_pointer); yyval.voidval = 0; ;
- break;}
-case 55:
-#line 539 "f-exp.y"
-{ push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; ;
- break;}
-case 56:
-#line 541 "f-exp.y"
-{ push_type (tp_reference); yyval.voidval = 0; ;
- break;}
-case 57:
-#line 543 "f-exp.y"
-{ push_type (tp_reference); yyval.voidval = yyvsp[0].voidval; ;
- break;}
-case 59:
-#line 548 "f-exp.y"
-{ yyval.voidval = yyvsp[-1].voidval; ;
- break;}
-case 60:
-#line 550 "f-exp.y"
-{ push_type (tp_function); ;
- break;}
-case 61:
-#line 552 "f-exp.y"
-{ push_type (tp_function); ;
- break;}
-case 62:
-#line 556 "f-exp.y"
-{ yyval.voidval = 0; ;
- break;}
-case 63:
-#line 558 "f-exp.y"
-{ free ((PTR)yyvsp[-1].tvec); yyval.voidval = 0; ;
- break;}
-case 64:
-#line 563 "f-exp.y"
-{ yyval.tval = yyvsp[0].tsym.type; ;
- break;}
-case 65:
-#line 565 "f-exp.y"
-{ yyval.tval = builtin_type_f_integer; ;
- break;}
-case 66:
-#line 567 "f-exp.y"
-{ yyval.tval = builtin_type_f_integer_s2; ;
- break;}
-case 67:
-#line 569 "f-exp.y"
-{ yyval.tval = builtin_type_f_character; ;
- break;}
-case 68:
-#line 571 "f-exp.y"
-{ yyval.tval = builtin_type_f_logical;;
- break;}
-case 69:
-#line 573 "f-exp.y"
-{ yyval.tval = builtin_type_f_logical_s2;;
- break;}
-case 70:
-#line 575 "f-exp.y"
-{ yyval.tval = builtin_type_f_logical_s1;;
- break;}
-case 71:
-#line 577 "f-exp.y"
-{ yyval.tval = builtin_type_f_real;;
- break;}
-case 72:
-#line 579 "f-exp.y"
-{ yyval.tval = builtin_type_f_real_s8;;
- break;}
-case 73:
-#line 581 "f-exp.y"
-{ yyval.tval = builtin_type_f_real_s16;;
- break;}
-case 74:
-#line 583 "f-exp.y"
-{ yyval.tval = builtin_type_f_complex_s8;;
- break;}
-case 75:
-#line 585 "f-exp.y"
-{ yyval.tval = builtin_type_f_complex_s16;;
- break;}
-case 76:
-#line 587 "f-exp.y"
-{ yyval.tval = builtin_type_f_complex_s32;;
- break;}
-case 78:
-#line 595 "f-exp.y"
-{ yyval.tvec = (struct type **) xmalloc (sizeof (struct type *) * 2);
- yyval.ivec[0] = 1; /* Number of types in vector */
- yyval.tvec[1] = yyvsp[0].tval;
- ;
- break;}
-case 79:
-#line 600 "f-exp.y"
-{ int len = sizeof (struct type *) * (++(yyvsp[-2].ivec[0]) + 1);
- yyval.tvec = (struct type **) xrealloc ((char *) yyvsp[-2].tvec, len);
- yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval;
- ;
- break;}
-case 80:
-#line 607 "f-exp.y"
-{ yyval.sval = yyvsp[0].ssym.stoken; ;
- break;}
-case 81:
-#line 609 "f-exp.y"
-{ yyval.sval = yyvsp[0].tsym.stoken; ;
- break;}
-case 82:
-#line 611 "f-exp.y"
-{ yyval.sval = yyvsp[0].ssym.stoken; ;
- break;}
-}
- /* the action file gets copied in in place of this dollarsign */
-#line 498 "/stone/jimb/main-98r2/share/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;
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- size += strlen(yytname[x]) + 15, count++;
- msg = (char *) xmalloc(size + 15);
- if (msg != 0)
- {
- strcpy(msg, "parse error");
-
- if (count < 5)
- {
- count = 0;
- for (x = (yyn < 0 ? -yyn : 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
- yyerror ("parse error; also virtual memory exceeded");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror("parse error");
- }
-
- goto yyerrlab1;
-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 624 "f-exp.y"
-
-
-/* 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;
- int long_p = 0;
- ULONGEST high_bit;
- struct type *signed_type;
- struct type *unsigned_type;
-
- if (parsed_float)
- {
- /* It's a float since it contains a point or an exponent. */
- /* [dD] is not understood as an exponent by atof, change it to 'e'. */
- char *tmp, *tmp2;
-
- tmp = strsave (p);
- for (tmp2 = tmp; *tmp2; ++tmp2)
- if (*tmp2 == 'd' || *tmp2 == 'D')
- *tmp2 = 'e';
- putithere->dval = atof (tmp);
- free (tmp);
- 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')
- long_p = 1;
- 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 */
-
- /* Portably test for overflow (only works for nonzero values, so make
- a second check for zero). */
- if ((prevn >= n) && n != 0)
- unsigned_p=1; /* Try something unsigned */
- /* If range checking enabled, portably test for unsigned overflow. */
- if (RANGE_CHECK && n != 0)
- {
- if ((unsigned_p && (unsigned)prevn >= (unsigned)n))
- range_error("Overflow on numeric constant.");
- }
- prevn = n;
- }
-
- /* If the number is too big to be an int, or it's got an l suffix
- then it's a long. Work out if this has to be a long by
- shifting right and and seeing if anything remains, and the
- target int size is different to the target long size.
-
- In the expression below, we could have tested
- (n >> TARGET_INT_BIT)
- to see if it was zero,
- but too many compilers warn about that, when ints and longs
- are the same size. So we shift it twice, with fewer bits
- each time, for the same result. */
-
- if ((TARGET_INT_BIT != TARGET_LONG_BIT
- && ((n >> 2) >> (TARGET_INT_BIT-2))) /* Avoid shift warning */
- || long_p)
- {
- high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1);
- unsigned_type = builtin_type_unsigned_long;
- signed_type = builtin_type_long;
- }
- else
- {
- high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1);
- unsigned_type = builtin_type_unsigned_int;
- signed_type = builtin_type_int;
- }
-
- putithere->typed_val.val = n;
-
- /* If the high bit of the worked out type is set then this number
- has to be unsigned. */
-
- if (unsigned_p || (n & high_bit))
- putithere->typed_val.type = unsigned_type;
- else
- putithere->typed_val.type = signed_type;
-
- return INT;
-}
-
-struct token
-{
- char *operator;
- int token;
- enum exp_opcode opcode;
-};
-
-static const struct token dot_ops[] =
-{
- { ".and.", BOOL_AND, BINOP_END },
- { ".AND.", BOOL_AND, BINOP_END },
- { ".or.", BOOL_OR, BINOP_END },
- { ".OR.", BOOL_OR, BINOP_END },
- { ".not.", BOOL_NOT, BINOP_END },
- { ".NOT.", BOOL_NOT, BINOP_END },
- { ".eq.", EQUAL, BINOP_END },
- { ".EQ.", EQUAL, BINOP_END },
- { ".eqv.", EQUAL, BINOP_END },
- { ".NEQV.", NOTEQUAL, BINOP_END },
- { ".neqv.", NOTEQUAL, BINOP_END },
- { ".EQV.", EQUAL, BINOP_END },
- { ".ne.", NOTEQUAL, BINOP_END },
- { ".NE.", NOTEQUAL, BINOP_END },
- { ".le.", LEQ, BINOP_END },
- { ".LE.", LEQ, BINOP_END },
- { ".ge.", GEQ, BINOP_END },
- { ".GE.", GEQ, BINOP_END },
- { ".gt.", GREATERTHAN, BINOP_END },
- { ".GT.", GREATERTHAN, BINOP_END },
- { ".lt.", LESSTHAN, BINOP_END },
- { ".LT.", LESSTHAN, BINOP_END },
- { NULL, 0, 0 }
-};
-
-struct f77_boolean_val
-{
- char *name;
- int value;
-};
-
-static const struct f77_boolean_val boolean_values[] =
-{
- { ".true.", 1 },
- { ".TRUE.", 1 },
- { ".false.", 0 },
- { ".FALSE.", 0 },
- { NULL, 0 }
-};
-
-static const struct token f77_keywords[] =
-{
- { "complex_16", COMPLEX_S16_KEYWORD, BINOP_END },
- { "complex_32", COMPLEX_S32_KEYWORD, BINOP_END },
- { "character", CHARACTER, BINOP_END },
- { "integer_2", INT_S2_KEYWORD, BINOP_END },
- { "logical_1", LOGICAL_S1_KEYWORD, BINOP_END },
- { "logical_2", LOGICAL_S2_KEYWORD, BINOP_END },
- { "complex_8", COMPLEX_S8_KEYWORD, BINOP_END },
- { "integer", INT_KEYWORD, BINOP_END },
- { "logical", LOGICAL_KEYWORD, BINOP_END },
- { "real_16", REAL_S16_KEYWORD, BINOP_END },
- { "complex", COMPLEX_S8_KEYWORD, BINOP_END },
- { "sizeof", SIZEOF, BINOP_END },
- { "real_8", REAL_S8_KEYWORD, BINOP_END },
- { "real", REAL_KEYWORD, BINOP_END },
- { NULL, 0, 0 }
-};
-
-/* Implementation of a dynamically expandable buffer for processing input
- characters acquired through lexptr and building a value to return in
- yylval. Ripped off from ch-exp.y */
-
-static char *tempbuf; /* Current buffer contents */
-static int tempbufsize; /* Size of allocated buffer */
-static int tempbufindex; /* Current index into buffer */
-
-#define GROWBY_MIN_SIZE 64 /* Minimum amount to grow buffer by */
-
-#define CHECKBUF(size) \
- do { \
- if (tempbufindex + (size) >= tempbufsize) \
- { \
- growbuf_by_size (size); \
- } \
- } while (0);
-
-
-/* Grow the static temp buffer if necessary, including allocating the first one
- on demand. */
-
-static void
-growbuf_by_size (count)
- int count;
-{
- int growby;
-
- growby = max (count, GROWBY_MIN_SIZE);
- tempbufsize += growby;
- if (tempbuf == NULL)
- tempbuf = (char *) xmalloc (tempbufsize);
- else
- tempbuf = (char *) xrealloc (tempbuf, tempbufsize);
-}
-
-/* Blatantly ripped off from ch-exp.y. This routine recognizes F77
- string-literals.
-
- Recognize a string literal. A string literal is a nonzero sequence
- of characters enclosed in matching single quotes, except that
- a single character inside single quotes is a character literal, which
- we reject as a string literal. To embed the terminator character inside
- a string, it is simply doubled (I.E. 'this''is''one''string') */
-
-static int
-match_string_literal ()
-{
- char *tokptr = lexptr;
-
- for (tempbufindex = 0, tokptr++; *tokptr != '\0'; tokptr++)
- {
- CHECKBUF (1);
- if (*tokptr == *lexptr)
- {
- if (*(tokptr + 1) == *lexptr)
- tokptr++;
- else
- break;
- }
- tempbuf[tempbufindex++] = *tokptr;
- }
- if (*tokptr == '\0' /* no terminator */
- || tempbufindex == 0) /* no string */
- return 0;
- else
- {
- tempbuf[tempbufindex] = '\0';
- yylval.sval.ptr = tempbuf;
- yylval.sval.length = tempbufindex;
- lexptr = ++tokptr;
- return STRING_LITERAL;
- }
-}
-
-/* Read one token, getting characters through lexptr. */
-
-static int
-yylex ()
-{
- int c;
- int namelen;
- unsigned int i,token;
- char *tokstart;
-
- retry:
-
- tokstart = lexptr;
-
- /* First of all, let us make sure we are not dealing with the
- special tokens .true. and .false. which evaluate to 1 and 0. */
-
- if (*lexptr == '.')
- {
- for (i = 0; boolean_values[i].name != NULL; i++)
- {
- if STREQN (tokstart, boolean_values[i].name,
- strlen (boolean_values[i].name))
- {
- lexptr += strlen (boolean_values[i].name);
- yylval.lval = boolean_values[i].value;
- return BOOLEAN_LITERAL;
- }
- }
- }
-
- /* See if it is a special .foo. operator */
-
- for (i = 0; dot_ops[i].operator != NULL; i++)
- if (STREQN (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)))
- {
- lexptr += strlen (dot_ops[i].operator);
- yylval.opcode = dot_ops[i].opcode;
- return dot_ops[i].token;
- }
-
- switch (c = *tokstart)
- {
- case 0:
- return 0;
-
- case ' ':
- case '\t':
- case '\n':
- lexptr++;
- goto retry;
-
- case '\'':
- token = match_string_literal ();
- if (token != 0)
- return (token);
- break;
-
- 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, got_d = 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_d && (*p == 'd' || *p == 'D'))
- got_dot = got_d = 1;
- else if (!hex && !got_dot && *p == '.')
- got_dot = 1;
- else if (((got_e && (p[-1] == 'e' || p[-1] == 'E'))
- || (got_d && (p[-1] == 'd' || p[-1] == 'D')))
- && (*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|got_d,
- &yylval);
- if (toktype == ERROR)
- {
- char *err_copy = (char *) alloca (p - tokstart + 1);
-
- memcpy (err_copy, tokstart, 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;
- }
-
- 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);
-
- 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;
-
- /* Catch specific keywords. */
-
- for (i = 0; f77_keywords[i].operator != NULL; i++)
- if (STREQN(tokstart, f77_keywords[i].operator,
- strlen(f77_keywords[i].operator)))
- {
- /* lexptr += strlen(f77_keywords[i].operator); */
- yylval.opcode = f77_keywords[i].opcode;
- return f77_keywords[i].token;
- }
-
- yylval.sval.ptr = tokstart;
- yylval.sval.length = namelen;
-
- if (*tokstart == '$')
- {
- write_dollar_variable (yylval.sval);
- return VARIABLE;
- }
-
- /* 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_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;
- }
- }
-
- /* 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 ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
-}
diff --git a/contrib/gdb/gdb/gdbserver/gdbreplay.c b/contrib/gdb/gdb/gdbserver/gdbreplay.c
index ebe06ba..39258a2 100644
--- a/contrib/gdb/gdb/gdbserver/gdbreplay.c
+++ b/contrib/gdb/gdb/gdbserver/gdbreplay.c
@@ -26,7 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <netinet/tcp.h>
#include <signal.h>
#include <ctype.h>
-#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
/* Sort of a hack... */
#define EOL (EOF - 1)
@@ -41,13 +42,10 @@ void
perror_with_name (string)
char *string;
{
- extern int sys_nerr;
- extern char *sys_errlist[];
- extern int errno;
char *err;
char *combined;
- err = (errno < sys_nerr) ? sys_errlist[errno] : "unknown error";
+ err = strerror(errno);
combined = (char *) alloca (strlen (err) + strlen (string) + 3);
strcpy (combined, string);
strcat (combined, ": ");
diff --git a/contrib/gdb/gdb/gdbserver/utils.c b/contrib/gdb/gdb/gdbserver/utils.c
index 63d522c..1e4aabe 100644
--- a/contrib/gdb/gdb/gdbserver/utils.c
+++ b/contrib/gdb/gdb/gdbserver/utils.c
@@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "server.h"
#include <stdio.h>
-#include <string.h>
/* Generally useful subroutines used throughout the program. */
@@ -31,10 +30,7 @@ void
perror_with_name (string)
char *string;
{
- extern int sys_nerr;
- extern char *sys_errlist[];
- extern int errno;
- char *err;
+ const char *err;
char *combined;
if (errno < sys_nerr)
@@ -56,7 +52,7 @@ perror_with_name (string)
#ifdef ANSI_PROTOTYPES
NORETURN void
-error (const char *string, ...)
+error (char *string, ...)
#else
void
error (va_alist)
diff --git a/contrib/gdb/gdb/gnu-nat.c b/contrib/gdb/gdb/gnu-nat.c
deleted file mode 100644
index 156d981..0000000
--- a/contrib/gdb/gdb/gnu-nat.c
+++ /dev/null
@@ -1,3201 +0,0 @@
-/* Interface GDB to the GNU Hurd
- Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
-
- This file is part of GDB.
-
- Written by Miles Bader <miles@gnu.ai.mit.edu>
-
- Some code and ideas from m3-nat.c by Jukka Virtanen <jtv@hut.fi>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include <stdio.h>
-#include <errno.h>
-#include <signal.h>
-#include <assert.h>
-#include <setjmp.h>
-#include <limits.h>
-#include <sys/ptrace.h>
-
-/* We include this because we don't need the access macros and they conflict
- with gdb's definitions (ick). This is very non standard! */
-#include <waitflags.h>
-
-#include <mach.h>
-#include <mach/message.h>
-#include <mach/notify.h>
-#include <mach_error.h>
-#include <mach/exception.h>
-#include <mach/vm_attributes.h>
-
-#include <hurd/process.h>
-#include <hurd/process_request.h>
-#include <hurd/msg.h>
-#include <hurd/msg_request.h>
-#include <hurd/signal.h>
-#include <hurd/interrupt.h>
-#include <hurd/sigpreempt.h>
-
-#include <portinfo.h>
-
-#include "defs.h"
-#include "inferior.h"
-#include "symtab.h"
-#include "value.h"
-#include "language.h"
-#include "target.h"
-#include "wait.h"
-#include "gdbcmd.h"
-#include "gdbcore.h"
-
-#include "gnu-nat.h"
-
-#include "exc_request_S.h"
-#include "notify_S.h"
-#include "process_reply_S.h"
-#include "msg_reply_S.h"
-#include "exc_request_U.h"
-#include "msg_U.h"
-
-static process_t proc_server = MACH_PORT_NULL;
-
-/* If we've sent a proc_wait_request to the proc server, the pid of the
- process we asked about. We can only ever have one outstanding. */
-int proc_wait_pid = 0;
-
-/* The number of wait requests we've sent, and expect replies from. */
-int proc_waits_pending = 0;
-
-int gnu_debug_flag = 0;
-
-/* Forward decls */
-
-extern struct target_ops gnu_ops;
-extern char *strerror();
-
-int inf_update_procs (struct inf *inf);
-struct inf *make_inf ();
-void inf_clear_wait (struct inf *inf);
-void inf_cleanup (struct inf *inf);
-void inf_startup (struct inf *inf, int pid);
-int inf_update_suspends (struct inf *inf);
-void inf_set_pid (struct inf *inf, pid_t pid);
-void inf_validate_procs (struct inf *inf);
-void inf_steal_exc_ports (struct inf *inf);
-void inf_restore_exc_ports (struct inf *inf);
-struct proc *inf_tid_to_proc (struct inf *inf, int tid);
-inline void inf_set_threads_resume_sc (struct inf *inf,
- struct proc *run_thread,
- int run_others);
-inline int inf_set_threads_resume_sc_for_signal_thread (struct inf *inf);
-inline void inf_suspend (struct inf *inf);
-inline void inf_resume (struct inf *inf);
-void inf_set_step_thread (struct inf *inf, struct proc *proc);
-void inf_detach (struct inf *inf);
-void inf_attach (struct inf *inf, int pid);
-void inf_signal (struct inf *inf, enum target_signal sig);
-
-#define inf_debug(_inf, msg, args...) \
- do { struct inf *__inf = (_inf); \
- debug ("{inf %d %p}: " msg, __inf->pid, __inf , ##args); } while (0)
-
-void proc_abort (struct proc *proc, int force);
-thread_state_t proc_get_state (struct proc *proc, int force);
-struct proc *make_proc (struct inf *inf, mach_port_t port, int tid);
-struct proc *_proc_free (struct proc *proc);
-int proc_update_sc (struct proc *proc);
-error_t proc_get_exception_port (struct proc *proc, mach_port_t *port);
-error_t proc_set_exception_port (struct proc *proc, mach_port_t port);
-static mach_port_t _proc_get_exc_port (struct proc *proc);
-void proc_steal_exc_port (struct proc *proc, mach_port_t exc_port);
-void proc_restore_exc_port (struct proc *proc);
-int proc_trace (struct proc *proc, int set);
-char *proc_string (struct proc *proc);
-
-/* Evaluate RPC_EXPR in a scope with the variables MSGPORT and REFPORT bound
- to INF's msg port and task port respectively. If it has no msg port,
- EIEIO is returned. INF must refer to a running process! */
-#define INF_MSGPORT_RPC(inf, rpc_expr) \
- HURD_MSGPORT_RPC (proc_getmsgport (proc_server, inf->pid, &msgport), \
- (refport = inf->task->port, 0), 0, \
- msgport ? (rpc_expr) : EIEIO)
-
-/* Like INF_MSGPORT_RPC, but will also resume the signal thread to ensure
- there's someone around to deal with the RPC (and resuspend things
- afterwards). This effects INF's threads' resume_sc count. */
-#define INF_RESUME_MSGPORT_RPC(inf, rpc_expr) \
- (inf_set_threads_resume_sc_for_signal_thread (inf) \
- ? ({ error_t __e; \
- inf_resume (inf); \
- __e = INF_MSGPORT_RPC (inf, rpc_expr); \
- inf_suspend (inf); \
- __e; }) \
- : EIEIO)
-
-#define MIG_SERVER_DIED EMIG_SERVER_DIED /* XXX */
-
-/* The state passed by an exception message. */
-struct exc_state
-{
- int exception; /* The exception code */
- int code, subcode;
- mach_port_t handler; /* The real exception port to handle this. */
- mach_port_t reply; /* The reply port from the exception call. */
-};
-
-/* The results of the last wait an inf did. */
-struct inf_wait
-{
- struct target_waitstatus status; /* The status returned to gdb. */
- struct exc_state exc; /* The exception that caused us to return. */
- struct proc *thread; /* The thread in question. */
- int suppress; /* Something trivial happened. */
-};
-
-/* The state of an inferior. */
-struct inf
-{
- /* Fields describing the current inferior. */
-
- struct proc *task; /* The mach task. */
- struct proc *threads; /* A linked list of all threads in TASK. */
-
- /* True if THREADS needn't be validated by querying the task. We assume that
- we and the task in question are the only ones frobbing the thread list,
- so as long as we don't let any code run, we don't have to worry about
- THREADS changing. */
- int threads_up_to_date;
-
- pid_t pid; /* The real system PID. */
-
- struct inf_wait wait; /* What to return from target_wait. */
-
- /* One thread proc in INF may be in `single-stepping mode'. This is it. */
- struct proc *step_thread;
-
- /* The thread we think is the signal thread. */
- struct proc *signal_thread;
-
- mach_port_t event_port; /* Where we receive various msgs. */
-
- /* True if we think at least one thread in the inferior could currently be
- running. */
- int running : 1;
-
- /* True if the process has stopped (in the proc server sense). Note that
- since a proc server `stop' leaves the signal thread running, the inf can
- be RUNNING && STOPPED... */
- int stopped : 1;
-
- /* True if the inferior is traced. */
- int traced : 1;
-
- /* True if we shouldn't try waiting for the inferior, usually because we
- can't for some reason. */
- int no_wait : 1;
-
- /* When starting a new inferior, we don't try to validate threads until all
- the proper execs have been done. This is a count of how many execs we
- expect to happen. */
- unsigned pending_execs;
-
- /* Fields describing global state */
-
- /* The task suspend count used when gdb has control. This is normally 1 to
- make things easier for us, but sometimes (like when attaching to vital
- system servers) it may be desirable to let the task continue to run
- (pausing individual threads as necessary). */
- int pause_sc;
-
- /* The task suspend count left when detaching from a task. */
- int detach_sc;
-
- /* The initial values used for the run_sc and pause_sc of newly discovered
- threads -- see the definition of those fields in struct proc. */
- int default_thread_run_sc;
- int default_thread_pause_sc;
- int default_thread_detach_sc;
-
- /* True if the process should be traced when started/attached. Newly
- started processes *must* be traced at first to exec them properly, but
- if this is false, tracing is turned off as soon it has done so. */
- int want_signals;
-
- /* True if exceptions from the inferior process should be trapped. This
- must be on to use breakpoints. */
- int want_exceptions;
-};
-
-
-int __proc_pid (struct proc *proc)
-{
- return proc->inf->pid;
-}
-
-/* Update PROC's real suspend count to match it's desired one. Returns true
- if we think PROC is now in a runnable state. */
-int
-proc_update_sc (struct proc *proc)
-{
- int running;
- int err = 0;
- int delta = proc->sc - proc->cur_sc;
-
- if (delta)
- proc_debug (proc, "sc: %d --> %d", proc->cur_sc, proc->sc);
-
- if (proc->sc == 0 && proc->state_changed)
- /* Since PROC may start running, we must write back any state changes. */
- {
- assert (proc_is_thread (proc));
- proc_debug (proc, "storing back changed thread state");
- err = thread_set_state (proc->port, THREAD_STATE_FLAVOR,
- (thread_state_t)&proc->state, THREAD_STATE_SIZE);
- if (! err)
- proc->state_changed = 0;
- }
-
- if (delta > 0)
- while (delta-- > 0 && !err)
- if (proc_is_task (proc))
- err = task_suspend (proc->port);
- else
- err = thread_suspend (proc->port);
- else
- while (delta++ < 0 && !err)
- if (proc_is_task (proc))
- err = task_resume (proc->port);
- else
- err = thread_resume (proc->port);
-
- if (! err)
- proc->cur_sc = proc->sc;
-
- /* If we got an error, then the task/thread has disappeared. */
- running = !err && proc->sc == 0;
-
- proc_debug (proc, "is %s", err ? "dead" : running ? "running" : "suspended");
- if (err)
- proc_debug (proc, "err = %s", strerror (err));
-
- if (running)
- {
- proc->aborted = 0;
- proc->state_valid = proc->state_changed = 0;
- proc->fetched_regs = 0;
- }
-
- return running;
-}
-
-/* Thread_abort is called on PROC if needed. PROC must be a thread proc.
- If PROC is deemed `precious', then nothing is done unless FORCE is true.
- In particular, a thread is precious if it's running (in which case forcing
- it includes suspending it first), or if it has an exception pending. */
-void
-proc_abort (struct proc *proc, int force)
-{
- assert (proc_is_thread (proc));
-
- if (! proc->aborted)
- {
- struct inf *inf = proc->inf;
- int running = (proc->cur_sc == 0 && inf->task->cur_sc == 0);
-
- if (running && force)
- {
- proc->sc = 1;
- inf_update_suspends (proc->inf);
- running = 0;
- warning ("Stopped %s.", proc_string (proc));
- }
- else if (proc == inf->wait.thread && inf->wait.exc.reply && !force)
- /* An exception is pending on PROC, which don't mess with. */
- running = 1;
-
- if (! running)
- /* We only abort the thread if it's not actually running. */
- {
- thread_abort (proc->port);
- proc_debug (proc, "aborted");
- proc->aborted = 1;
- }
- else
- proc_debug (proc, "not aborting");
- }
-}
-
-/* Make sure that the state field in PROC is up to date, and return a pointer
- to it, or 0 if something is wrong. If WILL_MODIFY is true, makes sure
- that the thread is stopped and aborted first, and sets the state_changed
- field in PROC to true. */
-thread_state_t
-proc_get_state (struct proc *proc, int will_modify)
-{
- int was_aborted = proc->aborted;
-
- proc_debug (proc, "updating state info%s",
- will_modify ? " (with intention to modify)" : "");
-
- proc_abort (proc, will_modify);
-
- if (! was_aborted && proc->aborted)
- /* PROC's state may have changed since we last fetched it. */
- proc->state_valid = 0;
-
- if (! proc->state_valid)
- {
- mach_msg_type_number_t state_size = THREAD_STATE_SIZE;
- error_t err =
- thread_get_state (proc->port, THREAD_STATE_FLAVOR,
- (thread_state_t)&proc->state, &state_size);
- proc_debug (proc, "getting thread state");
- proc->state_valid = !err;
- }
-
- if (proc->state_valid)
- {
- if (will_modify)
- proc->state_changed = 1;
- return (thread_state_t)&proc->state;
- }
- else
- return 0;
-}
-
-/* Set PORT to PROC's exception port. */
-error_t
-proc_get_exception_port (struct proc *proc, mach_port_t *port)
-{
- if (proc_is_task (proc))
- return task_get_exception_port (proc->port, port);
- else
- return thread_get_exception_port (proc->port, port);
-}
-
-/* Set PROC's exception port to PORT. */
-error_t
-proc_set_exception_port (struct proc *proc, mach_port_t port)
-{
- proc_debug (proc, "setting exception port: %d", port);
- if (proc_is_task (proc))
- return task_set_exception_port (proc->port, port);
- else
- return thread_set_exception_port (proc->port, port);
-}
-
-/* Get PROC's exception port, cleaning up a bit if proc has died. */
-static mach_port_t
-_proc_get_exc_port (struct proc *proc)
-{
- mach_port_t exc_port;
- error_t err = proc_get_exception_port (proc, &exc_port);
-
- if (err)
- /* PROC must be dead. */
- {
- if (proc->exc_port)
- mach_port_deallocate (mach_task_self (), proc->exc_port);
- proc->exc_port = MACH_PORT_NULL;
- if (proc->saved_exc_port)
- mach_port_deallocate (mach_task_self (), proc->saved_exc_port);
- proc->saved_exc_port = MACH_PORT_NULL;
- }
-
- return exc_port;
-}
-
-/* Replace PROC's exception port with EXC_PORT, unless it's already been
- done. Stash away any existing exception port so we can restore it later. */
-void
-proc_steal_exc_port (struct proc *proc, mach_port_t exc_port)
-{
- mach_port_t cur_exc_port = _proc_get_exc_port (proc);
-
- if (cur_exc_port)
- {
- error_t err;
-
- proc_debug (proc, "inserting exception port: %d", exc_port);
-
- if (cur_exc_port != exc_port)
- /* Put in our exception port. */
- err = proc_set_exception_port (proc, exc_port);
-
- if (err || cur_exc_port == proc->exc_port)
- /* We previously set the exception port, and it's still set. So we
- just keep the old saved port which is what the proc set. */
- {
- if (cur_exc_port)
- mach_port_deallocate (mach_task_self (), cur_exc_port);
- }
- else
- /* Keep a copy of PROC's old exception port so it can be restored. */
- {
- if (proc->saved_exc_port)
- mach_port_deallocate (mach_task_self (), proc->saved_exc_port);
- proc->saved_exc_port = cur_exc_port;
- }
-
- proc_debug (proc, "saved exception port: %d", proc->saved_exc_port);
-
- if (!err)
- proc->exc_port = exc_port;
- else
- warning ("Error setting exception port for %s: %s",
- proc_string (proc), strerror (err));
- }
-}
-
-/* If we previously replaced PROC's exception port, put back what we
- found there at the time, unless *our* exception port has since been
- overwritten, in which case who knows what's going on. */
-void
-proc_restore_exc_port (struct proc *proc)
-{
- mach_port_t cur_exc_port = _proc_get_exc_port (proc);
-
- if (cur_exc_port)
- {
- error_t err = 0;
-
- proc_debug (proc, "restoring real exception port");
-
- if (proc->exc_port == cur_exc_port)
- /* Our's is still there. */
- err = proc_set_exception_port (proc, proc->saved_exc_port);
-
- if (proc->saved_exc_port)
- mach_port_deallocate (mach_task_self (), proc->saved_exc_port);
- proc->saved_exc_port = MACH_PORT_NULL;
-
- if (!err)
- proc->exc_port = MACH_PORT_NULL;
- else
- warning ("Error setting exception port for %s: %s",
- proc_string (proc), strerror (err));
- }
-}
-
-/* Turns hardware tracing in PROC on or off when SET is true or false,
- respectively. Returns true on success. */
-int
-proc_trace (struct proc *proc, int set)
-{
- thread_state_t state = proc_get_state (proc, 1);
-
- if (! state)
- return 0; /* the thread must be dead. */
-
- proc_debug (proc, "tracing %s", set ? "on" : "off");
-
- if (set)
- {
- /* XXX We don't get the exception unless the thread has its own
- exception port???? */
- if (proc->exc_port == MACH_PORT_NULL)
- proc_steal_exc_port (proc, proc->inf->event_port);
- THREAD_STATE_SET_TRACED (state);
- }
- else
- THREAD_STATE_CLEAR_TRACED (state);
-
- return 1;
-}
-
-/* A variable from which to assign new TIDs. */
-static int next_thread_id = 1;
-
-/* Returns a new proc structure with the given fields. Also adds a
- notification for PORT becoming dead to be sent to INF's notify port. */
-struct proc *
-make_proc (struct inf *inf, mach_port_t port, int tid)
-{
- error_t err;
- mach_port_t prev_port = MACH_PORT_NULL;
- struct proc *proc = malloc (sizeof (struct proc));
-
- proc->port = port;
- proc->tid = tid;
- proc->inf = inf;
- proc->next = 0;
- proc->saved_exc_port = MACH_PORT_NULL;
- proc->exc_port = MACH_PORT_NULL;
-
- proc->sc = 0;
- proc->cur_sc = 0;
-
- /* Note that these are all the values for threads; the task simply uses the
- corresponding field in INF directly. */
- proc->run_sc = inf->default_thread_run_sc;
- proc->pause_sc = inf->default_thread_pause_sc;
- proc->detach_sc = inf->default_thread_detach_sc;
- proc->resume_sc = proc->run_sc;
-
- proc->aborted = 0;
- proc->dead = 0;
- proc->state_valid = 0;
- proc->state_changed = 0;
-
- proc_debug (proc, "is new");
-
- /* Get notified when things die. */
- err =
- mach_port_request_notification (mach_task_self(), port,
- MACH_NOTIFY_DEAD_NAME, 1,
- inf->event_port,
- MACH_MSG_TYPE_MAKE_SEND_ONCE,
- &prev_port);
- if (err)
- warning ("Couldn't request notification for port %d: %s",
- port, strerror (err));
- else
- {
- proc_debug (proc, "notifications to: %d", inf->event_port);
- if (prev_port != MACH_PORT_NULL)
- mach_port_deallocate (mach_task_self (), prev_port);
- }
-
- if (inf->want_exceptions)
- if (proc_is_task (proc))
- /* Make the task exception port point to us. */
- proc_steal_exc_port (proc, inf->event_port);
- else
- /* Just clear thread exception ports -- they default to the task one. */
- proc_steal_exc_port (proc, MACH_PORT_NULL);
-
- return proc;
-}
-
-/* Frees PROC and any resources it uses, and returns the value of PROC's
- next field. */
-struct proc *
-_proc_free (struct proc *proc)
-{
- struct inf *inf = proc->inf;
- struct proc *next = proc->next;
-
- proc_debug (proc, "freeing...");
-
- if (proc == inf->step_thread)
- /* Turn off single stepping. */
- inf_set_step_thread (inf, 0);
- if (proc == inf->wait.thread)
- inf_clear_wait (inf);
- if (proc == inf->signal_thread)
- inf->signal_thread = 0;
-
- if (proc->port != MACH_PORT_NULL)
- {
- if (proc->exc_port != MACH_PORT_NULL)
- /* Restore the original exception port. */
- proc_restore_exc_port (proc);
- if (proc->cur_sc != 0)
- /* Resume the thread/task. */
- {
- proc->sc = 0;
- proc_update_sc (proc);
- }
- mach_port_deallocate (mach_task_self (), proc->port);
- }
-
- free (proc);
- return next;
-}
-
-struct inf *make_inf ()
-{
- struct inf *inf = malloc (sizeof (struct inf));
-
- if (!inf)
- return 0;
-
- inf->task = 0;
- inf->threads = 0;
- inf->threads_up_to_date = 0;
- inf->pid = 0;
- inf->wait.status.kind = TARGET_WAITKIND_SPURIOUS;
- inf->wait.thread = 0;
- inf->wait.exc.handler = MACH_PORT_NULL;
- inf->wait.exc.reply = MACH_PORT_NULL;
- inf->step_thread = 0;
- inf->signal_thread = 0;
- inf->event_port = MACH_PORT_NULL;
- inf->stopped = 0;
- inf->running = 0;
- inf->traced = 0;
- inf->no_wait = 0;
- inf->pending_execs = 0;
- inf->pause_sc = 1;
- inf->detach_sc = 0;
- inf->default_thread_run_sc = 0;
- inf->default_thread_pause_sc = 0;
- inf->default_thread_detach_sc = 0;
- inf->want_signals = 1; /* By default */
- inf->want_exceptions = 1; /* By default */
-
- return inf;
-}
-
-/* clear INF's target wait status. */
-void
-inf_clear_wait (struct inf *inf)
-{
- inf_debug (inf, "clearing wait");
- inf->wait.status.kind = TARGET_WAITKIND_SPURIOUS;
- inf->wait.thread = 0;
- inf->wait.suppress = 0;
- if (inf->wait.exc.handler != MACH_PORT_NULL)
- {
- mach_port_deallocate (mach_task_self (), inf->wait.exc.handler);
- inf->wait.exc.handler = MACH_PORT_NULL;
- }
- if (inf->wait.exc.reply != MACH_PORT_NULL)
- {
- mach_port_deallocate (mach_task_self (), inf->wait.exc.reply);
- inf->wait.exc.reply = MACH_PORT_NULL;
- }
-}
-
-void
-inf_cleanup (struct inf *inf)
-{
- inf_debug (inf, "cleanup");
-
- inf_clear_wait (inf);
-
- inf_set_pid (inf, -1);
- inf->pid = 0;
- inf->traced = 0;
- inf->no_wait = 0;
- inf->stopped = 0;
- inf->running = 0;
- inf->pending_execs = 0;
-
- if (inf->event_port)
- {
- mach_port_destroy (mach_task_self (), inf->event_port);
- inf->event_port = MACH_PORT_NULL;
- }
-}
-
-void
-inf_startup (struct inf *inf, int pid)
-{
- error_t err;
-
- inf_debug (inf, "startup: pid = %d", pid);
-
- inf_cleanup (inf);
-
- /* Make the port on which we receive all events. */
- err = mach_port_allocate (mach_task_self (),
- MACH_PORT_RIGHT_RECEIVE, &inf->event_port);
- if (err)
- error ("Error allocating event port: %s", strerror (err));
-
- /* Make a send right for it, so we can easily copy it for other people. */
- mach_port_insert_right (mach_task_self (), inf->event_port,
- inf->event_port, MACH_MSG_TYPE_MAKE_SEND);
- inf_set_pid (inf, pid);
-}
-
-/* close current process, if any, and attach INF to process PORT */
-void
-inf_set_pid (struct inf *inf, pid_t pid)
-{
- task_t task_port;
- struct proc *task = inf->task;
-
- inf_debug (inf, "setting pid: %d", pid);
-
- if (pid < 0)
- task_port = MACH_PORT_NULL;
- else
- {
- error_t err = proc_pid2task (proc_server, pid, &task_port);
- if (err)
- error ("Error getting task for pid %d: %s", pid, strerror (err));
- }
-
- inf_debug (inf, "setting task: %d", task_port);
-
- if (inf->pause_sc)
- task_suspend (task_port);
-
- if (task && task->port != task_port)
- {
- inf->task = 0;
- inf_validate_procs (inf); /* Trash all the threads. */
- _proc_free (task); /* And the task. */
- }
-
- if (task_port != MACH_PORT_NULL)
- {
- inf->task = make_proc (inf, task_port, PROC_TID_TASK);
- inf->threads_up_to_date = 0;
- }
-
- if (inf->task)
- {
- inf->pid = pid;
- if (inf->pause_sc)
- inf->task->sc = inf->task->cur_sc = 1; /* Reflect task_suspend above */
- }
- else
- inf->pid = -1;
-}
-
-/* Validates INF's stopped field from the actual proc server state. */
-static void
-inf_validate_stopped (struct inf *inf)
-{
- char *noise;
- mach_msg_type_number_t noise_len = 0;
- struct procinfo *pi;
- mach_msg_type_number_t pi_len = 0;
- int info_flags = 0;
- error_t err =
- proc_getprocinfo (proc_server, inf->pid, &info_flags,
- (procinfo_t *)&pi, &pi_len, &noise, &noise_len);
-
- if (! err)
- {
- inf->stopped = !!(pi->state & PI_STOPPED);
- vm_deallocate (mach_task_self (), (vm_address_t)pi, pi_len);
- if (noise_len > 0)
- vm_deallocate (mach_task_self (), (vm_address_t)noise, noise_len);
- }
-}
-
-/* Validates INF's task suspend count. If it's higher than we expect, verify
- with the user before `stealing' the extra count. */
-static void
-inf_validate_task_sc (struct inf *inf)
-{
- struct task_basic_info info;
- mach_msg_type_number_t info_len = TASK_BASIC_INFO_COUNT;
- error_t err =
- task_info (inf->task->port, TASK_BASIC_INFO, (task_info_t)&info, &info_len);
-
- if (err)
- inf->task->dead = 1; /* oh well */
- else if (inf->task->cur_sc < info.suspend_count)
- {
- int abort;
-
- target_terminal_ours (); /* Allow I/O. */
- abort =
- !query ("Pid %d has an additional task suspend count of %d; clear it? ",
- inf->pid, info.suspend_count - inf->task->cur_sc);
- target_terminal_inferior (); /* Give it back to the child. */
-
- if (abort)
- error ("Additional task suspend count left untouched.");
-
- inf->task->cur_sc = info.suspend_count;
- }
-}
-
-/* Turns tracing for INF on or off, depending on ON, unless it already is.
- If INF is running, the resume_sc count of INF's threads will be modified,
- and the signal thread will briefly be run to change the trace state. */
-void
-inf_set_traced (struct inf *inf, int on)
-{
- if (on != inf->traced)
- if (inf->task && !inf->task->dead)
- /* Make it take effect immediately. */
- {
- sigset_t mask = on ? ~(sigset_t)0 : 0;
- error_t err =
- INF_RESUME_MSGPORT_RPC (inf, msg_set_init_int (msgport, refport,
- INIT_TRACEMASK, mask));
- if (err == EIEIO)
- {
- if (on)
- warning ("Can't modify tracing state for pid %d: No signal thread",
- inf->pid);
- inf->traced = on;
- }
- else if (err)
- warning ("Can't modify tracing state for pid %d: %s",
- inf->pid, strerror (err));
- else
- inf->traced = on;
- }
- else
- inf->traced = on;
-}
-
-/* Makes all the real suspend count deltas of all the procs in INF match the
- desired values. Careful to always do thread/task suspend counts in the
- safe order. Returns true if at least one thread is thought to be running.*/
-int
-inf_update_suspends (struct inf *inf)
-{
- struct proc *task = inf->task;
- /* We don't have to update INF->threads even though we're iterating over it
- because we'll change a thread only if it already has an existing proc
- entry. */
-
- inf_debug (inf, "updating suspend counts");
-
- if (task)
- {
- struct proc *thread;
- int task_running = (task->sc == 0), thread_running = 0;
-
- if (task->sc > task->cur_sc)
- /* The task is becoming _more_ suspended; do before any threads. */
- task_running = proc_update_sc (task);
-
- if (inf->pending_execs)
- /* When we're waiting for an exec, things may be happening behind our
- back, so be conservative. */
- thread_running = 1;
-
- /* Do all the thread suspend counts. */
- for (thread = inf->threads; thread; thread = thread->next)
- thread_running |= proc_update_sc (thread);
-
- if (task->sc != task->cur_sc)
- /* We didn't do the task first, because we wanted to wait for the
- threads; do it now. */
- task_running = proc_update_sc (task);
-
- inf_debug (inf, "%srunning...",
- (thread_running && task_running) ? "" : "not ");
-
- inf->running = thread_running && task_running;
-
- /* Once any thread has executed some code, we can't depend on the
- threads list any more. */
- if (inf->running)
- inf->threads_up_to_date = 0;
-
- return inf->running;
- }
-
- return 0;
-}
-
-/* Converts a GDB pid to a struct proc. */
-struct proc *
-inf_tid_to_thread (struct inf *inf, int tid)
-{
- struct proc *thread = inf->threads;
-
- while (thread)
- if (thread->tid == tid)
- return thread;
- else
- thread = thread->next;
- return 0;
-}
-
-/* Converts a thread port to a struct proc. */
-struct proc *
-inf_port_to_thread (struct inf *inf, mach_port_t port)
-{
- struct proc *thread = inf->threads;
- while (thread)
- if (thread->port == port)
- return thread;
- else
- thread = thread->next;
- return 0;
-}
-
-/* Make INF's list of threads be consistent with reality of TASK. */
-void
-inf_validate_procs (struct inf *inf)
-{
- int i;
- thread_array_t threads;
- unsigned num_threads;
- struct proc *task = inf->task;
-
- /* If no threads are currently running, this function will guarantee that
- things are up to date. The exception is if there are zero threads --
- then it is almost certainly in an odd state, and probably some outside
- agent will create threads. */
- inf->threads_up_to_date = inf->threads ? !inf->running : 0;
-
- if (task)
- {
- error_t err = task_threads (task->port, &threads, &num_threads);
- inf_debug (inf, "fetching threads");
- if (err)
- /* TASK must be dead. */
- {
- task->dead = 1;
- task = 0;
- }
- }
-
- if (!task)
- {
- num_threads = 0;
- inf_debug (inf, "no task");
- }
-
- {
- unsigned search_start = 0; /* Make things normally linear. */
- /* Which thread in PROCS corresponds to each task thread, & the task. */
- struct proc *matched[num_threads + 1];
- /* The last thread in INF->threads, so we can add to the end. */
- struct proc *last = 0;
- /* The current thread we're considering. */
- struct proc *thread = inf->threads;
-
- bzero (matched, sizeof (matched));
-
- while (thread)
- {
- unsigned left;
-
- for (i = search_start, left = num_threads; left; i++, left--)
- {
- if (i >= num_threads)
- i -= num_threads; /* I wrapped around. */
- if (thread->port == threads[i])
- /* We already know about this thread. */
- {
- matched[i] = thread;
- last = thread;
- thread = thread->next;
- search_start++;
- break;
- }
- }
-
- if (! left)
- {
- proc_debug (thread, "died!");
- thread->port = MACH_PORT_NULL;
- thread = _proc_free (thread); /* THREAD is dead. */
- (last ? last->next : inf->threads) = thread;
- }
- }
-
- for (i = 0; i < num_threads; i++)
- if (matched[i])
- /* Throw away the duplicate send right. */
- mach_port_deallocate (mach_task_self (), threads[i]);
- else
- /* THREADS[I] is a thread we don't know about yet! */
- {
- thread = make_proc (inf, threads[i], next_thread_id++);
- (last ? last->next : inf->threads) = thread;
- last = thread;
- proc_debug (thread, "new thread: %d", threads[i]);
- add_thread (thread->tid); /* Tell GDB's generic thread code. */
- }
-
- vm_deallocate(mach_task_self(),
- (vm_address_t)threads, (num_threads * sizeof(thread_t)));
- }
-}
-
-/* Makes sure that INF's thread list is synced with the actual process. */
-inline int
-inf_update_procs (struct inf *inf)
-{
- if (! inf->task)
- return 0;
- if (! inf->threads_up_to_date)
- inf_validate_procs (inf);
- return !!inf->task;
-}
-
-/* Sets the resume_sc of each thread in inf. That of RUN_THREAD is set to 0,
- and others are set to their run_sc if RUN_OTHERS is true, and otherwise
- their pause_sc. */
-inline void
-inf_set_threads_resume_sc (struct inf *inf,
- struct proc *run_thread, int run_others)
-{
- struct proc *thread;
- inf_update_procs (inf);
- for (thread = inf->threads; thread; thread = thread->next)
- if (thread == run_thread)
- thread->resume_sc = 0;
- else if (run_others)
- thread->resume_sc = thread->run_sc;
- else
- thread->resume_sc = thread->pause_sc;
-}
-
-/* Cause INF to continue execution immediately; individual threads may still
- be suspended (but their suspend counts will be updated). */
-inline void
-inf_resume (struct inf *inf)
-{
- struct proc *thread;
-
- inf_update_procs (inf);
-
- for (thread = inf->threads; thread; thread = thread->next)
- thread->sc = thread->resume_sc;
-
- if (inf->task)
- {
- if (! inf->pending_execs)
- /* Try to make sure our task count is correct -- in the case where
- we're waiting for an exec though, things are too volatile, so just
- assume things will be reasonable (which they usually will be). */
- inf_validate_task_sc (inf);
- inf->task->sc = 0;
- }
-
- inf_update_suspends (inf);
-}
-
-/* Cause INF to stop execution immediately; individual threads may still
- be running. */
-inline void
-inf_suspend (struct inf *inf)
-{
- struct proc *thread;
-
- inf_update_procs (inf);
-
- for (thread = inf->threads; thread; thread = thread->next)
- thread->sc = thread->pause_sc;
-
- if (inf->task)
- inf->task->sc = inf->pause_sc;
-
- inf_update_suspends (inf);
-}
-
-/* INF has one thread PROC that is in single-stepping mode. This function
- changes it to be PROC, changing any old step_thread to be a normal one. A
- PROC of 0 clears any existing value. */
-void
-inf_set_step_thread (struct inf *inf, struct proc *thread)
-{
- assert (!thread || proc_is_thread (thread));
-
- if (thread)
- inf_debug (inf, "setting step thread: %d/%d", inf->pid, thread->tid);
- else
- inf_debug (inf, "clearing step thread");
-
- if (inf->step_thread != thread)
- {
- if (inf->step_thread && inf->step_thread->port != MACH_PORT_NULL)
- if (! proc_trace (inf->step_thread, 0))
- return;
- if (thread && proc_trace (thread, 1))
- inf->step_thread = thread;
- else
- inf->step_thread = 0;
- }
-}
-
-/* Set up the thread resume_sc's so that only the signal thread is running
- (plus whatever other thread are set to always run). Returns true if we
- did so, or false if we can't find a signal thread. */
-inline int
-inf_set_threads_resume_sc_for_signal_thread (struct inf *inf)
-{
- if (inf->signal_thread)
- {
- inf_set_threads_resume_sc (inf, inf->signal_thread, 0);
- return 1;
- }
- else
- return 0;
-}
-
-static void
-inf_update_signal_thread (struct inf *inf)
-{
- /* XXX for now we assume that if there's a msgport, the 2nd thread is
- the signal thread. */
- inf->signal_thread = inf->threads ? inf->threads->next : 0;
-}
-
-/* Detachs from INF's inferior task, letting it run once again... */
-void
-inf_detach (struct inf *inf)
-{
- struct proc *task = inf->task;
-
- inf_debug (inf, "detaching...");
-
- inf_clear_wait (inf);
- inf_set_step_thread (inf, 0);
-
- if (task)
- {
- struct proc *thread;
-
- inf_set_traced (inf, 0);
- if (inf->stopped)
- inf_signal (inf, TARGET_SIGNAL_0);
-
- proc_restore_exc_port (task);
- task->sc = inf->detach_sc;
-
- for (thread = inf->threads; thread; thread = thread->next)
- {
- proc_restore_exc_port (thread);
- thread->sc = thread->detach_sc;
- }
-
- inf_update_suspends (inf);
- }
-
- inf_cleanup (inf);
-}
-
-/* Attaches INF to the process with process id PID, returning it in a suspended
- state suitable for debugging. */
-void
-inf_attach (struct inf *inf, int pid)
-{
- inf_debug (inf, "attaching: %d", pid);
-
- if (inf->pid)
- inf_detach (inf);
-
- inf_startup (inf, pid);
-}
-
-/* Makes sure that we've got our exception ports entrenched in the process. */
-void inf_steal_exc_ports (struct inf *inf)
-{
- struct proc *thread;
-
- inf_debug (inf, "stealing exception ports");
-
- inf_set_step_thread (inf, 0); /* The step thread is special. */
-
- proc_steal_exc_port (inf->task, inf->event_port);
- for (thread = inf->threads; thread; thread = thread->next)
- proc_steal_exc_port (thread, MACH_PORT_NULL);
-}
-
-/* Makes sure the process has its own exception ports. */
-void inf_restore_exc_ports (struct inf *inf)
-{
- struct proc *thread;
-
- inf_debug (inf, "restoring exception ports");
-
- inf_set_step_thread (inf, 0); /* The step thread is special. */
-
- proc_restore_exc_port (inf->task);
- for (thread = inf->threads; thread; thread = thread->next)
- proc_restore_exc_port (thread);
-}
-
-/* Deliver signal SIG to INF. If INF is stopped, delivering a signal, even
- signal 0, will continue it. INF is assumed to be in a paused state, and
- the resume_sc's of INF's threads may be affected. */
-void
-inf_signal (struct inf *inf, enum target_signal sig)
-{
- error_t err = 0;
- int host_sig = target_signal_to_host (sig);
-
-#define NAME target_signal_to_name (sig)
-
- if (host_sig >= _NSIG)
- /* A mach exception. Exceptions are encoded in the signal space by
- putting them after _NSIG; this assumes they're positive (and not
- extremely large)! */
- {
- struct inf_wait *w = &inf->wait;
- if (w->status.kind == TARGET_WAITKIND_STOPPED
- && w->status.value.sig == sig
- && w->thread && !w->thread->aborted)
- /* We're passing through the last exception we received. This is
- kind of bogus, because exceptions are per-thread whereas gdb
- treats signals as per-process. We just forward the exception to
- the correct handler, even it's not for the same thread as TID --
- i.e., we pretend it's global. */
- {
- struct exc_state *e = &w->exc;
- inf_debug (inf, "passing through exception:"
- " task = %d, thread = %d, exc = %d"
- ", code = %d, subcode = %d",
- w->thread->port, inf->task->port,
- e->exception, e->code, e->subcode);
- err =
- exception_raise_request (e->handler,
- e->reply, MACH_MSG_TYPE_MOVE_SEND_ONCE,
- w->thread->port, inf->task->port,
- e->exception, e->code, e->subcode);
- }
- else
- error ("Can't forward spontaneous exception (%s).", NAME);
- }
- else
- /* A Unix signal. */
- if (inf->stopped)
- /* The process is stopped and expecting a signal. Just send off a
- request and let it get handled when we resume everything. */
- {
- inf_debug (inf, "sending %s to stopped process", NAME);
- err =
- INF_MSGPORT_RPC (inf,
- msg_sig_post_untraced_request (msgport,
- inf->event_port,
- MACH_MSG_TYPE_MAKE_SEND_ONCE,
- host_sig, 0,
- refport));
- if (! err)
- /* Posting an untraced signal automatically continues it.
- We clear this here rather than when we get the reply
- because we'd rather assume it's not stopped when it
- actually is, than the reverse. */
- inf->stopped = 0;
- }
- else
- /* It's not expecting it. We have to let just the signal thread
- run, and wait for it to get into a reasonable state before we
- can continue the rest of the process. When we finally resume the
- process the signal we request will be the very first thing that
- happens. */
- {
- inf_debug (inf, "sending %s to unstopped process (so resuming signal thread)", NAME);
- err =
- INF_RESUME_MSGPORT_RPC (inf, msg_sig_post_untraced (msgport,
- host_sig, 0, refport));
- }
-
- if (err == EIEIO)
- /* Can't do too much... */
- warning ("Can't deliver signal %s: No signal thread.", NAME);
- else if (err)
- warning ("Delivering signal %s: %s", NAME, strerror (err));
-
-#undef NAME
-}
-
-/* The inferior used for all gdb target ops. */
-struct inf *current_inferior = 0;
-
-/* The inferior being waited for by gnu_wait. Since GDB is decidely not
- multi-threaded, we don't bother to lock this. */
-struct inf *waiting_inf;
-
-/* Wait for something to happen in the inferior, returning what in STATUS. */
-static int
-gnu_wait (int tid, struct target_waitstatus *status)
-{
- struct msg {
- mach_msg_header_t hdr;
- mach_msg_type_t type;
- int data[8000];
- } msg;
- error_t err;
- struct proc *thread;
- struct inf *inf = current_inferior;
-
- assert (inf->task);
-
- if (!inf->threads && !inf->pending_execs)
- /* No threads! Assume that maybe some outside agency is frobbing our
- task, and really look for new threads. If we can't find any, just tell
- the user to try again later. */
- {
- inf_validate_procs (inf);
- if (!inf->threads && !inf->task->dead)
- error ("There are no threads; try again later.");
- }
-
- waiting_inf = inf;
-
- inf_debug (inf, "waiting for: %d", tid);
-
- rewait:
- if (proc_wait_pid != inf->pid && !inf->no_wait)
- /* Always get information on events from the proc server. */
- {
- inf_debug (inf, "requesting wait on pid %d", inf->pid);
-
- if (proc_wait_pid)
- /* The proc server is single-threaded, and only allows a single
- outstanding wait request, so we have to cancel the previous one. */
- {
- inf_debug (inf, "cancelling previous wait on pid %d", proc_wait_pid);
- interrupt_operation (proc_server, 0);
- }
-
- err =
- proc_wait_request (proc_server, inf->event_port, inf->pid, WUNTRACED);
- if (err)
- warning ("wait request failed: %s", strerror (err));
- else
- {
- inf_debug (inf, "waits pending: %d", proc_waits_pending);
- proc_wait_pid = inf->pid;
- /* Even if proc_waits_pending was > 0 before, we still won't get
- any other replies, because it was either from a different INF,
- or a different process attached to INF -- and the event port,
- which is the wait reply port, changes when you switch processes.*/
- proc_waits_pending = 1;
- }
- }
-
- inf_clear_wait (inf);
-
- /* What can happen? (1) Dead name notification; (2) Exceptions arrive;
- (3) wait reply from the proc server. */
-
- inf_debug (inf, "waiting for an event...");
- err = mach_msg (&msg.hdr, MACH_RCV_MSG | MACH_RCV_INTERRUPT,
- 0, sizeof (struct msg), inf->event_port,
- MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
-
- /* Re-suspend the task. */
- inf_suspend (inf);
-
- if (!inf->task && inf->pending_execs)
- /* When doing an exec, it's possible that the old task wasn't reused
- (e.g., setuid execs). So if the task seems to have disappeared,
- attempt to refetch it, as the pid should still be the same. */
- inf_set_pid (inf, inf->pid);
-
- if (err == EMACH_RCV_INTERRUPTED)
- inf_debug (inf, "interrupted");
- else if (err)
- error ("Couldn't wait for an event: %s", strerror (err));
- else
- {
- struct {
- mach_msg_header_t hdr;
- mach_msg_type_t err_type;
- kern_return_t err;
- char noise[200];
- } reply;
-
- inf_debug (inf, "event: msgid = %d", msg.hdr.msgh_id);
-
- /* Handle what we got. */
- if (! notify_server (&msg.hdr, &reply.hdr)
- && ! exc_server (&msg.hdr, &reply.hdr)
- && ! process_reply_server (&msg.hdr, &reply.hdr)
- && ! msg_reply_server (&msg.hdr, &reply.hdr))
- /* Whatever it is, it's something strange. */
- error ("Got a strange event, msg id = %d.", msg.hdr.msgh_id);
-
- if (reply.err)
- error ("Handling event, msgid = %d: %s",
- msg.hdr.msgh_id, strerror (reply.err));
- }
-
- if (inf->pending_execs)
- /* We're waiting for the inferior to finish execing. */
- {
- struct inf_wait *w = &inf->wait;
- enum target_waitkind kind = w->status.kind;
-
- if (kind == TARGET_WAITKIND_SPURIOUS)
- /* Since gdb is actually counting the number of times the inferior
- stops, expecting one stop per exec, we only return major events
- while execing. */
- {
- w->suppress = 1;
- inf_debug (inf, "pending_execs = %d, ignoring minor event",
- inf->pending_execs);
- }
- else if (kind == TARGET_WAITKIND_STOPPED
- && w->status.value.sig == TARGET_SIGNAL_TRAP)
- /* Ah hah! A SIGTRAP from the inferior while starting up probably
- means we've succesfully completed an exec! */
- {
- if (--inf->pending_execs == 0)
- /* We're done! */
- {
-#if 0 /* do we need this? */
- prune_threads (1); /* Get rid of the old shell threads */
- renumber_threads (0); /* Give our threads reasonable names. */
-#endif
- }
- inf_debug (inf, "pending exec completed, pending_execs => %d",
- inf->pending_execs);
- }
- else if (kind == TARGET_WAITKIND_STOPPED)
- /* It's possible that this signal is because of a crashed process
- being handled by the hurd crash server; in this case, the process
- will have an extra task suspend, which we need to know about.
- Since the code in inf_resume that normally checks for this is
- disabled while INF->pending_execs, we do the check here instead. */
- inf_validate_task_sc (inf);
- }
-
- if (inf->wait.suppress)
- /* Some totally spurious event happened that we don't consider
- worth returning to gdb. Just keep waiting. */
- {
- inf_debug (inf, "suppressing return, rewaiting...");
- inf_resume (inf);
- goto rewait;
- }
-
- /* Pass back out our results. */
- bcopy (&inf->wait.status, status, sizeof (*status));
-
- thread = inf->wait.thread;
- if (thread)
- tid = thread->tid;
- else
- thread = inf_tid_to_thread (inf, tid);
-
- if (!thread || thread->port == MACH_PORT_NULL)
- /* TID is dead; try and find a new thread. */
- if (inf_update_procs (inf) && inf->threads)
- tid = inf->threads->tid; /* The first available thread. */
- else
- tid = inferior_pid; /* let wait_for_inferior handle exit case */
-
- if (thread && tid >= 0 && status->kind != TARGET_WAITKIND_SPURIOUS
- && inf->pause_sc == 0 && thread->pause_sc == 0)
- /* If something actually happened to THREAD, make sure we suspend it. */
- {
- thread->sc = 1;
- inf_update_suspends (inf);
- }
-
- inf_debug (inf, "returning tid = %d, status = %s (%d)", tid,
- status->kind == TARGET_WAITKIND_EXITED ? "EXITED"
- : status->kind == TARGET_WAITKIND_STOPPED ? "STOPPED"
- : status->kind == TARGET_WAITKIND_SIGNALLED ? "SIGNALLED"
- : status->kind == TARGET_WAITKIND_LOADED ? "LOADED"
- : status->kind == TARGET_WAITKIND_SPURIOUS ? "SPURIOUS"
- : "?",
- status->value.integer);
-
- return tid;
-}
-
-/* The rpc handler called by exc_server. */
-error_t
-S_exception_raise_request (mach_port_t port, mach_port_t reply_port,
- thread_t thread_port, task_t task_port,
- int exception, int code, int subcode)
-{
- struct inf *inf = waiting_inf;
- struct proc *thread = inf_port_to_thread (inf, thread_port);
-
- inf_debug (waiting_inf,
- "thread = %d, task = %d, exc = %d, code = %d, subcode = %d",
- thread_port, task_port, exception, code);
-
- if (!thread)
- /* We don't know about thread? */
- {
- inf_update_procs (inf);
- thread = inf_port_to_thread (inf, thread_port);
- if (!thread)
- /* Give up, the generating thread is gone. */
- return 0;
- }
-
- mach_port_deallocate (mach_task_self (), thread_port);
- mach_port_deallocate (mach_task_self (), task_port);
-
- if (! thread->aborted)
- /* THREAD hasn't been aborted since this exception happened (abortion
- clears any exception state), so it must be real. */
- {
- /* Store away the details; this will destroy any previous info. */
- inf->wait.thread = thread;
-
- inf->wait.status.kind = TARGET_WAITKIND_STOPPED;
-
- if (exception == EXC_BREAKPOINT)
- /* GDB likes to get SIGTRAP for breakpoints. */
- {
- inf->wait.status.value.sig = TARGET_SIGNAL_TRAP;
- mach_port_deallocate (mach_task_self (), reply_port);
- }
- else
- /* Record the exception so that we can forward it later. */
- {
- if (thread->exc_port == port)
- {
- inf_debug (waiting_inf, "Handler is thread exeption port <%d>",
- thread->saved_exc_port);
- inf->wait.exc.handler = thread->saved_exc_port;
- }
- else
- {
- inf_debug (waiting_inf, "Handler is task exeption port <%d>",
- inf->task->saved_exc_port);
- inf->wait.exc.handler = inf->task->saved_exc_port;
- assert (inf->task->exc_port == port);
- }
- if (inf->wait.exc.handler != MACH_PORT_NULL)
- /* Add a reference to the exception handler. */
- mach_port_mod_refs (mach_task_self (),
- inf->wait.exc.handler, MACH_PORT_RIGHT_SEND,
- 1);
-
- inf->wait.exc.exception = exception;
- inf->wait.exc.code = code;
- inf->wait.exc.subcode = subcode;
- inf->wait.exc.reply = reply_port;
-
- /* Exceptions are encoded in the signal space by putting them after
- _NSIG; this assumes they're positive (and not extremely large)! */
- inf->wait.status.value.sig =
- target_signal_from_host (_NSIG + exception);
- }
- }
- else
- /* A supppressed exception, which ignore. */
- {
- inf->wait.suppress = 1;
- mach_port_deallocate (mach_task_self (), reply_port);
- }
-
- return 0;
-}
-
-/* Fill in INF's wait field after a task has died without giving us more
- detailed information. */
-void
-inf_task_died_status (struct inf *inf)
-{
- warning ("Pid %d died with unknown exit status, using SIGKILL.", inf->pid);
- inf->wait.status.kind = TARGET_WAITKIND_SIGNALLED;
- inf->wait.status.value.sig = TARGET_SIGNAL_KILL;
-}
-
-/* Notify server routines. The only real one is dead name notification. */
-error_t
-do_mach_notify_dead_name (mach_port_t notify, mach_port_t dead_port)
-{
- struct inf *inf = waiting_inf;
-
- inf_debug (waiting_inf, "port = %d", dead_port);
-
- if (inf->task && inf->task->port == dead_port)
- {
- proc_debug (inf->task, "is dead");
- inf->task->port = MACH_PORT_NULL;
- if (proc_wait_pid == inf->pid)
- /* We have a wait outstanding on the process, which will return more
- detailed information, so delay until we get that. */
- inf->wait.suppress = 1;
- else
- /* We never waited for the process (maybe it wasn't a child), so just
- pretend it got a SIGKILL. */
- inf_task_died_status (inf);
- }
- else
- {
- struct proc *thread = inf_port_to_thread (inf, dead_port);
- if (thread)
- {
- proc_debug (thread, "is dead");
- thread->port = MACH_PORT_NULL;
- }
- }
-
- mach_port_deallocate (mach_task_self (), dead_port);
- inf->threads_up_to_date = 0; /* Just in case */
-
- return 0;
-}
-
-static error_t
-ill_rpc (char *fun)
-{
- warning ("illegal rpc: %s", fun);
- return 0;
-}
-
-error_t
-do_mach_notify_no_senders (mach_port_t notify, mach_port_mscount_t count)
-{
- return ill_rpc (__FUNCTION__);
-}
-
-error_t
-do_mach_notify_port_deleted (mach_port_t notify, mach_port_t name)
-{
- return ill_rpc (__FUNCTION__);
-}
-
-error_t
-do_mach_notify_msg_accepted (mach_port_t notify, mach_port_t name)
-{
- return ill_rpc (__FUNCTION__);
-}
-
-error_t
-do_mach_notify_port_destroyed (mach_port_t notify, mach_port_t name)
-{
- return ill_rpc (__FUNCTION__);
-}
-
-error_t
-do_mach_notify_send_once (mach_port_t notify)
-{
- return ill_rpc (__FUNCTION__);
-}
-
-/* Process_reply server routines. We only use process_wait_reply. */
-
-error_t
-S_proc_wait_reply (mach_port_t reply, error_t err,
- int status, int sigcode, rusage_t rusage, pid_t pid)
-{
- struct inf *inf = waiting_inf;
-
- inf_debug (inf, "err = %s, pid = %d, status = 0x%x, sigcode = %d",
- err ? strerror (err) : "0", pid, status, sigcode);
-
- if (err && proc_wait_pid && (!inf->task || !inf->task->port))
- /* Ack. The task has died, but the task-died notification code didn't
- tell anyone because it thought a more detailed reply from the
- procserver was forthcoming. However, we now learn that won't
- happen... So we have to act like the task just died, and this time,
- tell the world. */
- inf_task_died_status (inf);
-
- if (--proc_waits_pending == 0)
- /* PROC_WAIT_PID represents the most recent wait. We will always get
- replies in order because the proc server is single threaded. */
- proc_wait_pid = 0;
-
- inf_debug (inf, "waits pending now: %d", proc_waits_pending);
-
- if (err)
- {
- if (err != EINTR)
- {
- warning ("Can't wait for pid %d: %s", inf->pid, strerror (err));
- inf->no_wait = 1;
-
- /* Since we can't see the inferior's signals, don't trap them. */
- inf_set_traced (inf, 0);
- }
- }
- else if (pid == inf->pid)
- {
- store_waitstatus (&inf->wait.status, status);
- if (inf->wait.status.kind == TARGET_WAITKIND_STOPPED)
- /* The process has sent us a signal, and stopped itself in a sane
- state pending our actions. */
- {
- inf_debug (inf, "process has stopped itself");
- inf->stopped = 1;
- }
- }
- else
- inf->wait.suppress = 1; /* Something odd happened. Ignore. */
-
- return 0;
-}
-
-error_t
-S_proc_setmsgport_reply (mach_port_t reply, error_t err,
- mach_port_t old_msg_port)
-{
- return ill_rpc (__FUNCTION__);
-}
-
-error_t
-S_proc_getmsgport_reply (mach_port_t reply, error_t err, mach_port_t msg_port)
-{
- return ill_rpc (__FUNCTION__);
-}
-
-/* Msg_reply server routines. We only use msg_sig_post_untraced_reply. */
-
-error_t
-S_msg_sig_post_untraced_reply (mach_port_t reply, error_t err)
-{
- struct inf *inf = waiting_inf;
-
- if (err == EBUSY)
- /* EBUSY is what we get when the crash server has grabbed control of the
- process and doesn't like what signal we tried to send it. Just act
- like the process stopped (using a signal of 0 should mean that the
- *next* time the user continues, it will pass signal 0, which the crash
- server should like). */
- {
- inf->wait.status.kind = TARGET_WAITKIND_STOPPED;
- inf->wait.status.value.sig = TARGET_SIGNAL_0;
- }
- else if (err)
- warning ("Signal delivery failed: %s", strerror (err));
-
- if (err)
- /* We only get this reply when we've posted a signal to a process which we
- thought was stopped, and which we expected to continue after the signal.
- Given that the signal has failed for some reason, it's reasonable to
- assume it's still stopped. */
- inf->stopped = 1;
- else
- inf->wait.suppress = 1;
-
- return 0;
-}
-
-error_t
-S_msg_sig_post_reply (mach_port_t reply, error_t err)
-{
- return ill_rpc (__FUNCTION__);
-}
-
-/* Returns the number of messages queued for the receive right PORT. */
-static mach_port_msgcount_t
-port_msgs_queued (mach_port_t port)
-{
- struct mach_port_status status;
- error_t err =
- mach_port_get_receive_status (mach_task_self (), port, &status);
-
- if (err)
- return 0;
- else
- return status.mps_msgcount;
-}
-
-/* Resume execution of the inferior process.
-
- If STEP is nonzero, single-step it.
- If SIGNAL is nonzero, give it that signal.
-
- TID STEP:
- -1 true Single step the current thread allowing other threads to run.
- -1 false Continue the current thread allowing other threads to run.
- X true Single step the given thread, don't allow any others to run.
- X false Continue the given thread, do not allow any others to run.
- (Where X, of course, is anything except -1)
-
- Note that a resume may not `take' if there are pending exceptions/&c
- still unprocessed from the last resume we did (any given resume may result
- in multiple events returned by wait).
-*/
-static void
-gnu_resume (int tid, int step, enum target_signal sig)
-{
- struct proc *step_thread = 0;
- struct inf *inf = current_inferior;
-
- inf_debug (inf, "tid = %d, step = %d, sig = %d", tid, step, sig);
-
- if (sig != TARGET_SIGNAL_0 || inf->stopped)
- inf_signal (inf, sig);
- else if (inf->wait.exc.reply != MACH_PORT_NULL)
- /* We received an exception to which we have chosen not to forward, so
- abort the faulting thread, which will perhaps retake it. */
- {
- proc_abort (inf->wait.thread, 1);
- warning ("Aborting %s with unforwarded exception %s.",
- proc_string (inf->wait.thread),
- target_signal_to_name (inf->wait.status.value.sig));
- }
-
- if (port_msgs_queued (inf->event_port))
- /* If there are still messages in our event queue, don't bother resuming
- the process, as we're just going to stop it right away anyway. */
- return;
-
- inf_update_procs (inf);
-
- if (tid < 0)
- /* Allow all threads to run, except perhaps single-stepping one. */
- {
- inf_debug (inf, "running all threads; tid = %d", inferior_pid);
- tid = inferior_pid; /* What to step. */
- inf_set_threads_resume_sc (inf, 0, 1);
- }
- else
- /* Just allow a single thread to run. */
- {
- struct proc *thread = inf_tid_to_thread (inf, tid);
- if (! thread)
- error ("Can't run single thread id %d: no such thread!");
- inf_debug (inf, "running one thread: %d/%d", inf->pid, thread->tid);
- inf_set_threads_resume_sc (inf, thread, 0);
- }
-
- if (step)
- {
- step_thread = inf_tid_to_thread (inf, tid);
- if (! step_thread)
- warning ("Can't step thread id %d: no such thread.", tid);
- else
- inf_debug (inf, "stepping thread: %d/%d", inf->pid, step_thread->tid);
- }
- if (step_thread != inf->step_thread)
- inf_set_step_thread (inf, step_thread);
-
- inf_debug (inf, "here we go...");
- inf_resume (inf);
-}
-
-static void
-gnu_kill_inferior ()
-{
- struct proc *task = current_inferior->task;
- if (task)
- {
- proc_debug (task, "terminating...");
- task_terminate (task->port);
- inf_set_pid (current_inferior, -1);
- }
- target_mourn_inferior ();
-}
-
-/* Clean up after the inferior dies. */
-
-static void
-gnu_mourn_inferior ()
-{
- inf_debug (current_inferior, "rip");
- inf_detach (current_inferior);
- unpush_target (&gnu_ops);
- generic_mourn_inferior ();
-}
-
-/* Fork an inferior process, and start debugging it. */
-
-/* Set INFERIOR_PID to the first thread available in the child, if any. */
-static int
-inf_pick_first_thread ()
-{
- if (current_inferior->task && current_inferior->threads)
- /* The first thread. */
- return current_inferior->threads->tid;
- else
- /* What may be the next thread. */
- return next_thread_id;
-}
-
-static struct inf *
-cur_inf ()
-{
- if (! current_inferior)
- current_inferior = make_inf ();
- return current_inferior;
-}
-
-static void
-gnu_create_inferior (exec_file, allargs, env)
- char *exec_file;
- char *allargs;
- char **env;
-{
- struct inf *inf = cur_inf ();
-
- void trace_me ()
- {
- /* We're in the child; make this process stop as soon as it execs. */
- inf_debug (inf, "tracing self");
- if (ptrace (PTRACE_TRACEME) != 0)
- error ("ptrace (PTRACE_TRACEME) failed!");
- }
- int attach_to_child (int pid)
- {
- /* Attach to the now stopped child, which is actually a shell... */
- inf_debug (inf, "attaching to child: %d", pid);
-
- inf_attach (inf, pid);
-
- attach_flag = 0;
- push_target (&gnu_ops);
-
- inf->pending_execs = 2;
- inf->traced = 1;
-
- /* Now let the child run again, knowing that it will stop immediately
- because of the ptrace. */
- inf_resume (inf);
- inferior_pid = inf_pick_first_thread ();
-
- startup_inferior (inf->pending_execs);
-
- return inferior_pid;
- }
-
- inf_debug (inf, "creating inferior");
-
- fork_inferior (exec_file, allargs, env, trace_me, attach_to_child, NULL, NULL);
-
- inf_update_signal_thread (inf);
- inf_set_traced (inf, inf->want_signals);
-
- /* Execing the process will have trashed our exception ports; steal them
- back (or make sure they're restored if the user wants that). */
- if (inf->want_exceptions)
- inf_steal_exc_ports (inf);
- else
- inf_restore_exc_ports (inf);
-
- /* Here we go! */
- proceed ((CORE_ADDR) -1, 0, 0);
-}
-
-/* Mark our target-struct as eligible for stray "run" and "attach"
- commands. */
-static int
-gnu_can_run ()
-{
- return 1;
-}
-
-#ifdef ATTACH_DETACH
-
-/* Attach to process PID, then initialize for debugging it
- and wait for the trace-trap that results from attaching. */
-static void
-gnu_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- int pid;
- char *exec_file;
- struct inf *inf = cur_inf ();
-
- if (!args)
- error_no_arg ("PID to attach");
-
- pid = atoi (args);
-
- if (pid == getpid()) /* Trying to masturbate? */
- error ("I refuse to debug myself!");
-
- if (from_tty)
- {
- exec_file = (char *) get_exec_file (0);
-
- if (exec_file)
- printf_unfiltered ("Attaching to program `%s', pid %d\n",
- exec_file, pid);
- else
- printf_unfiltered ("Attaching to pid %d\n", pid);
-
- gdb_flush (gdb_stdout);
- }
-
- inf_debug (inf, "attaching to pid: %d", pid);
-
- inf_attach (inf, pid);
- inf_update_procs (inf);
-
- inferior_pid = inf_pick_first_thread ();
-
- attach_flag = 1;
- push_target (&gnu_ops);
-
- inf_update_signal_thread (inf);
- inf_set_traced (inf, inf->want_signals);
-
- /* If the process was stopped before we attached, make it continue the next
- time the user does a continue. */
- inf_validate_stopped (inf);
-
-#if 0 /* Do we need this? */
- renumber_threads (0); /* Give our threads reasonable names. */
-#endif
-}
-
-/* Take a program previously attached to and detaches it.
- The program resumes execution and will no longer stop
- on signals, etc. We'd 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 fork. */
-static void
-gnu_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- if (from_tty)
- {
- char *exec_file = get_exec_file (0);
- if (exec_file)
- printf_unfiltered ("Detaching from program `%s' pid %d\n",
- exec_file, current_inferior->pid);
- else
- printf_unfiltered ("Detaching from pid %d\n", current_inferior->pid);
- gdb_flush (gdb_stdout);
- }
-
- inf_detach (current_inferior);
-
- inferior_pid = 0;
-
- unpush_target (&gnu_ops); /* Pop out of handling an inferior */
-}
-#endif /* ATTACH_DETACH */
-
-static void
-gnu_terminal_init_inferior ()
-{
- assert (current_inferior);
- terminal_init_inferior_with_pgrp (current_inferior->pid);
-}
-
-/* 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
-gnu_prepare_to_store ()
-{
-#ifdef CHILD_PREPARE_TO_STORE
- CHILD_PREPARE_TO_STORE ();
-#endif
-}
-
-static void
-gnu_open (arg, from_tty)
- char *arg;
- int from_tty;
-{
- error ("Use the \"run\" command to start a Unix child process.");
-}
-
-static void
-gnu_stop ()
-{
- error ("to_stop target function not implemented");
-}
-
-static void
-gnu_pid_to_exec_file ()
-{
- error ("to_pid_to_exec_file target function not implemented");
-}
-
-
-static int
-gnu_thread_alive (int tid)
-{
- inf_update_procs (current_inferior);
- return !!inf_tid_to_thread (current_inferior, tid);
-}
-
-/*
- * Read inferior task's LEN bytes from ADDR and copy it to MYADDR
- * in gdb's address space.
- *
- * Return 0 on failure; number of bytes read otherwise.
- */
-int
-gnu_read_inferior (task, addr, myaddr, length)
- task_t task;
- CORE_ADDR addr;
- char *myaddr;
- int length;
-{
- error_t err;
- vm_address_t low_address = (vm_address_t) trunc_page (addr);
- vm_size_t aligned_length =
- (vm_size_t) round_page (addr+length) - low_address;
- pointer_t copied;
- int copy_count;
-
- /* Get memory from inferior with page aligned addresses */
- err = vm_read (task, low_address, aligned_length, &copied, &copy_count);
- if (err)
- return 0;
-
- err = hurd_safe_copyin (myaddr, (void*)addr - low_address + copied, length);
- if (err)
- {
- warning ("Read from inferior faulted: %s", strerror (err));
- length = 0;
- }
-
- err = vm_deallocate (mach_task_self (), copied, copy_count);
- if (err)
- warning ("gnu_read_inferior vm_deallocate failed: %s", strerror (err));
-
- return length;
-}
-
-#define CHK_GOTO_OUT(str,ret) \
- do if (ret != KERN_SUCCESS) { errstr = #str; goto out; } while(0)
-
-struct vm_region_list {
- struct vm_region_list *next;
- vm_prot_t protection;
- vm_address_t start;
- vm_size_t length;
-};
-
-struct obstack region_obstack;
-
-/*
- * Write gdb's LEN bytes from MYADDR and copy it to ADDR
- * in inferior task's address space.
- */
-int
-gnu_write_inferior (task, addr, myaddr, length)
- task_t task;
- CORE_ADDR addr;
- char *myaddr;
- int length;
-{
- error_t err = 0;
- vm_address_t low_address = (vm_address_t) trunc_page (addr);
- vm_size_t aligned_length =
- (vm_size_t) round_page (addr+length) - low_address;
- pointer_t copied;
- int copy_count;
- int deallocate = 0;
-
- char *errstr = "Bug in gnu_write_inferior";
-
- struct vm_region_list *region_element;
- struct vm_region_list *region_head = (struct vm_region_list *)NULL;
-
- /* Get memory from inferior with page aligned addresses */
- err = vm_read (task,
- low_address,
- aligned_length,
- &copied,
- &copy_count);
- CHK_GOTO_OUT ("gnu_write_inferior vm_read failed", err);
-
- deallocate++;
-
- err = hurd_safe_copyout ((void*)addr - low_address + copied, myaddr, length);
- CHK_GOTO_OUT ("Write to inferior faulted", err);
-
- obstack_init (&region_obstack);
-
- /* Do writes atomically.
- * First check for holes and unwritable memory.
- */
- {
- vm_size_t remaining_length = aligned_length;
- vm_address_t region_address = low_address;
-
- struct vm_region_list *scan;
-
- while(region_address < low_address + aligned_length)
- {
- vm_prot_t protection;
- vm_prot_t max_protection;
- vm_inherit_t inheritance;
- boolean_t shared;
- mach_port_t object_name;
- vm_offset_t offset;
- vm_size_t region_length = remaining_length;
- vm_address_t old_address = region_address;
-
- err = vm_region (task,
- &region_address,
- &region_length,
- &protection,
- &max_protection,
- &inheritance,
- &shared,
- &object_name,
- &offset);
- CHK_GOTO_OUT ("vm_region failed", err);
-
- /* Check for holes in memory */
- if (old_address != region_address)
- {
- warning ("No memory at 0x%x. Nothing written",
- old_address);
- err = KERN_SUCCESS;
- length = 0;
- goto out;
- }
-
- if (!(max_protection & VM_PROT_WRITE))
- {
- warning ("Memory at address 0x%x is unwritable. Nothing written",
- old_address);
- err = KERN_SUCCESS;
- length = 0;
- goto out;
- }
-
- /* Chain the regions for later use */
- region_element =
- (struct vm_region_list *)
- obstack_alloc (&region_obstack, sizeof (struct vm_region_list));
-
- region_element->protection = protection;
- region_element->start = region_address;
- region_element->length = region_length;
-
- /* Chain the regions along with protections */
- region_element->next = region_head;
- region_head = region_element;
-
- region_address += region_length;
- remaining_length = remaining_length - region_length;
- }
-
- /* If things fail after this, we give up.
- * Somebody is messing up inferior_task's mappings.
- */
-
- /* Enable writes to the chained vm regions */
- for (scan = region_head; scan; scan = scan->next)
- {
- boolean_t protection_changed = FALSE;
-
- if (!(scan->protection & VM_PROT_WRITE))
- {
- err = vm_protect (task,
- scan->start,
- scan->length,
- FALSE,
- scan->protection | VM_PROT_WRITE);
- CHK_GOTO_OUT ("vm_protect: enable write failed", err);
- }
- }
-
- err = vm_write (task,
- low_address,
- copied,
- aligned_length);
- CHK_GOTO_OUT ("vm_write failed", err);
-
- /* Set up the original region protections, if they were changed */
- for (scan = region_head; scan; scan = scan->next)
- {
- boolean_t protection_changed = FALSE;
-
- if (!(scan->protection & VM_PROT_WRITE))
- {
- err = vm_protect (task,
- scan->start,
- scan->length,
- FALSE,
- scan->protection);
- CHK_GOTO_OUT ("vm_protect: enable write failed", err);
- }
- }
- }
-
- out:
- if (deallocate)
- {
- obstack_free (&region_obstack, 0);
-
- (void) vm_deallocate (mach_task_self (),
- copied,
- copy_count);
- }
-
- if (err != KERN_SUCCESS)
- {
- warning ("%s: %s", errstr, mach_error_string (err));
- return 0;
- }
-
- return length;
-}
-
-/* Return 0 on failure, number of bytes handled otherwise. */
-static int
-gnu_xfer_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* IGNORED */
-{
- int result;
- task_t task =
- current_inferior
- ? (current_inferior->task ? current_inferior->task->port : 0)
- : 0;
-
- if (task == MACH_PORT_NULL)
- return 0;
- else
- {
- inf_debug (current_inferior, "%s %p[%d] %s %p",
- write ? "writing" : "reading", memaddr, len,
- write ? "<--" : "-->", myaddr);
- if (write)
- return gnu_write_inferior (task, memaddr, myaddr, len);
- else
- return gnu_read_inferior (task, memaddr, myaddr, len);
- }
-}
-
-extern void gnu_store_registers (int regno);
-extern void gnu_fetch_registers (int regno);
-
-struct target_ops gnu_ops ;
-
-static void
-init_gnu_ops(void)
-{
- gnu_ops.to_shortname = "GNU"; /* to_shortname */
- gnu_ops.to_longname = "GNU Hurd process"; /* to_longname */
- gnu_ops.to_doc = "GNU Hurd process"; /* to_doc */
- gnu_ops.to_open = gnu_open; /* to_open */
- gnu_ops.to_close = 0; /* to_close */
- gnu_ops.to_attach = gnu_attach; /* to_attach */
- gnu_ops.to_post_attach = NULL;
- gnu_ops.to_require_attach = NULL; /* to_require_attach */
- gnu_ops.to_detach = gnu_detach; /* to_detach */
- gnu_ops.to_require_detach = NULL; /* to_require_detach */
- gnu_ops.to_resume = gnu_resume; /* to_resume */
- gnu_ops.to_wait = gnu_wait; /* to_wait */
- gnu_ops.to_post_wait = NULL; /* to_post_wait */
- gnu_ops.to_fetch_registers = gnu_fetch_registers; /* to_fetch_registers */
- gnu_ops.to_store_registers = gnu_store_registers; /* to_store_registers */
- gnu_ops.to_prepare_to_store = gnu_prepare_to_store; /* to_prepare_to_store */
- gnu_ops.to_xfer_memory = gnu_xfer_memory; /* to_xfer_memory */
- gnu_ops.to_files_info = 0; /* to_files_info */
- gnu_ops.to_insert_breakpoint = memory_insert_breakpoint;
- gnu_ops.to_remove_breakpoint = memory_remove_breakpoint;
- gnu_ops.to_terminal_init = gnu_terminal_init_inferior;
- gnu_ops.to_terminal_inferior = terminal_inferior;
- gnu_ops.to_terminal_ours_for_output = terminal_ours_for_output;
- gnu_ops.to_terminal_ours = terminal_ours;
- gnu_ops.to_terminal_info = child_terminal_info;
- gnu_ops.to_kill = gnu_kill_inferior; /* to_kill */
- gnu_ops.to_load = 0; /* to_load */
- gnu_ops.to_lookup_symbol = 0; /* to_lookup_symbol */
- gnu_ops.to_create_inferior = gnu_create_inferior; /* to_create_inferior */
- gnu_ops.to_post_startup_inferior = NULL; /* to_post_startup_inferior */
- gnu_ops.to_acknowledge_created_inferior = NULL; /* to_acknowledge_created_inferior */
- gnu_ops.to_clone_and_follow_inferior = NULL; /* to_clone_and_follow_inferior */
- gnu_ops.to_post_follow_inferior_by_clone = NULL; /* to_post_follow_inferior_by_clone */
- gnu_ops.to_insert_fork_catchpoint = NULL;
- gnu_ops.to_remove_fork_catchpoint = NULL;
- gnu_ops.to_insert_vfork_catchpoint = NULL;
- gnu_ops.to_remove_vfork_catchpoint = NULL;
- gnu_ops.to_has_forked = NULL; /* to_has_forked */
- gnu_ops.to_has_vforked = NULL; /* to_has_vforked */
- gnu_ops.to_can_follow_vfork_prior_to_exec = NULL;
- gnu_ops.to_post_follow_vfork = NULL; /* to_post_follow_vfork */
- gnu_ops.to_insert_exec_catchpoint = NULL;
- gnu_ops.to_remove_exec_catchpoint = NULL;
- gnu_ops.to_has_execd = NULL;
- gnu_ops.to_reported_exec_events_per_exec_call = NULL;
- gnu_ops.to_has_exited = NULL;
- gnu_ops.to_mourn_inferior = gnu_mourn_inferior; /* to_mourn_inferior */
- gnu_ops.to_can_run = gnu_can_run; /* to_can_run */
- gnu_ops.to_notice_signals = 0; /* to_notice_signals */
- gnu_ops.to_thread_alive = gnu_thread_alive;/* to_thread_alive */
- gnu_ops.to_stop = gnu_stop; /* to_stop */
- gnu_ops.to_pid_to_exec_file = gnu_pid_to_exec_file; /* to_pid_to_exec_file */
- gnu_ops.to_core_file_to_sym_file = NULL;
- gnu_ops.to_stratum = process_stratum; /* to_stratum */
- gnu_ops.DONT_USE = 0; /* to_next */
- gnu_ops.to_has_all_memory = 1; /* to_has_all_memory */
- gnu_ops.to_has_memory = 1; /* to_has_memory */
- gnu_ops.to_has_stack = 1; /* to_has_stack */
- gnu_ops.to_has_registers = 1; /* to_has_registers */
- gnu_ops.to_has_execution = 1; /* to_has_execution */
- gnu_ops.to_sections = 0; /* sections */
- gnu_ops.to_sections_end = 0; /* sections_end */
- gnu_ops.to_magic = OPS_MAGIC ; /* to_magic */
-} /* init_gnu_ops */
-
-/* Return printable description of proc. */
-char *proc_string (struct proc *proc)
-{
- static char tid_str[80];
- if (proc_is_task (proc))
- sprintf (tid_str, "process %d", proc->inf->pid);
- else
- sprintf (tid_str, "thread %d.%d",
- proc->inf->pid, pid_to_thread_id (proc->tid));
- return tid_str;
-}
-
-char *
-gnu_target_pid_to_str (int tid)
-{
- struct inf *inf = current_inferior;
- struct proc *thread = inf_tid_to_thread (inf, tid);
-
- if (thread)
- return proc_string (thread);
- else
- {
- static char tid_str[80];
- sprintf (tid_str, "bogus thread id %d", tid);
- return tid_str;
- }
-}
-
-/* User task commands. */
-
-struct cmd_list_element *set_task_cmd_list = 0;
-struct cmd_list_element *show_task_cmd_list = 0;
-/* User thread commands. */
-
-/* Commands with a prefix of `set/show thread'. */
-extern struct cmd_list_element *thread_cmd_list;
-struct cmd_list_element *set_thread_cmd_list = NULL;
-struct cmd_list_element *show_thread_cmd_list = NULL;
-
-/* Commands with a prefix of `set/show thread default'. */
-struct cmd_list_element *set_thread_default_cmd_list = NULL;
-struct cmd_list_element *show_thread_default_cmd_list = NULL;
-
-static void
-set_thread_cmd (char *args, int from_tty)
-{
- printf_unfiltered ("\"set thread\" must be followed by the name of a thread
-property, or \"default\".\n");
-}
-
-static void
-show_thread_cmd (char *args, int from_tty)
-{
- printf_unfiltered ("\"show thread\" must be followed by the name of a thread property, or \"default\".\n");
-}
-
-static void
-set_thread_default_cmd (char *args, int from_tty)
-{
- printf_unfiltered ("\"set thread default\" must be followed by the name of a thread property.\n");
-}
-
-static void
-show_thread_default_cmd (char *args, int from_tty)
-{
- printf_unfiltered ("\"show thread default\" must be followed by the name of a thread property.\n");
-}
-
-static int
-parse_int_arg (char *args, char *cmd_prefix)
-{
- if (args)
- {
- char *arg_end;
- int val = strtoul (args, &arg_end, 10);
- if (*args && *arg_end == '\0')
- return val;
- }
- error ("Illegal argument for \"%s\" command, should be an integer.", cmd_prefix);
-}
-
-static int
-_parse_bool_arg (char *args, char *t_val, char *f_val, char *cmd_prefix)
-{
- if (!args || strcmp (args, t_val) == 0)
- return 1;
- else if (strcmp (args, f_val) == 0)
- return 0;
- else
- error ("Illegal argument for \"%s\" command, should be \"%s\" or \"%s\".",
- cmd_prefix, t_val, f_val);
-}
-
-#define parse_bool_arg(args, cmd_prefix) \
- _parse_bool_arg (args, "on", "off", cmd_prefix)
-
-static void
-check_empty (char *args, char *cmd_prefix)
-{
- if (args)
- error ("Garbage after \"%s\" command: `%s'", cmd_prefix, args);
-}
-
-/* Returns the alive thread named by INFERIOR_PID, or signals an error. */
-static struct proc *
-cur_thread ()
-{
- struct inf *inf = cur_inf ();
- struct proc *thread = inf_tid_to_thread (inf, inferior_pid);
- if (!thread)
- error ("No current thread.");
- return thread;
-}
-
-/* Returns the current inferior, but signals an error if it has no task. */
-static struct inf *
-active_inf ()
-{
- struct inf *inf = cur_inf ();
- if (! inf->task)
- error ("No current process.");
- return inf;
-}
-
-static void
-set_task_pause_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- int old_sc = inf->pause_sc;
-
- inf->pause_sc = parse_bool_arg (args, "set task pause");
-
- if (old_sc == 0 && inf->pause_sc != 0)
- /* If the task is currently unsuspended, immediately suspend it,
- otherwise wait until the next time it gets control. */
- inf_suspend (inf);
-}
-
-static void
-show_task_pause_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- check_empty (args, "show task pause");
- printf_unfiltered ("The inferior task %s suspended while gdb has control.\n",
- inf->task
- ? (inf->pause_sc == 0 ? "isn't" : "is")
- : (inf->pause_sc == 0 ? "won't be" : "will be"));
-}
-
-static void
-set_task_detach_sc_cmd (char *args, int from_tty)
-{
- cur_inf ()->detach_sc = parse_int_arg (args, "set task detach-suspend-count");
-}
-
-static void
-show_task_detach_sc_cmd (char *args, int from_tty)
-{
- check_empty (args, "show task detach-suspend-count");
- printf_unfiltered ("The inferior task will be left with a suspend count of %d when detaching.\n",
- cur_inf ()->detach_sc);
-}
-
-static void
-set_thread_default_pause_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- inf->default_thread_pause_sc =
- parse_bool_arg (args, "set thread default pause") ? 0 : 1;
-}
-
-static void
-show_thread_default_pause_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- int sc = inf->default_thread_pause_sc;
- check_empty (args, "show thread default pause");
- printf_unfiltered ("New threads %s suspended while gdb has control%s.\n",
- sc ? "are" : "aren't",
- !sc && inf->pause_sc ? " (but the task is)" : "");
-}
-
-static void
-set_thread_default_run_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- inf->default_thread_run_sc =
- parse_bool_arg (args, "set thread default run") ? 0 : 1;
-}
-
-static void
-show_thread_default_run_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- check_empty (args, "show thread default run");
- printf_unfiltered ("New threads %s allowed to run.\n",
- inf->default_thread_run_sc == 0 ? "are" : "aren't");
-}
-
-static void
-set_thread_default_detach_sc_cmd (char *args, int from_tty)
-{
- cur_inf ()->default_thread_detach_sc =
- parse_int_arg (args, "set thread default detach-suspend-count");
-}
-
-static void
-show_thread_default_detach_sc_cmd (char *args, int from_tty)
-{
- check_empty (args, "show thread default detach-suspend-count");
- printf_unfiltered ("New threads will get a detach-suspend-count of %d.\n",
- cur_inf ()->default_thread_detach_sc);
-}
-
-/* Steal a send right called NAME in the inferior task, and make it PROC's
- saved exception port. */
-static void
-steal_exc_port (struct proc *proc, mach_port_t name)
-{
- error_t err;
- mach_port_t port;
- mach_msg_type_name_t port_type;
-
- if (!proc || !proc->inf->task)
- error ("No inferior task.");
-
- err = mach_port_extract_right (proc->inf->task->port,
- name, MACH_MSG_TYPE_COPY_SEND,
- &port, &port_type);
- if (err)
- error ("Couldn't extract send right %d from inferior: %s",
- name, strerror (err));
-
- if (proc->saved_exc_port)
- /* Get rid of our reference to the old one. */
- mach_port_deallocate (mach_task_self (), proc->saved_exc_port);
-
- proc->saved_exc_port = port;
-
- if (! proc->exc_port)
- /* If PROC is a thread, we may not have set its exception port before.
- We can't use proc_steal_exc_port because it also sets saved_exc_port. */
- {
- proc->exc_port = proc->inf->event_port;
- err = proc_set_exception_port (proc, proc->exc_port);
- error ("Can't set exception port for %s: %s",
- proc_string (proc), strerror (err));
- }
-}
-
-static void
-set_task_exc_port_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- if (!args)
- error ("No argument to \"set task exception-port\" command.");
- steal_exc_port (inf->task, parse_and_eval_address (args));
-}
-
-static void
-set_stopped_cmd (char *args, int from_tty)
-{
- cur_inf ()->stopped = _parse_bool_arg (args, "yes", "no", "set stopped");
-}
-
-static void
-show_stopped_cmd (char *args, int from_tty)
-{
- struct inf *inf = active_inf ();
- check_empty (args, "show stopped");
- printf_unfiltered ("The inferior process %s stopped.\n",
- inf->stopped ? "is" : "isn't");
-}
-
-static void
-set_sig_thread_cmd (char *args, int from_tty)
-{
- int tid;
- struct inf *inf = cur_inf ();
-
- if (!args || (! isdigit (*args) && strcmp (args, "none") != 0))
- error ("Illegal argument to \"set signal-thread\" command.\n"
- "Should be an integer thread ID, or `none'.");
-
- if (strcmp (args, "none") == 0)
- inf->signal_thread = 0;
- else
- {
- int tid = thread_id_to_pid (atoi (args));
- if (tid < 0)
- error ("Thread ID %s not known. Use the \"info threads\" command to\n"
- "see the IDs of currently known threads.", args);
- inf->signal_thread = inf_tid_to_thread (inf, tid);
- }
-}
-
-static void
-show_sig_thread_cmd (char *args, int from_tty)
-{
- struct inf *inf = active_inf ();
- check_empty (args, "show signal-thread");
- if (inf->signal_thread)
- printf_unfiltered ("The signal thread is %s.\n",
- proc_string (inf->signal_thread));
- else
- printf_unfiltered ("There is no signal thread.\n");
-}
-
-static void
-set_signals_cmd (char *args, int from_tty)
-{
- int trace;
- struct inf *inf = cur_inf ();
-
- inf->want_signals = parse_bool_arg (args, "set signals");
-
- if (inf->task && inf->want_signals != inf->traced)
- /* Make this take effect immediately in a running process. */
- inf_set_traced (inf, inf->want_signals);
-}
-
-static void
-show_signals_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- check_empty (args, "show signals");
- printf_unfiltered ("The inferior process's signals %s intercepted.\n",
- inf->task
- ? (inf->traced ? "are" : "aren't")
- : (inf->want_signals ? "will be" : "won't be"));
-}
-
-static void
-set_exceptions_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- int val = parse_bool_arg (args, "set exceptions");
-
- if (inf->task && inf->want_exceptions != val)
- /* Make this take effect immediately in a running process. */
- /* XXX */;
-
- inf->want_exceptions = val;
-}
-
-static void
-show_exceptions_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
- check_empty (args, "show exceptions");
- printf_unfiltered ("Exceptions in the inferior %s trapped.\n",
- inf->task
- ? (inf->want_exceptions ? "are" : "aren't")
- : (inf->want_exceptions ? "will be" : "won't be"));
-}
-
-static void
-set_task_cmd (char *args, int from_tty)
-{
- printf_unfiltered ("\"set task\" must be followed by the name of a task property.\n");
-}
-
-static void
-show_task_cmd (char *args, int from_tty)
-{
- struct inf *inf = cur_inf ();
-
- check_empty (args, "show task");
-
- show_signals_cmd (0, from_tty);
- show_exceptions_cmd (0, from_tty);
- show_task_pause_cmd (0, from_tty);
-
- if (inf->pause_sc == 0)
- show_thread_default_pause_cmd (0, from_tty);
- show_thread_default_run_cmd (0, from_tty);
-
- if (inf->task)
- {
- show_stopped_cmd (0, from_tty);
- show_sig_thread_cmd (0, from_tty);
- }
-
- if (inf->detach_sc != 0)
- show_task_detach_sc_cmd (0, from_tty);
- if (inf->default_thread_detach_sc != 0)
- show_thread_default_detach_sc_cmd (0, from_tty);
-}
-
-static void
-set_noninvasive_cmd (char *args, int from_tty)
-{
- /* Invert the sense of the arg for each component. */
- char *inv_args = parse_bool_arg (args, "set noninvasive") ? "off" : "on";
-
- set_task_pause_cmd (inv_args, from_tty);
- set_signals_cmd (inv_args, from_tty);
- set_exceptions_cmd (inv_args, from_tty);
-}
-
-static void
-info_port_rights (char *args, mach_port_type_t only)
-{
- struct inf *inf = active_inf ();
- value_ptr vmark = value_mark ();
-
- if (args)
- /* Explicit list of port rights. */
- {
- while (*args)
- {
- value_ptr val = parse_to_comma_and_eval (&args);
- long right = value_as_long (val);
- error_t err =
- print_port_info (right, 0, inf->task->port, PORTINFO_DETAILS,
- stdout);
- if (err)
- error ("%ld: %s.", right, strerror (err));
- }
- }
- else
- /* Print all of them. */
- {
- error_t err =
- print_task_ports_info (inf->task->port, only, PORTINFO_DETAILS,
- stdout);
- if (err)
- error ("%s.", strerror (err));
- }
-
- value_free_to_mark (vmark);
-}
-
-static void
-info_send_rights_cmd (char *args, int from_tty)
-{
- info_port_rights (args, MACH_PORT_TYPE_SEND);
-}
-static void
-info_recv_rights_cmd (char *args, int from_tty)
-{
- info_port_rights (args, MACH_PORT_TYPE_RECEIVE);
-}
-static void
-info_port_sets_cmd (char *args, int from_tty)
-{
- info_port_rights (args, MACH_PORT_TYPE_PORT_SET);
-}
-static void
-info_dead_names_cmd (char *args, int from_tty)
-{
- info_port_rights (args, MACH_PORT_TYPE_DEAD_NAME);
-}
-static void
-info_port_rights_cmd (char *args, int from_tty)
-{
- info_port_rights (args, ~0);
-}
-
-static void add_task_commands ()
-{
- add_cmd ("pause", class_run, set_thread_default_pause_cmd,
- "Set whether the new threads are suspended while gdb has control.\n"
- "This property normally has no effect because the whole task is\n"
- "suspended, however, that may be disabled with \"set task pause off\".\n"
- "The default value is \"off\".",
- &set_thread_default_cmd_list);
- add_cmd ("pause", no_class, show_thread_default_pause_cmd,
- "Show whether new threads are suspended while gdb has control.",
- &show_thread_default_cmd_list);
- add_cmd ("run", class_run, set_thread_default_run_cmd,
- "Set whether new threads are allowed to run (once gdb has noticed them).",
- &set_thread_default_cmd_list);
- add_cmd ("run", no_class, show_thread_default_run_cmd,
- "Show whether new threads are allowed to run (once gdb has noticed
-them).",
- &show_thread_default_cmd_list);
- add_cmd ("detach-suspend-count", class_run, set_thread_default_detach_sc_cmd,
- "Set the default detach-suspend-count value for new threads.",
- &set_thread_default_cmd_list);
- add_cmd ("detach-suspend-count", no_class, show_thread_default_detach_sc_cmd,
- "Show the default detach-suspend-count value for new threads.",
- &show_thread_default_cmd_list);
-
- add_cmd ("signals", class_run, set_signals_cmd,
- "Set whether the inferior process's signals will be intercepted.\n"
- "Mach exceptions (such as breakpoint traps) are not affected.",
- &setlist);
- add_alias_cmd ("sigs", "signals", class_run, 1, &setlist);
- add_cmd ("signals", no_class, show_signals_cmd,
- "Show whether the inferior process's signals will be intercepted.",
- &showlist);
- add_alias_cmd ("sigs", "signals", no_class, 1, &showlist);
-
- add_cmd ("signal-thread", class_run, set_sig_thread_cmd,
- "Set the thread that gdb thinks is the libc signal thread.\n"
- "This thread is run when delivering a signal to a non-stopped process.",
- &setlist);
- add_alias_cmd ("sigthread", "signal-thread", class_run, 1, &setlist);
- add_cmd ("signal-thread", no_class, show_sig_thread_cmd,
- "Set the thread that gdb thinks is the libc signal thread.",
- &showlist);
- add_alias_cmd ("sigthread", "signal-thread", no_class, 1, &showlist);
-
- add_cmd ("stopped", class_run, set_stopped_cmd,
- "Set whether gdb thinks the inferior process is stopped as with SIGSTOP.\n"
- "Stopped process will be continued by sending them a signal.",
- &setlist);
- add_cmd ("stopped", no_class, show_signals_cmd,
- "Show whether gdb thinks the inferior process is stopped as with SIGSTOP.",
- &showlist);
-
- add_cmd ("exceptions", class_run, set_exceptions_cmd,
- "Set whether exceptions in the inferior process will be trapped.\n"
- "When exceptions are turned off, neither breakpoints nor single-stepping\n"
- "will work.",
- &setlist);
- /* Allow `set exc' despite conflict with `set exception-port'. */
- add_alias_cmd ("exc", "exceptions", class_run, 1, &setlist);
- add_cmd ("exceptions", no_class, show_exceptions_cmd,
- "Show whether exceptions in the inferior process will be trapped.",
- &showlist);
-
- add_prefix_cmd ("task", no_class, set_task_cmd,
- "Command prefix for setting task attributes.",
- &set_task_cmd_list, "set task ", 0, &setlist);
- add_prefix_cmd ("task", no_class, show_task_cmd,
- "Command prefix for showing task attributes.",
- &show_task_cmd_list, "show task ", 0, &showlist);
-
- add_cmd ("pause", class_run, set_task_pause_cmd,
- "Set whether the task is suspended while gdb has control.\n"
- "A value of \"on\" takes effect immediately, otherwise nothing\n"
- "happens until the next time the program is continued.\n"
- "When setting this to \"off\", \"set thread default pause on\"\n"
- "can be used to pause individual threads by default instead.",
- &set_task_cmd_list);
- add_cmd ("pause", no_class, show_task_pause_cmd,
- "Show whether the task is suspended while gdb has control.",
- &show_task_cmd_list);
- add_cmd ("detach-suspend-count", class_run, set_task_detach_sc_cmd,
- "Set the suspend count will leave on the thread when detaching.",
- &set_task_cmd_list);
- add_cmd ("detach-suspend-count", no_class, show_task_detach_sc_cmd,
- "Show the suspend count will leave on the thread when detaching.",
- &show_task_cmd_list);
-
- add_cmd ("exception-port", no_class, set_task_exc_port_cmd,
- "Set the task exception port to which we forward exceptions.\n"
- "The argument should be the value of the send right in the task.",
- &set_task_cmd_list);
- add_alias_cmd ("excp", "exception-port", no_class, 1, &set_task_cmd_list);
- add_alias_cmd ("exc-port", "exception-port", no_class, 1, &set_task_cmd_list);
-
- /* A convenient way of turning on all options require to noninvasively
- debug running tasks. */
- add_cmd ("noninvasive", no_class, set_noninvasive_cmd,
- "Set task options so that we interfere as little as possible.\n"
- "This is the same as setting `task pause', `exceptions', and"
- "`signals' to the opposite value.",
- &setlist);
-
- /* Commands to show information about the task's ports. */
- add_cmd ("send-rights", class_info, info_send_rights_cmd,
- "Show information about the task's send rights",
- &infolist);
- add_cmd ("receive-rights", class_info, info_recv_rights_cmd,
- "Show information about the task's receive rights",
- &infolist);
- add_cmd ("port-rights", class_info, info_send_rights_cmd,
- "Show information about the task's port rights",
- &infolist);
- add_cmd ("port-sets", class_info, info_port_sets_cmd,
- "Show information about the task's port sets",
- &infolist);
- add_cmd ("dead-names", class_info, info_dead_names_cmd,
- "Show information about the task's dead names",
- &infolist);
- add_info_alias ("ports", "port-rights", 1);
- add_info_alias ("port", "port-rights", 1);
- add_info_alias ("psets", "port-sets", 1);
-}
-
-
-static void
-set_thread_pause_cmd (char *args, int from_tty)
-{
- struct proc *thread = cur_thread ();
- int old_sc = thread->pause_sc;
- thread->pause_sc = parse_bool_arg (args, "set thread pause");
- if (old_sc == 0 && thread->pause_sc != 0 && thread->inf->pause_sc == 0)
- /* If the task is currently unsuspended, immediately suspend it,
- otherwise wait until the next time it gets control. */
- inf_suspend (thread->inf);
-}
-
-static void
-show_thread_pause_cmd (char *args, int from_tty)
-{
- struct proc *thread = cur_thread ();
- int sc = thread->pause_sc;
- check_empty (args, "show task pause");
- printf_unfiltered ("Thread %s %s suspended while gdb has control%s.\n",
- proc_string (thread),
- sc ? "is" : "isn't",
- !sc && thread->inf->pause_sc ? " (but the task is)" : "");
-}
-
-static void
-set_thread_run_cmd (char *args, int from_tty)
-{
- struct proc *thread = cur_thread ();
- thread->run_sc = parse_bool_arg (args, "set thread run") ? 0 : 1;
-}
-
-static void
-show_thread_run_cmd (char *args, int from_tty)
-{
- struct proc *thread = cur_thread ();
- check_empty (args, "show thread run");
- printf_unfiltered ("Thread %s %s allowed to run.",
- proc_string (thread),
- thread->run_sc == 0 ? "is" : "isn't");
-}
-
-static void
-set_thread_detach_sc_cmd (char *args, int from_tty)
-{
- cur_thread ()->detach_sc = parse_int_arg (args, "set thread detach-suspend-count");
-}
-
-static void
-show_thread_detach_sc_cmd (char *args, int from_tty)
-{
- struct proc *thread = cur_thread ();
- check_empty (args, "show thread detach-suspend-count");
- printf_unfiltered ("Thread %s will be left with a suspend count of %d when detaching.\n",
- proc_string (thread),
- thread->detach_sc);
-}
-
-static void
-set_thread_exc_port_cmd (char *args, int from_tty)
-{
- struct proc *thread = cur_thread ();
- if (!args)
- error ("No argument to \"set thread exception-port\" command.");
- steal_exc_port (thread, parse_and_eval_address (args));
-}
-
-#if 0
-static void
-show_thread_cmd (char *args, int from_tty)
-{
- struct proc *thread = cur_thread ();
- check_empty (args, "show thread");
- show_thread_run_cmd (0, from_tty);
- show_thread_pause_cmd (0, from_tty);
- if (thread->detach_sc != 0)
- show_thread_detach_sc_cmd (0, from_tty);
-}
-#endif
-
-static void
-thread_takeover_sc_cmd (char *args, int from_tty)
-{
- struct proc *thread = cur_thread ();
- thread_basic_info_data_t _info;
- thread_basic_info_t info = &_info;
- mach_msg_type_number_t info_len = THREAD_BASIC_INFO_COUNT;
- error_t err =
- thread_info (thread->port, THREAD_BASIC_INFO, (int *)&info, &info_len);
- if (err)
- error ("%s.", strerror (err));
- thread->sc = info->suspend_count;
- if (from_tty)
- printf_unfiltered ("Suspend count was %d.\n", thread->sc);
- if (info != &_info)
- vm_deallocate (mach_task_self (), (vm_address_t)info, info_len * sizeof (int));
-}
-
-add_thread_commands ()
-{
- add_prefix_cmd ("thread", no_class, set_thread_cmd,
- "Command prefix for setting thread properties.",
- &set_thread_cmd_list, "set thread ", 0, &setlist);
- add_prefix_cmd ("default", no_class, show_thread_cmd,
- "Command prefix for setting default thread properties.",
- &set_thread_default_cmd_list, "set thread default ", 0,
- &set_thread_cmd_list);
- add_prefix_cmd ("thread", no_class, set_thread_default_cmd,
- "Command prefix for showing thread properties.",
- &show_thread_cmd_list, "show thread ", 0, &showlist);
- add_prefix_cmd ("default", no_class, show_thread_default_cmd,
- "Command prefix for showing default thread properties.",
- &show_thread_default_cmd_list, "show thread default ", 0,
- &show_thread_cmd_list);
-
- add_cmd ("pause", class_run, set_thread_pause_cmd,
- "Set whether the current thread is suspended while gdb has control.\n"
- "A value of \"on\" takes effect immediately, otherwise nothing\n"
- "happens until the next time the program is continued. This\n"
- "property normally has no effect because the whole task is suspended,\n"
- "however, that may be disabled with \"set task pause off\".\n"
- "The default value is \"off\".",
- &set_thread_cmd_list);
- add_cmd ("pause", no_class, show_thread_pause_cmd,
- "Show whether the current thread is suspended while gdb has control.",
- &show_thread_cmd_list);
-
- add_cmd ("run", class_run, set_thread_run_cmd,
- "Set whether the current thread is allowed to run.",
- &set_thread_cmd_list);
- add_cmd ("run", no_class, show_thread_run_cmd,
- "Show whether the current thread is allowed to run.",
- &show_thread_cmd_list);
-
- add_cmd ("detach-suspend-count", class_run, set_thread_detach_sc_cmd,
- "Set the suspend count will leave on the thread when detaching.\n"
- "Note that this is relative to suspend count when gdb noticed the thread;\n"
- "use the `thread takeover-suspend-count' to force it to an absolute value.",
- &set_thread_cmd_list);
- add_cmd ("detach-suspend-count", no_class, show_thread_detach_sc_cmd,
- "Show the suspend count will leave on the thread when detaching."
- "Note that this is relative to suspend count when gdb noticed the thread;\n"
- "use the `thread takeover-suspend-count' to force it to an absolute value.",
- &show_thread_cmd_list);
-
- add_cmd ("exception-port", no_class, set_thread_exc_port_cmd,
- "Set the exception port to which we forward exceptions for the\n"
- "current thread, overriding the task exception port.\n"
- "The argument should be the value of the send right in the task.",
- &set_thread_cmd_list);
- add_alias_cmd ("excp", "exception-port", no_class, 1, &set_thread_cmd_list);
- add_alias_cmd ("exc-port", "exception-port", no_class, 1, &set_thread_cmd_list);
-
- add_cmd ("takeover-suspend-count", no_class, thread_takeover_sc_cmd,
- "Force the threads absolute suspend-count to be gdb's.\n"
- "Prior to giving this command, gdb's thread suspend-counts are relative to\n"
- "the thread's initial suspend-count when gdb notices the threads.",
- &thread_cmd_list);
-}
-
-void
-_initialize_gnu_nat ()
-{
- proc_server = getproc ();
- init_gnu_ops() ;
- add_target (&gnu_ops);
- add_task_commands ();
- add_thread_commands ();
-
-#if MAINTENANCE_CMDS
- add_set_cmd ("gnu-debug", class_maintenance,
- var_boolean, (char *)&gnu_debug_flag,
- "Set debugging output for the gnu backend.", &maintenancelist);
-#endif
-}
-
-#ifdef FLUSH_INFERIOR_CACHE
-
-/* When over-writing code on some machines the I-Cache must be flushed
- explicitly, because it is not kept coherent by the lazy hardware.
- This definitely includes breakpoints, for instance, or else we
- end up looping in mysterious Bpt traps */
-
-void
-flush_inferior_icache(pc, amount)
- CORE_ADDR pc;
-{
- vm_machine_attribute_val_t flush = MATTR_VAL_ICACHE_FLUSH;
- error_t ret;
-
- ret = vm_machine_attribute (current_inferior->task->port,
- pc,
- amount,
- MATTR_CACHE,
- &flush);
- if (ret != KERN_SUCCESS)
- warning ("Error flushing inferior's cache : %s", strerror (ret));
-}
-#endif FLUSH_INFERIOR_CACHE
diff --git a/contrib/gdb/gdb/gnu-nat.h b/contrib/gdb/gdb/gnu-nat.h
deleted file mode 100644
index d238dc0..0000000
--- a/contrib/gdb/gdb/gnu-nat.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Common things used by the various *gnu-nat.c files
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-
-Written by Miles Bader <miles@gnu.ai.mit.edu>
-
-The GNU Hurd is free software; you can redistribute 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 GNU Hurd is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef __GNU_NAT_H__
-#define __GNU_NAT_H__
-
-#include <unistd.h>
-#include <mach.h>
-
-struct inf;
-
-extern struct inf *current_inferior;
-
-/* Converts a GDB pid to a struct proc. */
-struct proc *inf_tid_to_thread (struct inf *inf, int tid);
-
-/* A proc is either a thread, or the task (there can only be one task proc
- because it always has the same TID, PROC_TID_TASK). */
-struct proc
-{
- thread_t port; /* The task or thread port. */
- int tid; /* The GDB pid (actually a thread id). */
- int num; /* An id number for threads, to print. */
-
- mach_port_t saved_exc_port; /* The task/thread's real exception port. */
- mach_port_t exc_port; /* Our replacement, which for. */
-
- int sc; /* Desired suspend count. */
- int cur_sc; /* Implemented suspend count. */
- int run_sc; /* Default sc when the program is running. */
- int pause_sc; /* Default sc when gdb has control. */
- int resume_sc; /* Sc resulting from the last resume. */
- int detach_sc; /* SC to leave around when detaching
- from program. */
-
- thread_state_data_t state; /* Registers, &c. */
- int state_valid : 1; /* True if STATE is up to date. */
- int state_changed : 1;
-
- int aborted : 1; /* True if thread_abort has been called. */
- int dead : 1; /* We happen to know it's actually dead. */
-
- /* Bit mask of registers fetched by gdb. This is used when we re-fetch
- STATE after aborting the thread, to detect that gdb may have out-of-date
- information. */
- unsigned long fetched_regs;
-
- struct inf *inf; /* Where we come from. */
-
- struct proc *next;
-};
-
-/* The task has a thread entry with this TID. */
-#define PROC_TID_TASK (-1)
-
-#define proc_is_task(proc) ((proc)->tid == PROC_TID_TASK)
-#define proc_is_thread(proc) ((proc)->tid != PROC_TID_TASK)
-
-extern int __proc_pid (struct proc *proc);
-
-extern thread_state_t proc_get_state (struct proc *proc, int will_modify);
-
-#define proc_debug(_proc, msg, args...) \
- do { struct proc *__proc = (_proc); \
- debug ("{proc %d/%d %p}: " msg, \
- __proc_pid (__proc), __proc->tid, __proc , ##args); } while (0)
-
-#if MAINTENANCE_CMDS
-extern int gnu_debug_flag;
-#define debug(msg, args...) \
- do { if (gnu_debug_flag) \
- fprintf (stderr, "%s: " msg "\r\n", __FUNCTION__ , ##args); } while (0)
-#else
-#define debug(msg, args...) (void)0
-#endif
-
-#endif /* __GNU_NAT_H__ */
diff --git a/contrib/gdb/gdb/go32-xdep.c b/contrib/gdb/gdb/go32-xdep.c
deleted file mode 100644
index 01c817a..0000000
--- a/contrib/gdb/gdb/go32-xdep.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Host-dependent code for dos running GO32 for GDB, the GNU debugger.
- Copyright 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-
-int
-sigsetmask (mask)
- int mask;
-{
- return 0;
-}
-
-void
-strlwr (str)
- char *str;
-{
- for (; *str; str++)
- *str = tolower(*str);
-}
diff --git a/contrib/gdb/gdb/i386-stub.c b/contrib/gdb/gdb/i386-stub.c
deleted file mode 100644
index 768f00c..0000000
--- a/contrib/gdb/gdb/i386-stub.c
+++ /dev/null
@@ -1,927 +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: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
- *
- * Module name: remcom.c $
- * Revision: 1.34 $
- * Date: 91/03/09 12:29:49 $
- * 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 $
- *
- * Modified for 386 by Jim Kingdon, Cygnus Support.
- *
- * 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.
- *
- * The external function exceptionHandler() is
- * used to attach a specific handler to a specific 386 vector number.
- * It should use the same privilege level it runs at. It should
- * install it as an interrupt gate so that interrupts are masked
- * while the handler runs.
- * Also, need to assign exceptionHook and oldExceptionHook.
- *
- * 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
- *
- * $<packet info>#<checksum>.
- *
- * where
- * <packet info> :: <characters representing the command or response>
- * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>>
- *
- * 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 <stdio.h>
-#include <string.h>
-
-/************************************************************************
- *
- * external low-level support routines
- */
-typedef void (*ExceptionHook)(int); /* pointer to function with int parm */
-typedef void (*Function)(); /* pointer to a function */
-
-extern void putDebugChar(); /* write a single character */
-extern int 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;
-/* debug > 0 prints ill-formed commands in valid packets & checksum errors */
-
-void waitabit();
-
-static const char hexchars[]="0123456789abcdef";
-
-/* Number of registers. */
-#define NUMREGS 16
-
-/* Number of bytes of registers. */
-#define NUMREGBYTES (NUMREGS * 4)
-
-enum regnames {EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI,
- PC /* also known as eip */,
- PS /* also known as eflags */,
- CS, SS, DS, ES, FS, GS};
-
-/*
- * these should not be static cuz they can be used outside this module
- */
-int registers[NUMREGS];
-
-#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;
-
-/*************************** ASSEMBLY CODE MACROS *************************/
-/* */
-
-extern void
-return_to_prog ();
-
-/* Restore the program's registers (including the stack pointer, which
- means we get the right stack and don't have to worry about popping our
- return address and any stack frames and so on) and return. */
-asm(".text");
-asm(".globl _return_to_prog");
-asm("_return_to_prog:");
-asm(" movw _registers+44, %ss");
-asm(" movl _registers+16, %esp");
-asm(" movl _registers+4, %ecx");
-asm(" movl _registers+8, %edx");
-asm(" movl _registers+12, %ebx");
-asm(" movl _registers+20, %ebp");
-asm(" movl _registers+24, %esi");
-asm(" movl _registers+28, %edi");
-asm(" movw _registers+48, %ds");
-asm(" movw _registers+52, %es");
-asm(" movw _registers+56, %fs");
-asm(" movw _registers+60, %gs");
-asm(" movl _registers+36, %eax");
-asm(" pushl %eax"); /* saved eflags */
-asm(" movl _registers+40, %eax");
-asm(" pushl %eax"); /* saved cs */
-asm(" movl _registers+32, %eax");
-asm(" pushl %eax"); /* saved eip */
-asm(" movl _registers, %eax");
-/* use iret to restore pc and flags together so
- that trace flag works right. */
-asm(" iret");
-
-#define BREAKPOINT() asm(" int $3");
-
-/* Put the error code here just in case the user cares. */
-int gdb_i386errcode;
-/* Likewise, the vector number here (since GDB only gets the signal
- number through the usual means, and that's not very specific). */
-int gdb_i386vector = -1;
-
-/* GDB stores segment registers in 32-bit words (that's just the way
- m-i386v.h is written). So zero the appropriate areas in registers. */
-#define SAVE_REGISTERS1() \
- asm ("movl %eax, _registers"); \
- asm ("movl %ecx, _registers+4"); \
- asm ("movl %edx, _registers+8"); \
- asm ("movl %ebx, _registers+12"); \
- asm ("movl %ebp, _registers+20"); \
- asm ("movl %esi, _registers+24"); \
- asm ("movl %edi, _registers+28"); \
- asm ("movw $0, %ax"); \
- asm ("movw %ds, _registers+48"); \
- asm ("movw %ax, _registers+50"); \
- asm ("movw %es, _registers+52"); \
- asm ("movw %ax, _registers+54"); \
- asm ("movw %fs, _registers+56"); \
- asm ("movw %ax, _registers+58"); \
- asm ("movw %gs, _registers+60"); \
- asm ("movw %ax, _registers+62");
-#define SAVE_ERRCODE() \
- asm ("popl %ebx"); \
- asm ("movl %ebx, _gdb_i386errcode");
-#define SAVE_REGISTERS2() \
- asm ("popl %ebx"); /* old eip */ \
- asm ("movl %ebx, _registers+32"); \
- asm ("popl %ebx"); /* old cs */ \
- asm ("movl %ebx, _registers+40"); \
- asm ("movw %ax, _registers+42"); \
- asm ("popl %ebx"); /* old eflags */ \
- asm ("movl %ebx, _registers+36"); \
- /* Now that we've done the pops, we can save the stack pointer."); */ \
- asm ("movw %ss, _registers+44"); \
- asm ("movw %ax, _registers+46"); \
- asm ("movl %esp, _registers+16");
-
-/* See if mem_fault_routine is set, if so just IRET to that address. */
-#define CHECK_FAULT() \
- asm ("cmpl $0, _mem_fault_routine"); \
- asm ("jne mem_fault");
-
-asm (".text");
-asm ("mem_fault:");
-/* OK to clobber temp registers; we're just going to end up in set_mem_err. */
-/* Pop error code from the stack and save it. */
-asm (" popl %eax");
-asm (" movl %eax, _gdb_i386errcode");
-
-asm (" popl %eax"); /* eip */
-/* We don't want to return there, we want to return to the function
- pointed to by mem_fault_routine instead. */
-asm (" movl _mem_fault_routine, %eax");
-asm (" popl %ecx"); /* cs (low 16 bits; junk in hi 16 bits). */
-asm (" popl %edx"); /* eflags */
-
-/* Remove this stack frame; when we do the iret, we will be going to
- the start of a function, so we want the stack to look just like it
- would after a "call" instruction. */
-asm (" leave");
-
-/* Push the stuff that iret wants. */
-asm (" pushl %edx"); /* eflags */
-asm (" pushl %ecx"); /* cs */
-asm (" pushl %eax"); /* eip */
-
-/* Zero mem_fault_routine. */
-asm (" movl $0, %eax");
-asm (" movl %eax, _mem_fault_routine");
-
-asm ("iret");
-
-#define CALL_HOOK() asm("call _remcomHandler");
-
-/* This function is called when a i386 exception occurs. It saves
- * all the cpu regs in the _registers array, munges the stack a bit,
- * and invokes an exception handler (remcom_handler).
- *
- * stack on entry: stack on exit:
- * old eflags vector number
- * old cs (zero-filled to 32 bits)
- * old eip
- *
- */
-extern void _catchException3();
-asm(".text");
-asm(".globl __catchException3");
-asm("__catchException3:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $3");
-CALL_HOOK();
-
-/* Same thing for exception 1. */
-extern void _catchException1();
-asm(".text");
-asm(".globl __catchException1");
-asm("__catchException1:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $1");
-CALL_HOOK();
-
-/* Same thing for exception 0. */
-extern void _catchException0();
-asm(".text");
-asm(".globl __catchException0");
-asm("__catchException0:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $0");
-CALL_HOOK();
-
-/* Same thing for exception 4. */
-extern void _catchException4();
-asm(".text");
-asm(".globl __catchException4");
-asm("__catchException4:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $4");
-CALL_HOOK();
-
-/* Same thing for exception 5. */
-extern void _catchException5();
-asm(".text");
-asm(".globl __catchException5");
-asm("__catchException5:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $5");
-CALL_HOOK();
-
-/* Same thing for exception 6. */
-extern void _catchException6();
-asm(".text");
-asm(".globl __catchException6");
-asm("__catchException6:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $6");
-CALL_HOOK();
-
-/* Same thing for exception 7. */
-extern void _catchException7();
-asm(".text");
-asm(".globl __catchException7");
-asm("__catchException7:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $7");
-CALL_HOOK();
-
-/* Same thing for exception 8. */
-extern void _catchException8();
-asm(".text");
-asm(".globl __catchException8");
-asm("__catchException8:");
-SAVE_REGISTERS1();
-SAVE_ERRCODE();
-SAVE_REGISTERS2();
-asm ("pushl $8");
-CALL_HOOK();
-
-/* Same thing for exception 9. */
-extern void _catchException9();
-asm(".text");
-asm(".globl __catchException9");
-asm("__catchException9:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $9");
-CALL_HOOK();
-
-/* Same thing for exception 10. */
-extern void _catchException10();
-asm(".text");
-asm(".globl __catchException10");
-asm("__catchException10:");
-SAVE_REGISTERS1();
-SAVE_ERRCODE();
-SAVE_REGISTERS2();
-asm ("pushl $10");
-CALL_HOOK();
-
-/* Same thing for exception 12. */
-extern void _catchException12();
-asm(".text");
-asm(".globl __catchException12");
-asm("__catchException12:");
-SAVE_REGISTERS1();
-SAVE_ERRCODE();
-SAVE_REGISTERS2();
-asm ("pushl $12");
-CALL_HOOK();
-
-/* Same thing for exception 16. */
-extern void _catchException16();
-asm(".text");
-asm(".globl __catchException16");
-asm("__catchException16:");
-SAVE_REGISTERS1();
-SAVE_REGISTERS2();
-asm ("pushl $16");
-CALL_HOOK();
-
-/* For 13, 11, and 14 we have to deal with the CHECK_FAULT stuff. */
-
-/* Same thing for exception 13. */
-extern void _catchException13 ();
-asm (".text");
-asm (".globl __catchException13");
-asm ("__catchException13:");
-CHECK_FAULT();
-SAVE_REGISTERS1();
-SAVE_ERRCODE();
-SAVE_REGISTERS2();
-asm ("pushl $13");
-CALL_HOOK();
-
-/* Same thing for exception 11. */
-extern void _catchException11 ();
-asm (".text");
-asm (".globl __catchException11");
-asm ("__catchException11:");
-CHECK_FAULT();
-SAVE_REGISTERS1();
-SAVE_ERRCODE();
-SAVE_REGISTERS2();
-asm ("pushl $11");
-CALL_HOOK();
-
-/* Same thing for exception 14. */
-extern void _catchException14 ();
-asm (".text");
-asm (".globl __catchException14");
-asm ("__catchException14:");
-CHECK_FAULT();
-SAVE_REGISTERS1();
-SAVE_ERRCODE();
-SAVE_REGISTERS2();
-asm ("pushl $14");
-CALL_HOOK();
-
-/*
- * remcomHandler is a front end for handle_exception. It moves the
- * stack pointer into an area reserved for debugger use.
- */
-asm("_remcomHandler:");
-asm(" popl %eax"); /* pop off return address */
-asm(" popl %eax"); /* get the exception number */
-asm(" movl _stackPtr, %esp"); /* move to remcom stack area */
-asm(" pushl %eax"); /* push exception onto stack */
-asm(" call _handle_exception"); /* this never returns */
-
-void _returnFromException()
-{
- return_to_prog ();
-}
-
-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 $<data>#<checksum> */
-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() & 0x7f)) != '$');
- checksum = 0;
- xmitcsum = -1;
-
- count = 0;
-
- /* now, read until a # or end of buffer is found */
- while (count < BUFMAX) {
- ch = getDebugChar() & 0x7f;
- if (ch == '#') break;
- checksum = checksum + ch;
- buffer[count] = ch;
- count = count + 1;
- }
- buffer[count] = 0;
-
- if (ch == '#') {
- xmitcsum = hex(getDebugChar() & 0x7f) << 4;
- xmitcsum += hex(getDebugChar() & 0x7f);
- 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. */
-
-
-void putpacket(buffer)
-char * buffer;
-{
- unsigned char checksum;
- int count;
- char ch;
-
- /* $<packet info>#<checksum>. */
- do {
- putDebugChar('$');
- checksum = 0;
- count = 0;
-
- while (ch=buffer[count]) {
- putDebugChar(ch);
- checksum += ch;
- count += 1;
- }
-
- putDebugChar('#');
- putDebugChar(hexchars[checksum >> 4]);
- putDebugChar(hexchars[checksum % 16]);
-
- } while ((getDebugChar() & 0x7f) != '+');
-
-}
-
-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);
-}
-
-/* Address of a routine to RTE to if we get a memory fault. */
-static void (*volatile mem_fault_routine)() = NULL;
-
-/* Indicate to caller of mem2hex or hex2mem that there has been an
- error. */
-static volatile int mem_err = 0;
-
-void
-set_mem_err ()
-{
- mem_err = 1;
-}
-
-/* These are separate functions so that they are so short and sweet
- that the compiler won't save any registers (if there is a fault
- to mem_fault, they won't get restored, so there better not be any
- saved). */
-int
-get_char (addr)
- char *addr;
-{
- return *addr;
-}
-
-void
-set_char (addr, val)
- char *addr;
- int val;
-{
- *addr = val;
-}
-
-/* convert the memory pointed to by mem into hex, placing result in buf */
-/* return a pointer to the last char put in buf (null) */
-/* If MAY_FAULT is non-zero, then we should set mem_err in response to
- a fault; if zero treat a fault like any other fault in the stub. */
-char* mem2hex(mem, buf, count, may_fault)
-char* mem;
-char* buf;
-int count;
-int may_fault;
-{
- int i;
- unsigned char ch;
-
- if (may_fault)
- mem_fault_routine = set_mem_err;
- for (i=0;i<count;i++) {
- ch = get_char (mem++);
- if (may_fault && mem_err)
- return (buf);
- *buf++ = hexchars[ch >> 4];
- *buf++ = hexchars[ch % 16];
- }
- *buf = 0;
- if (may_fault)
- mem_fault_routine = NULL;
- 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, may_fault)
-char* buf;
-char* mem;
-int count;
-int may_fault;
-{
- int i;
- unsigned char ch;
-
- if (may_fault)
- mem_fault_routine = set_mem_err;
- for (i=0;i<count;i++) {
- ch = hex(*buf++) << 4;
- ch = ch + hex(*buf++);
- set_char (mem++, ch);
- if (may_fault && mem_err)
- return (mem);
- }
- if (may_fault)
- mem_fault_routine = NULL;
- return(mem);
-}
-
-/* this function takes the 386 exception vector and attempts to
- translate this number into a unix compatible signal value */
-int computeSignal( exceptionVector )
-int exceptionVector;
-{
- int sigval;
- switch (exceptionVector) {
- case 0 : sigval = 8; break; /* divide by zero */
- case 1 : sigval = 5; break; /* debug exception */
- case 3 : sigval = 5; break; /* breakpoint */
- case 4 : sigval = 16; break; /* into instruction (overflow) */
- case 5 : sigval = 16; break; /* bound instruction */
- case 6 : sigval = 4; break; /* Invalid opcode */
- case 7 : sigval = 8; break; /* coprocessor not available */
- case 8 : sigval = 7; break; /* double fault */
- case 9 : sigval = 11; break; /* coprocessor segment overrun */
- case 10 : sigval = 11; break; /* Invalid TSS */
- case 11 : sigval = 11; break; /* Segment not present */
- case 12 : sigval = 11; break; /* stack exception */
- case 13 : sigval = 11; break; /* general protection */
- case 14 : sigval = 11; break; /* page fault */
- case 16 : sigval = 7; break; /* coprocessor error */
- default:
- sigval = 7; /* "software generated"*/
- }
- return (sigval);
-}
-
-/**********************************************/
-/* WHILE WE FIND NICE HEX CHARS, BUILD AN INT */
-/* RETURN NUMBER OF CHARS PROCESSED */
-/**********************************************/
-int hexToInt(char **ptr, int *intValue)
-{
- int numChars = 0;
- int hexValue;
-
- *intValue = 0;
-
- while (**ptr)
- {
- hexValue = hex(**ptr);
- if (hexValue >=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;
-
- gdb_i386vector = exceptionVector;
-
- 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, 0);
- break;
- case 'G' : /* set the value of the CPU registers - return OK */
- hex2mem(&remcomInBuffer[1], (char*) registers, NUMREGBYTES, 0);
- strcpy(remcomOutBuffer,"OK");
- break;
- case 'P' : /* set the value of a single CPU register - return OK */
- {
- int regno;
-
- ptr = &remcomInBuffer[1];
- if (hexToInt (&ptr, &regno) && *ptr++ == '=')
- if (regno >= 0 && regno < NUMREGS)
- {
- hex2mem (ptr, (char *)&registers[regno], 4, 0);
- strcpy(remcomOutBuffer,"OK");
- break;
- }
-
- strcpy (remcomOutBuffer, "E01");
- break;
- }
-
- /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
- case 'm' :
- /* 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;
- mem_err = 0;
- mem2hex((char*) addr, remcomOutBuffer, length, 1);
- if (mem_err) {
- strcpy (remcomOutBuffer, "E03");
- debug_error ("memory fault");
- }
- }
-
- if (ptr)
- {
- strcpy(remcomOutBuffer,"E01");
- debug_error("malformed read memory command: %s",remcomInBuffer);
- }
- break;
-
- /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
- case 'M' :
- /* 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++) == ':')
- {
- mem_err = 0;
- hex2mem(ptr, (char*) addr, length, 1);
-
- if (mem_err) {
- strcpy (remcomOutBuffer, "E03");
- debug_error ("memory fault");
- } else {
- strcpy(remcomOutBuffer,"OK");
- }
-
- ptr = 0;
- }
- if (ptr)
- {
- strcpy(remcomOutBuffer,"E02");
- debug_error("malformed write memory command: %s",remcomInBuffer);
- }
- 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 ] &= 0xfffffeff;
-
- /* set the trace bit if we're stepping */
- if (remcomInBuffer[0] == 's') registers[ PS ] |= 0x100;
-
- /*
- * 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 0
- /* Don't really think we need this, except maybe for protection
- exceptions. */
- /*
- * invoke the previous handler.
- */
- if (oldExceptionHook)
- (*oldExceptionHook) (frame->exceptionVector);
- newPC = registers[ PC ]; /* pc may have changed */
-#endif /* 0 */
-
- _returnFromException(); /* this is a jump */
-
- break;
-
- /* kill the program */
- case 'k' : /* do nothing */
-#if 0
- /* Huh? This doesn't look like "nothing".
- m68k-stub.c and sparc-stub.c don't have it. */
- BREAKPOINT();
-#endif
- break;
- } /* switch */
-
- /* reply to the request */
- putpacket(remcomOutBuffer);
- }
-}
-
-/* this function is used to set up exception handlers for tracing and
- breakpoints */
-void set_debug_traps()
-{
-extern void remcomHandler();
-int exception;
-
- stackPtr = &remcomStack[STACKSIZE/sizeof(int) - 1];
-
- exceptionHandler (0, _catchException0);
- exceptionHandler (1, _catchException1);
- exceptionHandler (3, _catchException3);
- exceptionHandler (4, _catchException4);
- exceptionHandler (5, _catchException5);
- exceptionHandler (6, _catchException6);
- exceptionHandler (7, _catchException7);
- exceptionHandler (8, _catchException8);
- exceptionHandler (9, _catchException9);
- exceptionHandler (10, _catchException10);
- exceptionHandler (11, _catchException11);
- exceptionHandler (12, _catchException12);
- exceptionHandler (13, _catchException13);
- exceptionHandler (14, _catchException14);
- exceptionHandler (16, _catchException16);
-
- if (exceptionHook != remcomHandler)
- {
- oldExceptionHook = exceptionHook;
- exceptionHook = remcomHandler;
- }
-
- /* In case GDB is started before us, ack any packets (presumably
- "$?#xx") sitting there. */
- putDebugChar ('+');
-
- 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)
-#if 0
- handle_exception(3);
-#else
- BREAKPOINT();
-#endif
- waitabit();
-}
-
-int waitlimit = 1000000;
-
-void
-waitabit()
-{
- int i;
- for (i = 0; i < waitlimit; i++) ;
-}
diff --git a/contrib/gdb/gdb/i386aix-nat.c b/contrib/gdb/gdb/i386aix-nat.c
deleted file mode 100644
index 20e656e..0000000
--- a/contrib/gdb/gdb/i386aix-nat.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/* Intel 386 native support.
- Copyright (C) 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "language.h"
-#include "gdbcore.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/user.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-#include <stddef.h>
-#include <sys/ptrace.h>
-
-/* Does AIX define this in <errno.h>? */
-extern int errno;
-
-#ifdef HAVE_SYS_REG_H
-#include <sys/reg.h>
-#endif
-
-#include "floatformat.h"
-
-#include "target.h"
-
-static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
-
-
-/* this table must line up with REGISTER_NAMES in tm-i386v.h */
-/* symbols like 'EAX' come from <sys/reg.h> */
-static int regmap[] =
-{
- EAX, ECX, EDX, EBX,
- USP, 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
- */
-
-int
-i386_register_u_addr (blockend, regnum)
- int blockend;
- int 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]);
-
-}
-
-/* The code below only work on the aix ps/2 (i386-ibm-aix) -
- * mtranle@paris - Sat Apr 11 10:34:12 1992
- */
-
-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_unfiltered ("u: ");
- print_387_status_word (status);
- }
-
- if (ep->status != 0)
- {
- if (bothstatus)
- printf_unfiltered ("e: ");
- print_387_status_word (ep->status);
- }
-
- print_387_control_word (ep->control);
- printf_unfiltered ("last exception: ");
- printf_unfiltered ("opcode %s; ", local_hex_string(ep->opcode));
- printf_unfiltered ("pc %s:", local_hex_string(ep->code_seg));
- printf_unfiltered ("%s; ", local_hex_string(ep->eip));
- printf_unfiltered ("operand %s", local_hex_string(ep->operand_seg));
- printf_unfiltered (":%s\n", local_hex_string(ep->operand));
-
- top = ((ep->status >> 11) & 7);
-
- printf_unfiltered ("regno tag msb lsb value\n");
- for (fpreg = 7; fpreg >= 0; fpreg--)
- {
- double val;
-
- printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
-
- switch ((ep->tag >> ((7 - fpreg) * 2)) & 3)
- {
- case 0: printf_unfiltered ("valid "); break;
- case 1: printf_unfiltered ("zero "); break;
- case 2: printf_unfiltered ("trap "); break;
- case 3: printf_unfiltered ("empty "); break;
- }
- for (i = 9; i >= 0; i--)
- printf_unfiltered ("%02x", ep->regs[fpreg][i]);
-
- i387_to_double ((char *)ep->regs[fpreg], (char *)&val);
- printf_unfiltered (" %#g\n", val);
- }
-}
-
-static struct env387 core_env387;
-
-void
-i386_float_info ()
-{
- struct env387 fps;
- int fpsaved = 0;
- /* We need to reverse the order of the registers. Apparently AIX stores
- the highest-numbered ones first. */
- struct env387 fps_fixed;
- int i;
-
- if (inferior_pid)
- {
- char buf[10];
- unsigned short status;
-
- ptrace (PT_READ_FPR, inferior_pid, buf, offsetof(struct env387, status));
- memcpy (&status, buf, sizeof (status));
- fpsaved = status;
- }
- else
- {
- if ((fpsaved = core_env387.status) != 0)
- memcpy(&fps, &core_env387, sizeof(fps));
- }
-
- if (fpsaved == 0)
- {
- printf_unfiltered ("no floating point status saved\n");
- return;
- }
-
- if (inferior_pid)
- {
- int offset;
- for (offset = 0; offset < sizeof(fps); offset += 10)
- {
- char buf[10];
- ptrace (PT_READ_FPR, inferior_pid, buf, offset);
- memcpy ((char *)&fps.control + offset, buf,
- MIN(10, sizeof(fps) - offset));
- }
- }
- fps_fixed = fps;
- for (i = 0; i < 8; ++i)
- memcpy (fps_fixed.regs[i], fps.regs[7 - i], 10);
- print_387_status (0, &fps_fixed);
-}
-
-/* Fetch one register. */
-static void
-fetch_register (regno)
- int regno;
-{
- char buf[MAX_REGISTER_RAW_SIZE];
- if (regno < FP0_REGNUM)
- *(int *)buf = ptrace (PT_READ_GPR, inferior_pid,
- PT_REG(regmap[regno]), 0, 0);
- else
- ptrace (PT_READ_FPR, inferior_pid, buf,
- (regno - FP0_REGNUM)*10 + offsetof(struct env387, regs));
- supply_register (regno, buf);
-}
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- if (regno < 0)
- for (regno = 0; regno < NUM_REGS; regno++)
- fetch_register (regno);
- else
- fetch_register (regno);
-}
-
-/* store one register */
-static void
-store_register (regno)
- int regno;
-{
- char buf[80];
- extern char registers[];
- errno = 0;
- if (regno < FP0_REGNUM)
- ptrace (PT_WRITE_GPR, inferior_pid, PT_REG(regmap[regno]),
- *(int *) &registers[REGISTER_BYTE (regno)], 0);
- else
- ptrace (PT_WRITE_FPR, inferior_pid, &registers[REGISTER_BYTE (regno)],
- (regno - FP0_REGNUM)*10 + offsetof(struct env387, regs));
-
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (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;
-{
- if (regno < 0)
- for (regno = 0; regno < NUM_REGS; regno++)
- store_register (regno);
- else
- store_register (regno);
-}
-
-#ifndef CD_AX /* defined in sys/i386/coredump.h */
-# define CD_AX 0
-# define CD_BX 1
-# define CD_CX 2
-# define CD_DX 3
-# define CD_SI 4
-# define CD_DI 5
-# define CD_BP 6
-# define CD_SP 7
-# define CD_FL 8
-# define CD_IP 9
-# define CD_CS 10
-# define CD_DS 11
-# define CD_ES 12
-# define CD_FS 13
-# define CD_GS 14
-# define CD_SS 15
-#endif
-
-/*
- * The order here in core_regmap[] has to be the same as in
- * regmap[] above.
- */
-static int core_regmap[] =
-{
- CD_AX, CD_CX, CD_DX, CD_BX,
- CD_SP, CD_BP, CD_SI, CD_DI,
- CD_IP, CD_FL, CD_CS, CD_SS,
- CD_DS, CD_ES, CD_FS, CD_GS,
-};
-
-static void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr; /* ignored */
-{
-
- if (which == 0)
- {
- /* Integer registers */
-
-#define cd_regs(n) ((int *)core_reg_sect)[n]
-#define regs(n) *((int *) &registers[REGISTER_BYTE (n)])
-
- int i;
- for (i = 0; i < FP0_REGNUM; i++)
- regs(i) = cd_regs(core_regmap[i]);
- }
- else if (which == 2)
- {
- /* Floating point registers */
-
- if (core_reg_size >= sizeof (core_env387))
- memcpy (&core_env387, core_reg_sect, core_reg_size);
- else
- fprintf_unfiltered (gdb_stderr, "Couldn't read float regs from core file\n");
- }
-}
-
-
-/* Register that we are able to handle i386aix core file formats.
- FIXME: is this really bfd_target_unknown_flavour? */
-
-static struct core_fns i386aix_core_fns =
-{
- bfd_target_unknown_flavour,
- fetch_core_registers,
- NULL
-};
-
-void
-_initialize_core_i386aix ()
-{
- add_core_fns (&i386aix_core_fns);
-}
diff --git a/contrib/gdb/gdb/i386b-nat.c b/contrib/gdb/gdb/i386b-nat.c
index e784773..2645302 100644
--- a/contrib/gdb/gdb/i386b-nat.c
+++ b/contrib/gdb/gdb/i386b-nat.c
@@ -57,7 +57,7 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, ignore)
char *core_reg_sect;
unsigned core_reg_size;
int which;
- CORE_ADDR ignore;
+ unsigned int ignore;
{
struct md_core *core_reg = (struct md_core *)core_reg_sect;
@@ -72,13 +72,32 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, ignore)
#include <machine/reg.h>
+/* Some systems don't provide all the registers on a trap. Use SS as a
+ default if so. */
+
+#ifndef tDS
+#define tDS tSS
+#endif
+#ifndef tES
+#define tES tSS
+#endif
+#ifndef tFS
+#define tFS tSS
+#endif
+#ifndef tGS
+#define tGS tSS
+#endif
+
+/* These tables map between the registers on a trap frame, and the register
+ order used by the rest of GDB. */
/* this table must line up with REGISTER_NAMES in tm-i386.h */
/* symbols like 'tEAX' come from <machine/reg.h> */
static int tregmap[] =
{
tEAX, tECX, tEDX, tEBX,
tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS
+ tEIP, tEFLAGS, tCS, tSS,
+ tDS, tES, tFS, tGS
};
#ifdef sEAX
@@ -97,7 +116,8 @@ static int sregmap[] =
{
tEAX, tECX, tEDX, tEBX,
tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS
+ tEIP, tEFLAGS, tCS, tSS,
+ tDS, tES, tFS, tGS
};
#endif /* No sEAX */
@@ -130,7 +150,6 @@ i386_register_u_addr (blockend, regnum)
#include "floatformat.h"
#include <sys/param.h>
-#include <sys/dir.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <fcntl.h>
@@ -153,6 +172,37 @@ extern void print_387_status_word ();
#define fpstate save87
#define U_FPSTATE(u) u.u_pcb.pcb_savefpu
+static void
+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 */
+}
+
struct env387
{
unsigned short control;
@@ -196,7 +246,7 @@ print_387_status (status, ep)
}
print_387_control_word ((unsigned int)ep->control);
- printf_unfiltered ("last exception: ");
+ printf_unfiltered ("last instruction: ");
printf_unfiltered ("opcode %s; ", local_hex_string(ep->opcode));
printf_unfiltered ("pc %s:", local_hex_string(ep->code_seg));
printf_unfiltered ("%s; ", local_hex_string(ep->eip));
@@ -205,12 +255,18 @@ print_387_status (status, ep)
top = (ep->status >> 11) & 7;
- printf_unfiltered ("regno tag msb lsb value\n");
+ printf_unfiltered (" regno tag msb lsb value\n");
for (fpreg = 7; fpreg >= 0; fpreg--)
{
+ int st_regno;
double val;
- printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
+ /* The physical regno `fpreg' is only relevant as an index into the
+ * tag word. Logical `%st' numbers are required for indexing ep->regs.
+ */
+ st_regno = (fpreg + 8 - top) & 7;
+
+ printf_unfiltered ("%%st(%d) %s ", st_regno, fpreg == top ? "=>" : " ");
switch ((ep->tag >> (fpreg * 2)) & 3)
{
@@ -220,14 +276,14 @@ print_387_status (status, ep)
case 3: printf_unfiltered ("empty "); break;
}
for (i = 9; i >= 0; i--)
- printf_unfiltered ("%02x", ep->regs[fpreg][i]);
+ printf_unfiltered ("%02x", ep->regs[st_regno][i]);
- floatformat_to_double(&floatformat_i387_ext, (char *) ep->regs[fpreg],
- &val);
+ i387_to_double((char *) ep->regs[st_regno], (char *) &val);
printf_unfiltered (" %g\n", val);
}
}
+void
i386_float_info ()
{
struct user u; /* just for address computations */
@@ -272,9 +328,15 @@ i386_float_info ()
skip = 0;
#endif
}
-
+
+#ifdef __FreeBSD__
+ fpstatep = (struct fpstate *)(buf + skip);
+ print_387_status (fpstatep->sv_ex_sw, (struct env387 *)fpstatep);
+#else
print_387_status (0, (struct env387 *)buf);
+#endif
}
+#endif /* FLOAT_INFO */
int
kernel_u_size ()
@@ -282,4 +344,16 @@ kernel_u_size ()
return (sizeof (struct user));
}
-#endif
+#ifdef SETUP_ARBITRARY_FRAME
+#include "frame.h"
+struct frame_info *
+setup_arbitrary_frame (argc, argv)
+ int argc;
+ CORE_ADDR *argv;
+{
+ if (argc != 2)
+ error ("i386 frame specifications require two arguments: sp and pc");
+
+ return create_new_frame (argv[0], argv[1]);
+}
+#endif /* SETUP_ARBITRARY_FRAME */
diff --git a/contrib/gdb/gdb/i386gnu-nat.c b/contrib/gdb/gdb/i386gnu-nat.c
deleted file mode 100644
index 6ed92c1..0000000
--- a/contrib/gdb/gdb/i386gnu-nat.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/* Low level interface to I386 running the GNU Hurd
- Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "floatformat.h"
-
-#include <stdio.h>
-#include <errno.h>
-
-#include <mach.h>
-#include <mach/message.h>
-#include <mach/exception.h>
-#include <mach_error.h>
-
-#include "gnu-nat.h"
-
-/* Hmmm... Should this not be here?
- * Now for i386_float_info() target_has_execution
- */
-#include <target.h>
-
-/* @@@ Should move print_387_status() to i387-tdep.c */
-extern void print_387_control_word (); /* i387-tdep.h */
-extern void print_387_status_word ();
-
-/* Find offsets to thread states at compile time.
- * If your compiler does not grok this, calculate offsets
- * offsets yourself and use them (or get a compatible compiler :-)
- */
-
-#define REG_OFFSET(reg) (int)(&((struct i386_thread_state *)0)->reg)
-
-/* at reg_offset[i] is the offset to the i386_thread_state
- * location where the gdb registers[i] is stored.
- */
-
-static int reg_offset[] =
-{
- REG_OFFSET(eax), REG_OFFSET(ecx), REG_OFFSET(edx), REG_OFFSET(ebx),
- REG_OFFSET(uesp), REG_OFFSET(ebp), REG_OFFSET(esi), REG_OFFSET(edi),
- REG_OFFSET(eip), REG_OFFSET(efl), REG_OFFSET(cs), REG_OFFSET(ss),
- REG_OFFSET(ds), REG_OFFSET(es), REG_OFFSET(fs), REG_OFFSET(gs)
-};
-
-#define REG_ADDR(state,regnum) ((char *)(state)+reg_offset[regnum])
-
-/* Fetch COUNT contiguous registers from thread STATE starting from REGNUM
- * Caller knows that the regs handled in one transaction are of same size.
- */
-#define FETCH_REGS(state, regnum, count) \
- memcpy (&registers[REGISTER_BYTE (regnum)], \
- REG_ADDR (state, regnum), \
- count * REGISTER_RAW_SIZE (regnum))
-
-/* Store COUNT contiguous registers to thread STATE starting from REGNUM */
-#define STORE_REGS(state, regnum, count) \
- memcpy (REG_ADDR (state, regnum), \
- &registers[REGISTER_BYTE (regnum)], \
- count * REGISTER_RAW_SIZE (regnum))
-
-/*
- * Fetch inferiors registers for gdb.
- * REG specifies which (as gdb views it) register, -1 for all.
- */
-void
-gnu_fetch_registers (int reg)
-{
- struct proc *thread;
- thread_state_t state;
-
- inf_update_procs (current_inferior); /* Make sure we know about new threads. */
-
- thread = inf_tid_to_thread (current_inferior, inferior_pid);
- if (! thread)
- error ("fetch inferior registers: %d: Invalid thread", inferior_pid);
-
- state = proc_get_state (thread, 0);
-
- if (! state)
- warning ("Couldn't fetch register %s from %s (invalid thread).",
- REGISTER_NAME (reg), proc_string (thread));
- else if (reg >= 0)
- {
- proc_debug (thread, "fetching register: %s", REGISTER_NAME (reg));
- supply_register (reg, REG_ADDR(state, reg));
- thread->fetched_regs |= (1 << reg);
- }
- else
- {
- proc_debug (thread, "fetching all registers");
- for (reg = 0; reg < NUM_REGS; reg++)
- supply_register (reg, REG_ADDR(state, reg));
- thread->fetched_regs = ~0;
- }
-}
-
-/* Store our register values back into the inferior.
- * If REG is -1, do this for all registers.
- * Otherwise, REG specifies which register
- *
- * On mach3 all registers are always saved in one call.
- */
-void
-gnu_store_registers (reg)
- int reg;
-{
- struct proc *thread;
- int was_aborted, was_valid;
- thread_state_t state;
- thread_state_data_t old_state;
-
- inf_update_procs (current_inferior); /* Make sure we know about new threads. */
-
- thread = inf_tid_to_thread (current_inferior, inferior_pid);
- if (! thread)
- error ("store inferior registers: %d: Invalid thread", inferior_pid);
-
- proc_debug (thread, "storing register %s.", REGISTER_NAME (reg));
-
- was_aborted = thread->aborted;
- was_valid = thread->state_valid;
- if (! was_aborted && was_valid)
- bcopy (&thread->state, &old_state, sizeof (old_state));
-
- state = proc_get_state (thread, 1);
-
- if (! state)
- warning ("Couldn't store register %s from %s (invalid thread).",
- REGISTER_NAME (reg), proc_string (thread));
- else
- {
- if (! was_aborted && was_valid)
- /* See which registers have changed after aborting the thread. */
- {
- int check_reg;
- for (check_reg = 0; check_reg < NUM_REGS; check_reg++)
- if ((thread->fetched_regs & (1 << check_reg))
- && bcmp (REG_ADDR (&old_state, check_reg),
- REG_ADDR (state, check_reg),
- REGISTER_RAW_SIZE (check_reg)))
- /* Register CHECK_REG has changed! Ack! */
- {
- warning ("Register %s changed after thread was aborted.",
- REGISTER_NAME (check_reg));
- if (reg >= 0 && reg != check_reg)
- /* Update gdb's copy of the register. */
- supply_register (check_reg, REG_ADDR (state, check_reg));
- else
- warning ("... also writing this register! Suspicious...");
- }
- }
-
- if (reg >= 0)
- {
- proc_debug (thread, "storing register: %s", REGISTER_NAME (reg));
- STORE_REGS (state, reg, 1);
- }
- else
- {
- proc_debug (thread, "storing all registers");
- for (reg = 0; reg < NUM_REGS; reg++)
- STORE_REGS (state, reg, 1);
- }
- }
-}
-
-/* jtv@hut.fi: I copied and modified this 387 code from
- * gdb/i386-xdep.c. Modifications for Mach 3.0.
- *
- * i387 status dumper. See also i387-tdep.c
- */
-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];
-};
-/* This routine is machine independent?
- * Should move it to i387-tdep.c but you need to export struct env387
- */
-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_unfiltered ("u: ");
- print_387_status_word (status);
- }
-
- if (ep->status != 0)
- {
- if (bothstatus)
- printf_unfiltered ("e: ");
- print_387_status_word (ep->status);
- }
-
- print_387_control_word (ep->control);
- printf_unfiltered ("last exception: ");
- printf_unfiltered ("opcode %s; ", local_hex_string(ep->opcode));
- printf_unfiltered ("pc %s:", local_hex_string(ep->code_seg));
- printf_unfiltered ("%s; ", local_hex_string(ep->eip));
- printf_unfiltered ("operand %s", local_hex_string(ep->operand_seg));
- printf_unfiltered (":%s\n", local_hex_string(ep->operand));
-
- top = (ep->status >> 11) & 7;
-
- printf_unfiltered ("regno tag msb lsb value\n");
- for (fpreg = 7; fpreg >= 0; fpreg--)
- {
- double val;
-
- printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
-
- switch ((ep->tag >> (fpreg * 2)) & 3)
- {
- case 0: printf_unfiltered ("valid "); break;
- case 1: printf_unfiltered ("zero "); break;
- case 2: printf_unfiltered ("trap "); break;
- case 3: printf_unfiltered ("empty "); break;
- }
- for (i = 9; i >= 0; i--)
- printf_unfiltered ("%02x", ep->regs[fpreg][i]);
-
- floatformat_to_double (&floatformat_i387_ext, (char *)ep->regs[fpreg],
- &val);
- printf_unfiltered (" %g\n", val);
- }
- if (ep->r0)
- printf_unfiltered ("warning: reserved0 is %s\n", local_hex_string(ep->r0));
- if (ep->r1)
- printf_unfiltered ("warning: reserved1 is %s\n", local_hex_string(ep->r1));
- if (ep->r2)
- printf_unfiltered ("warning: reserved2 is %s\n", local_hex_string(ep->r2));
- if (ep->r3)
- printf_unfiltered ("warning: reserved3 is %s\n", local_hex_string(ep->r3));
-}
-
-/*
- * values that go into fp_kind (from <i386/fpreg.h>)
- */
-#define FP_NO 0 /* no fp chip, no emulator (no fp support) */
-#define FP_SW 1 /* no fp chip, using software emulator */
-#define FP_HW 2 /* chip present bit */
-#define FP_287 2 /* 80287 chip present */
-#define FP_387 3 /* 80387 chip present */
-
-typedef struct fpstate {
-#if 1
- unsigned char state[FP_STATE_BYTES]; /* "hardware" state */
-#else
- struct env387 state; /* Actually this */
-#endif
- int status; /* Duplicate status */
-} *fpstate_t;
-
-/* Mach 3 specific routines.
- */
-static int
-get_i387_state (fstate)
- struct fpstate *fstate;
-{
- error_t err;
- thread_state_data_t state;
- unsigned int fsCnt = i386_FLOAT_STATE_COUNT;
- struct i386_float_state *fsp;
- struct proc *thread = inf_tid_to_thread (current_inferior, inferior_pid);
-
- if (!thread)
- error ("get_i387_state: Invalid thread");
-
- proc_abort (thread, 0); /* Make sure THREAD's in a reasonable state. */
-
- err = thread_get_state (thread->port, i386_FLOAT_STATE, state, &fsCnt);
- if (err)
- {
- warning ("Can not get live floating point state: %s",
- mach_error_string (err));
- return 0;
- }
-
- fsp = (struct i386_float_state *)state;
- /* The 387 chip (also 486 counts) or a software emulator? */
- if (!fsp->initialized || (fsp->fpkind != FP_387 && fsp->fpkind != FP_SW))
- return 0;
-
- /* Clear the target then copy thread's float state there.
- Make a copy of the status word, for some reason?
- */
- memset (fstate, 0, sizeof (struct fpstate));
-
- fstate->status = fsp->exc_status;
-
- memcpy (fstate->state, (char *)&fsp->hw_state, FP_STATE_BYTES);
-
- return 1;
-}
-
-/*
- * This is called by "info float" command
- */
-void
-i386_mach3_float_info()
-{
- char buf [sizeof (struct fpstate) + 2 * sizeof (int)];
- int valid = 0;
- fpstate_t fps;
-
- if (target_has_execution)
- valid = get_i387_state (buf);
-
- if (!valid)
- {
- warning ("no floating point status saved");
- return;
- }
-
- fps = (fpstate_t) buf;
-
- print_387_status (fps->status, (struct env387 *)fps->state);
-}
diff --git a/contrib/gdb/gdb/i386ly-tdep.c b/contrib/gdb/gdb/i386ly-tdep.c
deleted file mode 100644
index 101f4ed..0000000
--- a/contrib/gdb/gdb/i386ly-tdep.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Target-dependent code for Intel 386 running LynxOS.
- Copyright 1993 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "target.h"
-#include "gdbcore.h"
-
-/* Return the PC of the caller from the call frame. Assumes the subr prologue
- has already been executed, and the frame pointer setup. If this is the
- outermost frame, we check to see if we are in a system call by examining the
- previous instruction. If so, then the return PC is actually at SP+4 because
- system calls use a different calling sequence. */
-
-CORE_ADDR
-i386lynx_saved_pc_after_call (frame)
- struct frame_info *frame;
-{
- char opcode[7];
- static const unsigned char call_inst[] = {0x9a, 0, 0, 0, 0, 8, 0}; /* lcall 0x8,0x0 */
-
- read_memory (frame->pc - 7, opcode, 7);
- if (memcmp (opcode, call_inst, 7) == 0)
- return read_memory_integer (read_register (SP_REGNUM) + 4, 4);
-
- return read_memory_integer (read_register (SP_REGNUM), 4);
-}
diff --git a/contrib/gdb/gdb/i386m3-nat.c b/contrib/gdb/gdb/i386m3-nat.c
deleted file mode 100644
index c0257b1..0000000
--- a/contrib/gdb/gdb/i386m3-nat.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/* Low level interface to I386 running mach 3.0.
- Copyright (C) 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "floatformat.h"
-
-#include <stdio.h>
-
-#include <mach.h>
-#include <mach/message.h>
-#include <mach/exception.h>
-#include <mach_error.h>
-
-/* Hmmm... Should this not be here?
- * Now for i386_float_info() target_has_execution
- */
-#include <target.h>
-
-/* This mess is duplicated in bfd/i386mach3.h
- *
- * This is an ugly way to hack around the incorrect
- * definition of UPAGES in i386/machparam.h.
- *
- * The definition should specify the size reserved
- * for "struct user" in core files in PAGES,
- * but instead it gives it in 512-byte core-clicks
- * for i386 and i860.
- */
-#include <sys/param.h>
-#if UPAGES == 16
-#define UAREA_SIZE ctob(UPAGES)
-#elif UPAGES == 2
-#define UAREA_SIZE (NBPG*UPAGES)
-#else
-FIXME!! UPAGES is neither 2 nor 16
-#endif
-
-/* @@@ Should move print_387_status() to i387-tdep.c */
-extern void print_387_control_word (); /* i387-tdep.h */
-extern void print_387_status_word ();
-
-#define private static
-
-
-/* Find offsets to thread states at compile time.
- * If your compiler does not grok this, calculate offsets
- * offsets yourself and use them (or get a compatible compiler :-)
- */
-
-#define REG_OFFSET(reg) (int)(&((struct i386_thread_state *)0)->reg)
-
-/* at reg_offset[i] is the offset to the i386_thread_state
- * location where the gdb registers[i] is stored.
- */
-
-static int reg_offset[] =
-{
- REG_OFFSET(eax), REG_OFFSET(ecx), REG_OFFSET(edx), REG_OFFSET(ebx),
- REG_OFFSET(uesp), REG_OFFSET(ebp), REG_OFFSET(esi), REG_OFFSET(edi),
- REG_OFFSET(eip), REG_OFFSET(efl), REG_OFFSET(cs), REG_OFFSET(ss),
- REG_OFFSET(ds), REG_OFFSET(es), REG_OFFSET(fs), REG_OFFSET(gs)
-};
-
-#define REG_ADDRESS(state,regnum) ((char *)(state)+reg_offset[regnum])
-
-/* Fetch COUNT contiguous registers from thread STATE starting from REGNUM
- * Caller knows that the regs handled in one transaction are of same size.
- */
-#define FETCH_REGS(state, regnum, count) \
- memcpy (&registers[REGISTER_BYTE (regnum)], \
- REG_ADDRESS (state, regnum), \
- count*REGISTER_SIZE)
-
-/* Store COUNT contiguous registers to thread STATE starting from REGNUM */
-#define STORE_REGS(state, regnum, count) \
- memcpy (REG_ADDRESS (state, regnum), \
- &registers[REGISTER_BYTE (regnum)], \
- count*REGISTER_SIZE)
-
-/*
- * Fetch inferiors registers for gdb.
- * REGNO specifies which (as gdb views it) register, -1 for all.
- */
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- kern_return_t ret;
- thread_state_data_t state;
- unsigned int stateCnt = i386_THREAD_STATE_COUNT;
- int index;
-
- if (! MACH_PORT_VALID (current_thread))
- error ("fetch inferior registers: Invalid thread");
-
- if (must_suspend_thread)
- setup_thread (current_thread, 1);
-
- ret = thread_get_state (current_thread,
- i386_THREAD_STATE,
- state,
- &stateCnt);
-
- if (ret != KERN_SUCCESS)
- warning ("fetch_inferior_registers: %s ",
- mach_error_string (ret));
-#if 0
- /* It may be more effective to store validate all of them,
- * since we fetched them all anyway
- */
- else if (regno != -1)
- supply_register (regno, (char *)state+reg_offset[regno]);
-#endif
- else
- {
- for (index = 0; index < NUM_REGS; index++)
- supply_register (index, (char *)state+reg_offset[index]);
- }
-
- if (must_suspend_thread)
- setup_thread (current_thread, 0);
-}
-
-/* Store our register values back into the inferior.
- * If REGNO is -1, do this for all registers.
- * Otherwise, REGNO specifies which register
- *
- * On mach3 all registers are always saved in one call.
- */
-void
-store_inferior_registers (regno)
- int regno;
-{
- kern_return_t ret;
- thread_state_data_t state;
- unsigned int stateCnt = i386_THREAD_STATE_COUNT;
- register int index;
-
- if (! MACH_PORT_VALID (current_thread))
- error ("store inferior registers: Invalid thread");
-
- if (must_suspend_thread)
- setup_thread (current_thread, 1);
-
- /* Fetch the state of the current thread */
- ret = thread_get_state (current_thread,
- i386_THREAD_STATE,
- state,
- &stateCnt);
-
- if (ret != KERN_SUCCESS)
- {
- warning ("store_inferior_registers (get): %s",
- mach_error_string (ret));
- if (must_suspend_thread)
- setup_thread (current_thread, 0);
- return;
- }
-
- /* move gdb's registers to thread's state
- *
- * Since we save all registers anyway, save the ones
- * that gdb thinks are valid (e.g. ignore the regno
- * parameter)
- */
-#if 0
- if (regno != -1)
- STORE_REGS (state, regno, 1);
- else
-#endif
- {
- for (index = 0; index < NUM_REGS; index++)
- STORE_REGS (state, index, 1);
- }
-
- /* Write gdb's current view of register to the thread
- */
- ret = thread_set_state (current_thread,
- i386_THREAD_STATE,
- state,
- i386_THREAD_STATE_COUNT);
-
- if (ret != KERN_SUCCESS)
- warning ("store_inferior_registers (set): %s",
- mach_error_string (ret));
-
- if (must_suspend_thread)
- setup_thread (current_thread, 0);
-}
-
-
-
-/* Return the address in the core dump or inferior of register REGNO.
- * BLOCKEND should be the address of the end of the UPAGES area read
- * in memory, but it's not?
- *
- * Currently our UX server dumps the whole thread state to the
- * core file. If your UX does something else, adapt the routine
- * below to return the offset to the given register.
- *
- * Called by core-aout.c(fetch_core_registers)
- */
-
-CORE_ADDR
-register_addr (regno, blockend)
- int regno;
- CORE_ADDR blockend;
-{
- CORE_ADDR addr;
-
- if (regno < 0 || regno >= NUM_REGS)
- error ("Invalid register number %d.", regno);
-
- /* UAREA_SIZE == 8 kB in i386 */
- addr = (unsigned int)REG_ADDRESS (UAREA_SIZE - sizeof(struct i386_thread_state), regno);
-
- return addr;
-}
-
-/* jtv@hut.fi: I copied and modified this 387 code from
- * gdb/i386-xdep.c. Modifications for Mach 3.0.
- *
- * i387 status dumper. See also i387-tdep.c
- */
-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];
-};
-/* This routine is machine independent?
- * Should move it to i387-tdep.c but you need to export struct env387
- */
-private
-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_unfiltered ("u: ");
- print_387_status_word (status);
- }
-
- if (ep->status != 0)
- {
- if (bothstatus)
- printf_unfiltered ("e: ");
- print_387_status_word (ep->status);
- }
-
- print_387_control_word (ep->control);
- printf_unfiltered ("last exception: ");
- printf_unfiltered ("opcode %s; ", local_hex_string(ep->opcode));
- printf_unfiltered ("pc %s:", local_hex_string(ep->code_seg));
- printf_unfiltered ("%s; ", local_hex_string(ep->eip));
- printf_unfiltered ("operand %s", local_hex_string(ep->operand_seg));
- printf_unfiltered (":%s\n", local_hex_string(ep->operand));
-
- top = (ep->status >> 11) & 7;
-
- printf_unfiltered ("regno tag msb lsb value\n");
- for (fpreg = 7; fpreg >= 0; fpreg--)
- {
- double val;
-
- printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
-
- switch ((ep->tag >> (fpreg * 2)) & 3)
- {
- case 0: printf_unfiltered ("valid "); break;
- case 1: printf_unfiltered ("zero "); break;
- case 2: printf_unfiltered ("trap "); break;
- case 3: printf_unfiltered ("empty "); break;
- }
- for (i = 9; i >= 0; i--)
- printf_unfiltered ("%02x", ep->regs[fpreg][i]);
-
- floatformat_to_double (&floatformat_i387_ext, (char *)ep->regs[fpreg],
- &val);
- printf_unfiltered (" %g\n", val);
- }
- if (ep->r0)
- printf_unfiltered ("warning: reserved0 is %s\n", local_hex_string(ep->r0));
- if (ep->r1)
- printf_unfiltered ("warning: reserved1 is %s\n", local_hex_string(ep->r1));
- if (ep->r2)
- printf_unfiltered ("warning: reserved2 is %s\n", local_hex_string(ep->r2));
- if (ep->r3)
- printf_unfiltered ("warning: reserved3 is %s\n", local_hex_string(ep->r3));
-}
-
-/*
- * values that go into fp_kind (from <i386/fpreg.h>)
- */
-#define FP_NO 0 /* no fp chip, no emulator (no fp support) */
-#define FP_SW 1 /* no fp chip, using software emulator */
-#define FP_HW 2 /* chip present bit */
-#define FP_287 2 /* 80287 chip present */
-#define FP_387 3 /* 80387 chip present */
-
-typedef struct fpstate {
-#if 1
- unsigned char state[FP_STATE_BYTES]; /* "hardware" state */
-#else
- struct env387 state; /* Actually this */
-#endif
- int status; /* Duplicate status */
-} *fpstate_t;
-
-/* Mach 3 specific routines.
- */
-private boolean_t
-get_i387_state (fstate)
- struct fpstate *fstate;
-{
- kern_return_t ret;
- thread_state_data_t state;
- unsigned int fsCnt = i386_FLOAT_STATE_COUNT;
- struct i386_float_state *fsp;
-
- ret = thread_get_state (current_thread,
- i386_FLOAT_STATE,
- state,
- &fsCnt);
-
- if (ret != KERN_SUCCESS)
- {
- warning ("Can not get live floating point state: %s",
- mach_error_string (ret));
- return FALSE;
- }
-
- fsp = (struct i386_float_state *)state;
- /* The 387 chip (also 486 counts) or a software emulator? */
- if (!fsp->initialized || (fsp->fpkind != FP_387 && fsp->fpkind != FP_SW))
- return FALSE;
-
- /* Clear the target then copy thread's float state there.
- Make a copy of the status word, for some reason?
- */
- memset (fstate, 0, sizeof (struct fpstate));
-
- fstate->status = fsp->exc_status;
-
- memcpy (fstate->state, (char *)&fsp->hw_state, FP_STATE_BYTES);
-
- return TRUE;
-}
-
-private boolean_t
-get_i387_core_state (fstate)
- struct fpstate *fstate;
-{
- /* Not implemented yet. Core files do not contain float state. */
- return FALSE;
-}
-
-/*
- * This is called by "info float" command
- */
-void
-i386_mach3_float_info()
-{
- char buf [sizeof (struct fpstate) + 2 * sizeof (int)];
- boolean_t valid = FALSE;
- fpstate_t fps;
-
- if (target_has_execution)
- valid = get_i387_state (buf);
-#if 0
- else if (WE HAVE CORE FILE) /* @@@@ Core files not supported */
- valid = get_i387_core_state (buf);
-#endif
-
- if (!valid)
- {
- warning ("no floating point status saved");
- return;
- }
-
- fps = (fpstate_t) buf;
-
- print_387_status (fps->status, (struct env387 *)fps->state);
-}
diff --git a/contrib/gdb/gdb/i386mach-nat.c b/contrib/gdb/gdb/i386mach-nat.c
deleted file mode 100644
index f843d7f..0000000
--- a/contrib/gdb/gdb/i386mach-nat.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/* Native dependent code for Mach 386's for GDB, the GNU debugger.
- Copyright (C) 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "gdbcore.h"
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <sys/user.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include <sys/ptrace.h>
-#include <machine/reg.h>
-
-#include <sys/file.h>
-#include "gdb_stat.h"
-#include <sys/core.h>
-
-static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
-
-void
-fetch_inferior_registers (regno)
- int regno; /* Original value discarded */
-{
- struct regs inferior_registers;
- struct fp_state inferior_fp_registers;
- extern char registers[];
-
- registers_fetched ();
-
- ptrace (PTRACE_GETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers);
- ptrace (PTRACE_GETFPREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_fp_registers);
-
- memcpy (registers, &inferior_registers, sizeof inferior_registers);
-
- memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)],
- inferior_fp_registers.f_st,
- sizeof inferior_fp_registers.f_st);
- memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
- &inferior_fp_registers.f_ctrl,
- 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). */
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- struct regs inferior_registers;
- struct fp_state inferior_fp_registers;
- extern char registers[];
-
- memcpy (&inferior_registers, registers, 20 * 4);
-
- memcpy (inferior_fp_registers.f_st,&registers[REGISTER_BYTE (FP0_REGNUM)],
- sizeof inferior_fp_registers.f_st);
- memcpy (&inferior_fp_registers.f_ctrl,
- &registers[REGISTER_BYTE (FPC_REGNUM)],
- 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,
- (PTRACE_ARG3_TYPE) stack);
- int reg = inferior_registers.r_reg[EAX];
- inferior_registers.r_reg[EAX] =
- inferior_registers.r_reg[FP_REGNUM];
- ptrace (PTRACE_SETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers);
- ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, 0xc589);
- ptrace (PTRACE_SINGLESTEP, inferior_pid, (PTRACE_ARG3_TYPE) stack, 0);
- wait (0);
- ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, stuff);
- inferior_registers.r_reg[EAX] = reg;
- }
-#endif
- ptrace (PTRACE_SETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers);
- ptrace (PTRACE_SETFPREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_fp_registers);
-}
-
-
-
-/* Work with core files, for GDB. */
-
-static void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr; /* Unused in this version */
-{
- int val;
- extern char registers[];
-
- switch (which) {
- case 0:
- case 1:
- memcpy (registers, core_reg_sect, core_reg_size);
- break;
-
- case 2:
-#ifdef FP0_REGNUM
- memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)],
- core_reg_sect,
- core_reg_size); /* FIXME, probably bogus */
-#endif
-#ifdef FPC_REGNUM
- memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
- &corestr.c_fpu.f_fpstatus.f_ctrl,
- sizeof corestr.c_fpu.f_fpstatus -
- sizeof corestr.c_fpu.f_fpstatus.f_st);
-#endif
- break;
- }
-}
-
-
-/* Register that we are able to handle i386mach core file formats.
- FIXME: is this really bfd_target_unknown_flavour? */
-
-static struct core_fns i386mach_core_fns =
-{
- bfd_target_unknown_flavour,
- fetch_core_registers,
- NULL
-};
-
-void
-_initialize_core_i386mach ()
-{
- add_core_fns (&i386mach_core_fns);
-}
diff --git a/contrib/gdb/gdb/i386v-nat.c b/contrib/gdb/gdb/i386v-nat.c
deleted file mode 100644
index 5618687..0000000
--- a/contrib/gdb/gdb/i386v-nat.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/* Intel 386 native support for SYSV systems (pre-SVR4).
- Copyright (C) 1988, 89, 91, 92, 94, 96, 1998 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-#ifdef HAVE_PTRACE_H
-# include <ptrace.h>
-#else
-# ifdef HAVE_SYS_PTRACE_H
-# include <sys/ptrace.h>
-# endif
-#endif
-
-#include "frame.h"
-#include "inferior.h"
-#include "language.h"
-#include "gdbcore.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/user.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-
-/* FIXME: The following used to be just "#include <sys/debugreg.h>", but
- * the the Linux 2.1.x kernel and glibc 2.0.x are not in sync; including
- * <sys/debugreg.h> will result in an error. With luck, these losers
- * will get their act together and we can trash this hack in the near future.
- * --jsm 1998-10-21
- */
-
-#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS
-# ifdef HAVE_ASM_DEBUGREG_H
-# include <asm/debugreg.h>
-# else
-# include <sys/debugreg.h>
-# endif
-#endif
-
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-#ifdef HAVE_SYS_REG_H
-#include <sys/reg.h>
-#endif
-
-#include "floatformat.h"
-
-#include "target.h"
-
-
-/* this table must line up with REGISTER_NAMES in tm-i386v.h */
-/* symbols like 'EAX' come from <sys/reg.h> */
-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
- */
-
-int
-i386_register_u_addr (blockend, regnum)
- int blockend;
- int regnum;
-{
- struct user u;
- int fpstate;
- int ubase;
-
- ubase = blockend;
- /* FIXME: Should have better way to test floating point range */
- if (regnum >= FP0_REGNUM && regnum <= (FP0_REGNUM + 7))
- {
-#ifdef KSTKSZ /* SCO, and others? */
- ubase += 4 * (SS + 1) - KSTKSZ;
- fpstate = ubase + ((char *)&u.u_fps.u_fpstate - (char *)&u);
- return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM));
-#else
- fpstate = ubase + ((char *)&u.i387.st_space - (char *)&u);
- return (fpstate + 10 * (regnum - FP0_REGNUM));
-#endif
- }
- else
- {
- return (ubase + 4 * regmap[regnum]);
- }
-
-}
-
-int
-kernel_u_size ()
-{
- return (sizeof (struct user));
-}
-
-#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS
-
-#if !defined (offsetof)
-#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
-#endif
-
-/* Record the value of the debug control register. */
-static int debug_control_mirror;
-
-/* Record which address associates with which register. */
-static CORE_ADDR address_lookup[DR_LASTADDR - DR_FIRSTADDR + 1];
-
-static int
-i386_insert_aligned_watchpoint PARAMS ((int, CORE_ADDR, CORE_ADDR, int,
- int));
-
-static int
-i386_insert_nonaligned_watchpoint PARAMS ((int, CORE_ADDR, CORE_ADDR, int,
- int));
-
-/* Insert a watchpoint. */
-
-int
-i386_insert_watchpoint (pid, addr, len, rw)
- int pid;
- CORE_ADDR addr;
- int len;
- int rw;
-{
- return i386_insert_aligned_watchpoint (pid, addr, addr, len, rw);
-}
-
-static int
-i386_insert_aligned_watchpoint (pid, waddr, addr, len, rw)
- int pid;
- CORE_ADDR waddr;
- CORE_ADDR addr;
- int len;
- int rw;
-{
- int i;
- int read_write_bits, len_bits;
- int free_debug_register;
- int register_number;
-
- /* Look for a free debug register. */
- for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
- {
- if (address_lookup[i - DR_FIRSTADDR] == 0)
- break;
- }
-
- /* No more debug registers! */
- if (i > DR_LASTADDR)
- return -1;
-
- read_write_bits = (rw & 1) ? DR_RW_READ : DR_RW_WRITE;
-
- if (len == 1)
- len_bits = DR_LEN_1;
- else if (len == 2)
- {
- if (addr % 2)
- return i386_insert_nonaligned_watchpoint (pid, waddr, addr, len, rw);
- len_bits = DR_LEN_2;
- }
-
- else if (len == 4)
- {
- if (addr % 4)
- return i386_insert_nonaligned_watchpoint (pid, waddr, addr, len, rw);
- len_bits = DR_LEN_4;
- }
- else
- return i386_insert_nonaligned_watchpoint (pid, waddr, addr, len, rw);
-
- free_debug_register = i;
- register_number = free_debug_register - DR_FIRSTADDR;
- debug_control_mirror |=
- ((read_write_bits | len_bits)
- << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * register_number));
- debug_control_mirror |=
- (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * register_number));
- debug_control_mirror |= DR_LOCAL_SLOWDOWN;
- debug_control_mirror &= ~DR_CONTROL_RESERVED;
-
- ptrace (6, pid, offsetof (struct user, u_debugreg[DR_CONTROL]),
- debug_control_mirror);
- ptrace (6, pid, offsetof (struct user, u_debugreg[free_debug_register]),
- addr);
-
- /* Record where we came from. */
- address_lookup[register_number] = addr;
- return 0;
-}
-
-static int
-i386_insert_nonaligned_watchpoint (pid, waddr, addr, len, rw)
- int pid;
- CORE_ADDR waddr;
- CORE_ADDR addr;
- int len;
- int rw;
-{
- int align;
- int size;
- int rv;
-
- static int size_try_array[16] = {
- 1, 1, 1, 1, /* trying size one */
- 2, 1, 2, 1, /* trying size two */
- 2, 1, 2, 1, /* trying size three */
- 4, 1, 2, 1 /* trying size four */
- };
-
- rv = 0;
- while (len > 0)
- {
- align = addr % 4;
- /* Four is the maximum length for 386. */
- size = (len > 4) ? 3 : len - 1;
- size = size_try_array[size * 4 + align];
-
- rv = i386_insert_aligned_watchpoint (pid, waddr, addr, size, rw);
- if (rv)
- {
- i386_remove_watchpoint (pid, waddr, size);
- return rv;
- }
- addr += size;
- len -= size;
- }
- return rv;
-}
-
-/* Remove a watchpoint. */
-
-int
-i386_remove_watchpoint (pid, addr, len)
- int pid;
- CORE_ADDR addr;
- int len;
-{
- int i;
- int register_number;
-
- for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
- {
- register_number = i - DR_FIRSTADDR;
- if (address_lookup[register_number] == addr)
- {
- debug_control_mirror &=
- ~(1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * register_number));
- address_lookup[register_number] = 0;
- }
- }
- ptrace (6, pid, offsetof (struct user, u_debugreg[DR_CONTROL]),
- debug_control_mirror);
- ptrace (6, pid, offsetof (struct user, u_debugreg[DR_STATUS]), 0);
-
- return 0;
-}
-
-/* Check if stopped by a watchpoint. */
-
-CORE_ADDR
-i386_stopped_by_watchpoint (pid)
- int pid;
-{
- int i;
- int status;
-
- status = ptrace (3, pid, offsetof (struct user, u_debugreg[DR_STATUS]), 0);
- ptrace (6, pid, offsetof (struct user, u_debugreg[DR_STATUS]), 0);
-
- for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
- {
- if (status & (1 << (i - DR_FIRSTADDR)))
- return address_lookup[i - DR_FIRSTADDR];
- }
-
- return 0;
-}
-
-#endif /* TARGET_HAS_HARDWARE_WATCHPOINTS */
-
-#if 0
-/* using FLOAT_INFO as is would be a problem. FLOAT_INFO is called
- via a command xxx and eventually calls ptrace without ever having
- traversed the target vector. This would be terribly impolite
- behaviour for a sun4 hosted remote gdb.
-
- A fix might be to move this code into the "info registers" command.
- rich@cygnus.com 15 Sept 92. */
-i386_float_info ()
-{
- struct user u; /* just for address computations */
- int i;
- /* fpstate defined in <sys/user.h> */
- 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, (PTRACE_ARG3_TYPE) 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_unfiltered ("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, (PTRACE_ARG3_TYPE) 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 /* never */
diff --git a/contrib/gdb/gdb/i386v4-nat.c b/contrib/gdb/gdb/i386v4-nat.c
deleted file mode 100644
index ea84c65..0000000
--- a/contrib/gdb/gdb/i386v4-nat.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* Native-dependent code for SVR4 Unix running on i386's, for GDB.
- Copyright 1988, 1989, 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "value.h"
-
-#ifdef HAVE_SYS_REG_H
-#include <sys/reg.h>
-#endif
-
-
-#ifdef HAVE_SYS_PROCFS_H
-
-#include <sys/procfs.h>
-
-/* 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 i386 for example, the general register set is typically defined
- by:
-
- typedef int gregset_t[19]; (in <sys/regset.h>)
-
- #define GS 0 (in <sys/reg.h>)
- #define FS 1
- ...
- #define UESP 17
- #define SS 18
-
- and the floating point set by:
-
- typedef struct fpregset
- {
- union
- {
- struct fpchip_state // fp extension state //
- {
- int state[27]; // 287/387 saved state //
- int status; // status word saved at exception //
- } fpchip_state;
- struct fp_emul_space // for emulators //
- {
- char fp_emul[246];
- char fp_epad[2];
- } fp_emul_space;
- int f_fpregs[62]; // union of the above //
- } fp_reg_set;
- long f_wregs[33]; // saved weitek state //
- } fpregset_t;
-
- These routines provide the packing and unpacking of gregset_t and
- fpregset_t formatted data.
-
- */
-
-#ifdef HAVE_GREGSET_T
-
-/* This is a duplicate of the table in i386-xdep.c. */
-
-static int regmap[] =
-{
- EAX, ECX, EDX, EBX,
- UESP, EBP, ESI, EDI,
- EIP, EFL, CS, SS,
- DS, ES, FS, GS,
-};
-
-/* Prototypes for local functions */
-
-void fill_gregset PARAMS ((gregset_t *, int));
-
-void supply_gregset PARAMS ((gregset_t *));
-
-void supply_fpregset PARAMS ((fpregset_t *));
-
-void fill_fpregset PARAMS ((fpregset_t *, int));
-
-
-/* FIXME: These routine absolutely depends upon (NUM_REGS - NUM_FREGS)
- being less than or equal to the number of registers that can be stored
- in a gregset_t. Note that with the current scheme there will typically
- be more registers actually stored in a gregset_t that what we know
- about. This is bogus and should be fixed. */
-
-/* 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 regi;
- register greg_t *regp = (greg_t *) gregsetp;
- extern int regmap[];
-
- for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++)
- {
- supply_register (regi, (char *) (regp + regmap[regi]));
- }
-}
-
-void
-fill_gregset (gregsetp, regno)
- gregset_t *gregsetp;
- int regno;
-{
- int regi;
- register greg_t *regp = (greg_t *) gregsetp;
- extern char registers[];
- extern int regmap[];
-
- for (regi = 0 ; regi < (NUM_REGS - NUM_FREGS) ; regi++)
- {
- if ((regno == -1) || (regno == regi))
- {
- *(regp + regmap[regi]) = *(int *) &registers[REGISTER_BYTE (regi)];
- }
- }
-}
-
-#endif /* HAVE_GREGSET_T */
-
-#if defined (FP0_REGNUM) && defined (HAVE_FPREGSET_T)
-
-/* 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;
-{
- /* FIXME: see m68k-tdep.c for an example, for the m68k. */
-}
-
-/* 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;
-{
- /* FIXME: see m68k-tdep.c for an example, for the m68k. */
-}
-
-#endif /* defined (FP0_REGNUM) && defined (HAVE_FPREGSET_T) */
-
-#endif /* HAVE_SYS_PROCFS_H */
diff --git a/contrib/gdb/gdb/infptrace.c b/contrib/gdb/gdb/infptrace.c
index 1db7223..d266f00 100644
--- a/contrib/gdb/gdb/infptrace.c
+++ b/contrib/gdb/gdb/infptrace.c
@@ -1,6 +1,5 @@
/* Low level Unix child interface to ptrace, for GDB when running under Unix.
- Copyright 1988, 89, 90, 91, 92, 93, 94, 95, 96, 1998
- Free Software Foundation, Inc.
+ Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
This file is part of GDB.
@@ -31,17 +30,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#endif
#include <sys/param.h>
-#include <sys/dir.h>
#include <signal.h>
#include <sys/ioctl.h>
-#ifdef HAVE_PTRACE_H
-# include <ptrace.h>
+#ifndef NO_PTRACE_H
+#ifdef PTRACE_IN_WRONG_PLACE
+#include <ptrace.h>
#else
-# ifdef HAVE_SYS_PTRACE_H
-# include <sys/ptrace.h>
-# endif
+#include <sys/ptrace.h>
#endif
+#endif /* NO_PTRACE_H */
#if !defined (PT_READ_I)
#define PT_READ_I 1 /* Read word from text space */
@@ -96,18 +94,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#endif /* KERNEL_U_ADDR_BSD. */
#endif /* !FETCH_INFERIOR_REGISTERS */
-#if !defined (CHILD_XFER_MEMORY)
-static void udot_info PARAMS ((char *, int));
-#endif
-
-#if !defined (FETCH_INFERIOR_REGISTERS)
-static void fetch_register PARAMS ((int));
-static void store_register PARAMS ((int));
-#endif
-
-void _initialize_kernel_u_addr PARAMS ((void));
-void _initialize_infptrace PARAMS ((void));
-
/* This function simply calls ptrace with the given arguments.
It exists so that all calls to ptrace are isolated in this
@@ -118,112 +104,34 @@ call_ptrace (request, pid, addr, data)
PTRACE_ARG3_TYPE addr;
int data;
{
- int pt_status = 0;
-
-#if 0
- int saved_errno;
-
- printf ("call_ptrace(request=%d, pid=%d, addr=0x%x, data=0x%x)",
- request, pid, addr, data);
-#endif
-#if defined(PT_SETTRC)
- /* If the parent can be told to attach to us, try to do it. */
- if (request == PT_SETTRC) {
- errno = 0;
- pt_status = ptrace (PT_SETTRC, pid, addr, data
-#if defined (FIVE_ARG_PTRACE)
- /* Deal with HPUX 8.0 braindamage. We never use the
- calls which require the fifth argument. */
- , 0
-#endif
- );
-
- if (errno) perror_with_name ("ptrace");
-#if 0
- printf (" = %d\n", pt_status);
-#endif
- if (pt_status < 0)
- return pt_status;
- else
- return parent_attach_all (pid, addr, data);
- }
-#endif
-
-#if defined(PT_CONTIN1)
- /* On HPUX, PT_CONTIN1 is a form of continue that preserves pending
- signals. If it's available, use it. */
- if (request == PT_CONTINUE)
- request = PT_CONTIN1;
-#endif
-
-#if defined(PT_SINGLE1)
- /* On HPUX, PT_SINGLE1 is a form of step that preserves pending
- signals. If it's available, use it. */
- if (request == PT_STEP)
- request = PT_SINGLE1;
-#endif
-
-#if 0
- saved_errno = errno;
- errno = 0;
-#endif
- pt_status = ptrace (request, pid, addr, data
+ return ptrace (request, pid, addr, data
#if defined (FIVE_ARG_PTRACE)
/* Deal with HPUX 8.0 braindamage. We never use the
calls which require the fifth argument. */
, 0
#endif
);
-#if 0
- if (errno)
- printf (" [errno = %d]", errno);
-
- errno = saved_errno;
- printf (" = 0x%x\n", pt_status);
-#endif
- return pt_status;
}
-
#if defined (DEBUG_PTRACE) || defined (FIVE_ARG_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
-/* Wait for a process to finish, possibly running a target-specific
- hook before returning. */
-
-int
-ptrace_wait (pid, status)
- int pid;
- int *status;
-{
- int wstate;
-
- wstate = wait (status);
- target_post_wait (wstate, *status);
- return wstate;
-}
-
void
kill_inferior ()
{
- int status;
-
if (inferior_pid == 0)
return;
-
- /* This once used to call "kill" to kill the inferior just in case
- the inferior was still running. As others have noted in the past
- (kingdon) there shouldn't be any way to get here if the inferior
- is still running -- else there's a major problem elsewere in gdb
- and it needs to be fixed.
-
- The kill call causes problems under hpux10, so it's been removed;
- if this causes problems we'll deal with them as they arise. */
+ /* ptrace PT_KILL only works if process is stopped!!! So stop it with
+ a real signal first, if we can. FIXME: This is bogus. When the inferior
+ is not stopped, GDB should just be waiting for it. Either the following
+ line is unecessary, or there is some problem elsewhere in GDB which
+ causes us to get here when the inferior is not stopped. */
+ kill (inferior_pid, SIGKILL);
ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0);
- ptrace_wait (0, &status);
+ wait ((int *)0);
target_mourn_inferior ();
}
@@ -257,13 +165,8 @@ child_resume (pid, step, signal)
instructions), so we don't have to worry about that here. */
if (step)
- {
- if (SOFTWARE_SINGLE_STEP_P)
- abort(); /* Make sure this doesn't happen. */
- else
- ptrace (PT_STEP, pid, (PTRACE_ARG3_TYPE) 1,
- target_signal_to_host (signal));
- }
+ ptrace (PT_STEP, pid, (PTRACE_ARG3_TYPE) 1,
+ target_signal_to_host (signal));
else
ptrace (PT_CONTINUE, pid, (PTRACE_ARG3_TYPE) 1,
target_signal_to_host (signal));
@@ -358,10 +261,12 @@ fetch_register (regno)
{
/* This isn't really an address. But ptrace thinks of it as one. */
CORE_ADDR regaddr;
+ char buf[MAX_REGISTER_RAW_SIZE];
char mess[128]; /* For messages */
register int i;
- unsigned int offset; /* Offset of registers within the u area. */
- char buf[MAX_REGISTER_RAW_SIZE];
+
+ /* Offset of registers within the u area. */
+ unsigned int offset;
if (CANNOT_FETCH_REGISTER (regno))
{
@@ -381,7 +286,7 @@ fetch_register (regno)
regaddr += sizeof (PTRACE_XFER_TYPE);
if (errno != 0)
{
- sprintf (mess, "reading register %s (#%d)", REGISTER_NAME (regno), regno);
+ sprintf (mess, "reading register %s (#%d)", reg_names[regno], regno);
perror_with_name (mess);
}
}
@@ -389,25 +294,22 @@ fetch_register (regno)
}
-/* Fetch register values from the inferior.
- If REGNO is negative, do this for all registers.
- Otherwise, REGNO specifies which register (so we can save time). */
+/* Fetch all registers, or just one, from the child process. */
void
fetch_inferior_registers (regno)
int regno;
{
- if (regno >= 0)
+ int numregs;
+
+ if (regno == -1)
{
- fetch_register (regno);
+ numregs = ARCH_NUM_REGS;
+ for (regno = 0; regno < numregs; regno++)
+ fetch_register (regno);
}
else
- {
- for (regno = 0; regno < ARCH_NUM_REGS; regno++)
- {
- fetch_register (regno);
- }
- }
+ fetch_register (regno);
}
/* Registers we shouldn't try to store. */
@@ -415,57 +317,57 @@ fetch_inferior_registers (regno)
#define CANNOT_STORE_REGISTER(regno) 0
#endif
-/* Store one register. */
+/* 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). */
-static void
-store_register (regno)
+void
+store_inferior_registers (regno)
int regno;
{
/* This isn't really an address. But ptrace thinks of it as one. */
CORE_ADDR regaddr;
- char mess[128]; /* For messages */
- register int i;
- unsigned int offset; /* Offset of registers within the u area. */
-
- if (CANNOT_STORE_REGISTER (regno))
- {
- return;
- }
+ char buf[80];
+ register int i, numregs;
- offset = U_REGS_OFFSET;
+ unsigned int offset = U_REGS_OFFSET;
- regaddr = register_addr (regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(PTRACE_XFER_TYPE))
+ if (regno >= 0)
{
- errno = 0;
- ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
- *(PTRACE_XFER_TYPE *) &registers[REGISTER_BYTE (regno) + i]);
- regaddr += sizeof (PTRACE_XFER_TYPE);
- if (errno != 0)
+ regaddr = register_addr (regno, offset);
+ for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(PTRACE_XFER_TYPE))
{
- sprintf (mess, "writing register %s (#%d)", REGISTER_NAME (regno), regno);
- perror_with_name (mess);
+ errno = 0;
+ ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
+ *(PTRACE_XFER_TYPE *) &registers[REGISTER_BYTE (regno) + i]);
+ if (errno != 0)
+ {
+ sprintf (buf, "writing register number %d(%d)", regno, i);
+ perror_with_name (buf);
+ }
+ regaddr += sizeof(PTRACE_XFER_TYPE);
}
}
-}
-
-/* Store our register values back into the inferior.
- If REGNO is negative, do this for all registers.
- Otherwise, REGNO specifies which register (so we can save time). */
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- if (regno >= 0)
- {
- store_register (regno);
- }
else
{
- for (regno = 0; regno < ARCH_NUM_REGS; regno++)
+ numregs = ARCH_NUM_REGS;
+ for (regno = 0; regno < numregs; regno++)
{
- store_register (regno);
+ if (CANNOT_STORE_REGISTER (regno))
+ continue;
+ regaddr = register_addr (regno, offset);
+ for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(PTRACE_XFER_TYPE))
+ {
+ errno = 0;
+ ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
+ *(PTRACE_XFER_TYPE *) &registers[REGISTER_BYTE (regno) + i]);
+ if (errno != 0)
+ {
+ sprintf (buf, "writing register number %d(%d)", regno, i);
+ perror_with_name (buf);
+ }
+ regaddr += sizeof(PTRACE_XFER_TYPE);
+ }
}
}
}
@@ -540,7 +442,7 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
ptrace (PT_WRITE_D, inferior_pid, (PTRACE_ARG3_TYPE) addr,
buffer[i]);
if (errno)
- {
+ {
/* Using the appropriate one (I or D) is necessary for
Gould NP1, at least. */
errno = 0;
@@ -550,9 +452,6 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
if (errno)
return 0;
}
-#ifdef CLEAR_INSN_CACHE
- CLEAR_INSN_CACHE();
-#endif
}
else
{
@@ -577,15 +476,11 @@ child_xfer_memory (memaddr, myaddr, len, write, target)
static void
-udot_info (dummy1, dummy2)
- char *dummy1;
- int dummy2;
+udot_info ()
{
-#if defined (KERNEL_U_SIZE)
int udot_off; /* Offset into user struct */
int udot_val; /* Value from user struct at udot_off */
char mess[128]; /* For messages */
-#endif
if (!target_has_execution)
{
diff --git a/contrib/gdb/gdb/irix4-nat.c b/contrib/gdb/gdb/irix4-nat.c
deleted file mode 100644
index 5a6e111..0000000
--- a/contrib/gdb/gdb/irix4-nat.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/* Native support for the SGI Iris running IRIX version 4, for GDB.
- Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1995
- 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.
- Implemented for Irix 4.x by Garrett A. Wollman.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "gdbcore.h"
-
-#include <sys/time.h>
-#include <sys/procfs.h>
-#include <setjmp.h> /* For JB_XXX. */
-
-/* Size of elements in jmpbuf */
-
-#define JB_ELEMENT_SIZE 4
-
-typedef unsigned int greg_t; /* why isn't this defined? */
-
-static void
-fetch_core_registers PARAMS ((char *, unsigned int, int, CORE_ADDR));
-
-/*
- * See the comment in m68k-tdep.c regarding the utility of these functions.
- */
-
-void
-supply_gregset (gregsetp)
- gregset_t *gregsetp;
-{
- register int regi;
- register greg_t *regp = (greg_t *)(gregsetp->gp_regs);
- static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0};
-
- /* FIXME: somewhere, there should be a #define for the meaning
- of this magic number 32; we should use that. */
- for(regi = 0; regi < 32; regi++)
- supply_register (regi, (char *)(regp + regi));
-
- supply_register (PC_REGNUM, (char *)&(gregsetp->gp_pc));
- supply_register (HI_REGNUM, (char *)&(gregsetp->gp_mdhi));
- supply_register (LO_REGNUM, (char *)&(gregsetp->gp_mdlo));
- supply_register (CAUSE_REGNUM, (char *)&(gregsetp->gp_cause));
-
- /* Fill inaccessible registers with zero. */
- supply_register (BADVADDR_REGNUM, zerobuf);
-}
-
-void
-fill_gregset (gregsetp, regno)
- gregset_t *gregsetp;
- int regno;
-{
- int regi;
- register greg_t *regp = (greg_t *)(gregsetp->gp_regs);
-
- /* same FIXME as above wrt 32*/
- for (regi = 0; regi < 32; regi++)
- if ((regno == -1) || (regno == regi))
- *(regp + regi) = *(greg_t *) &registers[REGISTER_BYTE (regi)];
-
- if ((regno == -1) || (regno == PC_REGNUM))
- gregsetp->gp_pc = *(greg_t *) &registers[REGISTER_BYTE (PC_REGNUM)];
-
- if ((regno == -1) || (regno == CAUSE_REGNUM))
- gregsetp->gp_cause = *(greg_t *) &registers[REGISTER_BYTE (CAUSE_REGNUM)];
-
- if ((regno == -1) || (regno == HI_REGNUM))
- gregsetp->gp_mdhi = *(greg_t *) &registers[REGISTER_BYTE (HI_REGNUM)];
-
- if ((regno == -1) || (regno == LO_REGNUM))
- gregsetp->gp_mdlo = *(greg_t *) &registers[REGISTER_BYTE (LO_REGNUM)];
-}
-
-/*
- * Now we do the same thing for floating-point registers.
- * We don't bother to condition on FP0_REGNUM since any
- * reasonable MIPS configuration has an R3010 in it.
- *
- * Again, see the comments in m68k-tdep.c.
- */
-
-void
-supply_fpregset (fpregsetp)
- fpregset_t *fpregsetp;
-{
- register int regi;
- static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0};
-
- for (regi = 0; regi < 32; regi++)
- supply_register (FP0_REGNUM + regi,
- (char *)&fpregsetp->fp_r.fp_regs[regi]);
-
- supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr);
-
- /* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */
- supply_register (FCRIR_REGNUM, zerobuf);
-}
-
-void
-fill_fpregset (fpregsetp, regno)
- fpregset_t *fpregsetp;
- int regno;
-{
- int regi;
- char *from, *to;
-
- for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++)
- {
- if ((regno == -1) || (regno == regi))
- {
- from = (char *) &registers[REGISTER_BYTE (regi)];
- to = (char *) &(fpregsetp->fp_r.fp_regs[regi - FP0_REGNUM]);
- memcpy(to, from, REGISTER_RAW_SIZE (regi));
- }
- }
-
- if ((regno == -1) || (regno == FCRCS_REGNUM))
- fpregsetp->fp_csr = *(unsigned *) &registers[REGISTER_BYTE(FCRCS_REGNUM)];
-}
-
-
-/* Figure out where the longjmp will land.
- We expect the first arg to be a pointer to the jmp_buf structure from which
- we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
- This routine returns true on success. */
-
-int
-get_longjmp_target (pc)
- CORE_ADDR *pc;
-{
- char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
- CORE_ADDR jb_addr;
-
- jb_addr = read_register (A0_REGNUM);
-
- if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf,
- TARGET_PTR_BIT / TARGET_CHAR_BIT))
- return 0;
-
- *pc = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
-
- return 1;
-}
-
-static void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which; /* Unused */
- CORE_ADDR reg_addr; /* Unused */
-{
- if (core_reg_size != REGISTER_BYTES)
- {
- warning ("wrong size gregset struct in core file");
- return;
- }
-
- memcpy ((char *)registers, core_reg_sect, core_reg_size);
-}
-
-
-/* Register that we are able to handle irix4 core file formats.
- FIXME: is this really bfd_target_unknown_flavour? */
-
-static struct core_fns irix4_core_fns =
-{
- bfd_target_unknown_flavour,
- fetch_core_registers,
- NULL
-};
-
-void
-_initialize_core_irix4 ()
-{
- add_core_fns (&irix4_core_fns);
-}
diff --git a/contrib/gdb/gdb/irix5-nat.c b/contrib/gdb/gdb/irix5-nat.c
deleted file mode 100644
index b3373a9..0000000
--- a/contrib/gdb/gdb/irix5-nat.c
+++ /dev/null
@@ -1,1349 +0,0 @@
-/* Native support for the SGI Iris running IRIX version 5, for GDB.
- Copyright 1988, 89, 90, 91, 92, 93, 94, 95, 96, 98, 1999
- 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.
- Implemented for Irix 4.x by Garrett A. Wollman.
- Modified for Irix 5.x by Ian Lance Taylor.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "gdbcore.h"
-#include "target.h"
-
-#include "gdb_string.h"
-#include <sys/time.h>
-#include <sys/procfs.h>
-#include <setjmp.h> /* For JB_XXX. */
-
-static void
-fetch_core_registers PARAMS ((char *, unsigned int, int, CORE_ADDR));
-
-/* Size of elements in jmpbuf */
-
-#define JB_ELEMENT_SIZE 4
-
-/*
- * See the comment in m68k-tdep.c regarding the utility of these functions.
- *
- * These definitions are from the MIPS SVR4 ABI, so they may work for
- * any MIPS SVR4 target.
- */
-
-void
-supply_gregset (gregsetp)
- gregset_t *gregsetp;
-{
- register int regi;
- register greg_t *regp = &(*gregsetp)[0];
- int gregoff = sizeof (greg_t) - MIPS_REGSIZE;
- static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0};
-
- for(regi = 0; regi <= CTX_RA; regi++)
- supply_register (regi, (char *)(regp + regi) + gregoff);
-
- supply_register (PC_REGNUM, (char *)(regp + CTX_EPC) + gregoff);
- supply_register (HI_REGNUM, (char *)(regp + CTX_MDHI) + gregoff);
- supply_register (LO_REGNUM, (char *)(regp + CTX_MDLO) + gregoff);
- supply_register (CAUSE_REGNUM, (char *)(regp + CTX_CAUSE) + gregoff);
-
- /* Fill inaccessible registers with zero. */
- supply_register (BADVADDR_REGNUM, zerobuf);
-}
-
-void
-fill_gregset (gregsetp, regno)
- gregset_t *gregsetp;
- int regno;
-{
- int regi;
- register greg_t *regp = &(*gregsetp)[0];
-
- /* Under Irix6, if GDB is built with N32 ABI and is debugging an O32
- executable, we have to sign extend the registers to 64 bits before
- filling in the gregset structure. */
-
- for (regi = 0; regi <= CTX_RA; regi++)
- if ((regno == -1) || (regno == regi))
- *(regp + regi) =
- extract_signed_integer (&registers[REGISTER_BYTE (regi)],
- REGISTER_RAW_SIZE (regi));
-
- if ((regno == -1) || (regno == PC_REGNUM))
- *(regp + CTX_EPC) =
- extract_signed_integer (&registers[REGISTER_BYTE (PC_REGNUM)],
- REGISTER_RAW_SIZE (PC_REGNUM));
-
- if ((regno == -1) || (regno == CAUSE_REGNUM))
- *(regp + CTX_CAUSE) =
- extract_signed_integer (&registers[REGISTER_BYTE (CAUSE_REGNUM)],
- REGISTER_RAW_SIZE (CAUSE_REGNUM));
-
- if ((regno == -1) || (regno == HI_REGNUM))
- *(regp + CTX_MDHI) =
- extract_signed_integer (&registers[REGISTER_BYTE (HI_REGNUM)],
- REGISTER_RAW_SIZE (HI_REGNUM));
-
- if ((regno == -1) || (regno == LO_REGNUM))
- *(regp + CTX_MDLO) =
- extract_signed_integer (&registers[REGISTER_BYTE (LO_REGNUM)],
- REGISTER_RAW_SIZE (LO_REGNUM));
-}
-
-/*
- * Now we do the same thing for floating-point registers.
- * We don't bother to condition on FP0_REGNUM since any
- * reasonable MIPS configuration has an R3010 in it.
- *
- * Again, see the comments in m68k-tdep.c.
- */
-
-void
-supply_fpregset (fpregsetp)
- fpregset_t *fpregsetp;
-{
- register int regi;
- static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0};
-
- /* FIXME, this is wrong for the N32 ABI which has 64 bit FP regs. */
-
- for (regi = 0; regi < 32; regi++)
- supply_register (FP0_REGNUM + regi,
- (char *)&fpregsetp->fp_r.fp_regs[regi]);
-
- supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr);
-
- /* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */
- supply_register (FCRIR_REGNUM, zerobuf);
-}
-
-void
-fill_fpregset (fpregsetp, regno)
- fpregset_t *fpregsetp;
- int regno;
-{
- int regi;
- char *from, *to;
-
- /* FIXME, this is wrong for the N32 ABI which has 64 bit FP regs. */
-
- for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++)
- {
- if ((regno == -1) || (regno == regi))
- {
- from = (char *) &registers[REGISTER_BYTE (regi)];
- to = (char *) &(fpregsetp->fp_r.fp_regs[regi - FP0_REGNUM]);
- memcpy(to, from, REGISTER_RAW_SIZE (regi));
- }
- }
-
- if ((regno == -1) || (regno == FCRCS_REGNUM))
- fpregsetp->fp_csr = *(unsigned *) &registers[REGISTER_BYTE(FCRCS_REGNUM)];
-}
-
-
-/* Figure out where the longjmp will land.
- We expect the first arg to be a pointer to the jmp_buf structure from which
- we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
- This routine returns true on success. */
-
-int
-get_longjmp_target (pc)
- CORE_ADDR *pc;
-{
- char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
- CORE_ADDR jb_addr;
-
- jb_addr = read_register (A0_REGNUM);
-
- if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf,
- TARGET_PTR_BIT / TARGET_CHAR_BIT))
- return 0;
-
- *pc = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
-
- return 1;
-}
-
-static void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which; /* Unused */
- CORE_ADDR reg_addr; /* Unused */
-{
- if (core_reg_size == REGISTER_BYTES)
- {
- memcpy ((char *)registers, core_reg_sect, core_reg_size);
- }
- else if (MIPS_REGSIZE == 4 &&
- core_reg_size == (2 * MIPS_REGSIZE) * NUM_REGS)
- {
- /* This is a core file from a N32 executable, 64 bits are saved
- for all registers. */
- char *srcp = core_reg_sect;
- char *dstp = registers;
- int regno;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- if (regno >= FP0_REGNUM && regno < (FP0_REGNUM + 32))
- {
- /* FIXME, this is wrong, N32 has 64 bit FP regs, but GDB
- currently assumes that they are 32 bit. */
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- if (REGISTER_RAW_SIZE(regno) == 4)
- {
- /* copying 4 bytes from eight bytes?
- I don't see how this can be right... */
- srcp += 4;
- }
- else
- {
- /* copy all 8 bytes (sizeof(double)) */
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- }
- }
- else
- {
- srcp += 4;
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- *dstp++ = *srcp++;
- }
- }
- }
- else
- {
- warning ("wrong size gregset struct in core file");
- return;
- }
-
- registers_fetched ();
-}
-
-/* Irix 5 uses what appears to be a unique form of shared library
- support. This is a copy of solib.c modified for Irix 5. */
-/* FIXME: Most of this code could be merged with osfsolib.c and solib.c
- by using next_link_map_member and xfer_link_map_member in solib.c. */
-
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/param.h>
-#include <fcntl.h>
-
-/* <obj.h> includes <sym.h> and <symconst.h>, which causes conflicts
- with our versions of those files included by tm-mips.h. Prevent
- <obj.h> from including them with some appropriate defines. */
-#define __SYM_H__
-#define __SYMCONST_H__
-#include <obj.h>
-#ifdef HAVE_OBJLIST_H
-#include <objlist.h>
-#endif
-
-#ifdef NEW_OBJ_INFO_MAGIC
-#define HANDLE_NEW_OBJ_LIST
-#endif
-
-#include "symtab.h"
-#include "bfd.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "command.h"
-#include "frame.h"
-#include "gnu-regex.h"
-#include "inferior.h"
-#include "language.h"
-#include "gdbcmd.h"
-
-/* The symbol which starts off the list of shared libraries. */
-#define DEBUG_BASE "__rld_obj_head"
-
-/* Irix 6.x introduces a new variant of object lists.
- To be able to debug O32 executables under Irix 6, we have to handle both
- variants. */
-
-typedef enum
-{
- OBJ_LIST_OLD, /* Pre Irix 6.x object list. */
- OBJ_LIST_32, /* 32 Bit Elf32_Obj_Info. */
- OBJ_LIST_64 /* 64 Bit Elf64_Obj_Info, FIXME not yet implemented. */
-} obj_list_variant;
-
-/* Define our own link_map structure.
- This will help to share code with osfsolib.c and solib.c. */
-
-struct link_map {
- obj_list_variant l_variant; /* which variant of object list */
- CORE_ADDR l_lladdr; /* addr in inferior list was read from */
- CORE_ADDR l_next; /* address of next object list entry */
-};
-
-/* Irix 5 shared objects are pre-linked to particular addresses
- although the dynamic linker may have to relocate them if the
- address ranges of the libraries used by the main program clash.
- The offset is the difference between the address where the object
- is mapped and the binding address of the shared library. */
-#define LM_OFFSET(so) ((so) -> offset)
-/* Loaded address of shared library. */
-#define LM_ADDR(so) ((so) -> lmstart)
-
-char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
-
-struct so_list {
- struct so_list *next; /* next structure in linked list */
- struct link_map lm;
- CORE_ADDR offset; /* prelink to load address offset */
- char *so_name; /* shared object lib name */
- CORE_ADDR lmstart; /* lower addr bound of mapped object */
- CORE_ADDR lmend; /* upper addr bound of mapped object */
- char symbols_loaded; /* flag: symbols read in yet? */
- char from_tty; /* flag: print msgs? */
- struct objfile *objfile; /* objfile for loaded lib */
- struct section_table *sections;
- struct section_table *sections_end;
- struct section_table *textsection;
- bfd *abfd;
-};
-
-static struct so_list *so_list_head; /* List of known shared objects */
-static CORE_ADDR debug_base; /* Base of dynamic linker structures */
-static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
-
-/* Local function prototypes */
-
-static void
-sharedlibrary_command PARAMS ((char *, int));
-
-static int
-enable_break PARAMS ((void));
-
-static int
-disable_break PARAMS ((void));
-
-static void
-info_sharedlibrary_command PARAMS ((char *, int));
-
-static int
-symbol_add_stub PARAMS ((char *));
-
-static struct so_list *
-find_solib PARAMS ((struct so_list *));
-
-static struct link_map *
-first_link_map_member PARAMS ((void));
-
-static struct link_map *
-next_link_map_member PARAMS ((struct so_list *));
-
-static void
-xfer_link_map_member PARAMS ((struct so_list *, struct link_map *));
-
-static CORE_ADDR
-locate_base PARAMS ((void));
-
-static int
-solib_map_sections PARAMS ((char *));
-
-/*
-
-LOCAL FUNCTION
-
- solib_map_sections -- open bfd and build sections for shared lib
-
-SYNOPSIS
-
- static int solib_map_sections (struct so_list *so)
-
-DESCRIPTION
-
- Given a pointer to one of the shared objects in our list
- of mapped objects, use the recorded name to open a bfd
- descriptor for the object, build a section table, and then
- relocate all the section addresses by the base address at
- which the shared object was mapped.
-
-FIXMES
-
- In most (all?) cases the shared object file name recorded in the
- dynamic linkage tables will be a fully qualified pathname. For
- cases where it isn't, do we really mimic the systems search
- mechanism correctly in the below code (particularly the tilde
- expansion stuff?).
- */
-
-static int
-solib_map_sections (arg)
- char *arg;
-{
- struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */
- char *filename;
- char *scratch_pathname;
- int scratch_chan;
- struct section_table *p;
- struct cleanup *old_chain;
- bfd *abfd;
-
- filename = tilde_expand (so -> so_name);
- old_chain = 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);
- }
- /* Leave scratch_pathname allocated. abfd->name will point to it. */
-
- abfd = bfd_fdopenr (scratch_pathname, gnutarget, scratch_chan);
- if (!abfd)
- {
- close (scratch_chan);
- error ("Could not open `%s' as an executable file: %s",
- scratch_pathname, bfd_errmsg (bfd_get_error ()));
- }
- /* Leave bfd open, core_xfer_memory and "info files" need it. */
- so -> abfd = abfd;
- abfd -> cacheable = true;
-
- if (!bfd_check_format (abfd, bfd_object))
- {
- error ("\"%s\": not in executable format: %s.",
- scratch_pathname, bfd_errmsg (bfd_get_error ()));
- }
- if (build_section_table (abfd, &so -> sections, &so -> sections_end))
- {
- error ("Can't find the file sections in `%s': %s",
- bfd_get_filename (exec_bfd), bfd_errmsg (bfd_get_error ()));
- }
-
- for (p = so -> sections; p < so -> sections_end; p++)
- {
- /* Relocate the section binding addresses as recorded in the shared
- object's file by the offset to get the address to which the
- object was actually mapped. */
- p -> addr += LM_OFFSET (so);
- p -> endaddr += LM_OFFSET (so);
- so -> lmend = (CORE_ADDR) max (p -> endaddr, so -> lmend);
- if (STREQ (p -> the_bfd_section -> name, ".text"))
- {
- so -> textsection = p;
- }
- }
-
- /* Free the file names, close the file now. */
- do_cleanups (old_chain);
-
- return (1);
-}
-
-/*
-
-LOCAL FUNCTION
-
- locate_base -- locate the base address of dynamic linker structs
-
-SYNOPSIS
-
- CORE_ADDR locate_base (void)
-
-DESCRIPTION
-
- For both the SunOS and SVR4 shared library implementations, if the
- inferior executable has been linked dynamically, there is a single
- address somewhere in the inferior's data space which is the key to
- locating all of the dynamic linker's runtime structures. This
- address is the value of the symbol defined by the macro DEBUG_BASE.
- The job of this function is to find and return that address, or to
- return 0 if there is no such address (the executable is statically
- linked for example).
-
- For SunOS, the job is almost trivial, since the dynamic linker and
- all of it's structures are statically linked to the executable at
- link time. Thus the symbol for the address we are looking for has
- already been added to the minimal symbol table for the executable's
- objfile at the time the symbol file's symbols were read, and all we
- have to do is look it up there. Note that we explicitly do NOT want
- to find the copies in the shared library.
-
- The SVR4 version is much more complicated because the dynamic linker
- and it's structures are located in the shared C library, which gets
- run as the executable's "interpreter" by the kernel. We have to go
- to a lot more work to discover the address of DEBUG_BASE. Because
- of this complexity, we cache the value we find and return that value
- on subsequent invocations. Note there is no copy in the executable
- symbol tables.
-
- Irix 5 is basically like SunOS.
-
- Note that we can assume nothing about the process state at the time
- we need to find this address. We may be stopped on the first instruc-
- tion of the interpreter (C shared library), the first instruction of
- the executable itself, or somewhere else entirely (if we attached
- to the process for example).
-
- */
-
-static CORE_ADDR
-locate_base ()
-{
- struct minimal_symbol *msymbol;
- CORE_ADDR address = 0;
-
- msymbol = lookup_minimal_symbol (DEBUG_BASE, NULL, symfile_objfile);
- if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
- {
- address = SYMBOL_VALUE_ADDRESS (msymbol);
- }
- return (address);
-}
-
-/*
-
-LOCAL FUNCTION
-
- first_link_map_member -- locate first member in dynamic linker's map
-
-SYNOPSIS
-
- static struct link_map *first_link_map_member (void)
-
-DESCRIPTION
-
- Read in a copy of the first member in the inferior's dynamic
- link map from the inferior's dynamic linker structures, and return
- a pointer to the link map descriptor.
-*/
-
-static struct link_map *
-first_link_map_member ()
-{
- struct obj_list *listp;
- struct obj_list list_old;
- struct link_map *lm;
- static struct link_map first_lm;
- CORE_ADDR lladdr;
- CORE_ADDR next_lladdr;
-
- /* We have not already read in the dynamic linking structures
- from the inferior, lookup the address of the base structure. */
- debug_base = locate_base ();
- if (debug_base == 0)
- return NULL;
-
- /* Get address of first list entry. */
- read_memory (debug_base, (char *) &listp, sizeof (struct obj_list *));
-
- if (listp == NULL)
- return NULL;
-
- /* Get first list entry. */
- lladdr = (CORE_ADDR) listp;
- read_memory (lladdr, (char *) &list_old, sizeof (struct obj_list));
-
- /* The first entry in the list is the object file we are debugging,
- so skip it. */
- next_lladdr = (CORE_ADDR) list_old.next;
-
-#ifdef HANDLE_NEW_OBJ_LIST
- if (list_old.data == NEW_OBJ_INFO_MAGIC)
- {
- Elf32_Obj_Info list_32;
-
- read_memory (lladdr, (char *) &list_32, sizeof (Elf32_Obj_Info));
- if (list_32.oi_size != sizeof (Elf32_Obj_Info))
- return NULL;
- next_lladdr = (CORE_ADDR) list_32.oi_next;
- }
-#endif
-
- if (next_lladdr == 0)
- return NULL;
-
- first_lm.l_lladdr = next_lladdr;
- lm = &first_lm;
- return lm;
-}
-
-/*
-
-LOCAL FUNCTION
-
- next_link_map_member -- locate next member in dynamic linker's map
-
-SYNOPSIS
-
- static struct link_map *next_link_map_member (so_list_ptr)
-
-DESCRIPTION
-
- Read in a copy of the next member in the inferior's dynamic
- link map from the inferior's dynamic linker structures, and return
- a pointer to the link map descriptor.
-*/
-
-static struct link_map *
-next_link_map_member (so_list_ptr)
- struct so_list *so_list_ptr;
-{
- struct link_map *lm = &so_list_ptr -> lm;
- CORE_ADDR next_lladdr = lm -> l_next;
- static struct link_map next_lm;
-
- if (next_lladdr == 0)
- {
- /* We have hit the end of the list, so check to see if any were
- added, but be quiet if we can't read from the target any more. */
- int status = 0;
-
- if (lm -> l_variant == OBJ_LIST_OLD)
- {
- struct obj_list list_old;
-
- status = target_read_memory (lm -> l_lladdr,
- (char *) &list_old,
- sizeof (struct obj_list));
- next_lladdr = (CORE_ADDR) list_old.next;
- }
-#ifdef HANDLE_NEW_OBJ_LIST
- else if (lm -> l_variant == OBJ_LIST_32)
- {
- Elf32_Obj_Info list_32;
- status = target_read_memory (lm -> l_lladdr,
- (char *) &list_32,
- sizeof (Elf32_Obj_Info));
- next_lladdr = (CORE_ADDR) list_32.oi_next;
- }
-#endif
-
- if (status != 0 || next_lladdr == 0)
- return NULL;
- }
-
- next_lm.l_lladdr = next_lladdr;
- lm = &next_lm;
- return lm;
-}
-
-/*
-
-LOCAL FUNCTION
-
- xfer_link_map_member -- set local variables from dynamic linker's map
-
-SYNOPSIS
-
- static void xfer_link_map_member (so_list_ptr, lm)
-
-DESCRIPTION
-
- Read in a copy of the requested member in the inferior's dynamic
- link map from the inferior's dynamic linker structures, and fill
- in the necessary so_list_ptr elements.
-*/
-
-static void
-xfer_link_map_member (so_list_ptr, lm)
- struct so_list *so_list_ptr;
- struct link_map *lm;
-{
- struct obj_list list_old;
- CORE_ADDR lladdr = lm -> l_lladdr;
- struct link_map *new_lm = &so_list_ptr -> lm;
- int errcode;
-
- read_memory (lladdr, (char *) &list_old, sizeof (struct obj_list));
-
- new_lm -> l_variant = OBJ_LIST_OLD;
- new_lm -> l_lladdr = lladdr;
- new_lm -> l_next = (CORE_ADDR) list_old.next;
-
-#ifdef HANDLE_NEW_OBJ_LIST
- if (list_old.data == NEW_OBJ_INFO_MAGIC)
- {
- Elf32_Obj_Info list_32;
-
- read_memory (lladdr, (char *) &list_32, sizeof (Elf32_Obj_Info));
- if (list_32.oi_size != sizeof (Elf32_Obj_Info))
- return;
- new_lm -> l_variant = OBJ_LIST_32;
- new_lm -> l_next = (CORE_ADDR) list_32.oi_next;
-
- target_read_string ((CORE_ADDR) list_32.oi_pathname,
- &so_list_ptr -> so_name,
- list_32.oi_pathname_len + 1, &errcode);
- if (errcode != 0)
- memory_error (errcode, (CORE_ADDR) list_32.oi_pathname);
-
- LM_ADDR (so_list_ptr) = (CORE_ADDR) list_32.oi_ehdr;
- LM_OFFSET (so_list_ptr) =
- (CORE_ADDR) list_32.oi_ehdr - (CORE_ADDR) list_32.oi_orig_ehdr;
- }
- else
-#endif
- {
-#if defined (_MIPS_SIM_NABI32) && _MIPS_SIM == _MIPS_SIM_NABI32
- /* If we are compiling GDB under N32 ABI, the alignments in
- the obj struct are different from the O32 ABI and we will get
- wrong values when accessing the struct.
- As a workaround we use fixed values which are good for
- Irix 6.2. */
- char buf[432];
-
- read_memory ((CORE_ADDR) list_old.data, buf, sizeof (buf));
-
- target_read_string (extract_address (&buf[236], 4),
- &so_list_ptr -> so_name,
- INT_MAX, &errcode);
- if (errcode != 0)
- memory_error (errcode, extract_address (&buf[236], 4));
-
- LM_ADDR (so_list_ptr) = extract_address (&buf[196], 4);
- LM_OFFSET (so_list_ptr) =
- extract_address (&buf[196], 4) - extract_address (&buf[248], 4);
-#else
- struct obj obj_old;
-
- read_memory ((CORE_ADDR) list_old.data, (char *) &obj_old,
- sizeof (struct obj));
-
- target_read_string ((CORE_ADDR) obj_old.o_path,
- &so_list_ptr -> so_name,
- INT_MAX, &errcode);
- if (errcode != 0)
- memory_error (errcode, (CORE_ADDR) obj_old.o_path);
-
- LM_ADDR (so_list_ptr) = (CORE_ADDR) obj_old.o_praw;
- LM_OFFSET (so_list_ptr) =
- (CORE_ADDR) obj_old.o_praw - obj_old.o_base_address;
-#endif
- }
-
- catch_errors (solib_map_sections, (char *) so_list_ptr,
- "Error while mapping shared library sections:\n",
- RETURN_MASK_ALL);
-}
-
-
-/*
-
-LOCAL FUNCTION
-
- find_solib -- step through list of shared objects
-
-SYNOPSIS
-
- struct so_list *find_solib (struct so_list *so_list_ptr)
-
-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.
- */
-
-static struct so_list *
-find_solib (so_list_ptr)
- struct so_list *so_list_ptr; /* Last lm or NULL for first one */
-{
- struct so_list *so_list_next = NULL;
- struct link_map *lm = NULL;
- struct so_list *new;
-
- if (so_list_ptr == NULL)
- {
- /* We are setting up for a new scan through the loaded images. */
- if ((so_list_next = so_list_head) == NULL)
- {
- /* Find the first link map list member. */
- lm = first_link_map_member ();
- }
- }
- else
- {
- /* We have been called before, and are in the process of walking
- the shared library list. Advance to the next shared object. */
- lm = next_link_map_member (so_list_ptr);
- so_list_next = so_list_ptr -> next;
- }
- if ((so_list_next == NULL) && (lm != NULL))
- {
- new = (struct so_list *) xmalloc (sizeof (struct so_list));
- memset ((char *) new, 0, sizeof (struct so_list));
- /* Add the new node as the next node in the list, or as the root
- node if this is the first one. */
- if (so_list_ptr != NULL)
- {
- so_list_ptr -> next = new;
- }
- else
- {
- so_list_head = new;
- }
- so_list_next = new;
- xfer_link_map_member (new, lm);
- }
- 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 */
- CORE_ADDR text_addr = 0;
-
- if (so -> textsection)
- text_addr = so -> textsection -> addr;
- else if (so -> abfd != NULL)
- {
- asection *lowest_sect;
-
- /* If we didn't find a mapped non zero sized .text section, set up
- text_addr so that the relocation in symbol_file_add does no harm. */
-
- lowest_sect = bfd_get_section_by_name (so -> abfd, ".text");
- if (lowest_sect == NULL)
- bfd_map_over_sections (so -> abfd, find_lowest_section,
- (PTR) &lowest_sect);
- if (lowest_sect)
- text_addr = bfd_section_vma (so -> abfd, lowest_sect) + LM_OFFSET (so);
- }
-
- so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
- text_addr,
- 0, 0, 0, 0, 0);
- return (1);
-}
-
-/*
-
-GLOBAL FUNCTION
-
- solib_add -- add a shared library file to the symtab and section list
-
-SYNOPSIS
-
- void solib_add (char *arg_string, int from_tty,
- struct target_ops *target)
-
-DESCRIPTION
-
-*/
-
-void
-solib_add (arg_string, from_tty, target)
- char *arg_string;
- int from_tty;
- struct target_ops *target;
-{
- register struct so_list *so = NULL; /* link map state variable */
-
- /* Last shared library that we read. */
- struct so_list *so_last = NULL;
-
- char *re_err;
- int count;
- int old;
-
- if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
- {
- error ("Invalid regexp: %s", re_err);
- }
-
- /* 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 = NULL;
- count = 0;
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- count += so -> sections_end - so -> sections;
- }
- }
-
- if (count)
- {
- int update_coreops;
-
- /* We must update the to_sections field in the core_ops structure
- here, otherwise we dereference a potential dangling pointer
- for each call to target_read/write_memory within this routine. */
- update_coreops = core_ops.to_sections == target->to_sections;
-
- /* Reallocate the target's section table including the new size. */
- if (target -> to_sections)
- {
- old = target -> to_sections_end - target -> to_sections;
- target -> to_sections = (struct section_table *)
- xrealloc ((char *)target -> to_sections,
- (sizeof (struct section_table)) * (count + old));
- }
- else
- {
- old = 0;
- target -> to_sections = (struct section_table *)
- xmalloc ((sizeof (struct section_table)) * count);
- }
- target -> to_sections_end = target -> to_sections + (count + old);
-
- /* Update the to_sections field in the core_ops structure
- if needed. */
- if (update_coreops)
- {
- core_ops.to_sections = target->to_sections;
- core_ops.to_sections_end = target->to_sections_end;
- }
-
- /* Add these section table entries to the target's table. */
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- count = so -> sections_end - so -> sections;
- memcpy ((char *) (target -> to_sections + old),
- so -> sections,
- (sizeof (struct section_table)) * count);
- old += count;
- }
- }
- }
- }
-
- /* Now add the symbol files. */
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0] && re_exec (so -> so_name))
- {
- so -> from_tty = from_tty;
- if (so -> symbols_loaded)
- {
- if (from_tty)
- {
- printf_unfiltered ("Symbols already loaded for %s\n", so -> so_name);
- }
- }
- else if (catch_errors
- (symbol_add_stub, (char *) so,
- "Error while reading shared library symbols:\n",
- RETURN_MASK_ALL))
- {
- so_last = so;
- so -> symbols_loaded = 1;
- }
- }
- }
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- if (so_last)
- reinit_frame_cache ();
-}
-
-/*
-
-LOCAL FUNCTION
-
- info_sharedlibrary_command -- code for "info sharedlibrary"
-
-SYNOPSIS
-
- static void info_sharedlibrary_command ()
-
-DESCRIPTION
-
- Walk through the shared library list and print information
- about each attached library.
-*/
-
-static void
-info_sharedlibrary_command (ignore, from_tty)
- char *ignore;
- int from_tty;
-{
- register struct so_list *so = NULL; /* link map state variable */
- int header_done = 0;
-
- if (exec_bfd == NULL)
- {
- printf_unfiltered ("No exec file.\n");
- return;
- }
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- if (!header_done)
- {
- printf_unfiltered("%-12s%-12s%-12s%s\n", "From", "To", "Syms Read",
- "Shared Object Library");
- header_done++;
- }
- printf_unfiltered ("%-12s",
- local_hex_string_custom ((unsigned long) LM_ADDR (so),
- "08l"));
- printf_unfiltered ("%-12s",
- local_hex_string_custom ((unsigned long) so -> lmend,
- "08l"));
- printf_unfiltered ("%-12s", so -> symbols_loaded ? "Yes" : "No");
- printf_unfiltered ("%s\n", so -> so_name);
- }
- }
- if (so_list_head == NULL)
- {
- printf_unfiltered ("No shared libraries loaded at this time.\n");
- }
-}
-
-/*
-
-GLOBAL FUNCTION
-
- solib_address -- check to see if an address is in a shared lib
-
-SYNOPSIS
-
- char *solib_address (CORE_ADDR address)
-
-DESCRIPTION
-
- Provides a hook for other gdb routines to discover whether or
- not a particular address is within the mapped address space of
- a shared library. Any address between the base mapping address
- and the first address beyond the end of the last mapping, is
- considered to be within the shared library address space, for
- our purposes.
-
- For example, this routine is called at one point to disable
- breakpoints which are in shared libraries that are not currently
- mapped in.
- */
-
-char *
-solib_address (address)
- CORE_ADDR address;
-{
- register struct so_list *so = 0; /* link map state variable */
-
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- if ((address >= (CORE_ADDR) LM_ADDR (so)) &&
- (address < (CORE_ADDR) so -> lmend))
- return (so->so_name);
- }
- }
- return (0);
-}
-
-/* Called by free_all_symtabs */
-
-void
-clear_solib()
-{
- struct so_list *next;
- char *bfd_filename;
-
- disable_breakpoints_in_shlibs (1);
-
- while (so_list_head)
- {
- if (so_list_head -> sections)
- {
- free ((PTR)so_list_head -> sections);
- }
- if (so_list_head -> abfd)
- {
- bfd_filename = bfd_get_filename (so_list_head -> abfd);
- if (!bfd_close (so_list_head -> abfd))
- warning ("cannot close \"%s\": %s",
- bfd_filename, bfd_errmsg (bfd_get_error ()));
- }
- else
- /* This happens for the executable on SVR4. */
- bfd_filename = NULL;
-
- next = so_list_head -> next;
- if (bfd_filename)
- free ((PTR)bfd_filename);
- free (so_list_head->so_name);
- free ((PTR)so_list_head);
- so_list_head = next;
- }
- debug_base = 0;
-}
-
-/*
-
-LOCAL FUNCTION
-
- disable_break -- remove the "mapping changed" breakpoint
-
-SYNOPSIS
-
- static int disable_break ()
-
-DESCRIPTION
-
- Removes the breakpoint that gets hit when the dynamic linker
- completes a mapping change.
-
-*/
-
-static int
-disable_break ()
-{
- int status = 1;
-
-
- /* Note that breakpoint address and original contents are in our address
- space, so we just need to write the original contents back. */
-
- if (memory_remove_breakpoint (breakpoint_addr, shadow_contents) != 0)
- {
- status = 0;
- }
-
- /* For the SVR4 version, we always know the breakpoint address. For the
- SunOS version we don't know it until the above code is executed.
- Grumble if we are stopped anywhere besides the breakpoint address. */
-
- if (stop_pc != breakpoint_addr)
- {
- warning ("stopped at unknown breakpoint while handling shared libraries");
- }
-
- return (status);
-}
-
-/*
-
-LOCAL FUNCTION
-
- enable_break -- arrange for dynamic linker to hit breakpoint
-
-SYNOPSIS
-
- int enable_break (void)
-
-DESCRIPTION
-
- This functions inserts a breakpoint at the entry point of the
- main executable, where all shared libraries are mapped in.
-*/
-
-static int
-enable_break ()
-{
- if (symfile_objfile != NULL
- && target_insert_breakpoint (symfile_objfile->ei.entry_point,
- shadow_contents) == 0)
- {
- breakpoint_addr = symfile_objfile->ei.entry_point;
- return 1;
- }
-
- return 0;
-}
-
-/*
-
-GLOBAL FUNCTION
-
- solib_create_inferior_hook -- shared library startup support
-
-SYNOPSIS
-
- void solib_create_inferior_hook()
-
-DESCRIPTION
-
- When gdb starts up the inferior, it nurses it along (through the
- shell) until it is ready to execute it's first instruction. At this
- point, this function gets called via expansion of the macro
- SOLIB_CREATE_INFERIOR_HOOK.
-
- For SunOS executables, this first instruction is typically the
- one at "_start", or a similar text label, regardless of whether
- the executable is statically or dynamically linked. The runtime
- startup code takes care of dynamically linking in any shared
- libraries, once gdb allows the inferior to continue.
-
- For SVR4 executables, this first instruction is either the first
- instruction in the dynamic linker (for dynamically linked
- executables) or the instruction at "start" for statically linked
- executables. For dynamically linked executables, the system
- first exec's /lib/libc.so.N, which contains the dynamic linker,
- and starts it running. The dynamic linker maps in any needed
- shared libraries, maps in the actual user executable, and then
- jumps to "start" in the user executable.
-
- For both SunOS shared libraries, and SVR4 shared libraries, we
- can arrange to cooperate with the dynamic linker to discover the
- names of shared libraries that are dynamically linked, and the
- base addresses to which they are linked.
-
- This function is responsible for discovering those names and
- addresses, and saving sufficient information about them to allow
- their symbols to be read at a later time.
-
-FIXME
-
- Between enable_break() and disable_break(), this code does not
- properly handle hitting breakpoints which the user might have
- set in the startup code or in the dynamic linker itself. Proper
- handling will probably have to wait until the implementation is
- changed to use the "breakpoint handler function" method.
-
- Also, what if child has exit()ed? Must exit loop somehow.
- */
-
-void
-solib_create_inferior_hook()
-{
- if (!enable_break ())
- {
- warning ("shared library handler failed to enable breakpoint");
- return;
- }
-
- /* Now run the target. It will eventually hit the breakpoint, at
- which point all of the libraries will have been mapped in and we
- can go groveling around in the dynamic linker structures to find
- out what we need to know about them. */
-
- clear_proceed_status ();
- stop_soon_quietly = 1;
- stop_signal = TARGET_SIGNAL_0;
- do
- {
- target_resume (-1, 0, stop_signal);
- wait_for_inferior ();
- }
- while (stop_signal != TARGET_SIGNAL_TRAP);
-
- /* We are now either at the "mapping complete" breakpoint (or somewhere
- else, a condition we aren't prepared to deal with anyway), so adjust
- the PC as necessary after a breakpoint, disable the breakpoint, and
- add any shared libraries that were mapped in. */
-
- if (DECR_PC_AFTER_BREAK)
- {
- stop_pc -= DECR_PC_AFTER_BREAK;
- write_register (PC_REGNUM, stop_pc);
- }
-
- if (!disable_break ())
- {
- warning ("shared library handler failed to disable breakpoint");
- }
-
- /* solib_add will call reinit_frame_cache.
- But we are stopped in the startup code and we might not have symbols
- for the startup code, so heuristic_proc_start could be called
- and will put out an annoying warning.
- Delaying the resetting of stop_soon_quietly until after symbol loading
- suppresses the warning. */
- if (auto_solib_add)
- solib_add ((char *) 0, 0, (struct target_ops *) 0);
- stop_soon_quietly = 0;
-}
-
-/*
-
-LOCAL FUNCTION
-
- sharedlibrary_command -- handle command to explicitly add library
-
-SYNOPSIS
-
- static void sharedlibrary_command (char *args, int from_tty)
-
-DESCRIPTION
-
-*/
-
-static void
-sharedlibrary_command (args, from_tty)
-char *args;
-int from_tty;
-{
- dont_repeat ();
- 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", info_sharedlibrary_command,
- "Status of loaded shared object libraries.");
-
- add_show_from_set
- (add_set_cmd ("auto-solib-add", class_support, var_zinteger,
- (char *) &auto_solib_add,
- "Set autoloading of shared library symbols.\n\
-If nonzero, symbols from all shared object libraries will be loaded\n\
-automatically when the inferior begins execution or when the dynamic linker\n\
-informs gdb that a new library has been loaded. Otherwise, symbols\n\
-must be loaded manually, using `sharedlibrary'.",
- &setlist),
- &showlist);
-}
-
-
-/* Register that we are able to handle irix5 core file formats.
- This really is bfd_target_unknown_flavour */
-
-static struct core_fns irix5_core_fns =
-{
- bfd_target_unknown_flavour,
- fetch_core_registers,
- NULL
-};
-
-void
-_initialize_core_irix5 ()
-{
- add_core_fns (&irix5_core_fns);
-}
diff --git a/contrib/gdb/gdb/isi-xdep.c b/contrib/gdb/gdb/isi-xdep.c
deleted file mode 100644
index 8773c83..0000000
--- a/contrib/gdb/gdb/isi-xdep.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <machine/reg.h>
-int rloc[] = {
- R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, FP, SP, PS, PC
-};
diff --git a/contrib/gdb/gdb/kdb-start.c b/contrib/gdb/gdb/kdb-start.c
deleted file mode 100644
index bec558f..0000000
--- a/contrib/gdb/gdb/kdb-start.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Main loop for the standalone kernel debugger, for GDB, the GNU Debugger.
- Copyright 1989, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-static char *args[] = {"kdb", "kdb-symbols", 0};
-
-static char *environment[] = {0};
-
-char **environ;
-
-start ()
-{
- INIT_STACK (kdb_stack_beg, kdb_stack_end);
-
- environ = environment;
-
- main (2, args, environment);
-}
diff --git a/contrib/gdb/gdb/lynx-nat.c b/contrib/gdb/gdb/lynx-nat.c
deleted file mode 100644
index f006aa4..0000000
--- a/contrib/gdb/gdb/lynx-nat.c
+++ /dev/null
@@ -1,837 +0,0 @@
-/* Native-dependent code for LynxOS.
- Copyright 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "target.h"
-#include "gdbcore.h"
-
-#include <sys/ptrace.h>
-#include <sys/wait.h>
-#include <sys/fpp.h>
-
-static unsigned long registers_addr PARAMS ((int pid));
-static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR);
-
-#define X(ENTRY)(offsetof(struct econtext, ENTRY))
-
-#ifdef I386
-/* Mappings from tm-i386v.h */
-
-static int regmap[] =
-{
- X(eax),
- X(ecx),
- X(edx),
- X(ebx),
- X(esp), /* sp */
- X(ebp), /* fp */
- X(esi),
- X(edi),
- X(eip), /* pc */
- X(flags), /* ps */
- X(cs),
- X(ss),
- X(ds),
- X(es),
- X(ecode), /* Lynx doesn't give us either fs or gs, so */
- X(fault), /* we just substitute these two in the hopes
- that they are useful. */
-};
-#endif /* I386 */
-
-#ifdef M68K
-/* Mappings from tm-m68k.h */
-
-static int regmap[] =
-{
- X(regs[0]), /* d0 */
- X(regs[1]), /* d1 */
- X(regs[2]), /* d2 */
- X(regs[3]), /* d3 */
- X(regs[4]), /* d4 */
- X(regs[5]), /* d5 */
- X(regs[6]), /* d6 */
- X(regs[7]), /* d7 */
- X(regs[8]), /* a0 */
- X(regs[9]), /* a1 */
- X(regs[10]), /* a2 */
- X(regs[11]), /* a3 */
- X(regs[12]), /* a4 */
- X(regs[13]), /* a5 */
- X(regs[14]), /* fp */
- offsetof (st_t, usp) - offsetof (st_t, ec), /* sp */
- X(status), /* ps */
- X(pc),
-
- X(fregs[0*3]), /* fp0 */
- X(fregs[1*3]), /* fp1 */
- X(fregs[2*3]), /* fp2 */
- X(fregs[3*3]), /* fp3 */
- X(fregs[4*3]), /* fp4 */
- X(fregs[5*3]), /* fp5 */
- X(fregs[6*3]), /* fp6 */
- X(fregs[7*3]), /* fp7 */
-
- X(fcregs[0]), /* fpcontrol */
- X(fcregs[1]), /* fpstatus */
- X(fcregs[2]), /* fpiaddr */
- X(ssw), /* fpcode */
- X(fault), /* fpflags */
-};
-#endif /* M68K */
-
-#ifdef SPARC
-/* Mappings from tm-sparc.h */
-
-#define FX(ENTRY)(offsetof(struct fcontext, ENTRY))
-
-static int regmap[] =
-{
- -1, /* g0 */
- X(g1),
- X(g2),
- X(g3),
- X(g4),
- -1, /* g5->g7 aren't saved by Lynx */
- -1,
- -1,
-
- X(o[0]),
- X(o[1]),
- X(o[2]),
- X(o[3]),
- X(o[4]),
- X(o[5]),
- X(o[6]), /* sp */
- X(o[7]), /* ra */
-
- -1,-1,-1,-1,-1,-1,-1,-1, /* l0 -> l7 */
-
- -1,-1,-1,-1,-1,-1,-1,-1, /* i0 -> i7 */
-
- FX(f.fregs[0]), /* f0 */
- FX(f.fregs[1]),
- FX(f.fregs[2]),
- FX(f.fregs[3]),
- FX(f.fregs[4]),
- FX(f.fregs[5]),
- FX(f.fregs[6]),
- FX(f.fregs[7]),
- FX(f.fregs[8]),
- FX(f.fregs[9]),
- FX(f.fregs[10]),
- FX(f.fregs[11]),
- FX(f.fregs[12]),
- FX(f.fregs[13]),
- FX(f.fregs[14]),
- FX(f.fregs[15]),
- FX(f.fregs[16]),
- FX(f.fregs[17]),
- FX(f.fregs[18]),
- FX(f.fregs[19]),
- FX(f.fregs[20]),
- FX(f.fregs[21]),
- FX(f.fregs[22]),
- FX(f.fregs[23]),
- FX(f.fregs[24]),
- FX(f.fregs[25]),
- FX(f.fregs[26]),
- FX(f.fregs[27]),
- FX(f.fregs[28]),
- FX(f.fregs[29]),
- FX(f.fregs[30]),
- FX(f.fregs[31]),
-
- X(y),
- X(psr),
- X(wim),
- X(tbr),
- X(pc),
- X(npc),
- FX(fsr), /* fpsr */
- -1, /* cpsr */
-};
-#endif /* SPARC */
-
-#ifdef rs6000
-
-static int regmap[] =
-{
- X(iregs[0]), /* r0 */
- X(iregs[1]),
- X(iregs[2]),
- X(iregs[3]),
- X(iregs[4]),
- X(iregs[5]),
- X(iregs[6]),
- X(iregs[7]),
- X(iregs[8]),
- X(iregs[9]),
- X(iregs[10]),
- X(iregs[11]),
- X(iregs[12]),
- X(iregs[13]),
- X(iregs[14]),
- X(iregs[15]),
- X(iregs[16]),
- X(iregs[17]),
- X(iregs[18]),
- X(iregs[19]),
- X(iregs[20]),
- X(iregs[21]),
- X(iregs[22]),
- X(iregs[23]),
- X(iregs[24]),
- X(iregs[25]),
- X(iregs[26]),
- X(iregs[27]),
- X(iregs[28]),
- X(iregs[29]),
- X(iregs[30]),
- X(iregs[31]),
-
- X(fregs[0]), /* f0 */
- X(fregs[1]),
- X(fregs[2]),
- X(fregs[3]),
- X(fregs[4]),
- X(fregs[5]),
- X(fregs[6]),
- X(fregs[7]),
- X(fregs[8]),
- X(fregs[9]),
- X(fregs[10]),
- X(fregs[11]),
- X(fregs[12]),
- X(fregs[13]),
- X(fregs[14]),
- X(fregs[15]),
- X(fregs[16]),
- X(fregs[17]),
- X(fregs[18]),
- X(fregs[19]),
- X(fregs[20]),
- X(fregs[21]),
- X(fregs[22]),
- X(fregs[23]),
- X(fregs[24]),
- X(fregs[25]),
- X(fregs[26]),
- X(fregs[27]),
- X(fregs[28]),
- X(fregs[29]),
- X(fregs[30]),
- X(fregs[31]),
-
- X(srr0), /* IAR (PC) */
- X(srr1), /* MSR (PS) */
- X(cr), /* CR */
- X(lr), /* LR */
- X(ctr), /* CTR */
- X(xer), /* XER */
- X(mq) /* MQ */
-};
-
-#endif /* rs6000 */
-
-#ifdef SPARC
-
-/* This routine handles some oddball cases for Sparc registers and LynxOS.
- In partucular, it causes refs to G0, g5->7, and all fp regs to return zero.
- It also handles knows where to find the I & L regs on the stack. */
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- int whatregs = 0;
-
-#define WHATREGS_FLOAT 1
-#define WHATREGS_GEN 2
-#define WHATREGS_STACK 4
-
- if (regno == -1)
- whatregs = WHATREGS_FLOAT | WHATREGS_GEN | WHATREGS_STACK;
- else if (regno >= L0_REGNUM && regno <= I7_REGNUM)
- whatregs = WHATREGS_STACK;
- else if (regno >= FP0_REGNUM && regno < FP0_REGNUM + 32)
- whatregs = WHATREGS_FLOAT;
- else
- whatregs = WHATREGS_GEN;
-
- if (whatregs & WHATREGS_GEN)
- {
- struct econtext ec; /* general regs */
- char buf[MAX_REGISTER_RAW_SIZE];
- int retval;
- int i;
-
- errno = 0;
- retval = ptrace (PTRACE_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &ec,
- 0);
- if (errno)
- perror_with_name ("ptrace(PTRACE_GETREGS)");
-
- memset (buf, 0, REGISTER_RAW_SIZE (G0_REGNUM));
- supply_register (G0_REGNUM, buf);
- supply_register (TBR_REGNUM, (char *)&ec.tbr);
-
- memcpy (&registers[REGISTER_BYTE (G1_REGNUM)], &ec.g1,
- 4 * REGISTER_RAW_SIZE (G1_REGNUM));
- for (i = G1_REGNUM; i <= G1_REGNUM + 3; i++)
- register_valid[i] = 1;
-
- supply_register (PS_REGNUM, (char *)&ec.psr);
- supply_register (Y_REGNUM, (char *)&ec.y);
- supply_register (PC_REGNUM, (char *)&ec.pc);
- supply_register (NPC_REGNUM, (char *)&ec.npc);
- supply_register (WIM_REGNUM, (char *)&ec.wim);
-
- memcpy (&registers[REGISTER_BYTE (O0_REGNUM)], ec.o,
- 8 * REGISTER_RAW_SIZE (O0_REGNUM));
- for (i = O0_REGNUM; i <= O0_REGNUM + 7; i++)
- register_valid[i] = 1;
- }
-
- if (whatregs & WHATREGS_STACK)
- {
- CORE_ADDR sp;
- int i;
-
- sp = read_register (SP_REGNUM);
-
- target_xfer_memory (sp + FRAME_SAVED_I0,
- &registers[REGISTER_BYTE(I0_REGNUM)],
- 8 * REGISTER_RAW_SIZE (I0_REGNUM), 0);
- for (i = I0_REGNUM; i <= I7_REGNUM; i++)
- register_valid[i] = 1;
-
- target_xfer_memory (sp + FRAME_SAVED_L0,
- &registers[REGISTER_BYTE(L0_REGNUM)],
- 8 * REGISTER_RAW_SIZE (L0_REGNUM), 0);
- for (i = L0_REGNUM; i <= L0_REGNUM + 7; i++)
- register_valid[i] = 1;
- }
-
- if (whatregs & WHATREGS_FLOAT)
- {
- struct fcontext fc; /* fp regs */
- int retval;
- int i;
-
- errno = 0;
- retval = ptrace (PTRACE_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) &fc,
- 0);
- if (errno)
- perror_with_name ("ptrace(PTRACE_GETFPREGS)");
-
- memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], fc.f.fregs,
- 32 * REGISTER_RAW_SIZE (FP0_REGNUM));
- for (i = FP0_REGNUM; i <= FP0_REGNUM + 31; i++)
- register_valid[i] = 1;
-
- supply_register (FPS_REGNUM, (char *)&fc.fsr);
- }
-}
-
-/* This routine handles storing of the I & L regs for the Sparc. The trick
- here is that they actually live on the stack. The really tricky part is
- that when changing the stack pointer, the I & L regs must be written to
- where the new SP points, otherwise the regs will be incorrect when the
- process is started up again. We assume that the I & L regs are valid at
- this point. */
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- int whatregs = 0;
-
- if (regno == -1)
- whatregs = WHATREGS_FLOAT | WHATREGS_GEN | WHATREGS_STACK;
- else if (regno >= L0_REGNUM && regno <= I7_REGNUM)
- whatregs = WHATREGS_STACK;
- else if (regno >= FP0_REGNUM && regno < FP0_REGNUM + 32)
- whatregs = WHATREGS_FLOAT;
- else if (regno == SP_REGNUM)
- whatregs = WHATREGS_STACK | WHATREGS_GEN;
- else
- whatregs = WHATREGS_GEN;
-
- if (whatregs & WHATREGS_GEN)
- {
- struct econtext ec; /* general regs */
- int retval;
-
- ec.tbr = read_register (TBR_REGNUM);
- memcpy (&ec.g1, &registers[REGISTER_BYTE (G1_REGNUM)],
- 4 * REGISTER_RAW_SIZE (G1_REGNUM));
-
- ec.psr = read_register (PS_REGNUM);
- ec.y = read_register (Y_REGNUM);
- ec.pc = read_register (PC_REGNUM);
- ec.npc = read_register (NPC_REGNUM);
- ec.wim = read_register (WIM_REGNUM);
-
- memcpy (ec.o, &registers[REGISTER_BYTE (O0_REGNUM)],
- 8 * REGISTER_RAW_SIZE (O0_REGNUM));
-
- errno = 0;
- retval = ptrace (PTRACE_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &ec,
- 0);
- if (errno)
- perror_with_name ("ptrace(PTRACE_SETREGS)");
- }
-
- if (whatregs & WHATREGS_STACK)
- {
- int regoffset;
- CORE_ADDR sp;
-
- sp = read_register (SP_REGNUM);
-
- if (regno == -1 || regno == SP_REGNUM)
- {
- if (!register_valid[L0_REGNUM+5])
- abort();
- target_xfer_memory (sp + FRAME_SAVED_I0,
- &registers[REGISTER_BYTE (I0_REGNUM)],
- 8 * REGISTER_RAW_SIZE (I0_REGNUM), 1);
-
- target_xfer_memory (sp + FRAME_SAVED_L0,
- &registers[REGISTER_BYTE (L0_REGNUM)],
- 8 * REGISTER_RAW_SIZE (L0_REGNUM), 1);
- }
- else if (regno >= L0_REGNUM && regno <= I7_REGNUM)
- {
- if (!register_valid[regno])
- abort();
- if (regno >= L0_REGNUM && regno <= L0_REGNUM + 7)
- regoffset = REGISTER_BYTE (regno) - REGISTER_BYTE (L0_REGNUM)
- + FRAME_SAVED_L0;
- else
- regoffset = REGISTER_BYTE (regno) - REGISTER_BYTE (I0_REGNUM)
- + FRAME_SAVED_I0;
- target_xfer_memory (sp + regoffset, &registers[REGISTER_BYTE (regno)],
- REGISTER_RAW_SIZE (regno), 1);
- }
- }
-
- if (whatregs & WHATREGS_FLOAT)
- {
- struct fcontext fc; /* fp regs */
- int retval;
-
-/* We read fcontext first so that we can get good values for fq_t... */
- errno = 0;
- retval = ptrace (PTRACE_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) &fc,
- 0);
- if (errno)
- perror_with_name ("ptrace(PTRACE_GETFPREGS)");
-
- memcpy (fc.f.fregs, &registers[REGISTER_BYTE (FP0_REGNUM)],
- 32 * REGISTER_RAW_SIZE (FP0_REGNUM));
-
- fc.fsr = read_register (FPS_REGNUM);
-
- errno = 0;
- retval = ptrace (PTRACE_SETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) &fc,
- 0);
- if (errno)
- perror_with_name ("ptrace(PTRACE_SETFPREGS)");
- }
-}
-#endif /* SPARC */
-
-#if defined (I386) || defined (M68K) || defined (rs6000)
-
-/* Return the offset relative to the start of the per-thread data to the
- saved context block. */
-
-static unsigned long
-registers_addr(pid)
- int pid;
-{
- CORE_ADDR stblock;
- int ecpoff = offsetof(st_t, ecp);
- CORE_ADDR ecp;
-
- errno = 0;
- stblock = (CORE_ADDR) ptrace (PTRACE_THREADUSER, pid, (PTRACE_ARG3_TYPE)0,
- 0);
- if (errno)
- perror_with_name ("ptrace(PTRACE_THREADUSER)");
-
- ecp = (CORE_ADDR) ptrace (PTRACE_PEEKTHREAD, pid, (PTRACE_ARG3_TYPE)ecpoff,
- 0);
- if (errno)
- perror_with_name ("ptrace(PTRACE_PEEKTHREAD)");
-
- return ecp - stblock;
-}
-
-/* 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;
-{
- int reglo, reghi;
- int i;
- unsigned long ecp;
-
- if (regno == -1)
- {
- reglo = 0;
- reghi = NUM_REGS - 1;
- }
- else
- reglo = reghi = regno;
-
- ecp = registers_addr (inferior_pid);
-
- for (regno = reglo; regno <= reghi; regno++)
- {
- char buf[MAX_REGISTER_RAW_SIZE];
- int ptrace_fun = PTRACE_PEEKTHREAD;
-
-#ifdef M68K
- ptrace_fun = regno == SP_REGNUM ? PTRACE_PEEKUSP : PTRACE_PEEKTHREAD;
-#endif
-
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
- {
- unsigned int reg;
-
- errno = 0;
- reg = ptrace (ptrace_fun, inferior_pid,
- (PTRACE_ARG3_TYPE) (ecp + regmap[regno] + i), 0);
- if (errno)
- perror_with_name ("ptrace(PTRACE_PEEKUSP)");
-
- *(int *)&buf[i] = reg;
- }
- 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). */
-
-/* Registers we shouldn't try to store. */
-#if !defined (CANNOT_STORE_REGISTER)
-#define CANNOT_STORE_REGISTER(regno) 0
-#endif
-
-void
-store_inferior_registers (regno)
- int regno;
-{
- int reglo, reghi;
- int i;
- unsigned long ecp;
-
- if (regno == -1)
- {
- reglo = 0;
- reghi = NUM_REGS - 1;
- }
- else
- reglo = reghi = regno;
-
- ecp = registers_addr (inferior_pid);
-
- for (regno = reglo; regno <= reghi; regno++)
- {
- int ptrace_fun = PTRACE_POKEUSER;
-
- if (CANNOT_STORE_REGISTER (regno))
- continue;
-
-#ifdef M68K
- ptrace_fun = regno == SP_REGNUM ? PTRACE_POKEUSP : PTRACE_POKEUSER;
-#endif
-
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
- {
- unsigned int reg;
-
- reg = *(unsigned int *)&registers[REGISTER_BYTE (regno) + i];
-
- errno = 0;
- ptrace (ptrace_fun, inferior_pid,
- (PTRACE_ARG3_TYPE) (ecp + regmap[regno] + i), reg);
- if (errno)
- perror_with_name ("ptrace(PTRACE_POKEUSP)");
- }
- }
-}
-#endif /* defined (I386) || defined (M68K) || defined (rs6000) */
-
-/* Wait for child to do something. Return pid of child, or -1 in case
- of error; store status through argument pointer OURSTATUS. */
-
-int
-child_wait (pid, ourstatus)
- int pid;
- struct target_waitstatus *ourstatus;
-{
- int save_errno;
- int thread;
- union wait status;
-
- while (1)
- {
- int sig;
-
- set_sigint_trap(); /* Causes SIGINT to be passed on to the
- attached process. */
- pid = wait (&status);
-
- save_errno = errno;
-
- clear_sigint_trap();
-
- if (pid == -1)
- {
- if (save_errno == EINTR)
- continue;
- fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing: %s.\n",
- safe_strerror (save_errno));
- /* Claim it exited with unknown signal. */
- ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
- ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
- return -1;
- }
-
- if (pid != PIDGET (inferior_pid)) /* Some other process?!? */
- continue;
-
- thread = status.w_tid; /* Get thread id from status */
-
- /* Initial thread value can only be acquired via wait, so we have to
- resort to this hack. */
-
- if (TIDGET (inferior_pid) == 0 && thread != 0)
- {
- inferior_pid = BUILDPID (inferior_pid, thread);
- add_thread (inferior_pid);
- }
-
- pid = BUILDPID (pid, thread);
-
- /* We've become a single threaded process again. */
- if (thread == 0)
- inferior_pid = pid;
-
- /* Check for thread creation. */
- if (WIFSTOPPED(status)
- && WSTOPSIG(status) == SIGTRAP
- && !in_thread_list (pid))
- {
- int realsig;
-
- realsig = ptrace (PTRACE_GETTRACESIG, pid, (PTRACE_ARG3_TYPE)0, 0);
-
- if (realsig == SIGNEWTHREAD)
- {
- /* It's a new thread notification. We don't want to much with
- realsig -- the code in wait_for_inferior expects SIGTRAP. */
- ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
- ourstatus->value.sig = TARGET_SIGNAL_0;
- return pid;
- }
- else
- error ("Signal for unknown thread was not SIGNEWTHREAD");
- }
-
- /* Check for thread termination. */
- else if (WIFSTOPPED(status)
- && WSTOPSIG(status) == SIGTRAP
- && in_thread_list (pid))
- {
- int realsig;
-
- realsig = ptrace (PTRACE_GETTRACESIG, pid, (PTRACE_ARG3_TYPE)0, 0);
-
- if (realsig == SIGTHREADEXIT)
- {
- ptrace (PTRACE_CONT, PIDGET (pid), (PTRACE_ARG3_TYPE)0, 0);
- continue;
- }
- }
-
-#ifdef SPARC
- /* SPARC Lynx uses an byte reversed wait status; we must use the
- host macros to access it. These lines just a copy of
- store_waitstatus. We can't use CHILD_SPECIAL_WAITSTATUS
- because target.c can't include the Lynx <sys/wait.h>. */
- if (WIFEXITED (status))
- {
- ourstatus->kind = TARGET_WAITKIND_EXITED;
- ourstatus->value.integer = WEXITSTATUS (status);
- }
- else if (!WIFSTOPPED (status))
- {
- ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
- ourstatus->value.sig =
- target_signal_from_host (WTERMSIG (status));
- }
- else
- {
- ourstatus->kind = TARGET_WAITKIND_STOPPED;
- ourstatus->value.sig =
- target_signal_from_host (WSTOPSIG (status));
- }
-#else
- store_waitstatus (ourstatus, status.w_status);
-#endif
-
- return pid;
- }
-}
-
-/* Return nonzero if the given thread is still alive. */
-int
-child_thread_alive (pid)
- int pid;
-{
- /* Arggh. Apparently pthread_kill only works for threads within
- the process that calls pthread_kill.
-
- We want to avoid the lynx signal extensions as they simply don't
- map well to the generic gdb interface we want to keep.
-
- All we want to do is determine if a particular thread is alive;
- it appears as if we can just make a harmless thread specific
- ptrace call to do that. */
- return (ptrace (PTRACE_THREADUSER, pid, 0, 0) != -1);
-}
-
-/* Resume execution of the inferior process.
- If STEP is nonzero, single-step it.
- If SIGNAL is nonzero, give it that signal. */
-
-void
-child_resume (pid, step, signal)
- int pid;
- int step;
- enum target_signal signal;
-{
- int func;
-
- errno = 0;
-
- /* If pid == -1, then we want to step/continue all threads, else
- we only want to step/continue a single thread. */
- if (pid == -1)
- {
- pid = inferior_pid;
- func = step ? PTRACE_SINGLESTEP : PTRACE_CONT;
- }
- else
- func = step ? PTRACE_SINGLESTEP_ONE : PTRACE_CONT_ONE;
-
-
- /* An address of (PTRACE_ARG3_TYPE)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 this system does not support PT_STEP, a higher level function will
- have called single_step() to transmute the step request into a
- continue request (by setting breakpoints on all possible successor
- instructions), so we don't have to worry about that here. */
-
- ptrace (func, pid, (PTRACE_ARG3_TYPE) 1, target_signal_to_host (signal));
-
- if (errno)
- perror_with_name ("ptrace");
-}
-
-/* Convert a Lynx process ID to a string. Returns the string in a static
- buffer. */
-
-char *
-lynx_pid_to_str (pid)
- int pid;
-{
- static char buf[40];
-
- sprintf (buf, "process %d thread %d", PIDGET (pid), TIDGET (pid));
-
- return buf;
-}
-
-/* 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.
- */
-
-static void
-fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR reg_addr;
-{
- struct st_entry s;
- unsigned int regno;
-
- for (regno = 0; regno < NUM_REGS; regno++)
- if (regmap[regno] != -1)
- supply_register (regno, core_reg_sect + offsetof (st_t, ec)
- + regmap[regno]);
-
-#ifdef SPARC
-/* Fetching this register causes all of the I & L regs to be read from the
- stack and validated. */
-
- fetch_inferior_registers (I0_REGNUM);
-#endif
-}
-
-
-/* Register that we are able to handle lynx core file formats.
- FIXME: is this really bfd_target_unknown_flavour? */
-
-static struct core_fns lynx_core_fns =
-{
- bfd_target_unknown_flavour,
- fetch_core_registers,
- NULL
-};
-
-void
-_initialize_core_lynx ()
-{
- add_core_fns (&lynx_core_fns);
-}
diff --git a/contrib/gdb/gdb/m2-exp.tab.c b/contrib/gdb/gdb/m2-exp.tab.c
deleted file mode 100644
index 2bfc681..0000000
--- a/contrib/gdb/gdb/m2-exp.tab.c
+++ /dev/null
@@ -1,2089 +0,0 @@
-
-/* A Bison parser, made from m2-exp.y
- by GNU Bison version 1.25
- */
-
-#define YYBISON 1 /* Identify Bison output. */
-
-#define INT 258
-#define HEX 259
-#define ERROR 260
-#define UINT 261
-#define M2_TRUE 262
-#define M2_FALSE 263
-#define CHAR 264
-#define FLOAT 265
-#define STRING 266
-#define NAME 267
-#define BLOCKNAME 268
-#define IDENT 269
-#define VARNAME 270
-#define TYPENAME 271
-#define SIZE 272
-#define CAP 273
-#define ORD 274
-#define HIGH 275
-#define ABS 276
-#define MIN_FUNC 277
-#define MAX_FUNC 278
-#define FLOAT_FUNC 279
-#define VAL 280
-#define CHR 281
-#define ODD 282
-#define TRUNC 283
-#define INC 284
-#define DEC 285
-#define INCL 286
-#define EXCL 287
-#define COLONCOLON 288
-#define INTERNAL_VAR 289
-#define ABOVE_COMMA 290
-#define ASSIGN 291
-#define LEQ 292
-#define GEQ 293
-#define NOTEQUAL 294
-#define IN 295
-#define OROR 296
-#define LOGICAL_AND 297
-#define DIV 298
-#define MOD 299
-#define UNARY 300
-#define DOT 301
-#define NOT 302
-#define QID 303
-
-#line 40 "m2-exp.y"
-
-
-#include "defs.h"
-#include "gdb_string.h"
-#include "expression.h"
-#include "language.h"
-#include "value.h"
-#include "parser-defs.h"
-#include "m2-lang.h"
-#include "bfd.h" /* Required by objfiles.h. */
-#include "symfile.h" /* Required by objfiles.h. */
-#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
-
-/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
- as well as gratuitiously global symbol names, so we can have multiple
- yacc generated parsers in gdb. Note that these are only the variables
- produced by yacc. If other parser generators (bison, byacc, etc) produce
- additional global names that conflict at link time, then those parser
- generators need to be fixed instead of adding those names to this list. */
-
-#define yymaxdepth m2_maxdepth
-#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 yy_yys m2_yys
-#define yystate m2_state
-#define yytmp m2_tmp
-#define yyv m2_v
-#define yy_yyv m2_yyv
-#define yyval m2_val
-#define yylloc m2_lloc
-#define yyreds m2_reds /* With YYDEBUG defined */
-#define yytoks m2_toks /* With YYDEBUG defined */
-#define yylhs m2_yylhs
-#define yylen m2_yylen
-#define yydefred m2_yydefred
-#define yydgoto m2_yydgoto
-#define yysindex m2_yysindex
-#define yyrindex m2_yyrindex
-#define yygindex m2_yygindex
-#define yytable m2_yytable
-#define yycheck m2_yycheck
-
-#ifndef YYDEBUG
-#define YYDEBUG 0 /* Default to no yydebug support */
-#endif
-
-int
-yyparse PARAMS ((void));
-
-static int
-yylex PARAMS ((void));
-
-void
-yyerror PARAMS ((char *));
-
-#if 0
-static char *
-make_qualname PARAMS ((char *, char *));
-#endif
-
-static int
-parse_number PARAMS ((int));
-
-/* The sign of the number being parsed. */
-static int number_sign = 1;
-
-/* The block that the module specified by the qualifer on an identifer is
- contained in, */
-#if 0
-static struct block *modblock=0;
-#endif
-
-
-#line 135 "m2-exp.y"
-typedef union
- {
- LONGEST lval;
- ULONGEST ulval;
- DOUBLEST 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;
- } YYSTYPE;
-#include <stdio.h>
-
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
-#endif
-#endif
-
-
-
-#define YYFINAL 181
-#define YYFLAG -32768
-#define YYNTBASE 68
-
-#define YYTRANSLATE(x) ((unsigned)(x) <= 303 ? yytranslate[x] : 82)
-
-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, 2, 2, 44, 2, 2, 48, 2, 60,
- 64, 52, 50, 35, 51, 2, 53, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 38,
- 42, 39, 2, 49, 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, 67, 57, 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, 65, 2, 66, 62, 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, 29, 30, 31, 32, 33, 34, 36,
- 37, 40, 41, 43, 45, 46, 47, 54, 55, 56,
- 58, 61, 63
-};
-
-#if YYDEBUG != 0
-static const short yyprhs[] = { 0,
- 0, 2, 4, 6, 9, 10, 14, 17, 20, 22,
- 24, 29, 34, 39, 44, 49, 54, 59, 66, 71,
- 76, 81, 84, 89, 96, 101, 108, 112, 114, 118,
- 125, 132, 136, 141, 142, 148, 149, 155, 156, 158,
- 162, 164, 168, 173, 178, 182, 186, 190, 194, 198,
- 202, 206, 210, 214, 218, 222, 226, 230, 234, 238,
- 242, 246, 250, 252, 254, 256, 258, 260, 262, 264,
- 269, 271, 273, 275, 279, 281, 283, 287, 289
-};
-
-static const short yyrhs[] = { 70,
- 0, 69, 0, 81, 0, 70, 57, 0, 0, 51,
- 71, 70, 0, 50, 70, 0, 72, 70, 0, 61,
- 0, 62, 0, 18, 60, 70, 64, 0, 19, 60,
- 70, 64, 0, 21, 60, 70, 64, 0, 20, 60,
- 70, 64, 0, 22, 60, 81, 64, 0, 23, 60,
- 81, 64, 0, 24, 60, 70, 64, 0, 25, 60,
- 81, 35, 70, 64, 0, 26, 60, 70, 64, 0,
- 27, 60, 70, 64, 0, 28, 60, 70, 64, 0,
- 17, 70, 0, 29, 60, 70, 64, 0, 29, 60,
- 70, 35, 70, 64, 0, 30, 60, 70, 64, 0,
- 30, 60, 70, 35, 70, 64, 0, 70, 58, 12,
- 0, 73, 0, 70, 45, 73, 0, 31, 60, 70,
- 35, 70, 64, 0, 32, 60, 70, 35, 70, 64,
- 0, 65, 76, 66, 0, 81, 65, 76, 66, 0,
- 0, 70, 59, 74, 77, 67, 0, 0, 70, 60,
- 75, 76, 64, 0, 0, 70, 0, 76, 35, 70,
- 0, 70, 0, 77, 35, 70, 0, 65, 81, 66,
- 70, 0, 81, 60, 70, 64, 0, 60, 70, 64,
- 0, 70, 49, 70, 0, 70, 52, 70, 0, 70,
- 53, 70, 0, 70, 54, 70, 0, 70, 55, 70,
- 0, 70, 50, 70, 0, 70, 51, 70, 0, 70,
- 42, 70, 0, 70, 43, 70, 0, 70, 44, 70,
- 0, 70, 40, 70, 0, 70, 41, 70, 0, 70,
- 38, 70, 0, 70, 39, 70, 0, 70, 47, 70,
- 0, 70, 46, 70, 0, 70, 37, 70, 0, 7,
- 0, 8, 0, 3, 0, 6, 0, 9, 0, 10,
- 0, 80, 0, 17, 60, 81, 64, 0, 11, 0,
- 79, 0, 13, 0, 78, 33, 13, 0, 79, 0,
- 34, 0, 78, 33, 12, 0, 12, 0, 16, 0
-};
-
-#endif
-
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
- 204, 205, 208, 217, 220, 222, 227, 231, 235, 236,
- 239, 243, 247, 251, 255, 261, 267, 271, 277, 281,
- 285, 289, 294, 298, 304, 308, 314, 320, 323, 327,
- 331, 334, 336, 342, 347, 353, 357, 363, 366, 370,
- 375, 380, 385, 391, 397, 405, 409, 413, 417, 421,
- 425, 429, 433, 437, 439, 443, 447, 451, 455, 459,
- 463, 467, 474, 480, 486, 493, 502, 510, 517, 520,
- 527, 534, 538, 547, 559, 567, 571, 587, 638
-};
-#endif
-
-
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
-
-static const char * const yytname[] = { "$","error","$undefined.","INT","HEX",
-"ERROR","UINT","M2_TRUE","M2_FALSE","CHAR","FLOAT","STRING","NAME","BLOCKNAME",
-"IDENT","VARNAME","TYPENAME","SIZE","CAP","ORD","HIGH","ABS","MIN_FUNC","MAX_FUNC",
-"FLOAT_FUNC","VAL","CHR","ODD","TRUNC","INC","DEC","INCL","EXCL","COLONCOLON",
-"INTERNAL_VAR","','","ABOVE_COMMA","ASSIGN","'<'","'>'","LEQ","GEQ","'='","NOTEQUAL",
-"'#'","IN","OROR","LOGICAL_AND","'&'","'@'","'+'","'-'","'*'","'/'","DIV","MOD",
-"UNARY","'^'","DOT","'['","'('","NOT","'~'","QID","')'","'{'","'}'","']'","start",
-"type_exp","exp","@1","not_exp","set","@2","@3","arglist","non_empty_arglist",
-"block","fblock","variable","type", NULL
-};
-#endif
-
-static const short yyr1[] = { 0,
- 68, 68, 69, 70, 71, 70, 70, 70, 72, 72,
- 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
- 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
- 70, 73, 73, 74, 70, 75, 70, 76, 76, 76,
- 77, 77, 70, 70, 70, 70, 70, 70, 70, 70,
- 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
- 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
- 70, 78, 79, 79, 80, 80, 80, 80, 81
-};
-
-static const short yyr2[] = { 0,
- 1, 1, 1, 2, 0, 3, 2, 2, 1, 1,
- 4, 4, 4, 4, 4, 4, 4, 6, 4, 4,
- 4, 2, 4, 6, 4, 6, 3, 1, 3, 6,
- 6, 3, 4, 0, 5, 0, 5, 0, 1, 3,
- 1, 3, 4, 4, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 1, 1, 1, 1, 1, 1, 1, 4,
- 1, 1, 1, 3, 1, 1, 3, 1, 1
-};
-
-static const short yydefact[] = { 0,
- 65, 66, 63, 64, 67, 68, 71, 78, 73, 79,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 76, 0, 5, 0,
- 9, 10, 38, 2, 1, 0, 28, 0, 75, 69,
- 3, 0, 22, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 7,
- 0, 0, 39, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 4, 0, 34, 36, 8, 0, 0,
- 38, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 6, 45, 0,
- 32, 0, 62, 58, 59, 56, 57, 53, 54, 55,
- 38, 29, 0, 61, 60, 46, 51, 52, 47, 48,
- 49, 50, 27, 0, 38, 77, 74, 0, 0, 70,
- 11, 12, 14, 13, 15, 16, 17, 0, 19, 20,
- 21, 0, 23, 0, 25, 0, 0, 40, 43, 41,
- 0, 0, 44, 33, 0, 0, 0, 0, 0, 0,
- 35, 37, 18, 24, 26, 30, 31, 42, 0, 0,
- 0
-};
-
-static const short yydefgoto[] = { 179,
- 34, 63, 61, 36, 37, 134, 135, 64, 161, 38,
- 39, 40, 44
-};
-
-static const short yypact[] = { 155,
--32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
- 215, -27, -22, -20, -19, 14, 24, 26, 27, 28,
- 29, 31, 32, 33, 35, 36,-32768, 155,-32768, 155,
--32768,-32768, 155,-32768, 742, 155,-32768, -6, -4,-32768,
- -34, 155, 5, -34, 155, 155, 155, 155, 44, 44,
- 155, 44, 155, 155, 155, 155, 155, 155, 155, 5,
- 155, 272, 742, -31, -41, 155, 155, 155, 155, 155,
- 155, 155, 155, -15, 155, 155, 155, 155, 155, 155,
- 155, 155, 155,-32768, 85,-32768,-32768, 5, -5, 155,
- 155, -21, 300, 328, 356, 384, 34, 39, 412, 64,
- 440, 468, 496, 78, 244, 692, 718, 5,-32768, 155,
--32768, 155, 766, -37, -37, -37, -37, -37, -37, -37,
- 155,-32768, 40, 141, 201, 777, 786, 786, 5, 5,
- 5, 5,-32768, 155, 155,-32768,-32768, 524, -29,-32768,
--32768,-32768,-32768,-32768,-32768,-32768,-32768, 155,-32768,-32768,
--32768, 155,-32768, 155,-32768, 155, 155, 742, 5, 742,
- -33, -32,-32768,-32768, 552, 580, 608, 636, 664, 155,
--32768,-32768,-32768,-32768,-32768,-32768,-32768, 742, 100, 106,
--32768
-};
-
-static const short yypgoto[] = {-32768,
--32768, 0,-32768,-32768, 37,-32768,-32768, -86,-32768,-32768,
--32768,-32768, 52
-};
-
-
-#define YYLAST 846
-
-
-static const short yytable[] = { 35,
- 10, 170, 110, 110, 139, 110, 136, 137, 75, 76,
- 43, 77, 78, 79, 80, 81, 82, 83, 90, 84,
- 85, 86, 87, 91, 112, 90, 89, 60, -72, 62,
- 91, 172, 45, 171, 111, 88, 164, 46, 90, 47,
- 48, 62, 140, 91, 93, 94, 95, 96, 162, 121,
- 99, 41, 101, 102, 103, 104, 105, 106, 107, 10,
- 108, 84, 85, 86, 87, 113, 114, 115, 116, 117,
- 118, 119, 120, 49, 124, 125, 126, 127, 128, 129,
- 130, 131, 132, 50, 65, 51, 52, 53, 54, 138,
- 55, 56, 57, 92, 58, 59, 133, 145, 148, 180,
- 97, 98, 146, 100, 91, 181, 0, 0, 0, 158,
- 122, 159, 152, 0, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 123, 77, 78, 79, 80,
- 81, 82, 83, 160, 84, 85, 86, 87, 0, 0,
- 0, 153, 0, 0, 0, 0, 0, 165, 0, 0,
- 0, 166, 0, 167, 0, 168, 169, 1, 0, 0,
- 2, 3, 4, 5, 6, 7, 8, 9, 0, 178,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 76, 27, 77,
- 78, 79, 80, 81, 82, 83, 0, 84, 85, 86,
- 87, 0, 0, 0, 28, 29, 0, 0, 0, 0,
- 0, 0, 0, 0, 30, 31, 32, 1, 0, 33,
- 2, 3, 4, 5, 6, 7, 8, 9, 0, 0,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 0, 27, 77,
- 78, 79, 80, 81, 82, 83, 0, 84, 85, 86,
- 87, 0, 0, 0, 28, 29, 0, 0, 0, 0,
- 0, 0, 0, 0, 42, 31, 32, 0, 154, 33,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 0, 77, 78, 79, 80, 81, 82, 83, 0,
- 84, 85, 86, 87, 0, 0, 0, 155, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 0,
- 77, 78, 79, 80, 81, 82, 83, 0, 84, 85,
- 86, 87, 0, 0, 0, 109, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 0, 77, 78,
- 79, 80, 81, 82, 83, 0, 84, 85, 86, 87,
- 0, 0, 0, 141, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 0, 77, 78, 79, 80,
- 81, 82, 83, 0, 84, 85, 86, 87, 0, 0,
- 0, 142, 66, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 76, 0, 77, 78, 79, 80, 81, 82,
- 83, 0, 84, 85, 86, 87, 0, 0, 0, 143,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 0, 77, 78, 79, 80, 81, 82, 83, 0,
- 84, 85, 86, 87, 0, 0, 0, 144, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 0,
- 77, 78, 79, 80, 81, 82, 83, 0, 84, 85,
- 86, 87, 0, 0, 0, 147, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 0, 77, 78,
- 79, 80, 81, 82, 83, 0, 84, 85, 86, 87,
- 0, 0, 0, 149, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 0, 77, 78, 79, 80,
- 81, 82, 83, 0, 84, 85, 86, 87, 0, 0,
- 0, 150, 66, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 76, 0, 77, 78, 79, 80, 81, 82,
- 83, 0, 84, 85, 86, 87, 0, 0, 0, 151,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 0, 77, 78, 79, 80, 81, 82, 83, 0,
- 84, 85, 86, 87, 0, 0, 0, 163, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 0,
- 77, 78, 79, 80, 81, 82, 83, 0, 84, 85,
- 86, 87, 0, 0, 0, 173, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 0, 77, 78,
- 79, 80, 81, 82, 83, 0, 84, 85, 86, 87,
- 0, 0, 0, 174, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 0, 77, 78, 79, 80,
- 81, 82, 83, 0, 84, 85, 86, 87, 0, 0,
- 0, 175, 66, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 76, 0, 77, 78, 79, 80, 81, 82,
- 83, 0, 84, 85, 86, 87, 0, 0, 0, 176,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 0, 77, 78, 79, 80, 81, 82, 83, 0,
- 84, 85, 86, 87, 0, 0, 156, 177, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 0,
- 77, 78, 79, 80, 81, 82, 83, 0, 84, 85,
- 86, 87, 157, 0, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 0, 77, 78, 79, 80,
- 81, 82, 83, 0, 84, 85, 86, 87, 66, 67,
- 68, 69, 70, 71, 72, 73, 74, 75, 76, 0,
- 77, 78, 79, 80, 81, 82, 83, 0, 84, 85,
- 86, 87,-32768, 67, 68, 69, 70, 71, 72, 73,
- 74, 75, 76, 0, 77, 78, 79, 80, 81, 82,
- 83, 0, 84, 85, 86, 87, 78, 79, 80, 81,
- 82, 83, 0, 84, 85, 86, 87, 80, 81, 82,
- 83, 0, 84, 85, 86, 87
-};
-
-static const short yycheck[] = { 0,
- 16, 35, 35, 35, 91, 35, 12, 13, 46, 47,
- 11, 49, 50, 51, 52, 53, 54, 55, 60, 57,
- 58, 59, 60, 65, 66, 60, 33, 28, 33, 30,
- 65, 64, 60, 67, 66, 36, 66, 60, 60, 60,
- 60, 42, 64, 65, 45, 46, 47, 48, 135, 65,
- 51, 0, 53, 54, 55, 56, 57, 58, 59, 16,
- 61, 57, 58, 59, 60, 66, 67, 68, 69, 70,
- 71, 72, 73, 60, 75, 76, 77, 78, 79, 80,
- 81, 82, 83, 60, 33, 60, 60, 60, 60, 90,
- 60, 60, 60, 42, 60, 60, 12, 64, 35, 0,
- 49, 50, 64, 52, 65, 0, -1, -1, -1, 110,
- 74, 112, 35, -1, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 74, 49, 50, 51, 52,
- 53, 54, 55, 134, 57, 58, 59, 60, -1, -1,
- -1, 64, -1, -1, -1, -1, -1, 148, -1, -1,
- -1, 152, -1, 154, -1, 156, 157, 3, -1, -1,
- 6, 7, 8, 9, 10, 11, 12, 13, -1, 170,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, 47, 34, 49,
- 50, 51, 52, 53, 54, 55, -1, 57, 58, 59,
- 60, -1, -1, -1, 50, 51, -1, -1, -1, -1,
- -1, -1, -1, -1, 60, 61, 62, 3, -1, 65,
- 6, 7, 8, 9, 10, 11, 12, 13, -1, -1,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, -1, 34, 49,
- 50, 51, 52, 53, 54, 55, -1, 57, 58, 59,
- 60, -1, -1, -1, 50, 51, -1, -1, -1, -1,
- -1, -1, -1, -1, 60, 61, 62, -1, 35, 65,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, -1, 49, 50, 51, 52, 53, 54, 55, -1,
- 57, 58, 59, 60, -1, -1, -1, 64, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, -1,
- 49, 50, 51, 52, 53, 54, 55, -1, 57, 58,
- 59, 60, -1, -1, -1, 64, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, -1, 49, 50,
- 51, 52, 53, 54, 55, -1, 57, 58, 59, 60,
- -1, -1, -1, 64, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, -1, 49, 50, 51, 52,
- 53, 54, 55, -1, 57, 58, 59, 60, -1, -1,
- -1, 64, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, -1, 49, 50, 51, 52, 53, 54,
- 55, -1, 57, 58, 59, 60, -1, -1, -1, 64,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, -1, 49, 50, 51, 52, 53, 54, 55, -1,
- 57, 58, 59, 60, -1, -1, -1, 64, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, -1,
- 49, 50, 51, 52, 53, 54, 55, -1, 57, 58,
- 59, 60, -1, -1, -1, 64, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, -1, 49, 50,
- 51, 52, 53, 54, 55, -1, 57, 58, 59, 60,
- -1, -1, -1, 64, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, -1, 49, 50, 51, 52,
- 53, 54, 55, -1, 57, 58, 59, 60, -1, -1,
- -1, 64, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, -1, 49, 50, 51, 52, 53, 54,
- 55, -1, 57, 58, 59, 60, -1, -1, -1, 64,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, -1, 49, 50, 51, 52, 53, 54, 55, -1,
- 57, 58, 59, 60, -1, -1, -1, 64, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, -1,
- 49, 50, 51, 52, 53, 54, 55, -1, 57, 58,
- 59, 60, -1, -1, -1, 64, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, -1, 49, 50,
- 51, 52, 53, 54, 55, -1, 57, 58, 59, 60,
- -1, -1, -1, 64, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, -1, 49, 50, 51, 52,
- 53, 54, 55, -1, 57, 58, 59, 60, -1, -1,
- -1, 64, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, -1, 49, 50, 51, 52, 53, 54,
- 55, -1, 57, 58, 59, 60, -1, -1, -1, 64,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, -1, 49, 50, 51, 52, 53, 54, 55, -1,
- 57, 58, 59, 60, -1, -1, 35, 64, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, -1,
- 49, 50, 51, 52, 53, 54, 55, -1, 57, 58,
- 59, 60, 35, -1, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, -1, 49, 50, 51, 52,
- 53, 54, 55, -1, 57, 58, 59, 60, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, -1,
- 49, 50, 51, 52, 53, 54, 55, -1, 57, 58,
- 59, 60, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, -1, 49, 50, 51, 52, 53, 54,
- 55, -1, 57, 58, 59, 60, 50, 51, 52, 53,
- 54, 55, -1, 57, 58, 59, 60, 52, 53, 54,
- 55, -1, 57, 58, 59, 60
-};
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/stone/jimb/main-98r2/share/bison.simple"
-
-/* Skeleton output parser for bison,
- Copyright (C) 1984, 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, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-#ifndef alloca
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
-#include <alloca.h>
-#else /* not sparc */
-#if defined (MSDOS) && !defined (__TURBOC__)
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
- #pragma alloca
-#else /* not MSDOS, __TURBOC__, or _AIX */
-#ifdef __hpux
-#ifdef __cplusplus
-extern "C" {
-void *alloca (unsigned int);
-};
-#else /* not __cplusplus */
-void *alloca ();
-#endif /* not __cplusplus */
-#endif /* __hpux */
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#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
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval, &yylloc)
-#endif
-#else /* not YYLSP_NEEDED */
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval)
-#endif
-#endif /* not YYLSP_NEEDED */
-#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
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-int yyparse (void);
-#endif
-
-#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
-#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
-#else /* not GNU C or C++ */
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (to, from, count)
- char *to;
- char *from;
- 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_memcpy (char *to, char *from, int count)
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#endif
-#endif
-
-#line 196 "/stone/jimb/main-98r2/share/bison.simple"
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
-
-#ifdef YYPARSE_PARAM
-#ifdef __cplusplus
-#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL
-#else /* not __cplusplus */
-#define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-#endif /* not __cplusplus */
-#else /* not YYPARSE_PARAM */
-#define YYPARSE_PARAM_ARG
-#define YYPARSE_PARAM_DECL
-#endif /* not YYPARSE_PARAM */
-
-int
-yyparse(YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
-{
- 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 = 0; /* 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 xreallocate them elsewhere */
-
-#ifdef YYLSP_NEEDED
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
-
-#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
-#else
-#define YYPOPSTACK (yyvsp--, yyssp--)
-#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.
- The wasted elements are never initialized. */
-
- 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 xreallocate 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. */
-#ifdef YYLSP_NEEDED
- /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro. */
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yyls1, size * sizeof (*yylsp),
- &yystacksize);
-#else
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yystacksize);
-#endif
-
- 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_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
- yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1, 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
-
- goto yybackup;
- 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", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
-#ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
-#endif
- fprintf (stderr, ")\n");
- }
-#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];
- if (yylen > 0)
- 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 symbols 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 209 "m2-exp.y"
-{ write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type(yyvsp[0].tval);
- write_exp_elt_opcode(OP_TYPE);
- ;
- break;}
-case 4:
-#line 218 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_IND); ;
- break;}
-case 5:
-#line 221 "m2-exp.y"
-{ number_sign = -1; ;
- break;}
-case 6:
-#line 223 "m2-exp.y"
-{ number_sign = 1;
- write_exp_elt_opcode (UNOP_NEG); ;
- break;}
-case 7:
-#line 228 "m2-exp.y"
-{ write_exp_elt_opcode(UNOP_PLUS); ;
- break;}
-case 8:
-#line 232 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); ;
- break;}
-case 11:
-#line 240 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_CAP); ;
- break;}
-case 12:
-#line 244 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_ORD); ;
- break;}
-case 13:
-#line 248 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_ABS); ;
- break;}
-case 14:
-#line 252 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_HIGH); ;
- break;}
-case 15:
-#line 256 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_MIN);
- write_exp_elt_type (yyvsp[-1].tval);
- write_exp_elt_opcode (UNOP_MIN); ;
- break;}
-case 16:
-#line 262 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_MAX);
- write_exp_elt_type (yyvsp[-1].tval);
- write_exp_elt_opcode (UNOP_MIN); ;
- break;}
-case 17:
-#line 268 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_FLOAT); ;
- break;}
-case 18:
-#line 272 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_VAL);
- write_exp_elt_type (yyvsp[-3].tval);
- write_exp_elt_opcode (BINOP_VAL); ;
- break;}
-case 19:
-#line 278 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_CHR); ;
- break;}
-case 20:
-#line 282 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_ODD); ;
- break;}
-case 21:
-#line 286 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_TRUNC); ;
- break;}
-case 22:
-#line 290 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_SIZEOF); ;
- break;}
-case 23:
-#line 295 "m2-exp.y"
-{ write_exp_elt_opcode(UNOP_PREINCREMENT); ;
- break;}
-case 24:
-#line 299 "m2-exp.y"
-{ write_exp_elt_opcode(BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode(BINOP_ADD);
- write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); ;
- break;}
-case 25:
-#line 305 "m2-exp.y"
-{ write_exp_elt_opcode(UNOP_PREDECREMENT);;
- break;}
-case 26:
-#line 309 "m2-exp.y"
-{ write_exp_elt_opcode(BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode(BINOP_SUB);
- write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); ;
- break;}
-case 27:
-#line 315 "m2-exp.y"
-{ write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string (yyvsp[0].sval);
- write_exp_elt_opcode (STRUCTOP_STRUCT); ;
- break;}
-case 29:
-#line 324 "m2-exp.y"
-{ error("Sets are not implemented.");;
- break;}
-case 30:
-#line 328 "m2-exp.y"
-{ error("Sets are not implemented.");;
- break;}
-case 31:
-#line 332 "m2-exp.y"
-{ error("Sets are not implemented.");;
- break;}
-case 32:
-#line 335 "m2-exp.y"
-{ error("Sets are not implemented.");;
- break;}
-case 33:
-#line 337 "m2-exp.y"
-{ error("Sets are not implemented.");;
- break;}
-case 34:
-#line 346 "m2-exp.y"
-{ start_arglist(); ;
- break;}
-case 35:
-#line 348 "m2-exp.y"
-{ write_exp_elt_opcode (MULTI_SUBSCRIPT);
- write_exp_elt_longcst ((LONGEST) end_arglist());
- write_exp_elt_opcode (MULTI_SUBSCRIPT); ;
- break;}
-case 36:
-#line 356 "m2-exp.y"
-{ start_arglist (); ;
- break;}
-case 37:
-#line 358 "m2-exp.y"
-{ write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL); ;
- break;}
-case 39:
-#line 367 "m2-exp.y"
-{ arglist_len = 1; ;
- break;}
-case 40:
-#line 371 "m2-exp.y"
-{ arglist_len++; ;
- break;}
-case 41:
-#line 376 "m2-exp.y"
-{ arglist_len = 1; ;
- break;}
-case 42:
-#line 381 "m2-exp.y"
-{ arglist_len++; ;
- break;}
-case 43:
-#line 386 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_MEMVAL);
- write_exp_elt_type (yyvsp[-2].tval);
- write_exp_elt_opcode (UNOP_MEMVAL); ;
- break;}
-case 44:
-#line 392 "m2-exp.y"
-{ write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (yyvsp[-3].tval);
- write_exp_elt_opcode (UNOP_CAST); ;
- break;}
-case 45:
-#line 398 "m2-exp.y"
-{ ;
- break;}
-case 46:
-#line 406 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_REPEAT); ;
- break;}
-case 47:
-#line 410 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_MUL); ;
- break;}
-case 48:
-#line 414 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_DIV); ;
- break;}
-case 49:
-#line 418 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_INTDIV); ;
- break;}
-case 50:
-#line 422 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_REM); ;
- break;}
-case 51:
-#line 426 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_ADD); ;
- break;}
-case 52:
-#line 430 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_SUB); ;
- break;}
-case 53:
-#line 434 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_EQUAL); ;
- break;}
-case 54:
-#line 438 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_NOTEQUAL); ;
- break;}
-case 55:
-#line 440 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_NOTEQUAL); ;
- break;}
-case 56:
-#line 444 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_LEQ); ;
- break;}
-case 57:
-#line 448 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_GEQ); ;
- break;}
-case 58:
-#line 452 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_LESS); ;
- break;}
-case 59:
-#line 456 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_GTR); ;
- break;}
-case 60:
-#line 460 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_LOGICAL_AND); ;
- break;}
-case 61:
-#line 464 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_LOGICAL_OR); ;
- break;}
-case 62:
-#line 468 "m2-exp.y"
-{ write_exp_elt_opcode (BINOP_ASSIGN); ;
- break;}
-case 63:
-#line 475 "m2-exp.y"
-{ write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
- write_exp_elt_opcode (OP_BOOL); ;
- break;}
-case 64:
-#line 481 "m2-exp.y"
-{ write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
- write_exp_elt_opcode (OP_BOOL); ;
- break;}
-case 65:
-#line 487 "m2-exp.y"
-{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_m2_int);
- write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 66:
-#line 494 "m2-exp.y"
-{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_m2_card);
- write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
- write_exp_elt_opcode (OP_LONG);
- ;
- break;}
-case 67:
-#line 503 "m2-exp.y"
-{ write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type_m2_char);
- write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
- write_exp_elt_opcode (OP_LONG); ;
- break;}
-case 68:
-#line 511 "m2-exp.y"
-{ write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type (builtin_type_m2_real);
- write_exp_elt_dblcst (yyvsp[0].dval);
- write_exp_elt_opcode (OP_DOUBLE); ;
- break;}
-case 70:
-#line 521 "m2-exp.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 71:
-#line 528 "m2-exp.y"
-{ write_exp_elt_opcode (OP_M2_STRING);
- write_exp_string (yyvsp[0].sval);
- write_exp_elt_opcode (OP_M2_STRING); ;
- break;}
-case 72:
-#line 535 "m2-exp.y"
-{ yyval.bval = SYMBOL_BLOCK_VALUE(yyvsp[0].sym); ;
- break;}
-case 73:
-#line 539 "m2-exp.y"
-{ struct symbol *sym
- = lookup_symbol (copy_name (yyvsp[0].sval), expression_context_block,
- VAR_NAMESPACE, 0, NULL);
- yyval.sym = sym;;
- break;}
-case 74:
-#line 548 "m2-exp.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.sym = tem;
- ;
- break;}
-case 75:
-#line 560 "m2-exp.y"
-{ write_exp_elt_opcode(OP_VAR_VALUE);
- write_exp_elt_block (NULL);
- write_exp_elt_sym (yyvsp[0].sym);
- write_exp_elt_opcode (OP_VAR_VALUE); ;
- break;}
-case 77:
-#line 572 "m2-exp.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);
- /* block_found is set by lookup_symbol. */
- write_exp_elt_block (block_found);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE); ;
- break;}
-case 78:
-#line 588 "m2-exp.y"
-{ struct symbol *sym;
- int is_a_field_of_this;
-
- sym = lookup_symbol (copy_name (yyvsp[0].sval),
- expression_context_block,
- VAR_NAMESPACE,
- &is_a_field_of_this,
- NULL);
- if (sym)
- {
- if (symbol_read_needs_frame (sym))
- {
- if (innermost_block == 0 ||
- contained_in (block_found,
- innermost_block))
- innermost_block = block_found;
- }
-
- write_exp_elt_opcode (OP_VAR_VALUE);
- /* We want to use the selected frame, not
- another more inner frame which happens to
- be in the same block. */
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
- }
- else
- {
- struct minimal_symbol *msymbol;
- register char *arg = copy_name (yyvsp[0].sval);
-
- msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
- if (msymbol != NULL)
- {
- write_exp_msymbol
- (msymbol,
- lookup_function_type (builtin_type_int),
- builtin_type_int);
- }
- else if (!have_full_symbols () && !have_partial_symbols ())
- error ("No symbol table is loaded. Use the \"symbol-file\" command.");
- else
- error ("No symbol \"%s\" in current context.",
- copy_name (yyvsp[0].sval));
- }
- ;
- break;}
-case 79:
-#line 639 "m2-exp.y"
-{ yyval.tval = lookup_typename (copy_name (yyvsp[0].sval),
- expression_context_block, 0); ;
- break;}
-}
- /* the action file gets copied in in place of this dollarsign */
-#line 498 "/stone/jimb/main-98r2/share/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;
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- size += strlen(yytname[x]) + 15, count++;
- msg = (char *) xmalloc(size + 15);
- if (msg != 0)
- {
- strcpy(msg, "parse error");
-
- if (count < 5)
- {
- count = 0;
- for (x = (yyn < 0 ? -yyn : 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
- yyerror ("parse error; also virtual memory exceeded");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror("parse error");
- }
-
- goto yyerrlab1;
-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 644 "m2-exp.y"
-
-
-#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;
-
- 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" , OROR },
- {"IN", IN },/* Note space after IN */
- {"AND", LOGICAL_AND},
- {"ABS", ABS },
- {"CHR", CHR },
- {"DEC", DEC },
- {"NOT", NOT },
- {"DIV", DIV },
- {"INC", INC },
- {"MAX", MAX_FUNC },
- {"MIN", MIN_FUNC },
- {"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 < (int) (sizeof tokentab2 / sizeof tokentab2[0]) ; i++)
- if(STREQN(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);
-
- memcpy (err_copy, tokstart, 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;
-
- /* Lookup special keywords */
- for(i = 0 ; i < (int) (sizeof(keytab) / sizeof(keytab[0])) ; i++)
- if(namelen == strlen(keytab[i].keyw) && STREQN(tokstart,keytab[i].keyw,namelen))
- return keytab[i].token;
-
- yylval.sval.ptr = tokstart;
- yylval.sval.length = namelen;
-
- if (*tokstart == '$')
- {
- write_dollar_variable (yylval.sval);
- 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->aclass)
- {
- case LOC_STATIC:
- case LOC_REGISTER:
- case LOC_ARG:
- case LOC_REF_ARG:
- case LOC_REGPARM:
- case LOC_REGPARM_ADDR:
- case LOC_LOCAL:
- case LOC_LOCAL_ARG:
- case LOC_BASEREG:
- case LOC_BASEREG_ARG:
- case LOC_CONST:
- case LOC_CONST_BYTES:
- case LOC_OPTIMIZED_OUT:
- return NAME;
-
- case LOC_TYPEDEF:
- return TYPENAME;
-
- case LOC_BLOCK:
- return BLOCKNAME;
-
- case LOC_UNDEF:
- error("internal: Undefined class in m2lex()");
-
- case LOC_LABEL:
- case LOC_UNRESOLVED:
- error("internal: Unforseen case in m2lex()");
- }
- }
- else
- {
- /* Built-in BOOLEAN type. This is sort of a hack. */
- if(STREQN(tokstart,"TRUE",4))
- {
- yylval.ulval = 1;
- return M2_TRUE;
- }
- else if(STREQN(tokstart,"FALSE",5))
- {
- yylval.ulval = 0;
- return M2_FALSE;
- }
- }
-
- /* Must be another type of name... */
- return NAME;
- }
-}
-
-#if 0 /* Unused */
-static 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;
-}
-#endif /* 0 */
-
-void
-yyerror (msg)
- char *msg;
-{
- error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
-}
diff --git a/contrib/gdb/gdb/m3-nat.c b/contrib/gdb/gdb/m3-nat.c
deleted file mode 100644
index 4614f65..0000000
--- a/contrib/gdb/gdb/m3-nat.c
+++ /dev/null
@@ -1,4646 +0,0 @@
-/* Interface GDB to Mach 3.0 operating systems.
- (Most) Mach 3.0 related routines live in this file.
-
- Copyright (C) 1992, 1996, 1999 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/*
- * Author: Jukka Virtanen <jtv@hut.fi>
- * Computing Centre
- * Helsinki University of Technology
- * Finland
- *
- * Thanks to my friends who helped with ideas and testing:
- *
- * Johannes Helander, Antti Louko, Tero Mononen,
- * jvh@cs.hut.fi alo@hut.fi tmo@cs.hut.fi
- *
- * Tero Kivinen and Eamonn McManus
- * kivinen@cs.hut.fi emcmanus@gr.osf.org
- *
- */
-
-#include <stdio.h>
-
-#include <mach.h>
-#include <servers/netname.h>
-#include <servers/machid.h>
-#include <mach/message.h>
-#include <mach/notify.h>
-#include <mach_error.h>
-#include <mach/exception.h>
-#include <mach/vm_attributes.h>
-
-#include "defs.h"
-#include "inferior.h"
-#include "symtab.h"
-#include "value.h"
-#include "language.h"
-#include "target.h"
-#include "wait.h"
-#include "gdbcmd.h"
-#include "gdbcore.h"
-
-#if 0
-#include <servers/machid_lib.h>
-#else
-#define MACH_TYPE_TASK 1
-#define MACH_TYPE_THREAD 2
-#endif
-
-/* Included only for signal names and NSIG
- *
- * note: There are many problems in signal handling with
- * gdb in Mach 3.0 in general.
- */
-#include <signal.h>
-#define SIG_UNKNOWN 0 /* Exception that has no matching unix signal */
-
-#include <cthreads.h>
-
-/* This is what a cproc looks like. This is here partly because
- cthread_internals.h is not a header we can just #include, partly with
- an eye towards perhaps getting this to work with cross-debugging
- someday. Best solution is if CMU publishes a real interface to this
- stuff. */
-#define CPROC_NEXT_OFFSET 0
-#define CPROC_NEXT_SIZE (TARGET_PTR_BIT / HOST_CHAR_BIT)
-#define CPROC_INCARNATION_OFFSET (CPROC_NEXT_OFFSET + CPROC_NEXT_SIZE)
-#define CPROC_INCARNATION_SIZE (sizeof (cthread_t))
-#define CPROC_LIST_OFFSET (CPROC_INCARNATION_OFFSET + CPROC_INCARNATION_SIZE)
-#define CPROC_LIST_SIZE (TARGET_PTR_BIT / HOST_CHAR_BIT)
-#define CPROC_WAIT_OFFSET (CPROC_LIST_OFFSET + CPROC_LIST_SIZE)
-#define CPROC_WAIT_SIZE (TARGET_PTR_BIT / HOST_CHAR_BIT)
-#define CPROC_REPLY_OFFSET (CPROC_WAIT_OFFSET + CPROC_WAIT_SIZE)
-#define CPROC_REPLY_SIZE (sizeof (mach_port_t))
-#define CPROC_CONTEXT_OFFSET (CPROC_REPLY_OFFSET + CPROC_REPLY_SIZE)
-#define CPROC_CONTEXT_SIZE (TARGET_INT_BIT / HOST_CHAR_BIT)
-#define CPROC_LOCK_OFFSET (CPROC_CONTEXT_OFFSET + CPROC_CONTEXT_SIZE)
-#define CPROC_LOCK_SIZE (sizeof (spin_lock_t))
-#define CPROC_STATE_OFFSET (CPROC_LOCK_OFFSET + CPROC_LOCK_SIZE)
-#define CPROC_STATE_SIZE (TARGET_INT_BIT / HOST_CHAR_BIT)
-#define CPROC_WIRED_OFFSET (CPROC_STATE_OFFSET + CPROC_STATE_SIZE)
-#define CPROC_WIRED_SIZE (sizeof (mach_port_t))
-#define CPROC_BUSY_OFFSET (CPROC_WIRED_OFFSET + CPROC_WIRED_SIZE)
-#define CPROC_BUSY_SIZE (TARGET_INT_BIT / HOST_CHAR_BIT)
-#define CPROC_MSG_OFFSET (CPROC_BUSY_OFFSET + CPROC_BUSY_SIZE)
-#define CPROC_MSG_SIZE (sizeof (mach_msg_header_t))
-#define CPROC_BASE_OFFSET (CPROC_MSG_OFFSET + CPROC_MSG_SIZE)
-#define CPROC_BASE_SIZE (TARGET_INT_BIT / HOST_CHAR_BIT)
-#define CPROC_SIZE_OFFSET (CPROC_BASE_OFFSET + CPROC_BASE_SIZE)
-#define CPROC_SIZE_SIZE (TARGET_INT_BIT / HOST_CHAR_BIT)
-#define CPROC_SIZE (CPROC_SIZE_OFFSET + CPROC_SIZE_SIZE)
-
-/* Values for the state field in the cproc. */
-#define CPROC_RUNNING 0
-#define CPROC_SWITCHING 1
-#define CPROC_BLOCKED 2
-#define CPROC_CONDWAIT 4
-
-/* For cproc and kernel thread mapping */
-typedef struct gdb_thread {
- mach_port_t name;
- CORE_ADDR sp;
- CORE_ADDR pc;
- CORE_ADDR fp;
- boolean_t in_emulator;
- int slotid;
-
- /* This is for the mthreads list. It points to the cproc list.
- Perhaps the two lists should be merged (or perhaps it was a mistake
- to make them both use a struct gdb_thread). */
- struct gdb_thread *cproc;
-
- /* These are for the cproc list, which is linked through the next field
- of the struct gdb_thread. */
- char raw_cproc[CPROC_SIZE];
- /* The cthread which is pointed to by the incarnation field from the
- cproc. This points to the copy we've read into GDB. */
- cthread_t cthread;
- /* Point back to the mthreads list. */
- int reverse_map;
- struct gdb_thread *next;
-} *gdb_thread_t;
-
-/*
- * Actions for Mach exceptions.
- *
- * sigmap field maps the exception to corresponding Unix signal.
- *
- * I do not know how to map the exception to unix signal
- * if SIG_UNKNOWN is specified.
- */
-
-struct exception_list {
- char *name;
- boolean_t forward;
- boolean_t print;
- int sigmap;
-} exception_map[] = {
- {"not_mach3_exception", FALSE, TRUE, SIG_UNKNOWN},
- {"EXC_BAD_ACCESS", FALSE, TRUE, SIGSEGV},
- {"EXC_BAD_INSTRUCTION", FALSE, TRUE, SIGILL},
- {"EXC_ARITHMETIC", FALSE, TRUE, SIGFPE},
- {"EXC_EMULATION", FALSE, TRUE, SIGEMT}, /* ??? */
- {"EXC_SOFTWARE", FALSE, TRUE, SIG_UNKNOWN},
- {"EXC_BREAKPOINT", FALSE, FALSE, SIGTRAP}
-};
-
-/* Mach exception table size */
-int max_exception = sizeof(exception_map)/sizeof(struct exception_list) - 1;
-
-#define MAX_EXCEPTION max_exception
-
-WAITTYPE wait_status;
-
-/* If you define this, intercepted bsd server calls will be
- * dumped while waiting the inferior to EXEC the correct
- * program
- */
-/* #define DUMP_SYSCALL /* debugging interceptor */
-
-/* xx_debug() outputs messages if this is nonzero.
- * If > 1, DUMP_SYSCALL will dump message contents.
- */
-int debug_level = 0;
-
-/* "Temporary" debug stuff */
-void
-xx_debug (fmt, a,b,c)
-char *fmt;
-int a,b,c;
-{
- if (debug_level)
- warning (fmt, a, b, c);
-}
-
-/* This is in libmach.a */
-extern mach_port_t name_server_port;
-
-/* Set in catch_exception_raise */
-int stop_exception, stop_code, stop_subcode;
-int stopped_in_exception;
-
-/* Thread that was the active thread when we stopped */
-thread_t stop_thread = MACH_PORT_NULL;
-
-char *hostname = "";
-
-/* Set when task is attached or created */
-boolean_t emulator_present = FALSE;
-
-task_t inferior_task;
-thread_t current_thread;
-
-/* Exception ports for inferior task */
-mach_port_t inferior_exception_port = MACH_PORT_NULL;
-mach_port_t inferior_old_exception_port = MACH_PORT_NULL;
-
-/* task exceptions and notifications */
-mach_port_t inferior_wait_port_set = MACH_PORT_NULL;
-mach_port_t our_notify_port = MACH_PORT_NULL;
-
-/* This is "inferior_wait_port_set" when not single stepping, and
- * "singlestepped_thread_port" when we are single stepping.
- *
- * This is protected by a cleanup function: discard_single_step()
- */
-mach_port_t currently_waiting_for = MACH_PORT_NULL;
-
-/* A port for external messages to gdb.
- * External in the meaning that they do not come
- * from the inferior_task, but rather from external
- * tasks.
- *
- * As a debugging feature:
- * A debugger debugging another debugger can stop the
- * inferior debugger by the following command sequence
- * (without running external programs)
- *
- * (top-gdb) set stop_inferior_gdb ()
- * (top-gdb) continue
- */
-mach_port_t our_message_port = MACH_PORT_NULL;
-
-/* For single stepping */
-mach_port_t thread_exception_port = MACH_PORT_NULL;
-mach_port_t thread_saved_exception_port = MACH_PORT_NULL;
-mach_port_t singlestepped_thread_port = MACH_PORT_NULL;
-
-/* For machid calls */
-mach_port_t mid_server = MACH_PORT_NULL;
-mach_port_t mid_auth = MACH_PORT_NULL;
-
-/* If gdb thinks the inferior task is not suspended, it
- * must take suspend/abort the threads when it reads the state.
- */
-int must_suspend_thread = 0;
-
-/* When single stepping, we switch the port that mach_really_wait() listens to.
- * This cleanup is a guard to prevent the port set from being left to
- * the singlestepped_thread_port when error() is called.
- * This is nonzero only when we are single stepping.
- */
-#define NULL_CLEANUP (struct cleanup *)0
-struct cleanup *cleanup_step = NULL_CLEANUP;
-
-
-static struct target_ops m3_ops;
-
-static void m3_kill_inferior ();
-
-#if 0
-#define MACH_TYPE_EXCEPTION_PORT -1
-#endif
-
-/* Chain of ports to remember requested notifications. */
-
-struct port_chain {
- struct port_chain *next;
- mach_port_t port;
- int type;
- int mid; /* Now only valid with MACH_TYPE_THREAD and */
- /* MACH_TYPE_THREAD */
-};
-typedef struct port_chain *port_chain_t;
-
-/* Room for chain nodes comes from pchain_obstack */
-struct obstack pchain_obstack;
-struct obstack *port_chain_obstack = &pchain_obstack;
-
-/* For thread handling */
-struct obstack Cproc_obstack;
-struct obstack *cproc_obstack = &Cproc_obstack;
-
-/* the list of notified ports */
-port_chain_t notify_chain = (port_chain_t) NULL;
-
-port_chain_t
-port_chain_insert (list, name, type)
- port_chain_t list;
- mach_port_t name;
- int type;
-{
- kern_return_t ret;
- port_chain_t new;
- int mid;
-
- if (! MACH_PORT_VALID (name))
- return list;
-
- if (type == MACH_TYPE_TASK || type == MACH_TYPE_THREAD)
- {
- if (! MACH_PORT_VALID (mid_server))
- {
- warning ("Machid server port invalid, can not map port 0x%x to MID",
- name);
- mid = name;
- }
- else
- {
- ret = machid_mach_register (mid_server, mid_auth, name, type, &mid);
-
- if (ret != KERN_SUCCESS)
- {
- warning ("Can not map name (0x%x) to MID with machid", name);
- mid = name;
- }
- }
- }
- else
- abort ();
-
- new = (port_chain_t) obstack_alloc (port_chain_obstack,
- sizeof (struct port_chain));
- new->next = list;
- new->port = name;
- new->type = type;
- new->mid = mid;
-
- return new;
-}
-
-port_chain_t
-port_chain_delete (list, elem)
- port_chain_t list;
- mach_port_t elem;
-{
- if (list)
- if (list->port == elem)
- list = list->next;
- else
- while (list->next)
- {
- if (list->next->port == elem)
- list->next = list->next->next; /* GCd with obstack_free() */
- else
- list = list->next;
- }
- return list;
-}
-
-void
-port_chain_destroy (ostack)
- struct obstack *ostack;
-{
- obstack_free (ostack, 0);
- obstack_init (ostack);
-}
-
-port_chain_t
-port_chain_member (list, elem)
- port_chain_t list;
- mach_port_t elem;
-{
- while (list)
- {
- if (list->port == elem)
- return list;
- list = list->next;
- }
- return (port_chain_t) NULL;
-}
-
-int
-map_port_name_to_mid (name, type)
-mach_port_t name;
-int type;
-{
- port_chain_t elem;
-
- if (!MACH_PORT_VALID (name))
- return -1;
-
- elem = port_chain_member (notify_chain, name);
-
- if (elem && (elem->type == type))
- return elem->mid;
-
- if (elem)
- return -1;
-
- if (! MACH_PORT_VALID (mid_server))
- {
- warning ("Machid server port invalid, can not map port 0x%x to mid",
- name);
- return -1;
- }
- else
- {
- int mid;
- kern_return_t ret;
-
- ret = machid_mach_register (mid_server, mid_auth, name, type, &mid);
-
- if (ret != KERN_SUCCESS)
- {
- warning ("Can not map name (0x%x) to mid with machid", name);
- return -1;
- }
- return mid;
- }
-}
-
-/* Guard for currently_waiting_for and singlestepped_thread_port */
-static void
-discard_single_step (thread)
- thread_t thread;
-{
- currently_waiting_for = inferior_wait_port_set;
-
- cleanup_step = NULL_CLEANUP;
- if (MACH_PORT_VALID (thread) && MACH_PORT_VALID (singlestepped_thread_port))
- setup_single_step (thread, FALSE);
-}
-
-setup_single_step (thread, start_step)
- thread_t thread;
- boolean_t start_step;
-{
- kern_return_t ret;
-
- if (! MACH_PORT_VALID (thread))
- error ("Invalid thread supplied to setup_single_step");
- else
- {
- mach_port_t teport;
-
- /* Get the current thread exception port */
- ret = thread_get_exception_port (thread, &teport);
- CHK ("Getting thread's exception port", ret);
-
- if (start_step)
- {
- if (MACH_PORT_VALID (singlestepped_thread_port))
- {
- warning ("Singlestepped_thread_port (0x%x) is still valid?",
- singlestepped_thread_port);
- singlestepped_thread_port = MACH_PORT_NULL;
- }
-
- /* If we are already stepping this thread */
- if (MACH_PORT_VALID (teport) && teport == thread_exception_port)
- {
- ret = mach_port_deallocate (mach_task_self (), teport);
- CHK ("Could not deallocate thread exception port", ret);
- }
- else
- {
- ret = thread_set_exception_port (thread, thread_exception_port);
- CHK ("Setting exception port for thread", ret);
-#if 0
- /* Insert thread exception port to wait port set */
- ret = mach_port_move_member (mach_task_self(),
- thread_exception_port,
- inferior_wait_port_set);
- CHK ("Moving thread exception port to inferior_wait_port_set",
- ret);
-#endif
- thread_saved_exception_port = teport;
- }
-
- thread_trace (thread, TRUE);
-
- singlestepped_thread_port = thread_exception_port;
- currently_waiting_for = singlestepped_thread_port;
- cleanup_step = make_cleanup (discard_single_step, thread);
- }
- else
- {
- if (! MACH_PORT_VALID (teport))
- error ("Single stepped thread had an invalid exception port?");
-
- if (teport != thread_exception_port)
- error ("Single stepped thread had an unknown exception port?");
-
- ret = mach_port_deallocate (mach_task_self (), teport);
- CHK ("Couldn't deallocate thread exception port", ret);
-#if 0
- /* Remove thread exception port from wait port set */
- ret = mach_port_move_member (mach_task_self(),
- thread_exception_port,
- MACH_PORT_NULL);
- CHK ("Removing thread exception port from inferior_wait_port_set",
- ret);
-#endif
- /* Restore thread's old exception port */
- ret = thread_set_exception_port (thread,
- thread_saved_exception_port);
- CHK ("Restoring stepped thread's exception port", ret);
-
- if (MACH_PORT_VALID (thread_saved_exception_port))
- (void) mach_port_deallocate (mach_task_self (),
- thread_saved_exception_port);
-
- thread_trace (thread, FALSE);
-
- singlestepped_thread_port = MACH_PORT_NULL;
- currently_waiting_for = inferior_wait_port_set;
- if (cleanup_step)
- discard_cleanups (cleanup_step);
- }
- }
-}
-
-static
-request_notify (name, variant, type)
- mach_port_t name;
- mach_msg_id_t variant;
- int type;
-{
- kern_return_t ret;
- mach_port_t previous_port_dummy = MACH_PORT_NULL;
-
- if (! MACH_PORT_VALID (name))
- return;
-
- if (port_chain_member (notify_chain, name))
- return;
-
- ret = mach_port_request_notification (mach_task_self(),
- name,
- variant,
- 1,
- our_notify_port,
- MACH_MSG_TYPE_MAKE_SEND_ONCE,
- &previous_port_dummy);
- CHK ("Serious: request_notify failed", ret);
-
- (void) mach_port_deallocate (mach_task_self (),
- previous_port_dummy);
-
- notify_chain = port_chain_insert (notify_chain, name, type);
-}
-
-reverse_msg_bits(msgp, type)
- mach_msg_header_t *msgp;
- int type;
-{
- int rbits,lbits;
- rbits = MACH_MSGH_BITS_REMOTE(msgp->msgh_bits);
- lbits = type;
- msgp->msgh_bits =
- (msgp->msgh_bits & ~MACH_MSGH_BITS_PORTS_MASK) |
- MACH_MSGH_BITS(lbits,rbits);
-}
-
-/* On the third day He said:
-
- Let this be global
- and then it was global.
-
- When creating the inferior fork, the
- child code in inflow.c sets the name of the
- bootstrap_port in its address space to this
- variable.
-
- The name is transferred to our address space
- with mach3_read_inferior().
-
- Thou shalt not do this with
- task_get_bootstrap_port() in this task, since
- the name in the inferior task is different than
- the one we get.
-
- For blessed are the meek, as they shall inherit
- the address space.
- */
-mach_port_t original_server_port_name = MACH_PORT_NULL;
-
-
-/* Called from inferior after FORK but before EXEC */
-static void
-m3_trace_me ()
-{
- kern_return_t ret;
-
- /* Get the NAME of the bootstrap port in this task
- so that GDB can read it */
- ret = task_get_bootstrap_port (mach_task_self (),
- &original_server_port_name);
- if (ret != KERN_SUCCESS)
- abort ();
- ret = mach_port_deallocate (mach_task_self (),
- original_server_port_name);
- if (ret != KERN_SUCCESS)
- abort ();
-
- /* Suspend this task to let the parent change my ports.
- Resumed by the debugger */
- ret = task_suspend (mach_task_self ());
- if (ret != KERN_SUCCESS)
- abort ();
-}
-
-/*
- * Intercept system calls to Unix server.
- * After EXEC_COUNTER calls to exec(), return.
- *
- * Pre-assertion: Child is suspended. (Not verified)
- * Post-condition: Child is suspended after EXEC_COUNTER exec() calls.
- */
-
-void
-intercept_exec_calls (exec_counter)
- int exec_counter;
-{
- int terminal_initted = 0;
-
- struct syscall_msg_t {
- mach_msg_header_t header;
- mach_msg_type_t type;
- char room[ 2000 ]; /* Enuff space */
- };
-
- struct syscall_msg_t syscall_in, syscall_out;
-
- mach_port_t fake_server;
- mach_port_t original_server_send;
- mach_port_t original_exec_reply;
- mach_port_t exec_reply;
- mach_port_t exec_reply_send;
- mach_msg_type_name_t acquired;
- mach_port_t emulator_server_port_name;
- struct task_basic_info info;
- mach_msg_type_number_t info_count;
-
- kern_return_t ret;
-
- if (exec_counter <= 0)
- return; /* We are already set up in the correct program */
-
- ret = mach_port_allocate(mach_task_self(),
- MACH_PORT_RIGHT_RECEIVE,
- &fake_server);
- CHK("create inferior_fake_server port failed", ret);
-
- /* Wait for inferior_task to suspend itself */
- while(1)
- {
- info_count = sizeof (info);
- ret = task_info (inferior_task,
- TASK_BASIC_INFO,
- (task_info_t)&info,
- &info_count);
- CHK ("Task info", ret);
-
- if (info.suspend_count)
- break;
-
- /* Note that the definition of the parameter was undefined
- * at the time of this writing, so I just use an `ad hoc' value.
- */
- (void) swtch_pri (42); /* Universal Priority Value */
- }
-
- /* Read the inferior's bootstrap port name */
- if (!mach3_read_inferior (&original_server_port_name,
- &original_server_port_name,
- sizeof (original_server_port_name)))
- error ("Can't read inferior task bootstrap port name");
-
- /* @@ BUG: If more than 1 send right GDB will FAIL!!! */
- /* Should get refs, and set them back when restoring */
- /* Steal the original bsd server send right from inferior */
- ret = mach_port_extract_right (inferior_task,
- original_server_port_name,
- MACH_MSG_TYPE_MOVE_SEND,
- &original_server_send,
- &acquired);
- CHK("mach_port_extract_right (bsd server send)",ret);
-
- if (acquired != MACH_MSG_TYPE_PORT_SEND)
- error("Incorrect right extracted, send right to bsd server excpected");
-
- ret = mach_port_insert_right (inferior_task,
- original_server_port_name,
- fake_server,
- MACH_MSG_TYPE_MAKE_SEND);
- CHK("mach_port_insert_right (fake server send)",ret);
-
- xx_debug ("inferior task bsd server ports set up \nfs %x, ospn %x, oss %x\n",
- fake_server,
- original_server_port_name, original_server_send);
-
- /* A receive right to the reply generated by unix server exec() request */
- ret = mach_port_allocate(mach_task_self(),
- MACH_PORT_RIGHT_RECEIVE,
- &exec_reply);
- CHK("create intercepted_reply_port port failed", ret);
-
- /* Pass this send right to Unix server so it replies to us after exec() */
- ret = mach_port_extract_right (mach_task_self (),
- exec_reply,
- MACH_MSG_TYPE_MAKE_SEND_ONCE,
- &exec_reply_send,
- &acquired);
- CHK("mach_port_extract_right (exec_reply)",ret);
-
- if (acquired != MACH_MSG_TYPE_PORT_SEND_ONCE)
- error("Incorrect right extracted, send once excpected for exec reply");
-
- ret = mach_port_move_member(mach_task_self(),
- fake_server,
- inferior_wait_port_set);
- CHK ("Moving fake syscall port to inferior_wait_port_set", ret);
-
- xx_debug ("syscall fake server set up, resuming inferior\n");
-
- ret = task_resume (inferior_task);
- CHK("task_resume (startup)", ret);
-
- /* Read requests from the inferior.
- Pass directly through everything else except exec() calls.
- */
- while(exec_counter > 0)
- {
- ret = mach_msg (&syscall_in.header, /* header */
- MACH_RCV_MSG, /* options */
- 0, /* send size */
- sizeof (struct syscall_msg_t), /* receive size */
- inferior_wait_port_set, /* receive_name */
- MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
- CHK("mach_msg (intercepted sycall)", ret);
-
-#ifdef DUMP_SYSCALL
- print_msg (&syscall_in.header);
-#endif
-
- /* ASSERT : msgh_local_port == fake_server */
-
- if (notify_server (&syscall_in.header, &syscall_out.header))
- error ("received a notify while intercepting syscalls");
-
- if (syscall_in.header.msgh_id == MIG_EXEC_SYSCALL_ID)
- {
- xx_debug ("Received EXEC SYSCALL, counter = %d\n", exec_counter);
- if (exec_counter == 1)
- {
- original_exec_reply = syscall_in.header.msgh_remote_port;
- syscall_in.header.msgh_remote_port = exec_reply_send;
- }
-
- if (!terminal_initted)
- {
- /* Now that the child has exec'd we know it has already set its
- process group. On POSIX systems, tcsetpgrp will fail with
- EPERM if we try it before the child's setpgid. */
-
- /* 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 ();
-
- terminal_initted = 1;
- }
-
- exec_counter--;
- }
-
- syscall_in.header.msgh_local_port = syscall_in.header.msgh_remote_port;
- syscall_in.header.msgh_remote_port = original_server_send;
-
- reverse_msg_bits(&syscall_in.header, MACH_MSG_TYPE_COPY_SEND);
-
- ret = mach_msg_send (&syscall_in.header);
- CHK ("Forwarded syscall", ret);
- }
-
- ret = mach_port_move_member(mach_task_self(),
- fake_server,
- MACH_PORT_NULL);
- CHK ("Moving fake syscall out of inferior_wait_port_set", ret);
-
- ret = mach_port_move_member(mach_task_self(),
- exec_reply,
- inferior_wait_port_set);
- CHK ("Moving exec_reply to inferior_wait_port_set", ret);
-
- ret = mach_msg (&syscall_in.header, /* header */
- MACH_RCV_MSG, /* options */
- 0, /* send size */
- sizeof (struct syscall_msg_t), /* receive size */
- inferior_wait_port_set, /* receive_name */
- MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
- CHK("mach_msg (exec reply)", ret);
-
- ret = task_suspend (inferior_task);
- CHK ("Suspending inferior after last exec", ret);
-
- must_suspend_thread = 0;
-
- xx_debug ("Received exec reply from bsd server, suspended inferior task\n");
-
-#ifdef DUMP_SYSCALL
- print_msg (&syscall_in.header);
-#endif
-
- /* Message should appear as if it came from the unix server */
- syscall_in.header.msgh_local_port = MACH_PORT_NULL;
-
- /* and go to the inferior task original reply port */
- syscall_in.header.msgh_remote_port = original_exec_reply;
-
- reverse_msg_bits(&syscall_in.header, MACH_MSG_TYPE_MOVE_SEND_ONCE);
-
- ret = mach_msg_send (&syscall_in.header);
- CHK ("Forwarding exec reply to inferior", ret);
-
- /* Garbage collect */
- ret = mach_port_deallocate (inferior_task,
- original_server_port_name);
- CHK ("deallocating fake server send right", ret);
-
- ret = mach_port_insert_right (inferior_task,
- original_server_port_name,
- original_server_send,
- MACH_MSG_TYPE_MOVE_SEND);
- CHK ("Restoring the original bsd server send right", ret);
-
- ret = mach_port_destroy (mach_task_self (),
- fake_server);
- fake_server = MACH_PORT_DEAD;
- CHK("mach_port_destroy (fake_server)", ret);
-
- ret = mach_port_destroy (mach_task_self (),
- exec_reply);
- exec_reply = MACH_PORT_DEAD;
- CHK("mach_port_destroy (exec_reply)", ret);
-
- xx_debug ("Done with exec call interception\n");
-}
-
-void
-consume_send_rights (thread_list, thread_count)
- thread_array_t thread_list;
- int thread_count;
-{
- int index;
-
- if (!thread_count)
- return;
-
- for (index = 0; index < thread_count; index++)
- {
- /* Since thread kill command kills threads, don't check ret */
- (void) mach_port_deallocate (mach_task_self (),
- thread_list [ index ]);
- }
-}
-
-/* suspend/abort/resume a thread. */
-setup_thread (thread, what)
- mach_port_t thread;
- int what;
-{
- kern_return_t ret;
-
- if (what)
- {
- ret = thread_suspend (thread);
- CHK ("setup_thread thread_suspend", ret);
-
- ret = thread_abort (thread);
- CHK ("setup_thread thread_abort", ret);
- }
- else
- {
- ret = thread_resume (thread);
- CHK ("setup_thread thread_resume", ret);
- }
-}
-
-int
-map_slot_to_mid (slot, threads, thread_count)
- int slot;
- thread_array_t threads;
- int thread_count;
-{
- kern_return_t ret;
- int deallocate = 0;
- int index;
- int mid;
-
- if (! threads)
- {
- deallocate++;
- ret = task_threads (inferior_task, &threads, &thread_count);
- CHK ("Can not select a thread from a dead task", ret);
- }
-
- if (slot < 0 || slot >= thread_count)
- {
- if (deallocate)
- {
- consume_send_rights (threads, thread_count);
- (void) vm_deallocate (mach_task_self(), (vm_address_t)threads,
- (thread_count * sizeof(mach_port_t)));
- }
- if (slot < 0)
- error ("invalid slot number");
- else
- return -(slot+1);
- }
-
- mid = map_port_name_to_mid (threads [slot], MACH_TYPE_THREAD);
-
- if (deallocate)
- {
- consume_send_rights (threads, thread_count);
- (void) vm_deallocate (mach_task_self(), (vm_address_t)threads,
- (thread_count * sizeof(mach_port_t)));
- }
-
- return mid;
-}
-
-static int
-parse_thread_id (arg, thread_count, slots)
- char *arg;
- int thread_count;
- int slots;
-{
- kern_return_t ret;
- int mid;
- int slot;
- int index;
-
- if (arg == 0)
- return 0;
-
- while (*arg && (*arg == ' ' || *arg == '\t'))
- arg++;
-
- if (! *arg)
- return 0;
-
- /* Currently parse MID and @SLOTNUMBER */
- if (*arg != '@')
- {
- mid = atoi (arg);
- if (mid <= 0)
- error ("valid thread mid expected");
- return mid;
- }
-
- arg++;
- slot = atoi (arg);
-
- if (slot < 0)
- error ("invalid slot number");
-
- /* If you want slot numbers to remain slot numbers, set slots.
- *
- * Well, since 0 is reserved, return the ordinal number
- * of the thread rather than the slot number. Awk, this
- * counts as a kludge.
- */
- if (slots)
- return -(slot+1);
-
- if (thread_count && slot >= thread_count)
- return -(slot+1);
-
- mid = map_slot_to_mid (slot);
-
- return mid;
-}
-
-/* THREAD_ID 0 is special; it selects the first kernel
- * thread from the list (i.e. SLOTNUMBER 0)
- * This is used when starting the program with 'run' or when attaching.
- *
- * If FLAG is 0 the context is not changed, and the registers, frame, etc
- * will continue to describe the old thread.
- *
- * If FLAG is nonzero, really select the thread.
- * If FLAG is 2, the THREAD_ID is a slotnumber instead of a mid.
- *
- */
-kern_return_t
-select_thread (task, thread_id, flag)
- mach_port_t task;
- int thread_id;
- int flag;
-{
- thread_array_t thread_list;
- int thread_count;
- kern_return_t ret;
- int index;
- thread_t new_thread = MACH_PORT_NULL;
-
- if (thread_id < 0)
- error ("Can't select cprocs without kernel thread");
-
- ret = task_threads (task, &thread_list, &thread_count);
- if (ret != KERN_SUCCESS)
- {
- warning ("Can not select a thread from a dead task");
- m3_kill_inferior ();
- return KERN_FAILURE;
- }
-
- if (thread_count == 0)
- {
- /* The task can not do anything anymore, but it still
- * exists as a container for memory and ports.
- */
- registers_changed ();
- warning ("Task %d has no threads",
- map_port_name_to_mid (task, MACH_TYPE_TASK));
- current_thread = MACH_PORT_NULL;
- (void) vm_deallocate(mach_task_self(),
- (vm_address_t) thread_list,
- (thread_count * sizeof(mach_port_t)));
- return KERN_FAILURE;
- }
-
- if (! thread_id || flag == 2)
- {
- /* First thread or a slotnumber */
- if (! thread_id)
- new_thread = thread_list[0];
- else
- {
- if (thread_id < thread_count)
- new_thread = thread_list[ thread_id ];
- else
- {
- (void) vm_deallocate(mach_task_self(),
- (vm_address_t) thread_list,
- (thread_count * sizeof(mach_port_t)));
- error ("No such thread slot number : %d", thread_id);
- }
- }
- }
- else
- {
- for (index = 0; index < thread_count; index++)
- if (thread_id == map_port_name_to_mid (thread_list [index],
- MACH_TYPE_THREAD))
- {
- new_thread = thread_list [index];
- index = -1;
- break;
- }
-
- if (index != -1)
- error ("No thread with mid %d", thread_id);
- }
-
- /* Notify when the selected thread dies */
- request_notify (new_thread, MACH_NOTIFY_DEAD_NAME, MACH_TYPE_THREAD);
-
- ret = vm_deallocate(mach_task_self(),
- (vm_address_t) thread_list,
- (thread_count * sizeof(mach_port_t)));
- CHK ("vm_deallocate", ret);
-
- if (! flag)
- current_thread = new_thread;
- else
- {
-#if 0
- if (MACH_PORT_VALID (current_thread))
- {
- /* Store the gdb's view of the thread we are deselecting
- *
- * @@ I think gdb updates registers immediately when they are
- * changed, so don't do this.
- */
- ret = thread_abort (current_thread);
- CHK ("Could not abort system calls when saving state of old thread",
- ret);
- target_prepare_to_store ();
- target_store_registers (-1);
- }
-#endif
-
- registers_changed ();
-
- current_thread = new_thread;
-
- ret = thread_abort (current_thread);
- CHK ("Could not abort system calls when selecting a thread", ret);
-
- stop_pc = read_pc();
- flush_cached_frames ();
-
- select_frame (get_current_frame (), 0);
- }
-
- return KERN_SUCCESS;
-}
-
-/*
- * Switch to use thread named NEW_THREAD.
- * Return it's MID
- */
-int
-switch_to_thread (new_thread)
- thread_t new_thread;
-{
- thread_t saved_thread = current_thread;
- int mid;
-
- mid = map_port_name_to_mid (new_thread,
- MACH_TYPE_THREAD);
- if (mid == -1)
- warning ("Can't map thread name 0x%x to mid", new_thread);
- else if (select_thread (inferior_task, mid, 1) != KERN_SUCCESS)
- {
- if (current_thread)
- current_thread = saved_thread;
- error ("Could not select thread %d", mid);
- }
-
- return mid;
-}
-
-/* Do this in gdb after doing FORK but before STARTUP_INFERIOR.
- * Note that the registers are not yet valid in the inferior task.
- */
-static int
-m3_trace_him (pid)
- int pid;
-{
- kern_return_t ret;
-
- push_target (&m3_ops);
-
- inferior_task = task_by_pid (pid);
-
- if (! MACH_PORT_VALID (inferior_task))
- error ("Can not map Unix pid %d to Mach task", pid);
-
- /* Clean up previous notifications and create new ones */
- setup_notify_port (1);
-
- /* When notification appears, the inferior task has died */
- request_notify (inferior_task, MACH_NOTIFY_DEAD_NAME, MACH_TYPE_TASK);
-
- emulator_present = have_emulator_p (inferior_task);
-
- /* By default, select the first thread,
- * If task has no threads, gives a warning
- * Does not fetch registers, since they are not yet valid.
- */
- select_thread (inferior_task, 0, 0);
-
- inferior_exception_port = MACH_PORT_NULL;
-
- setup_exception_port ();
-
- xx_debug ("Now the debugged task is created\n");
-
- /* One trap to exec the shell, one to exec the program being debugged. */
- intercept_exec_calls (2);
-
- return pid;
-}
-
-setup_exception_port ()
-{
- kern_return_t ret;
-
- ret = mach_port_allocate (mach_task_self(),
- MACH_PORT_RIGHT_RECEIVE,
- &inferior_exception_port);
- CHK("mach_port_allocate",ret);
-
- /* add send right */
- ret = mach_port_insert_right (mach_task_self (),
- inferior_exception_port,
- inferior_exception_port,
- MACH_MSG_TYPE_MAKE_SEND);
- CHK("mach_port_insert_right",ret);
-
- ret = mach_port_move_member (mach_task_self(),
- inferior_exception_port,
- inferior_wait_port_set);
- CHK("mach_port_move_member",ret);
-
- ret = task_get_special_port (inferior_task,
- TASK_EXCEPTION_PORT,
- &inferior_old_exception_port);
- CHK ("task_get_special_port(old exc)",ret);
-
- ret = task_set_special_port (inferior_task,
- TASK_EXCEPTION_PORT,
- inferior_exception_port);
- CHK("task_set_special_port",ret);
-
- ret = mach_port_deallocate (mach_task_self (),
- inferior_exception_port);
- CHK("mack_port_deallocate",ret);
-
-#if 0
- /* When notify appears, the inferior_task's exception
- * port has been destroyed.
- *
- * Not used, since the dead_name_notification already
- * appears when task dies.
- *
- */
- request_notify (inferior_exception_port,
- MACH_NOTIFY_NO_SENDERS,
- MACH_TYPE_EXCEPTION_PORT);
-#endif
-}
-
-/* Nonzero if gdb is waiting for a message */
-int mach_really_waiting;
-
-/* Wait for the inferior to stop for some reason.
- - Loop on notifications until inferior_task dies.
- - Loop on exceptions until stopped_in_exception comes true.
- (e.g. we receive a single step trace trap)
- - a message arrives to gdb's message port
-
- There is no other way to exit this loop.
-
- Returns the inferior_pid for rest of gdb.
- Side effects: Set *OURSTATUS. */
-int
-mach_really_wait (pid, ourstatus)
- int pid;
- struct target_waitstatus *ourstatus;
-{
- kern_return_t ret;
- int w;
-
- struct msg {
- mach_msg_header_t header;
- mach_msg_type_t foo;
- int data[8000];
- } in_msg, out_msg;
-
- /* Either notify (death), exception or message can stop the inferior */
- stopped_in_exception = FALSE;
-
- while (1)
- {
- QUIT;
-
- stop_exception = stop_code = stop_subcode = -1;
- stop_thread = MACH_PORT_NULL;
-
- mach_really_waiting = 1;
- ret = mach_msg (&in_msg.header, /* header */
- MACH_RCV_MSG, /* options */
- 0, /* send size */
- sizeof (struct msg), /* receive size */
- currently_waiting_for, /* receive name */
- MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
- mach_really_waiting = 0;
- CHK("mach_msg (receive)", ret);
-
- /* Check if we received a notify of the childs' death */
- if (notify_server (&in_msg.header, &out_msg.header))
- {
- /* If inferior_task is null then the inferior has
- gone away and we want to return to command level.
- Otherwise it was just an informative message and we
- need to look to see if there are any more. */
- if (inferior_task != MACH_PORT_NULL)
- continue;
- else
- {
- /* Collect Unix exit status for gdb */
-
- wait3(&w, WNOHANG, 0);
-
- /* This mess is here to check that the rest of
- * gdb knows that the inferior died. It also
- * tries to hack around the fact that Mach 3.0 (mk69)
- * unix server (ux28) does not always know what
- * has happened to it's children when mach-magic
- * is applied on them.
- */
- if ((!WIFEXITED(w) && WIFSTOPPED(w)) ||
- (WIFEXITED(w) && WEXITSTATUS(w) > 0377))
- {
- WSETEXIT(w, 0);
- warning ("Using exit value 0 for terminated task");
- }
- else if (!WIFEXITED(w))
- {
- int sig = WTERMSIG(w);
-
- /* Signals cause problems. Warn the user. */
- if (sig != SIGKILL) /* Bad luck if garbage matches this */
- warning ("The terminating signal stuff may be nonsense");
- else if (sig > NSIG)
- {
- WSETEXIT(w, 0);
- warning ("Using exit value 0 for terminated task");
- }
- }
- store_waitstatus (ourstatus, w);
- return inferior_pid;
- }
- }
-
- /* Hmm. Check for exception, as it was not a notification.
- exc_server() does an upcall to catch_exception_raise()
- if this rpc is an exception. Further actions are decided
- there.
- */
- if (! exc_server (&in_msg.header, &out_msg.header))
- {
-
- /* Not an exception, check for message.
- *
- * Messages don't come from the inferior, or if they
- * do they better be asynchronous or it will hang.
- */
- if (gdb_message_server (&in_msg.header))
- continue;
-
- error ("Unrecognized message received in mach_really_wait");
- }
-
- /* Send the reply of the exception rpc to the suspended task */
- ret = mach_msg_send (&out_msg.header);
- CHK ("mach_msg_send (exc reply)", ret);
-
- if (stopped_in_exception)
- {
- /* Get unix state. May be changed in mach3_exception_actions() */
- wait3(&w, WNOHANG, 0);
-
- mach3_exception_actions (&w, FALSE, "Task");
-
- store_waitstatus (ourstatus, w);
- return inferior_pid;
- }
- }
-}
-
-/* Called by macro DO_QUIT() in utils.c(quit).
- * This is called just before calling error() to return to command level
- */
-void
-mach3_quit ()
-{
- int mid;
- kern_return_t ret;
-
- if (mach_really_waiting)
- {
- ret = task_suspend (inferior_task);
-
- if (ret != KERN_SUCCESS)
- {
- warning ("Could not suspend task for interrupt: %s",
- mach_error_string (ret));
- mach_really_waiting = 0;
- return;
- }
- }
-
- must_suspend_thread = 0;
- mach_really_waiting = 0;
-
- mid = map_port_name_to_mid (current_thread, MACH_TYPE_THREAD);
- if (mid == -1)
- {
- warning ("Selecting first existing kernel thread");
- mid = 0;
- }
-
- current_thread = MACH_PORT_NULL; /* Force setup */
- select_thread (inferior_task, mid, 1);
-
- return;
-}
-
-#if 0
-/* bogus bogus bogus. It is NOT OK to quit out of target_wait. */
-
-/* If ^C is typed when we are waiting for a message
- * and your Unix server is able to notice that we
- * should quit now.
- *
- * Called by REQUEST_QUIT() from utils.c(request_quit)
- */
-void
-mach3_request_quit ()
-{
- if (mach_really_waiting)
- immediate_quit = 1;
-}
-#endif
-
-/*
- * Gdb message server.
- * Currently implemented is the STOP message, that causes
- * gdb to return to the command level like ^C had been typed from terminal.
- */
-int
-gdb_message_server (InP)
- mach_msg_header_t *InP;
-{
- kern_return_t ret;
- int mid;
-
- if (InP->msgh_local_port == our_message_port)
- {
- /* A message coming to our_message_port. Check validity */
- switch (InP->msgh_id) {
-
- case GDB_MESSAGE_ID_STOP:
- ret = task_suspend (inferior_task);
- if (ret != KERN_SUCCESS)
- warning ("Could not suspend task for stop message: %s",
- mach_error_string (ret));
-
- /* QUIT in mach_really_wait() loop. */
- request_quit (0);
- break;
-
- default:
- warning ("Invalid message id %d received, ignored.",
- InP->msgh_id);
- break;
- }
-
- return 1;
- }
-
- /* Message not handled by this server */
- return 0;
-}
-
-/* NOTE: This is not an RPC call. It is a simpleroutine.
- *
- * This is not called from this gdb code.
- *
- * It may be called by another debugger to cause this
- * debugger to enter command level:
- *
- * (gdb) set stop_inferior_gdb ()
- * (gdb) continue
- *
- * External program "stop-gdb" implements this also.
- */
-void
-stop_inferior_gdb ()
-{
- kern_return_t ret;
-
- /* Code generated by mig, with minor cleanups :-)
- *
- * simpleroutine stop_inferior_gdb (our_message_port : mach_port_t);
- */
-
- typedef struct {
- mach_msg_header_t Head;
- } Request;
-
- Request Mess;
-
- register Request *InP = &Mess;
-
- InP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);
-
- /* msgh_size passed as argument */
- InP->Head.msgh_remote_port = our_message_port;
- InP->Head.msgh_local_port = MACH_PORT_NULL;
- InP->Head.msgh_seqno = 0;
- InP->Head.msgh_id = GDB_MESSAGE_ID_STOP;
-
- ret = mach_msg (&InP->Head,
- MACH_SEND_MSG|MACH_MSG_OPTION_NONE,
- sizeof(Request),
- 0,
- MACH_PORT_NULL,
- MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
-}
-
-#ifdef THREAD_ALLOWED_TO_BREAK
-/*
- * Return 1 if the MID specifies the thread that caused the
- * last exception.
- * Since catch_exception_raise() selects the thread causing
- * the last exception to current_thread, we just check that
- * it is selected and the last exception was a breakpoint.
- */
-int
-mach_thread_for_breakpoint (mid)
- int mid;
-{
- int cmid = map_port_name_to_mid (current_thread, MACH_TYPE_THREAD);
-
- if (mid < 0)
- {
- mid = map_slot_to_mid (-(mid+1), 0, 0);
- if (mid < 0)
- return 0; /* Don't stop, no such slot */
- }
-
- if (! mid || cmid == -1)
- return 1; /* stop */
-
- return cmid == mid && stop_exception == EXC_BREAKPOINT;
-}
-#endif /* THREAD_ALLOWED_TO_BREAK */
-
-#ifdef THREAD_PARSE_ID
-/*
- * Map a thread id string (MID or a @SLOTNUMBER)
- * to a thread-id.
- *
- * 0 matches all threads.
- * Otherwise the meaning is defined only in this file.
- * (mach_thread_for_breakpoint uses it)
- *
- * @@ This allows non-existent MIDs to be specified.
- * It now also allows non-existent slots to be
- * specified. (Slot numbers stored are negative,
- * and the magnitude is one greater than the actual
- * slot index. (Since 0 is reserved))
- */
-int
-mach_thread_parse_id (arg)
- char *arg;
-{
- int mid;
- if (arg == 0)
- error ("thread id excpected");
- mid = parse_thread_id (arg, 0, 1);
-
- return mid;
-}
-#endif /* THREAD_PARSE_ID */
-
-#ifdef THREAD_OUTPUT_ID
-char *
-mach_thread_output_id (mid)
- int mid;
-{
- static char foobar [20];
-
- if (mid > 0)
- sprintf (foobar, "mid %d", mid);
- else if (mid < 0)
- sprintf (foobar, "@%d", -(mid+1));
- else
- sprintf (foobar, "*any thread*");
-
- return foobar;
-}
-#endif /* THREAD_OUTPUT_ID */
-
-/* Called with hook PREPARE_TO_PROCEED() from infrun.c.
- *
- * If we have switched threads and stopped at breakpoint return 1 otherwise 0.
- *
- * if SELECT_IT is nonzero, reselect the thread that was active when
- * we stopped at a breakpoint.
- *
- */
-
-mach3_prepare_to_proceed (select_it)
- int select_it;
-{
- if (stop_thread &&
- stop_thread != current_thread &&
- stop_exception == EXC_BREAKPOINT)
- {
- int mid;
-
- if (! select_it)
- return 1;
-
- mid = switch_to_thread (stop_thread);
-
- return 1;
- }
-
- return 0;
-}
-
-/* this stuff here is an upcall via libmach/excServer.c
- and mach_really_wait which does the actual upcall.
-
- The code will pass the exception to the inferior if:
-
- - The task that signaled is not the inferior task
- (e.g. when debugging another debugger)
-
- - The user has explicitely requested to pass on the exceptions.
- (e.g to the default unix exception handler, which maps
- exceptions to signals, or the user has her own exception handler)
-
- - If the thread that signaled is being single-stepped and it
- has set it's own exception port and the exception is not
- EXC_BREAKPOINT. (Maybe this is not desirable?)
- */
-
-kern_return_t
-catch_exception_raise (port, thread, task, exception, code, subcode)
- mach_port_t port;
- thread_t thread;
- task_t task;
- int exception, code, subcode;
-{
- kern_return_t ret;
- boolean_t signal_thread;
- int mid = map_port_name_to_mid (thread, MACH_TYPE_THREAD);
-
- if (! MACH_PORT_VALID (thread))
- {
- /* If the exception was sent and thread dies before we
- receive it, THREAD will be MACH_PORT_DEAD
- */
-
- current_thread = thread = MACH_PORT_NULL;
- error ("Received exception from nonexistent thread");
- }
-
- /* Check if the task died in transit.
- * @@ Isn't the thread also invalid in such case?
- */
- if (! MACH_PORT_VALID (task))
- {
- current_thread = thread = MACH_PORT_NULL;
- error ("Received exception from nonexistent task");
- }
-
- if (exception < 0 || exception > MAX_EXCEPTION)
- fatal ("catch_exception_raise: unknown exception code %d thread %d",
- exception,
- mid);
-
- if (! MACH_PORT_VALID (inferior_task))
- error ("got an exception, but inferior_task is null or dead");
-
- stop_exception = exception;
- stop_code = code;
- stop_subcode = subcode;
- stop_thread = thread;
-
- signal_thread = exception != EXC_BREAKPOINT &&
- port == singlestepped_thread_port &&
- MACH_PORT_VALID (thread_saved_exception_port);
-
- /* If it was not our inferior or if we want to forward
- * the exception to the inferior's handler, do it here
- *
- * Note: If you have forwarded EXC_BREAKPOINT I trust you know why.
- */
- if (task != inferior_task ||
- signal_thread ||
- exception_map [exception].forward)
- {
- mach_port_t eport = inferior_old_exception_port;
-
- if (signal_thread)
- {
- /*
- GDB now forwards the exeption to thread's original handler,
- since the user propably knows what he is doing.
- Give a message, though.
- */
-
- mach3_exception_actions ((WAITTYPE *)NULL, TRUE, "Thread");
- eport = thread_saved_exception_port;
- }
-
- /* Send the exception to the original handler */
- ret = exception_raise (eport,
- thread,
- task,
- exception,
- code,
- subcode);
-
- (void) mach_port_deallocate (mach_task_self (), task);
- (void) mach_port_deallocate (mach_task_self (), thread);
-
- /* If we come here, we don't want to trace any more, since we
- * will never stop for tracing anyway.
- */
- discard_single_step (thread);
-
- /* Do not stop the inferior */
- return ret;
- }
-
- /* Now gdb handles the exception */
- stopped_in_exception = TRUE;
-
- ret = task_suspend (task);
- CHK ("Error suspending inferior after exception", ret);
-
- must_suspend_thread = 0;
-
- if (current_thread != thread)
- {
- if (MACH_PORT_VALID (singlestepped_thread_port))
- /* Cleanup discards single stepping */
- error ("Exception from thread %d while singlestepping thread %d",
- mid,
- map_port_name_to_mid (current_thread, MACH_TYPE_THREAD));
-
- /* Then select the thread that caused the exception */
- if (select_thread (inferior_task, mid, 0) != KERN_SUCCESS)
- error ("Could not select thread %d causing exception", mid);
- else
- warning ("Gdb selected thread %d", mid);
- }
-
- /* If we receive an exception that is not breakpoint
- * exception, we interrupt the single step and return to
- * debugger. Trace condition is cleared.
- */
- if (MACH_PORT_VALID (singlestepped_thread_port))
- {
- if (stop_exception != EXC_BREAKPOINT)
- warning ("Single step interrupted by exception");
- else if (port == singlestepped_thread_port)
- {
- /* Single step exception occurred, remove trace bit
- * and return to gdb.
- */
- if (! MACH_PORT_VALID (current_thread))
- error ("Single stepped thread is not valid");
-
- /* Resume threads, but leave the task suspended */
- resume_all_threads (0);
- }
- else
- warning ("Breakpoint while single stepping?");
-
- discard_single_step (current_thread);
- }
-
- (void) mach_port_deallocate (mach_task_self (), task);
- (void) mach_port_deallocate (mach_task_self (), thread);
-
- return KERN_SUCCESS;
-}
-
-int
-port_valid (port, mask)
- mach_port_t port;
- int mask;
-{
- kern_return_t ret;
- mach_port_type_t type;
-
- ret = mach_port_type (mach_task_self (),
- port,
- &type);
- if (ret != KERN_SUCCESS || (type & mask) != mask)
- return 0;
- return 1;
-}
-
-/* @@ No vm read cache implemented yet */
-boolean_t vm_read_cache_valid = FALSE;
-
-/*
- * Read inferior task's LEN bytes from ADDR and copy it to MYADDR
- * in gdb's address space.
- *
- * Return 0 on failure; number of bytes read otherwise.
- */
-int
-mach3_read_inferior (addr, myaddr, length)
- CORE_ADDR addr;
- char *myaddr;
- int length;
-{
- kern_return_t ret;
- vm_address_t low_address = (vm_address_t) trunc_page (addr);
- vm_size_t aligned_length =
- (vm_size_t) round_page (addr+length) - low_address;
- pointer_t copied_memory;
- int copy_count;
-
- /* Get memory from inferior with page aligned addresses */
- ret = vm_read (inferior_task,
- low_address,
- aligned_length,
- &copied_memory,
- &copy_count);
- if (ret != KERN_SUCCESS)
- {
- /* the problem is that the inferior might be killed for whatever reason
- * before we go to mach_really_wait. This is one place that ought to
- * catch many of those errors.
- * @@ A better fix would be to make all external events to GDB
- * to arrive via a SINGLE port set. (Including user input!)
- */
-
- if (! port_valid (inferior_task, MACH_PORT_TYPE_SEND))
- {
- m3_kill_inferior ();
- error ("Inferior killed (task port invalid)");
- }
- else
- {
-#ifdef OSF
- extern int errno;
- /* valprint.c gives nicer format if this does not
- screw it. Eamonn seems to like this, so I enable
- it if OSF is defined...
- */
- warning ("[read inferior %x failed: %s]",
- addr, mach_error_string (ret));
- errno = 0;
-#endif
- return 0;
- }
- }
-
- memcpy (myaddr, (char *)addr - low_address + copied_memory, length);
-
- ret = vm_deallocate (mach_task_self (),
- copied_memory,
- copy_count);
- CHK("mach3_read_inferior vm_deallocate failed", ret);
-
- return length;
-}
-
-#ifdef __STDC__
-#define CHK_GOTO_OUT(str,ret) \
- do if (ret != KERN_SUCCESS) { errstr = #str; goto out; } while(0)
-#else
-#define CHK_GOTO_OUT(str,ret) \
- do if (ret != KERN_SUCCESS) { errstr = str; goto out; } while(0)
-#endif
-
-struct vm_region_list {
- struct vm_region_list *next;
- vm_prot_t protection;
- vm_address_t start;
- vm_size_t length;
-};
-
-struct obstack region_obstack;
-
-/*
- * Write inferior task's LEN bytes from ADDR and copy it to MYADDR
- * in gdb's address space.
- */
-int
-mach3_write_inferior (addr, myaddr, length)
- CORE_ADDR addr;
- char *myaddr;
- int length;
-{
- kern_return_t ret;
- vm_address_t low_address = (vm_address_t) trunc_page (addr);
- vm_size_t aligned_length =
- (vm_size_t) round_page (addr+length) - low_address;
- pointer_t copied_memory;
- int copy_count;
- int deallocate = 0;
-
- char *errstr = "Bug in mach3_write_inferior";
-
- struct vm_region_list *region_element;
- struct vm_region_list *region_head = (struct vm_region_list *)NULL;
-
- /* Get memory from inferior with page aligned addresses */
- ret = vm_read (inferior_task,
- low_address,
- aligned_length,
- &copied_memory,
- &copy_count);
- CHK_GOTO_OUT ("mach3_write_inferior vm_read failed", ret);
-
- deallocate++;
-
- memcpy ((char *)addr - low_address + copied_memory, myaddr, length);
-
- obstack_init (&region_obstack);
-
- /* Do writes atomically.
- * First check for holes and unwritable memory.
- */
- {
- vm_size_t remaining_length = aligned_length;
- vm_address_t region_address = low_address;
-
- struct vm_region_list *scan;
-
- while(region_address < low_address + aligned_length)
- {
- vm_prot_t protection;
- vm_prot_t max_protection;
- vm_inherit_t inheritance;
- boolean_t shared;
- mach_port_t object_name;
- vm_offset_t offset;
- vm_size_t region_length = remaining_length;
- vm_address_t old_address = region_address;
-
- ret = vm_region (inferior_task,
- &region_address,
- &region_length,
- &protection,
- &max_protection,
- &inheritance,
- &shared,
- &object_name,
- &offset);
- CHK_GOTO_OUT ("vm_region failed", ret);
-
- /* Check for holes in memory */
- if (old_address != region_address)
- {
- warning ("No memory at 0x%x. Nothing written",
- old_address);
- ret = KERN_SUCCESS;
- length = 0;
- goto out;
- }
-
- if (!(max_protection & VM_PROT_WRITE))
- {
- warning ("Memory at address 0x%x is unwritable. Nothing written",
- old_address);
- ret = KERN_SUCCESS;
- length = 0;
- goto out;
- }
-
- /* Chain the regions for later use */
- region_element =
- (struct vm_region_list *)
- obstack_alloc (&region_obstack, sizeof (struct vm_region_list));
-
- region_element->protection = protection;
- region_element->start = region_address;
- region_element->length = region_length;
-
- /* Chain the regions along with protections */
- region_element->next = region_head;
- region_head = region_element;
-
- region_address += region_length;
- remaining_length = remaining_length - region_length;
- }
-
- /* If things fail after this, we give up.
- * Somebody is messing up inferior_task's mappings.
- */
-
- /* Enable writes to the chained vm regions */
- for (scan = region_head; scan; scan = scan->next)
- {
- boolean_t protection_changed = FALSE;
-
- if (!(scan->protection & VM_PROT_WRITE))
- {
- ret = vm_protect (inferior_task,
- scan->start,
- scan->length,
- FALSE,
- scan->protection | VM_PROT_WRITE);
- CHK_GOTO_OUT ("vm_protect: enable write failed", ret);
- }
- }
-
- ret = vm_write (inferior_task,
- low_address,
- copied_memory,
- aligned_length);
- CHK_GOTO_OUT ("vm_write failed", ret);
-
- /* Set up the original region protections, if they were changed */
- for (scan = region_head; scan; scan = scan->next)
- {
- boolean_t protection_changed = FALSE;
-
- if (!(scan->protection & VM_PROT_WRITE))
- {
- ret = vm_protect (inferior_task,
- scan->start,
- scan->length,
- FALSE,
- scan->protection);
- CHK_GOTO_OUT ("vm_protect: enable write failed", ret);
- }
- }
- }
-
- out:
- if (deallocate)
- {
- obstack_free (&region_obstack, 0);
-
- (void) vm_deallocate (mach_task_self (),
- copied_memory,
- copy_count);
- }
-
- if (ret != KERN_SUCCESS)
- {
- warning ("%s %s", errstr, mach_error_string (ret));
- return 0;
- }
-
- return length;
-}
-
-/* Return 0 on failure, number of bytes handled otherwise. */
-static int
-m3_xfer_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* IGNORED */
-{
- int result;
-
- if (write)
- result = mach3_write_inferior (memaddr, myaddr, len);
- else
- result = mach3_read_inferior (memaddr, myaddr, len);
-
- return result;
-}
-
-
-static char *
-translate_state(state)
-int state;
-{
- switch (state) {
- case TH_STATE_RUNNING: return("R");
- case TH_STATE_STOPPED: return("S");
- case TH_STATE_WAITING: return("W");
- case TH_STATE_UNINTERRUPTIBLE: return("U");
- case TH_STATE_HALTED: return("H");
- default: return("?");
- }
-}
-
-static char *
-translate_cstate (state)
- int state;
-{
- switch (state)
- {
- case CPROC_RUNNING: return "R";
- case CPROC_SWITCHING: return "S";
- case CPROC_BLOCKED: return "B";
- case CPROC_CONDWAIT: return "C";
- case CPROC_CONDWAIT|CPROC_SWITCHING: return "CS";
- default: return "?";
- }
-}
-
-/* type == MACH_MSG_TYPE_COPY_SEND || type == MACH_MSG_TYPE_MAKE_SEND */
-
-mach_port_t /* no mach_port_name_t found in include files. */
-map_inferior_port_name (inferior_name, type)
- mach_port_t inferior_name;
- mach_msg_type_name_t type;
-{
- kern_return_t ret;
- mach_msg_type_name_t acquired;
- mach_port_t iport;
-
- ret = mach_port_extract_right (inferior_task,
- inferior_name,
- type,
- &iport,
- &acquired);
- CHK("mach_port_extract_right (map_inferior_port_name)", ret);
-
- if (acquired != MACH_MSG_TYPE_PORT_SEND)
- error("Incorrect right extracted, (map_inferior_port_name)");
-
- ret = mach_port_deallocate (mach_task_self (),
- iport);
- CHK ("Deallocating mapped port (map_inferior_port_name)", ret);
-
- return iport;
-}
-
-/*
- * Naming convention:
- * Always return user defined name if found.
- * _K == A kernel thread with no matching CPROC
- * _C == A cproc with no current cthread
- * _t == A cthread with no user defined name
- *
- * The digits that follow the _names are the SLOT number of the
- * kernel thread if there is such a thing, otherwise just a negation
- * of the sequential number of such cprocs.
- */
-
-static char buf[7];
-
-static char *
-get_thread_name (one_cproc, id)
- gdb_thread_t one_cproc;
- int id;
-{
- if (one_cproc)
- if (one_cproc->cthread == NULL)
- {
- /* cproc not mapped to any cthread */
- sprintf(buf, "_C%d", id);
- }
- else if (! one_cproc->cthread->name)
- {
- /* cproc and cthread, but no name */
- sprintf(buf, "_t%d", id);
- }
- else
- return (char *)(one_cproc->cthread->name);
- else
- {
- if (id < 0)
- warning ("Inconsistency in thread name id %d", id);
-
- /* Kernel thread without cproc */
- sprintf(buf, "_K%d", id);
- }
-
- return buf;
-}
-
-int
-fetch_thread_info (task, mthreads_out)
- mach_port_t task;
- gdb_thread_t *mthreads_out; /* out */
-{
- kern_return_t ret;
- thread_array_t th_table;
- int th_count;
- gdb_thread_t mthreads = NULL;
- int index;
-
- ret = task_threads (task, &th_table, &th_count);
- if (ret != KERN_SUCCESS)
- {
- warning ("Error getting inferior's thread list:%s",
- mach_error_string(ret));
- m3_kill_inferior ();
- return -1;
- }
-
- mthreads = (gdb_thread_t)
- obstack_alloc
- (cproc_obstack,
- th_count * sizeof (struct gdb_thread));
-
- for (index = 0; index < th_count; index++)
- {
- thread_t saved_thread = MACH_PORT_NULL;
- int mid;
-
- if (must_suspend_thread)
- setup_thread (th_table[ index ], 1);
-
- if (th_table[index] != current_thread)
- {
- saved_thread = current_thread;
-
- mid = switch_to_thread (th_table[ index ]);
- }
-
- mthreads[index].name = th_table[index];
- mthreads[index].cproc = NULL; /* map_cprocs_to_kernel_threads() */
- mthreads[index].in_emulator = FALSE;
- mthreads[index].slotid = index;
-
- mthreads[index].sp = read_register (SP_REGNUM);
- mthreads[index].fp = read_register (FP_REGNUM);
- mthreads[index].pc = read_pc ();
-
- if (MACH_PORT_VALID (saved_thread))
- mid = switch_to_thread (saved_thread);
-
- if (must_suspend_thread)
- setup_thread (th_table[ index ], 0);
- }
-
- consume_send_rights (th_table, th_count);
- ret = vm_deallocate (mach_task_self(), (vm_address_t)th_table,
- (th_count * sizeof(mach_port_t)));
- if (ret != KERN_SUCCESS)
- {
- warning ("Error trying to deallocate thread list : %s",
- mach_error_string (ret));
- }
-
- *mthreads_out = mthreads;
-
- return th_count;
-}
-
-
-/*
- * Current emulator always saves the USP on top of
- * emulator stack below struct emul_stack_top stuff.
- */
-CORE_ADDR
-fetch_usp_from_emulator_stack (sp)
- CORE_ADDR sp;
-{
- CORE_ADDR stack_pointer;
-
- sp = (sp & ~(EMULATOR_STACK_SIZE-1)) +
- EMULATOR_STACK_SIZE - sizeof (struct emul_stack_top);
-
- if (mach3_read_inferior (sp,
- &stack_pointer,
- sizeof (CORE_ADDR)) != sizeof (CORE_ADDR))
- {
- warning ("Can't read user sp from emulator stack address 0x%x", sp);
- return 0;
- }
-
- return stack_pointer;
-}
-
-#ifdef MK67
-
-/* get_emulation_vector() interface was changed after mk67 */
-#define EMUL_VECTOR_COUNT 400 /* Value does not matter too much */
-
-#endif /* MK67 */
-
-/* Check if the emulator exists at task's address space.
- */
-boolean_t
-have_emulator_p (task)
- task_t task;
-{
- kern_return_t ret;
-#ifndef EMUL_VECTOR_COUNT
- vm_offset_t *emulation_vector;
- int n;
-#else
- vm_offset_t emulation_vector[ EMUL_VECTOR_COUNT ];
- int n = EMUL_VECTOR_COUNT;
-#endif
- int i;
- int vector_start;
-
- ret = task_get_emulation_vector (task,
- &vector_start,
-#ifndef EMUL_VECTOR_COUNT
- &emulation_vector,
-#else
- emulation_vector,
-#endif
- &n);
- CHK("task_get_emulation_vector", ret);
- xx_debug ("%d vectors from %d at 0x%08x\n",
- n, vector_start, emulation_vector);
-
- for(i = 0; i < n; i++)
- {
- vm_offset_t entry = emulation_vector [i];
-
- if (EMULATOR_BASE <= entry && entry <= EMULATOR_END)
- return TRUE;
- else if (entry)
- {
- static boolean_t informed = FALSE;
- if (!informed)
- {
- warning("Emulation vector address 0x08%x outside emulator space",
- entry);
- informed = TRUE;
- }
- }
- }
- return FALSE;
-}
-
-/* Map cprocs to kernel threads and vice versa. */
-
-void
-map_cprocs_to_kernel_threads (cprocs, mthreads, thread_count)
- gdb_thread_t cprocs;
- gdb_thread_t mthreads;
- int thread_count;
-{
- int index;
- gdb_thread_t scan;
- boolean_t all_mapped = TRUE;
- LONGEST stack_base;
- LONGEST stack_size;
-
- for (scan = cprocs; scan; scan = scan->next)
- {
- /* Default to: no kernel thread for this cproc */
- scan->reverse_map = -1;
-
- /* Check if the cproc is found by its stack */
- for (index = 0; index < thread_count; index++)
- {
- stack_base =
- extract_signed_integer (scan->raw_cproc + CPROC_BASE_OFFSET,
- CPROC_BASE_SIZE);
- stack_size =
- extract_signed_integer (scan->raw_cproc + CPROC_SIZE_OFFSET,
- CPROC_SIZE_SIZE);
- if ((mthreads + index)->sp > stack_base &&
- (mthreads + index)->sp <= stack_base + stack_size)
- {
- (mthreads + index)->cproc = scan;
- scan->reverse_map = index;
- break;
- }
- }
- all_mapped &= (scan->reverse_map != -1);
- }
-
- /* Check for threads that are currently in the emulator.
- * If so, they have a different stack, and the still unmapped
- * cprocs may well get mapped to these threads.
- *
- * If:
- * - cproc stack does not match any kernel thread stack pointer
- * - there is at least one extra kernel thread
- * that has no cproc mapped above.
- * - some kernel thread stack pointer points to emulator space
- * then we find the user stack pointer saved in the emulator
- * stack, and try to map that to the cprocs.
- *
- * Also set in_emulator for kernel threads.
- */
-
- if (emulator_present)
- {
- for (index = 0; index < thread_count; index++)
- {
- CORE_ADDR emul_sp;
- CORE_ADDR usp;
-
- gdb_thread_t mthread = (mthreads+index);
- emul_sp = mthread->sp;
-
- if (mthread->cproc == NULL &&
- EMULATOR_BASE <= emul_sp && emul_sp <= EMULATOR_END)
- {
- mthread->in_emulator = emulator_present;
-
- if (!all_mapped && cprocs)
- {
- usp = fetch_usp_from_emulator_stack (emul_sp);
-
- /* @@ Could be more accurate */
- if (! usp)
- error ("Zero stack pointer read from emulator?");
-
- /* Try to match this stack pointer to the cprocs that
- * don't yet have a kernel thread.
- */
- for (scan = cprocs; scan; scan = scan->next)
- {
-
- /* Check is this unmapped CPROC stack contains
- * the user stack pointer saved in the
- * emulator.
- */
- if (scan->reverse_map == -1)
- {
- stack_base =
- extract_signed_integer
- (scan->raw_cproc + CPROC_BASE_OFFSET,
- CPROC_BASE_SIZE);
- stack_size =
- extract_signed_integer
- (scan->raw_cproc + CPROC_SIZE_OFFSET,
- CPROC_SIZE_SIZE);
- if (usp > stack_base &&
- usp <= stack_base + stack_size)
- {
- mthread->cproc = scan;
- scan->reverse_map = index;
- break;
- }
- }
- }
- }
- }
- }
- }
-}
-
-/*
- * Format of the thread_list command
- *
- * slot mid sel name emul ks susp cstate wired address
- */
-#define TL_FORMAT "%-2.2s %5d%c %-10.10s %1.1s%s%-5.5s %-2.2s %-5.5s "
-
-#define TL_HEADER "\n@ MID Name KState CState Where\n"
-
-void
-print_tl_address (stream, pc)
- GDB_FILE *stream;
- CORE_ADDR pc;
-{
- if (! lookup_minimal_symbol_by_pc (pc))
- fprintf_filtered (stream, local_hex_format(), pc);
- else
- {
- extern int addressprint;
- extern int asm_demangle;
-
- int store = addressprint;
- addressprint = 0;
- print_address_symbolic (pc, stream, asm_demangle, "");
- addressprint = store;
- }
-}
-
-/* For thread names, but also for gdb_message_port external name */
-#define MAX_NAME_LEN 50
-
-/* Returns the address of variable NAME or 0 if not found */
-CORE_ADDR
-lookup_address_of_variable (name)
- char *name;
-{
- struct symbol *sym;
- CORE_ADDR symaddr = 0;
- struct minimal_symbol *msymbol;
-
- sym = lookup_symbol (name,
- (struct block *)NULL,
- VAR_NAMESPACE,
- (int *)NULL,
- (struct symtab **)NULL);
-
- if (sym)
- symaddr = SYMBOL_VALUE (sym);
-
- if (! symaddr)
- {
- msymbol = lookup_minimal_symbol (name, NULL, NULL);
-
- if (msymbol && msymbol->type == mst_data)
- symaddr = SYMBOL_VALUE_ADDRESS (msymbol);
- }
-
- return symaddr;
-}
-
-static gdb_thread_t
-get_cprocs()
-{
- gdb_thread_t cproc_head;
- gdb_thread_t cproc_copy;
- CORE_ADDR their_cprocs;
- char *buf[TARGET_PTR_BIT / HOST_CHAR_BIT];
- char *name;
- cthread_t cthread;
- CORE_ADDR symaddr;
-
- symaddr = lookup_address_of_variable ("cproc_list");
-
- if (! symaddr)
- {
- /* cproc_list is not in a file compiled with debugging
- symbols, but don't give up yet */
-
- symaddr = lookup_address_of_variable ("cprocs");
-
- if (symaddr)
- {
- static int informed = 0;
- if (!informed)
- {
- informed++;
- warning ("Your program is loaded with an old threads library.");
- warning ("GDB does not know the old form of threads");
- warning ("so things may not work.");
- }
- }
- }
-
- /* Stripped or no -lthreads loaded or "cproc_list" is in wrong segment. */
- if (! symaddr)
- return NULL;
-
- /* Get the address of the first cproc in the task */
- if (!mach3_read_inferior (symaddr,
- buf,
- TARGET_PTR_BIT / HOST_CHAR_BIT))
- error ("Can't read cproc master list at address (0x%x).", symaddr);
- their_cprocs = extract_address (buf, TARGET_PTR_BIT / HOST_CHAR_BIT);
-
- /* Scan the CPROCs in the task.
- CPROCs are chained with LIST field, not NEXT field, which
- chains mutexes, condition variables and queues */
-
- cproc_head = NULL;
-
- while (their_cprocs != (CORE_ADDR)0)
- {
- CORE_ADDR cproc_copy_incarnation;
- cproc_copy = (gdb_thread_t) obstack_alloc (cproc_obstack,
- sizeof (struct gdb_thread));
-
- if (!mach3_read_inferior (their_cprocs,
- &cproc_copy->raw_cproc[0],
- CPROC_SIZE))
- error("Can't read next cproc at 0x%x.", their_cprocs);
-
- their_cprocs =
- extract_address (cproc_copy->raw_cproc + CPROC_LIST_OFFSET,
- CPROC_LIST_SIZE);
- cproc_copy_incarnation =
- extract_address (cproc_copy->raw_cproc + CPROC_INCARNATION_OFFSET,
- CPROC_INCARNATION_SIZE);
-
- if (cproc_copy_incarnation == (CORE_ADDR)0)
- cproc_copy->cthread = NULL;
- else
- {
- /* This CPROC has an attached CTHREAD. Get its name */
- cthread = (cthread_t)obstack_alloc (cproc_obstack,
- sizeof(struct cthread));
-
- if (!mach3_read_inferior (cproc_copy_incarnation,
- cthread,
- sizeof(struct cthread)))
- error("Can't read next thread at 0x%x.",
- cproc_copy_incarnation);
-
- cproc_copy->cthread = cthread;
-
- if (cthread->name)
- {
- name = (char *) obstack_alloc (cproc_obstack, MAX_NAME_LEN);
-
- if (!mach3_read_inferior(cthread->name, name, MAX_NAME_LEN))
- error("Can't read next thread's name at 0x%x.", cthread->name);
-
- cthread->name = name;
- }
- }
-
- /* insert in front */
- cproc_copy->next = cproc_head;
- cproc_head = cproc_copy;
- }
- return cproc_head;
-}
-
-#ifndef FETCH_CPROC_STATE
-/*
- * Check if your machine does not grok the way this routine
- * fetches the FP,PC and SP of a cproc that is not
- * currently attached to any kernel thread (e.g. its cproc.context
- * field points to the place in stack where the context
- * is saved).
- *
- * If it doesn't, define your own routine.
- */
-#define FETCH_CPROC_STATE(mth) mach3_cproc_state (mth)
-
-int
-mach3_cproc_state (mthread)
- gdb_thread_t mthread;
-{
- int context;
-
- if (! mthread || !mthread->cproc)
- return -1;
-
- context = extract_signed_integer
- (mthread->cproc->raw_cproc + CPROC_CONTEXT_OFFSET,
- CPROC_CONTEXT_SIZE);
- if (context == 0)
- return -1;
-
- mthread->sp = context + MACHINE_CPROC_SP_OFFSET;
-
- if (mach3_read_inferior (context + MACHINE_CPROC_PC_OFFSET,
- &mthread->pc,
- sizeof (CORE_ADDR)) != sizeof (CORE_ADDR))
- {
- warning ("Can't read cproc pc from inferior");
- return -1;
- }
-
- if (mach3_read_inferior (context + MACHINE_CPROC_FP_OFFSET,
- &mthread->fp,
- sizeof (CORE_ADDR)) != sizeof (CORE_ADDR))
- {
- warning ("Can't read cproc fp from inferior");
- return -1;
- }
-
- return 0;
-}
-#endif /* FETCH_CPROC_STATE */
-
-
-void
-thread_list_command()
-{
- thread_basic_info_data_t ths;
- int thread_count;
- gdb_thread_t cprocs;
- gdb_thread_t scan;
- int index;
- char *name;
- char selected;
- char *wired;
- int infoCnt;
- kern_return_t ret;
- mach_port_t mid_or_port;
- gdb_thread_t their_threads;
- gdb_thread_t kthread;
-
- int neworder = 1;
-
- char *fmt = "There are %d kernel threads in task %d.\n";
-
- int tmid = map_port_name_to_mid (inferior_task, MACH_TYPE_TASK);
-
- MACH_ERROR_NO_INFERIOR;
-
- thread_count = fetch_thread_info (inferior_task,
- &their_threads);
- if (thread_count == -1)
- return;
-
- if (thread_count == 1)
- fmt = "There is %d kernel thread in task %d.\n";
-
- printf_filtered (fmt, thread_count, tmid);
-
- puts_filtered (TL_HEADER);
-
- cprocs = get_cprocs();
-
- map_cprocs_to_kernel_threads (cprocs, their_threads, thread_count);
-
- for (scan = cprocs; scan; scan = scan->next)
- {
- int mid;
- char buf[10];
- char slot[3];
- int cproc_state =
- extract_signed_integer
- (scan->raw_cproc + CPROC_STATE_OFFSET, CPROC_STATE_SIZE);
-
- selected = ' ';
-
- /* a wired cproc? */
- wired = (extract_address (scan->raw_cproc + CPROC_WIRED_OFFSET,
- CPROC_WIRED_SIZE)
- ? "wired" : "");
-
- if (scan->reverse_map != -1)
- kthread = (their_threads + scan->reverse_map);
- else
- kthread = NULL;
-
- if (kthread)
- {
- /* These cprocs have a kernel thread */
-
- mid = map_port_name_to_mid (kthread->name, MACH_TYPE_THREAD);
-
- infoCnt = THREAD_BASIC_INFO_COUNT;
-
- ret = thread_info (kthread->name,
- THREAD_BASIC_INFO,
- (thread_info_t)&ths,
- &infoCnt);
-
- if (ret != KERN_SUCCESS)
- {
- warning ("Unable to get basic info on thread %d : %s",
- mid,
- mach_error_string (ret));
- continue;
- }
-
- /* Who is the first to have more than 100 threads */
- sprintf (slot, "%d", kthread->slotid%100);
-
- if (kthread->name == current_thread)
- selected = '*';
-
- if (ths.suspend_count)
- sprintf (buf, "%d", ths.suspend_count);
- else
- buf[0] = '\000';
-
-#if 0
- if (ths.flags & TH_FLAGS_SWAPPED)
- strcat (buf, "S");
-#endif
-
- if (ths.flags & TH_FLAGS_IDLE)
- strcat (buf, "I");
-
- printf_filtered (TL_FORMAT,
- slot,
- mid,
- selected,
- get_thread_name (scan, kthread->slotid),
- kthread->in_emulator ? "E" : "",
- translate_state (ths.run_state),
- buf,
- translate_cstate (cproc_state),
- wired);
- print_tl_address (gdb_stdout, kthread->pc);
- }
- else
- {
- /* These cprocs don't have a kernel thread.
- * find out the calling frame with
- * FETCH_CPROC_STATE.
- */
-
- struct gdb_thread state;
-
-#if 0
- /* jtv -> emcmanus: why do you want this here? */
- if (scan->incarnation == NULL)
- continue; /* EMcM */
-#endif
-
- printf_filtered (TL_FORMAT,
- "-",
- -neworder, /* Pseudo MID */
- selected,
- get_thread_name (scan, -neworder),
- "",
- "-", /* kernel state */
- "",
- translate_cstate (cproc_state),
- "");
- state.cproc = scan;
-
- if (FETCH_CPROC_STATE (&state) == -1)
- puts_filtered ("???");
- else
- print_tl_address (gdb_stdout, state.pc);
-
- neworder++;
- }
- puts_filtered ("\n");
- }
-
- /* Scan for kernel threads without cprocs */
- for (index = 0; index < thread_count; index++)
- {
- if (! their_threads[index].cproc)
- {
- int mid;
-
- char buf[10];
- char slot[3];
-
- mach_port_t name = their_threads[index].name;
-
- mid = map_port_name_to_mid (name, MACH_TYPE_THREAD);
-
- infoCnt = THREAD_BASIC_INFO_COUNT;
-
- ret = thread_info(name,
- THREAD_BASIC_INFO,
- (thread_info_t)&ths,
- &infoCnt);
-
- if (ret != KERN_SUCCESS)
- {
- warning ("Unable to get basic info on thread %d : %s",
- mid,
- mach_error_string (ret));
- continue;
- }
-
- sprintf (slot, "%d", index%100);
-
- if (name == current_thread)
- selected = '*';
- else
- selected = ' ';
-
- if (ths.suspend_count)
- sprintf (buf, "%d", ths.suspend_count);
- else
- buf[0] = '\000';
-
-#if 0
- if (ths.flags & TH_FLAGS_SWAPPED)
- strcat (buf, "S");
-#endif
-
- if (ths.flags & TH_FLAGS_IDLE)
- strcat (buf, "I");
-
- printf_filtered (TL_FORMAT,
- slot,
- mid,
- selected,
- get_thread_name (NULL, index),
- their_threads[index].in_emulator ? "E" : "",
- translate_state (ths.run_state),
- buf,
- "", /* No cproc state */
- ""); /* Can't be wired */
- print_tl_address (gdb_stdout, their_threads[index].pc);
- puts_filtered ("\n");
- }
- }
-
- obstack_free (cproc_obstack, 0);
- obstack_init (cproc_obstack);
-}
-
-void
-thread_select_command(args, from_tty)
- char *args;
- int from_tty;
-{
- int mid;
- thread_array_t thread_list;
- int thread_count;
- kern_return_t ret;
- int is_slot = 0;
-
- MACH_ERROR_NO_INFERIOR;
-
- if (!args)
- error_no_arg ("MID or @SLOTNUMBER to specify a thread to select");
-
- while (*args == ' ' || *args == '\t')
- args++;
-
- if (*args == '@')
- {
- is_slot++;
- args++;
- }
-
- mid = atoi(args);
-
- if (mid == 0)
- if (!is_slot || *args != '0') /* Rudimentary checks */
- error ("You must select threads by MID or @SLOTNUMBER");
-
- if (select_thread (inferior_task, mid, is_slot?2:1) != KERN_SUCCESS)
- return;
-
- if (from_tty)
- printf_filtered ("Thread %d selected\n",
- is_slot ? map_port_name_to_mid (current_thread,
- MACH_TYPE_THREAD) : mid);
-}
-
-thread_trace (thread, set)
-mach_port_t thread;
-boolean_t set;
-{
- int flavor = TRACE_FLAVOR;
- unsigned int stateCnt = TRACE_FLAVOR_SIZE;
- kern_return_t ret;
- thread_state_data_t state;
-
- if (! MACH_PORT_VALID (thread))
- {
- warning ("thread_trace: invalid thread");
- return;
- }
-
- if (must_suspend_thread)
- setup_thread (thread, 1);
-
- ret = thread_get_state(thread, flavor, state, &stateCnt);
- CHK ("thread_trace: error reading thread state", ret);
-
- if (set)
- {
- TRACE_SET (thread, state);
- }
- else
- {
- if (! TRACE_CLEAR (thread, state))
- {
- if (must_suspend_thread)
- setup_thread (thread, 0);
- return;
- }
- }
-
- ret = thread_set_state(thread, flavor, state, stateCnt);
- CHK ("thread_trace: error writing thread state", ret);
- if (must_suspend_thread)
- setup_thread (thread, 0);
-}
-
-#ifdef FLUSH_INFERIOR_CACHE
-
-/* When over-writing code on some machines the I-Cache must be flushed
- explicitly, because it is not kept coherent by the lazy hardware.
- This definitely includes breakpoints, for instance, or else we
- end up looping in mysterious Bpt traps */
-
-flush_inferior_icache(pc, amount)
- CORE_ADDR pc;
-{
- vm_machine_attribute_val_t flush = MATTR_VAL_ICACHE_FLUSH;
- kern_return_t ret;
-
- ret = vm_machine_attribute (inferior_task,
- pc,
- amount,
- MATTR_CACHE,
- &flush);
- if (ret != KERN_SUCCESS)
- warning ("Error flushing inferior's cache : %s",
- mach_error_string (ret));
-}
-#endif FLUSH_INFERIOR_CACHE
-
-
-static
-suspend_all_threads (from_tty)
- int from_tty;
-{
- kern_return_t ret;
- thread_array_t thread_list;
- int thread_count, index;
- int infoCnt;
- thread_basic_info_data_t th_info;
-
-
- ret = task_threads (inferior_task, &thread_list, &thread_count);
- if (ret != KERN_SUCCESS)
- {
- warning ("Could not suspend inferior threads.");
- m3_kill_inferior ();
- return_to_top_level (RETURN_ERROR);
- }
-
- for (index = 0; index < thread_count; index++)
- {
- int mid;
-
- mid = map_port_name_to_mid (thread_list[ index ],
- MACH_TYPE_THREAD);
-
- ret = thread_suspend(thread_list[ index ]);
-
- if (ret != KERN_SUCCESS)
- warning ("Error trying to suspend thread %d : %s",
- mid, mach_error_string (ret));
-
- if (from_tty)
- {
- infoCnt = THREAD_BASIC_INFO_COUNT;
- ret = thread_info (thread_list[ index ],
- THREAD_BASIC_INFO,
- (thread_info_t) &th_info,
- &infoCnt);
- CHK ("suspend can't get thread info", ret);
-
- warning ("Thread %d suspend count is %d",
- mid, th_info.suspend_count);
- }
- }
-
- consume_send_rights (thread_list, thread_count);
- ret = vm_deallocate(mach_task_self(),
- (vm_address_t)thread_list,
- (thread_count * sizeof(int)));
- CHK ("Error trying to deallocate thread list", ret);
-}
-
-void
-thread_suspend_command (args, from_tty)
- char *args;
- int from_tty;
-{
- kern_return_t ret;
- int mid;
- mach_port_t saved_thread;
- int infoCnt;
- thread_basic_info_data_t th_info;
-
- MACH_ERROR_NO_INFERIOR;
-
- if (!strcasecmp (args, "all")) {
- suspend_all_threads (from_tty);
- return;
- }
-
- saved_thread = current_thread;
-
- mid = parse_thread_id (args, 0, 0);
-
- if (mid < 0)
- error ("You can suspend only existing kernel threads with MID or @SLOTNUMBER");
-
- if (mid == 0)
- mid = map_port_name_to_mid (current_thread, MACH_TYPE_THREAD);
- else
- if (select_thread (inferior_task, mid, 0) != KERN_SUCCESS)
- {
- if (current_thread)
- current_thread = saved_thread;
- error ("Could not select thread %d", mid);
- }
-
- ret = thread_suspend (current_thread);
- if (ret != KERN_SUCCESS)
- warning ("thread_suspend failed : %s",
- mach_error_string (ret));
-
- infoCnt = THREAD_BASIC_INFO_COUNT;
- ret = thread_info (current_thread,
- THREAD_BASIC_INFO,
- (thread_info_t) &th_info,
- &infoCnt);
- CHK ("suspend can't get thread info", ret);
-
- warning ("Thread %d suspend count is %d", mid, th_info.suspend_count);
-
- current_thread = saved_thread;
-}
-
-resume_all_threads (from_tty)
- int from_tty;
-{
- kern_return_t ret;
- thread_array_t thread_list;
- int thread_count, index;
- int mid;
- int infoCnt;
- thread_basic_info_data_t th_info;
-
- ret = task_threads (inferior_task, &thread_list, &thread_count);
- if (ret != KERN_SUCCESS)
- {
- m3_kill_inferior ();
- error("task_threads", mach_error_string( ret));
- }
-
- for (index = 0; index < thread_count; index++)
- {
- infoCnt = THREAD_BASIC_INFO_COUNT;
- ret = thread_info (thread_list [ index ],
- THREAD_BASIC_INFO,
- (thread_info_t) &th_info,
- &infoCnt);
- CHK ("resume_all can't get thread info", ret);
-
- mid = map_port_name_to_mid (thread_list[ index ],
- MACH_TYPE_THREAD);
-
- if (! th_info.suspend_count)
- {
- if (mid != -1 && from_tty)
- warning ("Thread %d is not suspended", mid);
- continue;
- }
-
- ret = thread_resume (thread_list[ index ]);
-
- if (ret != KERN_SUCCESS)
- warning ("Error trying to resume thread %d : %s",
- mid, mach_error_string (ret));
- else if (mid != -1 && from_tty)
- warning ("Thread %d suspend count is %d",
- mid, --th_info.suspend_count);
- }
-
- consume_send_rights (thread_list, thread_count);
- ret = vm_deallocate(mach_task_self(),
- (vm_address_t)thread_list,
- (thread_count * sizeof(int)));
- CHK("Error trying to deallocate thread list", ret);
-}
-
-void
-thread_resume_command (args, from_tty)
- char *args;
- int from_tty;
-{
- int mid;
- mach_port_t saved_thread;
- kern_return_t ret;
- thread_basic_info_data_t th_info;
- int infoCnt = THREAD_BASIC_INFO_COUNT;
-
- MACH_ERROR_NO_INFERIOR;
-
- if (!strcasecmp (args, "all")) {
- resume_all_threads (from_tty);
- return;
- }
-
- saved_thread = current_thread;
-
- mid = parse_thread_id (args, 0, 0);
-
- if (mid < 0)
- error ("You can resume only existing kernel threads with MID or @SLOTNUMBER");
-
- if (mid == 0)
- mid = map_port_name_to_mid (current_thread, MACH_TYPE_THREAD);
- else
- if (select_thread (inferior_task, mid, 0) != KERN_SUCCESS)
- {
- if (current_thread)
- current_thread = saved_thread;
- return_to_top_level (RETURN_ERROR);
- }
-
- ret = thread_info (current_thread,
- THREAD_BASIC_INFO,
- (thread_info_t) &th_info,
- &infoCnt);
- CHK ("resume can't get thread info", ret);
-
- if (! th_info.suspend_count)
- {
- warning ("Thread %d is not suspended", mid);
- goto out;
- }
-
- ret = thread_resume (current_thread);
- if (ret != KERN_SUCCESS)
- warning ("thread_resume failed : %s",
- mach_error_string (ret));
- else
- {
- th_info.suspend_count--;
- warning ("Thread %d suspend count is %d", mid, th_info.suspend_count);
- }
-
- out:
- current_thread = saved_thread;
-}
-
-void
-thread_kill_command (args, from_tty)
- char *args;
- int from_tty;
-{
- int mid;
- kern_return_t ret;
- int thread_count;
- thread_array_t thread_table;
- int index;
- mach_port_t thread_to_kill = MACH_PORT_NULL;
-
-
- MACH_ERROR_NO_INFERIOR;
-
- if (!args)
- error_no_arg ("thread mid to kill from the inferior task");
-
- mid = parse_thread_id (args, 0, 0);
-
- if (mid < 0)
- error ("You can kill only existing kernel threads with MID or @SLOTNUMBER");
-
- if (mid)
- {
- ret = machid_mach_port (mid_server, mid_auth, mid, &thread_to_kill);
- CHK ("thread_kill_command: machid_mach_port map failed", ret);
- }
- else
- mid = map_port_name_to_mid (current_thread, MACH_TYPE_THREAD);
-
- /* Don't allow gdb to kill *any* thread in the system. Use mkill program for that */
- ret = task_threads (inferior_task, &thread_table, &thread_count);
- CHK ("Error getting inferior's thread list", ret);
-
- if (thread_to_kill == current_thread)
- {
- ret = thread_terminate (thread_to_kill);
- CHK ("Thread could not be terminated", ret);
-
- if (select_thread (inferior_task, 0, 1) != KERN_SUCCESS)
- warning ("Last thread was killed, use \"kill\" command to kill task");
- }
- else
- for (index = 0; index < thread_count; index++)
- if (thread_table [ index ] == thread_to_kill)
- {
- ret = thread_terminate (thread_to_kill);
- CHK ("Thread could not be terminated", ret);
- }
-
- if (thread_count > 1)
- consume_send_rights (thread_table, thread_count);
-
- ret = vm_deallocate (mach_task_self(), (vm_address_t)thread_table,
- (thread_count * sizeof(mach_port_t)));
- CHK ("Error trying to deallocate thread list", ret);
-
- warning ("Thread %d killed", mid);
-}
-
-
-/* Task specific commands; add more if you like */
-
-void
-task_resume_command (args, from_tty)
- char *args;
- int from_tty;
-{
- kern_return_t ret;
- task_basic_info_data_t ta_info;
- int infoCnt = TASK_BASIC_INFO_COUNT;
- int mid = map_port_name_to_mid (inferior_task, MACH_TYPE_TASK);
-
- MACH_ERROR_NO_INFERIOR;
-
- /* Would be trivial to change, but is it desirable? */
- if (args)
- error ("Currently gdb can resume only it's inferior task");
-
- ret = task_info (inferior_task,
- TASK_BASIC_INFO,
- (task_info_t) &ta_info,
- &infoCnt);
- CHK ("task_resume_command: task_info failed", ret);
-
- if (ta_info.suspend_count == 0)
- error ("Inferior task %d is not suspended", mid);
- else if (ta_info.suspend_count == 1 &&
- from_tty &&
- !query ("Suspend count is now 1. Do you know what you are doing? "))
- error ("Task not resumed");
-
- ret = task_resume (inferior_task);
- CHK ("task_resume_command: task_resume", ret);
-
- if (ta_info.suspend_count == 1)
- {
- warning ("Inferior task %d is no longer suspended", mid);
- must_suspend_thread = 1;
- /* @@ This is not complete: Registers change all the time when not
- suspended! */
- registers_changed ();
- }
- else
- warning ("Inferior task %d suspend count is now %d",
- mid, ta_info.suspend_count-1);
-}
-
-
-void
-task_suspend_command (args, from_tty)
- char *args;
- int from_tty;
-{
- kern_return_t ret;
- task_basic_info_data_t ta_info;
- int infoCnt = TASK_BASIC_INFO_COUNT;
- int mid = map_port_name_to_mid (inferior_task, MACH_TYPE_TASK);
-
- MACH_ERROR_NO_INFERIOR;
-
- /* Would be trivial to change, but is it desirable? */
- if (args)
- error ("Currently gdb can suspend only it's inferior task");
-
- ret = task_suspend (inferior_task);
- CHK ("task_suspend_command: task_suspend", ret);
-
- must_suspend_thread = 0;
-
- ret = task_info (inferior_task,
- TASK_BASIC_INFO,
- (task_info_t) &ta_info,
- &infoCnt);
- CHK ("task_suspend_command: task_info failed", ret);
-
- warning ("Inferior task %d suspend count is now %d",
- mid, ta_info.suspend_count);
-}
-
-static char *
-get_size (bytes)
- int bytes;
-{
- static char size [ 30 ];
- int zz = bytes/1024;
-
- if (zz / 1024)
- sprintf (size, "%-2.1f M", ((float)bytes)/(1024.0*1024.0));
- else
- sprintf (size, "%d K", zz);
-
- return size;
-}
-
-/* Does this require the target task to be suspended?? I don't think so. */
-void
-task_info_command (args, from_tty)
- char *args;
- int from_tty;
-{
- int mid = -5;
- mach_port_t task;
- kern_return_t ret;
- task_basic_info_data_t ta_info;
- int infoCnt = TASK_BASIC_INFO_COUNT;
- int page_size = round_page(1);
- int thread_count = 0;
-
- if (MACH_PORT_VALID (inferior_task))
- mid = map_port_name_to_mid (inferior_task,
- MACH_TYPE_TASK);
-
- task = inferior_task;
-
- if (args)
- {
- int tmid = atoi (args);
-
- if (tmid <= 0)
- error ("Invalid mid %d for task info", tmid);
-
- if (tmid != mid)
- {
- mid = tmid;
- ret = machid_mach_port (mid_server, mid_auth, tmid, &task);
- CHK ("task_info_command: machid_mach_port map failed", ret);
- }
- }
-
- if (mid < 0)
- error ("You have to give the task MID as an argument");
-
- ret = task_info (task,
- TASK_BASIC_INFO,
- (task_info_t) &ta_info,
- &infoCnt);
- CHK ("task_info_command: task_info failed", ret);
-
- printf_filtered ("\nTask info for task %d:\n\n", mid);
- printf_filtered (" Suspend count : %d\n", ta_info.suspend_count);
- printf_filtered (" Base priority : %d\n", ta_info.base_priority);
- printf_filtered (" Virtual size : %s\n", get_size (ta_info.virtual_size));
- printf_filtered (" Resident size : %s\n", get_size (ta_info.resident_size));
-
- {
- thread_array_t thread_list;
-
- ret = task_threads (task, &thread_list, &thread_count);
- CHK ("task_info_command: task_threads", ret);
-
- printf_filtered (" Thread count : %d\n", thread_count);
-
- consume_send_rights (thread_list, thread_count);
- ret = vm_deallocate(mach_task_self(),
- (vm_address_t)thread_list,
- (thread_count * sizeof(int)));
- CHK("Error trying to deallocate thread list", ret);
- }
- if (have_emulator_p (task))
- printf_filtered (" Emulator at : 0x%x..0x%x\n",
- EMULATOR_BASE, EMULATOR_END);
- else
- printf_filtered (" No emulator.\n");
-
- if (thread_count && task == inferior_task)
- printf_filtered ("\nUse the \"thread list\" command to see the threads\n");
-}
-
-/* You may either FORWARD the exception to the inferior, or KEEP
- * it and return to GDB command level.
- *
- * exception mid [ forward | keep ]
- */
-
-static void
-exception_command (args, from_tty)
- char *args;
- int from_tty;
-{
- char *scan = args;
- int exception;
- int len;
-
- if (!args)
- error_no_arg ("exception number action");
-
- while (*scan == ' ' || *scan == '\t') scan++;
-
- if ('0' <= *scan && *scan <= '9')
- while ('0' <= *scan && *scan <= '9')
- scan++;
- else
- error ("exception number action");
-
- exception = atoi (args);
- if (exception <= 0 || exception > MAX_EXCEPTION)
- error ("Allowed exception numbers are in range 1..%d",
- MAX_EXCEPTION);
-
- if (*scan != ' ' && *scan != '\t')
- error ("exception number must be followed by a space");
- else
- while (*scan == ' ' || *scan == '\t') scan++;
-
- args = scan;
- len = 0;
- while (*scan)
- {
- len++;
- scan++;
- }
-
- if (!len)
- error("exception number action");
-
- if (!strncasecmp (args, "forward", len))
- exception_map[ exception ].forward = TRUE;
- else if (!strncasecmp (args, "keep", len))
- exception_map[ exception ].forward = FALSE;
- else
- error ("exception action is either \"keep\" or \"forward\"");
-}
-
-static void
-print_exception_info (exception)
- int exception;
-{
- boolean_t forward = exception_map[ exception ].forward;
-
- printf_filtered ("%s\t(%d): ", exception_map[ exception ].name,
- exception);
- if (!forward)
- if (exception_map[ exception ].sigmap != SIG_UNKNOWN)
- printf_filtered ("keep and handle as signal %d\n",
- exception_map[ exception ].sigmap);
- else
- printf_filtered ("keep and handle as unknown signal %d\n",
- exception_map[ exception ].sigmap);
- else
- printf_filtered ("forward exception to inferior\n");
-}
-
-void
-exception_info (args, from_tty)
- char *args;
- int from_tty;
-{
- int exception;
-
- if (!args)
- for (exception = 1; exception <= MAX_EXCEPTION; exception++)
- print_exception_info (exception);
- else
- {
- exception = atoi (args);
-
- if (exception <= 0 || exception > MAX_EXCEPTION)
- error ("Invalid exception number, values from 1 to %d allowed",
- MAX_EXCEPTION);
- print_exception_info (exception);
- }
-}
-
-/* Check for actions for mach exceptions.
- */
-mach3_exception_actions (w, force_print_only, who)
- WAITTYPE *w;
- boolean_t force_print_only;
- char *who;
-{
- boolean_t force_print = FALSE;
-
-
- if (force_print_only ||
- exception_map[stop_exception].sigmap == SIG_UNKNOWN)
- force_print = TRUE;
- else
- WSETSTOP (*w, exception_map[stop_exception].sigmap);
-
- if (exception_map[stop_exception].print || force_print)
- {
- target_terminal_ours ();
-
- printf_filtered ("\n%s received %s exception : ",
- who,
- exception_map[stop_exception].name);
-
- wrap_here (" ");
-
- switch(stop_exception) {
- case EXC_BAD_ACCESS:
- printf_filtered ("referencing address 0x%x : %s\n",
- stop_subcode,
- mach_error_string (stop_code));
- break;
- case EXC_BAD_INSTRUCTION:
- printf_filtered
- ("illegal or undefined instruction. code %d subcode %d\n",
- stop_code, stop_subcode);
- break;
- case EXC_ARITHMETIC:
- printf_filtered ("code %d\n", stop_code);
- break;
- case EXC_EMULATION:
- printf_filtered ("code %d subcode %d\n", stop_code, stop_subcode);
- break;
- case EXC_SOFTWARE:
- printf_filtered ("%s specific, code 0x%x\n",
- stop_code < 0xffff ? "hardware" : "os emulation",
- stop_code);
- break;
- case EXC_BREAKPOINT:
- printf_filtered ("type %d (machine dependent)\n",
- stop_code);
- break;
- default:
- fatal ("Unknown exception");
- }
- }
-}
-
-setup_notify_port (create_new)
- int create_new;
-{
- kern_return_t ret;
-
- if (MACH_PORT_VALID (our_notify_port))
- {
- ret = mach_port_destroy (mach_task_self (), our_notify_port);
- CHK ("Could not destroy our_notify_port", ret);
- }
-
- our_notify_port = MACH_PORT_NULL;
- notify_chain = (port_chain_t) NULL;
- port_chain_destroy (port_chain_obstack);
-
- if (create_new)
- {
- ret = mach_port_allocate (mach_task_self(),
- MACH_PORT_RIGHT_RECEIVE,
- &our_notify_port);
- if (ret != KERN_SUCCESS)
- fatal("Creating notify port %s", mach_error_string(ret));
-
- ret = mach_port_move_member(mach_task_self(),
- our_notify_port,
- inferior_wait_port_set);
- if (ret != KERN_SUCCESS)
- fatal("initial move member %s",mach_error_string(ret));
- }
-}
-
-/*
- * Register our message port to the net name server
- *
- * Currently used only by the external stop-gdb program
- * since ^C does not work if you would like to enter
- * gdb command level while debugging your program.
- *
- * NOTE: If the message port is sometimes used for other
- * purposes also, the NAME must not be a guessable one.
- * Then, there should be a way to change it.
- */
-
-char registered_name[ MAX_NAME_LEN ];
-
-void
-message_port_info (args, from_tty)
- char *args;
- int from_tty;
-{
- if (registered_name[0])
- printf_filtered ("gdb's message port name: '%s'\n",
- registered_name);
- else
- printf_filtered ("gdb's message port is not currently registered\n");
-}
-
-void
-gdb_register_port (name, port)
- char *name;
- mach_port_t port;
-{
- kern_return_t ret;
- static int already_signed = 0;
- int len;
-
- if (! MACH_PORT_VALID (port) || !name || !*name)
- {
- warning ("Invalid registration request");
- return;
- }
-
- if (! already_signed)
- {
- ret = mach_port_insert_right (mach_task_self (),
- our_message_port,
- our_message_port,
- MACH_MSG_TYPE_MAKE_SEND);
- CHK ("Failed to create a signature to our_message_port", ret);
- already_signed = 1;
- }
- else if (already_signed > 1)
- {
- ret = netname_check_out (name_server_port,
- registered_name,
- our_message_port);
- CHK ("Failed to check out gdb's message port", ret);
- registered_name[0] = '\000';
- already_signed = 1;
- }
-
- ret = netname_check_in (name_server_port, /* Name server port */
- name, /* Name of service */
- our_message_port, /* Signature */
- port); /* Creates a new send right */
- CHK("Failed to check in the port", ret);
-
- len = 0;
- while(len < MAX_NAME_LEN && *(name+len))
- {
- registered_name[len] = *(name+len);
- len++;
- }
- registered_name[len] = '\000';
- already_signed = 2;
-}
-
-struct cmd_list_element *cmd_thread_list;
-struct cmd_list_element *cmd_task_list;
-
-/*ARGSUSED*/
-static void
-thread_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- printf_unfiltered ("\"thread\" must be followed by the name of a thread command.\n");
- help_list (cmd_thread_list, "thread ", -1, gdb_stdout);
-}
-
-/*ARGSUSED*/
-static void
-task_command (arg, from_tty)
- char *arg;
- int from_tty;
-{
- printf_unfiltered ("\"task\" must be followed by the name of a task command.\n");
- help_list (cmd_task_list, "task ", -1, gdb_stdout);
-}
-
-add_mach_specific_commands ()
-{
- /* Thread handling commands */
-
- /* FIXME: Move our thread support into the generic thread.c stuff so we
- can share that code. */
- add_prefix_cmd ("mthread", class_stack, thread_command,
- "Generic command for handling Mach threads in the debugged task.",
- &cmd_thread_list, "thread ", 0, &cmdlist);
-
- add_com_alias ("th", "mthread", class_stack, 1);
-
- add_cmd ("select", class_stack, thread_select_command,
- "Select and print MID of the selected thread",
- &cmd_thread_list);
- add_cmd ("list", class_stack, thread_list_command,
- "List info of task's threads. Selected thread is marked with '*'",
- &cmd_thread_list);
- add_cmd ("suspend", class_run, thread_suspend_command,
- "Suspend one or all of the threads in the selected task.",
- &cmd_thread_list);
- add_cmd ("resume", class_run, thread_resume_command,
- "Resume one or all of the threads in the selected task.",
- &cmd_thread_list);
- add_cmd ("kill", class_run, thread_kill_command,
- "Kill the specified thread MID from inferior task.",
- &cmd_thread_list);
-#if 0
- /* The rest of this support (condition_thread) was not merged. It probably
- should not be merged in this form, but instead added to the generic GDB
- thread support. */
- add_cmd ("break", class_breakpoint, condition_thread,
- "Breakpoint N will only be effective for thread MID or @SLOT\n\
- If MID/@SLOT is omitted allow all threads to break at breakpoint",
- &cmd_thread_list);
-#endif
- /* Thread command shorthands (for backward compatibility) */
- add_alias_cmd ("ts", "mthread select", 0, 0, &cmdlist);
- add_alias_cmd ("tl", "mthread list", 0, 0, &cmdlist);
-
- /* task handling commands */
-
- add_prefix_cmd ("task", class_stack, task_command,
- "Generic command for handling debugged task.",
- &cmd_task_list, "task ", 0, &cmdlist);
-
- add_com_alias ("ta", "task", class_stack, 1);
-
- add_cmd ("suspend", class_run, task_suspend_command,
- "Suspend the inferior task.",
- &cmd_task_list);
- add_cmd ("resume", class_run, task_resume_command,
- "Resume the inferior task.",
- &cmd_task_list);
- add_cmd ("info", no_class, task_info_command,
- "Print information about the specified task.",
- &cmd_task_list);
-
- /* Print my message port name */
-
- add_info ("message-port", message_port_info,
- "Returns the name of gdb's message port in the netnameserver");
-
- /* Exception commands */
-
- add_info ("exceptions", exception_info,
- "What debugger does when program gets various exceptions.\n\
-Specify an exception number as argument to print info on that\n\
-exception only.");
-
- add_com ("exception", class_run, exception_command,
- "Specify how to handle an exception.\n\
-Args are exception number followed by \"forward\" or \"keep\".\n\
-`Forward' means forward the exception to the program's normal exception\n\
-handler.\n\
-`Keep' means reenter debugger if this exception happens, and GDB maps\n\
-the exception to some signal (see info exception)\n\
-Normally \"keep\" is used to return to GDB on exception.");
-}
-
-kern_return_t
-do_mach_notify_dead_name (notify, name)
- mach_port_t notify;
- mach_port_t name;
-{
- kern_return_t kr = KERN_SUCCESS;
-
- /* Find the thing that notified */
- port_chain_t element = port_chain_member (notify_chain, name);
-
- /* Take name of from unreceived dead name notification list */
- notify_chain = port_chain_delete (notify_chain, name);
-
- if (! element)
- error ("Received a dead name notify from unchained port (0x%x)", name);
-
- switch (element->type) {
-
- case MACH_TYPE_THREAD:
- target_terminal_ours_for_output ();
- if (name == current_thread)
- {
- printf_filtered ("\nCurrent thread %d died", element->mid);
- current_thread = MACH_PORT_NULL;
- }
- else
- printf_filtered ("\nThread %d died", element->mid);
-
- break;
-
- case MACH_TYPE_TASK:
- target_terminal_ours_for_output ();
- if (name != inferior_task)
- printf_filtered ("Task %d died, but it was not the selected task",
- element->mid);
- else
- {
- printf_filtered ("Current task %d died", element->mid);
-
- mach_port_destroy (mach_task_self(), name);
- inferior_task = MACH_PORT_NULL;
-
- if (notify_chain)
- warning ("There were still unreceived dead_name_notifications???");
-
- /* Destroy the old notifications */
- setup_notify_port (0);
-
- }
- break;
-
- default:
- error ("Unregistered dead_name 0x%x notification received. Type is %d, mid is 0x%x",
- name, element->type, element->mid);
- break;
- }
-
- return KERN_SUCCESS;
-}
-
-kern_return_t
-do_mach_notify_msg_accepted (notify, name)
- mach_port_t notify;
- mach_port_t name;
-{
- warning ("do_mach_notify_msg_accepted : notify %x, name %x",
- notify, name);
- return KERN_SUCCESS;
-}
-
-kern_return_t
-do_mach_notify_no_senders (notify, mscount)
- mach_port_t notify;
- mach_port_mscount_t mscount;
-{
- warning ("do_mach_notify_no_senders : notify %x, mscount %x",
- notify, mscount);
- return KERN_SUCCESS;
-}
-
-kern_return_t
-do_mach_notify_port_deleted (notify, name)
- mach_port_t notify;
- mach_port_t name;
-{
- warning ("do_mach_notify_port_deleted : notify %x, name %x",
- notify, name);
- return KERN_SUCCESS;
-}
-
-kern_return_t
-do_mach_notify_port_destroyed (notify, rights)
- mach_port_t notify;
- mach_port_t rights;
-{
- warning ("do_mach_notify_port_destroyed : notify %x, rights %x",
- notify, rights);
- return KERN_SUCCESS;
-}
-
-kern_return_t
-do_mach_notify_send_once (notify)
- mach_port_t notify;
-{
-#ifdef DUMP_SYSCALL
- /* MANY of these are generated. */
- warning ("do_mach_notify_send_once : notify %x",
- notify);
-#endif
- return KERN_SUCCESS;
-}
-
-/* Kills the inferior. It's gone when you call this */
-static void
-kill_inferior_fast ()
-{
- WAITTYPE w;
-
- if (inferior_pid == 0 || inferior_pid == 1)
- return;
-
- /* kill() it, since the Unix server does not otherwise notice when
- * killed with task_terminate().
- */
- if (inferior_pid > 0)
- kill (inferior_pid, SIGKILL);
-
- /* It's propably terminate already */
- (void) task_terminate (inferior_task);
-
- inferior_task = MACH_PORT_NULL;
- current_thread = MACH_PORT_NULL;
-
- wait3 (&w, WNOHANG, 0);
-
- setup_notify_port (0);
-}
-
-static void
-m3_kill_inferior ()
-{
- kill_inferior_fast ();
- target_mourn_inferior ();
-}
-
-/* Clean up after the inferior dies. */
-
-static void
-m3_mourn_inferior ()
-{
- unpush_target (&m3_ops);
- generic_mourn_inferior ();
-}
-
-
-/* Fork an inferior process, and start debugging it. */
-
-static void
-m3_create_inferior (exec_file, allargs, env)
- char *exec_file;
- char *allargs;
- char **env;
-{
- fork_inferior (exec_file, allargs, env, m3_trace_me, m3_trace_him, NULL, NULL);
- /* We are at the first instruction we care about. */
- /* Pedal to the metal... */
- proceed ((CORE_ADDR) -1, 0, 0);
-}
-
-/* Mark our target-struct as eligible for stray "run" and "attach"
- commands. */
-static int
-m3_can_run ()
-{
- return 1;
-}
-
-/* Mach 3.0 does not need ptrace for anything
- * Make sure nobody uses it on mach.
- */
-ptrace (a,b,c,d)
-int a,b,c,d;
-{
- error ("Lose, Lose! Somebody called ptrace\n");
-}
-
-/* Resume execution of the inferior process.
- If STEP is nonzero, single-step it.
- If SIGNAL is nonzero, give it that signal. */
-
-void
-m3_resume (pid, step, signal)
- int pid;
- int step;
- enum target_signal signal;
-{
- kern_return_t ret;
-
- if (step)
- {
- thread_basic_info_data_t th_info;
- unsigned int infoCnt = THREAD_BASIC_INFO_COUNT;
-
- /* There is no point in single stepping when current_thread
- * is dead.
- */
- if (! MACH_PORT_VALID (current_thread))
- error ("No thread selected; can not single step");
-
- /* If current_thread is suspended, tracing it would never return.
- */
- ret = thread_info (current_thread,
- THREAD_BASIC_INFO,
- (thread_info_t) &th_info,
- &infoCnt);
- CHK ("child_resume: can't get thread info", ret);
-
- if (th_info.suspend_count)
- error ("Can't trace a suspended thread. Use \"thread resume\" command to resume it");
- }
-
- vm_read_cache_valid = FALSE;
-
- if (signal && inferior_pid > 0) /* Do not signal, if attached by MID */
- kill (inferior_pid, target_signal_to_host (signal));
-
- if (step)
- {
- suspend_all_threads (0);
-
- setup_single_step (current_thread, TRUE);
-
- ret = thread_resume (current_thread);
- CHK ("thread_resume", ret);
- }
-
- ret = task_resume (inferior_task);
- if (ret == KERN_FAILURE)
- warning ("Task was not suspended");
- else
- CHK ("Resuming task", ret);
-
- /* HACK HACK This is needed by the multiserver system HACK HACK */
- while ((ret = task_resume(inferior_task)) == KERN_SUCCESS)
- /* make sure it really runs */;
- /* HACK HACK This is needed by the multiserver system HACK HACK */
-}
-
-#ifdef ATTACH_DETACH
-
-/* Start debugging the process with the given task */
-void
-task_attach (tid)
- task_t tid;
-{
- kern_return_t ret;
- inferior_task = tid;
-
- ret = task_suspend (inferior_task);
- CHK("task_attach: task_suspend", ret);
-
- must_suspend_thread = 0;
-
- setup_notify_port (1);
-
- request_notify (inferior_task, MACH_NOTIFY_DEAD_NAME, MACH_TYPE_TASK);
-
- setup_exception_port ();
-
- emulator_present = have_emulator_p (inferior_task);
-
- attach_flag = 1;
-}
-
-/* Well, we can call error also here and leave the
- * target stack inconsistent. Sigh.
- * Fix this sometime (the only way to fail here is that
- * the task has no threads at all, which is rare, but
- * possible; or if the target task has died, which is also
- * possible, but unlikely, since it has been suspended.
- * (Someone must have killed it))
- */
-void
-attach_to_thread ()
-{
- if (select_thread (inferior_task, 0, 1) != KERN_SUCCESS)
- error ("Could not select any threads to attach to");
-}
-
-mid_attach (mid)
- int mid;
-{
- kern_return_t ret;
-
- ret = machid_mach_port (mid_server, mid_auth, mid, &inferior_task);
- CHK("mid_attach: machid_mach_port", ret);
-
- task_attach (inferior_task);
-
- return mid;
-}
-
-/*
- * Start debugging the process whose unix process-id is PID.
- * A negative "pid" value is legal and signifies a mach_id not a unix pid.
- *
- * Prevent (possible unwanted) dangerous operations by enabled users
- * like "atta 0" or "atta foo" (equal to the previous :-) and
- * "atta pidself". Anyway, the latter is allowed by specifying a MID.
- */
-static int
-m3_do_attach (pid)
- int pid;
-{
- kern_return_t ret;
-
- if (pid == 0)
- error("MID=0, Debugging the master unix server does not compute");
-
- /* Foo. This assumes gdb has a unix pid */
- if (pid == getpid())
- error ("I will debug myself only by mid. (Gdb would suspend itself!)");
-
- if (pid < 0)
- {
- mid_attach (-(pid));
-
- /* inferior_pid will be NEGATIVE! */
- inferior_pid = pid;
-
- return inferior_pid;
- }
-
- inferior_task = task_by_pid (pid);
- if (! MACH_PORT_VALID (inferior_task))
- error("Cannot map Unix pid %d to Mach task port", pid);
-
- task_attach (inferior_task);
-
- inferior_pid = pid;
-
- return inferior_pid;
-}
-
-/* Attach to process PID, then initialize for debugging it
- and wait for the trace-trap that results from attaching. */
-
-static void
-m3_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- char *exec_file;
- int pid;
-
- if (!args)
- error_no_arg ("process-id to attach");
-
- pid = atoi (args);
-
- if (pid == getpid()) /* Trying to masturbate? */
- error ("I refuse to debug myself!");
-
- if (from_tty)
- {
- exec_file = (char *) get_exec_file (0);
-
- if (exec_file)
- printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, target_pid_to_str (pid));
- else
- printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
-
- gdb_flush (gdb_stdout);
- }
-
- m3_do_attach (pid);
- inferior_pid = pid;
- push_target (&m3_ops);
-}
-
-void
-deallocate_inferior_ports ()
-{
- kern_return_t ret;
- thread_array_t thread_list;
- int thread_count, index;
-
- if (!MACH_PORT_VALID (inferior_task))
- return;
-
- ret = task_threads (inferior_task, &thread_list, &thread_count);
- if (ret != KERN_SUCCESS)
- {
- warning ("deallocate_inferior_ports: task_threads",
- mach_error_string(ret));
- return;
- }
-
- /* Get rid of send rights to task threads */
- for (index = 0; index < thread_count; index++)
- {
- int rights;
- ret = mach_port_get_refs (mach_task_self (),
- thread_list[index],
- MACH_PORT_RIGHT_SEND,
- &rights);
- CHK("deallocate_inferior_ports: get refs", ret);
-
- if (rights > 0)
- {
- ret = mach_port_mod_refs (mach_task_self (),
- thread_list[index],
- MACH_PORT_RIGHT_SEND,
- -rights);
- CHK("deallocate_inferior_ports: mod refs", ret);
- }
- }
-
- ret = mach_port_mod_refs (mach_task_self (),
- inferior_exception_port,
- MACH_PORT_RIGHT_RECEIVE,
- -1);
- CHK ("deallocate_inferior_ports: cannot get rid of exception port", ret);
-
- ret = mach_port_deallocate (mach_task_self (),
- inferior_task);
- CHK ("deallocate_task_port: deallocating inferior_task", ret);
-
- current_thread = MACH_PORT_NULL;
- inferior_task = MACH_PORT_NULL;
-}
-
-/* Stop debugging the process whose number is PID
- and continue it with signal number SIGNAL.
- SIGNAL = 0 means just continue it. */
-
-static void
-m3_do_detach (signal)
- int signal;
-{
- kern_return_t ret;
-
- MACH_ERROR_NO_INFERIOR;
-
- if (current_thread != MACH_PORT_NULL)
- {
- /* Store the gdb's view of the thread we are deselecting
- * before we detach.
- * @@ I am really not sure if this is ever needeed.
- */
- target_prepare_to_store ();
- target_store_registers (-1);
- }
-
- ret = task_set_special_port (inferior_task,
- TASK_EXCEPTION_PORT,
- inferior_old_exception_port);
- CHK ("task_set_special_port", ret);
-
- /* Discard all requested notifications */
- setup_notify_port (0);
-
- if (remove_breakpoints ())
- warning ("Could not remove breakpoints when detaching");
-
- if (signal && inferior_pid > 0)
- kill (inferior_pid, signal);
-
- /* the task might be dead by now */
- (void) task_resume (inferior_task);
-
- deallocate_inferior_ports ();
-
- attach_flag = 0;
-}
-
-/* Take a program previously attached to and detaches it.
- The program resumes execution and will no longer stop
- on signals, etc. We'd 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 fork. */
-
-static void
-m3_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- int siggnal = 0;
-
- if (from_tty)
- {
- char *exec_file = get_exec_file (0);
- if (exec_file == 0)
- exec_file = "";
- printf_unfiltered ("Detaching from program: %s %s\n",
- exec_file, target_pid_to_str (inferior_pid));
- gdb_flush (gdb_stdout);
- }
- if (args)
- siggnal = atoi (args);
-
- m3_do_detach (siggnal);
- inferior_pid = 0;
- unpush_target (&m3_ops); /* Pop out of handling an inferior */
-}
-#endif /* ATTACH_DETACH */
-
-/* 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
-m3_prepare_to_store ()
-{
-#ifdef CHILD_PREPARE_TO_STORE
- CHILD_PREPARE_TO_STORE ();
-#endif
-}
-
-/* Print status information about what we're accessing. */
-
-static void
-m3_files_info (ignore)
- struct target_ops *ignore;
-{
- /* FIXME: should print MID and all that crap. */
- printf_unfiltered ("\tUsing the running image of %s %s.\n",
- attach_flag? "attached": "child", target_pid_to_str (inferior_pid));
-}
-
-static void
-m3_open (arg, from_tty)
- char *arg;
- int from_tty;
-{
- error ("Use the \"run\" command to start a Unix child process.");
-}
-
-#ifdef DUMP_SYSCALL
-#ifdef __STDC__
-#define STR(x) #x
-#else
-#define STR(x) "x"
-#endif
-
-char *bsd1_names[] = {
- "execve",
- "fork",
- "take_signal",
- "sigreturn",
- "getrusage",
- "chdir",
- "chroot",
- "open",
- "creat",
- "mknod",
- "link",
- "symlink",
- "unlink",
- "access",
- "stat",
- "readlink",
- "chmod",
- "chown",
- "utimes",
- "truncate",
- "rename",
- "mkdir",
- "rmdir",
- "xutimes",
- "mount",
- "umount",
- "acct",
- "setquota",
- "write_short",
- "write_long",
- "send_short",
- "send_long",
- "sendto_short",
- "sendto_long",
- "select",
- "task_by_pid",
- "recvfrom_short",
- "recvfrom_long",
- "setgroups",
- "setrlimit",
- "sigvec",
- "sigstack",
- "settimeofday",
- "adjtime",
- "setitimer",
- "sethostname",
- "bind",
- "accept",
- "connect",
- "setsockopt",
- "getsockopt",
- "getsockname",
- "getpeername",
- "init_process",
- "table_set",
- "table_get",
- "pioctl",
- "emulator_error",
- "readwrite",
- "share_wakeup",
- 0,
- "maprw_request_it",
- "maprw_release_it",
- "maprw_remap",
- "pid_by_task",
-};
-
-int bsd1_nnames = sizeof(bsd1_names)/sizeof(bsd1_names[0]);
-
-char*
-name_str(name,buf)
-
-int name;
-char *buf;
-
-{
- switch (name) {
- case MACH_MSG_TYPE_BOOLEAN:
- return "boolean";
- case MACH_MSG_TYPE_INTEGER_16:
- return "short";
- case MACH_MSG_TYPE_INTEGER_32:
- return "long";
- case MACH_MSG_TYPE_CHAR:
- return "char";
- case MACH_MSG_TYPE_BYTE:
- return "byte";
- case MACH_MSG_TYPE_REAL:
- return "real";
- case MACH_MSG_TYPE_STRING:
- return "string";
- default:
- sprintf(buf,"%d",name);
- return buf;
- }
-}
-
-char *
-id_str(id,buf)
-
-int id;
-char *buf;
-
-{
- char *p;
- if (id >= 101000 && id < 101000+bsd1_nnames) {
- if (p = bsd1_names[id-101000])
- return p;
- }
- if (id == 102000)
- return "psignal_retry";
- if (id == 100000)
- return "syscall";
- sprintf(buf,"%d",id);
- return buf;
-}
-
-print_msg(mp)
-mach_msg_header_t *mp;
-{
- char *fmt_x = "%20s : 0x%08x\n";
- char *fmt_d = "%20s : %10d\n";
- char *fmt_s = "%20s : %s\n";
- char buf[100];
-
- puts_filtered ("\n");
-#define pr(fmt,h,x) printf_filtered(fmt,STR(x),(h).x)
- pr(fmt_x,(*mp),msgh_bits);
- pr(fmt_d,(*mp),msgh_size);
- pr(fmt_x,(*mp),msgh_remote_port);
- pr(fmt_x,(*mp),msgh_local_port);
- pr(fmt_d,(*mp),msgh_kind);
- printf_filtered(fmt_s,STR(msgh_id),id_str(mp->msgh_id,buf));
-
- if (debug_level > 1)
- {
- char *p,*ep,*dp;
- int plen;
- p = (char*)mp;
- ep = p+mp->msgh_size;
- p += sizeof(*mp);
- for(; p < ep; p += plen) {
- mach_msg_type_t *tp;
- mach_msg_type_long_t *tlp;
- int name,size,number;
- tp = (mach_msg_type_t*)p;
- if (tp->msgt_longform) {
- tlp = (mach_msg_type_long_t*)tp;
- name = tlp->msgtl_name;
- size = tlp->msgtl_size;
- number = tlp->msgtl_number;
- plen = sizeof(*tlp);
- } else {
- name = tp->msgt_name;
- size = tp->msgt_size;
- number = tp->msgt_number;
- plen = sizeof(*tp);
- }
- printf_filtered("name=%-16s size=%2d number=%7d inline=%d long=%d deal=%d\n",
- name_str(name,buf),size,number,tp->msgt_inline,
- tp->msgt_longform, tp->msgt_deallocate);
- dp = p+plen;
- if (tp->msgt_inline) {
- int l;
- l = size*number/8;
- l = (l+sizeof(long)-1)&~((sizeof(long))-1);
- plen += l;
- print_data(dp,size,number);
- } else {
- plen += sizeof(int*);
- }
- printf_filtered("plen=%d\n",plen);
- }
- }
-}
-
-print_data(p,size,number)
-
-char *p;
-
-{
- int *ip;
- short *sp;
- int i;
-
- switch (size) {
- case 8:
- for(i = 0; i < number; i++) {
- printf_filtered(" %02x",p[i]);
- }
- break;
- case 16:
- sp = (short*)p;
- for(i = 0; i < number; i++) {
- printf_filtered(" %04x",sp[i]);
- }
- break;
- case 32:
- ip = (int*)p;
- for(i = 0; i < number; i++) {
- printf_filtered(" %08x",ip[i]);
- }
- break;
- }
- puts_filtered("\n");
-}
-#endif DUMP_SYSCALL
-
-static void
-m3_stop ()
-{
- error ("to_stop target function not implemented");
-}
-
-static char *
-m3_pid_to_exec_file (pid)
-int pid;
-{
- error ("to_pid_to_exec_file target function not implemented");
- return NULL; /* To keep all compilers happy. */
-}
-
-static void
-init_m3_ops ()
-{
- m3_ops.to_shortname = "mach";
- m3_ops.to_longname = "Mach child process";
- m3_ops.to_doc = "Mach child process (started by the \"run\" command).";
- m3_ops.to_open = m3_open;
- m3_ops.to_attach = m3_attach;
- m3_ops.to_detach = m3_detach;
- m3_ops.to_resume = m3_resume;
- m3_ops.to_wait = mach_really__wait;
- m3_ops.to_fetch_registers = fetch_inferior_registers;
- m3_ops.to_store_registers = store_inferior_registers;
- m3_ops.to_prepare_to_store = m3_prepare_to_store;
- m3_ops.to_xfer_memory = m3_xfer_memory;
- m3_ops.to_files_info = m3_files_info;
- m3_ops.to_insert_breakpoint = memory_insert_breakpoint;
- m3_ops.to_remove_breakpoint = memory_remove_breakpoint;
- m3_ops.to_terminal_init = terminal_init_inferior;
- m3_ops.to_terminal_inferior = terminal_inferior;
- m3_ops.to_terminal_ours_for_output = terminal_ours_for_output;
- m3_ops.to_terminal_ours = terminal_ours;
- m3_ops.to_terminal_info = child_terminal_info;
- m3_ops.to_kill = m3_kill_inferior;
- m3_ops.to_create_inferior = m3_create_inferior;
- m3_ops.to_mourn_inferior = m3_mourn_inferior;
- m3_ops.to_can_run = m3_can_run;
- m3_ops.to_stop = m3_stop;
- m3_ops.to_pid_to_exec_file = m3_pid_to_exec_file;
- m3_ops.to_stratum = process_stratum;
- m3_ops.to_has_all_memory = 1;
- m3_ops.to_has_memory = 1;
- m3_ops.to_has_stack = 1;
- m3_ops.to_has_registers = 1;
- m3_ops.to_has_execution = 1;
- m3_ops.to_magic = OPS_MAGIC;
-}
-
-void
-_initialize_m3_nat ()
-{
- kern_return_t ret;
-
- init_m3_ops ();
- add_target (&m3_ops);
-
- ret = mach_port_allocate(mach_task_self(),
- MACH_PORT_RIGHT_PORT_SET,
- &inferior_wait_port_set);
- if (ret != KERN_SUCCESS)
- fatal("initial port set %s",mach_error_string(ret));
-
- /* mach_really_wait now waits for this */
- currently_waiting_for = inferior_wait_port_set;
-
- ret = netname_look_up(name_server_port, hostname, "MachID", &mid_server);
- if (ret != KERN_SUCCESS)
- {
- mid_server = MACH_PORT_NULL;
-
- warning ("initialize machid: netname_lookup_up(MachID) : %s",
- mach_error_string(ret));
- warning ("Some (most?) features disabled...");
- }
-
- mid_auth = mach_privileged_host_port();
- if (mid_auth == MACH_PORT_NULL)
- mid_auth = mach_task_self();
-
- obstack_init (port_chain_obstack);
-
- ret = mach_port_allocate (mach_task_self (),
- MACH_PORT_RIGHT_RECEIVE,
- &thread_exception_port);
- CHK ("Creating thread_exception_port for single stepping", ret);
-
- ret = mach_port_insert_right (mach_task_self (),
- thread_exception_port,
- thread_exception_port,
- MACH_MSG_TYPE_MAKE_SEND);
- CHK ("Inserting send right to thread_exception_port", ret);
-
- /* Allocate message port */
- ret = mach_port_allocate (mach_task_self (),
- MACH_PORT_RIGHT_RECEIVE,
- &our_message_port);
- if (ret != KERN_SUCCESS)
- warning ("Creating message port %s", mach_error_string (ret));
- else
- {
- char buf[ MAX_NAME_LEN ];
- ret = mach_port_move_member(mach_task_self (),
- our_message_port,
- inferior_wait_port_set);
- if (ret != KERN_SUCCESS)
- warning ("message move member %s", mach_error_string (ret));
-
-
- /* @@@@ No way to change message port name currently */
- /* Foo. This assumes gdb has a unix pid */
- sprintf (buf, "gdb-%d", getpid ());
- gdb_register_port (buf, our_message_port);
- }
-
- /* Heap for thread commands */
- obstack_init (cproc_obstack);
-
- add_mach_specific_commands ();
-}
diff --git a/contrib/gdb/gdb/m68k-stub.c b/contrib/gdb/gdb/m68k-stub.c
deleted file mode 100644
index c2f1d3f..0000000
--- a/contrib/gdb/gdb/m68k-stub.c
+++ /dev/null
@@ -1,1014 +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: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
- *
- * Module name: remcom.c $
- * Revision: 1.34 $
- * Date: 91/03/09 12:29:49 $
- * 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. The breakpoint instruction
- * is hardwired to trap #1 because not to do so is a compatibility problem--
- * there either should be a standard breakpoint instruction, or the protocol
- * should be extended to provide some means to communicate which breakpoint
- * instruction is in use (or have the stub insert the breakpoint).
- *
- * 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 m68k 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
- *
- * $<packet info>#<checksum>.
- *
- * where
- * <packet info> :: <characters representing the command or response>
- * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>>
- *
- * 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 <stdio.h>
-#include <string.h>
-#include <setjmp.h>
-
-/************************************************************************
- *
- * external low-level support routines
- */
-typedef void (*ExceptionHook)(int); /* pointer to function with int parm */
-typedef void (*Function)(); /* pointer to a function */
-
-extern void putDebugChar(); /* write a single character */
-extern int getDebugChar(); /* read and return a single char */
-
-extern Function exceptionHandler(); /* assign an exception handler */
-extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */
-
-/************************/
-/* FORWARD DECLARATIONS */
-/************************/
-static void
-initializeRemcomErrorFrame ();
-
-/************************************************************************/
-/* 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
- };
-
-
-/* We keep a whole frame cache here. "Why?", I hear you cry, "doesn't
- GDB handle that sort of thing?" Well, yes, I believe the only
- reason for this cache is to save and restore floating point state
- (fsave/frestore). A cleaner way to do this would be to make the
- fsave data part of the registers which GDB deals with like any
- other registers. This should not be a performance problem if the
- ability to read individual registers is added to the protocol. */
-
-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;
-
-#ifdef mc68020
-/* 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 };
-#endif
-
-#ifdef mc68332
-static const short exceptionSize[] = { 4,4,6,4,4,4,4,4,4,4,4,4,16,4,4,4 };
-#endif
-
-/************* 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 return_to_user();
-
-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@-");
-#if defined (mc68020) || defined (mc68332)
-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");
-#if !defined (mc68020) && !defined (mc68332)
-asm(" lea sp@(4),sp"); /* pull off 68000 return address */
-#endif
-asm(" rte");
-
-extern void _catchException ();
-
-#if defined (mc68020) || defined (mc68332)
-/* 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*/
- }
-
-#if !defined (mc68020) && !defined (mc68332)
- /* 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 $<data>#<checksum> */
-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() & 0x7f)) != '$');
- checksum = 0;
- xmitcsum = -1;
-
- count = 0;
-
- /* now, read until a # or end of buffer is found */
- while (count < BUFMAX) {
- ch = getDebugChar() & 0x7f;
- if (ch == '#') break;
- checksum = checksum + ch;
- buffer[count] = ch;
- count = count + 1;
- }
- buffer[count] = 0;
-
- if (ch == '#') {
- xmitcsum = hex(getDebugChar() & 0x7f) << 4;
- xmitcsum += hex(getDebugChar() & 0x7f);
- 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;
-
- /* $<packet info>#<checksum>. */
- do {
- putDebugChar('$');
- checksum = 0;
- count = 0;
-
- while (ch=buffer[count]) {
- putDebugChar(ch);
- 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<count;i++) {
- ch = *mem++;
- *buf++ = hexchars[ch >> 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<count;i++) {
- ch = hex(*buf++) << 4;
- ch = ch + hex(*buf++);
- *mem++ = ch;
- }
- return(mem);
-}
-
-/* a bus error has occurred, perform a longjmp
- to return execution and allow handling of the error */
-
-void handle_buserror()
-{
- longjmp(remcomEnv,1);
-}
-
-/* this function takes the 68000 exception number and attempts to
- translate this number into a unix compatible signal value */
-int computeSignal( exceptionVector )
-int exceptionVector;
-{
- int sigval;
- switch (exceptionVector) {
- case 2 : sigval = 10; break; /* bus error */
- case 3 : sigval = 10; break; /* address error */
- case 4 : sigval = 4; break; /* illegal instruction */
- case 5 : sigval = 8; break; /* zero divide */
- case 6 : sigval = 8; break; /* chk instruction */
- case 7 : sigval = 8; break; /* trapv instruction */
- case 8 : sigval = 11; break; /* privilege violation */
- case 9 : sigval = 5; break; /* trace trap */
- case 10: sigval = 4; break; /* line 1010 emulator */
- case 11: sigval = 4; break; /* line 1111 emulator */
-
- /* Coprocessor protocol violation. Using a standard MMU or FPU
- this cannot be triggered by software. Call it a SIGBUS. */
- case 13: sigval = 10; break;
-
- case 31: sigval = 2; break; /* interrupt */
- case 33: sigval = 5; break; /* breakpoint */
-
- /* This is a trap #8 instruction. Apparently it is someone's software
- convention for some sort of SIGFPE condition. Whose? How many
- people are being screwed by having this code the way it is?
- Is there a clean solution? */
- case 40: sigval = 8; break; /* floating point err */
-
- case 48: sigval = 8; break; /* floating point err */
- case 49: sigval = 8; break; /* floating point err */
- case 50: sigval = 8; break; /* zero divide */
- case 51: sigval = 8; break; /* underflow */
- case 52: sigval = 8; break; /* operand error */
- case 53: sigval = 8; break; /* overflow */
- case 54: sigval = 8; break; /* NAN */
- default:
- sigval = 7; /* "software generated"*/
- }
- return (sigval);
-}
-
-/**********************************************/
-/* WHILE WE FIND NICE HEX CHARS, BUILD AN INT */
-/* RETURN NUMBER OF CHARS PROCESSED */
-/**********************************************/
-int hexToInt(char **ptr, int *intValue)
-{
- int numChars = 0;
- int hexValue;
-
- *intValue = 0;
-
- while (**ptr)
- {
- hexValue = hex(**ptr);
- if (hexValue >=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()
-{
- 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);
-
- /* This is a trap #8 instruction. Apparently it is someone's software
- convention for some sort of SIGFPE condition. Whose? How many
- people are being screwed by having this code the way it is?
- Is there a clean solution? */
- 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/contrib/gdb/gdb/m68k-tdep.c b/contrib/gdb/gdb/m68k-tdep.c
deleted file mode 100644
index d597efa..0000000
--- a/contrib/gdb/gdb/m68k-tdep.c
+++ /dev/null
@@ -1,516 +0,0 @@
-/* Target dependent code for the Motorola 68000 series.
- Copyright (C) 1990, 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "symtab.h"
-#include "gdbcore.h"
-#include "value.h"
-#include "gdb_string.h"
-
-
-/* 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);
-
- /* Always save the floating-point registers, whether they exist on
- this target or not. */
- 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);
- }
-
- 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 struct frame_info *frame = get_current_frame ();
- register CORE_ADDR fp;
- register int regnum;
- struct frame_saved_regs fsr;
- char raw_buffer[12];
-
- fp = FRAME_FP (frame);
- get_frame_saved_regs (frame, &fsr);
- 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);
- }
- }
- 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 ();
-}
-
-
-/* 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
-#define P_TRAP 0x4e40
-
-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 == 0x4856)
- ip += 2; /* Skip pea %fp */
- else if (op == 0x2c4f)
- ip += 2; /* Skip move.l %sp, %fp */
- 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);
-}
-
-void
-m68k_find_saved_regs (frame_info, saved_regs)
- struct frame_info *frame_info;
- struct frame_saved_regs *saved_regs;
-{
- register int regnum;
- register int regmask;
- register CORE_ADDR next_addr;
- register CORE_ADDR pc;
-
- /* First possible address for a pc in a call dummy for this frame. */
- CORE_ADDR possible_call_dummy_start =
- (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 4 - 8*12;
-
- int nextinsn;
- memset (saved_regs, 0, sizeof (*saved_regs));
- if ((frame_info)->pc >= possible_call_dummy_start
- && (frame_info)->pc <= (frame_info)->frame)
- {
-
- /* It is a call dummy. We could just stop now, since we know
- what the call dummy saves and where. But this code proceeds
- to parse the "prologue" which is part of the call dummy.
- This is needlessly complex and confusing. FIXME. */
-
- next_addr = (frame_info)->frame;
- pc = possible_call_dummy_start;
- }
- else
- {
- pc = get_pc_function_start ((frame_info)->pc);
-
- if (0x4856 == read_memory_integer (pc, 2)
- && 0x2c4f == read_memory_integer (pc + 2, 2))
- {
- /*
- pea %fp
- move.l %sp, %fp */
-
- pc += 4;
- next_addr = frame_info->frame;
- }
- else if (044016 == read_memory_integer (pc, 2))
- /* link.l %fp */
- /* Find the address above the saved
- regs using the amount of storage from the link instruction. */
- next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4;
- else if (047126 == read_memory_integer (pc, 2))
- /* link.w %fp */
- /* Find the address above the saved
- regs using the amount of storage from the link instruction. */
- 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;
- }
- regmask = read_memory_integer (pc + 2, 2);
-
- /* Here 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)
- saved_regs->regs[regnum] = (next_addr -= 12);
- regmask = read_memory_integer (pc + 2, 2); }
-
- /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */
- 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)
- 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)
- 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;
- saved_regs->regs[regnum] = (next_addr -= 4);
- /* gcc, at least, may use a pair of movel instructions when saving
- exactly 2 registers. */
- if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2)))
- {
- regnum = 0xf & read_memory_integer (pc, 2);
- pc += 2;
- 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)
- 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))
- saved_regs->regs[PS_REGNUM] = (next_addr -= 4);
- lose: ;
- saved_regs->regs[SP_REGNUM] = (frame_info)->frame + 8;
- saved_regs->regs[FP_REGNUM] = (frame_info)->frame;
- saved_regs->regs[PC_REGNUM] = (frame_info)->frame + 4;
-#ifdef SIG_SP_FP_OFFSET
- /* Adjust saved SP_REGNUM for fake _sigtramp frames. */
- if (frame_info->signal_handler_caller && frame_info->next)
- saved_regs->regs[SP_REGNUM] = frame_info->next->frame + SIG_SP_FP_OFFSET;
-#endif
-}
-
-
-#ifdef USE_PROC_FS /* Target dependent support for /proc */
-
-#include <sys/procfs.h>
-
-/* 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.
-
- */
-
-/* Atari SVR4 has R_SR but not R_PS */
-
-#if !defined (R_PS) && defined (R_SR)
-#define R_PS R_SR
-#endif
-
-/* 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 regi;
- register greg_t *regp = (greg_t *) gregsetp;
-
- for (regi = 0 ; regi < R_PC ; regi++)
- {
- supply_register (regi, (char *) (regp + regi));
- }
- 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;
-{
- register 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 + regi) = *(int *) &registers[REGISTER_BYTE (regi)];
- }
- }
- if ((regno == -1) || (regno == PS_REGNUM))
- {
- *(regp + R_PS) = *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
- }
- if ((regno == -1) || (regno == PC_REGNUM))
- {
- *(regp + R_PC) = *(int *) &registers[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 regi;
- char *from;
-
- for (regi = FP0_REGNUM ; regi < FPC_REGNUM ; regi++)
- {
- from = (char *) &(fpregsetp -> f_fpregs[regi-FP0_REGNUM][0]);
- supply_register (regi, from);
- }
- 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 *) &registers[REGISTER_BYTE (regi)];
- to = (char *) &(fpregsetp -> f_fpregs[regi-FP0_REGNUM][0]);
- memcpy (to, from, REGISTER_RAW_SIZE (regi));
- }
- }
- if ((regno == -1) || (regno == FPC_REGNUM))
- {
- fpregsetp -> f_pcr = *(int *) &registers[REGISTER_BYTE (FPC_REGNUM)];
- }
- if ((regno == -1) || (regno == FPS_REGNUM))
- {
- fpregsetp -> f_psr = *(int *) &registers[REGISTER_BYTE (FPS_REGNUM)];
- }
- if ((regno == -1) || (regno == FPI_REGNUM))
- {
- fpregsetp -> f_fpiaddr = *(int *) &registers[REGISTER_BYTE (FPI_REGNUM)];
- }
-}
-
-#endif /* defined (FP0_REGNUM) */
-
-#endif /* USE_PROC_FS */
-
-#ifdef GET_LONGJMP_TARGET
-/* Figure out where the longjmp will land. Slurp the args out of the stack.
- We expect the first arg to be a pointer to the jmp_buf structure from which
- we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
- This routine returns true on success. */
-
-int
-get_longjmp_target(pc)
- CORE_ADDR *pc;
-{
- char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
- CORE_ADDR sp, jb_addr;
-
- sp = read_register(SP_REGNUM);
-
- if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */
- buf,
- TARGET_PTR_BIT / TARGET_CHAR_BIT))
- return 0;
-
- jb_addr = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
-
- if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf,
- TARGET_PTR_BIT / TARGET_CHAR_BIT))
- return 0;
-
- *pc = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
-
- return 1;
-}
-#endif /* GET_LONGJMP_TARGET */
-
-/* Immediately after a function call, return the saved pc before the frame
- is setup. For sun3's, we check for the common case of being inside of a
- system call, and if so, we know that Sun pushes the call # on the stack
- prior to doing the trap. */
-
-CORE_ADDR
-m68k_saved_pc_after_call(frame)
- struct frame_info *frame;
-{
-#ifdef SYSCALL_TRAP
- int op;
-
- op = read_memory_integer (frame->pc - SYSCALL_TRAP_OFFSET, 2);
-
- if (op == SYSCALL_TRAP)
- return read_memory_integer (read_register (SP_REGNUM) + 4, 4);
- else
-#endif /* SYSCALL_TRAP */
- return read_memory_integer (read_register (SP_REGNUM), 4);
-}
-
-void
-_initialize_m68k_tdep ()
-{
- tm_print_insn = print_insn_m68k;
-}
diff --git a/contrib/gdb/gdb/m68knbsd-nat.c b/contrib/gdb/gdb/m68knbsd-nat.c
deleted file mode 100644
index c2e71df..0000000
--- a/contrib/gdb/gdb/m68knbsd-nat.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Native-dependent code for Motorola m68k's running NetBSD, for GDB.
- Copyright 1988, 1989, 1991, 1992, 1994, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <sys/types.h>
-#include <sys/ptrace.h>
-#include <machine/reg.h>
-#include <machine/frame.h>
-
-#include "defs.h"
-#include "inferior.h"
-
-void
-fetch_inferior_registers(regno)
- int regno;
-{
- struct reg inferior_registers;
- struct fpreg inferior_fp_registers;
-
- ptrace (PT_GETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers, 0);
- memcpy (&registers[REGISTER_BYTE (0)], &inferior_registers,
- sizeof(inferior_registers));
-
- ptrace (PT_GETFPREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
- memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
- sizeof(inferior_fp_registers));
-
- registers_fetched ();
-}
-
-void
-store_inferior_registers(regno)
- int regno;
-{
- struct reg inferior_registers;
- struct fpreg inferior_fp_registers;
-
- memcpy (&inferior_registers, &registers[REGISTER_BYTE (0)],
- sizeof(inferior_registers));
- ptrace (PT_SETREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_registers, 0);
-
- memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
- sizeof(inferior_fp_registers));
- ptrace (PT_SETFPREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
-}
-
-struct md_core {
- struct reg intreg;
- struct fpreg freg;
-};
-
-void
-fetch_core_registers (core_reg_sect, core_reg_size, which, ignore)
- char *core_reg_sect;
- unsigned core_reg_size;
- int which;
- CORE_ADDR ignore;
-{
- struct md_core *core_reg = (struct md_core *)core_reg_sect;
-
- /* Integer registers */
- memcpy(&registers[REGISTER_BYTE (0)],
- &core_reg->intreg, sizeof(struct reg));
- /* Floating point registers */
- memcpy(&registers[REGISTER_BYTE (FP0_REGNUM)],
- &core_reg->freg, sizeof(struct fpreg));
-}
diff --git a/contrib/gdb/gdb/m88k-nat.c b/contrib/gdb/gdb/m88k-nat.c
deleted file mode 100644
index 19e9392..0000000
--- a/contrib/gdb/gdb/m88k-nat.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/* Native-dependent Motorola 88xxx support for GDB, the GNU Debugger.
- Copyright 1988, 1990, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include "gdbcore.h"
-#include <sys/user.h>
-
-#ifndef USER /* added to support BCS ptrace_user */
-#define USER ptrace_user
-#endif
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-#include "symtab.h"
-#include "setjmp.h"
-#include "value.h"
-
-#ifdef DELTA88
-#include <sys/ptrace.h>
-
-/* 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 (regno)
- int regno; /* Original value discarded */
-{
- 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, (PTRACE_ARG3_TYPE) 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,
- (PTRACE_ARG3_TYPE) 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,
- (PTRACE_ARG3_TYPE) SXIP_OFFSET ,0);
- supply_register (SXIP_REGNUM, buf);
- *(int *) &buf[0] = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) SNIP_OFFSET,0);
- supply_register (SNIP_REGNUM, buf);
- *(int *) &buf[0] = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) 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). */
-
-void
-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;
-
- /* Don't try to deal with EXIP_REGNUM or ENIP_REGNUM, because I think either
- svr3 doesn't run on an 88110, or the kernel isolates the different (not
- completely sure this is true, but seems to be. */
- if (regno >= 0)
- {
- /* regaddr = register_addr (regno, offset); */
- if (regno < PC_REGNUM)
- {
- regaddr = offset + regno * sizeof (int);
- errno = 0;
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) 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,
- (PTRACE_ARG3_TYPE) SXIP_OFFSET, read_register(regno));
- else if (regno == SNIP_REGNUM)
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) SNIP_OFFSET, read_register(regno));
- else if (regno == SFIP_REGNUM)
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) SFIP_OFFSET, read_register(regno));
- else
- printf_unfiltered ("Bad register number for store_inferior routine\n");
- }
- else
- {
- for (regno = 0; regno < PC_REGNUM; regno++)
- {
- /* regaddr = register_addr (regno, offset); */
- errno = 0;
- regaddr = offset + regno * sizeof (int);
- ptrace (6, inferior_pid,
- (PTRACE_ARG3_TYPE) regaddr, read_register (regno));
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
- ptrace (6,inferior_pid,
- (PTRACE_ARG3_TYPE) SXIP_OFFSET,read_register(SXIP_REGNUM));
- ptrace (6,inferior_pid,
- (PTRACE_ARG3_TYPE) SNIP_OFFSET,read_register(SNIP_REGNUM));
- ptrace (6,inferior_pid,
- (PTRACE_ARG3_TYPE) SFIP_OFFSET,read_register(SFIP_REGNUM));
- }
-}
-
-
-/* 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) + REGISTER_SIZE * 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:
- if (regnum < NUM_REGS)
- /* The register is one of those which is not defined...
- give it zero */
- return (ustart + ((int) &u.pt_r0 - (int) &u));
- else
- return (blockend + REGISTER_SIZE * regnum);
- }
-}
-
-#ifdef USE_PROC_FS
-
-#include <sys/procfs.h>
-
-/* 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 regi;
- register greg_t *regp = (greg_t *) gregsetp;
-
- for (regi=0; regi <= SP_REGNUM; regi++)
- supply_register (regi, (char *) (regp + regi));
-
- supply_register (SXIP_REGNUM, (char *) (regp + R_XIP));
- supply_register (SNIP_REGNUM, (char *) (regp + R_NIP));
- supply_register (SFIP_REGNUM, (char *) (regp + R_FIP));
- supply_register (PSR_REGNUM, (char *) (regp + R_PSR));
- supply_register (FPSR_REGNUM, (char *) (regp + R_FPSR));
- supply_register (FPCR_REGNUM, (char *) (regp + R_FPCR));
-}
-
-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_R31 ; regi++)
- if ((regno == -1) || (regno == regi))
- *(regp + regi) = *(int *) &registers[REGISTER_BYTE(regi)];
-
- if ((regno == -1) || (regno == SXIP_REGNUM))
- *(regp + R_XIP) = *(int *) &registers[REGISTER_BYTE(SXIP_REGNUM)];
- if ((regno == -1) || (regno == SNIP_REGNUM))
- *(regp + R_NIP) = *(int *) &registers[REGISTER_BYTE(SNIP_REGNUM)];
- if ((regno == -1) || (regno == SFIP_REGNUM))
- *(regp + R_FIP) = *(int *) &registers[REGISTER_BYTE(SFIP_REGNUM)];
- if ((regno == -1) || (regno == PSR_REGNUM))
- *(regp + R_PSR) = *(int *) &registers[REGISTER_BYTE(PSR_REGNUM)];
- if ((regno == -1) || (regno == FPSR_REGNUM))
- *(regp + R_FPSR) = *(int *) &registers[REGISTER_BYTE(FPSR_REGNUM)];
- if ((regno == -1) || (regno == FPCR_REGNUM))
- *(regp + R_FPCR) = *(int *) &registers[REGISTER_BYTE(FPCR_REGNUM)];
-}
-
-#endif /* USE_PROC_FS */
diff --git a/contrib/gdb/gdb/m88k-tdep.c b/contrib/gdb/gdb/m88k-tdep.c
deleted file mode 100644
index f82cb76..0000000
--- a/contrib/gdb/gdb/m88k-tdep.c
+++ /dev/null
@@ -1,629 +0,0 @@
-/* Target-machine dependent code for Motorola 88000 series, for GDB.
- Copyright 1988, 1990, 1991, 1994, 1995 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "value.h"
-#include "gdbcore.h"
-#include "symtab.h"
-#include "setjmp.h"
-#include "value.h"
-
-/* Size of an instruction */
-#define BYTES_PER_88K_INSN 4
-
-void frame_find_saved_regs ();
-
-/* Is this target an m88110? Otherwise assume m88100. This has
- relevance for the ways in which we screw with instruction pointers. */
-
-int target_is_m88110 = 0;
-
-/* 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. */
-
-CORE_ADDR
-m88k_addr_bits_remove (addr)
- CORE_ADDR addr;
-{
- return ((addr) & ~3);
-}
-
-
-/* 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. */
-
-CORE_ADDR
-frame_chain (thisframe)
- struct frame_info *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)
- struct frame_info *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 */
-}
-
-void
-init_extra_frame_info (fromleaf, frame)
- int fromleaf;
- struct frame_info *frame;
-{
- frame->fsr = 0; /* Not yet allocated */
- frame->args_pointer = 0; /* Unknown */
- frame->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))
-#define SUBU_OFFSET(x) ((unsigned)(x & 0xFFFF))
-#define ST_OFFSET(x) ((unsigned)((x) & 0xFFFF))
-#define ST_SRC(x) EXTRACT_FIELD ((x), 21, 5)
-#define ADDU_OFFSET(x) ((unsigned)(x & 0xFFFF))
-
-/*
- * prologue_insn_tbl is a table of instructions which may comprise a
- * function prologue. Associated with each table entry (corresponding
- * to a single instruction or group of instructions), is an action.
- * This action is used by examine_prologue (below) to determine
- * the state of certain machine registers and where the stack frame lives.
- */
-
-enum prologue_insn_action {
- PIA_SKIP, /* don't care what the instruction does */
- PIA_NOTE_ST, /* note register stored and where */
- PIA_NOTE_STD, /* note pair of registers stored and where */
- PIA_NOTE_SP_ADJUSTMENT, /* note stack pointer adjustment */
- PIA_NOTE_FP_ASSIGNMENT, /* note frame pointer assignment */
- PIA_NOTE_PROLOGUE_END, /* no more prologue */
-};
-
-struct prologue_insns {
- unsigned long insn;
- unsigned long mask;
- enum prologue_insn_action action;
-};
-
-struct prologue_insns prologue_insn_tbl[] = {
- /* Various register move instructions */
- { 0x58000000, 0xf800ffff, PIA_SKIP }, /* or/or.u with immed of 0 */
- { 0xf4005800, 0xfc1fffe0, PIA_SKIP }, /* or rd, r0, rs */
- { 0xf4005800, 0xfc00ffff, PIA_SKIP }, /* or rd, rs, r0 */
-
- /* Stack pointer setup: "subu sp, sp, n" where n is a multiple of 8 */
- { 0x67ff0000, 0xffff0007, PIA_NOTE_SP_ADJUSTMENT },
-
- /* Frame pointer assignment: "addu r30, r31, n" */
- { 0x63df0000, 0xffff0000, PIA_NOTE_FP_ASSIGNMENT },
-
- /* Store to stack instructions; either "st rx, sp, n" or "st.d rx, sp, n" */
- { 0x241f0000, 0xfc1f0000, PIA_NOTE_ST }, /* st rx, sp, n */
- { 0x201f0000, 0xfc1f0000, PIA_NOTE_STD }, /* st.d rs, sp, n */
-
- /* Instructions needed for setting up r25 for pic code. */
- { 0x5f200000, 0xffff0000, PIA_SKIP }, /* or.u r25, r0, offset_high */
- { 0xcc000002, 0xffffffff, PIA_SKIP }, /* bsr.n Lab */
- { 0x5b390000, 0xffff0000, PIA_SKIP }, /* or r25, r25, offset_low */
- { 0xf7396001, 0xffffffff, PIA_SKIP }, /* Lab: addu r25, r25, r1 */
-
- /* Various branch or jump instructions which have a delay slot -- these
- do not form part of the prologue, but the instruction in the delay
- slot might be a store instruction which should be noted. */
- { 0xc4000000, 0xe4000000, PIA_NOTE_PROLOGUE_END },
- /* br.n, bsr.n, bb0.n, or bb1.n */
- { 0xec000000, 0xfc000000, PIA_NOTE_PROLOGUE_END }, /* bcnd.n */
- { 0xf400c400, 0xfffff7e0, PIA_NOTE_PROLOGUE_END } /* jmp.n or jsr.n */
-
-};
-
-
-/* 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. */
-
-#define NEXT_PROLOGUE_INSN(addr, lim, pword1) \
- (((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;
-{
- *pword1 = read_memory_integer (memaddr, BYTES_PER_88K_INSN);
- return memaddr + BYTES_PER_88K_INSN;
-}
-
-/* Read a register from frames called by us (or from the hardware regs). */
-
-static int
-read_next_frame_reg(frame, regno)
- struct frame_info *frame;
- int regno;
-{
- for (; frame; frame = frame->next) {
- if (regno == SP_REGNUM)
- return FRAME_FP (frame);
- else if (frame->fsr->regs[regno])
- return read_memory_integer(frame->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;
- CORE_ADDR frame_sp;
- struct frame_saved_regs *fsr;
- struct frame_info *fi;
-{
- register CORE_ADDR next_ip;
- register int src;
- unsigned int insn;
- 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;
- CORE_ADDR prologue_end = 0;
-
- memset (must_adjust, '\0', sizeof (must_adjust));
- next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn);
-
- while (next_ip)
- {
- struct prologue_insns *pip;
-
- for (pip=prologue_insn_tbl; (insn & pip->mask) != pip->insn; )
- if (++pip >= prologue_insn_tbl + sizeof prologue_insn_tbl)
- goto end_of_prologue_found; /* not a prologue insn */
-
- switch (pip->action)
- {
- case PIA_NOTE_ST:
- case PIA_NOTE_STD:
- if (sp_offset != -1) {
- src = ST_SRC (insn);
- offset = ST_OFFSET (insn);
- must_adjust[src] = 1;
- fsr->regs[src++] = offset; /* Will be adjusted later */
- if (pip->action == PIA_NOTE_STD && src < 32)
- {
- offset += 4;
- must_adjust[src] = 1;
- fsr->regs[src++] = offset;
- }
- }
- else
- goto end_of_prologue_found;
- break;
- case PIA_NOTE_SP_ADJUSTMENT:
- if (sp_offset == -1)
- sp_offset = -SUBU_OFFSET (insn);
- else
- goto end_of_prologue_found;
- break;
- case PIA_NOTE_FP_ASSIGNMENT:
- if (fp_offset == -1)
- fp_offset = ADDU_OFFSET (insn);
- else
- goto end_of_prologue_found;
- break;
- case PIA_NOTE_PROLOGUE_END:
- if (!prologue_end)
- prologue_end = ip;
- break;
- case PIA_SKIP:
- default :
- /* Do nothing */
- break;
- }
-
- ip = next_ip;
- next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn);
- }
-
-end_of_prologue_found:
-
- if (prologue_end)
- ip = prologue_end;
-
- /* 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 (before any alloca calls) displacement of SP
- (will be negative).
-
- fp_offset displacement from original SP to the FP for this frame
- or -1.
-
- fsr->regs[0..31] displacement from original SP to the stack
- location where reg[0..31] is stored.
-
- must_adjust[0..31] set if corresponding offset was set.
-
- If alloca has been called between the function prologue and the current
- IP, then the current SP (frame_sp) will not be the original SP as set by
- the function prologue. If the current SP is not the original SP, then the
- compiler will have allocated an FP for this frame, fp_offset will be set,
- and we can use it to calculate the original SP.
-
- 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, ACTUAL_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_unfiltered(gdb_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, (CORE_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_obstack, since it is
- fairly expensive. */
-
-void
-frame_find_saved_regs (fi, fsr)
- struct frame_info *fi;
- struct frame_saved_regs *fsr;
-{
- register struct frame_saved_regs *cache_fsr;
- CORE_ADDR ip;
- struct symtab_and_line sal;
- CORE_ADDR limit;
-
- if (!fi->fsr)
- {
- cache_fsr = (struct frame_saved_regs *)
- frame_obstack_alloc (sizeof (struct frame_saved_regs));
- memset (cache_fsr, '\0', 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. In the case where the PC is not in
- the function prologue, we set limit to two instructions beyond
- where the prologue ends in case if any of the prologue instructions
- were moved into a delay slot of a branch instruction. */
-
- ip = get_pc_function_start (fi->pc);
- sal = find_pc_line (ip, 0);
- limit = (sal.end && sal.end < fi->pc) ? sal.end + 2 * BYTES_PER_88K_INSN
- : fi->pc;
-
- /* This will fill in fields in *fi as well as in cache_fsr. */
-#ifdef SIGTRAMP_FRAME_FIXUP
- if (fi->signal_handler_caller)
- SIGTRAMP_FRAME_FIXUP(fi->frame);
-#endif
- examine_prologue (ip, limit, fi->frame, cache_fsr, fi);
-#ifdef SIGTRAMP_SP_FIXUP
- if (fi->signal_handler_caller && fi->fsr->regs[SP_REGNUM])
- SIGTRAMP_SP_FIXUP(fi->fsr->regs[SP_REGNUM]);
-#endif
- }
-
- 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;
-{
- struct frame_saved_regs fsr;
-
- 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;
-{
- struct frame_saved_regs fsr;
-
- 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)
- struct frame_info *frame;
-{
- return read_next_frame_reg(frame, SRP_REGNUM);
-}
-
-
-#define DUMMY_FRAME_SIZE 192
-
-static void
-write_word (sp, word)
- CORE_ADDR sp;
- ULONGEST word;
-{
- register int len = REGISTER_SIZE;
- char buffer[MAX_REGISTER_RAW_SIZE];
-
- store_unsigned_integer (buffer, len, word);
- write_memory (sp, buffer, len);
-}
-
-void
-m88k_push_dummy_frame()
-{
- register CORE_ADDR sp = read_register (SP_REGNUM);
- register int rn;
- int offset;
-
- sp -= DUMMY_FRAME_SIZE; /* allocate a bunch of space */
-
- for (rn = 0, offset = 0; rn <= SP_REGNUM; rn++, offset+=4)
- write_word (sp+offset, read_register(rn));
-
- write_word (sp+offset, read_register (SXIP_REGNUM));
- offset += 4;
-
- write_word (sp+offset, read_register (SNIP_REGNUM));
- offset += 4;
-
- write_word (sp+offset, read_register (SFIP_REGNUM));
- offset += 4;
-
- write_word (sp+offset, read_register (PSR_REGNUM));
- offset += 4;
-
- write_word (sp+offset, read_register (FPSR_REGNUM));
- offset += 4;
-
- write_word (sp+offset, read_register (FPCR_REGNUM));
- offset += 4;
-
- write_register (SP_REGNUM, sp);
- write_register (ACTUAL_FP_REGNUM, sp);
-}
-
-void
-pop_frame ()
-{
- register struct frame_info *frame = get_current_frame ();
- register CORE_ADDR fp;
- register int regnum;
- struct frame_saved_regs fsr;
-
- fp = FRAME_FP (frame);
- get_frame_saved_regs (frame, &fsr);
-
- if (PC_IN_CALL_DUMMY (read_pc (), read_register (SP_REGNUM), FRAME_FP (fi)))
- {
- /* FIXME: I think get_frame_saved_regs should be handling this so
- that we can deal with the saved registers properly (e.g. frame
- 1 is a call dummy, the user types "frame 2" and then "print $ps"). */
- register CORE_ADDR sp = read_register (ACTUAL_FP_REGNUM);
- int offset;
-
- for (regnum = 0, offset = 0; regnum <= SP_REGNUM; regnum++, offset+=4)
- (void) write_register (regnum, read_memory_integer (sp+offset, 4));
-
- write_register (SXIP_REGNUM, read_memory_integer (sp+offset, 4));
- offset += 4;
-
- write_register (SNIP_REGNUM, read_memory_integer (sp+offset, 4));
- offset += 4;
-
- write_register (SFIP_REGNUM, read_memory_integer (sp+offset, 4));
- offset += 4;
-
- write_register (PSR_REGNUM, read_memory_integer (sp+offset, 4));
- offset += 4;
-
- write_register (FPSR_REGNUM, read_memory_integer (sp+offset, 4));
- offset += 4;
-
- write_register (FPCR_REGNUM, read_memory_integer (sp+offset, 4));
- offset += 4;
-
- }
- else
- {
- for (regnum = FP_REGNUM ; regnum > 0 ; regnum--)
- if (fsr.regs[regnum])
- write_register (regnum,
- read_memory_integer (fsr.regs[regnum], 4));
- write_pc (frame_saved_pc (frame));
- }
- reinit_frame_cache ();
-}
-
-void
-_initialize_m88k_tdep ()
-{
- tm_print_insn = print_insn_m88k;
-}
diff --git a/contrib/gdb/gdb/minimon.h b/contrib/gdb/gdb/minimon.h
deleted file mode 100644
index f60c417..0000000
--- a/contrib/gdb/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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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/contrib/gdb/gdb/mon960-rom.c b/contrib/gdb/gdb/mon960-rom.c
deleted file mode 100644
index 32dcaff..0000000
--- a/contrib/gdb/gdb/mon960-rom.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* Remote target glue for the Intel 960 MON960 ROM monitor.
- Copyright 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "monitor.h"
-#include "serial.h"
-#include "srec.h"
-#include "xmodem.h"
-#include "symtab.h"
-#include "symfile.h" /* for generic_load */
-
-
-#define USE_GENERIC_LOAD
-
-static struct target_ops mon960_ops;
-
-static void mon960_open PARAMS ((char *args, int from_tty));
-
-#ifdef USE_GENERIC_LOAD
-
-static void
-mon960_load_gen (filename, from_tty)
- char *filename;
- int from_tty;
-{
- extern int inferior_pid;
-
- generic_load (filename, from_tty);
- /* Finally, make the PC point at the start address */
- if (exec_bfd)
- write_pc (bfd_get_start_address (exec_bfd));
-
- inferior_pid = 0; /* No process now */
-}
-
-#else
-
-static void
-mon960_load (desc, file, hashmark)
- serial_t desc;
- char *file;
- int hashmark;
-{
- bfd *abfd;
- asection *s;
- char *buffer;
- int i;
-
- buffer = alloca (XMODEM_PACKETSIZE);
- abfd = bfd_openr (file, 0);
- if (!abfd)
- {
- printf_filtered ("Unable to open file %s\n", file);
- return;
- }
- if (bfd_check_format (abfd, bfd_object) == 0)
- {
- printf_filtered ("File is not an object file\n");
- return;
- }
- for (s = abfd->sections; s; s = s->next)
- if (s->flags & SEC_LOAD)
- {
- bfd_size_type section_size;
- printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma,
- s->vma + s->_raw_size);
- gdb_flush (gdb_stdout);
- monitor_printf (current_monitor->load, s->vma);
- if (current_monitor->loadresp)
- monitor_expect (current_monitor->loadresp, NULL, 0);
- xmodem_init_xfer (desc);
- section_size = bfd_section_size (abfd, s);
- for (i = 0; i < section_size; i += XMODEM_DATASIZE)
- {
- int numbytes;
- numbytes = min (XMODEM_DATASIZE, section_size - i);
- bfd_get_section_contents (abfd, s, buffer + XMODEM_DATAOFFSET, i,
- numbytes);
- xmodem_send_packet (desc, buffer, numbytes, hashmark);
- if (hashmark)
- {
- putchar_unfiltered ('#');
- gdb_flush (gdb_stdout);
- }
- } /* Per-packet (or S-record) loop */
- xmodem_finish_xfer (desc);
- monitor_expect_prompt (NULL, 0);
- putchar_unfiltered ('\n');
- } /* Loadable sections */
- if (hashmark)
- putchar_unfiltered ('\n');
-}
-
-#endif /* USE_GENERIC_LOAD */
-
-/* This array of registers need to match the indexes used by GDB.
- This exists because the various ROM monitors use different strings
- than does GDB, and don't necessarily support all the registers
- either. So, typing "info reg sp" becomes a "r30". */
-
-/* these correspond to the offsets from tm-* files from config directories */
-/* g0-g14, fp, pfp, sp, rip,r3-15, pc, ac, tc, fp0-3 */
-/* NOTE: "ip" is documented as "ir" in the Mon960 UG. */
-/* NOTE: "ir" can't be accessed... but there's an ip and rip. */
-static char *full_regnames[NUM_REGS] = {
- /* 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", "tc", "ip", "fp0", "fp1", "fp2", "fp3",
- };
-
-static char *mon960_regnames[NUM_REGS];
-
-/* Define the monitor command strings. Since these are passed directly
- through to a printf style function, we may include formatting
- strings. We also need a CR or LF on the end. */
-
-/* need to pause the monitor for timing reasons, so slow it down */
-
-#if 0
-/* FIXME: this extremely long init string causes MON960 to return two NAKS
- instead of performing the autobaud recognition, at least when gdb
- is running on GNU/Linux. The short string below works on Linux, and on
- SunOS using a tcp serial connection. Must retest on SunOS using a
- direct serial connection; if that works, get rid of the long string. */
-static char *mon960_inits[] = {"\n\r\r\r\r\r\r\r\r\r\r\r\r\r\r\n\r\n\r\n", NULL};
-#else
-static char *mon960_inits[] = { "\r", NULL};
-#endif
-
-static struct monitor_ops mon960_cmds ;
-
-static void
-init_mon960_cmds (void)
-{
- mon960_cmds.flags = MO_CLR_BREAK_USES_ADDR
- | MO_NO_ECHO_ON_OPEN | MO_SEND_BREAK_ON_STOP | MO_GETMEM_READ_SINGLE ; /* flags */
- mon960_cmds.init = mon960_inits; /* Init strings */
- mon960_cmds.cont = "go\n\r"; /* continue command */
- mon960_cmds.step = "st\n\r"; /* single step */
- mon960_cmds.stop = NULL; /* break interrupts the program */
- mon960_cmds.set_break = NULL; /* set a breakpoint */
- mon960_cmds.clr_break = /* can't use "br" because only 2 hw bps are supported */
- mon960_cmds.clr_all_break = NULL; /* clear a breakpoint - "de" is for hw bps */
- NULL, /* clear all breakpoints */
- mon960_cmds.fill = NULL; /* fill (start end val) */
- /* can't use "fi" because it takes words, not bytes */
- /* can't use "mb", "md" or "mo" because they require interaction */
- mon960_cmds.setmem.cmdb = NULL; /* setmem.cmdb (addr, value) */
- mon960_cmds.setmem.cmdw = NULL; /* setmem.cmdw (addr, value) */
- mon960_cmds.setmem.cmdl = "md %x %x\n\r"; /* setmem.cmdl (addr, value) */
- mon960_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
- mon960_cmds.setmem.resp_delim = NULL; /* setmem.resp_delim */
- mon960_cmds.setmem.term = NULL; /* setmem.term */
- mon960_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */
- /* since the parsing of multiple bytes is difficult due to
- interspersed addresses, we'll only read 1 value at a time,
- even tho these can handle a count */
- mon960_cmds.getmem.cmdb = "db %x\n\r"; /* getmem.cmdb (addr, #bytes) */
- mon960_cmds.getmem.cmdw = "ds %x\n\r"; /* getmem.cmdw (addr, #swords) */
- mon960_cmds.getmem.cmdl = "di %x\n\r"; /* getmem.cmdl (addr, #words) */
- mon960_cmds.getmem.cmdll = "dd %x\n\r"; /* getmem.cmdll (addr, #dwords) */
- mon960_cmds.getmem.resp_delim = " : "; /* getmem.resp_delim */
- mon960_cmds.getmem.term = NULL; /* getmem.term */
- mon960_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
- mon960_cmds.setreg.cmd = "md %s %x\n\r"; /* setreg.cmd (name, value) */
- mon960_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */
- mon960_cmds.setreg.term = NULL; /* setreg.term */
- mon960_cmds.setreg.term_cmd = NULL, /* setreg.term_cmd */
- mon960_cmds.getreg.cmd = "di %s\n\r"; /* getreg.cmd (name) */
- mon960_cmds.getreg.resp_delim = " : "; /* getreg.resp_delim */
- mon960_cmds.getreg.term = NULL; /* getreg.term */
- mon960_cmds.getreg.term_cmd = NULL; /* getreg.term_cmd */
- mon960_cmds.dump_registers = "re\n\r"; /* dump_registers */
- mon960_cmds.register_pattern = "\\(\\w+\\)=\\([0-9a-fA-F]+\\)"; /* register_pattern */
- mon960_cmds.supply_register = NULL; /* supply_register */
-#ifdef USE_GENERIC_LOAD
- mon960_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
- mon960_cmds.load = NULL; /* download command */
- mon960_cmds.loadresp = NULL; /* load response */
-#else
- mon960_cmds.load_routine = mon960_load ; /* load_routine (defaults to SRECs) */
- mon960_cmds.load = "do\n\r"; /* download command */
- mon960_cmds.loadresp = "Downloading\n\r" ;/* load response */
-#endif
- mon960_cmds.prompt = "=>"; /* monitor command prompt */
- mon960_cmds.line_term = "\n\r"; /* end-of-command delimitor */
- mon960_cmds.cmd_end = NULL; /* optional command terminator */
- mon960_cmds.target = &mon960_ops; /* target operations */
- mon960_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- mon960_cmds.regnames = mon960_regnames; /* registers names */
- mon960_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
-};
-
-static void
-mon960_open (args, from_tty)
- char *args;
- int from_tty;
-{
- char buf[64];
-
- monitor_open (args, &mon960_cmds, from_tty);
-
- /* Attempt to fetch the value of the first floating point register (fp0).
- If the monitor returns a string containing the word "Bad" we'll assume
- this processor has no floating point registers, and nullify the
- regnames entries that refer to FP registers. */
-
- monitor_printf (mon960_cmds.getreg.cmd, full_regnames[FP0_REGNUM]); /* di fp0 */
- if (monitor_expect_prompt (buf, sizeof(buf)) != -1)
- if (strstr(buf, "Bad") != NULL)
- {
- int i;
-
- for (i = FP0_REGNUM; i < FP0_REGNUM + 4; i++)
- mon960_regnames[i] = NULL;
- }
-}
-
-void
-_initialize_mon960 ()
-{
- memcpy(mon960_regnames, full_regnames, sizeof(full_regnames));
-
- init_mon960_cmds ();
-
- init_monitor_ops (&mon960_ops);
-
- mon960_ops.to_shortname = "mon960"; /* for the target command */
- mon960_ops.to_longname = "Intel 960 MON960 monitor";
-#ifdef USE_GENERIC_LOAD
- mon960_ops.to_load = mon960_load_gen; /* FIXME - should go back and try "do" */
-#endif
- /* use SW breaks; target only supports 2 HW breakpoints */
- mon960_ops.to_insert_breakpoint = memory_insert_breakpoint;
- mon960_ops.to_remove_breakpoint = memory_remove_breakpoint;
-
- mon960_ops.to_doc =
- "Use an Intel 960 board running the MON960 debug monitor.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
-
- mon960_ops.to_open = mon960_open;
- add_target (&mon960_ops);
-}
diff --git a/contrib/gdb/gdb/monitor.c b/contrib/gdb/gdb/monitor.c
deleted file mode 100644
index dc47d8c..0000000
--- a/contrib/gdb/gdb/monitor.c
+++ /dev/null
@@ -1,2296 +0,0 @@
-/* Remote debugging interface for boot monitors, for GDB.
- Copyright 1990, 1991, 1992, 1993, 1995, 1996, 1997, 1999
- Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Rob Savoye for Cygnus.
- Resurrected from the ashes by Stu Grossman.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file was derived from various remote-* modules. It is a collection
- of generic support functions so GDB can talk directly to a ROM based
- monitor. This saves use from having to hack an exception based handler
- into existance, and makes for quick porting.
-
- This module talks to a debug monitor called 'MONITOR', which
- We communicate with MONITOR via either a direct serial line, or a TCP
- (or possibly TELNET) stream to a terminal multiplexor,
- which in turn talks to the target board. */
-
-/* FIXME 32x64: This code assumes that registers and addresses are at
- most 32 bits long. If they can be larger, you will need to declare
- values as LONGEST and use %llx or some such to print values when
- building commands to send to the monitor. Since we don't know of
- any actual 64-bit targets with ROM monitors that use this code,
- it's not an issue right now. -sts 4/18/96 */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "wait.h"
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <signal.h>
-#include <ctype.h>
-#include "gdb_string.h"
-#include <sys/types.h>
-#include "command.h"
-#include "serial.h"
-#include "monitor.h"
-#include "gdbcmd.h"
-#include "inferior.h"
-#include "gnu-regex.h"
-#include "dcache.h"
-#include "srec.h"
-
-static char *dev_name;
-static struct target_ops *targ_ops;
-
-static void monitor_vsprintf PARAMS ((char *sndbuf, char *pattern, va_list args));
-
-static int readchar PARAMS ((int timeout));
-
-static void monitor_command PARAMS ((char *args, int fromtty));
-
-static void monitor_fetch_register PARAMS ((int regno));
-static void monitor_store_register PARAMS ((int regno));
-
-static int monitor_printable_string PARAMS ((char *newstr, char *oldstr));
-static void monitor_error PARAMS ((char *format, CORE_ADDR memaddr, int len, char *string, int final_char));
-static void monitor_detach PARAMS ((char *args, int from_tty));
-static void monitor_resume PARAMS ((int pid, int step, enum target_signal sig));
-static void monitor_interrupt PARAMS ((int signo));
-static void monitor_interrupt_twice PARAMS ((int signo));
-static void monitor_interrupt_query PARAMS ((void));
-static void monitor_wait_cleanup PARAMS ((void *old_timeout));
-
-static int monitor_wait PARAMS ((int pid, struct target_waitstatus *status));
-static void monitor_fetch_registers PARAMS ((int regno));
-static void monitor_store_registers PARAMS ((int regno));
-static void monitor_prepare_to_store PARAMS ((void));
-static int monitor_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len, int write, struct target_ops *target));
-static void monitor_files_info PARAMS ((struct target_ops *ops));
-static int monitor_insert_breakpoint PARAMS ((CORE_ADDR addr, char *shadow));
-static int monitor_remove_breakpoint PARAMS ((CORE_ADDR addr, char *shadow));
-static void monitor_kill PARAMS ((void));
-static void monitor_load PARAMS ((char *file, int from_tty));
-static void monitor_mourn_inferior PARAMS ((void));
-static void monitor_stop PARAMS ((void));
-
-static int monitor_read_memory PARAMS ((CORE_ADDR addr, char *myaddr,int len));
-static int monitor_write_memory PARAMS ((CORE_ADDR addr, char *myaddr,int len));
-static int monitor_write_memory_bytes PARAMS ((CORE_ADDR addr,
- char *myaddr,int len));
-static int monitor_write_memory_block PARAMS((
- CORE_ADDR memaddr ,
- char * myaddr ,
- int len)) ;
-static int monitor_expect_regexp PARAMS ((struct re_pattern_buffer *pat,
- char *buf, int buflen));
-static void monitor_dump_regs PARAMS((void)) ;
-#if 0
-static int from_hex PARAMS ((int a));
-static unsigned long get_hex_word PARAMS ((void));
-#endif
-static void parse_register_dump PARAMS ((char *, int));
-
-static struct monitor_ops *current_monitor;
-
-static int hashmark; /* flag set by "set hash" */
-
-static int timeout = 30;
-
-static int in_monitor_wait = 0; /* Non-zero means we are in monitor_wait() */
-
-static void (*ofunc)(); /* Old SIGINT signal handler */
-
-/* Extra remote debugging for developing a new rom monitor variation */
-#if ! defined(EXTRA_RDEBUG)
-#define EXTRA_RDEBUG 0
-#endif
-#define RDEBUG(stuff) { if (EXTRA_RDEBUG && remote_debug) printf stuff ; }
-
-/* Descriptor for I/O to remote machine. Initialize it to NULL so
- that monitor_open knows that we don't have a file open when the
- program starts. */
-
-static serial_t monitor_desc = NULL;
-
-/* Pointer to regexp pattern matching data */
-
-static struct re_pattern_buffer register_pattern;
-static char register_fastmap[256];
-
-static struct re_pattern_buffer getmem_resp_delim_pattern;
-static char getmem_resp_delim_fastmap[256];
-
-static int dump_reg_flag; /* Non-zero means do a dump_registers cmd when
- monitor_wait wakes up. */
-
-static DCACHE *remote_dcache;
-static int first_time=0; /* is this the first time we're executing after
- gaving created the child proccess? */
-
-/* Convert a string into a printable representation, Return # byte in the
- new string. */
-
-static int
-monitor_printable_string (newstr, oldstr)
- char *newstr;
- char *oldstr;
-{
- char *save = newstr;
- int ch;
-
- while ((ch = *oldstr++) != '\0')
- {
- switch (ch)
- {
- default:
- if (isprint (ch))
- *newstr++ = ch;
-
- else
- {
- sprintf (newstr, "\\x%02x", ch & 0xff);
- newstr += 4;
- }
- break;
-
- case '\\': *newstr++ = '\\'; *newstr++ = '\\'; break;
- case '\b': *newstr++ = '\\'; *newstr++ = 'b'; break;
- case '\f': *newstr++ = '\\'; *newstr++ = 't'; break;
- case '\n': *newstr++ = '\\'; *newstr++ = 'n'; break;
- case '\r': *newstr++ = '\\'; *newstr++ = 'r'; break;
- case '\t': *newstr++ = '\\'; *newstr++ = 't'; break;
- case '\v': *newstr++ = '\\'; *newstr++ = 'v'; break;
- }
- }
-
- *newstr++ = '\0';
- return newstr - save;
-}
-
-/* Print monitor errors with a string, converting the string to printable
- representation. */
-
-static void
-monitor_error (format, memaddr, len, string, final_char)
- char *format;
- CORE_ADDR memaddr;
- int len;
- char *string;
- int final_char;
-{
- int real_len = (len == 0 && string != (char *)0) ? strlen (string) : len;
- char *safe_string = alloca ((real_len * 4) + 1);
- char *p, *q;
- int ch;
- int safe_len = monitor_printable_string (safe_string, string);
-
- if (final_char)
- error (format, (int)memaddr, p - safe_string, safe_string, final_char);
- else
- error (format, (int)memaddr, p - safe_string, safe_string);
-}
-
-/* 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
- if (a >= 'A' && a <= 'F')
- return a - 'A' + 10 ;
- else error ("Invalid hex digit %d", a);
-}
-
-/* monitor_vsprintf - similar to vsprintf but handles 64-bit addresses
-
- This function exists to get around the problem that many host platforms
- don't have a printf that can print 64-bit addresses. The %A format
- specification is recognized as a special case, and causes the argument
- to be printed as a 64-bit hexadecimal address.
-
- Only format specifiers of the form "[0-9]*[a-z]" are recognized.
- If it is a '%s' format, the argument is a string; otherwise the
- argument is assumed to be a long integer.
-
- %% is also turned into a single %.
-*/
-
-static void
-monitor_vsprintf (sndbuf, pattern, args)
- char *sndbuf;
- char *pattern;
- va_list args;
-{
- char format[10];
- char fmt;
- char *p;
- int i;
- long arg_int;
- CORE_ADDR arg_addr;
- char *arg_string;
-
- for (p = pattern; *p; p++)
- {
- if (*p == '%')
- {
- /* Copy the format specifier to a separate buffer. */
- format[0] = *p++;
- for (i = 1; *p >= '0' && *p <= '9' && i < (int) sizeof (format) - 2;
- i++, p++)
- format[i] = *p;
- format[i] = fmt = *p;
- format[i+1] = '\0';
-
- /* Fetch the next argument and print it. */
- switch (fmt)
- {
- case '%':
- strcpy (sndbuf, "%");
- break;
- case 'A':
- arg_addr = va_arg (args, CORE_ADDR);
- strcpy (sndbuf, paddr_nz (arg_addr));
- break;
- case 's':
- arg_string = va_arg (args, char *);
- sprintf (sndbuf, format, arg_string);
- break;
- default:
- arg_int = va_arg (args, long);
- sprintf (sndbuf, format, arg_int);
- break;
- }
- sndbuf += strlen (sndbuf);
- }
- else
- *sndbuf++ = *p;
- }
- *sndbuf = '\0';
-}
-
-
-/* monitor_printf_noecho -- Send data to monitor, but don't expect an echo.
- Works just like printf. */
-
-void
-#ifdef ANSI_PROTOTYPES
-monitor_printf_noecho (char *pattern, ...)
-#else
-monitor_printf_noecho (va_alist)
- va_dcl
-#endif
-{
- va_list args;
- char sndbuf[2000];
- int len;
-
-#if ANSI_PROTOTYPES
- va_start (args, pattern);
-#else
- char *pattern;
- va_start (args);
- pattern = va_arg (args, char *);
-#endif
-
- monitor_vsprintf (sndbuf, pattern, args);
-
- len = strlen (sndbuf);
- if (len + 1 > sizeof sndbuf)
- abort ();
-
-#if 0
- if (remote_debug > 0)
- puts_debug ("sent -->", sndbuf, "<--");
-#endif
- if (EXTRA_RDEBUG
- && remote_debug)
- {
- char *safe_string = (char *) alloca ((strlen (sndbuf) * 4) + 1);
- monitor_printable_string (safe_string, sndbuf);
- printf ("sent[%s]\n", safe_string);
- }
-
- monitor_write (sndbuf, len);
-}
-
-/* monitor_printf -- Send data to monitor and check the echo. Works just like
- printf. */
-
-void
-#ifdef ANSI_PROTOTYPES
-monitor_printf (char *pattern, ...)
-#else
-monitor_printf (va_alist)
- va_dcl
-#endif
-{
- va_list args;
- char sndbuf[2000];
- int len;
-
-#ifdef ANSI_PROTOTYPES
- va_start (args, pattern);
-#else
- char *pattern;
- va_start (args);
- pattern = va_arg (args, char *);
-#endif
-
- monitor_vsprintf (sndbuf, pattern, args);
-
- len = strlen (sndbuf);
- if (len + 1 > sizeof sndbuf)
- abort ();
-
-#if 0
- if (remote_debug > 0)
- puts_debug ("sent -->", sndbuf, "<--");
-#endif
- if (EXTRA_RDEBUG
- && remote_debug)
- {
- char *safe_string = (char *) alloca ((len * 4) + 1);
- monitor_printable_string (safe_string, sndbuf);
- printf ("sent[%s]\n", safe_string);
- }
-
- monitor_write (sndbuf, len);
-
- /* We used to expect that the next immediate output was the characters we
- just output, but sometimes some extra junk appeared before the characters
- we expected, like an extra prompt, or a portmaster sending telnet negotiations.
- So, just start searching for what we sent, and skip anything unknown. */
- RDEBUG(("ExpectEcho\n"))
- monitor_expect (sndbuf, (char *)0, 0);
-}
-
-
-/* Write characters to the remote system. */
-
-void
-monitor_write (buf, buflen)
- char *buf;
- int buflen;
-{
- if (SERIAL_WRITE(monitor_desc, buf, buflen))
- fprintf_unfiltered (gdb_stderr, "SERIAL_WRITE failed: %s\n",
- safe_strerror (errno));
-}
-
-
-/* Read a binary character from the remote system, doing all the fancy
- timeout stuff, but without interpreting the character in any way,
- and without printing remote debug information. */
-
-int
-monitor_readchar ()
-{
- int c;
- int looping;
-
- do
- {
- looping = 0;
- c = SERIAL_READCHAR (monitor_desc, timeout);
-
- if (c >= 0)
- c &= 0xff; /* don't lose bit 7 */
- }
- while (looping);
-
- if (c >= 0)
- return c;
-
- if (c == SERIAL_TIMEOUT)
- error ("Timeout reading from remote system.");
-
- perror_with_name ("remote-monitor");
-}
-
-
-/* Read a character from the remote system, doing all the fancy
- timeout stuff. */
-
-static int
-readchar (timeout)
- int timeout;
-{
- int c;
- static enum { last_random, last_nl, last_cr, last_crnl } state = last_random;
- int looping;
-
- do
- {
- looping = 0;
- c = SERIAL_READCHAR (monitor_desc, timeout);
-
- if (c >= 0)
- {
- c &= 0x7f;
-#if 0
- /* This seems to interfere with proper function of the
- input stream */
- if (remote_debug > 0)
- {
- char buf[2];
- buf[0] = c;
- buf[1] = '\0';
- puts_debug ("read -->", buf, "<--");
- }
-
-#endif
- }
-
- /* Canonicialize \n\r combinations into one \r */
- if ((current_monitor->flags & MO_HANDLE_NL) != 0)
- {
- if ((c == '\r' && state == last_nl)
- || (c == '\n' && state == last_cr))
- {
- state = last_crnl;
- looping = 1;
- }
- else if (c == '\r')
- state = last_cr;
- else if (c != '\n')
- state = last_random;
- else
- {
- state = last_nl;
- c = '\r';
- }
- }
- }
- while (looping);
-
- if (c >= 0)
- return c;
-
- if (c == SERIAL_TIMEOUT)
-#if 0 /* MAINTENANCE_CMDS */
- /* I fail to see how detaching here can be useful */
- if (in_monitor_wait) /* Watchdog went off */
- {
- target_mourn_inferior ();
- error ("GDB serial timeout has expired. Target detached.\n");
- }
- else
-#endif
- error ("Timeout reading from remote system.");
-
- perror_with_name ("remote-monitor");
-}
-
-/* Scan input from the remote system, until STRING is found. If BUF is non-
- zero, then collect input until we have collected either STRING or BUFLEN-1
- chars. In either case we terminate BUF with a 0. If input overflows BUF
- because STRING can't be found, return -1, else return number of chars in BUF
- (minus the terminating NUL). Note that in the non-overflow case, STRING
- will be at the end of BUF. */
-
-int
-monitor_expect (string, buf, buflen)
- char *string;
- char *buf;
- int buflen;
-{
- char *p = string;
- int obuflen = buflen;
- int c;
- extern struct target_ops *targ_ops;
-
- if (EXTRA_RDEBUG
- && remote_debug)
- {
- char *safe_string = (char *) alloca ((strlen (string) * 4) + 1);
- monitor_printable_string (safe_string, string);
- printf ("MON Expecting '%s'\n", safe_string);
- }
-
- immediate_quit = 1;
- while (1)
- {
- if (buf)
- {
- if (buflen < 2)
- {
- *buf = '\000';
- immediate_quit = 0;
- return -1;
- }
-
- c = readchar (timeout);
- if (c == '\000')
- continue;
- *buf++ = c;
- buflen--;
- }
- else
- c = readchar (timeout);
-
- /* Don't expect any ^C sent to be echoed */
-
- if (*p == '\003' || c == *p)
- {
- p++;
- if (*p == '\0')
- {
- immediate_quit = 0;
-
- if (buf)
- {
- *buf++ = '\000';
- return obuflen - buflen;
- }
- else
- return 0;
- }
- }
- else if ((c == '\021' || c == '\023') &&
- (STREQ (targ_ops->to_shortname, "m32r")
- || STREQ (targ_ops->to_shortname, "mon2000")))
- { /* m32r monitor emits random DC1/DC3 chars */
- continue;
- }
- else
- {
- p = string;
- if (c == *p)
- p++;
- }
- }
-}
-
-/* Search for a regexp. */
-
-static int
-monitor_expect_regexp (pat, buf, buflen)
- struct re_pattern_buffer *pat;
- char *buf;
- int buflen;
-{
- char *mybuf;
- char *p;
- RDEBUG(("MON Expecting regexp\n")) ;
- if (buf)
- mybuf = buf;
- else
- {
- mybuf = alloca (1024);
- buflen = 1024;
- }
-
- p = mybuf;
- while (1)
- {
- int retval;
-
- if (p - mybuf >= buflen)
- { /* Buffer about to overflow */
-
-/* On overflow, we copy the upper half of the buffer to the lower half. Not
- great, but it usually works... */
-
- memcpy (mybuf, mybuf + buflen / 2, buflen / 2);
- p = mybuf + buflen / 2;
- }
-
- *p++ = readchar (timeout);
-
- retval = re_search (pat, mybuf, p - mybuf, 0, p - mybuf, NULL);
- if (retval >= 0)
- return 1;
- }
-}
-
-/* Keep discarding input until we see the MONITOR 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 monitor_expect_prompt(). Exception: monitor_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 monitor_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. */
-
-int
-monitor_expect_prompt (buf, buflen)
- char *buf;
- int buflen;
-{
- RDEBUG(("MON Expecting prompt\n"))
- return monitor_expect (current_monitor->prompt, buf, buflen);
-}
-
-/* Get N 32-bit words from remote, each preceded by a space, and put
- them in registers starting at REGNO. */
-
-#if 0
-static unsigned long
-get_hex_word ()
-{
- unsigned long val;
- int i;
- int ch;
-
- do
- ch = readchar (timeout);
- while (isspace(ch));
-
- val = from_hex (ch);
-
- for (i = 7; i >= 1; i--)
- {
- ch = readchar (timeout);
- if (!isxdigit (ch))
- break;
- val = (val << 4) | from_hex (ch);
- }
-
- return val;
-}
-#endif
-
-static void
-compile_pattern (pattern, compiled_pattern, fastmap)
- char *pattern;
- struct re_pattern_buffer *compiled_pattern;
- char *fastmap;
-{
- int tmp;
- const char *val;
-
- compiled_pattern->fastmap = fastmap;
-
- tmp = re_set_syntax (RE_SYNTAX_EMACS);
- val = re_compile_pattern (pattern,
- strlen (pattern),
- compiled_pattern);
- re_set_syntax (tmp);
-
- if (val)
- error ("compile_pattern: Can't compile pattern string `%s': %s!", pattern, val);
-
- if (fastmap)
- re_compile_fastmap (compiled_pattern);
-}
-
-/* Open a connection to a remote debugger. NAME is the filename used
- for communication. */
-
-void
-monitor_open (args, mon_ops, from_tty)
- char *args;
- struct monitor_ops *mon_ops;
- int from_tty;
-{
- char *name;
- char **p;
-
- if (mon_ops->magic != MONITOR_OPS_MAGIC)
- error ("Magic number of monitor_ops struct wrong.");
-
- targ_ops = mon_ops->target;
- name = targ_ops->to_shortname;
-
- if (!args)
- error ("Use `target %s DEVICE-NAME' to use a serial port, or \n\
-`target %s HOST-NAME:PORT-NUMBER' to use a network connection.", name, name);
-
- target_preopen (from_tty);
-
- /* Setup pattern for register dump */
-
- if (mon_ops->register_pattern)
- compile_pattern (mon_ops->register_pattern, &register_pattern,
- register_fastmap);
-
- if (mon_ops->getmem.resp_delim)
- compile_pattern (mon_ops->getmem.resp_delim, &getmem_resp_delim_pattern,
- getmem_resp_delim_fastmap);
-
- unpush_target (targ_ops);
-
- if (dev_name)
- free (dev_name);
- dev_name = strsave (args);
-
- monitor_desc = SERIAL_OPEN (dev_name);
-
- if (!monitor_desc)
- perror_with_name (dev_name);
-
- if (baud_rate != -1)
- {
- if (SERIAL_SETBAUDRATE (monitor_desc, baud_rate))
- {
- SERIAL_CLOSE (monitor_desc);
- perror_with_name (dev_name);
- }
- }
-
- SERIAL_RAW (monitor_desc);
-
- SERIAL_FLUSH_INPUT (monitor_desc);
-
- /* some systems only work with 2 stop bits */
-
- SERIAL_SETSTOPBITS (monitor_desc, mon_ops->stopbits);
-
- current_monitor = mon_ops;
-
- /* See if we can wake up the monitor. First, try sending a stop sequence,
- then send the init strings. Last, remove all breakpoints. */
-
- if (current_monitor->stop)
- {
- monitor_stop ();
- if ((current_monitor->flags & MO_NO_ECHO_ON_OPEN) == 0)
- {
- RDEBUG(("EXP Open echo\n")) ;
- monitor_expect_prompt (NULL, 0);
- }
- }
-
- /* wake up the monitor and see if it's alive */
- for (p = mon_ops->init; *p != NULL; p++)
- {
- /* Some of the characters we send may not be echoed,
- but we hope to get a prompt at the end of it all. */
-
- if ((current_monitor->flags & MO_NO_ECHO_ON_OPEN) == 0)
- monitor_printf(*p);
- else
- monitor_printf_noecho (*p);
- monitor_expect_prompt (NULL, 0);
- }
-
- SERIAL_FLUSH_INPUT (monitor_desc);
-
- /* Remove all breakpoints */
-
- if (mon_ops->clr_all_break)
- {
- monitor_printf (mon_ops->clr_all_break);
- monitor_expect_prompt (NULL, 0);
- }
-
- if (from_tty)
- printf_unfiltered ("Remote target %s connected to %s\n", name, dev_name);
-
- push_target (targ_ops);
-
- inferior_pid = 42000; /* Make run command think we are busy... */
-
- /* Give monitor_wait something to read */
-
- monitor_printf (current_monitor->line_term);
-
- if (current_monitor->flags & MO_HAS_BLOCKWRITES)
- remote_dcache = dcache_init (monitor_read_memory, monitor_write_memory_block);
- else
- remote_dcache = dcache_init (monitor_read_memory, monitor_write_memory);
- start_remote ();
-}
-
-/* Close out all files and local state before this target loses
- control. */
-
-void
-monitor_close (quitting)
- int quitting;
-{
- if (monitor_desc)
- SERIAL_CLOSE (monitor_desc);
- monitor_desc = NULL;
-}
-
-/* Terminate the open connection to the remote debugger. Use this
- when you want to detach and do something else with your gdb. */
-
-static void
-monitor_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- pop_target (); /* calls monitor_close to do the real work */
- if (from_tty)
- printf_unfiltered ("Ending remote %s debugging\n", target_shortname);
-}
-
-/* Convert VALSTR into the target byte-ordered value of REGNO and store it. */
-
-char *
-monitor_supply_register (regno, valstr)
- int regno;
- char *valstr;
-{
- unsigned int val;
- unsigned char regbuf[MAX_REGISTER_RAW_SIZE];
- char *p;
-
- val = strtoul (valstr, &p, 16);
- RDEBUG(("Supplying Register %d %s\n",regno,valstr)) ;
-
- if (val == 0 && valstr == p)
- error ("monitor_supply_register (%d): bad value from monitor: %s.",
- regno, valstr);
-
- /* supply register stores in target byte order, so swap here */
-
- store_unsigned_integer (regbuf, REGISTER_RAW_SIZE (regno), val);
-
- supply_register (regno, regbuf);
-
- return p;
-}
-
-/* Tell the remote machine to resume. */
-
-void
-flush_monitor_dcache ()
-{
- dcache_flush (remote_dcache);
-}
-
-static void
-monitor_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
-{
- /* Some monitors require a different command when starting a program */
- RDEBUG(("MON resume\n")) ;
- if (current_monitor->flags & MO_RUN_FIRST_TIME && first_time == 1)
- {
- first_time = 0;
- monitor_printf ("run\r");
- if (current_monitor->flags & MO_NEED_REGDUMP_AFTER_CONT)
- dump_reg_flag = 1;
- return;
- }
- dcache_flush (remote_dcache);
- if (step)
- monitor_printf (current_monitor->step);
- else
- {
- if (current_monitor->continue_hook)
- (*current_monitor->continue_hook)() ;
- else monitor_printf (current_monitor->cont);
- if (current_monitor->flags & MO_NEED_REGDUMP_AFTER_CONT)
- dump_reg_flag = 1;
- }
-}
-
-/* Parse the output of a register dump command. A monitor specific
- regexp is used to extract individual register descriptions of the
- form REG=VAL. Each description is split up into a name and a value
- string which are passed down to monitor specific code. */
-
-static void
-parse_register_dump (buf, len)
- char *buf;
- int len;
-{
- RDEBUG(("MON Parsing register dump\n"))
- while (1)
- {
- int regnamelen, vallen;
- char *regname, *val;
- /* Element 0 points to start of register name, and element 1
- points to the start of the register value. */
- struct re_registers register_strings;
-
- memset (&register_strings, 0, sizeof (struct re_registers));
-
- if (re_search (&register_pattern, buf, len, 0, len,
- &register_strings) == -1)
- break;
-
- regnamelen = register_strings.end[1] - register_strings.start[1];
- regname = buf + register_strings.start[1];
- vallen = register_strings.end[2] - register_strings.start[2];
- val = buf + register_strings.start[2];
-
- current_monitor->supply_register (regname, regnamelen, val, vallen);
-
- buf += register_strings.end[0];
- len -= register_strings.end[0];
- }
-}
-
-/* Send ^C to target to halt it. Target will respond, and send us a
- packet. */
-
-static void
-monitor_interrupt (signo)
- int signo;
-{
- /* If this doesn't work, try more severe steps. */
- signal (signo, monitor_interrupt_twice);
-
- if (remote_debug)
- printf_unfiltered ("monitor_interrupt called\n");
-
- target_stop ();
-}
-
-/* The user typed ^C twice. */
-
-static void
-monitor_interrupt_twice (signo)
- int signo;
-{
- signal (signo, ofunc);
-
- monitor_interrupt_query ();
-
- signal (signo, monitor_interrupt);
-}
-
-/* Ask the user what to do when an interrupt is received. */
-
-static void
-monitor_interrupt_query ()
-{
- target_terminal_ours ();
-
- if (query ("Interrupted while waiting for the program.\n\
-Give up (and stop debugging it)? "))
- {
- target_mourn_inferior ();
- return_to_top_level (RETURN_QUIT);
- }
-
- target_terminal_inferior ();
-}
-
-static void
-monitor_wait_cleanup (old_timeout)
- void *old_timeout;
-{
- timeout = *(int*)old_timeout;
- signal (SIGINT, ofunc);
- in_monitor_wait = 0;
-}
-
-
-
-void monitor_wait_filter(char * buf,
- int bufmax,
- int * ext_resp_len,
- struct target_waitstatus * status
- )
-{
- int resp_len ;
- do
- {
- resp_len = monitor_expect_prompt (buf, bufmax);
- * ext_resp_len =resp_len ;
-
- if (resp_len <= 0)
- fprintf_unfiltered (gdb_stderr, "monitor_wait: excessive response from monitor: %s.", buf);
- }
- while (resp_len < 0);
-
- /* Print any output characters that were preceded by ^O. */
- /* FIXME - This would be great as a user settabgle flag */
- if (remote_debug ||
- current_monitor->flags & MO_PRINT_PROGRAM_OUTPUT)
- {
- int i;
-
- for (i = 0; i < resp_len - 1; i++)
- if (buf[i] == 0x0f)
- putchar_unfiltered (buf[++i]);
- }
-}
-
-
-
-/* Wait until the remote machine stops, then return, storing status in
- status just as `wait' would. */
-
-static int
-monitor_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- int old_timeout = timeout;
- char buf[1024];
- int resp_len;
- struct cleanup *old_chain;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- old_chain = make_cleanup (monitor_wait_cleanup, &old_timeout);
- RDEBUG(("MON wait\n"))
-
-#if 0 /* MAINTENANCE_CMDS */
- /* This is somthing other than a maintenance command */
- in_monitor_wait = 1;
- timeout = watchdog > 0 ? watchdog : -1;
-#else
- timeout = -1; /* Don't time out -- user program is running. */
-#endif
-
- ofunc = (void (*)()) signal (SIGINT, monitor_interrupt);
-
- if (current_monitor->wait_filter)
- (*current_monitor->wait_filter)(buf,sizeof (buf),&resp_len,status) ;
- else monitor_wait_filter(buf,sizeof (buf),&resp_len,status) ;
-
-#if 0 /* Transferred to monitor wait filter */
- do
- {
- resp_len = monitor_expect_prompt (buf, sizeof (buf));
-
- if (resp_len <= 0)
- fprintf_unfiltered (gdb_stderr, "monitor_wait: excessive response from monitor: %s.", buf);
- }
- while (resp_len < 0);
-
- /* Print any output characters that were preceded by ^O. */
- /* FIXME - This would be great as a user settabgle flag */
- if (remote_debug ||
- current_monitor->flags & MO_PRINT_PROGRAM_OUTPUT)
- {
- int i;
-
- for (i = 0; i < resp_len - 1; i++)
- if (buf[i] == 0x0f)
- putchar_unfiltered (buf[++i]);
- }
-#endif
-
- signal (SIGINT, ofunc);
-
- timeout = old_timeout;
-#if 0
- if (dump_reg_flag && current_monitor->dump_registers)
- {
- dump_reg_flag = 0;
- monitor_printf (current_monitor->dump_registers);
- resp_len = monitor_expect_prompt (buf, sizeof (buf));
- }
-
- if (current_monitor->register_pattern)
- parse_register_dump (buf, resp_len);
-#else
- RDEBUG(("Wait fetching registers after stop\n")) ;
- monitor_dump_regs() ;
-#endif
-
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
-
- discard_cleanups (old_chain);
-
- in_monitor_wait = 0;
-
- return inferior_pid;
-}
-
-/* Fetch register REGNO, or all registers if REGNO is -1. Returns
- errno value. */
-
-static void
-monitor_fetch_register (regno)
- int regno;
-{
- char *name;
- static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0};
- char regbuf[MAX_REGISTER_RAW_SIZE * 2 + 1];
- int i;
-
- name = current_monitor->regnames[regno];
- RDEBUG(("MON fetchreg %d '%s'\n",regno,name))
-
- if (!name || (*name == '\0'))
- { RDEBUG(("No register known for %d\n",regno))
- supply_register (regno, zerobuf);
- return;
- }
-
- /* send the register examine command */
-
- monitor_printf (current_monitor->getreg.cmd, name);
-
- /* If RESP_DELIM is specified, we search for that as a leading
- delimiter for the register value. Otherwise, we just start
- searching from the start of the buf. */
-
- if (current_monitor->getreg.resp_delim)
- {
- RDEBUG(("EXP getreg.resp_delim\n"))
- monitor_expect (current_monitor->getreg.resp_delim, NULL, 0);
- /* Handle case of first 32 registers listed in pairs. */
- if (current_monitor->flags & MO_32_REGS_PAIRED
- && regno & 1 == 1 && regno < 32)
- { RDEBUG(("EXP getreg.resp_delim\n")) ;
- monitor_expect (current_monitor->getreg.resp_delim, NULL, 0);
- }
- }
-
- /* Skip leading spaces and "0x" if MO_HEX_PREFIX flag is set */
- if (current_monitor->flags & MO_HEX_PREFIX)
- {
- int c;
- c = readchar (timeout);
- while (c == ' ')
- c = readchar (timeout);
- if ((c == '0') && ((c = readchar (timeout)) == 'x'))
- ;
- else
- error ("Bad value returned from monitor while fetching register %x.",
- regno);
- }
-
- /* Read upto the maximum number of hex digits for this register, skipping
- spaces, but stop reading if something else is seen. Some monitors
- like to drop leading zeros. */
-
- for (i = 0; i < REGISTER_RAW_SIZE (regno) * 2; i++)
- {
- int c;
- c = readchar (timeout);
- while (c == ' ')
- c = readchar (timeout);
-
- if (!isxdigit (c))
- break;
-
- regbuf[i] = c;
- }
-
- regbuf[i] = '\000'; /* terminate the number */
- RDEBUG(("REGVAL '%s'\n",regbuf)) ;
-
- /* If TERM is present, we wait for that to show up. Also, (if TERM
- is present), we will send TERM_CMD if that is present. In any
- case, we collect all of the output into buf, and then wait for
- the normal prompt. */
-
- if (current_monitor->getreg.term)
- {
- RDEBUG(("EXP getreg.term\n"))
- monitor_expect (current_monitor->getreg.term, NULL, 0); /* get response */
- }
-
- if (current_monitor->getreg.term_cmd)
- { RDEBUG(("EMIT getreg.term.cmd\n"))
- monitor_printf (current_monitor->getreg.term_cmd);
- }
- if (! current_monitor->getreg.term || /* Already expected or */
- current_monitor->getreg.term_cmd) /* ack expected */
- monitor_expect_prompt (NULL, 0); /* get response */
-
- monitor_supply_register (regno, regbuf);
-}
-
-/* Sometimes, it takes several commands to dump the registers */
-/* This is a primitive for use by variations of monitor interfaces in
- case they need to compose the operation.
- */
-int monitor_dump_reg_block(char * block_cmd)
-{
- char buf[1024];
- int resp_len;
- monitor_printf (block_cmd);
- resp_len = monitor_expect_prompt (buf, sizeof (buf));
- parse_register_dump (buf, resp_len);
- return 1 ;
-}
-
-
-/* Read the remote registers into the block regs. */
-/* Call the specific function if it has been provided */
-
-static void
-monitor_dump_regs ()
-{
- char buf[1024];
- int resp_len;
- if (current_monitor->dumpregs)
- (*(current_monitor->dumpregs))() ; /* call supplied function */
- else
- if (current_monitor->dump_registers) /* default version */
- { monitor_printf (current_monitor->dump_registers);
- resp_len = monitor_expect_prompt (buf, sizeof (buf));
- parse_register_dump (buf, resp_len);
- }
- else
- abort(); /* Need some way to read registers */
-}
-
-static void
-monitor_fetch_registers (regno)
- int regno;
-{
- RDEBUG(("MON fetchregs\n")) ;
- if (current_monitor->getreg.cmd)
- {
- if (regno >= 0)
- {
- monitor_fetch_register (regno);
- return;
- }
-
- for (regno = 0; regno < NUM_REGS; regno++)
- monitor_fetch_register (regno);
- }
- else {
- monitor_dump_regs ();
- }
-}
-
-/* Store register REGNO, or all if REGNO == 0. Return errno value. */
-
-static void
-monitor_store_register (regno)
- int regno;
-{
- char *name;
- unsigned int val;
-
- name = current_monitor->regnames[regno];
- if (!name || (*name == '\0'))
- { RDEBUG(("MON Cannot store unknown register\n"))
- return;
- }
-
- val = read_register (regno);
- RDEBUG(("MON storeg %d %08x\n",regno,(unsigned int)val))
-
- /* send the register deposit command */
-
- if (current_monitor->flags & MO_REGISTER_VALUE_FIRST)
- monitor_printf (current_monitor->setreg.cmd, val, name);
- else if (current_monitor->flags & MO_SETREG_INTERACTIVE)
- monitor_printf (current_monitor->setreg.cmd, name);
- else
- monitor_printf (current_monitor->setreg.cmd, name, val);
-
- if (current_monitor->setreg.term)
- { RDEBUG(("EXP setreg.term\n"))
- monitor_expect (current_monitor->setreg.term, NULL, 0);
- if (current_monitor->flags & MO_SETREG_INTERACTIVE)
- monitor_printf ("%x\r", val);
- monitor_expect_prompt (NULL, 0);
- }
- else
- monitor_expect_prompt (NULL, 0);
- if (current_monitor->setreg.term_cmd) /* Mode exit required */
- { RDEBUG(("EXP setreg_termcmd\n")) ;
- monitor_printf("%s",current_monitor->setreg.term_cmd) ;
- monitor_expect_prompt(NULL,0) ;
- }
-} /* monitor_store_register */
-
-/* Store the remote registers. */
-
-static void
-monitor_store_registers (regno)
- int regno;
-{
- if (regno >= 0)
- {
- monitor_store_register (regno);
- return;
- }
-
- for (regno = 0; regno < NUM_REGS; regno++)
- monitor_store_register (regno);
-}
-
-/* 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
-monitor_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static void
-monitor_files_info (ops)
- struct target_ops *ops;
-{
- printf_unfiltered ("\tAttached to %s at %d baud.\n", dev_name, baud_rate);
-}
-
-static int
-monitor_write_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- unsigned int val, hostval ;
- char *cmd;
- int i;
-
- RDEBUG(("MON write %d %08x\n",len,(unsigned long)memaddr))
-
- if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
- memaddr = ADDR_BITS_REMOVE (memaddr);
-
- /* Use memory fill command for leading 0 bytes. */
-
- if (current_monitor->fill)
- {
- for (i = 0; i < len; i++)
- if (myaddr[i] != 0)
- break;
-
- if (i > 4) /* More than 4 zeros is worth doing */
- {
- RDEBUG(("MON FILL %d\n",i))
- if (current_monitor->flags & MO_FILL_USES_ADDR)
- monitor_printf (current_monitor->fill, memaddr, (memaddr + i)-1, 0);
- else
- monitor_printf (current_monitor->fill, memaddr, i, 0);
-
- monitor_expect_prompt (NULL, 0);
-
- return i;
- }
- }
-
-#if 0
- /* Can't actually use long longs if VAL is an int (nice idea, though). */
- if ((memaddr & 0x7) == 0 && len >= 8 && current_monitor->setmem.cmdll)
- {
- len = 8;
- cmd = current_monitor->setmem.cmdll;
- }
- else
-#endif
- if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->setmem.cmdl)
- {
- len = 4;
- cmd = current_monitor->setmem.cmdl;
- }
- else if ((memaddr & 0x1) == 0 && len >= 2 && current_monitor->setmem.cmdw)
- {
- len = 2;
- cmd = current_monitor->setmem.cmdw;
- }
- else
- {
- len = 1;
- cmd = current_monitor->setmem.cmdb;
- }
-
- val = extract_unsigned_integer (myaddr, len);
-
- if (len == 4)
- { hostval = * (unsigned int *) myaddr ;
- RDEBUG(("Hostval(%08x) val(%08x)\n",hostval,val)) ;
- }
-
-
- if (current_monitor->flags & MO_NO_ECHO_ON_SETMEM)
- monitor_printf_noecho (cmd, memaddr, val);
- else if (current_monitor->flags & MO_SETMEM_INTERACTIVE)
- {
-
- monitor_printf_noecho (cmd, memaddr);
-
- if (current_monitor->setmem.term)
- { RDEBUG(("EXP setmem.term")) ;
- monitor_expect (current_monitor->setmem.term, NULL, 0);
- monitor_printf ("%x\r", val);
- }
- if (current_monitor->setmem.term_cmd)
- { /* Emit this to get out of the memory editing state */
- monitor_printf("%s",current_monitor->setmem.term_cmd) ;
- /* Drop through to expecting a prompt */
- }
- }
- else
- monitor_printf (cmd, memaddr, val);
-
- monitor_expect_prompt (NULL, 0);
-
- return len;
-}
-
-
-static int
-monitor_write_even_block(memaddr,myaddr,len)
- CORE_ADDR memaddr ;
- char * myaddr ;
- int len ;
-{
- unsigned int val ;
- int written = 0 ;;
- /* Enter the sub mode */
- monitor_printf(current_monitor->setmem.cmdl,memaddr) ;
- monitor_expect_prompt(NULL,0) ;
-
- while (len)
- {
- val = extract_unsigned_integer(myaddr,4) ; /* REALLY */
- monitor_printf("%x\r",val) ;
- myaddr += 4 ;
- memaddr += 4 ;
- written += 4 ;
- RDEBUG((" @ %08x\n",memaddr))
- /* If we wanted to, here we could validate the address */
- monitor_expect_prompt(NULL,0) ;
- }
- /* Now exit the sub mode */
- monitor_printf (current_monitor->getreg.term_cmd);
- monitor_expect_prompt(NULL,0) ;
- return written ;
-}
-
-
-static int monitor_write_memory_bytes(memaddr,myaddr,len)
- CORE_ADDR memaddr ;
- char * myaddr ;
- int len ;
-{
- unsigned char val ;
- int written = 0 ;
- if (len == 0) return 0 ;
- /* Enter the sub mode */
- monitor_printf(current_monitor->setmem.cmdb,memaddr) ;
- monitor_expect_prompt(NULL,0) ;
- while (len)
- {
- val = *myaddr ;
- monitor_printf("%x\r",val) ;
- myaddr++ ;
- memaddr++ ;
- written++ ;
- /* If we wanted to, here we could validate the address */
- monitor_expect_prompt(NULL,0) ;
- len-- ;
- }
- /* Now exit the sub mode */
- monitor_printf (current_monitor->getreg.term_cmd);
- monitor_expect_prompt(NULL,0) ;
- return written ;
-}
-
-
-static void
-longlongendswap (unsigned char * a)
-{
- int i,j ;
- unsigned char x ;
- i = 0 ; j = 7 ;
- while (i < 4)
- { x = *(a+i) ;
- *(a+i) = *(a+j) ;
- *(a+j) = x ;
- i++ , j-- ;
- }
-}
-/* Format 32 chars of long long value, advance the pointer */
-static char * hexlate = "0123456789abcdef" ;
-static char * longlong_hexchars(unsigned long long value,
- char * outbuff )
-{
- if (value == 0) { *outbuff++ = '0' ; return outbuff ; }
- else
- { static unsigned char disbuf[8] ; /* disassembly buffer */
- unsigned char * scan , * limit ; /* loop controls */
- unsigned char c , nib ;
- int leadzero = 1 ;
- scan = disbuf ; limit = scan + 8 ;
- { unsigned long long * dp ;
- dp = (unsigned long long *) scan ;
- *dp = value ;
- }
- longlongendswap(disbuf) ; /* FIXME: ONly on big endian hosts */
- while (scan < limit)
- { c = *scan++ ; /* a byte of our long long value */
- if (leadzero)
- if (c == 0) continue ;
- else leadzero = 0 ; /* henceforth we print even zeroes */
- nib = c >> 4 ; /* high nibble bits */
- *outbuff++ = hexlate[nib] ;
- nib = c & 0x0f ; /* low nibble bits */
- *outbuff++ = hexlate[nib] ;
- }
- return outbuff ;
- }
-} /* longlong_hexchars */
-
-
-
-/* I am only going to call this when writing virtual byte streams.
- Which possably entails endian conversions
- */
-static int monitor_write_memory_longlongs(memaddr,myaddr,len)
- CORE_ADDR memaddr ;
- char * myaddr ;
- int len ;
-{
- static char hexstage[20] ; /* At least 16 digits required, plus null */
- char * endstring ;
- long long * llptr ;
- long long value ;
- int written = 0 ;
- llptr = (unsigned long long *) myaddr ;
- if (len == 0 ) return 0 ;
- monitor_printf(current_monitor->setmem.cmdll,memaddr) ;
- monitor_expect_prompt(NULL,0) ;
- while (len >= 8 )
- {
- value = *llptr ;
- endstring = longlong_hexchars(*llptr,hexstage) ;
- *endstring = '\0' ; /* NUll terminate for printf */
- monitor_printf("%s\r",hexstage) ;
- llptr++ ;
- memaddr += 8 ;
- written += 8 ;
- /* If we wanted to, here we could validate the address */
- monitor_expect_prompt(NULL,0) ;
- len -= 8 ;
- }
- /* Now exit the sub mode */
- monitor_printf (current_monitor->getreg.term_cmd);
- monitor_expect_prompt(NULL,0) ;
- return written ;
-} /* */
-
-
-
-/* ----- MONITOR_WRITE_MEMORY_BLOCK ---------------------------- */
-/* This is for the large blocks of memory which may occur in downloading.
- And for monitors which use interactive entry,
- And for monitors which do not have other downloading methods.
- Without this, we will end up calling monitor_write_memory many times
- and do the entry and exit of the sub mode many times
- This currently assumes...
- MO_SETMEM_INTERACTIVE
- ! MO_NO_ECHO_ON_SETMEM
- To use this, the you have to patch the monitor_cmds block with
- this function. Otherwise, its not tuned up for use by all
- monitor variations.
- */
-
-static int monitor_write_memory_block(memaddr,myaddr,len)
- CORE_ADDR memaddr ;
- char * myaddr ;
- int len ;
-{
- int written ;
- written = 0 ;
- /* FIXME: This would be a good place to put the zero test */
-#if 1
- if ((len > 8) && (((len & 0x07)) == 0) && current_monitor->setmem.cmdll)
- {
- return monitor_write_memory_longlongs(memaddr,myaddr,len) ;
- }
-#endif
-#if 0
- if (len > 4)
- {
- int sublen ;
- written = monitor_write_even_block(memaddr,myaddr,len) ;
- /* Adjust calling parameters by written amount */
- memaddr += written ;
- myaddr += written ;
- len -= written ;
- }
-#endif
- written = monitor_write_memory_bytes(memaddr,myaddr,len) ;
- return written ;
-}
-
-/* This is an alternate form of monitor_read_memory which is used for monitors
- which can only read a single byte/word/etc. at a time. */
-
-static int
-monitor_read_memory_single (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- unsigned int val;
- char membuf[sizeof(int) * 2 + 1];
- char *p;
- char *cmd;
- int i;
-
- RDEBUG(("MON read single\n")) ;
-#if 0
- /* Can't actually use long longs (nice idea, though). In fact, the
- call to strtoul below will fail if it tries to convert a value
- that's too big to fit in a long. */
- if ((memaddr & 0x7) == 0 && len >= 8 && current_monitor->getmem.cmdll)
- {
- len = 8;
- cmd = current_monitor->getmem.cmdll;
- }
- else
-#endif
- if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->getmem.cmdl)
- {
- len = 4;
- cmd = current_monitor->getmem.cmdl;
- }
- else if ((memaddr & 0x1) == 0 && len >= 2 && current_monitor->getmem.cmdw)
- {
- len = 2;
- cmd = current_monitor->getmem.cmdw;
- }
- else
- {
- len = 1;
- cmd = current_monitor->getmem.cmdb;
- }
-
- /* Send the examine command. */
-
- monitor_printf (cmd, memaddr);
-
- /* If RESP_DELIM is specified, we search for that as a leading
- delimiter for the memory value. Otherwise, we just start
- searching from the start of the buf. */
-
- if (current_monitor->getmem.resp_delim)
- { RDEBUG(("EXP getmem.resp_delim\n")) ;
- monitor_expect_regexp (&getmem_resp_delim_pattern, NULL, 0);
- }
-
- /* Now, read the appropriate number of hex digits for this loc,
- skipping spaces. */
-
- /* Skip leading spaces and "0x" if MO_HEX_PREFIX flag is set. */
- if (current_monitor->flags & MO_HEX_PREFIX)
- {
- int c;
-
- c = readchar (timeout);
- while (c == ' ')
- c = readchar (timeout);
- if ((c == '0') && ((c = readchar (timeout)) == 'x'))
- ;
- else
- monitor_error ("monitor_read_memory_single (0x%x): bad response from monitor: %.*s%c.",
- memaddr, i, membuf, c);
- }
- for (i = 0; i < len * 2; i++)
- {
- int c;
-
- while (1)
- {
- c = readchar (timeout);
- if (isxdigit (c))
- break;
- if (c == ' ')
- continue;
-
- monitor_error ("monitor_read_memory_single (0x%x): bad response from monitor: %.*s%c.",
- memaddr, i, membuf, c);
- }
-
- membuf[i] = c;
- }
-
- membuf[i] = '\000'; /* terminate the number */
-
-/* If TERM is present, we wait for that to show up. Also, (if TERM is
- present), we will send TERM_CMD if that is present. In any case, we collect
- all of the output into buf, and then wait for the normal prompt. */
-
- if (current_monitor->getmem.term)
- {
- monitor_expect (current_monitor->getmem.term, NULL, 0); /* get response */
-
- if (current_monitor->getmem.term_cmd)
- {
- monitor_printf (current_monitor->getmem.term_cmd);
- monitor_expect_prompt (NULL, 0);
- }
- }
- else
- monitor_expect_prompt (NULL, 0); /* get response */
-
- p = membuf;
- val = strtoul (membuf, &p, 16);
-
- if (val == 0 && membuf == p)
- monitor_error ("monitor_read_memory_single (0x%x): bad value from monitor: %s.",
- memaddr, 0, membuf, 0);
-
- /* supply register stores in target byte order, so swap here */
-
- store_unsigned_integer (myaddr, len, val);
-
- return len;
-}
-
-/* Copy LEN bytes of data from debugger memory at MYADDR to inferior's
- memory at MEMADDR. Returns length moved. Currently, we do no more
- than 16 bytes at a time. */
-
-static int
-monitor_read_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- unsigned int val;
- char buf[512];
- char *p, *p1;
- int resp_len;
- int i;
- CORE_ADDR dumpaddr;
-
- if (len <= 0)
- {
- RDEBUG (("Zero length call to monitor_read_memory\n"));
- return 0;
- }
-
- if (remote_debug) printf("MON read block ta(%08x) ha(%08x) %d\n",
- (unsigned long) memaddr , (unsigned long)myaddr, len);
-
- if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
- memaddr = ADDR_BITS_REMOVE (memaddr);
-
- if (current_monitor->flags & MO_GETMEM_READ_SINGLE)
- return monitor_read_memory_single (memaddr, myaddr, len);
-
- len = min (len, 16);
-
- /* Some dumpers align the first data with the preceeding 16
- byte boundary. Some print blanks and start at the
- requested boundary. EXACT_DUMPADDR
- */
-
- dumpaddr = (current_monitor->flags & MO_EXACT_DUMPADDR)
- ? memaddr : memaddr & ~ 0x0f ;
-
- /* See if xfer would cross a 16 byte boundary. If so, clip it. */
- if (((memaddr ^ (memaddr + len - 1)) & ~0xf) != 0)
- len = ((memaddr + len) & ~0xf) - memaddr;
-
- /* send the memory examine command */
-
- if (current_monitor->flags & MO_GETMEM_NEEDS_RANGE)
- monitor_printf (current_monitor->getmem.cmdb, memaddr, memaddr + len - 1);
- else if (current_monitor->flags & MO_GETMEM_16_BOUNDARY)
- monitor_printf (current_monitor->getmem.cmdb, dumpaddr);
- else
- monitor_printf (current_monitor->getmem.cmdb, memaddr, len);
-
- /* If TERM is present, we wait for that to show up. Also, (if TERM
- is present), we will send TERM_CMD if that is present. In any
- case, we collect all of the output into buf, and then wait for
- the normal prompt. */
-
- if (current_monitor->getmem.term)
- {
- resp_len = monitor_expect (current_monitor->getmem.term, buf, sizeof buf); /* get response */
-
- if (resp_len <= 0)
- monitor_error ("monitor_read_memory (0x%x): excessive response from monitor: %.*s.",
- memaddr, resp_len, buf, 0);
-
- if (current_monitor->getmem.term_cmd)
- {
- SERIAL_WRITE (monitor_desc, current_monitor->getmem.term_cmd,
- strlen (current_monitor->getmem.term_cmd));
- monitor_expect_prompt (NULL, 0);
- }
- }
- else
- resp_len = monitor_expect_prompt (buf, sizeof buf); /* get response */
-
- p = buf;
-
- /* If RESP_DELIM is specified, we search for that as a leading
- delimiter for the values. Otherwise, we just start searching
- from the start of the buf. */
-
- if (current_monitor->getmem.resp_delim)
- {
- int retval, tmp;
- struct re_registers resp_strings;
- RDEBUG(("MON getmem.resp_delim %s\n",current_monitor->getmem.resp_delim)) ;
-
- memset (&resp_strings, 0, sizeof (struct re_registers));
- tmp = strlen (p);
- retval = re_search (&getmem_resp_delim_pattern, p, tmp, 0, tmp,
- &resp_strings);
-
- if (retval < 0)
- monitor_error ("monitor_read_memory (0x%x): bad response from monitor: %.*s.",
- memaddr, resp_len, buf, 0);
-
- p += resp_strings.end[0];
-#if 0
- p = strstr (p, current_monitor->getmem.resp_delim);
- if (!p)
- monitor_error ("monitor_read_memory (0x%x): bad response from monitor: %.*s.",
- memaddr, resp_len, buf, 0);
- p += strlen (current_monitor->getmem.resp_delim);
-#endif
- }
- if (remote_debug) printf("MON scanning %d ,%08x '%s'\n",len,p,p) ;
- if (current_monitor->flags & MO_GETMEM_16_BOUNDARY)
- {
- char c ;
- int fetched = 0 ;
- i = len;
- c = *p ;
-
-
- while (!(c == '\000' || c == '\n' || c == '\r') && i > 0)
- { if (isxdigit (c))
- { if ((dumpaddr >= memaddr) && (i > 0))
- { val = fromhex (c) * 16 + fromhex (*(p+1));
- *myaddr++ = val;
- if (remote_debug) printf("[%02x]",val) ;
- --i;
- fetched++ ;
- }
- ++dumpaddr;
- ++p;
- }
- ++p; /* skip a blank or other non hex char */
- c = *p ;
- }
- if (fetched == 0) error("Failed to read via monitor") ;
- if (remote_debug) printf("\n") ;
- return fetched ; /* Return the number of bytes actually read */
- }
- RDEBUG(("MON scanning bytes\n")) ;
-
- for (i = len; i > 0; i--)
- {
- /* Skip non-hex chars, but bomb on end of string and newlines */
-
- while (1)
- {
- if (isxdigit (*p))
- break;
-
- if (*p == '\000' || *p == '\n' || *p == '\r')
- monitor_error ("monitor_read_memory (0x%x): badly terminated response from monitor: %.*s",
- memaddr, resp_len, buf, 0);
- p++;
- }
-
- val = strtoul (p, &p1, 16);
-
- if (val == 0 && p == p1)
- monitor_error ("monitor_read_memory (0x%x): bad value from monitor: %.*s.",
- memaddr, resp_len, buf, 0);
-
- *myaddr++ = val;
-
- if (i == 1)
- break;
-
- p = p1;
- }
-
- return len;
-}
-
-static int
-monitor_xfer_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* ignored */
-{
- return dcache_xfer_memory (remote_dcache, memaddr, myaddr, len, write);
-}
-
-static void
-monitor_kill ()
-{
- return; /* ignore attempts to kill target system */
-}
-
-/* All we actually do is set the PC to the start address of exec_bfd, and start
- the program at that point. */
-
-static void
-monitor_create_inferior (exec_file, args, env)
- char *exec_file;
- char *args;
- char **env;
-{
- if (args && (*args != '\000'))
- error ("Args are not supported by the monitor.");
-
- first_time = 1;
- clear_proceed_status ();
- proceed (bfd_get_start_address (exec_bfd), TARGET_SIGNAL_0, 0);
-}
-
-/* Clean up when a program exits.
- The program actually lives on in the remote processor's RAM, and may be
- run again without a download. Don't leave it full of breakpoint
- instructions. */
-
-static void
-monitor_mourn_inferior ()
-{
- unpush_target (targ_ops);
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-
-#define NUM_MONITOR_BREAKPOINTS 8
-
-static CORE_ADDR breakaddr[NUM_MONITOR_BREAKPOINTS] = {0};
-
-/* Tell the monitor to add a breakpoint. */
-
-static int
-monitor_insert_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
-{
- int i;
- unsigned char *bp;
- int bplen;
-
- RDEBUG(("MON inst bkpt %08x\n",addr))
- if (current_monitor->set_break == NULL)
- error ("No set_break defined for this monitor");
-
- if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
- addr = ADDR_BITS_REMOVE (addr);
-
- /* Determine appropriate breakpoint size for this address. */
- bp = memory_breakpoint_from_pc (&addr, &bplen);
-
- for (i = 0; i < NUM_MONITOR_BREAKPOINTS; i++)
- {
- if (breakaddr[i] == 0)
- {
- breakaddr[i] = addr;
- monitor_read_memory (addr, shadow, bplen);
- monitor_printf (current_monitor->set_break, addr);
- monitor_expect_prompt (NULL, 0);
- return 0;
- }
- }
-
- error ("Too many breakpoints (> %d) for monitor.", NUM_MONITOR_BREAKPOINTS);
-}
-
-/* Tell the monitor to remove a breakpoint. */
-
-static int
-monitor_remove_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
-{
- int i;
-
- RDEBUG(("MON rmbkpt %08x\n",addr))
- if (current_monitor->clr_break == NULL)
- error ("No clr_break defined for this monitor");
-
- if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
- addr = ADDR_BITS_REMOVE (addr);
-
- for (i = 0; i < NUM_MONITOR_BREAKPOINTS; i++)
- {
- if (breakaddr[i] == addr)
- {
- breakaddr[i] = 0;
- /* some monitors remove breakpoints based on the address */
- if (current_monitor->flags & MO_CLR_BREAK_USES_ADDR)
- monitor_printf (current_monitor->clr_break, addr);
- else if (current_monitor->flags & MO_CLR_BREAK_1_BASED)
- monitor_printf (current_monitor->clr_break, i + 1);
- else
- monitor_printf (current_monitor->clr_break, i);
- monitor_expect_prompt (NULL, 0);
- return 0;
- }
- }
- fprintf_unfiltered (gdb_stderr,
- "Can't find breakpoint associated with 0x%x\n", addr);
- return 1;
-}
-
-/* monitor_wait_srec_ack -- wait for the target to send an acknowledgement for
- an S-record. Return non-zero if the ACK is received properly. */
-
-static int
-monitor_wait_srec_ack ()
-{
- int i, ch;
-
- if (current_monitor->flags & MO_SREC_ACK_PLUS)
- {
- return (readchar (timeout) == '+');
- }
- else if (current_monitor->flags & MO_SREC_ACK_ROTATE)
- {
- /* Eat two backspaces, a "rotating" char (|/-\), and a space. */
- if ((ch = readchar (1)) < 0)
- return 0;
- if ((ch = readchar (1)) < 0)
- return 0;
- if ((ch = readchar (1)) < 0)
- return 0;
- if ((ch = readchar (1)) < 0)
- return 0;
- }
- return 1;
-}
-
-/* monitor_load -- download a file. */
-
-static void
-monitor_load (file, from_tty)
- char *file;
- int from_tty;
-{
- dcache_flush (remote_dcache);
- RDEBUG(("MON load\n"))
-
- if (current_monitor->load_routine)
- current_monitor->load_routine (monitor_desc, file, hashmark);
- else
- { /* The default is ascii S-records */
- int n;
- unsigned long load_offset;
- char buf[128];
-
- /* enable user to specify address for downloading as 2nd arg to load */
- n = sscanf (file, "%s 0x%lx", buf, &load_offset);
- if (n > 1)
- file = buf;
- else
- load_offset = 0;
-
- monitor_printf (current_monitor->load);
- if (current_monitor->loadresp)
- monitor_expect (current_monitor->loadresp, NULL, 0);
-
- load_srec (monitor_desc, file, (bfd_vma) load_offset,
- 32, SREC_ALL, hashmark,
- current_monitor->flags & MO_SREC_ACK ?
- monitor_wait_srec_ack : NULL);
-
- monitor_expect_prompt (NULL, 0);
- }
-
-/* Finally, make the PC point at the start address */
-
- if (exec_bfd)
- write_pc (bfd_get_start_address (exec_bfd));
-
- inferior_pid = 0; /* No process now */
-
-/* This is necessary because many things were based on the PC at the time that
- we attached to the monitor, which is no longer valid now that we have loaded
- new code (and just changed the PC). Another way to do this might be to call
- normal_stop, except that the stack may not be valid, and things would get
- horribly confused... */
-
- clear_symtab_users ();
-}
-
-static void
-monitor_stop ()
-{
- RDEBUG(("MON stop\n")) ;
- if ((current_monitor->flags & MO_SEND_BREAK_ON_STOP) != 0)
- SERIAL_SEND_BREAK (monitor_desc);
- if (current_monitor->stop)
- monitor_printf_noecho (current_monitor->stop);
-}
-
-/* Put a command string, in args, out to MONITOR. Output from MONITOR
- is placed on the users terminal until the prompt is seen. FIXME: We
- read the characters ourseleves here cause of a nasty echo. */
-
-static void
-monitor_command (args, from_tty)
- char *args;
- int from_tty;
-{
- char *p;
- int resp_len;
- char buf[1000];
-
- if (monitor_desc == NULL)
- error ("monitor target not open.");
-
- p = current_monitor->prompt;
-
- /* Send the command. Note that if no args were supplied, then we're
- just sending the monitor a newline, which is sometimes useful. */
-
- monitor_printf ("%s\r", (args ? args : ""));
-
- resp_len = monitor_expect_prompt (buf, sizeof buf);
-
- fputs_unfiltered (buf, gdb_stdout); /* Output the response */
-}
-
-/* Convert hex digit A to a number. */
-
-#if 0
-static int
-from_hex (a)
- int a;
-{
- if (a >= '0' && a <= '9')
- return a - '0';
- if (a >= 'a' && a <= 'f')
- return a - 'a' + 10;
- if (a >= 'A' && a <= 'F')
- return a - 'A' + 10;
-
- error ("Reply contains invalid hex digit 0x%x", a);
-}
-#endif
-
-char *
-monitor_get_dev_name ()
-{
- return dev_name;
-}
-
-static struct target_ops monitor_ops;
-
-static void
-init_base_monitor_ops (void)
-{
- monitor_ops.to_shortname = NULL;
- monitor_ops.to_longname = NULL;
- monitor_ops.to_doc = NULL;
- monitor_ops.to_open = NULL;
- monitor_ops.to_close = monitor_close;
- monitor_ops.to_attach = NULL;
- monitor_ops.to_post_attach = NULL;
- monitor_ops.to_require_attach = NULL;
- monitor_ops.to_detach = monitor_detach;
- monitor_ops.to_require_detach = NULL;
- monitor_ops.to_resume = monitor_resume;
- monitor_ops.to_wait = monitor_wait;
- monitor_ops.to_post_wait = NULL;
- monitor_ops.to_fetch_registers = monitor_fetch_registers;
- monitor_ops.to_store_registers = monitor_store_registers;
- monitor_ops.to_prepare_to_store = monitor_prepare_to_store;
- monitor_ops.to_xfer_memory = monitor_xfer_memory;
- monitor_ops.to_files_info = monitor_files_info;
- monitor_ops.to_insert_breakpoint = monitor_insert_breakpoint;
- monitor_ops.to_remove_breakpoint = monitor_remove_breakpoint;
- monitor_ops.to_terminal_init = 0;
- monitor_ops.to_terminal_inferior = 0;
- monitor_ops.to_terminal_ours_for_output = 0;
- monitor_ops.to_terminal_ours = 0;
- monitor_ops.to_terminal_info = 0;
- monitor_ops.to_kill = monitor_kill;
- monitor_ops.to_load = monitor_load;
- monitor_ops.to_lookup_symbol = 0;
- monitor_ops.to_create_inferior = monitor_create_inferior;
- monitor_ops.to_post_startup_inferior = NULL;
- monitor_ops.to_acknowledge_created_inferior = NULL;
- monitor_ops.to_clone_and_follow_inferior = NULL;
- monitor_ops.to_post_follow_inferior_by_clone = NULL;
- monitor_ops.to_insert_fork_catchpoint = NULL;
- monitor_ops.to_remove_fork_catchpoint = NULL;
- monitor_ops.to_insert_vfork_catchpoint = NULL;
- monitor_ops.to_remove_vfork_catchpoint = NULL;
- monitor_ops.to_has_forked = NULL;
- monitor_ops.to_has_vforked = NULL;
- monitor_ops.to_can_follow_vfork_prior_to_exec = NULL;
- monitor_ops.to_post_follow_vfork = NULL;
- monitor_ops.to_insert_exec_catchpoint = NULL;
- monitor_ops.to_remove_exec_catchpoint = NULL;
- monitor_ops.to_has_execd = NULL;
- monitor_ops.to_reported_exec_events_per_exec_call = NULL;
- monitor_ops.to_has_exited = NULL;
- monitor_ops.to_mourn_inferior = monitor_mourn_inferior;
- monitor_ops.to_can_run = 0;
- monitor_ops.to_notice_signals = 0;
- monitor_ops.to_thread_alive = 0;
- monitor_ops.to_stop = monitor_stop;
- monitor_ops.to_pid_to_exec_file = NULL;
- monitor_ops.to_core_file_to_sym_file = NULL;
- monitor_ops.to_stratum = process_stratum;
- monitor_ops.DONT_USE = 0;
- monitor_ops.to_has_all_memory = 1;
- monitor_ops.to_has_memory = 1;
- monitor_ops.to_has_stack = 1;
- monitor_ops.to_has_registers = 1;
- monitor_ops.to_has_execution = 1;
- monitor_ops.to_sections = 0;
- monitor_ops.to_sections_end = 0;
- monitor_ops.to_magic = OPS_MAGIC;
-} /* init_base_monitor_ops */
-
-/* Init the target_ops structure pointed at by OPS */
-
-void
-init_monitor_ops (ops)
- struct target_ops *ops;
-{
- if (monitor_ops.to_magic != OPS_MAGIC)
- init_base_monitor_ops ();
-
- memcpy (ops, &monitor_ops, sizeof monitor_ops);
-}
-
-/* Define additional commands that are usually only used by monitors. */
-
-void
-_initialize_remote_monitors ()
-{
- init_base_monitor_ops ();
- add_show_from_set (add_set_cmd ("hash", no_class, var_boolean,
- (char *)&hashmark,
- "Set display of activity while downloading a file.\n\
-When enabled, a hashmark \'#\' is displayed.",
- &setlist),
- &showlist);
-
- add_com ("monitor", class_obscure, monitor_command,
- "Send a command to the debug monitor.");
-}
-
-
diff --git a/contrib/gdb/gdb/monitor.h b/contrib/gdb/gdb/monitor.h
deleted file mode 100644
index 4ccddd5..0000000
--- a/contrib/gdb/gdb/monitor.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/* Definitions for remote debugging interface for ROM monitors.
- Copyright 1990, 1991, 1992, 1996 Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Rob Savoye 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "serial.h"
-
-/* This structure describes the strings necessary to give small command
- sequences to the monitor, and parse the response.
-
- CMD is the actual command typed at the monitor. Usually this has
- embedded sequences ala printf, which are substituted with the
- arguments appropriate to that type of command. Ie: to examine a
- register, we substitute the register name for the first arg. To
- modify memory, we substitute the memory location and the new
- contents for the first and second args, etc...
-
- RESP_DELIM used to home in on the response string, and is used to
- disambiguate the answer within the pile of text returned by the
- monitor. This should be a unique string that immediately precedes
- the answer. Ie: if your monitor prints out `PC: 00000001= ' in
- response to asking for the PC, you should use `: ' as the
- RESP_DELIM. RESP_DELIM may be NULL if the res- ponse is going to
- be ignored, or has no particular leading text.
-
- TERM is the string that the monitor outputs to indicate that it is
- idle, and waiting for input. This is usually a prompt of some
- sort. In the previous example, it would be `= '. It is important
- that TERM really means that the monitor is idle, otherwise GDB may
- try to type at it when it isn't ready for input. This is a problem
- because many monitors cannot deal with type-ahead. TERM may be
- NULL if the normal prompt is output.
-
- TERM_CMD is used to quit out of the subcommand mode and get back to
- the main prompt. TERM_CMD may be NULL if it isn't necessary. It
- will also be ignored if TERM is NULL. */
-
-struct memrw_cmd
-{
- char *cmdb; /* Command to send for byte read/write */
- char *cmdw; /* Command for word (16 bit) read/write */
- char *cmdl; /* Command for long (32 bit) read/write */
- char *cmdll; /* Command for long long (64 bit) read/write */
- char *resp_delim; /* String just prior to the desired value */
- char *term; /* Terminating string to search for */
- char *term_cmd; /* String to get out of sub-mode (if necessary) */
-};
-
-struct regrw_cmd
-{
- char *cmd; /* Command to send for reg read/write */
- char *resp_delim; /* String (actually a regexp if getmem) just
- prior to the desired value */
- char *term; /* Terminating string to search for */
- char *term_cmd; /* String to get out of sub-mode (if necessary) */
-};
-
-struct monitor_ops
-{
- int flags; /* See below */
- char **init; /* List of init commands. NULL terminated. */
- char *cont; /* continue command */
- char *step; /* single step */
- char *stop; /* Interrupt program string */
- char *set_break; /* set a breakpoint */
- char *clr_break; /* clear a breakpoint */
- char *clr_all_break; /* Clear all breakpoints */
- char *fill; /* Memory fill cmd (addr len val) */
- struct memrw_cmd setmem; /* set memory to a value */
- struct memrw_cmd getmem; /* display memory */
- struct regrw_cmd setreg; /* set a register */
- struct regrw_cmd getreg; /* get a register */
- /* Some commands can dump a bunch of registers
- at once. This comes as a set of REG=VAL
- pairs. This should be called for each pair
- of registers that we can parse to supply
- GDB with the value of a register. */
- char *dump_registers; /* Command to dump all regs at once */
- char *register_pattern; /* Pattern that picks out register from reg dump */
- void (*supply_register) PARAMS ((char *name, int namelen,
- char *val, int vallen));
- void (*load_routine) PARAMS ((serial_t desc, char *file,
- int hashmark)); /* Download routine */
- int (*dumpregs) PARAMS((void)) ; /* routine to dump all registers */
- int (*continue_hook) PARAMS((void)) ; /* Emit the continue command */
- int (*wait_filter) PARAMS((char * buf, /* Maybe contains registers */
- int bufmax ,
- int * response_length,
- struct target_waitstatus * status)) ;
- char *load; /* load command */
- char *loadresp; /* Response to load command */
- char *prompt; /* monitor command prompt */
- char *line_term; /* end-of-command delimitor */
- char *cmd_end; /* optional command terminator */
- struct target_ops *target; /* target operations */
- int stopbits; /* number of stop bits */
- char **regnames; /* array of register names in ascii */
- int magic; /* Check value */
-};
-
-/* The monitor ops magic number, used to detect if an ops structure doesn't
- have the right number of entries filled in. */
-
-#define MONITOR_OPS_MAGIC 600925
-
-/* Flag definitions. */
-
-/* If set, then clear breakpoint command uses address, otherwise it
- uses an index returned by the monitor. */
-
-#define MO_CLR_BREAK_USES_ADDR 0x1
-
-/* If set, then memory fill command uses STARTADDR, ENDADDR+1, VALUE
- as args, else it uses STARTADDR, LENGTH, VALUE as args. */
-
-#define MO_FILL_USES_ADDR 0x2
-
-/* If set, then monitor doesn't automatically supply register dump
- when coming back after a continue. */
-
-#define MO_NEED_REGDUMP_AFTER_CONT 0x4
-
-/* getmem needs start addr and end addr */
-
-#define MO_GETMEM_NEEDS_RANGE 0x8
-
-/* getmem can only read one loc at a time */
-
-#define MO_GETMEM_READ_SINGLE 0x10
-
-/* handle \r\n combinations */
-
-#define MO_HANDLE_NL 0x20
-
-/* don't expect echos in monitor_open */
-
-#define MO_NO_ECHO_ON_OPEN 0x40
-
-/* If set, send break to stop monitor */
-
-#define MO_SEND_BREAK_ON_STOP 0x80
-
-/* If set, target sends an ACK after each S-record */
-
-#define MO_SREC_ACK 0x100
-
-/* Allow 0x prefix on addresses retured from monitor */
-
-#define MO_HEX_PREFIX 0x200
-
-/* Some monitors require a different command when starting a program */
-
-#define MO_RUN_FIRST_TIME 0x400
-
-/* Don't expect echos when getting memory */
-
-#define MO_NO_ECHO_ON_SETMEM 0x800
-
-/* If set, then register store command expects value BEFORE regname */
-
-#define MO_REGISTER_VALUE_FIRST 0x1000
-
-/* If set, then the monitor displays registers as pairs. */
-
-#define MO_32_REGS_PAIRED 0x2000
-
-/* If set, then register setting happens interactively. */
-
-#define MO_SETREG_INTERACTIVE 0x4000
-
-/* If set, then memory setting happens interactively. */
-
-#define MO_SETMEM_INTERACTIVE 0x8000
-
-/* If set, then memory dumps are always on 16-byte boundaries, even
- when less is desired. */
-
-#define MO_GETMEM_16_BOUNDARY 0x10000
-
-/* If set, then the monitor numbers its breakpoints starting from 1. */
-
-#define MO_CLR_BREAK_1_BASED 0x20000
-
-/* If set, then the monitor acks srecords with a plus sign. */
-
-#define MO_SREC_ACK_PLUS 0x40000
-
-/* If set, then the monitor "acks" srecords with rotating lines. */
-
-#define MO_SREC_ACK_ROTATE 0x80000
-
-/* If set, then remove useless address bits from memory addresses. */
-
-#define MO_ADDR_BITS_REMOVE 0x100000
-
-/* If set, then display target program output if prefixed by ^O. */
-
-#define MO_PRINT_PROGRAM_OUTPUT 0x200000
-
-/* Some dump bytes commands align the first data with the preceeding
-16 byte boundary. Some print blanks and start at the exactly the
-requested boundary. */
-
-#define MO_EXACT_DUMPADDR 0x400000
-
-/* Rather entering and exiting the write memory dialog for each word byte,
- we can save time by transferring the whole block without exiting
- the memory editing mode. You only need to worry about this
- if you are doing memory downloading.
- This engages a new write function registered with dcache.
- */
-#define MO_HAS_BLOCKWRITES 0x800000
-
-#define SREC_SIZE 160
-
-extern void monitor_open PARAMS ((char *args, struct monitor_ops *ops,
- int from_tty));
-extern void monitor_close PARAMS ((int quitting));
-extern char *monitor_supply_register PARAMS ((int regno, char *valstr));
-extern int monitor_expect PARAMS ((char *prompt, char *buf, int buflen));
-extern int monitor_expect_prompt PARAMS ((char *buf, int buflen));
-extern void monitor_printf PARAMS ((char *, ...))
- ATTR_FORMAT(printf, 1, 2);
-extern void monitor_printf_noecho PARAMS ((char *, ...))
- ATTR_FORMAT(printf, 1, 2);
-extern void monitor_write PARAMS ((char *buf, int buflen));
-extern int monitor_readchar PARAMS ((void));
-extern char *monitor_get_dev_name PARAMS ((void));
-extern void init_monitor_ops PARAMS ((struct target_ops *));
-extern int monitor_dump_reg_block PARAMS((char * dump_cmd)) ;
-extern void flush_monitor_dcache PARAMS ((void));
diff --git a/contrib/gdb/gdb/mpw-config.in b/contrib/gdb/gdb/mpw-config.in
deleted file mode 100644
index ed07878..0000000
--- a/contrib/gdb/gdb/mpw-config.in
+++ /dev/null
@@ -1,81 +0,0 @@
-# Configuration fragment for GDB.
-
-If "{host_canonical}" =~ /m68k-apple-mpw/
- forward-include "{srcdir}"config:m68k:xm-mpw.h xm.h
- Set siow_lib '"{Libraries}"SIOW.o'
-
-Else If "{host_canonical}" =~ /powerpc-apple-mpw/
- forward-include "{srcdir}"config:powerpc:xm-mpw.h xm.h
- Set siow_lib '"{PPCLibraries}"PPCSIOW.o'
-
-End If
-
-Set xdepfiles '"{o}"mac-xdep.c.o'
-
-Set enable_cflags ""
-
-# Make a copy of this file and give it a different name, so it
-# won't be confused with GDB's serial.h.
-
-Duplicate -y "{CIncludes}"Serial.h MacSerial.h
-
-Echo "/* dummy */" >termio.h
-
-If "{target_canonical}" =~ /m68k-apple-macos/
- forward-include "{srcdir}"config:m68k:tm-mac.h tm.h
- forward-include "{srcdir}"config:m68k:tm-m68k.h 'm68k/tm-m68k.h'
- Set tdepfiles '"{o}"m68k-tdep.c.o'
-
-Else If "{target_canonical}" =~ /powerpc-apple-macos/
- forward-include "{srcdir}"config:powerpc:tm-macos.h tm.h
- forward-include "{srcdir}"config:rs6000:tm-rs6000.h 'rs6000/tm-rs6000.h'
- Set tdepfiles '"{o}"rs6000-tdep.c.o "{o}"xcoffread.c.o'
-
-Else If "{target_canonical}" =~ /i386-unknown-go32/
- forward-include "{srcdir}"config:i386:tm-i386v.h tm.h
- Set tdepfiles '"{o}"i386-tdep.c.o'
-
-Else If "{target_canonical}" =~ /mips-idt-ecoff/
- forward-include "{srcdir}"config:mips:tm-embed.h tm.h
- forward-include "{srcdir}"config:mips:tm-bigmips.h 'mips/tm-bigmips.h'
- forward-include "{srcdir}"config:mips:tm-mips.h 'mips/tm-mips.h'
- Set tdepfiles '"{o}"mips-tdep.c.o "{o}"remote-mips.c.o'
-
-Else If "{target_canonical}" =~ /sh-hitachi-hms/
- forward-include "{srcdir}"config:sh:tm-sh.h tm.h
- Set tdepfiles '"{o}"sh-tdep.c.o'
-
-End If
-
-If "{target_canonical}" =~ /m68k-apple-macos/
- forward-include "{srcdir}"config:m68k:nm-macos.h nm.h
- Set natdepfiles '"{o}"mac-nat.c.o'
-
-Else If "{target_canonical}" =~ /powerpc-apple-macos/
- forward-include "{srcdir}"config:powerpc:nm-macos.h nm.h
- Set natdepfiles '"{o}"mac-nat.c.o'
-
-Else
- forward-include "{srcdir}"config:nm-empty.h nm.h
- Set natdepfiles ' '
-
-End If
-
-Echo '# From mpw-config.in' > "{o}"mk.tmp
-Echo "TDEPFILES = " {tdepfiles} >> "{o}"mk.tmp
-Echo "XDEPFILES = " {xdepfiles} >> "{o}"mk.tmp
-Echo "NATDEPFILES = " {natdepfiles} >> "{o}"mk.tmp
-Echo "XM_ADD_FILES = " >> "{o}"mk.tmp
-Echo "TM_ADD_FILES = " >> "{o}"mk.tmp
-Echo "NAT_ADD_FILES = " >> "{o}"mk.tmp
-Echo "XM_CDEPS = " >> "{o}"mk.tmp
-Echo "TM_CDEPS = " >> "{o}"mk.tmp
-Echo "NAT_CDEPS = " >> "{o}"mk.tmp
-Echo "SIOW_LIB = " {siow_lib} >> "{o}"mk.tmp
-Echo "ENABLE_CFLAGS = " {enable_cflags} >> "{o}"mk.tmp
-Echo '# End from mpw-config.in' >> "{o}"mk.tmp
-
-Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new
-Echo '#include "mpw.h"' >> "{o}"config.new
-
-MoveIfChange "{o}"config.new "{o}"config.h
diff --git a/contrib/gdb/gdb/mpw-make.sed b/contrib/gdb/gdb/mpw-make.sed
deleted file mode 100644
index ce6a9ec..0000000
--- a/contrib/gdb/gdb/mpw-make.sed
+++ /dev/null
@@ -1,178 +0,0 @@
-# Sed commands that finish translating the GDB Unix Makefile to MPW syntax.
-
-/^host_alias =/s/^/#/
-/^target_alias =/s/^/#/
-
-/^host_makefile_frag@$/d
-/^target_makefile_frag@$/d
-
-/@ENABLE_CFLAGS@/s/@ENABLE_CFLAGS@/{ENABLE_CFLAGS}/g
-/^ENABLE_CFLAGS=/s/^/#/
-
-# Edit all the symbolic definitions pointing to various libraries and such.
-
-/^INCLUDE_DIR = /s/"{srcdir}":include/"{topsrcdir}"include:/
-
-/^MMALLOC_DIR = /s/::mmalloc/mmalloc:/
-/^MMALLOC_SRC = /s/"{srcdir}"/"{topsrcdir}"/
-/^MMALLOC =/s/=.*$/=/
-/MMALLOC_CFLAGS =/s/=.*$/= -u USE_MMALLOC/
-
-/^BFD_DIR = /s/::bfd/bfd:/
-/^BFD = /s/{BFD_DIR}:libbfd/{BFD_DIR}libbfd/
-/^BFD_SRC = /s/"{srcdir}"/"{topsrcdir}"/
-
-/^READLINE_DIR = /s/::readline/readline:/
-/^READLINE =/s/=.*$/=/
-/^READLINE_SRC = /s/"{srcdir}"/"{topsrcdir}"/
-
-/^INCLUDE_CFLAGS = /s/$/ -i "{topsrcdir}"include:mpw: -i ::extra-include:/
-
-/^SER_HARDWIRE =/s/ser-unix/ser-mac/
-
-/^TERMCAP =/s/ =.*$/ =/
-
-# Whack out various autoconf vars that we don't need.
-/@CONFIG_LDFLAGS@/s/@CONFIG_LDFLAGS@//g
-/@HLDFLAGS@/s/@HLDFLAGS@//g
-/@DEFS@/s/@DEFS@//g
-/@YACC@/s/@YACC@/byacc/g
-/@ENABLE_OBS@/s/@ENABLE_OBS@//g
-/@ENABLE_CLIBS@/s/@ENABLE_CLIBS@//g
-/@LIBS@/s/@LIBS@//g
-
-# Whack out autoconf hook for thread debugging.
-/@THREAD_DB_OBS@/s/@THREAD_DB_OBS@//g
-
-# Fix up paths to include directories.
-/INCLUDE_DIR/s/"{s}"{INCLUDE_DIR}/{INCLUDE_DIR}/g
-/INCLUDE_DIR/s/{INCLUDE_DIR}:/{INCLUDE_DIR}/g
-/INCLUDE_DIR/s/"{INCLUDE_DIR}":/"{INCLUDE_DIR}"/g
-
-/{BFD_DIR}/s/"{BFD_DIR}":/"{BFD_DIR}"/g
-/{BFD_DIR}/s/\([ ]\){BFD_DIR}/\1::{BFD_DIR}/g
-/{BFD_DIR}/s/\([ ]\)"{BFD_DIR}"/\1::"{BFD_DIR}"/g
-
-/{BFD_SRC}/s/"{s}"{BFD_SRC}/{BFD_SRC}/g
-/{BFD_SRC}/s/{BFD_SRC}:/{BFD_SRC}/g
-
-/{READLINE_SRC}/s/"{s}"{READLINE_SRC}/{READLINE_SRC}/g
-
-/^readline_headers =/,/^$/c\
-readline_headers =\
-
-
-# This isn't really useful, and seems to cause nonsensical complaints.
-/{ALLDEPFILES}/s/{ALLDEPFILES}//g
-
-/^copying.c \\Option-f /,/^$/d
-
-# Fix the syntax of bits of C code that go into version.c.
-/char /s/'char .Option-x/'char */
-
-# Point at files in the obj dir rather than src dir.
-/version/s/"{s}"version\.c/"{o}"version.c/g
-/version/s/^version\.c/"{o}"version.c/
-/config/s/"{s}"config\.h/"{o}"config.h/g
-/config/s/^config\.h/"{o}"config.h/
-/xm/s/"{s}"xm\.h/"{o}"xm.h/g
-/xm/s/^xm\.h/"{o}"xm.h/
-/tm/s/"{s}"tm\.h/"{o}"tm.h/g
-/tm/s/^tm\.h/"{o}"tm.h/
-/nm/s/"{s}"nm\.h/"{o}"nm.h/g
-/nm/s/^nm\.h/"{o}"nm.h/
-
-/exp.tab.c/s/"{s}"\([a-z0-9]*\)-exp\.tab\.c/"{o}"\1-exp.tab.c/g
-/exp.tab.c/s/^\([a-z0-9]*\)-exp\.tab\.c/"{o}"\1-exp.tab.c/
-
-/y.tab/s/"{s}"y.tab\.c/"{o}"y.tab.c/g
-/y.tab/s/^y.tab\.c/"{o}"y.tab.c/
-
-/init/s/"{s}"init\.c-tmp/"{o}"init.c-tmp/g
-/init/s/^init\.c-tmp/"{o}"init.c-tmp/
-/init/s/"{s}"init\.c/"{o}"init.c/g
-/init/s/^init\.c/"{o}"init.c/
-
-# Fix up the generation of version.c.
-/"{o}"version.c \\Option-f Makefile/,/^$/c\
-"{o}"version.c \\Option-f Makefile\
- echo -n 'char *version = "' >"{o}"version.c\
- echo -n "{VERSION}" >>"{o}"version.c\
- echo '";' >>"{o}"version.c\
- echo -n 'char *host_name = "' >>"{o}"version.c\
- echo -n "{host_alias}" >>"{o}"version.c\
- echo '";' >>"{o}"version.c\
- echo -n 'char *target_name = "' >>"{o}"version.c\
- echo -n "{target_alias}" >>"{o}"version.c\
- echo '";' >>"{o}"version.c\
-
-
-/ansidecl/s/include "{s}""ansidecl.h"/include "ansidecl.h"/
-
-# Open-brace in a command causes much confusion; replace with the
-# result from a script.
-/initialize_all_files ()/c\
- Echo -n 'void initialize_all_files () ' >> "{o}"init.c-tmp\
- open-brace >> "{o}"init.c-tmp
-
-# Replace the whole sed bit for init.c; it's simpler that way...
-/echo {OBS} {TSOBS}/,/echo '}'/c\
- For i in {OBS} {TSOBS}\
- Set filename "`Echo {i} | sed \\Option-d\
- -e '/^Onindy.c.o/d' \\Option-d\
- -e '/^nindy.c.o/d' \\Option-d\
- -e '/ttyflush.c.o/d' \\Option-d\
- -e '/xdr_ld.c.o/d' \\Option-d\
- -e '/xdr_ptrace.c.o/d' \\Option-d\
- -e '/xdr_rdb.c.o/d' \\Option-d\
- -e '/udr.c.o/d' \\Option-d\
- -e '/udip2soc.c.o/d' \\Option-d\
- -e '/udi2go32.c.o/d' \\Option-d\
- -e '/version.c.o/d' \\Option-d\
- -e '/[a-z0-9A-Z_]*-exp.tab.c.o/d' \\Option-d\
- -e 's/\\.c\\.o/.c/' \\Option-d\
- -e 's/^://'`"\
- If "{filename}" != ""\
- sed <"{s}""{filename}" >>"{o}"init.c-tmp -n \\Option-d\
- -e '/^_initialize_[a-z_0-9A-Z]* *(/s/^\\([a-z_0-9A-Z]*\\).*/ {extern void \\1 (); \\1 ();}/p'\
- End If\
- End For\
- Echo '}' >>"{o}"init.c-tmp
-
-# Fix the main compile/link command.
-/{CC_LD} {INTERNAL_LDFLAGS} -o gdb/,/"{o}"init.c.o {OBS} {TSOBS} {ADD_FILES} {CLIBS} {LOADLIBES}/c\
- {CC_LD} {INTERNAL_LDFLAGS} -o gdb{PROG_EXT} "{o}"init.c.o {OBS} {TSOBS} {ADD_FILES} {CLIBS} {LOADLIBES} {EXTRALIBS}\
- {MAKEPEF} gdb{PROG_EXT} -o gdb {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
- {REZ} "{s}"mac-gdb.r -o gdb -append -d PROG_NAME='"'gdb'"' -d VERSION_STRING='"'{version}'"'\
-
-# Replace the install actions with MPW-friendly script.
-/^install \\Option-f /,/^$/c\
-install \\Option-f all install-only\
-\
-install-only \\Option-f \
- NewFolderRecursive "{bindir}"\
- Duplicate -y gdb "{bindir}"gdb\
- If "`Exists SiowGDB`" != ""\
- Duplicate -y SiowGDB "{bindir}"SiowGDB\
- End If\
-
-
-# Don't do any recursive subdir stuff.
-/ subdir_do/s/{MAKE}/null-command/
-
-# Edit out actions that only confuse MPW Make.
-/^config.status \\Option-f/,/^$/d
-/^Makefile \\Option-f/,/^$/d
-
-# Don't test config.h dependencies.
-/^"{o}"config.h \\Option-f/s/^/#/
-
-# Add an action to build SIOWgdb.
-$a\
-SIOWgdb \\Option-f {OBS} {TSOBS} {ADD_DEPS} {CDEPS} "{o}"init.c.o\
- Delete -i -y SIOWgdb\
- {CC_LD} {INTERNAL_LDFLAGS} -t 'APPL' -c 'gdb ' -o SIOWgdb{PROG_EXT} "{o}"init.c.o {OBS} {TSOBS} {ADD_FILES} {CLIBS} {SIOW_LIB} {LOADLIBES} {EXTRALIBS}\
- {MAKEPEF} SIOWgdb{PROG_EXT} -o SIOWgdb -ft 'APPL' -fc 'gdb ' {MAKEPEF_FLAGS} \
- {REZ} -o SIOWgdb "{RIncludes}"siow.r -append -d __kPrefSize=5000 -d __kMinSize=2000 -d APPNAME='"'SIOWgdb'"' \
- {REZ} "{s}"mac-gdb.r -o SIOWgdb -append -d VERSION_STRING='"'{version}'"'\
-
diff --git a/contrib/gdb/gdb/news-xdep.c b/contrib/gdb/gdb/news-xdep.c
deleted file mode 100644
index 7f57aeb..0000000
--- a/contrib/gdb/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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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/contrib/gdb/gdb/nindy-tdep.c b/contrib/gdb/gdb/nindy-tdep.c
deleted file mode 100644
index 2e0b10c..0000000
--- a/contrib/gdb/gdb/nindy-tdep.c
+++ /dev/null
@@ -1,74 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Miscellaneous NINDY-dependent routines.
- Some replace macros normally defined in "tm.h". */
-
-#include "defs.h"
-#include "symtab.h"
-#include "frame.h"
-#include "gdbcore.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)
- CORE_ADDR chain;
- struct frame_info *curframe;
-{
- struct symbol *sym;
- struct minimal_symbol *msymbol;
-
- /* 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 = SYMBOL_VALUE (sym);
- } else {
- msymbol = lookup_minimal_symbol (sf, NULL, NULL);
- if (msymbol == NULL)
- return 0;
- a = SYMBOL_VALUE_ADDRESS (msymbol);
- }
-
- return ( chain != read_memory_integer(a,4) );
-}
diff --git a/contrib/gdb/gdb/ns32k-tdep.c b/contrib/gdb/gdb/ns32k-tdep.c
deleted file mode 100644
index 3edb7f5..0000000
--- a/contrib/gdb/gdb/ns32k-tdep.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Print NS 32000 instructions for GDB, the GNU debugger.
- Copyright 1986, 1988, 1991, 1992, 1994, 1995
- Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-void
-_initialize_ns32k_tdep ()
-{
- tm_print_insn = print_insn_ns32k;
-}
-
-sign_extend (value, bits)
-{
- value = value & ((1 << bits) - 1);
- return (value & (1 << (bits-1))
- ? value | (~((1 << bits) - 1))
- : value);
-}
-
-void
-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;
- }
-}
-
-/* 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. */
-
-int
-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;
-}
-
-
-/* Nonzero if instruction at PC is a return instruction. */
-
-static int
-ns32k_about_to_return (pc)
- CORE_ADDR pc;
-{
- return (read_memory_integer (pc, 1) == 0x12);
-}
-
-
-/*
- * 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 (pc == 0)
- return 0;
-
- if (ns32k_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/contrib/gdb/gdb/ns32km3-nat.c b/contrib/gdb/gdb/ns32km3-nat.c
deleted file mode 100644
index cdafb9c..0000000
--- a/contrib/gdb/gdb/ns32km3-nat.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* Low level interface to ns532 running mach 3.0.
- Copyright (C) 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-
-#include <stdio.h>
-
-#include <mach.h>
-#include <mach/message.h>
-#include <mach/exception.h>
-#include <mach_error.h>
-
-#define private static
-
-
-/* Find offsets to thread states at compile time.
- * If your compiler does not grok this, calculate offsets
- * offsets yourself and use them (or get a compatible compiler :-)
- */
-
-#define REG_N_OFFSET(reg) (int)(&((struct ns532_combined_state *)0)->ts.reg)
-#define REG_F_OFFSET(reg) (int)(&((struct ns532_combined_state *)0)->fs.reg)
-
-/* at reg_offset[i] is the offset to the ns532_combined_state
- * location where the gdb registers[i] is stored.
- */
-
-static int reg_offset[] =
-{
- REG_N_OFFSET(r0), REG_N_OFFSET(r1), REG_N_OFFSET(r2), REG_N_OFFSET(r3),
- REG_N_OFFSET(r4), REG_N_OFFSET(r5), REG_N_OFFSET(r6), REG_N_OFFSET(r7),
- REG_F_OFFSET(l0a), REG_F_OFFSET(l0b),REG_F_OFFSET(l2a),REG_F_OFFSET(l2b),
- REG_F_OFFSET(l4a), REG_F_OFFSET(l4b),REG_F_OFFSET(l6a),REG_F_OFFSET(l6b),
- REG_N_OFFSET(sp), REG_N_OFFSET(fp), REG_N_OFFSET(pc), REG_N_OFFSET(psr),
- REG_F_OFFSET(fsr),
- REG_F_OFFSET(l0a), REG_F_OFFSET(l1a),REG_F_OFFSET(l2a),REG_F_OFFSET(l3a),
- REG_F_OFFSET(l4a), REG_F_OFFSET(l5a),REG_F_OFFSET(l6a),REG_F_OFFSET(l7a),
-};
-
-#define REG_ADDRESS(state,regnum) ((char *)(state)+reg_offset[regnum])
-
-/* Fetch COUNT contiguous registers from thread STATE starting from REGNUM
- * Caller knows that the regs handled in one transaction are of same size.
- */
-#define FETCH_REGS(state, regnum, count) \
- memcpy (&registers[REGISTER_BYTE (regnum)], \
- (char *)state+reg_offset[ regnum ], \
- count*REGISTER_SIZE)
-
-/* Store COUNT contiguous registers to thread STATE starting from REGNUM */
-#define STORE_REGS(state, regnum, count) \
- memcpy ((char *)state+reg_offset[ regnum ], \
- &registers[REGISTER_BYTE (regnum)], \
- count*REGISTER_SIZE)
-
-/*
- * Fetch inferiors registers for gdb.
- * REGNO specifies which (as gdb views it) register, -1 for all.
- */
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- kern_return_t ret;
- thread_state_data_t state;
- unsigned int stateCnt = NS532_COMBINED_STATE_COUNT;
- int index;
-
- if (! MACH_PORT_VALID (current_thread))
- error ("fetch inferior registers: Invalid thread");
-
- if (must_suspend_thread)
- setup_thread (current_thread, 1);
-
- ret = thread_get_state (current_thread,
- NS532_COMBINED_STATE,
- state,
- &stateCnt);
-
- if (ret != KERN_SUCCESS)
- warning ("fetch_inferior_registers: %s ",
- mach_error_string (ret));
-#if 0
- /* It may be more effective to store validate all of them,
- * since we fetched them all anyway
- */
- else if (regno != -1)
- supply_register (regno, (char *)state+reg_offset[regno]);
-#endif
- else
- {
- for (index = 0; index < NUM_REGS; index++)
- supply_register (index, (char *)state+reg_offset[index]);
- }
-
- if (must_suspend_thread)
- setup_thread (current_thread, 0);
-}
-
-/* Store our register values back into the inferior.
- * If REGNO is -1, do this for all registers.
- * Otherwise, REGNO specifies which register
- *
- * On mach3 all registers are always saved in one call.
- */
-void
-store_inferior_registers (regno)
- int regno;
-{
- kern_return_t ret;
- thread_state_data_t state;
- unsigned int stateCnt = NS532_COMBINED_STATE_COUNT;
- register int index;
-
- if (! MACH_PORT_VALID (current_thread))
- error ("store inferior registers: Invalid thread");
-
- if (must_suspend_thread)
- setup_thread (current_thread, 1);
-
- /* Fetch the state of the current thread */
- ret = thread_get_state (current_thread,
- NS532_COMBINED_STATE,
- state,
- &stateCnt);
-
- if (ret != KERN_SUCCESS)
- {
- warning ("store_inferior_registers (get): %s",
- mach_error_string (ret));
- if (must_suspend_thread)
- setup_thread (current_thread, 0);
- return;
- }
-
- /* move gdb's registers to thread's state
- *
- * Since we save all registers anyway, save the ones
- * that gdb thinks are valid (e.g. ignore the regno
- * parameter)
- */
-#if 0
- if (regno != -1)
- STORE_REGS (state, regno, 1);
- else
-#endif
- {
- for (index = 0; index < NUM_REGS; index++)
- STORE_REGS (state, index, 1);
- }
-
- /* Write gdb's current view of register to the thread
- */
- ret = thread_set_state (current_thread,
- NS532_COMBINED_STATE,
- state,
- NS532_COMBINED_STATE_COUNT);
-
- if (ret != KERN_SUCCESS)
- warning ("store_inferior_registers (set): %s",
- mach_error_string (ret));
-
- if (must_suspend_thread)
- setup_thread (current_thread, 0);
-}
diff --git a/contrib/gdb/gdb/objfiles.c b/contrib/gdb/gdb/objfiles.c
index 971a7d4..97b05dc 100644
--- a/contrib/gdb/gdb/objfiles.c
+++ b/contrib/gdb/gdb/objfiles.c
@@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Prototypes for local functions */
-#if defined(USE_MMALLOC) && defined(HAVE_MMAP)
+#if !defined(NO_MMALLOC) && defined(HAVE_MMAP)
static int
open_existing_mapped_file PARAMS ((char *, long, int));
@@ -45,13 +45,10 @@ open_existing_mapped_file PARAMS ((char *, long, int));
static int
open_mapped_file PARAMS ((char *filename, long mtime, int mapped));
-static PTR
-map_to_file PARAMS ((int));
+static CORE_ADDR
+map_to_address PARAMS ((void));
-#endif /* defined(USE_MMALLOC) && defined(HAVE_MMAP) */
-
-static void
-add_to_objfile_sections PARAMS ((bfd *, sec_ptr, PTR));
+#endif /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */
/* Externally visible variables that are owned by this module.
See declarations in objfile.h for more info. */
@@ -67,10 +64,6 @@ int mapped_symbol_files; /* Try to use mapped symbol files */
objfile_p_char is a char * to get it through
bfd_map_over_sections; we cast it back to its proper type. */
-#ifndef TARGET_KEEP_SECTION
-#define TARGET_KEEP_SECTION(ASECT) 0
-#endif
-
static void
add_to_objfile_sections (abfd, asect, objfile_p_char)
bfd *abfd;
@@ -82,16 +75,13 @@ add_to_objfile_sections (abfd, asect, objfile_p_char)
flagword aflag;
aflag = bfd_get_section_flags (abfd, asect);
-
- if (!(aflag & SEC_ALLOC) && !(TARGET_KEEP_SECTION(asect)))
+ if (!(aflag & SEC_ALLOC))
return;
-
if (0 == bfd_section_size (abfd, asect))
return;
section.offset = 0;
section.objfile = objfile;
section.the_bfd_section = asect;
- section.ovly_mapped = 0;
section.addr = bfd_section_vma (abfd, asect);
section.endaddr = section.addr + bfd_section_size (abfd, asect);
obstack_grow (&objfile->psymbol_obstack, (char *) &section, sizeof(section));
@@ -123,29 +113,19 @@ build_objfile_section_table (objfile)
/* Given a pointer to an initialized bfd (ABFD) and a flag that indicates
whether or not an objfile is to be mapped (MAPPED), allocate a new objfile
struct, fill it in as best we can, link it into the list of all known
- objfiles, and return a pointer to the new objfile struct.
-
- USER_LOADED is simply recorded in the objfile. This record offers a way for
- run_command to remove old objfile entries which are no longer valid (i.e.,
- are associated with an old inferior), but to preserve ones that the user
- explicitly loaded via the add-symbol-file command.
-
- IS_SOLIB is also simply recorded in the objfile. */
+ objfiles, and return a pointer to the new objfile struct. */
struct objfile *
-allocate_objfile (abfd, mapped, user_loaded, is_solib)
+allocate_objfile (abfd, mapped)
bfd *abfd;
int mapped;
- int user_loaded;
- int is_solib;
{
struct objfile *objfile = NULL;
struct objfile *last_one = NULL;
mapped |= mapped_symbol_files;
-#if defined(USE_MMALLOC) && defined(HAVE_MMAP)
- if (abfd != NULL)
+#if !defined(NO_MMALLOC) && defined(HAVE_MMAP)
{
/* If we can support mapped symbol files, try to open/reopen the
@@ -164,9 +144,11 @@ allocate_objfile (abfd, mapped, user_loaded, is_solib)
mapped);
if (fd >= 0)
{
+ CORE_ADDR mapto;
PTR md;
- if ((md = map_to_file (fd)) == NULL)
+ if (((mapto = map_to_address ()) == 0) ||
+ ((md = mmalloc_attach (fd, (PTR) mapto)) == NULL))
{
close (fd);
}
@@ -227,7 +209,7 @@ allocate_objfile (abfd, mapped, user_loaded, is_solib)
bfd_get_filename (abfd));
}
}
-#else /* !defined(USE_MMALLOC) || !defined(HAVE_MMAP) */
+#else /* defined(NO_MMALLOC) || !defined(HAVE_MMAP) */
if (mapped)
{
@@ -240,7 +222,7 @@ allocate_objfile (abfd, mapped, user_loaded, is_solib)
mapped_symbol_files = 0;
}
-#endif /* defined(USE_MMALLOC) && defined(HAVE_MMAP) */
+#endif /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */
/* If we don't support mapped symbol files, didn't ask for the file to be
mapped, or failed to open the mapped file for some reason, then revert
@@ -270,18 +252,15 @@ allocate_objfile (abfd, mapped, user_loaded, is_solib)
{
mfree (objfile -> md, objfile -> name);
}
- if (abfd != NULL)
- {
- objfile -> name = mstrsave (objfile -> md, bfd_get_filename (abfd));
- objfile -> mtime = bfd_get_mtime (abfd);
+ objfile -> name = mstrsave (objfile -> md, bfd_get_filename (abfd));
+ objfile -> mtime = bfd_get_mtime (abfd);
- /* Build section table. */
+ /* Build section table. */
- if (build_objfile_section_table (objfile))
- {
- error ("Can't find the file sections in `%s': %s",
- objfile -> name, bfd_errmsg (bfd_get_error ()));
- }
+ if (build_objfile_section_table (objfile))
+ {
+ error ("Can't find the file sections in `%s': %s",
+ objfile -> name, bfd_errmsg (bfd_get_error ()));
}
/* Add this file onto the tail of the linked list of other such files. */
@@ -296,15 +275,6 @@ allocate_objfile (abfd, mapped, user_loaded, is_solib)
last_one = last_one -> next);
last_one -> next = objfile;
}
-
- /* Record whether this objfile was created because the user explicitly
- caused it (e.g., used the add-symbol-file command).
- */
- objfile -> user_loaded = user_loaded;
-
- /* Record whether this objfile definitely represents a solib. */
- objfile -> is_solib = is_solib;
-
return (objfile);
}
@@ -440,7 +410,7 @@ free_objfile (objfile)
case. Note that the mmalloc_detach or the mfree is the last thing
we can do with this objfile. */
-#if defined(USE_MMALLOC) && defined(HAVE_MMAP)
+#if !defined(NO_MMALLOC) && defined(HAVE_MMAP)
if (objfile -> flags & OBJF_MAPPED)
{
@@ -454,7 +424,7 @@ free_objfile (objfile)
close (mmfd);
}
-#endif /* defined(USE_MMALLOC) && defined(HAVE_MMAP) */
+#endif /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */
/* If we still have an objfile, then either we don't support reusable
objfiles or this one was not reusable. So free it normally. */
@@ -501,9 +471,9 @@ objfile_relocate (objfile, new_offsets)
struct objfile *objfile;
struct section_offsets *new_offsets;
{
- struct section_offsets *delta = (struct section_offsets *)
- alloca (sizeof (struct section_offsets)
- + objfile->num_sections * sizeof (delta->offsets));
+ struct section_offsets *delta = (struct section_offsets *) alloca
+ (sizeof (struct section_offsets)
+ + objfile->num_sections * sizeof (delta->offsets));
{
int i;
@@ -549,7 +519,7 @@ objfile_relocate (objfile, new_offsets)
b = BLOCKVECTOR_BLOCK (bv, i);
BLOCK_START (b) += ANOFFSET (delta, s->block_line_section);
- BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
+ BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
for (j = 0; j < BLOCK_NSYMS (b); ++j)
{
@@ -559,11 +529,10 @@ objfile_relocate (objfile, new_offsets)
But I'm leaving out that test, on the theory that
they can't possibly pass the tests below. */
if ((SYMBOL_CLASS (sym) == LOC_LABEL
- || SYMBOL_CLASS (sym) == LOC_STATIC
- || SYMBOL_CLASS (sym) == LOC_INDIRECT)
+ || SYMBOL_CLASS (sym) == LOC_STATIC)
&& SYMBOL_SECTION (sym) >= 0)
{
- SYMBOL_VALUE_ADDRESS (sym) +=
+ SYMBOL_VALUE_ADDRESS (sym) +=
ANOFFSET (delta, SYMBOL_SECTION (sym));
}
#ifdef MIPS_EFI_SYMBOL_NAME
@@ -573,8 +542,7 @@ objfile_relocate (objfile, new_offsets)
if (SYMBOL_CLASS (sym) == LOC_CONST
&& SYMBOL_NAMESPACE (sym) == LABEL_NAMESPACE
&& STRCMP (SYMBOL_NAME (sym), MIPS_EFI_SYMBOL_NAME) == 0)
- ecoff_relocate_efi (sym, ANOFFSET (delta,
- s->block_line_section));
+ ecoff_relocate_efi (sym, ANOFFSET (delta, s->block_line_section));
#endif
}
}
@@ -598,14 +566,12 @@ objfile_relocate (objfile, new_offsets)
psym < objfile->global_psymbols.next;
psym++)
if (SYMBOL_SECTION (*psym) >= 0)
- SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
- SYMBOL_SECTION (*psym));
+ SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta, SYMBOL_SECTION (*psym));
for (psym = objfile->static_psymbols.list;
psym < objfile->static_psymbols.next;
psym++)
if (SYMBOL_SECTION (*psym) >= 0)
- SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta,
- SYMBOL_SECTION (*psym));
+ SYMBOL_VALUE_ADDRESS (*psym) += ANOFFSET (delta, SYMBOL_SECTION (*psym));
}
{
@@ -639,45 +605,42 @@ objfile_relocate (objfile, new_offsets)
if (flags & SEC_CODE)
{
- s->addr += ANOFFSET (delta, SECT_OFF_TEXT);
+ s->addr += ANOFFSET (delta, SECT_OFF_TEXT);
s->endaddr += ANOFFSET (delta, SECT_OFF_TEXT);
}
else if (flags & (SEC_DATA | SEC_LOAD))
{
- s->addr += ANOFFSET (delta, SECT_OFF_DATA);
+ s->addr += ANOFFSET (delta, SECT_OFF_DATA);
s->endaddr += ANOFFSET (delta, SECT_OFF_DATA);
}
else if (flags & SEC_ALLOC)
{
- s->addr += ANOFFSET (delta, SECT_OFF_BSS);
+ s->addr += ANOFFSET (delta, SECT_OFF_BSS);
s->endaddr += ANOFFSET (delta, SECT_OFF_BSS);
}
}
}
- if (objfile->ei.entry_point != ~(CORE_ADDR)0)
+ if (objfile->ei.entry_point != ~0)
objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT);
if (objfile->ei.entry_func_lowpc != INVALID_ENTRY_LOWPC)
{
- objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
+ objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
objfile->ei.entry_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
}
if (objfile->ei.entry_file_lowpc != INVALID_ENTRY_LOWPC)
{
- objfile->ei.entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
+ objfile->ei.entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
objfile->ei.entry_file_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
}
if (objfile->ei.main_func_lowpc != INVALID_ENTRY_LOWPC)
{
- objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
+ objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT);
objfile->ei.main_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT);
}
-
- /* Relocate breakpoints as necessary, after things are relocated. */
- breakpoint_re_set ();
}
/* Many places in gdb want to test just to see if we have any partial
@@ -718,28 +681,6 @@ have_full_symbols ()
return 0;
}
-
-/* This operations deletes all objfile entries that represent solibs that
- weren't explicitly loaded by the user, via e.g., the add-symbol-file
- command.
- */
-void
-objfile_purge_solibs ()
-{
- struct objfile * objf;
- struct objfile * temp;
-
- ALL_OBJFILES_SAFE (objf, temp)
- {
- /* We assume that the solib package has been purged already, or will
- be soon.
- */
- if (! objf->user_loaded && objf->is_solib)
- free_objfile (objf);
- }
-}
-
-
/* Many places in gdb want to test just to see if we have any minimal
symbols available. This function returns zero if none are currently
available, nonzero otherwise. */
@@ -759,7 +700,7 @@ have_minimal_symbols ()
return 0;
}
-#if defined(USE_MMALLOC) && defined(HAVE_MMAP)
+#if !defined(NO_MMALLOC) && defined(HAVE_MMAP)
/* Given the name of a mapped symbol file in SYMSFILENAME, and the timestamp
of the corresponding symbol file in MTIME, try to open an existing file
@@ -883,90 +824,72 @@ open_mapped_file (filename, mtime, mapped)
return (fd);
}
-static PTR
-map_to_file (fd)
- int fd;
+/* Return the base address at which we would like the next objfile's
+ mapped data to start.
+
+ For now, we use the kludge that the configuration specifies a base
+ address to which it is safe to map the first mmalloc heap, and an
+ increment to add to this address for each successive heap. There are
+ a lot of issues to deal with here to make this work reasonably, including:
+
+ Avoid memory collisions with existing mapped address spaces
+
+ Reclaim address spaces when their mmalloc heaps are unmapped
+
+ When mmalloc heaps are shared between processes they have to be
+ mapped at the same addresses in each
+
+ Once created, a mmalloc heap that is to be mapped back in must be
+ mapped at the original address. I.E. each objfile will expect to
+ be remapped at it's original address. This becomes a problem if
+ the desired address is already in use.
+
+ etc, etc, etc.
+
+ */
+
+
+static CORE_ADDR
+map_to_address ()
{
- PTR md;
- CORE_ADDR mapto;
- md = mmalloc_attach (fd, (PTR) 0);
- if (md != NULL)
- {
- mapto = (CORE_ADDR) mmalloc_getkey (md, 1);
- md = mmalloc_detach (md);
- if (md != NULL)
- {
- /* FIXME: should figure out why detach failed */
- md = NULL;
- }
- else if (mapto != (CORE_ADDR) NULL)
- {
- /* This mapping file needs to be remapped at "mapto" */
- md = mmalloc_attach (fd, (PTR) mapto);
- }
- else
- {
- /* This is a freshly created mapping file. */
- mapto = (CORE_ADDR) mmalloc_findbase (20 * 1024 * 1024);
- if (mapto != 0)
- {
- /* To avoid reusing the freshly created mapping file, at the
- address selected by mmap, we must truncate it before trying
- to do an attach at the address we want. */
- ftruncate (fd, 0);
- md = mmalloc_attach (fd, (PTR) mapto);
- if (md != NULL)
- {
- mmalloc_setkey (md, 1, (PTR) mapto);
- }
- }
- }
- }
- return (md);
+#if defined(MMAP_BASE_ADDRESS) && defined (MMAP_INCREMENT)
+
+ static CORE_ADDR next = MMAP_BASE_ADDRESS;
+ CORE_ADDR mapto = next;
+
+ next += MMAP_INCREMENT;
+ return (mapto);
+
+#else
+
+ warning ("need to recompile gdb with MMAP_BASE_ADDRESS and MMAP_INCREMENT defined");
+ return (0);
+
+#endif
+
}
-#endif /* defined(USE_MMALLOC) && defined(HAVE_MMAP) */
+#endif /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */
-/* Returns a section whose range includes PC and SECTION,
- or NULL if none found. Note the distinction between the return type,
- struct obj_section (which is defined in gdb), and the input type
- struct sec (which is a bfd-defined data type). The obj_section
- contains a pointer to the bfd struct sec section. */
+/* Returns a section whose range includes PC or NULL if none found. */
struct obj_section *
-find_pc_sect_section (pc, section)
+find_pc_section(pc)
CORE_ADDR pc;
- struct sec *section;
{
struct obj_section *s;
struct objfile *objfile;
ALL_OBJFILES (objfile)
for (s = objfile->sections; s < objfile->sections_end; ++s)
-#if defined(HPUXHPPA)
- if ((section == 0 || section == s->the_bfd_section) &&
- s->addr <= pc && pc <= s->endaddr)
-#else
- if ((section == 0 || section == s->the_bfd_section) &&
- s->addr <= pc && pc < s->endaddr)
-#endif
+ if (s->addr <= pc
+ && pc < s->endaddr)
return(s);
return(NULL);
}
-/* Returns a section whose range includes PC or NULL if none found.
- Backward compatibility, no section. */
-
-struct obj_section *
-find_pc_section(pc)
- CORE_ADDR pc;
-{
- return find_pc_sect_section (pc, find_pc_mapped_section (pc));
-}
-
-
/* In SVR4, we recognize a trampoline by it's section name.
That is, if the pc is in a section named ".plt" then we are in
a trampoline. */
diff --git a/contrib/gdb/gdb/op50-rom.c b/contrib/gdb/gdb/op50-rom.c
deleted file mode 100644
index 3262091..0000000
--- a/contrib/gdb/gdb/op50-rom.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* Remote target glue for the Oki op50n based eval board.
-
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "monitor.h"
-#include "serial.h"
-
-static void op50n_open PARAMS ((char *args, int from_tty));
-
-/*
- * this array of registers need to match the indexes used by GDB. The
- * whole reason this exists is cause the various ROM monitors use
- * different strings than GDB does, and doesn't support all the
- * registers either. So, typing "info reg sp" becomes a "r30".
- */
-
-static char *op50n_regnames[NUM_REGS] =
-{
- "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",
- "cr11", "p", NULL, NULL, NULL, "cr15", "cr19", "cr20",
- "cr21", "cr22", NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, "cr0", "cr8", "cr9", "cr10","cr12",
- "cr13", "cr24", "cr25", "cr26",
-};
-
-/*
- * Define the monitor command strings. Since these are passed directly
- * through to a printf style function, we need can include formatting
- * strings. We also need a CR or LF on the end.
- */
-
-static struct target_ops op50n_ops;
-
-static char *op50n_inits[] = {".\r", NULL};
-
-static struct monitor_ops op50n_cmds ;
-
-static void
-init_op50n_cmds(void)
-{
- op50n_cmds.flags = MO_CLR_BREAK_USES_ADDR /*| MO_GETMEM_READ_SINGLE*/; /* flags */
- op50n_cmds.init = op50n_inits; /* Init strings */
- op50n_cmds.cont = "g\r"; /* continue command */
- op50n_cmds.step = "t\r"; /* single step */
- op50n_cmds.stop = "\003.\r"; /* Interrupt char */
- op50n_cmds.set_break = "b %x\r"; /* set a breakpoint */
- op50n_cmds.clr_break = "b %x;0\r"; /* clear breakpoint at addr */
- op50n_cmds.clr_all_break = "bx\r"; /* clear all breakpoints */
- op50n_cmds.fill = "fx %x s%x %x\r"; /* memory fill cmd (addr, len, val) */
- op50n_cmds.setmem.cmdb = "sx %x %x\r"; /* setmem.cmdb (addr, value) */
- op50n_cmds.setmem.cmdw = "sh %x %x\r"; /* setmem.cmdw (addr, value) */
- op50n_cmds.setmem.cmdl = "s %x %x\r"; /* setmem.cmdl (addr, value) */
- op50n_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
- op50n_cmds.setmem.resp_delim = NULL; /* setmem.resp_delim */
- op50n_cmds.setmem.term = NULL; /* setmem.term */
- op50n_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */
-#if 0
- {
- "sx %x\r", /* getmem.cmdb (addr, len) */
- "sh %x\r", /* getmem.cmdw (addr, len) */
- "s %x\r", /* getmem.cmdl (addr, len) */
- NULL, /* getmem.cmdll (addr, len) */
- " : ", /* getmem.resp_delim */
- " ", /* getmem.term */
- ".\r", /* getmem.term_cmd */
- } ;
-#else
- op50n_cmds.getmem.cmdb = "dx %x s%x\r"; /* getmem.cmdb (addr, len) */
- op50n_cmds.getmem.cmdw = NULL; /* getmem.cmdw (addr, len) */
- op50n_cmds.getmem.cmdl = NULL; /* getmem.cmdl (addr, len) */
- op50n_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */
- op50n_cmds.getmem.resp_delim = " : "; /* getmem.resp_delim */
- op50n_cmds.getmem.term = NULL; /* getmem.term */
- op50n_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
-#endif
- op50n_cmds.setreg.cmd = "x %s %x\r"; /* setreg.cmd (name, value) */
- op50n_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */
- op50n_cmds.setreg.term = NULL; /* setreg.term */
- op50n_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
- op50n_cmds.getreg.cmd = "x %s\r"; /* getreg.cmd (name) */
- op50n_cmds.getreg.resp_delim = "="; /* getreg.resp_delim */
- op50n_cmds.getreg.term = " "; /* getreg.term */
- op50n_cmds.getreg.term_cmd = ".\r"; /* getreg.term_cmd */
- op50n_cmds.dump_registers = NULL; /* dump_registers */
- op50n_cmds.register_pattern = NULL; /* register_pattern */
- op50n_cmds.supply_register = NULL; /* supply_register */
- op50n_cmds.load_routine = NULL; /* load routine */
- op50n_cmds.load = "r 0\r"; /* download command */
- op50n_cmds.loadresp = NULL; /* load response */
- op50n_cmds.prompt = "\n#"; /* monitor command prompt */
- op50n_cmds.line_term = "\r"; /* end-of-command delimitor */
- op50n_cmds.cmd_end = NULL; /* optional command terminator */
- op50n_cmds.target = &op50n_ops; /* target operations */
- op50n_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- op50n_cmds.regnames = op50n_regnames; /* register names */
- op50n_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
-};
-
-static void
-op50n_open (args, from_tty)
- char *args;
- int from_tty;
-{
- monitor_open (args, &op50n_cmds, from_tty);
-}
-
-void
-_initialize_op50n ()
-{
- init_op50n_cmds() ;
- init_monitor_ops (&op50n_ops);
-
- op50n_ops.to_shortname = "op50n";
- op50n_ops.to_longname = "Oki's debug monitor for the Op50n Eval board";
- op50n_ops.to_doc = "Debug on a Oki OP50N eval board.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
- op50n_ops.to_open = op50n_open;
-
- add_target (&op50n_ops);
-}
diff --git a/contrib/gdb/gdb/osfsolib.c b/contrib/gdb/gdb/osfsolib.c
deleted file mode 100644
index 31c9bf9..0000000
--- a/contrib/gdb/gdb/osfsolib.c
+++ /dev/null
@@ -1,980 +0,0 @@
-/* Handle OSF/1 shared libraries for GDB, the GNU Debugger.
- Copyright 1993, 94, 95, 96, 98, 1999 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* FIXME: Most of this code could be merged with solib.c by using
- next_link_map_member and xfer_link_map_member in solib.c. */
-
-#include "defs.h"
-
-#include <sys/types.h>
-#include <signal.h>
-#include "gdb_string.h"
-#include <fcntl.h>
-
-#include "symtab.h"
-#include "bfd.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "gdbcore.h"
-#include "command.h"
-#include "target.h"
-#include "frame.h"
-#include "gnu-regex.h"
-#include "inferior.h"
-#include "language.h"
-#include "gdbcmd.h"
-
-#define MAX_PATH_SIZE 1024 /* FIXME: Should be dynamic */
-
-/* When handling shared libraries, GDB has to find out the pathnames
- of all shared libraries that are currently loaded (to read in their
- symbols) and where the shared libraries are loaded in memory
- (to relocate them properly from their prelinked addresses to the
- current load address).
-
- Under OSF/1 there are two possibilities to get at this information:
- 1) Peek around in the runtime loader structures.
- These are not documented, and they are not defined in the system
- header files. The definitions below were obtained by experimentation,
- but they seem stable enough.
- 2) Use the undocumented libxproc.a library, which contains the
- equivalent ldr_* routines.
- This approach is somewhat cleaner, but it requires that the GDB
- executable is dynamically linked. In addition it requires a
- NAT_CLIBS= -lxproc -Wl,-expect_unresolved,ldr_process_context
- linker specification for GDB and all applications that are using
- libgdb.
- We will use the peeking approach until it becomes unwieldy. */
-
-#ifndef USE_LDR_ROUTINES
-
-/* Definition of runtime loader structures, found by experimentation. */
-#define RLD_CONTEXT_ADDRESS 0x3ffc0000000
-
-typedef struct
-{
- CORE_ADDR next;
- CORE_ADDR previous;
- CORE_ADDR unknown1;
- char *module_name;
- CORE_ADDR modinfo_addr;
- long module_id;
- CORE_ADDR unknown2;
- CORE_ADDR unknown3;
- long region_count;
- CORE_ADDR regioninfo_addr;
-} ldr_module_info_t;
-
-typedef struct
-{
- long unknown1;
- CORE_ADDR regionname_addr;
- long protection;
- CORE_ADDR vaddr;
- CORE_ADDR mapaddr;
- long size;
- long unknown2[5];
-} ldr_region_info_t;
-
-typedef struct
-{
- CORE_ADDR unknown1;
- CORE_ADDR unknown2;
- CORE_ADDR head;
- CORE_ADDR tail;
-} ldr_context_t;
-
-static ldr_context_t ldr_context;
-
-#else
-
-#include <loader.h>
-static ldr_process_t fake_ldr_process;
-
-/* Called by ldr_* routines to read memory from the current target. */
-
-static int ldr_read_memory PARAMS ((CORE_ADDR, char *, int, int));
-
-static int
-ldr_read_memory (memaddr, myaddr, len, readstring)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int readstring;
-{
- int result;
- char *buffer;
-
- if (readstring)
- {
- target_read_string (memaddr, &buffer, len, &result);
- if (result == 0)
- strcpy (myaddr, buffer);
- free (buffer);
- }
- else
- result = target_read_memory (memaddr, myaddr, len);
-
- if (result != 0)
- result = -result;
- return result;
-}
-
-#endif
-
-/* Define our own link_map structure.
- This will help to share code with solib.c. */
-
-struct link_map {
- CORE_ADDR l_offset; /* prelink to load address offset */
- char *l_name; /* full name of loaded object */
- ldr_module_info_t module_info; /* corresponding module info */
-};
-
-#define LM_OFFSET(so) ((so) -> lm.l_offset)
-#define LM_NAME(so) ((so) -> lm.l_name)
-
-struct so_list {
- struct so_list *next; /* next structure in linked list */
- struct link_map lm; /* copy of link map from inferior */
- struct link_map *lmaddr; /* addr in inferior lm was read from */
- CORE_ADDR lmend; /* upper addr bound of mapped object */
- char so_name[MAX_PATH_SIZE]; /* shared object lib name (FIXME) */
- char symbols_loaded; /* flag: symbols read in yet? */
- char from_tty; /* flag: print msgs? */
- struct objfile *objfile; /* objfile for loaded lib */
- struct section_table *sections;
- struct section_table *sections_end;
- struct section_table *textsection;
- bfd *abfd;
-};
-
-static struct so_list *so_list_head; /* List of known shared objects */
-
-extern int
-fdmatch PARAMS ((int, int)); /* In libiberty */
-
-/* Local function prototypes */
-
-static void
-sharedlibrary_command PARAMS ((char *, int));
-
-static void
-info_sharedlibrary_command PARAMS ((char *, int));
-
-static int
-symbol_add_stub PARAMS ((char *));
-
-static struct so_list *
-find_solib PARAMS ((struct so_list *));
-
-static struct link_map *
-first_link_map_member PARAMS ((void));
-
-static struct link_map *
-next_link_map_member PARAMS ((struct so_list *));
-
-static void
-xfer_link_map_member PARAMS ((struct so_list *, struct link_map *));
-
-static int
-solib_map_sections PARAMS ((char *));
-
-/*
-
-LOCAL FUNCTION
-
- solib_map_sections -- open bfd and build sections for shared lib
-
-SYNOPSIS
-
- static int solib_map_sections (struct so_list *so)
-
-DESCRIPTION
-
- Given a pointer to one of the shared objects in our list
- of mapped objects, use the recorded name to open a bfd
- descriptor for the object, build a section table, and then
- relocate all the section addresses by the base address at
- which the shared object was mapped.
-
-FIXMES
-
- In most (all?) cases the shared object file name recorded in the
- dynamic linkage tables will be a fully qualified pathname. For
- cases where it isn't, do we really mimic the systems search
- mechanism correctly in the below code (particularly the tilde
- expansion stuff?).
- */
-
-static int
-solib_map_sections (arg)
- char *arg;
-{
- struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */
- char *filename;
- char *scratch_pathname;
- int scratch_chan;
- struct section_table *p;
- struct cleanup *old_chain;
- bfd *abfd;
-
- filename = tilde_expand (so -> so_name);
- old_chain = 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);
- }
- /* Leave scratch_pathname allocated. bfd->name will point to it. */
-
- abfd = bfd_fdopenr (scratch_pathname, gnutarget, scratch_chan);
- if (!abfd)
- {
- close (scratch_chan);
- error ("Could not open `%s' as an executable file: %s",
- scratch_pathname, bfd_errmsg (bfd_get_error ()));
- }
- /* Leave bfd open, core_xfer_memory and "info files" need it. */
- so -> abfd = abfd;
- abfd -> cacheable = true;
-
- if (!bfd_check_format (abfd, bfd_object))
- {
- error ("\"%s\": not in executable format: %s.",
- scratch_pathname, bfd_errmsg (bfd_get_error ()));
- }
- if (build_section_table (abfd, &so -> sections, &so -> sections_end))
- {
- error ("Can't find the file sections in `%s': %s",
- bfd_get_filename (exec_bfd), bfd_errmsg (bfd_get_error ()));
- }
-
- for (p = so -> sections; p < so -> sections_end; p++)
- {
- /* Relocate the section binding addresses as recorded in the shared
- object's file by the offset to get the address to which the
- object was actually mapped. */
- p -> addr += LM_OFFSET (so);
- p -> endaddr += LM_OFFSET (so);
- so -> lmend = (CORE_ADDR) max (p -> endaddr, so -> lmend);
- if (STREQ (p -> the_bfd_section -> name, ".text"))
- {
- so -> textsection = p;
- }
- }
-
- /* Free the file names, close the file now. */
- do_cleanups (old_chain);
-
- return (1);
-}
-
-/*
-
-LOCAL FUNCTION
-
- first_link_map_member -- locate first member in dynamic linker's map
-
-SYNOPSIS
-
- static struct link_map *first_link_map_member (void)
-
-DESCRIPTION
-
- Read in a copy of the first member in the inferior's dynamic
- link map from the inferior's dynamic linker structures, and return
- a pointer to the copy in our address space.
-*/
-
-static struct link_map *
-first_link_map_member ()
-{
- struct link_map *lm = NULL;
- static struct link_map first_lm;
-
-#ifdef USE_LDR_ROUTINES
- ldr_module_t mod_id = LDR_NULL_MODULE;
- size_t retsize;
-
- fake_ldr_process = ldr_core_process ();
- ldr_set_core_reader (ldr_read_memory);
- ldr_xdetach (fake_ldr_process);
- if (ldr_xattach (fake_ldr_process) != 0
- || ldr_next_module(fake_ldr_process, &mod_id) != 0
- || mod_id == LDR_NULL_MODULE
- || ldr_inq_module(fake_ldr_process, mod_id,
- &first_lm.module_info, sizeof(ldr_module_info_t),
- &retsize) != 0)
- return lm;
-#else
- CORE_ADDR ldr_context_addr;
-
- if (target_read_memory ((CORE_ADDR) RLD_CONTEXT_ADDRESS,
- (char *) &ldr_context_addr,
- sizeof (CORE_ADDR)) != 0
- || target_read_memory (ldr_context_addr,
- (char *) &ldr_context,
- sizeof (ldr_context_t)) != 0
- || target_read_memory ((CORE_ADDR) ldr_context.head,
- (char *) &first_lm.module_info,
- sizeof (ldr_module_info_t)) != 0)
- return lm;
-#endif
-
- lm = &first_lm;
-
- /* The first entry is for the main program and should be skipped. */
- lm->l_name = NULL;
-
- return lm;
-}
-
-static struct link_map *
-next_link_map_member (so_list_ptr)
- struct so_list *so_list_ptr;
-{
- struct link_map *lm = NULL;
- static struct link_map next_lm;
-#ifdef USE_LDR_ROUTINES
- ldr_module_t mod_id = so_list_ptr->lm.module_info.lmi_modid;
- size_t retsize;
-
- if (ldr_next_module(fake_ldr_process, &mod_id) != 0
- || mod_id == LDR_NULL_MODULE
- || ldr_inq_module(fake_ldr_process, mod_id,
- &next_lm.module_info, sizeof(ldr_module_info_t),
- &retsize) != 0)
- return lm;
-
- lm = &next_lm;
- lm->l_name = lm->module_info.lmi_name;
-#else
- CORE_ADDR ldr_context_addr;
-
- /* Reread context in case ldr_context.tail was updated. */
-
- if (target_read_memory ((CORE_ADDR) RLD_CONTEXT_ADDRESS,
- (char *) &ldr_context_addr,
- sizeof (CORE_ADDR)) != 0
- || target_read_memory (ldr_context_addr,
- (char *) &ldr_context,
- sizeof (ldr_context_t)) != 0
- || so_list_ptr->lm.module_info.modinfo_addr == ldr_context.tail
- || target_read_memory (so_list_ptr->lm.module_info.next,
- (char *) &next_lm.module_info,
- sizeof (ldr_module_info_t)) != 0)
- return lm;
-
- lm = &next_lm;
- lm->l_name = lm->module_info.module_name;
-#endif
- return lm;
-}
-
-static void
-xfer_link_map_member (so_list_ptr, lm)
- struct so_list *so_list_ptr;
- struct link_map *lm;
-{
- int i;
- so_list_ptr->lm = *lm;
-
- /* OSF/1 shared libraries are pre-linked to particular addresses,
- but the runtime loader may have to relocate them if the
- address ranges of the libraries used by the target executable clash,
- or if the target executable is linked with the -taso option.
- The offset is the difference between the address where the shared
- library is mapped and the pre-linked address of the shared library.
-
- FIXME: GDB is currently unable to relocate the shared library
- sections by different offsets. If sections are relocated by
- different offsets, put out a warning and use the offset of the
- first section for all remaining sections. */
- LM_OFFSET (so_list_ptr) = 0;
-
- /* There is one entry that has no name (for the inferior executable)
- since it is not a shared object. */
- if (LM_NAME (so_list_ptr) != 0)
- {
-
-#ifdef USE_LDR_ROUTINES
- int len = strlen (LM_NAME (so_list_ptr) + 1);
-
- if (len > MAX_PATH_SIZE)
- len = MAX_PATH_SIZE;
- strncpy (so_list_ptr->so_name, LM_NAME (so_list_ptr), MAX_PATH_SIZE);
- so_list_ptr->so_name[MAX_PATH_SIZE - 1] = '\0';
-
- for (i = 0; i < lm->module_info.lmi_nregion; i++)
- {
- ldr_region_info_t region_info;
- size_t retsize;
- CORE_ADDR region_offset;
-
- if (ldr_inq_region (fake_ldr_process, lm->module_info.lmi_modid,
- i, &region_info, sizeof (region_info),
- &retsize) != 0)
- break;
- region_offset = (CORE_ADDR) region_info.lri_mapaddr
- - (CORE_ADDR) region_info.lri_vaddr;
- if (i == 0)
- LM_OFFSET (so_list_ptr) = region_offset;
- else if (LM_OFFSET (so_list_ptr) != region_offset)
- warning ("cannot handle shared library relocation for %s (%s)",
- so_list_ptr->so_name, region_info.lri_name);
- }
-#else
- int errcode;
- char *buffer;
- target_read_string ((CORE_ADDR) LM_NAME (so_list_ptr), &buffer,
- MAX_PATH_SIZE - 1, &errcode);
- if (errcode != 0)
- error ("xfer_link_map_member: Can't read pathname for load map: %s\n",
- safe_strerror (errcode));
- strncpy (so_list_ptr->so_name, buffer, MAX_PATH_SIZE - 1);
- free (buffer);
- so_list_ptr->so_name[MAX_PATH_SIZE - 1] = '\0';
-
- for (i = 0; i < lm->module_info.region_count; i++)
- {
- ldr_region_info_t region_info;
- CORE_ADDR region_offset;
-
- if (target_read_memory (lm->module_info.regioninfo_addr
- + i * sizeof (region_info),
- (char *) &region_info,
- sizeof (region_info)) != 0)
- break;
- region_offset = region_info.mapaddr - region_info.vaddr;
- if (i == 0)
- LM_OFFSET (so_list_ptr) = region_offset;
- else if (LM_OFFSET (so_list_ptr) != region_offset)
- {
- char *region_name;
- target_read_string (region_info.regionname_addr, &buffer,
- MAX_PATH_SIZE - 1, &errcode);
- if (errcode == 0)
- region_name = buffer;
- else
- region_name = "??";
- warning ("cannot handle shared library relocation for %s (%s)",
- so_list_ptr->so_name, region_name);
- free (buffer);
- }
- }
-#endif
-
- catch_errors (solib_map_sections, (char *) so_list_ptr,
- "Error while mapping shared library sections:\n",
- RETURN_MASK_ALL);
- }
-}
-
-/*
-
-LOCAL FUNCTION
-
- find_solib -- step through list of shared objects
-
-SYNOPSIS
-
- struct so_list *find_solib (struct so_list *so_list_ptr)
-
-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 <link.h>.
- */
-
-static struct so_list *
-find_solib (so_list_ptr)
- struct so_list *so_list_ptr; /* Last lm or NULL for first one */
-{
- struct so_list *so_list_next = NULL;
- struct link_map *lm = NULL;
- struct so_list *new;
-
- if (so_list_ptr == NULL)
- {
- /* We are setting up for a new scan through the loaded images. */
- if ((so_list_next = so_list_head) == NULL)
- {
- /* Find the first link map list member. */
- lm = first_link_map_member ();
- }
- }
- else
- {
- /* We have been called before, and are in the process of walking
- the shared library list. Advance to the next shared object. */
- lm = next_link_map_member (so_list_ptr);
- so_list_next = so_list_ptr -> next;
- }
- if ((so_list_next == NULL) && (lm != NULL))
- {
- /* Get next link map structure from inferior image and build a local
- abbreviated load_map structure */
- new = (struct so_list *) xmalloc (sizeof (struct so_list));
- memset ((char *) new, 0, sizeof (struct so_list));
- new -> lmaddr = lm;
- /* Add the new node as the next node in the list, or as the root
- node if this is the first one. */
- if (so_list_ptr != NULL)
- {
- so_list_ptr -> next = new;
- }
- else
- {
- so_list_head = new;
- }
- so_list_next = new;
- xfer_link_map_member (new, lm);
- }
- 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 */
- CORE_ADDR text_addr = 0;
-
- if (so -> textsection)
- text_addr = so -> textsection -> addr;
- else if (so -> abfd != NULL)
- {
- asection *lowest_sect;
-
- /* If we didn't find a mapped non zero sized .text section, set up
- text_addr so that the relocation in symbol_file_add does no harm. */
-
- lowest_sect = bfd_get_section_by_name (so -> abfd, ".text");
- if (lowest_sect == NULL)
- bfd_map_over_sections (so -> abfd, find_lowest_section,
- (PTR) &lowest_sect);
- if (lowest_sect)
- text_addr = bfd_section_vma (so -> abfd, lowest_sect) + LM_OFFSET (so);
- }
-
- so -> objfile = symbol_file_add (so -> so_name, so -> from_tty,
- text_addr,
- 0, 0, 0, 0, 1);
- return (1);
-}
-
-/*
-
-GLOBAL FUNCTION
-
- solib_add -- add a shared library file to the symtab and section list
-
-SYNOPSIS
-
- void solib_add (char *arg_string, int from_tty,
- struct target_ops *target)
-
-DESCRIPTION
-
-*/
-
-void
-solib_add (arg_string, from_tty, target)
- char *arg_string;
- int from_tty;
- struct target_ops *target;
-{
- register struct so_list *so = NULL; /* link map state variable */
-
- /* Last shared library that we read. */
- struct so_list *so_last = NULL;
-
- char *re_err;
- int count;
- int old;
-
- if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
- {
- error ("Invalid regexp: %s", re_err);
- }
-
-
- /* 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 = NULL;
- count = 0;
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- count += so -> sections_end - so -> sections;
- }
- }
-
- if (count)
- {
- int update_coreops;
-
- /* We must update the to_sections field in the core_ops structure
- here, otherwise we dereference a potential dangling pointer
- for each call to target_read/write_memory within this routine. */
- update_coreops = core_ops.to_sections == target->to_sections;
-
- /* Reallocate the target's section table including the new size. */
- if (target -> to_sections)
- {
- old = target -> to_sections_end - target -> to_sections;
- target -> to_sections = (struct section_table *)
- xrealloc ((char *)target -> to_sections,
- (sizeof (struct section_table)) * (count + old));
- }
- else
- {
- old = 0;
- target -> to_sections = (struct section_table *)
- xmalloc ((sizeof (struct section_table)) * count);
- }
- target -> to_sections_end = target -> to_sections + (count + old);
-
- /* Update the to_sections field in the core_ops structure
- if needed. */
- if (update_coreops)
- {
- core_ops.to_sections = target->to_sections;
- core_ops.to_sections_end = target->to_sections_end;
- }
-
- /* Add these section table entries to the target's table. */
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- count = so -> sections_end - so -> sections;
- memcpy ((char *) (target -> to_sections + old),
- so -> sections,
- (sizeof (struct section_table)) * count);
- old += count;
- }
- }
- }
- }
-
- /* Now add the symbol files. */
- so = NULL;
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0] && re_exec (so -> so_name))
- {
- so -> from_tty = from_tty;
- if (so -> symbols_loaded)
- {
- if (from_tty)
- {
- printf_unfiltered ("Symbols already loaded for %s\n", so -> so_name);
- }
- }
- else if (catch_errors
- (symbol_add_stub, (char *) so,
- "Error while reading shared library symbols:\n",
- RETURN_MASK_ALL))
- {
- so_last = so;
- so -> symbols_loaded = 1;
- }
- }
- }
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- if (so_last)
- reinit_frame_cache ();
-}
-
-/*
-
-LOCAL FUNCTION
-
- info_sharedlibrary_command -- code for "info sharedlibrary"
-
-SYNOPSIS
-
- static void info_sharedlibrary_command ()
-
-DESCRIPTION
-
- Walk through the shared library list and print information
- about each attached library.
-*/
-
-static void
-info_sharedlibrary_command (ignore, from_tty)
- char *ignore;
- int from_tty;
-{
- register struct so_list *so = NULL; /* link map state variable */
- int header_done = 0;
-
- if (exec_bfd == NULL)
- {
- printf_unfiltered ("No exec file.\n");
- return;
- }
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0])
- {
- unsigned long txt_start = 0;
- unsigned long txt_end = 0;
-
- if (!header_done)
- {
- printf_unfiltered("%-20s%-20s%-12s%s\n", "From", "To", "Syms Read",
- "Shared Object Library");
- header_done++;
- }
- if (so -> textsection)
- {
- txt_start = (unsigned long) so -> textsection -> addr;
- txt_end = (unsigned long) so -> textsection -> endaddr;
- }
- printf_unfiltered ("%-20s", local_hex_string_custom (txt_start, "08l"));
- printf_unfiltered ("%-20s", local_hex_string_custom (txt_end, "08l"));
- printf_unfiltered ("%-12s", so -> symbols_loaded ? "Yes" : "No");
- printf_unfiltered ("%s\n", so -> so_name);
- }
- }
- if (so_list_head == NULL)
- {
- printf_unfiltered ("No shared libraries loaded at this time.\n");
- }
-}
-
-/*
-
-GLOBAL FUNCTION
-
- solib_address -- check to see if an address is in a shared lib
-
-SYNOPSIS
-
- char *solib_address (CORE_ADDR address)
-
-DESCRIPTION
-
- Provides a hook for other gdb routines to discover whether or
- not a particular address is within the mapped address space of
- a shared library. Any address between the base mapping address
- and the first address beyond the end of the last mapping, is
- considered to be within the shared library address space, for
- our purposes.
-
- For example, this routine is called at one point to disable
- breakpoints which are in shared libraries that are not currently
- mapped in.
- */
-
-char *
-solib_address (address)
- CORE_ADDR address;
-{
- register struct so_list *so = 0; /* link map state variable */
-
- while ((so = find_solib (so)) != NULL)
- {
- if (so -> so_name[0] && so -> textsection)
- {
- if ((address >= (CORE_ADDR) so -> textsection -> addr) &&
- (address < (CORE_ADDR) so -> textsection -> endaddr))
- return (so->so_name);
- }
- }
- return (0);
-}
-
-/* Called by free_all_symtabs */
-
-void
-clear_solib()
-{
- struct so_list *next;
- char *bfd_filename;
-
- disable_breakpoints_in_shlibs (1);
-
- while (so_list_head)
- {
- if (so_list_head -> sections)
- {
- free ((PTR)so_list_head -> sections);
- }
- if (so_list_head -> abfd)
- {
- bfd_filename = bfd_get_filename (so_list_head -> abfd);
- if (!bfd_close (so_list_head -> abfd))
- warning ("cannot close \"%s\": %s",
- bfd_filename, bfd_errmsg (bfd_get_error ()));
- }
- else
- /* This happens for the executable on SVR4. */
- bfd_filename = NULL;
-
- next = so_list_head -> next;
- if (bfd_filename)
- free ((PTR)bfd_filename);
- free ((PTR)so_list_head);
- so_list_head = next;
- }
-}
-
-/*
-
-GLOBAL FUNCTION
-
- solib_create_inferior_hook -- shared library startup support
-
-SYNOPSIS
-
- void solib_create_inferior_hook()
-
-DESCRIPTION
-
- When gdb starts up the inferior, it nurses it along (through the
- shell) until it is ready to execute it's first instruction. At this
- point, this function gets called via expansion of the macro
- SOLIB_CREATE_INFERIOR_HOOK.
- For a statically bound executable, this first instruction is the
- one at "_start", or a similar text label. No further processing is
- needed in that case.
- For a dynamically bound executable, this first instruction is somewhere
- in the rld, and the actual user executable is not yet mapped in.
- We continue the inferior again, rld then maps in the actual user
- executable and any needed shared libraries and then sends
- itself a SIGTRAP.
- At that point we discover the names of all shared libraries and
- read their symbols in.
-
-FIXME
-
- This code does not properly handle hitting breakpoints which the
- user might have set in the rld itself. Proper handling would have
- to check if the SIGTRAP happened due to a kill call.
-
- Also, what if child has exit()ed? Must exit loop somehow.
- */
-
-void
-solib_create_inferior_hook()
-{
-
- /* Nothing to do for statically bound executables. */
-
- if (symfile_objfile == NULL
- || symfile_objfile->obfd == NULL
- || ((bfd_get_file_flags (symfile_objfile->obfd) & DYNAMIC) == 0))
- return;
-
- /* Now run the target. It will eventually get a SIGTRAP, at
- which point all of the libraries will have been mapped in and we
- can go groveling around in the rld structures to find
- out what we need to know about them. */
-
- clear_proceed_status ();
- stop_soon_quietly = 1;
- stop_signal = TARGET_SIGNAL_0;
- do
- {
- target_resume (-1, 0, stop_signal);
- wait_for_inferior ();
- }
- while (stop_signal != TARGET_SIGNAL_TRAP);
-
- /* solib_add will call reinit_frame_cache.
- But we are stopped in the runtime loader and we do not have symbols
- for the runtime loader. So heuristic_proc_start will be called
- and will put out an annoying warning.
- Delaying the resetting of stop_soon_quietly until after symbol loading
- suppresses the warning. */
- if (auto_solib_add)
- solib_add ((char *) 0, 0, (struct target_ops *) 0);
- stop_soon_quietly = 0;
-}
-
-
-/*
-
-LOCAL FUNCTION
-
- sharedlibrary_command -- handle command to explicitly add library
-
-SYNOPSIS
-
- static void sharedlibrary_command (char *args, int from_tty)
-
-DESCRIPTION
-
-*/
-
-static void
-sharedlibrary_command (args, from_tty)
-char *args;
-int from_tty;
-{
- dont_repeat ();
- 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", info_sharedlibrary_command,
- "Status of loaded shared object libraries.");
-
- add_show_from_set
- (add_set_cmd ("auto-solib-add", class_support, var_zinteger,
- (char *) &auto_solib_add,
- "Set autoloading of shared library symbols.\n\
-If nonzero, symbols from all shared object libraries will be loaded\n\
-automatically when the inferior begins execution or when the dynamic linker\n\
-informs gdb that a new library has been loaded. Otherwise, symbols\n\
-must be loaded manually, using `sharedlibrary'.",
- &setlist),
- &showlist);
-}
diff --git a/contrib/gdb/gdb/ppcbug-rom.c b/contrib/gdb/gdb/ppcbug-rom.c
deleted file mode 100644
index 9496916..0000000
--- a/contrib/gdb/gdb/ppcbug-rom.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/* Remote debugging interface for PPCbug (PowerPC) Rom monitor
- for GDB, the GNU debugger.
- Copyright 1995 Free Software Foundation, Inc.
-
- Written by Stu Grossman of Cygnus Support
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "monitor.h"
-#include "serial.h"
-
-static void ppcbug_open PARAMS ((char *args, int from_tty));
-
-static void
-ppcbug_supply_register (regname, regnamelen, val, vallen)
- char *regname;
- int regnamelen;
- char *val;
- int vallen;
-{
- int regno = 0, base = 0;
-
- if (regnamelen < 2 || regnamelen > 4)
- return;
-
- switch (regname[0])
- {
- case 'R':
- if (regname[1] < '0' || regname[1] > '9')
- return;
- if (regnamelen == 2)
- regno = regname[1] - '0';
- else if (regnamelen == 3 && regname[2] >= '0' && regname[2] <= '9')
- regno = (regname[1] - '0') * 10 + (regname[2] - '0');
- else
- return;
- break;
- case 'F':
- if (regname[1] != 'R' || regname[2] < '0' || regname[2] > '9')
- return;
- if (regnamelen == 3)
- regno = 32 + regname[2] - '0';
- else if (regnamelen == 4 && regname[3] >= '0' && regname[3] <= '9')
- regno = 32 + (regname[2] - '0') * 10 + (regname[3] - '0');
- else
- return;
- break;
- case 'I':
- if (regnamelen != 2 || regname[1] != 'P')
- return;
- regno = 64;
- break;
- case 'M':
- if (regnamelen != 3 || regname[1] != 'S' || regname[2] != 'R')
- return;
- regno = 65;
- break;
- case 'C':
- if (regnamelen != 2 || regname[1] != 'R')
- return;
- regno = 66;
- break;
- case 'S':
- if (regnamelen != 4 || regname[1] != 'P' || regname[2] != 'R')
- return;
- else if (regname[3] == '8')
- regno = 67;
- else if (regname[3] == '9')
- regno = 68;
- else if (regname[3] == '1')
- regno = 69;
- else if (regname[3] == '0')
- regno = 70;
- else
- return;
- break;
- default:
- return;
- }
-
- monitor_supply_register (regno, val);
-}
-
-/*
- * This array of registers needs to match the indexes used by GDB. The
- * whole reason this exists is because the various ROM monitors use
- * different names than GDB does, and don't support all the
- * registers either. So, typing "info reg sp" becomes an "A7".
- */
-
-static char *ppcbug_regnames[NUM_REGS] =
-{
- "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",
-
- "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7",
- "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
- "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23",
- "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31",
-
-/* pc ps cnd lr cnt xer mq */
- "ip", "msr", "cr", "spr8", "spr9", "spr1", "spr0"
-};
-
-/*
- * Define the monitor command strings. Since these are passed directly
- * through to a printf style function, we need can include formatting
- * strings. We also need a CR or LF on the end.
- */
-
-static struct target_ops ppcbug_ops0;
-static struct target_ops ppcbug_ops1;
-
-static char *ppcbug_inits[] = {"\r", NULL};
-
-static void
-init_ppc_cmds (char * LOAD_CMD,
- struct monitor_ops * OPS,
- struct target_ops * targops)
-{
- OPS->flags = MO_CLR_BREAK_USES_ADDR | MO_HANDLE_NL;
- OPS->init = ppcbug_inits; /* Init strings */
- OPS->cont = "g\r"; /* continue command */
- OPS->step = "t\r"; /* single step */
- OPS->stop = NULL; /* interrupt command */
- OPS->set_break = "br %x\r"; /* set a breakpoint */
- OPS->clr_break = "nobr %x\r"; /* clear a breakpoint */
- OPS->clr_all_break = "nobr\r"; /* clear all breakpoints */
- OPS->fill = "bf %x:%x %x;b\r"; /* fill (start count val) */
- OPS->setmem.cmdb = "ms %x %02x\r"; /* setmem.cmdb (addr, value) */
- OPS->setmem.cmdw = "ms %x %04x\r"; /* setmem.cmdw (addr, value) */
- OPS->setmem.cmdl = "ms %x %08x\r"; /* setmem.cmdl (addr, value) */
- OPS->setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
- OPS->setmem.resp_delim = NULL; /* setreg.resp_delim */
- OPS->setmem.term = NULL; /* setreg.term */
- OPS->setmem.term_cmd = NULL; /* setreg.term_cmd */
- OPS->getmem.cmdb = "md %x:%x;b\r"; /* getmem.cmdb (addr, len) */
- OPS->getmem.cmdw = "md %x:%x;b\r"; /* getmem.cmdw (addr, len) */
- OPS->getmem.cmdl = "md %x:%x;b\r"; /* getmem.cmdl (addr, len) */
- OPS->getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */
- OPS->getmem.resp_delim = " "; /* getmem.resp_delim */
- OPS->getmem.term = NULL; /* getmem.term */
- OPS->getmem.term_cmd = NULL; /* getmem.term_cmd */
- OPS->setreg.cmd = "rs %s %x\r"; /* setreg.cmd (name, value) */
- OPS->setreg.resp_delim = NULL; /* setreg.resp_delim */
- OPS->setreg.term = NULL; /* setreg.term */
- OPS->setreg.term_cmd = NULL ; /* setreg.term_cmd */
- OPS->getreg.cmd = "rs %s\r"; /* getreg.cmd (name) */
- OPS->getreg.resp_delim = "="; /* getreg.resp_delim */
- OPS->getreg.term = NULL; /* getreg.term */
- OPS->getreg.term_cmd = NULL ; /* getreg.term_cmd */
- OPS->register_pattern = "\\(\\w+\\) +=\\([0-9a-fA-F]+\\b\\)"; /* register_pattern */
- OPS->supply_register = ppcbug_supply_register; /* supply_register */
- OPS->dump_registers = "rd\r"; /* dump all registers */
- OPS->load_routine = NULL; /* load_routine (defaults to SRECs) */
- OPS->load = LOAD_CMD; /* download command */
- OPS->loadresp = NULL; /* load response */
- OPS->prompt = "PPC1-Bug>"; /* monitor command prompt */
- OPS->line_term = "\r"; /* end-of-line terminator */
- OPS->cmd_end = NULL; /* optional command terminator */
- OPS->target = targops ; /* target operations */
- OPS->stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- OPS->regnames = ppcbug_regnames; /* registers names */
- OPS->magic = MONITOR_OPS_MAGIC; /* magic */
-}
-
-
-static struct monitor_ops ppcbug_cmds0 ;
-static struct monitor_ops ppcbug_cmds1 ;
-
-static void
-ppcbug_open0(args, from_tty)
- char *args;
- int from_tty;
-{
- monitor_open (args, &ppcbug_cmds0, from_tty);
-}
-
-static void
-ppcbug_open1(args, from_tty)
- char *args;
- int from_tty;
-{
- monitor_open (args, &ppcbug_cmds1, from_tty);
-}
-
-void
-_initialize_ppcbug_rom ()
-{
- init_ppc_cmds("lo 0\r", &ppcbug_cmds0, &ppcbug_ops0) ;
- init_ppc_cmds("lo 1\r", &ppcbug_cmds1, &ppcbug_ops1);
- init_monitor_ops (&ppcbug_ops0);
-
- ppcbug_ops0.to_shortname = "ppcbug";
- ppcbug_ops0.to_longname = "PowerPC PPCBug monitor on port 0";
- ppcbug_ops0.to_doc = "Debug via the PowerPC PPCBug monitor using port 0.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
- ppcbug_ops0.to_open = ppcbug_open0;
-
- add_target (&ppcbug_ops0);
-
- init_monitor_ops (&ppcbug_ops1);
-
- ppcbug_ops1.to_shortname = "ppcbug1";
- ppcbug_ops1.to_longname = "PowerPC PPCBug monitor on port 1";
- ppcbug_ops1.to_doc = "Debug via the PowerPC PPCBug monitor using port 1.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
- ppcbug_ops1.to_open = ppcbug_open1;
-
- add_target (&ppcbug_ops1);
-}
diff --git a/contrib/gdb/gdb/procfs.c b/contrib/gdb/gdb/procfs.c
deleted file mode 100644
index ff20240..0000000
--- a/contrib/gdb/gdb/procfs.c
+++ /dev/null
@@ -1,5764 +0,0 @@
-/* Machine independent support for SVR4 /proc (process file system) for GDB.
- Copyright 1991, 1992-98, 1999 Free Software Foundation, Inc.
- Written by Fred Fish at Cygnus Support. Changes for sysv4.2mp procfs
- compatibility by Geoffrey Noer at Cygnus Solutions.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-/* 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
-separately. 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 "defs.h"
-
-#include <sys/types.h>
-#include <time.h>
-#include <sys/fault.h>
-#include <sys/syscall.h>
-#include <sys/procfs.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "gdb_string.h"
-#include <stropts.h>
-#include <poll.h>
-#include <unistd.h>
-#include "gdb_stat.h"
-
-#include "inferior.h"
-#include "target.h"
-#include "command.h"
-#include "gdbcore.h"
-#include "gdbthread.h"
-
-#if !defined(SYS_lwp_create) && defined(SYS_lwpcreate)
-# define SYS_lwp_create SYS_lwpcreate
-#endif
-
-#if !defined(SYS_lwp_exit) && defined(SYS_lwpexit)
-# define SYS_lwp_exit SYS_lwpexit
-#endif
-
-#if !defined(SYS_lwp_wait) && defined(SYS_lwpwait)
-# define SYS_lwp_wait SYS_lwpwait
-#endif
-
-#if !defined(SYS_lwp_self) && defined(SYS_lwpself)
-# define SYS_lwp_self SYS_lwpself
-#endif
-
-#if !defined(SYS_lwp_info) && defined(SYS_lwpinfo)
-# define SYS_lwp_info SYS_lwpinfo
-#endif
-
-#if !defined(SYS_lwp_private) && defined(SYS_lwpprivate)
-# define SYS_lwp_private SYS_lwpprivate
-#endif
-
-#if !defined(SYS_lwp_kill) && defined(SYS_lwpkill)
-# define SYS_lwp_kill SYS_lwpkill
-#endif
-
-#if !defined(SYS_lwp_suspend) && defined(SYS_lwpsuspend)
-# define SYS_lwp_suspend SYS_lwpsuspend
-#endif
-
-#if !defined(SYS_lwp_continue) && defined(SYS_lwpcontinue)
-# define SYS_lwp_continue SYS_lwpcontinue
-#endif
-
-/* the name of the proc status struct depends on the implementation */
-/* Wrap Light Weight Process member in THE_PR_LWP macro for clearer code */
-#ifndef HAVE_PSTATUS_T
- typedef prstatus_t gdb_prstatus_t;
-#define THE_PR_LWP(a) a
-#else /* HAVE_PSTATUS_T */
- typedef pstatus_t gdb_prstatus_t;
-#define THE_PR_LWP(a) a.pr_lwp
-#if !defined(HAVE_PRRUN_T) && defined(HAVE_MULTIPLE_PROC_FDS)
- /* Fallback definitions - for using configure information directly */
-#ifndef UNIXWARE
-#define UNIXWARE 1
-#endif
-#if !defined(PROCFS_USE_READ_WRITE) && !defined(HAVE_PROCFS_PIOCSET)
-#define PROCFS_USE_READ_WRITE 1
-#endif
-#endif /* !HAVE_PRRUN_T && HAVE_MULTIPLE_PROC_FDS */
-#endif /* HAVE_PSTATUS_T */
-
-#define MAX_SYSCALLS 256 /* Maximum number of syscalls for table */
-
-/* proc name formats may vary depending on the proc implementation */
-#ifdef HAVE_MULTIPLE_PROC_FDS
-# ifndef CTL_PROC_NAME_FMT
-# define CTL_PROC_NAME_FMT "/proc/%d/ctl"
-# define AS_PROC_NAME_FMT "/proc/%d/as"
-# define MAP_PROC_NAME_FMT "/proc/%d/map"
-# define STATUS_PROC_NAME_FMT "/proc/%d/status"
-# endif
-#else /* HAVE_MULTIPLE_PROC_FDS */
-# ifndef CTL_PROC_NAME_FMT
-# define CTL_PROC_NAME_FMT "/proc/%05d"
-# define AS_PROC_NAME_FMT "/proc/%05d"
-# define MAP_PROC_NAME_FMT "/proc/%05d"
-# define STATUS_PROC_NAME_FMT "/proc/%05d"
-# endif
-#endif /* HAVE_MULTIPLE_PROC_FDS */
-
-
-/* These #ifdefs are for sol2.x in particular. sol2.x has
- both a "gregset_t" and a "prgregset_t", which have
- similar uses but different layouts. sol2.x gdb tries to
- use prgregset_t (and prfpregset_t) everywhere. */
-
-#ifdef GDB_GREGSET_TYPE
- typedef GDB_GREGSET_TYPE gdb_gregset_t;
-#else
- typedef gregset_t gdb_gregset_t;
-#endif
-
-#ifdef GDB_FPREGSET_TYPE
- typedef GDB_FPREGSET_TYPE gdb_fpregset_t;
-#else
- typedef fpregset_t gdb_fpregset_t;
-#endif
-
-
-#define MAX_PROC_NAME_SIZE sizeof("/proc/1234567890/status")
-
-struct target_ops procfs_ops;
-
-int procfs_suppress_run = 0; /* Non-zero if procfs should pretend not to
- be a runnable target. Used by targets
- that can sit atop procfs, such as solaris
- thread support. */
-
-#if 1 /* FIXME: Gross and ugly hack to resolve coredep.c global */
-CORE_ADDR kernel_u_addr;
-#endif
-
-#ifdef BROKEN_SIGINFO_H /* Workaround broken SGS <sys/siginfo.h> */
-#undef si_pid
-#define si_pid _data._proc.pid
-#undef si_uid
-#define si_uid _data._proc._pdata._kill.uid
-#endif /* BROKEN_SIGINFO_H */
-
-/* Define structures for passing commands to /proc/pid/ctl file. Note that
- while we create these for the PROCFS_USE_READ_WRITE world, we use them
- and ignore the extra cmd int in other proc schemes.
-*/
-/* generic ctl msg */
-struct proc_ctl {
- int cmd;
- long data;
-};
-
-/* set general registers */
-struct greg_ctl {
- int cmd;
- gdb_gregset_t gregset;
-};
-
-/* set fp registers */
-struct fpreg_ctl {
- int cmd;
- gdb_fpregset_t fpregset;
-};
-
-/* set signals to be traced */
-struct sig_ctl {
- int cmd;
- sigset_t sigset;
-};
-
-/* set faults to be traced */
-struct flt_ctl {
- int cmd;
- fltset_t fltset;
-};
-
-/* set system calls to be traced */
-struct sys_ctl {
- int cmd;
- sysset_t sysset;
-};
-
-/* set current signal to be traced */
-struct sigi_ctl {
- int cmd;
- siginfo_t siginfo;
-};
-
-/* 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 for the inferior is statically allocated and
- only one exists at any given time. There is a separate procinfo
- structure for use by the "info proc" command, so that we can print
- useful information about any random process without interfering with
- the inferior's procinfo information. */
-
-struct procinfo {
- struct procinfo *next;
- int pid; /* Process ID of inferior */
- int ctl_fd; /* File descriptor for /proc ctl file */
- int status_fd; /* File descriptor for /proc status file */
- int as_fd; /* File descriptor for /proc as file */
- int map_fd; /* File descriptor for /proc map file */
- char *pathname; /* Pathname to /proc entry */
- int had_event; /* poll/select says something happened */
- int was_stopped; /* Nonzero if was stopped prior to attach */
- int nopass_next_sigstop; /* Don't pass a sigstop on next resume */
-#ifdef HAVE_PRRUN_T
- prrun_t prrun; /* Control state when it is run */
-#endif
- gdb_prstatus_t prstatus; /* Current process status info */
- struct greg_ctl gregset; /* General register set */
- struct fpreg_ctl fpregset; /* Floating point register set */
- struct flt_ctl fltset; /* Current traced hardware fault set */
- struct sig_ctl trace; /* Current traced signal set */
- struct sys_ctl exitset; /* Current traced system call exit set */
- struct sys_ctl entryset; /* Current traced system call entry set */
- struct sig_ctl saved_sighold; /* Saved held signal set */
- struct flt_ctl saved_fltset; /* Saved traced hardware fault set */
- struct sig_ctl saved_trace; /* Saved traced signal set */
- struct sys_ctl saved_exitset; /* Saved traced system call exit set */
- struct sys_ctl saved_entryset;/* Saved traced system call entry set */
- int num_syscall_handlers; /* Number of syscall trap handlers
- currently installed */
- /* Pointer to list of syscall trap handlers */
- struct procfs_syscall_handler *syscall_handlers;
- int saved_rtnval; /* return value and status for wait(), */
- int saved_statval; /* as supplied by a syscall handler. */
- int new_child; /* Non-zero if it's a new thread */
-};
-
-/* List of inferior process information */
-static struct procinfo *procinfo_list = NULL;
-static struct pollfd *poll_list; /* pollfds used for waiting on /proc */
-
-static int num_poll_list = 0; /* Number of entries in poll_list */
-
-/* Much of the information used in the /proc interface, particularly for
- printing status information, is kept as tables of structures of the
- following form. These tables can be used to map numeric values to
- their symbolic names and to a string that describes their specific use. */
-
-struct trans {
- int value; /* The numeric value */
- char *name; /* The equivalent symbolic value */
- char *desc; /* Short description of value */
-};
-
-/* Translate bits in the pr_flags member of the prstatus structure, into the
- names and desc information. */
-
-static struct trans pr_flag_table[] =
-{
-#if defined (PR_STOPPED)
- { PR_STOPPED, "PR_STOPPED", "Process is stopped" },
-#endif
-#if defined (PR_ISTOP)
- { PR_ISTOP, "PR_ISTOP", "Stopped on an event of interest" },
-#endif
-#if defined (PR_DSTOP)
- { PR_DSTOP, "PR_DSTOP", "A stop directive is in effect" },
-#endif
-#if defined (PR_ASLEEP)
- { PR_ASLEEP, "PR_ASLEEP", "Sleeping in an interruptible system call" },
-#endif
-#if defined (PR_FORK)
- { PR_FORK, "PR_FORK", "Inherit-on-fork is in effect" },
-#endif
-#if defined (PR_RLC)
- { PR_RLC, "PR_RLC", "Run-on-last-close is in effect" },
-#endif
-#if defined (PR_PTRACE)
- { PR_PTRACE, "PR_PTRACE", "Process is being controlled by ptrace" },
-#endif
-#if defined (PR_PCINVAL)
- { PR_PCINVAL, "PR_PCINVAL", "PC refers to an invalid virtual address" },
-#endif
-#if defined (PR_ISSYS)
- { PR_ISSYS, "PR_ISSYS", "Is a system process" },
-#endif
-#if defined (PR_STEP)
- { PR_STEP, "PR_STEP", "Process has single step pending" },
-#endif
-#if defined (PR_KLC)
- { PR_KLC, "PR_KLC", "Kill-on-last-close is in effect" },
-#endif
-#if defined (PR_ASYNC)
- { PR_ASYNC, "PR_ASYNC", "Asynchronous stop is in effect" },
-#endif
-#if defined (PR_PCOMPAT)
- { PR_PCOMPAT, "PR_PCOMPAT", "Ptrace compatibility mode in effect" },
-#endif
-#if defined (PR_MSACCT)
- { PR_MSACCT, "PR_MSACCT", "Microstate accounting enabled" },
-#endif
-#if defined (PR_BPTADJ)
- { PR_BPTADJ, "PR_BPTADJ", "Breakpoint PC adjustment in effect" },
-#endif
-#if defined (PR_ASLWP)
- { PR_ASLWP, "PR_ASLWP", "Asynchronus signal LWP" },
-#endif
- { 0, NULL, NULL }
-};
-
-/* Translate values in the pr_why field of the prstatus struct. */
-
-static struct trans pr_why_table[] =
-{
-#if defined (PR_REQUESTED)
- { PR_REQUESTED, "PR_REQUESTED", "Directed to stop via PIOCSTOP/PIOCWSTOP" },
-#endif
-#if defined (PR_SIGNALLED)
- { PR_SIGNALLED, "PR_SIGNALLED", "Receipt of a traced signal" },
-#endif
-#if defined (PR_SYSENTRY)
- { PR_SYSENTRY, "PR_SYSENTRY", "Entry to a traced system call" },
-#endif
-#if defined (PR_SYSEXIT)
- { PR_SYSEXIT, "PR_SYSEXIT", "Exit from a traced system call" },
-#endif
-#if defined (PR_JOBCONTROL)
- { PR_JOBCONTROL, "PR_JOBCONTROL", "Default job control stop signal action" },
-#endif
-#if defined (PR_FAULTED)
- { PR_FAULTED, "PR_FAULTED", "Incurred a traced hardware fault" },
-#endif
-#if defined (PR_SUSPENDED)
- { PR_SUSPENDED, "PR_SUSPENDED", "Process suspended" },
-#endif
-#if defined (PR_CHECKPOINT)
- { PR_CHECKPOINT, "PR_CHECKPOINT", "(???)" },
-#endif
- { 0, NULL, NULL }
-};
-
-/* Hardware fault translation table. */
-
-static struct trans faults_table[] =
-{
-#if defined (FLTILL)
- { FLTILL, "FLTILL", "Illegal instruction" },
-#endif
-#if defined (FLTPRIV)
- { FLTPRIV, "FLTPRIV", "Privileged instruction" },
-#endif
-#if defined (FLTBPT)
- { FLTBPT, "FLTBPT", "Breakpoint trap" },
-#endif
-#if defined (FLTTRACE)
- { FLTTRACE, "FLTTRACE", "Trace trap" },
-#endif
-#if defined (FLTACCESS)
- { FLTACCESS, "FLTACCESS", "Memory access fault" },
-#endif
-#if defined (FLTBOUNDS)
- { FLTBOUNDS, "FLTBOUNDS", "Memory bounds violation" },
-#endif
-#if defined (FLTIOVF)
- { FLTIOVF, "FLTIOVF", "Integer overflow" },
-#endif
-#if defined (FLTIZDIV)
- { FLTIZDIV, "FLTIZDIV", "Integer zero divide" },
-#endif
-#if defined (FLTFPE)
- { FLTFPE, "FLTFPE", "Floating-point exception" },
-#endif
-#if defined (FLTSTACK)
- { FLTSTACK, "FLTSTACK", "Unrecoverable stack fault" },
-#endif
-#if defined (FLTPAGE)
- { FLTPAGE, "FLTPAGE", "Recoverable page fault" },
-#endif
- { 0, NULL, NULL }
-};
-
-/* Translation table for signal generation information. See UNIX System
- V Release 4 Programmer's Reference Manual, siginfo(5). */
-
-static struct sigcode {
- int signo;
- int code;
- char *codename;
- char *desc;
-} siginfo_table[] = {
-#if defined (SIGILL) && defined (ILL_ILLOPC)
- { SIGILL, ILL_ILLOPC, "ILL_ILLOPC", "Illegal opcode" },
-#endif
-#if defined (SIGILL) && defined (ILL_ILLOPN)
- { SIGILL, ILL_ILLOPN, "ILL_ILLOPN", "Illegal operand", },
-#endif
-#if defined (SIGILL) && defined (ILL_ILLADR)
- { SIGILL, ILL_ILLADR, "ILL_ILLADR", "Illegal addressing mode" },
-#endif
-#if defined (SIGILL) && defined (ILL_ILLTRP)
- { SIGILL, ILL_ILLTRP, "ILL_ILLTRP", "Illegal trap" },
-#endif
-#if defined (SIGILL) && defined (ILL_PRVOPC)
- { SIGILL, ILL_PRVOPC, "ILL_PRVOPC", "Privileged opcode" },
-#endif
-#if defined (SIGILL) && defined (ILL_PRVREG)
- { SIGILL, ILL_PRVREG, "ILL_PRVREG", "Privileged register" },
-#endif
-#if defined (SIGILL) && defined (ILL_COPROC)
- { SIGILL, ILL_COPROC, "ILL_COPROC", "Coprocessor error" },
-#endif
-#if defined (SIGILL) && defined (ILL_BADSTK)
- { SIGILL, ILL_BADSTK, "ILL_BADSTK", "Internal stack error" },
-#endif
-#if defined (SIGFPE) && defined (FPE_INTDIV)
- { SIGFPE, FPE_INTDIV, "FPE_INTDIV", "Integer divide by zero" },
-#endif
-#if defined (SIGFPE) && defined (FPE_INTOVF)
- { SIGFPE, FPE_INTOVF, "FPE_INTOVF", "Integer overflow" },
-#endif
-#if defined (SIGFPE) && defined (FPE_FLTDIV)
- { SIGFPE, FPE_FLTDIV, "FPE_FLTDIV", "Floating point divide by zero" },
-#endif
-#if defined (SIGFPE) && defined (FPE_FLTOVF)
- { SIGFPE, FPE_FLTOVF, "FPE_FLTOVF", "Floating point overflow" },
-#endif
-#if defined (SIGFPE) && defined (FPE_FLTUND)
- { SIGFPE, FPE_FLTUND, "FPE_FLTUND", "Floating point underflow" },
-#endif
-#if defined (SIGFPE) && defined (FPE_FLTRES)
- { SIGFPE, FPE_FLTRES, "FPE_FLTRES", "Floating point inexact result" },
-#endif
-#if defined (SIGFPE) && defined (FPE_FLTINV)
- { SIGFPE, FPE_FLTINV, "FPE_FLTINV", "Invalid floating point operation" },
-#endif
-#if defined (SIGFPE) && defined (FPE_FLTSUB)
- { SIGFPE, FPE_FLTSUB, "FPE_FLTSUB", "Subscript out of range" },
-#endif
-#if defined (SIGSEGV) && defined (SEGV_MAPERR)
- { SIGSEGV, SEGV_MAPERR, "SEGV_MAPERR", "Address not mapped to object" },
-#endif
-#if defined (SIGSEGV) && defined (SEGV_ACCERR)
- { SIGSEGV, SEGV_ACCERR, "SEGV_ACCERR", "Invalid permissions for object" },
-#endif
-#if defined (SIGBUS) && defined (BUS_ADRALN)
- { SIGBUS, BUS_ADRALN, "BUS_ADRALN", "Invalid address alignment" },
-#endif
-#if defined (SIGBUS) && defined (BUS_ADRERR)
- { SIGBUS, BUS_ADRERR, "BUS_ADRERR", "Non-existent physical address" },
-#endif
-#if defined (SIGBUS) && defined (BUS_OBJERR)
- { SIGBUS, BUS_OBJERR, "BUS_OBJERR", "Object specific hardware error" },
-#endif
-#if defined (SIGTRAP) && defined (TRAP_BRKPT)
- { SIGTRAP, TRAP_BRKPT, "TRAP_BRKPT", "Process breakpoint" },
-#endif
-#if defined (SIGTRAP) && defined (TRAP_TRACE)
- { SIGTRAP, TRAP_TRACE, "TRAP_TRACE", "Process trace trap" },
-#endif
-#if defined (SIGCLD) && defined (CLD_EXITED)
- { SIGCLD, CLD_EXITED, "CLD_EXITED", "Child has exited" },
-#endif
-#if defined (SIGCLD) && defined (CLD_KILLED)
- { SIGCLD, CLD_KILLED, "CLD_KILLED", "Child was killed" },
-#endif
-#if defined (SIGCLD) && defined (CLD_DUMPED)
- { SIGCLD, CLD_DUMPED, "CLD_DUMPED", "Child has terminated abnormally" },
-#endif
-#if defined (SIGCLD) && defined (CLD_TRAPPED)
- { SIGCLD, CLD_TRAPPED, "CLD_TRAPPED", "Traced child has trapped" },
-#endif
-#if defined (SIGCLD) && defined (CLD_STOPPED)
- { SIGCLD, CLD_STOPPED, "CLD_STOPPED", "Child has stopped" },
-#endif
-#if defined (SIGCLD) && defined (CLD_CONTINUED)
- { SIGCLD, CLD_CONTINUED, "CLD_CONTINUED", "Stopped child had continued" },
-#endif
-#if defined (SIGPOLL) && defined (POLL_IN)
- { SIGPOLL, POLL_IN, "POLL_IN", "Input input available" },
-#endif
-#if defined (SIGPOLL) && defined (POLL_OUT)
- { SIGPOLL, POLL_OUT, "POLL_OUT", "Output buffers available" },
-#endif
-#if defined (SIGPOLL) && defined (POLL_MSG)
- { SIGPOLL, POLL_MSG, "POLL_MSG", "Input message available" },
-#endif
-#if defined (SIGPOLL) && defined (POLL_ERR)
- { SIGPOLL, POLL_ERR, "POLL_ERR", "I/O error" },
-#endif
-#if defined (SIGPOLL) && defined (POLL_PRI)
- { SIGPOLL, POLL_PRI, "POLL_PRI", "High priority input available" },
-#endif
-#if defined (SIGPOLL) && defined (POLL_HUP)
- { SIGPOLL, POLL_HUP, "POLL_HUP", "Device disconnected" },
-#endif
- { 0, 0, NULL, NULL }
-};
-
-static char *syscall_table[MAX_SYSCALLS];
-
-/* Prototypes for local functions */
-
-static void procfs_stop PARAMS ((void));
-
-static int procfs_thread_alive PARAMS ((int));
-
-static int procfs_can_run PARAMS ((void));
-
-static void procfs_mourn_inferior PARAMS ((void));
-
-static void procfs_fetch_registers PARAMS ((int));
-
-static int procfs_wait PARAMS ((int, struct target_waitstatus *));
-
-static void procfs_open PARAMS ((char *, int));
-
-static void procfs_files_info PARAMS ((struct target_ops *));
-
-static void procfs_prepare_to_store PARAMS ((void));
-
-static void procfs_detach PARAMS ((char *, int));
-
-static void procfs_attach PARAMS ((char *, int));
-
-static void proc_set_exec_trap PARAMS ((void));
-
-static void procfs_init_inferior PARAMS ((int));
-
-static struct procinfo *create_procinfo PARAMS ((int));
-
-static void procfs_store_registers PARAMS ((int));
-
-static int procfs_xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
-
-static void procfs_kill_inferior PARAMS ((void));
-
-static char *sigcodedesc PARAMS ((siginfo_t *));
-
-static char *sigcodename PARAMS ((siginfo_t *));
-
-static struct procinfo *wait_fd PARAMS ((void));
-
-static void remove_fd PARAMS ((struct procinfo *));
-
-static void add_fd PARAMS ((struct procinfo *));
-
-static void set_proc_siginfo PARAMS ((struct procinfo *, int));
-
-static void init_syscall_table PARAMS ((void));
-
-static char *syscallname PARAMS ((int));
-
-static char *signalname PARAMS ((int));
-
-static char *errnoname PARAMS ((int));
-
-static int proc_address_to_fd PARAMS ((struct procinfo *, CORE_ADDR, int));
-
-static int open_proc_file PARAMS ((int, struct procinfo *, int, int));
-
-static void close_proc_file PARAMS ((struct procinfo *));
-
-static void unconditionally_kill_inferior PARAMS ((struct procinfo *));
-
-static NORETURN void proc_init_failed PARAMS ((struct procinfo *, char *, int)) ATTR_NORETURN;
-
-static void info_proc PARAMS ((char *, int));
-
-static void info_proc_flags PARAMS ((struct procinfo *, int));
-
-static void info_proc_stop PARAMS ((struct procinfo *, int));
-
-static void info_proc_siginfo PARAMS ((struct procinfo *, int));
-
-static void info_proc_syscalls PARAMS ((struct procinfo *, int));
-
-static void info_proc_mappings PARAMS ((struct procinfo *, int));
-
-static void info_proc_signals PARAMS ((struct procinfo *, int));
-
-static void info_proc_faults PARAMS ((struct procinfo *, int));
-
-static char *mappingflags PARAMS ((long));
-
-static char *lookupname PARAMS ((struct trans *, unsigned int, char *));
-
-static char *lookupdesc PARAMS ((struct trans *, unsigned int));
-
-static int do_attach PARAMS ((int pid));
-
-static void do_detach PARAMS ((int siggnal));
-
-static void procfs_create_inferior PARAMS ((char *, char *, char **));
-
-static void procfs_notice_signals PARAMS ((int pid));
-
-static void notice_signals PARAMS ((struct procinfo *, struct sig_ctl *));
-
-static struct procinfo *find_procinfo PARAMS ((pid_t pid, int okfail));
-
-static int procfs_write_pcwstop PARAMS ((struct procinfo *));
-static int procfs_read_status PARAMS ((struct procinfo *));
-static void procfs_write_pckill PARAMS ((struct procinfo *));
-
-typedef int syscall_func_t PARAMS ((struct procinfo *pi, int syscall_num,
- int why, int *rtnval, int *statval));
-
-static void procfs_set_syscall_trap PARAMS ((struct procinfo *pi,
- int syscall_num, int flags,
- syscall_func_t *func));
-
-static void procfs_clear_syscall_trap PARAMS ((struct procinfo *pi,
- int syscall_num, int errok));
-
-#define PROCFS_SYSCALL_ENTRY 0x1 /* Trap on entry to sys call */
-#define PROCFS_SYSCALL_EXIT 0x2 /* Trap on exit from sys call */
-
-static syscall_func_t procfs_exit_handler;
-
-static syscall_func_t procfs_exec_handler;
-
-#ifdef SYS_sproc
-static syscall_func_t procfs_sproc_handler;
-static syscall_func_t procfs_fork_handler;
-#endif
-
-#ifdef SYS_lwp_create
-static syscall_func_t procfs_lwp_creation_handler;
-#endif
-
-static void modify_inherit_on_fork_flag PARAMS ((int fd, int flag));
-static void modify_run_on_last_close_flag PARAMS ((int fd, int flag));
-
-/* */
-
-struct procfs_syscall_handler
-{
- int syscall_num; /* The number of the system call being handled */
- /* The function to be called */
- syscall_func_t *func;
-};
-
-static void procfs_resume PARAMS ((int pid, int step,
- enum target_signal signo));
-
-static void init_procfs_ops PARAMS ((void));
-
-/* External function prototypes that can't be easily included in any
- header file because the args are typedefs in system include files. */
-
-extern void supply_gregset PARAMS ((gdb_gregset_t *));
-
-extern void fill_gregset PARAMS ((gdb_gregset_t *, int));
-
-#ifdef FP0_REGNUM
-extern void supply_fpregset PARAMS ((gdb_fpregset_t *));
-
-extern void fill_fpregset PARAMS ((gdb_fpregset_t *, int));
-#endif
-
-/*
-
-LOCAL FUNCTION
-
- find_procinfo -- convert a process id to a struct procinfo
-
-SYNOPSIS
-
- static struct procinfo * find_procinfo (pid_t pid, int okfail);
-
-DESCRIPTION
-
- Given a process id, look it up in the procinfo chain. Returns
- a struct procinfo *. If can't find pid, then call error(),
- unless okfail is set, in which case, return NULL;
- */
-
-static struct procinfo *
-find_procinfo (pid, okfail)
- pid_t pid;
- int okfail;
-{
- struct procinfo *procinfo;
-
- for (procinfo = procinfo_list; procinfo; procinfo = procinfo->next)
- if (procinfo->pid == pid)
- return procinfo;
-
- if (okfail)
- return NULL;
-
- error ("procfs (find_procinfo): Couldn't locate pid %d", pid);
-}
-
-/*
-
-LOCAL MACRO
-
- current_procinfo -- convert inferior_pid to a struct procinfo
-
-SYNOPSIS
-
- static struct procinfo * current_procinfo;
-
-DESCRIPTION
-
- Looks up inferior_pid in the procinfo chain. Always returns a
- struct procinfo *. If process can't be found, we error() out.
- */
-
-#define current_procinfo find_procinfo (inferior_pid, 0)
-
-/*
-
-LOCAL FUNCTION
-
- add_fd -- Add the fd to the poll/select list
-
-SYNOPSIS
-
- static void add_fd (struct procinfo *);
-
-DESCRIPTION
-
- Add the fd of the supplied procinfo to the list of fds used for
- poll/select operations.
- */
-
-static void
-add_fd (pi)
- struct procinfo *pi;
-{
- if (num_poll_list <= 0)
- poll_list = (struct pollfd *) xmalloc (sizeof (struct pollfd));
- else
- poll_list = (struct pollfd *) xrealloc (poll_list,
- (num_poll_list + 1)
- * sizeof (struct pollfd));
- poll_list[num_poll_list].fd = pi->ctl_fd;
-#ifdef UNIXWARE
- poll_list[num_poll_list].events = POLLWRNORM;
-#else
- poll_list[num_poll_list].events = POLLPRI;
-#endif
-
- num_poll_list++;
-}
-
-/*
-
-LOCAL FUNCTION
-
- remove_fd -- Remove the fd from the poll/select list
-
-SYNOPSIS
-
- static void remove_fd (struct procinfo *);
-
-DESCRIPTION
-
- Remove the fd of the supplied procinfo from the list of fds used
- for poll/select operations.
- */
-
-static void
-remove_fd (pi)
- struct procinfo *pi;
-{
- int i;
-
- for (i = 0; i < num_poll_list; i++)
- {
- if (poll_list[i].fd == pi->ctl_fd)
- {
- if (i != num_poll_list - 1)
- memcpy (poll_list + i, poll_list + i + 1,
- (num_poll_list - i - 1) * sizeof (struct pollfd));
-
- num_poll_list--;
-
- if (num_poll_list == 0)
- free (poll_list);
- else
- poll_list = (struct pollfd *) xrealloc (poll_list,
- num_poll_list
- * sizeof (struct pollfd));
- return;
- }
- }
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_read_status - get procfs fd status
-
-SYNOPSIS
-
- static int procfs_read_status (pi) struct procinfo *pi;
-
-DESCRIPTION
-
- Given a pointer to a procinfo struct, get the status of
- the status_fd in the appropriate way. Returns 0 on failure,
- 1 on success.
- */
-
-static int
-procfs_read_status (pi)
- struct procinfo *pi;
-{
-#ifdef PROCFS_USE_READ_WRITE
- if ((lseek (pi->status_fd, 0, SEEK_SET) < 0) ||
- (read (pi->status_fd, (char *) &pi->prstatus,
- sizeof (gdb_prstatus_t)) != sizeof (gdb_prstatus_t)))
-#else
- if (ioctl (pi->status_fd, PIOCSTATUS, &pi->prstatus) < 0)
-#endif
- return 0;
- else
- return 1;
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_write_pcwstop - send a PCWSTOP to procfs fd
-
-SYNOPSIS
-
- static int procfs_write_pcwstop (pi) struct procinfo *pi;
-
-DESCRIPTION
-
- Given a pointer to a procinfo struct, send a PCWSTOP to
- the ctl_fd in the appropriate way. Returns 0 on failure,
- 1 on success.
- */
-
-static int
-procfs_write_pcwstop (pi)
- struct procinfo *pi;
-{
-#ifdef PROCFS_USE_READ_WRITE
- long cmd = PCWSTOP;
- if (write (pi->ctl_fd, (char *) &cmd, sizeof (long)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCWSTOP, &pi->prstatus) < 0)
-#endif
- return 0;
- else
- return 1;
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_write_pckill - send a kill to procfs fd
-
-SYNOPSIS
-
- static void procfs_write_pckill (pi) struct procinfo *pi;
-
-DESCRIPTION
-
- Given a pointer to a procinfo struct, send a kill to
- the ctl_fd in the appropriate way. Returns 0 on failure,
- 1 on success.
- */
-
-static void
-procfs_write_pckill (pi)
- struct procinfo *pi;
-{
-#ifdef PROCFS_USE_READ_WRITE
- struct proc_ctl pctl;
- pctl.cmd = PCKILL;
- pctl.data = SIGKILL;
- write (pi->ctl_fd, &pctl, sizeof (struct proc_ctl));
-#else
- int signo = SIGKILL;
- ioctl (pi->ctl_fd, PIOCKILL, &signo);
-#endif
-}
-
-static struct procinfo *
-wait_fd ()
-{
- struct procinfo *pi, *next_pi;
-#ifndef LOSING_POLL
- int num_fds;
- int i;
-#endif
-
- set_sigint_trap (); /* Causes SIGINT to be passed on to the
- attached process. */
- set_sigio_trap ();
-
- wait_again:
-#ifndef LOSING_POLL
- while (1)
- {
- num_fds = poll (poll_list, num_poll_list, -1);
- if (num_fds > 0)
- break;
- if (num_fds < 0 && errno == EINTR)
- continue;
- print_sys_errmsg ("poll failed", errno);
- error ("Poll failed, returned %d", num_fds);
- }
-#else /* LOSING_POLL */
- pi = current_procinfo;
-
- while (!procfs_write_pcwstop (pi))
- {
- if (errno == ENOENT)
- {
- /* Process exited. */
- pi->prstatus.pr_flags = 0;
- break;
- }
- else if (errno != EINTR)
- {
- print_sys_errmsg (pi->pathname, errno);
- error ("procfs_write_pcwstop failed");
- }
- }
- pi->had_event = 1;
-#endif /* LOSING_POLL */
-
- clear_sigint_trap ();
- clear_sigio_trap ();
-
-#ifndef LOSING_POLL
-
- for (i = 0; i < num_poll_list && num_fds > 0; i++)
- {
- if (0 == (poll_list[i].revents &
- (POLLWRNORM | POLLPRI | POLLERR | POLLHUP | POLLNVAL)))
- continue;
- for (pi = procinfo_list; pi; pi = next_pi)
- {
- next_pi = pi->next;
- if (poll_list[i].fd == pi->ctl_fd)
- {
- num_fds--;
- if ((poll_list[i].revents & POLLHUP) != 0 ||
- !procfs_read_status(pi))
- { /* The LWP has apparently terminated. */
- if (num_poll_list <= 1)
- {
- pi->prstatus.pr_flags = 0;
- pi->had_event = 1;
- break;
- }
- if (info_verbose)
- printf_filtered ("LWP %d exited.\n",
- (pi->pid >> 16) & 0xffff);
- close_proc_file (pi);
- i--; /* don't skip deleted entry */
- if (num_fds != 0)
- break; /* already another event to process */
- else
- goto wait_again; /* wait for another event */
- }
- pi->had_event = 1;
- break;
- }
- }
- if (!pi)
- error ("wait_fd: Couldn't find procinfo for fd %d\n",
- poll_list[i].fd);
- }
-#endif /* LOSING_POLL */
-
- return pi;
-}
-
-/*
-
-LOCAL FUNCTION
-
- lookupdesc -- translate a value to a summary desc string
-
-SYNOPSIS
-
- static char *lookupdesc (struct trans *transp, unsigned int val);
-
-DESCRIPTION
-
- Given a pointer to a translation table and a value to be translated,
- lookup the desc string and return it.
- */
-
-static char *
-lookupdesc (transp, val)
- struct trans *transp;
- unsigned int val;
-{
- char *desc;
-
- for (desc = NULL; transp -> name != NULL; transp++)
- {
- if (transp -> value == val)
- {
- desc = transp -> desc;
- break;
- }
- }
-
- /* Didn't find a translation for the specified value, set a default one. */
-
- if (desc == NULL)
- {
- desc = "Unknown";
- }
- return (desc);
-}
-
-/*
-
-LOCAL FUNCTION
-
- lookupname -- translate a value to symbolic name
-
-SYNOPSIS
-
- static char *lookupname (struct trans *transp, unsigned int val,
- char *prefix);
-
-DESCRIPTION
-
- Given a pointer to a translation table, a value to be translated,
- and a default prefix to return if the value can't be translated,
- match the value with one of the translation table entries and
- return a pointer to the symbolic name.
-
- If no match is found it just returns the value as a printable string,
- with the given prefix. The previous such value, if any, is freed
- at this time.
- */
-
-static char *
-lookupname (transp, val, prefix)
- struct trans *transp;
- unsigned int val;
- char *prefix;
-{
- static char *locbuf;
- char *name;
-
- for (name = NULL; transp -> name != NULL; transp++)
- {
- if (transp -> value == val)
- {
- name = transp -> name;
- break;
- }
- }
-
- /* Didn't find a translation for the specified value, build a default
- one using the specified prefix and return it. The lifetime of
- the value is only until the next one is needed. */
-
- if (name == NULL)
- {
- if (locbuf != NULL)
- {
- free (locbuf);
- }
- locbuf = xmalloc (strlen (prefix) + 16);
- sprintf (locbuf, "%s %u", prefix, val);
- name = locbuf;
- }
- return (name);
-}
-
-static char *
-sigcodename (sip)
- siginfo_t *sip;
-{
- struct sigcode *scp;
- char *name = NULL;
- static char locbuf[32];
-
- for (scp = siginfo_table; scp -> codename != NULL; scp++)
- {
- if ((scp -> signo == sip -> si_signo) &&
- (scp -> code == sip -> si_code))
- {
- name = scp -> codename;
- break;
- }
- }
- if (name == NULL)
- {
- sprintf (locbuf, "sigcode %u", sip -> si_signo);
- name = locbuf;
- }
- return (name);
-}
-
-static char *
-sigcodedesc (sip)
- siginfo_t *sip;
-{
- struct sigcode *scp;
- char *desc = NULL;
-
- for (scp = siginfo_table; scp -> codename != NULL; scp++)
- {
- if ((scp -> signo == sip -> si_signo) &&
- (scp -> code == sip -> si_code))
- {
- desc = scp -> desc;
- break;
- }
- }
- if (desc == NULL)
- {
- desc = "Unrecognized signal or trap use";
- }
- return (desc);
-}
-
-/*
-
-LOCAL FUNCTION
-
- syscallname - translate a system call number into a system call name
-
-SYNOPSIS
-
- char *syscallname (int syscallnum)
-
-DESCRIPTION
-
- Given a system call number, translate it into the printable name
- of a system call, or into "syscall <num>" if it is an unknown
- number.
- */
-
-static char *
-syscallname (syscallnum)
- int syscallnum;
-{
- static char locbuf[32];
-
- if (syscallnum >= 0 && syscallnum < MAX_SYSCALLS
- && syscall_table[syscallnum] != NULL)
- return syscall_table[syscallnum];
- else
- {
- sprintf (locbuf, "syscall %u", syscallnum);
- return locbuf;
- }
-}
-
-/*
-
-LOCAL FUNCTION
-
- init_syscall_table - initialize syscall translation table
-
-SYNOPSIS
-
- void init_syscall_table (void)
-
-DESCRIPTION
-
- Dynamically initialize the translation table to convert system
- call numbers into printable system call names. Done once per
- gdb run, on initialization.
-
-NOTES
-
- This is awfully ugly, but preprocessor tricks to make it prettier
- tend to be nonportable.
- */
-
-static void
-init_syscall_table ()
-{
-#if defined (SYS_exit)
- syscall_table[SYS_exit] = "exit";
-#endif
-#if defined (SYS_fork)
- syscall_table[SYS_fork] = "fork";
-#endif
-#if defined (SYS_read)
- syscall_table[SYS_read] = "read";
-#endif
-#if defined (SYS_write)
- syscall_table[SYS_write] = "write";
-#endif
-#if defined (SYS_open)
- syscall_table[SYS_open] = "open";
-#endif
-#if defined (SYS_close)
- syscall_table[SYS_close] = "close";
-#endif
-#if defined (SYS_wait)
- syscall_table[SYS_wait] = "wait";
-#endif
-#if defined (SYS_creat)
- syscall_table[SYS_creat] = "creat";
-#endif
-#if defined (SYS_link)
- syscall_table[SYS_link] = "link";
-#endif
-#if defined (SYS_unlink)
- syscall_table[SYS_unlink] = "unlink";
-#endif
-#if defined (SYS_exec)
- syscall_table[SYS_exec] = "exec";
-#endif
-#if defined (SYS_execv)
- syscall_table[SYS_execv] = "execv";
-#endif
-#if defined (SYS_execve)
- syscall_table[SYS_execve] = "execve";
-#endif
-#if defined (SYS_chdir)
- syscall_table[SYS_chdir] = "chdir";
-#endif
-#if defined (SYS_time)
- syscall_table[SYS_time] = "time";
-#endif
-#if defined (SYS_mknod)
- syscall_table[SYS_mknod] = "mknod";
-#endif
-#if defined (SYS_chmod)
- syscall_table[SYS_chmod] = "chmod";
-#endif
-#if defined (SYS_chown)
- syscall_table[SYS_chown] = "chown";
-#endif
-#if defined (SYS_brk)
- syscall_table[SYS_brk] = "brk";
-#endif
-#if defined (SYS_stat)
- syscall_table[SYS_stat] = "stat";
-#endif
-#if defined (SYS_lseek)
- syscall_table[SYS_lseek] = "lseek";
-#endif
-#if defined (SYS_getpid)
- syscall_table[SYS_getpid] = "getpid";
-#endif
-#if defined (SYS_mount)
- syscall_table[SYS_mount] = "mount";
-#endif
-#if defined (SYS_umount)
- syscall_table[SYS_umount] = "umount";
-#endif
-#if defined (SYS_setuid)
- syscall_table[SYS_setuid] = "setuid";
-#endif
-#if defined (SYS_getuid)
- syscall_table[SYS_getuid] = "getuid";
-#endif
-#if defined (SYS_stime)
- syscall_table[SYS_stime] = "stime";
-#endif
-#if defined (SYS_ptrace)
- syscall_table[SYS_ptrace] = "ptrace";
-#endif
-#if defined (SYS_alarm)
- syscall_table[SYS_alarm] = "alarm";
-#endif
-#if defined (SYS_fstat)
- syscall_table[SYS_fstat] = "fstat";
-#endif
-#if defined (SYS_pause)
- syscall_table[SYS_pause] = "pause";
-#endif
-#if defined (SYS_utime)
- syscall_table[SYS_utime] = "utime";
-#endif
-#if defined (SYS_stty)
- syscall_table[SYS_stty] = "stty";
-#endif
-#if defined (SYS_gtty)
- syscall_table[SYS_gtty] = "gtty";
-#endif
-#if defined (SYS_access)
- syscall_table[SYS_access] = "access";
-#endif
-#if defined (SYS_nice)
- syscall_table[SYS_nice] = "nice";
-#endif
-#if defined (SYS_statfs)
- syscall_table[SYS_statfs] = "statfs";
-#endif
-#if defined (SYS_sync)
- syscall_table[SYS_sync] = "sync";
-#endif
-#if defined (SYS_kill)
- syscall_table[SYS_kill] = "kill";
-#endif
-#if defined (SYS_fstatfs)
- syscall_table[SYS_fstatfs] = "fstatfs";
-#endif
-#if defined (SYS_pgrpsys)
- syscall_table[SYS_pgrpsys] = "pgrpsys";
-#endif
-#if defined (SYS_xenix)
- syscall_table[SYS_xenix] = "xenix";
-#endif
-#if defined (SYS_dup)
- syscall_table[SYS_dup] = "dup";
-#endif
-#if defined (SYS_pipe)
- syscall_table[SYS_pipe] = "pipe";
-#endif
-#if defined (SYS_times)
- syscall_table[SYS_times] = "times";
-#endif
-#if defined (SYS_profil)
- syscall_table[SYS_profil] = "profil";
-#endif
-#if defined (SYS_plock)
- syscall_table[SYS_plock] = "plock";
-#endif
-#if defined (SYS_setgid)
- syscall_table[SYS_setgid] = "setgid";
-#endif
-#if defined (SYS_getgid)
- syscall_table[SYS_getgid] = "getgid";
-#endif
-#if defined (SYS_signal)
- syscall_table[SYS_signal] = "signal";
-#endif
-#if defined (SYS_msgsys)
- syscall_table[SYS_msgsys] = "msgsys";
-#endif
-#if defined (SYS_sys3b)
- syscall_table[SYS_sys3b] = "sys3b";
-#endif
-#if defined (SYS_sysi86)
- syscall_table[SYS_sysi86] = "sysi86";
-#endif
-#if defined (SYS_acct)
- syscall_table[SYS_acct] = "acct";
-#endif
-#if defined (SYS_shmsys)
- syscall_table[SYS_shmsys] = "shmsys";
-#endif
-#if defined (SYS_semsys)
- syscall_table[SYS_semsys] = "semsys";
-#endif
-#if defined (SYS_ioctl)
- syscall_table[SYS_ioctl] = "ioctl";
-#endif
-#if defined (SYS_uadmin)
- syscall_table[SYS_uadmin] = "uadmin";
-#endif
-#if defined (SYS_utssys)
- syscall_table[SYS_utssys] = "utssys";
-#endif
-#if defined (SYS_fsync)
- syscall_table[SYS_fsync] = "fsync";
-#endif
-#if defined (SYS_umask)
- syscall_table[SYS_umask] = "umask";
-#endif
-#if defined (SYS_chroot)
- syscall_table[SYS_chroot] = "chroot";
-#endif
-#if defined (SYS_fcntl)
- syscall_table[SYS_fcntl] = "fcntl";
-#endif
-#if defined (SYS_ulimit)
- syscall_table[SYS_ulimit] = "ulimit";
-#endif
-#if defined (SYS_rfsys)
- syscall_table[SYS_rfsys] = "rfsys";
-#endif
-#if defined (SYS_rmdir)
- syscall_table[SYS_rmdir] = "rmdir";
-#endif
-#if defined (SYS_mkdir)
- syscall_table[SYS_mkdir] = "mkdir";
-#endif
-#if defined (SYS_getdents)
- syscall_table[SYS_getdents] = "getdents";
-#endif
-#if defined (SYS_sysfs)
- syscall_table[SYS_sysfs] = "sysfs";
-#endif
-#if defined (SYS_getmsg)
- syscall_table[SYS_getmsg] = "getmsg";
-#endif
-#if defined (SYS_putmsg)
- syscall_table[SYS_putmsg] = "putmsg";
-#endif
-#if defined (SYS_poll)
- syscall_table[SYS_poll] = "poll";
-#endif
-#if defined (SYS_lstat)
- syscall_table[SYS_lstat] = "lstat";
-#endif
-#if defined (SYS_symlink)
- syscall_table[SYS_symlink] = "symlink";
-#endif
-#if defined (SYS_readlink)
- syscall_table[SYS_readlink] = "readlink";
-#endif
-#if defined (SYS_setgroups)
- syscall_table[SYS_setgroups] = "setgroups";
-#endif
-#if defined (SYS_getgroups)
- syscall_table[SYS_getgroups] = "getgroups";
-#endif
-#if defined (SYS_fchmod)
- syscall_table[SYS_fchmod] = "fchmod";
-#endif
-#if defined (SYS_fchown)
- syscall_table[SYS_fchown] = "fchown";
-#endif
-#if defined (SYS_sigprocmask)
- syscall_table[SYS_sigprocmask] = "sigprocmask";
-#endif
-#if defined (SYS_sigsuspend)
- syscall_table[SYS_sigsuspend] = "sigsuspend";
-#endif
-#if defined (SYS_sigaltstack)
- syscall_table[SYS_sigaltstack] = "sigaltstack";
-#endif
-#if defined (SYS_sigaction)
- syscall_table[SYS_sigaction] = "sigaction";
-#endif
-#if defined (SYS_sigpending)
- syscall_table[SYS_sigpending] = "sigpending";
-#endif
-#if defined (SYS_context)
- syscall_table[SYS_context] = "context";
-#endif
-#if defined (SYS_evsys)
- syscall_table[SYS_evsys] = "evsys";
-#endif
-#if defined (SYS_evtrapret)
- syscall_table[SYS_evtrapret] = "evtrapret";
-#endif
-#if defined (SYS_statvfs)
- syscall_table[SYS_statvfs] = "statvfs";
-#endif
-#if defined (SYS_fstatvfs)
- syscall_table[SYS_fstatvfs] = "fstatvfs";
-#endif
-#if defined (SYS_nfssys)
- syscall_table[SYS_nfssys] = "nfssys";
-#endif
-#if defined (SYS_waitsys)
- syscall_table[SYS_waitsys] = "waitsys";
-#endif
-#if defined (SYS_sigsendsys)
- syscall_table[SYS_sigsendsys] = "sigsendsys";
-#endif
-#if defined (SYS_hrtsys)
- syscall_table[SYS_hrtsys] = "hrtsys";
-#endif
-#if defined (SYS_acancel)
- syscall_table[SYS_acancel] = "acancel";
-#endif
-#if defined (SYS_async)
- syscall_table[SYS_async] = "async";
-#endif
-#if defined (SYS_priocntlsys)
- syscall_table[SYS_priocntlsys] = "priocntlsys";
-#endif
-#if defined (SYS_pathconf)
- syscall_table[SYS_pathconf] = "pathconf";
-#endif
-#if defined (SYS_mincore)
- syscall_table[SYS_mincore] = "mincore";
-#endif
-#if defined (SYS_mmap)
- syscall_table[SYS_mmap] = "mmap";
-#endif
-#if defined (SYS_mprotect)
- syscall_table[SYS_mprotect] = "mprotect";
-#endif
-#if defined (SYS_munmap)
- syscall_table[SYS_munmap] = "munmap";
-#endif
-#if defined (SYS_fpathconf)
- syscall_table[SYS_fpathconf] = "fpathconf";
-#endif
-#if defined (SYS_vfork)
- syscall_table[SYS_vfork] = "vfork";
-#endif
-#if defined (SYS_fchdir)
- syscall_table[SYS_fchdir] = "fchdir";
-#endif
-#if defined (SYS_readv)
- syscall_table[SYS_readv] = "readv";
-#endif
-#if defined (SYS_writev)
- syscall_table[SYS_writev] = "writev";
-#endif
-#if defined (SYS_xstat)
- syscall_table[SYS_xstat] = "xstat";
-#endif
-#if defined (SYS_lxstat)
- syscall_table[SYS_lxstat] = "lxstat";
-#endif
-#if defined (SYS_fxstat)
- syscall_table[SYS_fxstat] = "fxstat";
-#endif
-#if defined (SYS_xmknod)
- syscall_table[SYS_xmknod] = "xmknod";
-#endif
-#if defined (SYS_clocal)
- syscall_table[SYS_clocal] = "clocal";
-#endif
-#if defined (SYS_setrlimit)
- syscall_table[SYS_setrlimit] = "setrlimit";
-#endif
-#if defined (SYS_getrlimit)
- syscall_table[SYS_getrlimit] = "getrlimit";
-#endif
-#if defined (SYS_lchown)
- syscall_table[SYS_lchown] = "lchown";
-#endif
-#if defined (SYS_memcntl)
- syscall_table[SYS_memcntl] = "memcntl";
-#endif
-#if defined (SYS_getpmsg)
- syscall_table[SYS_getpmsg] = "getpmsg";
-#endif
-#if defined (SYS_putpmsg)
- syscall_table[SYS_putpmsg] = "putpmsg";
-#endif
-#if defined (SYS_rename)
- syscall_table[SYS_rename] = "rename";
-#endif
-#if defined (SYS_uname)
- syscall_table[SYS_uname] = "uname";
-#endif
-#if defined (SYS_setegid)
- syscall_table[SYS_setegid] = "setegid";
-#endif
-#if defined (SYS_sysconfig)
- syscall_table[SYS_sysconfig] = "sysconfig";
-#endif
-#if defined (SYS_adjtime)
- syscall_table[SYS_adjtime] = "adjtime";
-#endif
-#if defined (SYS_systeminfo)
- syscall_table[SYS_systeminfo] = "systeminfo";
-#endif
-#if defined (SYS_seteuid)
- syscall_table[SYS_seteuid] = "seteuid";
-#endif
-#if defined (SYS_sproc)
- syscall_table[SYS_sproc] = "sproc";
-#endif
-#if defined (SYS_keyctl)
- syscall_table[SYS_keyctl] = "keyctl";
-#endif
-#if defined (SYS_secsys)
- syscall_table[SYS_secsys] = "secsys";
-#endif
-#if defined (SYS_filepriv)
- syscall_table[SYS_filepriv] = "filepriv";
-#endif
-#if defined (SYS_procpriv)
- syscall_table[SYS_procpriv] = "procpriv";
-#endif
-#if defined (SYS_devstat)
- syscall_table[SYS_devstat] = "devstat";
-#endif
-#if defined (SYS_aclipc)
- syscall_table[SYS_aclipc] = "aclipc";
-#endif
-#if defined (SYS_fdevstat)
- syscall_table[SYS_fdevstat] = "fdevstat";
-#endif
-#if defined (SYS_flvlfile)
- syscall_table[SYS_flvlfile] = "flvlfile";
-#endif
-#if defined (SYS_lvlfile)
- syscall_table[SYS_lvlfile] = "lvlfile";
-#endif
-#if defined (SYS_lvlequal)
- syscall_table[SYS_lvlequal] = "lvlequal";
-#endif
-#if defined (SYS_lvlproc)
- syscall_table[SYS_lvlproc] = "lvlproc";
-#endif
-#if defined (SYS_lvlipc)
- syscall_table[SYS_lvlipc] = "lvlipc";
-#endif
-#if defined (SYS_acl)
- syscall_table[SYS_acl] = "acl";
-#endif
-#if defined (SYS_auditevt)
- syscall_table[SYS_auditevt] = "auditevt";
-#endif
-#if defined (SYS_auditctl)
- syscall_table[SYS_auditctl] = "auditctl";
-#endif
-#if defined (SYS_auditdmp)
- syscall_table[SYS_auditdmp] = "auditdmp";
-#endif
-#if defined (SYS_auditlog)
- syscall_table[SYS_auditlog] = "auditlog";
-#endif
-#if defined (SYS_auditbuf)
- syscall_table[SYS_auditbuf] = "auditbuf";
-#endif
-#if defined (SYS_lvldom)
- syscall_table[SYS_lvldom] = "lvldom";
-#endif
-#if defined (SYS_lvlvfs)
- syscall_table[SYS_lvlvfs] = "lvlvfs";
-#endif
-#if defined (SYS_mkmld)
- syscall_table[SYS_mkmld] = "mkmld";
-#endif
-#if defined (SYS_mldmode)
- syscall_table[SYS_mldmode] = "mldmode";
-#endif
-#if defined (SYS_secadvise)
- syscall_table[SYS_secadvise] = "secadvise";
-#endif
-#if defined (SYS_online)
- syscall_table[SYS_online] = "online";
-#endif
-#if defined (SYS_setitimer)
- syscall_table[SYS_setitimer] = "setitimer";
-#endif
-#if defined (SYS_getitimer)
- syscall_table[SYS_getitimer] = "getitimer";
-#endif
-#if defined (SYS_gettimeofday)
- syscall_table[SYS_gettimeofday] = "gettimeofday";
-#endif
-#if defined (SYS_settimeofday)
- syscall_table[SYS_settimeofday] = "settimeofday";
-#endif
-#if defined (SYS_lwp_create)
- syscall_table[SYS_lwp_create] = "_lwp_create";
-#endif
-#if defined (SYS_lwp_exit)
- syscall_table[SYS_lwp_exit] = "_lwp_exit";
-#endif
-#if defined (SYS_lwp_wait)
- syscall_table[SYS_lwp_wait] = "_lwp_wait";
-#endif
-#if defined (SYS_lwp_self)
- syscall_table[SYS_lwp_self] = "_lwp_self";
-#endif
-#if defined (SYS_lwp_info)
- syscall_table[SYS_lwp_info] = "_lwp_info";
-#endif
-#if defined (SYS_lwp_private)
- syscall_table[SYS_lwp_private] = "_lwp_private";
-#endif
-#if defined (SYS_processor_bind)
- syscall_table[SYS_processor_bind] = "processor_bind";
-#endif
-#if defined (SYS_processor_exbind)
- syscall_table[SYS_processor_exbind] = "processor_exbind";
-#endif
-#if defined (SYS_prepblock)
- syscall_table[SYS_prepblock] = "prepblock";
-#endif
-#if defined (SYS_block)
- syscall_table[SYS_block] = "block";
-#endif
-#if defined (SYS_rdblock)
- syscall_table[SYS_rdblock] = "rdblock";
-#endif
-#if defined (SYS_unblock)
- syscall_table[SYS_unblock] = "unblock";
-#endif
-#if defined (SYS_cancelblock)
- syscall_table[SYS_cancelblock] = "cancelblock";
-#endif
-#if defined (SYS_pread)
- syscall_table[SYS_pread] = "pread";
-#endif
-#if defined (SYS_pwrite)
- syscall_table[SYS_pwrite] = "pwrite";
-#endif
-#if defined (SYS_truncate)
- syscall_table[SYS_truncate] = "truncate";
-#endif
-#if defined (SYS_ftruncate)
- syscall_table[SYS_ftruncate] = "ftruncate";
-#endif
-#if defined (SYS_lwp_kill)
- syscall_table[SYS_lwp_kill] = "_lwp_kill";
-#endif
-#if defined (SYS_sigwait)
- syscall_table[SYS_sigwait] = "sigwait";
-#endif
-#if defined (SYS_fork1)
- syscall_table[SYS_fork1] = "fork1";
-#endif
-#if defined (SYS_forkall)
- syscall_table[SYS_forkall] = "forkall";
-#endif
-#if defined (SYS_modload)
- syscall_table[SYS_modload] = "modload";
-#endif
-#if defined (SYS_moduload)
- syscall_table[SYS_moduload] = "moduload";
-#endif
-#if defined (SYS_modpath)
- syscall_table[SYS_modpath] = "modpath";
-#endif
-#if defined (SYS_modstat)
- syscall_table[SYS_modstat] = "modstat";
-#endif
-#if defined (SYS_modadm)
- syscall_table[SYS_modadm] = "modadm";
-#endif
-#if defined (SYS_getksym)
- syscall_table[SYS_getksym] = "getksym";
-#endif
-#if defined (SYS_lwp_suspend)
- syscall_table[SYS_lwp_suspend] = "_lwp_suspend";
-#endif
-#if defined (SYS_lwp_continue)
- syscall_table[SYS_lwp_continue] = "_lwp_continue";
-#endif
-#if defined (SYS_priocntllst)
- syscall_table[SYS_priocntllst] = "priocntllst";
-#endif
-#if defined (SYS_sleep)
- syscall_table[SYS_sleep] = "sleep";
-#endif
-#if defined (SYS_lwp_sema_wait)
- syscall_table[SYS_lwp_sema_wait] = "_lwp_sema_wait";
-#endif
-#if defined (SYS_lwp_sema_post)
- syscall_table[SYS_lwp_sema_post] = "_lwp_sema_post";
-#endif
-#if defined (SYS_lwp_sema_trywait)
- syscall_table[SYS_lwp_sema_trywait] = "lwp_sema_trywait";
-#endif
-#if defined(SYS_fstatvfs64)
- syscall_table[SYS_fstatvfs64] = "fstatvfs64";
-#endif
-#if defined(SYS_statvfs64)
- syscall_table[SYS_statvfs64] = "statvfs64";
-#endif
-#if defined(SYS_ftruncate64)
- syscall_table[SYS_ftruncate64] = "ftruncate64";
-#endif
-#if defined(SYS_truncate64)
- syscall_table[SYS_truncate64] = "truncate64";
-#endif
-#if defined(SYS_getrlimit64)
- syscall_table[SYS_getrlimit64] = "getrlimit64";
-#endif
-#if defined(SYS_setrlimit64)
- syscall_table[SYS_setrlimit64] = "setrlimit64";
-#endif
-#if defined(SYS_lseek64)
- syscall_table[SYS_lseek64] = "lseek64";
-#endif
-#if defined(SYS_mmap64)
- syscall_table[SYS_mmap64] = "mmap64";
-#endif
-#if defined(SYS_pread64)
- syscall_table[SYS_pread64] = "pread64";
-#endif
-#if defined(SYS_creat64)
- syscall_table[SYS_creat64] = "creat64";
-#endif
-#if defined(SYS_dshmsys)
- syscall_table[SYS_dshmsys] = "dshmsys";
-#endif
-#if defined(SYS_invlpg)
- syscall_table[SYS_invlpg] = "invlpg";
-#endif
-#if defined(SYS_cg_ids)
- syscall_table[SYS_cg_ids] = "cg_ids";
-#endif
-#if defined(SYS_cg_processors)
- syscall_table[SYS_cg_processors] = "cg_processors";
-#endif
-#if defined(SYS_cg_info)
- syscall_table[SYS_cg_info] = "cg_info";
-#endif
-#if defined(SYS_cg_bind)
- syscall_table[SYS_cg_bind] = "cg_bind";
-#endif
-#if defined(SYS_cg_current)
- syscall_table[SYS_cg_current] = "cg_current";
-#endif
-#if defined(SYS_cg_memloc)
- syscall_table[SYS_cg_memloc] = "cg_memloc";
-#endif
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_kill_inferior - kill any currently inferior
-
-SYNOPSIS
-
- void procfs_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?)
-
-*/
-
-static void
-procfs_kill_inferior ()
-{
- target_mourn_inferior ();
-}
-
-/*
-
-LOCAL FUNCTION
-
- unconditionally_kill_inferior - terminate the inferior
-
-SYNOPSIS
-
- static void unconditionally_kill_inferior (struct procinfo *)
-
-DESCRIPTION
-
- Kill the specified 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 (we could call that
- politely_kill_inferior()).
-
-*/
-
-static void
-unconditionally_kill_inferior (pi)
- struct procinfo *pi;
-{
- int ppid;
- struct proc_ctl pctl;
-
- ppid = pi->prstatus.pr_ppid;
-
-#ifdef PROCFS_NEED_CLEAR_CURSIG_FOR_KILL
- /* Alpha OSF/1-3.x procfs needs a clear of the current signal
- before the PIOCKILL, otherwise it might generate a corrupted core
- file for the inferior. */
- ioctl (pi->ctl_fd, PIOCSSIG, NULL);
-#endif
-#ifdef PROCFS_NEED_PIOCSSIG_FOR_KILL
- /* Alpha OSF/1-2.x procfs needs a PIOCSSIG call with a SIGKILL signal
- to kill the inferior, otherwise it might remain stopped with a
- pending SIGKILL.
- We do not check the result of the PIOCSSIG, the inferior might have
- died already. */
- {
- struct siginfo newsiginfo;
-
- memset ((char *) &newsiginfo, 0, sizeof (newsiginfo));
- newsiginfo.si_signo = SIGKILL;
- newsiginfo.si_code = 0;
- newsiginfo.si_errno = 0;
- newsiginfo.si_pid = getpid ();
- newsiginfo.si_uid = getuid ();
- ioctl (pi->ctl_fd, PIOCSSIG, &newsiginfo);
- }
-#else /* PROCFS_NEED_PIOCSSIG_FOR_KILL */
- procfs_write_pckill (pi);
-#endif /* PROCFS_NEED_PIOCSSIG_FOR_KILL */
-
- close_proc_file (pi);
-
-/* Only wait() for our direct children. Our grandchildren zombies are killed
- by the death of their parents. */
-
- if (ppid == getpid())
- wait ((int *) 0);
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_xfer_memory -- copy data to or from inferior memory space
-
-SYNOPSIS
-
- int procfs_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 procfs_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.
- */
-
-static int
-procfs_xfer_memory (memaddr, myaddr, len, dowrite, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int dowrite;
- struct target_ops *target; /* ignored */
-{
- int nbytes = 0;
- struct procinfo *pi;
-
- pi = current_procinfo;
-
- if (lseek(pi->as_fd, (off_t) memaddr, SEEK_SET) == (off_t) memaddr)
- {
- if (dowrite)
- {
- nbytes = write (pi->as_fd, myaddr, len);
- }
- else
- {
- nbytes = read (pi->as_fd, myaddr, len);
- }
- if (nbytes < 0)
- {
- nbytes = 0;
- }
- }
- return (nbytes);
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_store_registers -- copy register values back to inferior
-
-SYNOPSIS
-
- void procfs_store_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)
-
- */
-
-static void
-procfs_store_registers (regno)
- int regno;
-{
- struct procinfo *pi;
-#ifdef PROCFS_USE_READ_WRITE
- struct greg_ctl greg;
- struct fpreg_ctl fpreg;
-#endif
-
- pi = current_procinfo;
-
-#ifdef PROCFS_USE_READ_WRITE
- if (regno != -1)
- {
- procfs_read_status (pi);
- memcpy ((char *) &greg.gregset,
- (char *) &pi->prstatus.pr_lwp.pr_context.uc_mcontext.gregs,
- sizeof (gdb_gregset_t));
- }
- fill_gregset (&greg.gregset, regno);
- greg.cmd = PCSREG;
- write (pi->ctl_fd, &greg, sizeof (greg));
-#else /* PROCFS_USE_READ_WRITE */
- if (regno != -1)
- {
- ioctl (pi->ctl_fd, PIOCGREG, &pi->gregset.gregset);
- }
- fill_gregset (&pi->gregset.gregset, regno);
- ioctl (pi->ctl_fd, PIOCSREG, &pi->gregset.gregset);
-#endif /* PROCFS_USE_READ_WRITE */
-
-#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. */
-
-#ifdef PROCFS_USE_READ_WRITE
- if (regno != -1)
- {
- procfs_read_status (pi);
- memcpy ((char *) &fpreg.fpregset,
- (char *) &pi->prstatus.pr_lwp.pr_context.uc_mcontext.fpregs,
- sizeof (gdb_fpregset_t));
- }
- fill_fpregset (&fpreg.fpregset, regno);
- fpreg.cmd = PCSFPREG;
- write (pi->ctl_fd, &fpreg, sizeof (fpreg));
-#else /* PROCFS_USE_READ_WRITE */
- if (regno != -1)
- {
- ioctl (pi->ctl_fd, PIOCGFPREG, &pi->fpregset.fpregset);
- }
- fill_fpregset (&pi->fpregset.fpregset, regno);
- ioctl (pi->ctl_fd, PIOCSFPREG, &pi->fpregset.fpregset);
-#endif /* PROCFS_USE_READ_WRITE */
-
-#endif /* FP0_REGNUM */
-
-}
-
-/*
-
-LOCAL FUNCTION
-
- init_procinfo - setup a procinfo struct and connect it to a process
-
-SYNOPSIS
-
- struct procinfo * init_procinfo (int pid)
-
-DESCRIPTION
-
- Allocate a procinfo structure, open the /proc file and then set up the
- set of signals and faults that are to be traced. Returns a pointer to
- the new procinfo structure.
-
-NOTES
-
- If proc_init_failed ever gets called, control returns to the command
- processing loop via the standard error handling code.
-
- */
-
-static struct procinfo *
-init_procinfo (pid, kill)
- int pid;
- int kill;
-{
- struct procinfo *pi = (struct procinfo *)
- xmalloc (sizeof (struct procinfo));
- struct sig_ctl sctl;
- struct flt_ctl fctl;
-
- memset ((char *) pi, 0, sizeof (*pi));
- if (!open_proc_file (pid, pi, O_RDWR, 1))
- proc_init_failed (pi, "can't open process file", kill);
-
- /* open_proc_file may modify pid. */
-
- pid = pi -> pid;
-
- /* Add new process to process info list */
-
- pi->next = procinfo_list;
- procinfo_list = pi;
-
- add_fd (pi); /* Add to list for poll/select */
-
- /* Remember some things about the inferior that we will, or might, change
- so that we can restore them when we detach. */
-#ifdef UNIXWARE
- memcpy ((char *) &pi->saved_trace.sigset,
- (char *) &pi->prstatus.pr_sigtrace, sizeof (sigset_t));
- memcpy ((char *) &pi->saved_fltset.fltset,
- (char *) &pi->prstatus.pr_flttrace, sizeof (fltset_t));
- memcpy ((char *) &pi->saved_entryset.sysset,
- (char *) &pi->prstatus.pr_sysentry, sizeof (sysset_t));
- memcpy ((char *) &pi->saved_exitset.sysset,
- (char *) &pi->prstatus.pr_sysexit, sizeof (sysset_t));
-
- /* Set up trace and fault sets, as gdb expects them. */
-
- prfillset (&sctl.sigset);
- notice_signals (pi, &sctl);
- prfillset (&fctl.fltset);
- prdelset (&fctl.fltset, FLTPAGE);
-
-#else /* ! UNIXWARE */
- ioctl (pi->ctl_fd, PIOCGTRACE, &pi->saved_trace.sigset);
- ioctl (pi->ctl_fd, PIOCGHOLD, &pi->saved_sighold.sigset);
- ioctl (pi->ctl_fd, PIOCGFAULT, &pi->saved_fltset.fltset);
- ioctl (pi->ctl_fd, PIOCGENTRY, &pi->saved_entryset.sysset);
- ioctl (pi->ctl_fd, PIOCGEXIT, &pi->saved_exitset.sysset);
-
- /* Set up trace and fault sets, as gdb expects them. */
-
- memset ((char *) &pi->prrun, 0, sizeof (pi->prrun));
- prfillset (&pi->prrun.pr_trace);
- procfs_notice_signals (pid);
- prfillset (&pi->prrun.pr_fault);
- prdelset (&pi->prrun.pr_fault, FLTPAGE);
-#ifdef PROCFS_DONT_TRACE_FAULTS
- premptyset (&pi->prrun.pr_fault);
-#endif
-#endif /* UNIXWARE */
-
- if (!procfs_read_status (pi))
- proc_init_failed (pi, "procfs_read_status failed", kill);
-
- return pi;
-}
-
-/*
-
-LOCAL FUNCTION
-
- create_procinfo - initialize access to a /proc entry
-
-SYNOPSIS
-
- struct procinfo * create_procinfo (int pid)
-
-DESCRIPTION
-
- Allocate a procinfo structure, open the /proc file and then set up the
- set of signals and faults that are to be traced. Returns a pointer to
- the new procinfo structure.
-
-NOTES
-
- If proc_init_failed ever gets called, control returns to the command
- processing loop via the standard error handling code.
-
- */
-
-static struct procinfo *
-create_procinfo (pid)
- int pid;
-{
- struct procinfo *pi;
- struct sig_ctl sctl;
- struct flt_ctl fctl;
-
- pi = find_procinfo (pid, 1);
- if (pi != NULL)
- return pi; /* All done! It already exists */
-
- pi = init_procinfo (pid, 1);
-
-#ifndef UNIXWARE
-/* A bug in Solaris (2.5 at least) causes PIOCWSTOP to hang on LWPs that are
- already stopped, even if they all have PR_ASYNC set. */
- if (!(pi->prstatus.pr_flags & PR_STOPPED))
-#endif
- if (!procfs_write_pcwstop (pi))
- proc_init_failed (pi, "procfs_write_pcwstop failed", 1);
-
-#ifdef PROCFS_USE_READ_WRITE
- fctl.cmd = PCSFAULT;
- if (write (pi->ctl_fd, (char *) &fctl, sizeof (struct flt_ctl)) < 0)
- proc_init_failed (pi, "PCSFAULT failed", 1);
-#else
- if (ioctl (pi->ctl_fd, PIOCSFAULT, &pi->prrun.pr_fault) < 0)
- proc_init_failed (pi, "PIOCSFAULT failed", 1);
-#endif
-
- return pi;
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_exit_handler - handle entry into the _exit syscall
-
-SYNOPSIS
-
- int procfs_exit_handler (pi, syscall_num, why, rtnvalp, statvalp)
-
-DESCRIPTION
-
- This routine is called when an inferior process enters the _exit()
- system call. It continues the process, and then collects the exit
- status and pid which are returned in *statvalp and *rtnvalp. After
- that it returns non-zero to indicate that procfs_wait should wake up.
-
-NOTES
- There is probably a better way to do this.
-
- */
-
-static int
-procfs_exit_handler (pi, syscall_num, why, rtnvalp, statvalp)
- struct procinfo *pi;
- int syscall_num;
- int why;
- int *rtnvalp;
- int *statvalp;
-{
- struct procinfo *temp_pi, *next_pi;
- struct proc_ctl pctl;
-
-#ifdef UNIXWARE
- pctl.cmd = PCRUN;
- pctl.data = PRCFAULT;
-#else
- pi->prrun.pr_flags = PRCFAULT;
-#endif
-
-#ifdef PROCFS_USE_READ_WRITE
- if (write (pi->ctl_fd, (char *)&pctl, sizeof (struct proc_ctl)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) != 0)
-#endif
- perror_with_name (pi->pathname);
-
- if (attach_flag)
- {
- /* Claim it exited (don't call wait). */
- if (info_verbose)
- printf_filtered ("(attached process has exited)\n");
- *statvalp = 0;
- *rtnvalp = inferior_pid;
- }
- else
- {
- *rtnvalp = wait (statvalp);
- if (*rtnvalp >= 0)
- *rtnvalp = pi->pid;
- }
-
- /* Close ALL open proc file handles,
- except the one that called SYS_exit. */
- for (temp_pi = procinfo_list; temp_pi; temp_pi = next_pi)
- {
- next_pi = temp_pi->next;
- if (temp_pi == pi)
- continue; /* Handled below */
- close_proc_file (temp_pi);
- }
- return 1;
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_exec_handler - handle exit from the exec family of syscalls
-
-SYNOPSIS
-
- int procfs_exec_handler (pi, syscall_num, why, rtnvalp, statvalp)
-
-DESCRIPTION
-
- This routine is called when an inferior process is about to finish any
- of the exec() family of system calls. It pretends that we got a
- SIGTRAP (for compatibility with ptrace behavior), and returns non-zero
- to tell procfs_wait to wake up.
-
-NOTES
- This need for compatibility with ptrace is questionable. In the
- future, it shouldn't be necessary.
-
- */
-
-static int
-procfs_exec_handler (pi, syscall_num, why, rtnvalp, statvalp)
- struct procinfo *pi;
- int syscall_num;
- int why;
- int *rtnvalp;
- int *statvalp;
-{
- *statvalp = (SIGTRAP << 8) | 0177;
-
- return 1;
-}
-
-#if defined(SYS_sproc) && !defined(UNIXWARE)
-/* IRIX lwp creation system call */
-
-/*
-
-LOCAL FUNCTION
-
- procfs_sproc_handler - handle exit from the sproc syscall
-
-SYNOPSIS
-
- int procfs_sproc_handler (pi, syscall_num, why, rtnvalp, statvalp)
-
-DESCRIPTION
-
- This routine is called when an inferior process is about to finish an
- sproc() system call. This is the system call that IRIX uses to create
- a lightweight process. When the target process gets this event, we can
- look at rval1 to find the new child processes ID, and create a new
- procinfo struct from that.
-
- After that, it pretends that we got a SIGTRAP, and returns non-zero
- to tell procfs_wait to wake up. Subsequently, wait_for_inferior gets
- woken up, sees the new process and continues it.
-
-NOTES
- We actually never see the child exiting from sproc because we will
- shortly stop the child with PIOCSTOP, which is then registered as the
- event of interest.
- */
-
-static int
-procfs_sproc_handler (pi, syscall_num, why, rtnvalp, statvalp)
- struct procinfo *pi;
- int syscall_num;
- int why;
- int *rtnvalp;
- int *statvalp;
-{
-/* We've just detected the completion of an sproc system call. Now we need to
- setup a procinfo struct for this thread, and notify the thread system of the
- new arrival. */
-
-/* If sproc failed, then nothing interesting happened. Continue the process
- and go back to sleep. */
-
- if (pi->prstatus.pr_errno != 0)
- {
- pi->prrun.pr_flags &= PRSTEP;
- pi->prrun.pr_flags |= PRCFAULT;
-
- if (ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) != 0)
- perror_with_name (pi->pathname);
-
- return 0;
- }
-
- /* At this point, the new thread is stopped at it's first instruction, and
- the parent is stopped at the exit from sproc. */
-
- /* Notify the caller of the arrival of a new thread. */
- create_procinfo (pi->prstatus.pr_rval1);
-
- *rtnvalp = pi->prstatus.pr_rval1;
- *statvalp = (SIGTRAP << 8) | 0177;
-
- return 1;
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_fork_handler - handle exit from the fork syscall
-
-SYNOPSIS
-
- int procfs_fork_handler (pi, syscall_num, why, rtnvalp, statvalp)
-
-DESCRIPTION
-
- This routine is called when an inferior process is about to finish a
- fork() system call. We will open up the new process, and then close
- it, which releases it from the clutches of the debugger.
-
- After that, we continue the target process as though nothing had
- happened.
-
-NOTES
- This is necessary for IRIX because we have to set PR_FORK in order
- to catch the creation of lwps (via sproc()). When an actual fork
- occurs, it becomes necessary to reset the forks debugger flags and
- continue it because we can't hack multiple processes yet.
- */
-
-static int
-procfs_fork_handler (pi, syscall_num, why, rtnvalp, statvalp)
- struct procinfo *pi;
- int syscall_num;
- int why;
- int *rtnvalp;
- int *statvalp;
-{
- struct procinfo *pitemp;
-
-/* At this point, we've detected the completion of a fork (or vfork) call in
- our child. The grandchild is also stopped because we set inherit-on-fork
- earlier. (Note that nobody has the grandchilds' /proc file open at this
- point.) We will release the grandchild from the debugger by opening it's
- /proc file and then closing it. Since run-on-last-close is set, the
- grandchild continues on its' merry way. */
-
-
- pitemp = create_procinfo (pi->prstatus.pr_rval1);
- if (pitemp)
- close_proc_file (pitemp);
-
- if (ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) != 0)
- perror_with_name (pi->pathname);
-
- return 0;
-}
-#endif /* SYS_sproc && !UNIXWARE */
-
-/*
-
-LOCAL FUNCTION
-
- procfs_set_inferior_syscall_traps - setup the syscall traps
-
-SYNOPSIS
-
- void procfs_set_inferior_syscall_traps (struct procinfo *pip)
-
-DESCRIPTION
-
- Called for each "procinfo" (process, thread, or LWP) in the
- inferior, to register for notification of and handlers for
- syscall traps in the inferior.
-
- */
-
-static void
-procfs_set_inferior_syscall_traps (pip)
- struct procinfo *pip;
-{
- procfs_set_syscall_trap (pip, SYS_exit, PROCFS_SYSCALL_ENTRY,
- procfs_exit_handler);
-
-#ifndef PRFS_STOPEXEC
-#ifdef SYS_exec
- procfs_set_syscall_trap (pip, SYS_exec, PROCFS_SYSCALL_EXIT,
- procfs_exec_handler);
-#endif
-#ifdef SYS_execv
- procfs_set_syscall_trap (pip, SYS_execv, PROCFS_SYSCALL_EXIT,
- procfs_exec_handler);
-#endif
-#ifdef SYS_execve
- procfs_set_syscall_trap (pip, SYS_execve, PROCFS_SYSCALL_EXIT,
- procfs_exec_handler);
-#endif
-#endif /* PRFS_STOPEXEC */
-
- /* Setup traps on exit from sproc() */
-
-#ifdef SYS_sproc
- procfs_set_syscall_trap (pip, SYS_sproc, PROCFS_SYSCALL_EXIT,
- procfs_sproc_handler);
- procfs_set_syscall_trap (pip, SYS_fork, PROCFS_SYSCALL_EXIT,
- procfs_fork_handler);
-#ifdef SYS_vfork
- procfs_set_syscall_trap (pip, SYS_vfork, PROCFS_SYSCALL_EXIT,
- procfs_fork_handler);
-#endif
-/* Turn on inherit-on-fork flag so that all children of the target process
- start with tracing flags set. This allows us to trap lwp creation. Note
- that we also have to trap on fork and vfork in order to disable all tracing
- in the targets child processes. */
-
- modify_inherit_on_fork_flag (pip->ctl_fd, 1);
-#endif
-
-#ifdef SYS_lwp_create
- procfs_set_syscall_trap (pip, SYS_lwp_create, PROCFS_SYSCALL_EXIT,
- procfs_lwp_creation_handler);
-#endif
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_init_inferior - initialize target vector and access to a
- /proc entry
-
-SYNOPSIS
-
- void procfs_init_inferior (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. Returns the pid, which may have had
- the thread-id added to it.
-
-NOTES
-
- If proc_init_failed ever gets called, control returns to the command
- processing loop via the standard error handling code.
-
- */
-
-static void
-procfs_init_inferior (pid)
- int pid;
-{
- struct procinfo *pip;
-
- push_target (&procfs_ops);
-
- pip = create_procinfo (pid);
-
- procfs_set_inferior_syscall_traps (pip);
-
- /* create_procinfo may change the pid, so we have to update inferior_pid
- here before calling other gdb routines that need the right pid. */
-
- pid = pip -> pid;
- inferior_pid = pid;
-
- add_thread (pip -> pid); /* Setup initial thread */
-
-#ifdef START_INFERIOR_TRAPS_EXPECTED
- startup_inferior (START_INFERIOR_TRAPS_EXPECTED);
-#else
- /* One trap to exec the shell, one to exec the program being debugged. */
- startup_inferior (2);
-#endif
-}
-
-/*
-
-GLOBAL FUNCTION
-
- procfs_notice_signals
-
-SYNOPSIS
-
- static void procfs_notice_signals (int pid);
-
-DESCRIPTION
-
- When the user changes the state of gdb's signal handling via the
- "handle" command, this function gets called to see if any change
- in the /proc interface is required. It is also called internally
- by other /proc interface functions to initialize the state of
- the traced signal set.
-
- One thing it does is that signals for which the state is "nostop",
- "noprint", and "pass", have their trace bits reset in the pr_trace
- field, so that they are no longer traced. This allows them to be
- delivered directly to the inferior without the debugger ever being
- involved.
- */
-
-static void
-procfs_notice_signals (pid)
- int pid;
-{
- struct procinfo *pi;
- struct sig_ctl sctl;
-
- pi = find_procinfo (pid, 0);
-
-#ifndef HAVE_PRRUN_T
- premptyset (&sctl.sigset);
-#else
- sctl.sigset = pi->prrun.pr_trace;
-#endif
-
- notice_signals (pi, &sctl);
-
-#ifdef HAVE_PRRUN_T
- pi->prrun.pr_trace = sctl.sigset;
-#endif
-}
-
-static void
-notice_signals (pi, sctl)
- struct procinfo *pi;
- struct sig_ctl *sctl;
-{
- int signo;
-
- for (signo = 0; signo < NSIG; signo++)
- {
- if (signal_stop_state (target_signal_from_host (signo)) == 0 &&
- signal_print_state (target_signal_from_host (signo)) == 0 &&
- signal_pass_state (target_signal_from_host (signo)) == 1)
- {
- prdelset (&sctl->sigset, signo);
- }
- else
- {
- praddset (&sctl->sigset, signo);
- }
- }
-#ifdef PROCFS_USE_READ_WRITE
- sctl->cmd = PCSTRACE;
- if (write (pi->ctl_fd, (char *) sctl, sizeof (struct sig_ctl)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCSTRACE, &sctl->sigset))
-#endif
- {
- print_sys_errmsg ("PIOCSTRACE failed", errno);
- }
-}
-
-/*
-
-LOCAL 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.
-
- Also note that we want to turn off the inherit-on-fork flag in
- the child process so that any grand-children start with all
- tracing flags cleared.
- */
-
-static void
-proc_set_exec_trap ()
-{
- struct sys_ctl exitset;
- struct sys_ctl entryset;
- char procname[MAX_PROC_NAME_SIZE];
- int fd;
-
- sprintf (procname, CTL_PROC_NAME_FMT, getpid ());
-#ifdef UNIXWARE
- if ((fd = open (procname, O_WRONLY)) < 0)
-#else
- if ((fd = open (procname, O_RDWR)) < 0)
-#endif
- {
- perror (procname);
- gdb_flush (gdb_stderr);
- _exit (127);
- }
- premptyset (&exitset.sysset);
- premptyset (&entryset.sysset);
-
-#ifdef PRFS_STOPEXEC
- /* Under Alpha OSF/1 we have to use a PIOCSSPCACT ioctl to trace
- exits from exec system calls because of the user level loader. */
- {
- int prfs_flags;
-
- if (ioctl (fd, PIOCGSPCACT, &prfs_flags) < 0)
- {
- perror (procname);
- gdb_flush (gdb_stderr);
- _exit (127);
- }
- prfs_flags |= PRFS_STOPEXEC;
- if (ioctl (fd, PIOCSSPCACT, &prfs_flags) < 0)
- {
- perror (procname);
- gdb_flush (gdb_stderr);
- _exit (127);
- }
- }
-#else /* PRFS_STOPEXEC */
- /* GW: Rationale...
- Not all systems with /proc have all the exec* syscalls with the same
- names. On the SGI, for example, there is no SYS_exec, but there
- *is* a SYS_execv. So, we try to account for that. */
-
-#ifdef SYS_exec
- praddset (&exitset.sysset, SYS_exec);
-#endif
-#ifdef SYS_execve
- praddset (&exitset.sysset, SYS_execve);
-#endif
-#ifdef SYS_execv
- praddset (&exitset.sysset, SYS_execv);
-#endif
-
-#ifdef PROCFS_USE_READ_WRITE
- exitset.cmd = PCSEXIT;
- if (write (fd, (char *) &exitset, sizeof (struct sys_ctl)) < 0)
-#else
- if (ioctl (fd, PIOCSEXIT, &exitset.sysset) < 0)
-#endif
- {
- perror (procname);
- gdb_flush (gdb_stderr);
- _exit (127);
- }
-#endif /* PRFS_STOPEXEC */
-
- praddset (&entryset.sysset, SYS_exit);
-
-#ifdef PROCFS_USE_READ_WRITE
- entryset.cmd = PCSENTRY;
- if (write (fd, (char *) &entryset, sizeof (struct sys_ctl)) < 0)
-#else
- if (ioctl (fd, PIOCSENTRY, &entryset.sysset) < 0)
-#endif
- {
- perror (procname);
- gdb_flush (gdb_stderr);
- _exit (126);
- }
-
- /* Turn off inherit-on-fork flag so that all grand-children of gdb
- start with tracing flags cleared. */
-
- modify_inherit_on_fork_flag (fd, 0);
-
- /* Turn on run-on-last-close flag so that this process will not hang
- if GDB goes away for some reason. */
-
- modify_run_on_last_close_flag (fd, 1);
-
-#ifndef UNIXWARE /* since this is a solaris-ism, we don't want it */
- /* NOTE: revisit when doing thread support for UW */
-#ifdef PR_ASYNC
- {
- long pr_flags;
- struct proc_ctl pctl;
-
-/* Solaris needs this to make procfs treat all threads seperately. Without
- this, all threads halt whenever something happens to any thread. Since
- GDB wants to control all this itself, it needs to set PR_ASYNC. */
-
- pr_flags = PR_ASYNC;
-#ifdef PROCFS_USE_READ_WRITE
- pctl.cmd = PCSET;
- pctl.data = PR_FORK|PR_ASYNC;
- write (fd, (char *) &pctl, sizeof (struct proc_ctl));
-#else
- ioctl (fd, PIOCSET, &pr_flags);
-#endif
- }
-#endif /* PR_ASYNC */
-#endif /* !UNIXWARE */
-}
-
-/*
-
-GLOBAL FUNCTION
-
- proc_iterate_over_mappings -- call function for every mapped space
-
-SYNOPSIS
-
- int proc_iterate_over_mappings (int (*func)())
-
-DESCRIPTION
-
- Given a pointer to a function, call that function for every
- mapped address space, passing it an open file descriptor for
- the file corresponding to that mapped address space (if any)
- and the base address of the mapped space. Quit when we hit
- the end of the mappings or the function returns nonzero.
- */
-
-#ifdef UNIXWARE
-int
-proc_iterate_over_mappings (func)
- int (*func) PARAMS ((int, CORE_ADDR));
-{
- int nmap;
- int fd;
- int funcstat = 0;
- prmap_t *prmaps;
- prmap_t *prmap;
- struct procinfo *pi;
- struct stat sbuf;
-
- pi = current_procinfo;
-
- if (fstat (pi->map_fd, &sbuf) < 0)
- return 0;
-
- nmap = sbuf.st_size / sizeof (prmap_t);
- prmaps = (prmap_t *) alloca (nmap * sizeof(prmap_t));
- if ((lseek (pi->map_fd, 0, SEEK_SET) == 0) &&
- (read (pi->map_fd, (char *) prmaps, nmap * sizeof (prmap_t)) ==
- (nmap * sizeof (prmap_t))))
- {
- int i = 0;
- for (prmap = prmaps; i < nmap && funcstat == 0; ++prmap, ++i)
- {
- char name[sizeof ("/proc/1234567890/object") +
- sizeof (prmap->pr_mapname)];
- sprintf (name, "/proc/%d/object/%s", pi->pid, prmap->pr_mapname);
- if ((fd = open (name, O_RDONLY)) == -1)
- {
- funcstat = 1;
- break;
- }
- funcstat = (*func) (fd, (CORE_ADDR) prmap->pr_vaddr);
- close (fd);
- }
- }
- return (funcstat);
-}
-#else /* UNIXWARE */
-int
-proc_iterate_over_mappings (func)
- int (*func) PARAMS ((int, CORE_ADDR));
-{
- int nmap;
- int fd;
- int funcstat = 0;
- struct prmap *prmaps;
- struct prmap *prmap;
- struct procinfo *pi;
-
- pi = current_procinfo;
-
- if (ioctl (pi->map_fd, PIOCNMAP, &nmap) == 0)
- {
- prmaps = (struct prmap *) alloca ((nmap + 1) * sizeof (*prmaps));
- if (ioctl (pi->map_fd, PIOCMAP, prmaps) == 0)
- {
- for (prmap = prmaps; prmap -> pr_size && funcstat == 0; ++prmap)
- {
- fd = proc_address_to_fd (pi, (CORE_ADDR) prmap -> pr_vaddr, 0);
- funcstat = (*func) (fd, (CORE_ADDR) prmap -> pr_vaddr);
- close (fd);
- }
- }
- }
- return (funcstat);
-}
-#endif /* UNIXWARE */
-
-#if 0 /* Currently unused */
-/*
-
-GLOBAL FUNCTION
-
- proc_base_address -- find base address for segment containing address
-
-SYNOPSIS
-
- CORE_ADDR proc_base_address (CORE_ADDR addr)
-
-DESCRIPTION
-
- Given an address of a location in the inferior, find and return
- the base address of the mapped segment containing that address.
-
- This is used for example, by the shared library support code,
- where we have the pc value for some location in the shared library
- where we are stopped, and need to know the base address of the
- segment containing that address.
-*/
-
-CORE_ADDR
-proc_base_address (addr)
- CORE_ADDR addr;
-{
- int nmap;
- struct prmap *prmaps;
- struct prmap *prmap;
- CORE_ADDR baseaddr = 0;
- struct procinfo *pi;
-
- pi = current_procinfo;
-
- if (ioctl (pi->map_fd, PIOCNMAP, &nmap) == 0)
- {
- prmaps = (struct prmap *) alloca ((nmap + 1) * sizeof (*prmaps));
- if (ioctl (pi->map_fd, PIOCMAP, prmaps) == 0)
- {
- for (prmap = prmaps; prmap -> pr_size; ++prmap)
- {
- if ((prmap -> pr_vaddr <= (caddr_t) addr) &&
- (prmap -> pr_vaddr + prmap -> pr_size > (caddr_t) addr))
- {
- baseaddr = (CORE_ADDR) prmap -> pr_vaddr;
- break;
- }
- }
- }
- }
- return (baseaddr);
-}
-
-#endif /* 0 */
-
-#ifndef UNIXWARE
-/*
-
-LOCAL FUNCTION
-
- proc_address_to_fd -- return open fd for file mapped to address
-
-SYNOPSIS
-
- int proc_address_to_fd (struct procinfo *pi, CORE_ADDR addr, complain)
-
-DESCRIPTION
-
- Given an address in the current inferior's address space, use the
- /proc interface to find an open file descriptor for the file that
- this address was mapped in from. Return -1 if there is no current
- inferior. Print a warning message if there is an inferior but
- the address corresponds to no file (IE a bogus address).
-
-*/
-
-static int
-proc_address_to_fd (pi, addr, complain)
- struct procinfo *pi;
- CORE_ADDR addr;
- int complain;
-{
- int fd = -1;
-
- if ((fd = ioctl (pi->ctl_fd, PIOCOPENM, (caddr_t *) &addr)) < 0)
- {
- if (complain)
- {
- print_sys_errmsg (pi->pathname, errno);
- warning ("can't find mapped file for address 0x%x", addr);
- }
- }
- return (fd);
-}
-#endif /* !UNIXWARE */
-
-/* Attach to process PID, then initialize for debugging it
- and wait for the trace-trap that results from attaching. */
-
-static void
-procfs_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- char *exec_file;
- int pid;
-
- if (!args)
- error_no_arg ("process-id to attach");
-
- pid = atoi (args);
-
- if (pid == getpid()) /* Trying to masturbate? */
- error ("I refuse to debug myself!");
-
- if (from_tty)
- {
- exec_file = (char *) get_exec_file (0);
-
- if (exec_file)
- printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, target_pid_to_str (pid));
- else
- printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
-
- gdb_flush (gdb_stdout);
- }
-
- inferior_pid = pid = do_attach (pid);
- push_target (&procfs_ops);
-}
-
-
-/* Take a program previously attached to and detaches it.
- The program resumes execution and will no longer stop
- on signals, etc. We'd 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
-procfs_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- int siggnal = 0;
-
- if (from_tty)
- {
- char *exec_file = get_exec_file (0);
- if (exec_file == 0)
- exec_file = "";
- printf_unfiltered ("Detaching from program: %s %s\n",
- exec_file, target_pid_to_str (inferior_pid));
- gdb_flush (gdb_stdout);
- }
- if (args)
- siggnal = atoi (args);
-
- do_detach (siggnal);
- inferior_pid = 0;
- unpush_target (&procfs_ops); /* Pop out of handling an inferior */
-}
-
-/* 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
-procfs_prepare_to_store ()
-{
-#ifdef CHILD_PREPARE_TO_STORE
- CHILD_PREPARE_TO_STORE ();
-#endif
-}
-
-/* Print status information about what we're accessing. */
-
-static void
-procfs_files_info (ignore)
- struct target_ops *ignore;
-{
- printf_unfiltered ("\tUsing the running image of %s %s via /proc.\n",
- attach_flag? "attached": "child", target_pid_to_str (inferior_pid));
-}
-
-/* ARGSUSED */
-static void
-procfs_open (arg, from_tty)
- char *arg;
- int from_tty;
-{
- error ("Use the \"run\" command to start a Unix child process.");
-}
-
-/*
-
-LOCAL FUNCTION
-
- do_attach -- attach to an already existing process
-
-SYNOPSIS
-
- int do_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. (I have changed this version to do so, too. All you
- have to do is "continue" to make it go on. -- gnu@cygnus.com)
-
-*/
-
-static int
-do_attach (pid)
- int pid;
-{
- struct procinfo *pi;
- struct sig_ctl sctl;
- struct flt_ctl fctl;
- int nlwp, *lwps;
-
- pi = init_procinfo (pid, 0);
-
-#ifdef PIOCLWPIDS
- nlwp = pi->prstatus.pr_nlwp;
- lwps = alloca ((2 * nlwp + 2) * sizeof (id_t));
-
- if (ioctl (pi->ctl_fd, PIOCLWPIDS, lwps))
- {
- print_sys_errmsg (pi -> pathname, errno);
- error ("PIOCLWPIDS failed");
- }
-#else /* PIOCLWPIDS */
- nlwp = 1;
- lwps = alloca ((2 * nlwp + 2) * sizeof *lwps);
- lwps[0] = 0;
-#endif
- for (; nlwp > 0; nlwp--, lwps++)
- {
- /* First one has already been created above. */
- if ((pi = find_procinfo ((*lwps << 16) | pid, 1)) == 0)
- pi = init_procinfo ((*lwps << 16) | pid, 0);
-
- if (THE_PR_LWP(pi->prstatus).pr_flags & (PR_STOPPED | PR_ISTOP))
- {
- pi->was_stopped = 1;
- }
- else
- {
- pi->was_stopped = 0;
- if (1 || query ("Process is currently running, stop it? "))
- {
- long cmd;
- /* Make it run again when we close it. */
- modify_run_on_last_close_flag (pi->ctl_fd, 1);
-#ifdef PROCFS_USE_READ_WRITE
- cmd = PCSTOP;
- if (write (pi->ctl_fd, (char *) &cmd, sizeof (long)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCSTOP, &pi->prstatus) < 0)
-#endif
- {
- print_sys_errmsg (pi->pathname, errno);
- close_proc_file (pi);
- error ("PIOCSTOP failed");
- }
-#ifdef UNIXWARE
- if (!procfs_read_status (pi))
- {
- print_sys_errmsg (pi->pathname, errno);
- close_proc_file (pi);
- error ("procfs_read_status failed");
- }
-#endif
- pi->nopass_next_sigstop = 1;
- }
- else
- {
- printf_unfiltered ("Ok, gdb will wait for %s to stop.\n",
- target_pid_to_str (pi->pid));
- }
- }
-
-#ifdef PROCFS_USE_READ_WRITE
- fctl.cmd = PCSFAULT;
- if (write (pi->ctl_fd, (char *) &fctl, sizeof (struct flt_ctl)) < 0)
- print_sys_errmsg ("PCSFAULT failed", errno);
-#else /* PROCFS_USE_READ_WRITE */
- if (ioctl (pi->ctl_fd, PIOCSFAULT, &pi->prrun.pr_fault))
- {
- print_sys_errmsg ("PIOCSFAULT failed", errno);
- }
- if (ioctl (pi->ctl_fd, PIOCSTRACE, &pi->prrun.pr_trace))
- {
- print_sys_errmsg ("PIOCSTRACE failed", errno);
- }
- add_thread (pi->pid);
- procfs_set_inferior_syscall_traps (pi);
-#endif /* PROCFS_USE_READ_WRITE */
- }
- attach_flag = 1;
- return (pi->pid);
-}
-
-/*
-
-LOCAL FUNCTION
-
- do_detach -- detach from an attached-to process
-
-SYNOPSIS
-
- void do_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).
- */
-
-static void
-do_detach (signal)
- int signal;
-{
- struct procinfo *pi;
-
- for (pi = procinfo_list; pi; pi = pi->next)
- {
- if (signal)
- {
- set_proc_siginfo (pi, signal);
- }
-#ifdef PROCFS_USE_READ_WRITE
- pi->saved_exitset.cmd = PCSEXIT;
- if (write (pi->ctl_fd, (char *) &pi->saved_exitset,
- sizeof (struct sys_ctl)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCSEXIT, &pi->saved_exitset.sysset) < 0)
-#endif
- {
- print_sys_errmsg (pi->pathname, errno);
- printf_unfiltered ("PIOCSEXIT failed.\n");
- }
-#ifdef PROCFS_USE_READ_WRITE
- pi->saved_entryset.cmd = PCSENTRY;
- if (write (pi->ctl_fd, (char *) &pi->saved_entryset,
- sizeof (struct sys_ctl)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCSENTRY, &pi->saved_entryset.sysset) < 0)
-#endif
- {
- print_sys_errmsg (pi->pathname, errno);
- printf_unfiltered ("PIOCSENTRY failed.\n");
- }
-#ifdef PROCFS_USE_READ_WRITE
- pi->saved_trace.cmd = PCSTRACE;
- if (write (pi->ctl_fd, (char *) &pi->saved_trace,
- sizeof (struct sig_ctl)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCSTRACE, &pi->saved_trace.sigset) < 0)
-#endif
- {
- print_sys_errmsg (pi->pathname, errno);
- printf_unfiltered ("PIOCSTRACE failed.\n");
- }
-#ifndef UNIXWARE
- if (ioctl (pi->ctl_fd, PIOCSHOLD, &pi->saved_sighold.sigset) < 0)
- {
- print_sys_errmsg (pi->pathname, errno);
- printf_unfiltered ("PIOSCHOLD failed.\n");
- }
-#endif
-#ifdef PROCFS_USE_READ_WRITE
- pi->saved_fltset.cmd = PCSFAULT;
- if (write (pi->ctl_fd, (char *) &pi->saved_fltset,
- sizeof (struct flt_ctl)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCSFAULT, &pi->saved_fltset.fltset) < 0)
-#endif
- {
- print_sys_errmsg (pi->pathname, errno);
- printf_unfiltered ("PIOCSFAULT failed.\n");
- }
- if (!procfs_read_status (pi))
- {
- print_sys_errmsg (pi->pathname, errno);
- printf_unfiltered ("procfs_read_status failed.\n");
- }
- else
- {
- if (signal
- || (THE_PR_LWP(pi->prstatus).pr_flags & (PR_STOPPED | PR_ISTOP)))
- {
- long cmd;
- struct proc_ctl pctl;
-
- if (signal || !pi->was_stopped ||
- query ("Was stopped when attached, make it runnable again? "))
- {
- /* Clear any pending signal if we want to detach without
- a signal. */
- if (signal == 0)
- set_proc_siginfo (pi, signal);
-
- /* Clear any fault that might have stopped it. */
-#ifdef PROCFS_USE_READ_WRITE
- cmd = PCCFAULT;
- if (write (pi->ctl_fd, (char *) &cmd, sizeof (long)) < 0)
-#else
- if (ioctl (pi->ctl_fd, PIOCCFAULT, 0))
-#endif
- {
- print_sys_errmsg (pi->pathname, errno);
- printf_unfiltered ("PIOCCFAULT failed.\n");
- }
-
- /* Make it run again when we close it. */
-
- modify_run_on_last_close_flag (pi->ctl_fd, 1);
- }
- }
- }
- close_proc_file (pi);
- }
- attach_flag = 0;
-}
-
-/* emulate wait() as much as possible.
- Wait for child to do something. Return pid of child, or -1 in case
- of error; store status in *OURSTATUS.
-
- 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.
-
- 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. */
-static int
-procfs_wait (pid, ourstatus)
- int pid;
- struct target_waitstatus *ourstatus;
-{
- short what;
- short why;
- int statval = 0;
- int checkerr = 0;
- int rtnval = -1;
- struct procinfo *pi;
- struct proc_ctl pctl;
-
-scan_again:
-
- /* handle all syscall events first, otherwise we might not
- notice a thread was created until too late. */
-
- for (pi = procinfo_list; pi; pi = pi->next)
- {
- if (!pi->had_event)
- continue;
-
- if (! (THE_PR_LWP(pi->prstatus).pr_flags & (PR_STOPPED | PR_ISTOP)) )
- continue;
-
- why = THE_PR_LWP(pi->prstatus).pr_why;
- what = THE_PR_LWP(pi->prstatus).pr_what;
- if (why == PR_SYSENTRY || why == PR_SYSEXIT)
- {
- int i;
- int found_handler = 0;
-
- for (i = 0; i < pi->num_syscall_handlers; i++)
- if (pi->syscall_handlers[i].syscall_num == what)
- {
- found_handler = 1;
- pi->saved_rtnval = pi->pid;
- pi->saved_statval = 0;
- if (!pi->syscall_handlers[i].func
- (pi, what, why, &pi->saved_rtnval, &pi->saved_statval))
- pi->had_event = 0;
- break;
- }
-
- if (!found_handler)
- {
- if (why == PR_SYSENTRY)
- error ("PR_SYSENTRY, unhandled system call %d", what);
- else
- error ("PR_SYSEXIT, unhandled system call %d", what);
- }
- }
- }
-
- /* find a relevant process with an event */
-
- for (pi = procinfo_list; pi; pi = pi->next)
- if (pi->had_event && (pid == -1 || pi->pid == pid))
- break;
-
- if (!pi)
- {
- wait_fd ();
- goto scan_again;
- }
-
- if (!checkerr
- && !(THE_PR_LWP(pi->prstatus).pr_flags & (PR_STOPPED | PR_ISTOP)))
- {
- if (!procfs_write_pcwstop (pi))
- {
- checkerr++;
- }
- }
- if (checkerr)
- {
- if (errno == ENOENT)
- {
- /* XXX Fixme -- what to do if attached? Can't call wait... */
- rtnval = wait (&statval);
- if ((rtnval) != (PIDGET (inferior_pid)))
- {
- print_sys_errmsg (pi->pathname, errno);
- error ("procfs_wait: wait failed, returned %d", rtnval);
- /* NOTREACHED */
- }
- }
- else
- {
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCSTATUS or PIOCWSTOP failed.");
- /* NOTREACHED */
- }
- }
- else if (THE_PR_LWP(pi->prstatus).pr_flags & (PR_STOPPED | PR_ISTOP))
- {
-#ifdef UNIXWARE
- rtnval = pi->prstatus.pr_pid;
-#else
- rtnval = pi->pid;
-#endif
- why = THE_PR_LWP(pi->prstatus).pr_why;
- what = THE_PR_LWP(pi->prstatus).pr_what;
-
- switch (why)
- {
- case PR_SIGNALLED:
- statval = (what << 8) | 0177;
- break;
- case PR_SYSENTRY:
- case PR_SYSEXIT:
- rtnval = pi->saved_rtnval;
- statval = pi->saved_statval;
- break;
- case PR_REQUESTED:
- statval = (SIGSTOP << 8) | 0177;
- break;
- case PR_JOBCONTROL:
- statval = (what << 8) | 0177;
- break;
- case PR_FAULTED:
- switch (what)
- {
-#ifdef FLTWATCH
- case FLTWATCH:
- statval = (SIGTRAP << 8) | 0177;
- break;
-#endif
-#ifdef FLTKWATCH
- case FLTKWATCH:
- statval = (SIGTRAP << 8) | 0177;
- break;
-#endif
-#ifndef FAULTED_USE_SIGINFO
- /* Irix, contrary to the documentation, fills in 0 for si_signo.
- Solaris fills in si_signo. I'm not sure about others. */
- 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 */
-#endif /* not FAULTED_USE_SIGINFO */
- default:
- /* Use the signal which the kernel assigns. This is better than
- trying to second-guess it from the fault. In fact, I suspect
- that FLTACCESS can be either SIGSEGV or SIGBUS. */
- statval =
- ((THE_PR_LWP(pi->prstatus).pr_info.si_signo) << 8) | 0177;
- break;
- }
- break;
- default:
- error ("PIOCWSTOP, unknown why %d, what %d", why, what);
- }
- /* Stop all the other threads when any of them stops. */
-
- {
- struct procinfo *procinfo, *next_pi;
-
- for (procinfo = procinfo_list; procinfo; procinfo = next_pi)
- {
- next_pi = procinfo->next;
- if (!procinfo->had_event)
- {
-#ifdef PROCFS_USE_READ_WRITE
- long cmd = PCSTOP;
- if (write (pi->ctl_fd, (char *) &cmd, sizeof (long)) < 0)
- {
- print_sys_errmsg (procinfo->pathname, errno);
- error ("PCSTOP failed");
- }
-#else
- /* A bug in Solaris (2.5) causes us to hang when trying to
- stop a stopped process. So, we have to check first in
- order to avoid the hang. */
- if (!procfs_read_status (procinfo))
- {
- /* The LWP has apparently terminated. */
- if (info_verbose)
- printf_filtered ("LWP %d doesn't respond.\n",
- (procinfo->pid >> 16) & 0xffff);
- close_proc_file (procinfo);
- continue;
- }
-
- if (!(procinfo->prstatus.pr_flags & PR_STOPPED))
- if (ioctl (procinfo->ctl_fd, PIOCSTOP, &procinfo->prstatus)
- < 0)
- {
- print_sys_errmsg (procinfo->pathname, errno);
- warning ("PIOCSTOP failed");
- }
-#endif
- }
- }
- }
- }
- else
- {
- error ("PIOCWSTOP, stopped for unknown/unhandled reason, flags %#x",
- THE_PR_LWP(pi->prstatus).pr_flags);
- }
-
- store_waitstatus (ourstatus, statval);
-
- if (rtnval == -1) /* No more children to wait for */
- {
- warning ("Child process unexpectedly missing");
- /* Claim it exited with unknown signal. */
- ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
- ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
- return rtnval;
- }
-
- pi->had_event = 0; /* Indicate that we've seen this one */
- return (rtnval);
-}
-
-/*
-
-LOCAL FUNCTION
-
- set_proc_siginfo - set a process's current signal info
-
-SYNOPSIS
-
- void set_proc_siginfo (struct procinfo *pip, int signo);
-
-DESCRIPTION
-
- Given a pointer to a process info struct in PIP and a signal number
- in SIGNO, set the process's current signal and its associated signal
- information. The signal will be delivered to the process immediately
- after execution is resumed, even if it is being held. In addition,
- this particular delivery will not cause another PR_SIGNALLED stop
- even if the signal is being traced.
-
- If we are not delivering the same signal that the prstatus siginfo
- struct contains information about, then synthesize a siginfo struct
- to match the signal we are doing to deliver, make it of the type
- "generated by a user process", and send this synthesized copy. When
- used to set the inferior's signal state, this will be required if we
- are not currently stopped because of a traced signal, or if we decide
- to continue with a different signal.
-
- Note that when continuing the inferior from a stop due to receipt
- of a traced signal, we either have set PRCSIG to clear the existing
- signal, or we have to call this function to do a PIOCSSIG with either
- the existing siginfo struct from pr_info, or one we have synthesized
- appropriately for the signal we want to deliver. Otherwise if the
- signal is still being traced, the inferior will immediately stop
- again.
-
- See siginfo(5) for more details.
-*/
-
-static void
-set_proc_siginfo (pip, signo)
- struct procinfo *pip;
- int signo;
-{
- struct siginfo newsiginfo;
- struct siginfo *sip;
- struct sigi_ctl sictl;
-
-#ifdef PROCFS_DONT_PIOCSSIG_CURSIG
- /* With Alpha OSF/1 procfs, the kernel gets really confused if it
- receives a PIOCSSIG with a signal identical to the current signal,
- it messes up the current signal. Work around the kernel bug. */
- if (signo == THE_PR_LWP(pip->prstatus).pr_cursig)
- return;
-#endif
-
-#ifdef UNIXWARE
- if (signo == THE_PR_LWP(pip->prstatus).pr_info.si_signo)
- {
- memcpy ((char *) &sictl.siginfo, (char *) &pip->prstatus.pr_lwp.pr_info,
- sizeof (siginfo_t));
- }
-#else
- if (signo == THE_PR_LWP(pip->prstatus).pr_info.si_signo)
- {
- sip = &pip -> prstatus.pr_info;
- }
-#endif
- else
- {
-#ifdef UNIXWARE
- siginfo_t *sip = &sictl.siginfo;
- memset ((char *) sip, 0, sizeof (siginfo_t));
-#else
- memset ((char *) &newsiginfo, 0, sizeof (newsiginfo));
- sip = &newsiginfo;
-#endif
- sip -> si_signo = signo;
- sip -> si_code = 0;
- sip -> si_errno = 0;
- sip -> si_pid = getpid ();
- sip -> si_uid = getuid ();
- }
-#ifdef PROCFS_USE_READ_WRITE
- sictl.cmd = PCSSIG;
- if (write (pip->ctl_fd, (char *) &sictl, sizeof (struct sigi_ctl)) < 0)
-#else
- if (ioctl (pip->ctl_fd, PIOCSSIG, sip) < 0)
-#endif
- {
- print_sys_errmsg (pip -> pathname, errno);
- warning ("PIOCSSIG failed");
- }
-}
-
-/* Resume execution of process PID. If STEP is nozero, then
- just single step it. If SIGNAL is nonzero, restart it with that
- signal activated. */
-
-static void
-procfs_resume (pid, step, signo)
- int pid;
- int step;
- enum target_signal signo;
-{
- int signal_to_pass;
- struct procinfo *pi, *procinfo, *next_pi;
- struct proc_ctl pctl;
-
- pi = find_procinfo (pid == -1 ? inferior_pid : pid, 0);
-
- errno = 0;
-#ifdef UNIXWARE
- pctl.cmd = PCRUN;
- pctl.data = PRCFAULT;
-#else
- pi->prrun.pr_flags = PRSTRACE | PRSFAULT | PRCFAULT;
-#endif
-
-#if 0
- /* It should not be necessary. If the user explicitly changes the value,
- value_assign calls write_register_bytes, which writes it. */
-/* 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. */
-
-#ifdef PRSVADDR_BROKEN
-/* Can't do this under Solaris running on a Sparc, as there seems to be no
- place to put nPC. In fact, if you use this, nPC seems to be set to some
- random garbage. We have to rely on the fact that PC and nPC have been
- written previously via PIOCSREG during a register flush. */
-
- pi->prrun.pr_vaddr = (caddr_t) *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
- pi->prrun.pr_flags != PRSVADDR;
-#endif
-#endif
-
- if (signo == TARGET_SIGNAL_STOP && pi->nopass_next_sigstop)
- /* When attaching to a child process, if we forced it to stop with
- a PIOCSTOP, then we will have set the nopass_next_sigstop flag.
- Upon resuming the first time after such a stop, we explicitly
- inhibit sending it another SIGSTOP, which would be the normal
- result of default signal handling. One potential drawback to
- this is that we will also ignore any attempt to by the user
- to explicitly continue after the attach with a SIGSTOP. Ultimately
- this problem should be dealt with by making the routines that
- deal with the inferior a little smarter, and possibly even allow
- an inferior to continue running at the same time as gdb. (FIXME?) */
- signal_to_pass = 0;
- else if (signo == TARGET_SIGNAL_TSTP
- && THE_PR_LWP(pi->prstatus).pr_cursig == SIGTSTP
- && THE_PR_LWP(pi->prstatus).pr_action.sa_handler == SIG_DFL
- )
-
- /* We are about to pass the inferior a SIGTSTP whose action is
- SIG_DFL. The SIG_DFL action for a SIGTSTP is to stop
- (notifying the parent via wait()), and then keep going from the
- same place when the parent is ready for you to keep going. So
- under the debugger, it should do nothing (as if the program had
- been stopped and then later resumed. Under ptrace, this
- happens for us, but under /proc, the system obligingly stops
- the process, and wait_for_inferior would have no way of
- distinguishing that type of stop (which indicates that we
- should just start it again), with a stop due to the pr_trace
- field of the prrun_t struct.
-
- Note that if the SIGTSTP is being caught, we *do* need to pass it,
- because the handler needs to get executed. */
- signal_to_pass = 0;
- else
- signal_to_pass = target_signal_to_host (signo);
-
- if (signal_to_pass)
- {
- set_proc_siginfo (pi, signal_to_pass);
- }
- else
- {
-#ifdef UNIXWARE
- pctl.data |= PRCSIG;
-#else
- pi->prrun.pr_flags |= PRCSIG;
-#endif
- }
- pi->nopass_next_sigstop = 0;
- if (step)
- {
-#ifdef UNIXWARE
- pctl.data |= PRSTEP;
-#else
- pi->prrun.pr_flags |= PRSTEP;
-#endif
- }
- pi->had_event = 0;
- /* Don't try to start a process unless it's stopped on an
- `event of interest'. Doing so will cause errors. */
-
- if (!procfs_read_status (pi))
- {
- /* The LWP has apparently terminated. */
- if (info_verbose)
- printf_filtered ("LWP %d doesn't respond.\n",
- (pi->pid >> 16) & 0xffff);
- close_proc_file (pi);
- }
- else
- {
-#ifdef PROCFS_USE_READ_WRITE
- if (write (pi->ctl_fd, (char *) &pctl, sizeof (struct proc_ctl)) < 0)
-#else
- if ((pi->prstatus.pr_flags & PR_ISTOP)
- && ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) != 0)
-#endif
- {
- /* The LWP has apparently terminated. */
- if (info_verbose)
- printf_filtered ("LWP %d doesn't respond.\n",
- (pi->pid >> 16) & 0xffff);
- close_proc_file (pi);
- }
- }
-
- /* Continue all the other threads that haven't had an event of interest.
- Also continue them if they have NOPASS_NEXT_SIGSTOP set; this is only
- set by do_attach, and means this is the first resume after an attach.
- All threads were CSTOP'd by do_attach, and should be resumed now. */
-
- if (pid == -1)
- for (procinfo = procinfo_list; procinfo; procinfo = next_pi)
- {
- next_pi = procinfo->next;
- if (pi != procinfo)
- if (!procinfo->had_event ||
- (procinfo->nopass_next_sigstop && signo == TARGET_SIGNAL_STOP))
- {
- procinfo->had_event = procinfo->nopass_next_sigstop = 0;
-#ifdef PROCFS_USE_READ_WRITE
- pctl.data = PRCFAULT | PRCSIG;
- if (write (procinfo->ctl_fd, (char *) &pctl,
- sizeof (struct proc_ctl)) < 0)
- {
- if (!procfs_read_status (procinfo))
- fprintf_unfiltered(gdb_stderr,
- "procfs_read_status failed, errno=%d\n",
- errno);
- print_sys_errmsg (procinfo->pathname, errno);
- error ("PCRUN failed");
- }
-#else
- procinfo->prrun.pr_flags &= PRSTEP;
- procinfo->prrun.pr_flags |= PRCFAULT | PRCSIG;
- if (!procfs_read_status (procinfo))
- {
- /* The LWP has apparently terminated. */
- if (info_verbose)
- printf_filtered ("LWP %d doesn't respond.\n",
- (procinfo->pid >> 16) & 0xffff);
- close_proc_file (procinfo);
- continue;
- }
-
- /* Don't try to start a process unless it's stopped on an
- `event of interest'. Doing so will cause errors. */
-
- if ((procinfo->prstatus.pr_flags & PR_ISTOP)
- && ioctl (procinfo->ctl_fd, PIOCRUN, &procinfo->prrun) < 0)
- {
- if (!procfs_read_status (procinfo))
- fprintf_unfiltered(gdb_stderr,
- "procfs_read_status failed, errno=%d\n",
- errno);
- print_sys_errmsg (procinfo->pathname, errno);
- warning ("PIOCRUN failed");
- }
-#endif
- }
- procfs_read_status (procinfo);
- }
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_fetch_registers -- fetch current registers from inferior
-
-SYNOPSIS
-
- void procfs_fetch_registers (int regno)
-
-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.
-
-*/
-
-static void
-procfs_fetch_registers (regno)
- int regno;
-{
- struct procinfo *pi;
-
- pi = current_procinfo;
-
-#ifdef UNIXWARE
- if (procfs_read_status (pi))
- {
- supply_gregset (&pi->prstatus.pr_lwp.pr_context.uc_mcontext.gregs);
-#if defined (FP0_REGNUM)
- supply_fpregset (&pi->prstatus.pr_lwp.pr_context.uc_mcontext.fpregs);
-#endif
- }
-#else /* UNIXWARE */
- if (ioctl (pi->ctl_fd, PIOCGREG, &pi->gregset.gregset) != -1)
- {
- supply_gregset (&pi->gregset.gregset);
- }
-#if defined (FP0_REGNUM)
- if (ioctl (pi->ctl_fd, PIOCGFPREG, &pi->fpregset.fpregset) != -1)
- {
- supply_fpregset (&pi->fpregset.fpregset);
- }
-#endif
-#endif /* UNIXWARE */
-}
-
-/*
-
-LOCAL FUNCTION
-
- proc_init_failed - called when /proc access initialization fails
-fails
-
-SYNOPSIS
-
- static void proc_init_failed (struct procinfo *pi,
- char *why, int kill_p)
-
-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. If KILL_P is true, sends SIGKILL.
- */
-
-static void
-proc_init_failed (pi, why, kill_p)
- struct procinfo *pi;
- char *why;
- int kill_p;
-{
- print_sys_errmsg (pi->pathname, errno);
- if (kill_p)
- kill (pi->pid, SIGKILL);
- close_proc_file (pi);
- error (why);
- /* NOTREACHED */
-}
-
-/*
-
-LOCAL FUNCTION
-
- close_proc_file - close any currently open /proc entry
-
-SYNOPSIS
-
- static void close_proc_file (struct procinfo *pip)
-
-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
-close_proc_file (pip)
- struct procinfo *pip;
-{
- struct procinfo *procinfo;
-
- delete_thread (pip->pid); /* remove thread from GDB's thread list */
- remove_fd (pip); /* Remove fd from poll/select list */
-
- close (pip->ctl_fd);
-#ifdef HAVE_MULTIPLE_PROC_FDS
- close (pip->as_fd);
- close (pip->status_fd);
- close (pip->map_fd);
-#endif
-
- free (pip -> pathname);
-
- /* Unlink pip from the procinfo chain. Note pip might not be on the list. */
-
- if (procinfo_list == pip)
- procinfo_list = pip->next;
- else
- {
- for (procinfo = procinfo_list; procinfo; procinfo = procinfo->next)
- {
- if (procinfo->next == pip)
- {
- procinfo->next = pip->next;
- break;
- }
- }
- free (pip);
- }
-}
-
-/*
-
-LOCAL FUNCTION
-
- open_proc_file - open a /proc entry for a given process id
-
-SYNOPSIS
-
- static int open_proc_file (int pid, struct procinfo *pip, int mode)
-
-DESCRIPTION
-
- Given a process id and a mode, close the existing open /proc
- entry (if any) and open one for the new process id, in the
- specified mode. 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".
-
- Note that for Solaris, the process-id also includes an LWP-id, so we
- actually attempt to open that. If we are handed a pid with a 0 LWP-id,
- then we will ask the kernel what it is and add it to the pid. Hence,
- the pid can be changed by us.
- */
-
-static int
-open_proc_file (pid, pip, mode, control)
- int pid;
- struct procinfo *pip;
- int mode;
- int control;
-{
- int tmp, tmpfd;
-
- pip -> next = NULL;
- pip -> had_event = 0;
- pip -> pathname = xmalloc (MAX_PROC_NAME_SIZE);
- pip -> pid = pid;
-
-#ifndef PIOCOPENLWP
- tmp = pid;
-#else
- tmp = pid & 0xffff;
-#endif
-
-#ifdef HAVE_MULTIPLE_PROC_FDS
- sprintf (pip->pathname, STATUS_PROC_NAME_FMT, tmp);
- if ((pip->status_fd = open (pip->pathname, O_RDONLY)) < 0)
- {
- return 0;
- }
-
- sprintf (pip->pathname, AS_PROC_NAME_FMT, tmp);
- if ((pip->as_fd = open (pip->pathname, O_RDWR)) < 0)
- {
- close (pip->status_fd);
- return 0;
- }
-
- sprintf (pip->pathname, MAP_PROC_NAME_FMT, tmp);
- if ((pip->map_fd = open (pip->pathname, O_RDONLY)) < 0)
- {
- close (pip->status_fd);
- close (pip->as_fd);
- return 0;
- }
-
- if (control)
- {
- sprintf (pip->pathname, CTL_PROC_NAME_FMT, tmp);
- if ((pip->ctl_fd = open (pip->pathname, O_WRONLY)) < 0)
- {
- close (pip->status_fd);
- close (pip->as_fd);
- close (pip->map_fd);
- return 0;
- }
- }
-
-#else /* HAVE_MULTIPLE_PROC_FDS */
- sprintf (pip -> pathname, CTL_PROC_NAME_FMT, tmp);
-
- if ((tmpfd = open (pip -> pathname, mode)) < 0)
- return 0;
-
-#ifndef PIOCOPENLWP
- pip -> ctl_fd = tmpfd;
- pip -> as_fd = tmpfd;
- pip -> map_fd = tmpfd;
- pip -> status_fd = tmpfd;
-#else
- tmp = (pid >> 16) & 0xffff; /* Extract thread id */
-
- if (tmp == 0)
- { /* Don't know thread id yet */
- if (ioctl (tmpfd, PIOCSTATUS, &pip -> prstatus) < 0)
- {
- print_sys_errmsg (pip -> pathname, errno);
- close (tmpfd);
- error ("open_proc_file: PIOCSTATUS failed");
- }
-
- tmp = pip -> prstatus.pr_who; /* Get thread id from prstatus_t */
- pip -> pid = (tmp << 16) | pid; /* Update pip */
- }
-
- if ((pip -> ctl_fd = ioctl (tmpfd, PIOCOPENLWP, &tmp)) < 0)
- {
- close (tmpfd);
- return 0;
- }
-
-#ifdef PIOCSET /* New method */
- {
- long pr_flags;
- pr_flags = PR_ASYNC;
- ioctl (pip -> ctl_fd, PIOCSET, &pr_flags);
- }
-#endif
-
- /* keep extra fds in sync */
- pip->as_fd = pip->ctl_fd;
- pip->map_fd = pip->ctl_fd;
- pip->status_fd = pip->ctl_fd;
-
- close (tmpfd); /* All done with main pid */
-#endif /* PIOCOPENLWP */
-
-#endif /* HAVE_MULTIPLE_PROC_FDS */
-
- return 1;
-}
-
-static char *
-mappingflags (flags)
- long flags;
-{
- static char asciiflags[8];
-
- strcpy (asciiflags, "-------");
-#if defined (MA_PHYS)
- if (flags & MA_PHYS) asciiflags[0] = 'd';
-#endif
- if (flags & MA_STACK) asciiflags[1] = 's';
- if (flags & MA_BREAK) asciiflags[2] = 'b';
- if (flags & MA_SHARED) asciiflags[3] = 's';
- if (flags & MA_READ) asciiflags[4] = 'r';
- if (flags & MA_WRITE) asciiflags[5] = 'w';
- if (flags & MA_EXEC) asciiflags[6] = 'x';
- return (asciiflags);
-}
-
-static void
-info_proc_flags (pip, summary)
- struct procinfo *pip;
- int summary;
-{
- struct trans *transp;
-#ifdef UNIXWARE
- long flags = pip->prstatus.pr_flags | pip->prstatus.pr_lwp.pr_flags;
-#else
- long flags = pip->prstatus.pr_flags;
-#endif
-
- printf_filtered ("%-32s", "Process status flags:");
- if (!summary)
- {
- printf_filtered ("\n\n");
- }
- for (transp = pr_flag_table; transp -> name != NULL; transp++)
- {
- if (flags & transp -> value)
- {
- if (summary)
- {
- printf_filtered ("%s ", transp -> name);
- }
- else
- {
- printf_filtered ("\t%-16s %s.\n", transp -> name, transp -> desc);
- }
- }
- }
- printf_filtered ("\n");
-}
-
-static void
-info_proc_stop (pip, summary)
- struct procinfo *pip;
- int summary;
-{
- struct trans *transp;
- int why;
- int what;
-
- why = THE_PR_LWP(pip->prstatus).pr_why;
- what = THE_PR_LWP(pip->prstatus).pr_what;
-
- if (THE_PR_LWP(pip->prstatus).pr_flags & PR_STOPPED)
- {
- printf_filtered ("%-32s", "Reason for stopping:");
- if (!summary)
- {
- printf_filtered ("\n\n");
- }
- for (transp = pr_why_table; transp -> name != NULL; transp++)
- {
- if (why == transp -> value)
- {
- if (summary)
- {
- printf_filtered ("%s ", transp -> name);
- }
- else
- {
- printf_filtered ("\t%-16s %s.\n",
- transp -> name, transp -> desc);
- }
- break;
- }
- }
-
- /* Use the pr_why field to determine what the pr_what field means, and
- print more information. */
-
- switch (why)
- {
- case PR_REQUESTED:
- /* pr_what is unused for this case */
- break;
- case PR_JOBCONTROL:
- case PR_SIGNALLED:
- if (summary)
- {
- printf_filtered ("%s ", signalname (what));
- }
- else
- {
- printf_filtered ("\t%-16s %s.\n", signalname (what),
- safe_strsignal (what));
- }
- break;
- case PR_SYSENTRY:
- if (summary)
- {
- printf_filtered ("%s ", syscallname (what));
- }
- else
- {
- printf_filtered ("\t%-16s %s.\n", syscallname (what),
- "Entered this system call");
- }
- break;
- case PR_SYSEXIT:
- if (summary)
- {
- printf_filtered ("%s ", syscallname (what));
- }
- else
- {
- printf_filtered ("\t%-16s %s.\n", syscallname (what),
- "Returned from this system call");
- }
- break;
- case PR_FAULTED:
- if (summary)
- {
- printf_filtered ("%s ",
- lookupname (faults_table, what, "fault"));
- }
- else
- {
- printf_filtered ("\t%-16s %s.\n",
- lookupname (faults_table, what, "fault"),
- lookupdesc (faults_table, what));
- }
- break;
- }
- printf_filtered ("\n");
- }
-}
-
-static void
-info_proc_siginfo (pip, summary)
- struct procinfo *pip;
- int summary;
-{
- struct siginfo *sip;
-
- if ((THE_PR_LWP(pip->prstatus).pr_flags & PR_STOPPED) &&
- (THE_PR_LWP(pip->prstatus).pr_why == PR_SIGNALLED ||
- THE_PR_LWP(pip->prstatus).pr_why == PR_FAULTED))
- {
- printf_filtered ("%-32s", "Additional signal/fault info:");
- sip = &(THE_PR_LWP(pip->prstatus).pr_info);
- if (summary)
- {
- printf_filtered ("%s ", signalname (sip -> si_signo));
- if (sip -> si_errno > 0)
- {
- printf_filtered ("%s ", errnoname (sip -> si_errno));
- }
- if (sip -> si_code <= 0)
- {
- printf_filtered ("sent by %s, uid %d ",
- target_pid_to_str (sip -> si_pid),
- sip -> si_uid);
- }
- else
- {
- printf_filtered ("%s ", sigcodename (sip));
- if ((sip -> si_signo == SIGILL) ||
- (sip -> si_signo == SIGFPE) ||
- (sip -> si_signo == SIGSEGV) ||
- (sip -> si_signo == SIGBUS))
- {
- printf_filtered ("addr=%#lx ",
- (unsigned long) sip -> si_addr);
- }
- else if ((sip -> si_signo == SIGCHLD))
- {
- printf_filtered ("child %s, status %u ",
- target_pid_to_str (sip -> si_pid),
- sip -> si_status);
- }
- else if ((sip -> si_signo == SIGPOLL))
- {
- printf_filtered ("band %u ", sip -> si_band);
- }
- }
- }
- else
- {
- printf_filtered ("\n\n");
- printf_filtered ("\t%-16s %s.\n", signalname (sip -> si_signo),
- safe_strsignal (sip -> si_signo));
- if (sip -> si_errno > 0)
- {
- printf_filtered ("\t%-16s %s.\n",
- errnoname (sip -> si_errno),
- safe_strerror (sip -> si_errno));
- }
- if (sip -> si_code <= 0)
- {
- printf_filtered ("\t%-16u %s\n", sip -> si_pid, /* XXX need target_pid_to_str() */
- "PID of process sending signal");
- printf_filtered ("\t%-16u %s\n", sip -> si_uid,
- "UID of process sending signal");
- }
- else
- {
- printf_filtered ("\t%-16s %s.\n", sigcodename (sip),
- sigcodedesc (sip));
- if ((sip -> si_signo == SIGILL) ||
- (sip -> si_signo == SIGFPE))
- {
- printf_filtered ("\t%#-16lx %s.\n",
- (unsigned long) sip -> si_addr,
- "Address of faulting instruction");
- }
- else if ((sip -> si_signo == SIGSEGV) ||
- (sip -> si_signo == SIGBUS))
- {
- printf_filtered ("\t%#-16lx %s.\n",
- (unsigned long) sip -> si_addr,
- "Address of faulting memory reference");
- }
- else if ((sip -> si_signo == SIGCHLD))
- {
- printf_filtered ("\t%-16u %s.\n", sip -> si_pid, /* XXX need target_pid_to_str() */
- "Child process ID");
- printf_filtered ("\t%-16u %s.\n", sip -> si_status,
- "Child process exit value or signal");
- }
- else if ((sip -> si_signo == SIGPOLL))
- {
- printf_filtered ("\t%-16u %s.\n", sip -> si_band,
- "Band event for POLL_{IN,OUT,MSG}");
- }
- }
- }
- printf_filtered ("\n");
- }
-}
-
-static void
-info_proc_syscalls (pip, summary)
- struct procinfo *pip;
- int summary;
-{
- int syscallnum;
-
- if (!summary)
- {
-
-#if 0 /* FIXME: Needs to use gdb-wide configured info about system calls. */
- if (pip -> prstatus.pr_flags & PR_ASLEEP)
- {
- int syscallnum = pip -> prstatus.pr_reg[R_D0];
- if (summary)
- {
- printf_filtered ("%-32s", "Sleeping in system call:");
- printf_filtered ("%s", syscallname (syscallnum));
- }
- else
- {
- printf_filtered ("Sleeping in system call '%s'.\n",
- syscallname (syscallnum));
- }
- }
-#endif
-
-#ifndef UNIXWARE
- if (ioctl (pip -> ctl_fd, PIOCGENTRY, &pip -> entryset) < 0)
- {
- print_sys_errmsg (pip -> pathname, errno);
- error ("PIOCGENTRY failed");
- }
-
- if (ioctl (pip -> ctl_fd, PIOCGEXIT, &pip -> exitset) < 0)
- {
- print_sys_errmsg (pip -> pathname, errno);
- error ("PIOCGEXIT failed");
- }
-#endif
-
- printf_filtered ("System call tracing information:\n\n");
-
- printf_filtered ("\t%-12s %-8s %-8s\n",
- "System call",
- "Entry",
- "Exit");
- for (syscallnum = 0; syscallnum < MAX_SYSCALLS; syscallnum++)
- {
- QUIT;
- if (syscall_table[syscallnum] != NULL)
- printf_filtered ("\t%-12s ", syscall_table[syscallnum]);
- else
- printf_filtered ("\t%-12d ", syscallnum);
-
-#ifdef UNIXWARE
- printf_filtered ("%-8s ",
- prismember (&pip->prstatus.pr_sysentry, syscallnum)
- ? "on" : "off");
- printf_filtered ("%-8s ",
- prismember (&pip->prstatus.pr_sysexit, syscallnum)
- ? "on" : "off");
-#else
- printf_filtered ("%-8s ",
- prismember (&pip -> entryset, syscallnum)
- ? "on" : "off");
- printf_filtered ("%-8s ",
- prismember (&pip -> exitset, syscallnum)
- ? "on" : "off");
-#endif
- printf_filtered ("\n");
- }
- printf_filtered ("\n");
- }
-}
-
-static char *
-signalname (signo)
- int signo;
-{
- const char *name;
- static char locbuf[32];
-
- name = strsigno (signo);
- if (name == NULL)
- {
- sprintf (locbuf, "Signal %d", signo);
- }
- else
- {
- sprintf (locbuf, "%s (%d)", name, signo);
- }
- return (locbuf);
-}
-
-static char *
-errnoname (errnum)
- int errnum;
-{
- const char *name;
- static char locbuf[32];
-
- name = strerrno (errnum);
- if (name == NULL)
- {
- sprintf (locbuf, "Errno %d", errnum);
- }
- else
- {
- sprintf (locbuf, "%s (%d)", name, errnum);
- }
- return (locbuf);
-}
-
-static void
-info_proc_signals (pip, summary)
- struct procinfo *pip;
- int summary;
-{
- int signo;
-
- if (!summary)
- {
-#ifndef PROCFS_USE_READ_WRITE
- if (ioctl (pip -> ctl_fd, PIOCGTRACE, &pip -> trace) < 0)
- {
- print_sys_errmsg (pip -> pathname, errno);
- error ("PIOCGTRACE failed");
- }
-#endif
-
- printf_filtered ("Disposition of signals:\n\n");
- printf_filtered ("\t%-15s %-8s %-8s %-8s %s\n\n",
- "Signal", "Trace", "Hold", "Pending", "Description");
- for (signo = 0; signo < NSIG; signo++)
- {
- QUIT;
- printf_filtered ("\t%-15s ", signalname (signo));
-#ifdef UNIXWARE
- printf_filtered ("%-8s ",
- prismember (&pip -> prstatus.pr_sigtrace, signo)
- ? "on" : "off");
- printf_filtered ("%-8s ",
- prismember (&pip -> prstatus.pr_lwp.pr_context.uc_sigmask, signo)
- ? "on" : "off");
-#else
- printf_filtered ("%-8s ",
- prismember (&pip -> trace, signo)
- ? "on" : "off");
- printf_filtered ("%-8s ",
- prismember (&pip -> prstatus.pr_sighold, signo)
- ? "on" : "off");
-#endif
-
-#ifdef UNIXWARE
- if (prismember (&pip->prstatus.pr_sigpend, signo) ||
- prismember (&pip->prstatus.pr_lwp.pr_lwppend, signo))
- printf_filtered("%-8s ", "yes");
- else
- printf_filtered("%-8s ", "no");
-#else /* UNIXWARE */
-#ifdef PROCFS_SIGPEND_OFFSET
- /* Alpha OSF/1 numbers the pending signals from 1. */
- printf_filtered ("%-8s ",
- (signo ? prismember (&pip -> prstatus.pr_sigpend,
- signo - 1)
- : 0)
- ? "yes" : "no");
-#else
- printf_filtered ("%-8s ",
- prismember (&pip -> prstatus.pr_sigpend, signo)
- ? "yes" : "no");
-#endif
-#endif /* UNIXWARE */
- printf_filtered (" %s\n", safe_strsignal (signo));
- }
- printf_filtered ("\n");
- }
-}
-
-static void
-info_proc_faults (pip, summary)
- struct procinfo *pip;
- int summary;
-{
- struct trans *transp;
-
- if (!summary)
- {
-#ifndef UNIXWARE
- if (ioctl (pip -> ctl_fd, PIOCGFAULT, &pip->fltset.fltset) < 0)
- {
- print_sys_errmsg (pip -> pathname, errno);
- error ("PIOCGFAULT failed");
- }
-#endif
-
- printf_filtered ("Current traced hardware fault set:\n\n");
- printf_filtered ("\t%-12s %-8s\n", "Fault", "Trace");
-
- for (transp = faults_table; transp -> name != NULL; transp++)
- {
- QUIT;
- printf_filtered ("\t%-12s ", transp -> name);
-#ifdef UNIXWARE
- printf_filtered ("%-8s", prismember (&pip->prstatus.pr_flttrace, transp -> value)
- ? "on" : "off");
-#else
- printf_filtered ("%-8s", prismember (&pip->fltset.fltset, transp -> value)
- ? "on" : "off");
-#endif
- printf_filtered ("\n");
- }
- printf_filtered ("\n");
- }
-}
-
-static void
-info_proc_mappings (pip, summary)
- struct procinfo *pip;
- int summary;
-{
- int nmap;
- struct prmap *prmaps;
- struct prmap *prmap;
- struct stat sbuf;
-
- if (!summary)
- {
- printf_filtered ("Mapped address spaces:\n\n");
-#ifdef BFD_HOST_64_BIT
- printf_filtered (" %18s %18s %10s %10s %7s\n",
-#else
- printf_filtered ("\t%10s %10s %10s %10s %7s\n",
-#endif
- "Start Addr",
- " End Addr",
- " Size",
- " Offset",
- "Flags");
-#ifdef PROCFS_USE_READ_WRITE
- if (fstat (pip->map_fd, &sbuf) == 0)
- {
- nmap = sbuf.st_size / sizeof (prmap_t);
- prmaps = (struct prmap *) alloca ((nmap + 1) * sizeof (*prmaps));
- if ((lseek (pip->map_fd, 0, SEEK_SET) == 0) &&
- (read (pip->map_fd, (char *) prmaps,
- nmap * sizeof (*prmaps)) == (nmap * sizeof (*prmaps))))
- {
- int i = 0;
- for (prmap = prmaps; i < nmap; ++prmap, ++i)
-#else
- if (ioctl (pip -> ctl_fd, PIOCNMAP, &nmap) == 0)
- {
- prmaps = (struct prmap *) alloca ((nmap + 1) * sizeof (*prmaps));
- if (ioctl (pip -> ctl_fd, PIOCMAP, prmaps) == 0)
- {
- for (prmap = prmaps; prmap -> pr_size; ++prmap)
-#endif /* PROCFS_USE_READ_WRITE */
- {
-#ifdef BFD_HOST_64_BIT
- printf_filtered (" %#18lx %#18lx %#10x %#10x %7s\n",
-#else
- printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
-#endif
- (unsigned long)prmap -> pr_vaddr,
- (unsigned long)prmap -> pr_vaddr
- + prmap -> pr_size - 1,
- prmap -> pr_size,
- prmap -> pr_off,
- mappingflags (prmap -> pr_mflags));
- }
- }
- }
- printf_filtered ("\n");
- }
-}
-
-/*
-
-LOCAL FUNCTION
-
- info_proc -- implement the "info proc" command
-
-SYNOPSIS
-
- void info_proc (char *args, int from_tty)
-
-DESCRIPTION
-
- Implement gdb's "info proc" command by using the /proc interface
- to print status information about any currently running process.
-
- Examples of the use of "info proc" are:
-
- info proc (prints summary info for current inferior)
- info proc 123 (prints summary info for process with pid 123)
- info proc mappings (prints address mappings)
- info proc times (prints process/children times)
- info proc id (prints pid, ppid, gid, sid, etc)
- FIXME: i proc id not implemented.
- info proc status (prints general process state info)
- FIXME: i proc status not implemented.
- info proc signals (prints info about signal handling)
- info proc all (prints all info)
-
- */
-
-static void
-info_proc (args, from_tty)
- char *args;
- int from_tty;
-{
- int pid;
- struct procinfo *pip;
- struct cleanup *old_chain;
- char **argv;
- int argsize;
- int summary = 1;
- int flags = 0;
- int syscalls = 0;
- int signals = 0;
- int faults = 0;
- int mappings = 0;
- int times = 0;
- int id = 0;
- int status = 0;
- int all = 0;
- int nlwp;
- int *lwps;
-
- old_chain = make_cleanup (null_cleanup, 0);
-
- /* Default to using the current inferior if no pid specified. Note
- that inferior_pid may be 0, hence we set okerr. */
-
- pid = inferior_pid & 0x7fffffff; /* strip off sol-thread bit */
- if (!(pip = find_procinfo (pid, 1))) /* inferior_pid no good? */
- pip = procinfo_list; /* take first available */
- pid = pid & 0xffff; /* extract "real" pid */
-
- if (args != NULL)
- {
- if ((argv = buildargv (args)) == NULL)
- {
- nomem (0);
- }
- make_cleanup (freeargv, (char *) argv);
-
- while (*argv != NULL)
- {
- argsize = strlen (*argv);
- if (argsize >= 1 && strncmp (*argv, "all", argsize) == 0)
- {
- summary = 0;
- all = 1;
- }
- else if (argsize >= 2 && strncmp (*argv, "faults", argsize) == 0)
- {
- summary = 0;
- faults = 1;
- }
- else if (argsize >= 2 && strncmp (*argv, "flags", argsize) == 0)
- {
- summary = 0;
- flags = 1;
- }
- else if (argsize >= 1 && strncmp (*argv, "id", argsize) == 0)
- {
- summary = 0;
- id = 1;
- }
- else if (argsize >= 1 && strncmp (*argv, "mappings", argsize) == 0)
- {
- summary = 0;
- mappings = 1;
- }
- else if (argsize >= 2 && strncmp (*argv, "signals", argsize) == 0)
- {
- summary = 0;
- signals = 1;
- }
- else if (argsize >= 2 && strncmp (*argv, "status", argsize) == 0)
- {
- summary = 0;
- status = 1;
- }
- else if (argsize >= 2 && strncmp (*argv, "syscalls", argsize) == 0)
- {
- summary = 0;
- syscalls = 1;
- }
- else if (argsize >= 1 && strncmp (*argv, "times", argsize) == 0)
- {
- summary = 0;
- times = 1;
- }
- else if ((pid = atoi (*argv)) > 0)
- {
- pip = (struct procinfo *) xmalloc (sizeof (struct procinfo));
- memset (pip, 0, sizeof (*pip));
-
- pip->pid = pid;
- if (!open_proc_file (pid, pip, O_RDONLY, 0))
- {
- perror_with_name (pip -> pathname);
- /* NOTREACHED */
- }
- pid = pip->pid;
- make_cleanup (close_proc_file, pip);
- }
- else if (**argv != '\000')
- {
- error ("Unrecognized or ambiguous keyword `%s'.", *argv);
- }
- argv++;
- }
- }
-
- /* If we don't have a valid open process at this point, then we have no
- inferior or didn't specify a specific pid. */
-
- if (!pip)
- {
- error ("\
-No process. Start debugging a program or specify an explicit process ID.");
- }
-
- if (!procfs_read_status (pip))
- {
- print_sys_errmsg (pip -> pathname, errno);
- error ("procfs_read_status failed");
- }
-
-#ifndef PROCFS_USE_READ_WRITE
-#ifdef PIOCLWPIDS
- nlwp = pip->prstatus.pr_nlwp;
- lwps = alloca ((2 * nlwp + 2) * sizeof (*lwps));
-
- if (ioctl (pip->ctl_fd, PIOCLWPIDS, lwps))
- {
- print_sys_errmsg (pip -> pathname, errno);
- error ("PIOCLWPIDS failed");
- }
-#else /* PIOCLWPIDS */
- nlwp = 1;
- lwps = alloca ((2 * nlwp + 2) * sizeof *lwps);
- lwps[0] = 0;
-#endif /* PIOCLWPIDS */
-
- for (; nlwp > 0; nlwp--, lwps++)
- {
- pip = find_procinfo ((*lwps << 16) | pid, 1);
-
- if (!pip)
- {
- pip = (struct procinfo *) xmalloc (sizeof (struct procinfo));
- memset (pip, 0, sizeof (*pip));
- if (!open_proc_file ((*lwps << 16) | pid, pip, O_RDONLY, 0))
- continue;
-
- make_cleanup (close_proc_file, pip);
-
- if (!procfs_read_status (pip))
- {
- print_sys_errmsg (pip -> pathname, errno);
- error ("procfs_read_status failed");
- }
- }
-
-#endif /* PROCFS_USE_READ_WRITE */
-
- /* Print verbose information of the requested type(s), or just a summary
- of the information for all types. */
-
- printf_filtered ("\nInformation for %s.%d:\n\n", pip -> pathname, *lwps);
- if (summary || all || flags)
- {
- info_proc_flags (pip, summary);
- }
- if (summary || all)
- {
- info_proc_stop (pip, summary);
-#ifdef UNIXWARE
- supply_gregset (&pip->prstatus.pr_lwp.pr_context.uc_mcontext.gregs);
-#else
- supply_gregset (&pip->prstatus.pr_reg);
-#endif
- printf_filtered ("PC: ");
- print_address (read_pc (), gdb_stdout);
- printf_filtered ("\n");
- }
- if (summary || all || signals || faults)
- {
- info_proc_siginfo (pip, summary);
- }
- if (summary || all || syscalls)
- {
- info_proc_syscalls (pip, summary);
- }
- if (summary || all || mappings)
- {
- info_proc_mappings (pip, summary);
- }
- if (summary || all || signals)
- {
- info_proc_signals (pip, summary);
- }
- if (summary || all || faults)
- {
- info_proc_faults (pip, summary);
- }
- printf_filtered ("\n");
-
- /* All done, deal with closing any temporary process info structure,
- freeing temporary memory , etc. */
-
- do_cleanups (old_chain);
-#ifndef PROCFS_USE_READ_WRITE
- }
-#endif
-}
-
-/*
-
-LOCAL FUNCTION
-
- modify_inherit_on_fork_flag - Change the inherit-on-fork flag
-
-SYNOPSIS
-
- void modify_inherit_on_fork_flag (fd, flag)
-
-DESCRIPTION
-
- Call this routine to modify the inherit-on-fork flag. This routine is
- just a nice wrapper to hide the #ifdefs needed by various systems to
- control this flag.
-
- */
-
-static void
-modify_inherit_on_fork_flag (fd, flag)
- int fd;
- int flag;
-{
-#if defined (PIOCSET) || defined (PCSET)
- long pr_flags;
-#endif
- int retval = 0;
- struct proc_ctl pctl;
-
-#if defined (PIOCSET) || defined (PCSET) /* New method */
- pr_flags = PR_FORK;
- if (flag)
- {
-#ifdef PROCFS_USE_READ_WRITE
- pctl.cmd = PCSET;
- pctl.data = PR_FORK;
- if (write (fd, (char *) &pctl, sizeof (struct proc_ctl)) < 0)
- retval = -1;
-#else
- retval = ioctl (fd, PIOCSET, &pr_flags);
-#endif
- }
- else
- {
-#ifdef PROCFS_USE_READ_WRITE
- pctl.cmd = PCRESET;
- pctl.data = PR_FORK;
- if (write (fd, (char *) &pctl, sizeof (struct proc_ctl)) < 0)
- retval = -1;
-#else
- retval = ioctl (fd, PIOCRESET, &pr_flags);
-#endif
- }
-
-#else
-#ifdef PIOCSFORK /* Original method */
- if (flag)
- {
- retval = ioctl (fd, PIOCSFORK, NULL);
- }
- else
- {
- retval = ioctl (fd, PIOCRFORK, NULL);
- }
-#else
- Neither PR_FORK nor PIOCSFORK exist!!!
-#endif
-#endif
-
- if (!retval)
- return;
-
- print_sys_errmsg ("modify_inherit_on_fork_flag", errno);
- error ("PIOCSFORK or PR_FORK modification failed");
-}
-
-/*
-
-LOCAL FUNCTION
-
- modify_run_on_last_close_flag - Change the run-on-last-close flag
-
-SYNOPSIS
-
- void modify_run_on_last_close_flag (fd, flag)
-
-DESCRIPTION
-
- Call this routine to modify the run-on-last-close flag. This routine
- is just a nice wrapper to hide the #ifdefs needed by various systems to
- control this flag.
-
- */
-
-static void
-modify_run_on_last_close_flag (fd, flag)
- int fd;
- int flag;
-{
-#if defined (PIOCSET) || defined (PCSET)
- long pr_flags;
-#endif
- int retval = 0;
- struct proc_ctl pctl;
-
-#if defined (PIOCSET) || defined (PCSET) /* New method */
- pr_flags = PR_RLC;
- if (flag)
- {
-#ifdef PROCFS_USE_READ_WRITE
- pctl.cmd = PCSET;
- pctl.data = PR_RLC;
- if (write (fd, (char *) &pctl, sizeof (struct proc_ctl)) < 0)
- retval = -1;
-#else
- retval = ioctl (fd, PIOCSET, &pr_flags);
-#endif
- }
- else
- {
-#ifdef PROCFS_USE_READ_WRITE
- pctl.cmd = PCRESET;
- pctl.data = PR_RLC;
- if (write (fd, (char *) &pctl, sizeof (struct proc_ctl)) < 0)
- retval = -1;
-#else
- retval = ioctl (fd, PIOCRESET, &pr_flags);
-#endif
- }
-
-#else
-#ifdef PIOCSRLC /* Original method */
- if (flag)
- retval = ioctl (fd, PIOCSRLC, NULL);
- else
- retval = ioctl (fd, PIOCRRLC, NULL);
-#else
- Neither PR_RLC nor PIOCSRLC exist!!!
-#endif
-#endif
-
- if (!retval)
- return;
-
- print_sys_errmsg ("modify_run_on_last_close_flag", errno);
- error ("PIOCSRLC or PR_RLC modification failed");
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_clear_syscall_trap -- Deletes the trap for the specified system call.
-
-SYNOPSIS
-
- void procfs_clear_syscall_trap (struct procinfo *, int syscall_num, int errok)
-
-DESCRIPTION
-
- This function function disables traps for the specified system call.
- errok is non-zero if errors should be ignored.
- */
-
-static void
-procfs_clear_syscall_trap (pi, syscall_num, errok)
- struct procinfo *pi;
- int syscall_num;
- int errok;
-{
- sysset_t sysset;
- int goterr, i;
-
-#ifndef UNIXWARE
- goterr = ioctl (pi->ctl_fd, PIOCGENTRY, &sysset) < 0;
-
- if (goterr && !errok)
- {
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCGENTRY failed");
- }
-
- if (!goterr)
- {
- prdelset (&sysset, syscall_num);
-
- if ((ioctl (pi->ctl_fd, PIOCSENTRY, &sysset) < 0) && !errok)
- {
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCSENTRY failed");
- }
- }
-
- goterr = ioctl (pi->ctl_fd, PIOCGEXIT, &sysset) < 0;
-
- if (goterr && !errok)
- {
- procfs_clear_syscall_trap (pi, syscall_num, 1);
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCGEXIT failed");
- }
-
- if (!goterr)
- {
- praddset (&sysset, syscall_num);
-
- if ((ioctl (pi->ctl_fd, PIOCSEXIT, &sysset) < 0) && !errok)
- {
- procfs_clear_syscall_trap (pi, syscall_num, 1);
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCSEXIT failed");
- }
- }
-#endif
-
- if (!pi->syscall_handlers)
- {
- if (!errok)
- error ("procfs_clear_syscall_trap: syscall_handlers is empty");
- return;
- }
-
- /* Remove handler func from the handler list */
-
- for (i = 0; i < pi->num_syscall_handlers; i++)
- if (pi->syscall_handlers[i].syscall_num == syscall_num)
- {
- if (i + 1 != pi->num_syscall_handlers)
- { /* Not the last entry.
- Move subsequent entries fwd. */
- memcpy (&pi->syscall_handlers[i], &pi->syscall_handlers[i + 1],
- (pi->num_syscall_handlers - i - 1)
- * sizeof (struct procfs_syscall_handler));
- }
-
- pi->syscall_handlers = xrealloc (pi->syscall_handlers,
- (pi->num_syscall_handlers - 1)
- * sizeof (struct procfs_syscall_handler));
- pi->num_syscall_handlers--;
- return;
- }
-
- if (!errok)
- error ("procfs_clear_syscall_trap: Couldn't find handler for sys call %d",
- syscall_num);
-}
-
-/*
-
-LOCAL FUNCTION
-
- procfs_set_syscall_trap -- arrange for a function to be called when the
- child executes the specified system call.
-
-SYNOPSIS
-
- void procfs_set_syscall_trap (struct procinfo *, int syscall_num, int flags,
- syscall_func_t *function)
-
-DESCRIPTION
-
- This function sets up an entry and/or exit trap for the specified system
- call. When the child executes the specified system call, your function
- will be called with the call #, a flag that indicates entry or exit, and
- pointers to rtnval and statval (which are used by procfs_wait). The
- function should return non-zero if something interesting happened, zero
- otherwise.
- */
-
-static void
-procfs_set_syscall_trap (pi, syscall_num, flags, func)
- struct procinfo *pi;
- int syscall_num;
- int flags;
- syscall_func_t *func;
-{
- sysset_t sysset;
-
-#ifndef UNIXWARE
- if (flags & PROCFS_SYSCALL_ENTRY)
- {
- if (ioctl (pi->ctl_fd, PIOCGENTRY, &sysset) < 0)
- {
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCGENTRY failed");
- }
-
- praddset (&sysset, syscall_num);
-
- if (ioctl (pi->ctl_fd, PIOCSENTRY, &sysset) < 0)
- {
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCSENTRY failed");
- }
- }
-
- if (flags & PROCFS_SYSCALL_EXIT)
- {
- if (ioctl (pi->ctl_fd, PIOCGEXIT, &sysset) < 0)
- {
- procfs_clear_syscall_trap (pi, syscall_num, 1);
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCGEXIT failed");
- }
-
- praddset (&sysset, syscall_num);
-
- if (ioctl (pi->ctl_fd, PIOCSEXIT, &sysset) < 0)
- {
- procfs_clear_syscall_trap (pi, syscall_num, 1);
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCSEXIT failed");
- }
- }
-#endif
-
- if (!pi->syscall_handlers)
- {
- pi->syscall_handlers = xmalloc (sizeof (struct procfs_syscall_handler));
- pi->syscall_handlers[0].syscall_num = syscall_num;
- pi->syscall_handlers[0].func = func;
- pi->num_syscall_handlers = 1;
- }
- else
- {
- int i;
-
- for (i = 0; i < pi->num_syscall_handlers; i++)
- if (pi->syscall_handlers[i].syscall_num == syscall_num)
- {
- pi->syscall_handlers[i].func = func;
- return;
- }
-
- pi->syscall_handlers = xrealloc (pi->syscall_handlers, (i + 1)
- * sizeof (struct procfs_syscall_handler));
- pi->syscall_handlers[i].syscall_num = syscall_num;
- pi->syscall_handlers[i].func = func;
- pi->num_syscall_handlers++;
- }
-}
-
-#ifdef SYS_lwp_create
-
-/*
-
-LOCAL FUNCTION
-
- procfs_lwp_creation_handler - handle exit from the _lwp_create syscall
-
-SYNOPSIS
-
- int procfs_lwp_creation_handler (pi, syscall_num, why, rtnvalp, statvalp)
-
-DESCRIPTION
-
- This routine is called both when an inferior process and it's new lwp
- are about to finish a _lwp_create() system call. This is the system
- call that Solaris uses to create a lightweight process. When the
- target process gets this event, we can look at sysarg[2] to find the
- new childs lwp ID, and create a procinfo struct from that. After that,
- we pretend that we got a SIGTRAP, and return non-zero to tell
- procfs_wait to wake up. Subsequently, wait_for_inferior gets woken up,
- sees the new process and continues it.
-
- When we see the child exiting from lwp_create, we just contine it,
- since everything was handled when the parent trapped.
-
-NOTES
- In effect, we are only paying attention to the parent's completion of
- the lwp_create syscall. If we only paid attention to the child
- instead, then we wouldn't detect the creation of a suspended thread.
- */
-
-static int
-procfs_lwp_creation_handler (pi, syscall_num, why, rtnvalp, statvalp)
- struct procinfo *pi;
- int syscall_num;
- int why;
- int *rtnvalp;
- int *statvalp;
-{
- int lwp_id;
- struct procinfo *childpi;
- struct proc_ctl pctl;
-
- /* We've just detected the completion of an lwp_create system call. Now we
- need to setup a procinfo struct for this thread, and notify the thread
- system of the new arrival. */
-
- /* If lwp_create failed, then nothing interesting happened. Continue the
- process and go back to sleep. */
-
-#ifdef UNIXWARE
- /* Joel ... can you check this logic out please? JKJ */
- if (pi->prstatus.pr_lwp.pr_context.uc_mcontext.gregs[R_EFL] & 1)
- { /* _lwp_create failed */
- pctl.cmd = PCRUN;
- pctl.data = PRCFAULT;
-
- if (write (pi->ctl_fd, (char *) &pctl, sizeof (struct proc_ctl)) < 0)
- perror_with_name (pi->pathname);
-
- return 0;
- }
-#else /* UNIXWARE */
- if (PROCFS_GET_CARRY (pi->prstatus.pr_reg))
- { /* _lwp_create failed */
- pi->prrun.pr_flags &= PRSTEP;
- pi->prrun.pr_flags |= PRCFAULT;
-
- if (ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) != 0)
- perror_with_name (pi->pathname);
-
- return 0;
- }
-#endif
-
- /* At this point, the new thread is stopped at it's first instruction, and
- the parent is stopped at the exit from lwp_create. */
-
- if (pi->new_child) /* Child? */
- { /* Yes, just continue it */
-#ifdef UNIXWARE
- pctl.cmd = PCRUN;
- pctl.data = PRCFAULT;
-
- if (write(pi->ctl_fd, (char *)&pctl, sizeof (struct proc_ctl)) < 0)
-#else /* !UNIXWARE */
- pi->prrun.pr_flags &= PRSTEP;
- pi->prrun.pr_flags |= PRCFAULT;
-
- if ((pi->prstatus.pr_flags & PR_ISTOP)
- && ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) != 0)
-#endif /* !UNIXWARE */
- perror_with_name (pi->pathname);
-
- pi->new_child = 0; /* No longer new */
-
- return 0;
- }
-
- /* We're the proud parent of a new thread. Setup an exit trap for lwp_create
- in the child and continue the parent. */
-
- /* Third arg is pointer to new thread id. */
- lwp_id = read_memory_integer (
- THE_PR_LWP(pi->prstatus).pr_sysarg[2], sizeof (int));
-
- lwp_id = (lwp_id << 16) | PIDGET (pi->pid);
-
- childpi = create_procinfo (lwp_id);
-
- /* The new process has actually inherited the lwp_create syscall trap from
- it's parent, but we still have to call this to register handlers for
- that child. */
-
- procfs_set_inferior_syscall_traps (childpi);
- add_thread (lwp_id);
- printf_filtered ("[New %s]\n", target_pid_to_str (lwp_id));
-
- /* Continue the parent */
-#ifdef UNIXWARE
- pctl.cmd = PCRUN;
- pctl.data = PRCFAULT;
-
- if (write(pi->ctl_fd, (char *)&pctl, sizeof (struct proc_ctl)) < 0)
-#else
- pi->prrun.pr_flags &= PRSTEP;
- pi->prrun.pr_flags |= PRCFAULT;
- if (ioctl (pi->ctl_fd, PIOCRUN, &pi->prrun) != 0)
-#endif
- perror_with_name (pi->pathname);
-
- /* The new child may have been created in one of two states:
- SUSPENDED or RUNNABLE. If runnable, we will simply signal it to run.
- If suspended, we flag it to be continued later, when it has an event. */
-
- if (THE_PR_LWP(childpi->prstatus).pr_why == PR_SUSPENDED)
- childpi->new_child = 1; /* Flag this as an unseen child process */
- else
- {
- /* Continue the child */
-#ifdef UNIXWARE
- pctl.cmd = PCRUN;
- pctl.data = PRCFAULT;
-
- if (write(pi->ctl_fd, (char *)&pctl, sizeof (struct proc_ctl)) < 0)
-#else
- childpi->prrun.pr_flags &= PRSTEP;
- childpi->prrun.pr_flags |= PRCFAULT;
-
- if (ioctl (childpi->ctl_fd, PIOCRUN, &childpi->prrun) != 0)
-#endif
- perror_with_name (childpi->pathname);
- }
- return 0;
-}
-#endif /* SYS_lwp_create */
-
-/* Fork an inferior process, and start debugging it with /proc. */
-
-static void
-procfs_create_inferior (exec_file, allargs, env)
- char *exec_file;
- char *allargs;
- char **env;
-{
- char *shell_file = getenv ("SHELL");
- char *tryname;
- if (shell_file != NULL && strchr (shell_file, '/') == NULL)
- {
-
- /* We will be looking down the PATH to find shell_file. If we
- just do this the normal way (via execlp, which operates by
- attempting an exec for each element of the PATH until it
- finds one which succeeds), then there will be an exec for
- each failed attempt, each of which will cause a PR_SYSEXIT
- stop, and we won't know how to distinguish the PR_SYSEXIT's
- for these failed execs with the ones for successful execs
- (whether the exec has succeeded is stored at that time in the
- carry bit or some such architecture-specific and
- non-ABI-specified place).
-
- So I can't think of anything better than to search the PATH
- now. This has several disadvantages: (1) There is a race
- condition; if we find a file now and it is deleted before we
- exec it, we lose, even if the deletion leaves a valid file
- further down in the PATH, (2) there is no way to know exactly
- what an executable (in the sense of "capable of being
- exec'd") file is. Using access() loses because it may lose
- if the caller is the superuser; failing to use it loses if
- there are ACLs or some such. */
-
- char *p;
- char *p1;
- /* FIXME-maybe: might want "set path" command so user can change what
- path is used from within GDB. */
- char *path = getenv ("PATH");
- int len;
- struct stat statbuf;
-
- if (path == NULL)
- path = "/bin:/usr/bin";
-
- tryname = alloca (strlen (path) + strlen (shell_file) + 2);
- for (p = path; p != NULL; p = p1 ? p1 + 1: NULL)
- {
- p1 = strchr (p, ':');
- if (p1 != NULL)
- len = p1 - p;
- else
- len = strlen (p);
- strncpy (tryname, p, len);
- tryname[len] = '\0';
- strcat (tryname, "/");
- strcat (tryname, shell_file);
- if (access (tryname, X_OK) < 0)
- continue;
- if (stat (tryname, &statbuf) < 0)
- continue;
- if (!S_ISREG (statbuf.st_mode))
- /* We certainly need to reject directories. I'm not quite
- as sure about FIFOs, sockets, etc., but I kind of doubt
- that people want to exec() these things. */
- continue;
- break;
- }
- if (p == NULL)
- /* Not found. This must be an error rather than merely passing
- the file to execlp(), because execlp() would try all the
- exec()s, causing GDB to get confused. */
- error ("Can't find shell %s in PATH", shell_file);
-
- shell_file = tryname;
- }
-
- fork_inferior (exec_file, allargs, env,
- proc_set_exec_trap, procfs_init_inferior, NULL, shell_file);
-
- /* We are at the first instruction we care about. */
- /* Pedal to the metal... */
-
- proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
-}
-
-/* Clean up after the inferior dies. */
-
-static void
-procfs_mourn_inferior ()
-{
- struct procinfo *pi;
- struct procinfo *next_pi;
-
- for (pi = procinfo_list; pi; pi = next_pi)
- {
- next_pi = pi->next;
- unconditionally_kill_inferior (pi);
- }
-
- unpush_target (&procfs_ops);
- generic_mourn_inferior ();
-}
-
-
-/* Mark our target-struct as eligible for stray "run" and "attach" commands. */
-static int
-procfs_can_run ()
-{
- /* This variable is controlled by modules that sit atop procfs that may layer
- their own process structure atop that provided here. sol-thread.c does
- this because of the Solaris two-level thread model. */
-
- return !procfs_suppress_run;
-}
-#ifdef TARGET_HAS_HARDWARE_WATCHPOINTS
-#ifndef UNIXWARE
-
-/* Insert a watchpoint */
-int
-procfs_set_watchpoint(pid, addr, len, rw)
- int pid;
- CORE_ADDR addr;
- int len;
- int rw;
-{
- struct procinfo *pi;
- prwatch_t wpt;
-
- pi = find_procinfo (pid == -1 ? inferior_pid : pid, 0);
- wpt.pr_vaddr = (caddr_t)addr;
- wpt.pr_size = len;
- wpt.pr_wflags = ((rw & 1) ? MA_READ : 0) | ((rw & 2) ? MA_WRITE : 0);
- if (ioctl (pi->ctl_fd, PIOCSWATCH, &wpt) < 0)
- {
- if (errno == E2BIG)
- return -1;
- /* Currently it sometimes happens that the same watchpoint gets
- deleted twice - don't die in this case (FIXME please) */
- if (errno == ESRCH && len == 0)
- return 0;
- print_sys_errmsg (pi->pathname, errno);
- error ("PIOCSWATCH failed");
- }
- return 0;
-}
-
-int
-procfs_stopped_by_watchpoint(pid)
- int pid;
-{
- struct procinfo *pi;
- short what;
- short why;
-
- pi = find_procinfo (pid == -1 ? inferior_pid : pid, 0);
- if (pi->prstatus.pr_flags & (PR_STOPPED | PR_ISTOP))
- {
- why = pi->prstatus.pr_why;
- what = pi->prstatus.pr_what;
- if (why == PR_FAULTED
-#if defined (FLTWATCH) && defined (FLTKWATCH)
- && (what == FLTWATCH || what == FLTKWATCH)
-#else
-#ifdef FLTWATCH
- && (what == FLTWATCH)
-#endif
-#ifdef FLTKWATCH
- && (what == FLTKWATCH)
-#endif
-#endif
- )
- return what;
- }
- return 0;
-}
-#endif /* !UNIXWARE */
-#endif /* TARGET_HAS_HARDWARE_WATCHPOINTS */
-
-/* Why is this necessary? Shouldn't dead threads just be removed from the
- thread database? */
-
-static int
-procfs_thread_alive (pid)
- int pid;
-{
- struct procinfo *pi, *next_pi;
-
- for (pi = procinfo_list; pi; pi = next_pi)
- {
- next_pi = pi->next;
- if (pi -> pid == pid)
- if (procfs_read_status (pi)) /* alive */
- return 1;
- else /* defunct (exited) */
- {
- close_proc_file (pi);
- return 0;
- }
- }
- return 0;
-}
-
-int
-procfs_first_available ()
-{
- struct procinfo *pi;
-
- for (pi = procinfo_list; pi; pi = pi->next)
- {
- if (procfs_read_status (pi))
- return pi->pid;
- }
- return -1;
-}
-
-int
-procfs_get_pid_fd (pid)
- int pid;
-{
- struct procinfo *pi = find_procinfo (pid, 1);
-
- if (pi == NULL)
- return -1;
-
- return pi->ctl_fd;
-}
-
-/* Send a SIGINT to the process group. This acts just like the user typed a
- ^C on the controlling terminal.
-
- XXX - This may not be correct for all systems. Some may want to use
- killpg() instead of kill (-pgrp). */
-
-static void
-procfs_stop ()
-{
- extern pid_t inferior_process_group;
-
- kill (-inferior_process_group, SIGINT);
-}
-
-/* Convert a pid to printable form. */
-
-#ifdef TIDGET
-char *
-procfs_pid_to_str (pid)
- int pid;
-{
- static char buf[100];
-
- sprintf (buf, "Kernel thread %d", TIDGET (pid));
-
- return buf;
-}
-#endif /* TIDGET */
-
-
-static void
-init_procfs_ops ()
-{
- procfs_ops.to_shortname = "procfs";
- procfs_ops.to_longname = "Unix /proc child process";
- procfs_ops.to_doc = "Unix /proc child process (started by the \"run\" command).";
- procfs_ops.to_open = procfs_open;
- procfs_ops.to_attach = procfs_attach;
- procfs_ops.to_detach = procfs_detach;
- procfs_ops.to_resume = procfs_resume;
- procfs_ops.to_wait = procfs_wait;
- procfs_ops.to_fetch_registers = procfs_fetch_registers;
- procfs_ops.to_store_registers = procfs_store_registers;
- procfs_ops.to_prepare_to_store = procfs_prepare_to_store;
- procfs_ops.to_xfer_memory = procfs_xfer_memory;
- procfs_ops.to_files_info = procfs_files_info;
- procfs_ops.to_insert_breakpoint = memory_insert_breakpoint;
- procfs_ops.to_remove_breakpoint = memory_remove_breakpoint;
- procfs_ops.to_terminal_init = terminal_init_inferior;
- procfs_ops.to_terminal_inferior = terminal_inferior;
- procfs_ops.to_terminal_ours_for_output = terminal_ours_for_output;
- procfs_ops.to_terminal_ours = terminal_ours;
- procfs_ops.to_terminal_info = child_terminal_info;
- procfs_ops.to_kill = procfs_kill_inferior;
- procfs_ops.to_create_inferior = procfs_create_inferior;
- procfs_ops.to_mourn_inferior = procfs_mourn_inferior;
- procfs_ops.to_can_run = procfs_can_run;
- procfs_ops.to_notice_signals = procfs_notice_signals;
- procfs_ops.to_thread_alive = procfs_thread_alive;
- procfs_ops.to_stop = procfs_stop;
- procfs_ops.to_stratum = process_stratum;
- procfs_ops.to_has_all_memory = 1;
- procfs_ops.to_has_memory = 1;
- procfs_ops.to_has_stack = 1;
- procfs_ops.to_has_registers = 1;
- procfs_ops.to_has_execution = 1;
- procfs_ops.to_magic = OPS_MAGIC;
-}
-
-void
-_initialize_procfs ()
-{
-#ifdef HAVE_OPTIONAL_PROC_FS
- char procname[MAX_PROC_NAME_SIZE];
- int fd;
-
- /* If we have an optional /proc filesystem (e.g. under OSF/1),
- don't add procfs support if we cannot access the running
- GDB via /proc. */
- sprintf (procname, STATUS_PROC_NAME_FMT, getpid ());
- if ((fd = open (procname, O_RDONLY)) < 0)
- return;
- close (fd);
-#endif
-
- init_procfs_ops ();
- add_target (&procfs_ops);
-
- add_info ("processes", info_proc,
-"Show process status information using /proc entry.\n\
-Specify process id or use current inferior by default.\n\
-Specify keywords for detailed information; default is summary.\n\
-Keywords are: `all', `faults', `flags', `id', `mappings', `signals',\n\
-`status', `syscalls', and `times'.\n\
-Unambiguous abbreviations may be used.");
-
- init_syscall_table ();
-}
diff --git a/contrib/gdb/gdb/ptx4-nat.c b/contrib/gdb/gdb/ptx4-nat.c
deleted file mode 100644
index 564b799..0000000
--- a/contrib/gdb/gdb/ptx4-nat.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/* Native-dependent code for ptx 4.0
- Copyright 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "gdbcore.h"
-#include <sys/procfs.h>
-#include <sys/ptrace.h>
-#include <sys/param.h>
-#include <fcntl.h>
-
-/* 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;
-{
- supply_register(EAX_REGNUM, (char *)&(*gregsetp)[EAX]);
- supply_register(EDX_REGNUM, (char *)&(*gregsetp)[EDX]);
- supply_register(ECX_REGNUM, (char *)&(*gregsetp)[ECX]);
- supply_register(EBX_REGNUM, (char *)&(*gregsetp)[EBX]);
- supply_register(ESI_REGNUM, (char *)&(*gregsetp)[ESI]);
- supply_register(EDI_REGNUM, (char *)&(*gregsetp)[EDI]);
- supply_register(ESP_REGNUM, (char *)&(*gregsetp)[UESP]);
- supply_register(EBP_REGNUM, (char *)&(*gregsetp)[EBP]);
- supply_register(EIP_REGNUM, (char *)&(*gregsetp)[EIP]);
- supply_register(EFLAGS_REGNUM, (char *)&(*gregsetp)[EFL]);
-}
-
-void
-fill_gregset (gregsetp, regno)
- gregset_t *gregsetp;
- int regno;
-{
- int regi;
- extern char registers[];
-
- for (regi = 0 ; regi < NUM_REGS ; regi++)
- {
- if ((regno == -1) || (regno == regi))
- {
- (*gregsetp)[regi] = *(greg_t *)&registers[REGISTER_BYTE (regi)];
- }
- }
-}
-
-#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;
-{
- supply_fpu_registers((struct fpusave *)&fpregsetp->fp_reg_set);
- supply_fpa_registers((struct fpasave *)&fpregsetp->f_wregs);
-}
-
-/* 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[];
-
- /* FIXME: see m68k-tdep.c for an example, for the m68k. */
-}
-
-#endif /* defined (FP0_REGNUM) */
-
-/*
- * This doesn't quite do the same thing as the procfs.c version, but give
- * it the same name so we don't have to put an ifdef in solib.c.
- */
-/* this could use elf_interpreter() from elfread.c */
-int
-proc_iterate_over_mappings(func)
- int (*func) PARAMS ((int, CORE_ADDR));
-{
- vaddr_t curseg, memptr;
- pt_vseg_t pv;
- int rv, cmperr;
- sec_ptr interp_sec;
- char *interp_content;
- int interp_fd, funcstat;
- unsigned int size;
- char buf1[NBPG], buf2[NBPG];
-
- /*
- * The following is really vile. We can get the name of the
- * shared library from the exec_bfd, and we can get a list of
- * each virtual memory segment, but there is no simple way to
- * find the mapped segment from the shared library (ala
- * procfs's PIOCOPENMEM). As a pretty nasty kludge, we
- * compare the virtual memory segment to the contents of the
- * .interp file. If they match, we assume that we've got the
- * right one.
- */
-
- /*
- * TODO: for attach, use XPT_OPENT to get the executable, in
- * case we're attached without knowning the executable's
- * filename.
- */
-
-#ifdef VERBOSE_DEBUG
- printf("proc_iter\n");
-#endif
- interp_sec = bfd_get_section_by_name(exec_bfd, ".interp");
- if (!interp_sec) {
- return 0;
- }
-
- size = bfd_section_size(exec_bfd, interp_sec);
- interp_content = alloca(size);
- if (0 == bfd_get_section_contents(exec_bfd, interp_sec,
- interp_content, (file_ptr)0, size)) {
- return 0;
- }
-
-#ifdef VERBOSE_DEBUG
- printf("proc_iter: \"%s\"\n", interp_content);
-#endif
- interp_fd = open(interp_content, O_RDONLY, 0);
- if (-1 == interp_fd) {
- return 0;
- }
-
- curseg = 0;
- while (1) {
- rv = ptrace(PT_NEXT_VSEG, inferior_pid, &pv, curseg);
-#ifdef VERBOSE_DEBUG
- printf("PT_NEXT_VSEG: rv %d errno %d\n", rv, errno);
-#endif
- if (-1 == rv)
- break;
- if (0 == rv)
- break;
-#ifdef VERBOSE_DEBUG
- printf("pv.pv_start 0x%x pv_size 0x%x pv_prot 0x%x\n",
- pv.pv_start, pv.pv_size, pv.pv_prot);
-#endif
- curseg = pv.pv_start + pv.pv_size;
-
- rv = lseek(interp_fd, 0, SEEK_SET);
- if (-1 == rv) {
- perror("lseek");
- close(interp_fd);
- return 0;
- }
- for (memptr = pv.pv_start; memptr < pv.pv_start + pv.pv_size;
- memptr += NBPG) {
-#ifdef VERBOSE_DEBUG
- printf("memptr 0x%x\n", memptr);
-#endif
- rv = read(interp_fd, buf1, NBPG);
- if (-1 == rv) {
- perror("read");
- close(interp_fd);
- return 0;
- }
- rv = ptrace(PT_RDATA_PAGE, inferior_pid, buf2,
- memptr);
- if (-1 == rv) {
- perror("ptrace");
- close(interp_fd);
- return 0;
- }
- cmperr = memcmp(buf1, buf2, NBPG);
- if (cmperr)
- break;
- }
- if (0 == cmperr) {
- /* this is it */
- funcstat = (*func)(interp_fd, pv.pv_start);
- break;
- }
- }
- close(interp_fd);
- return 0;
-}
diff --git a/contrib/gdb/gdb/pyr-tdep.c b/contrib/gdb/gdb/pyr-tdep.c
deleted file mode 100644
index 85e9a07..0000000
--- a/contrib/gdb/gdb/pyr-tdep.c
+++ /dev/null
@@ -1,452 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#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_unfiltered/*_filtered*/ ("%6.6s: %8x %6.6s: %8x %6s: %8x %6s: %8x\n",
- REGISTER_NAME (regno), reg_buf[regno],
- REGISTER_NAME (regno+16), reg_buf[regno+16],
- REGISTER_NAME (regno+32), reg_buf[regno+32],
- REGISTER_NAME (regno+48), reg_buf[regno+48]);
- }
- usp = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) ((char *)&u.u_pcb.pcb_usp) -
- ((char *)&u), 0);
- ksp = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) ((char *)&u.u_pcb.pcb_ksp) -
- ((char *)&u), 0);
- printf_unfiltered/*_filtered*/ ("\n%6.6s: %8x %6.6s: %8x (%08x) %6.6s %8x\n",
- REGISTER_NAME (CSP_REGNUM),reg_buf[CSP_REGNUM],
- REGISTER_NAME (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 (REGISTER_NAME (i), gdb_stdout);
- printf_filtered(":");
- print_spaces_filtered (6 - strlen (REGISTER_NAME (i)), gdb_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)
- struct frame_info *frame;
-{
- register int addr = find_saved_register (frame,CFP_REGNUM);
- register int result = read_memory_integer (addr, 4);
-#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING
- fprintf_unfiltered (gdb_stderr,
- "\t[[..frame_locals:%8x, %s= %x @%x fcfp= %x foo= %x\n\t gr13=%x pr13=%x tr13=%x @%x]]\n",
- frame->frame,
- REGISTER_NAME (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)
- struct frame_info *frame;
-{
- register int addr = find_saved_register (frame,CFP_REGNUM);
- register int result = read_memory_integer (addr, 4);
-
-#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING
- fprintf_unfiltered (gdb_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,
- REGISTER_NAME (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);
-}
-
-#include "symtab.h"
-#include "opcode/pyr.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 can supplant the normal definitions of some
- of the macros in tm-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_unfiltered ("...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_unfiltered ("..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)
-
-/* Let's be byte-independent so we can use this as a cross-assembler. */
-
-#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
-pyr_print_insn (memaddr, stream)
- CORE_ADDR memaddr;
- GDB_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_unfiltered (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_unfiltered (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_unfiltered (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_unfiltered (cc_bit_names[i], stream);
- bit_codes >>= 1;
- }
-
- fprintf_unfiltered (stream, ",%0x",
- displacement + memaddr);
- return (insn_size);
- }
-
- switch (operand_mode) {
- case 0:
- fprintf_unfiltered (stream, "%s,%s",
- REGISTER_NAME (op_1_regno),
- REGISTER_NAME (op_2_regno));
- break;
-
- case 1:
- fprintf_unfiltered (stream, " 0x%0x,%s",
- op_1_regno,
- REGISTER_NAME (op_2_regno));
- break;
-
- case 2:
- read_memory (memaddr+4, buffer, MAXLEN);
- insn_size += 4;
- extra_1 = * ((int *) buffer);
- fprintf_unfiltered (stream, " $0x%0x,%s",
- extra_1,
- REGISTER_NAME (op_2_regno));
- break;
- case 3:
- fprintf_unfiltered (stream, " (%s),%s",
- REGISTER_NAME (op_1_regno),
- REGISTER_NAME (op_2_regno));
- break;
-
- case 4:
- read_memory (memaddr+4, buffer, MAXLEN);
- insn_size += 4;
- extra_1 = * ((int *) buffer);
- fprintf_unfiltered (stream, " 0x%0x(%s),%s",
- extra_1,
- REGISTER_NAME (op_1_regno),
- REGISTER_NAME (op_2_regno));
- break;
-
- /* S1 destination mode */
- case 5:
- fprintf_unfiltered (stream,
- ((index_reg_regno) ? "%s,(%s)[%s*%1d]" : "%s,(%s)"),
- REGISTER_NAME (op_1_regno),
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (index_reg_regno),
- index_multiplier);
- break;
-
- case 6:
- fprintf_unfiltered (stream,
- ((index_reg_regno) ? " $%#0x,(%s)[%s*%1d]"
- : " $%#0x,(%s)"),
- op_1_regno,
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (index_reg_regno),
- index_multiplier);
- break;
-
- case 7:
- read_memory (memaddr+4, buffer, MAXLEN);
- insn_size += 4;
- extra_1 = * ((int *) buffer);
- fprintf_unfiltered (stream,
- ((index_reg_regno) ? " $%#0x,(%s)[%s*%1d]"
- : " $%#0x,(%s)"),
- extra_1,
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (index_reg_regno),
- index_multiplier);
- break;
-
- case 8:
- fprintf_unfiltered (stream,
- ((index_reg_regno) ? " (%s),(%s)[%s*%1d]" : " (%s),(%s)"),
- REGISTER_NAME (op_1_regno),
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (index_reg_regno),
- index_multiplier);
- break;
-
- case 9:
- read_memory (memaddr+4, buffer, MAXLEN);
- insn_size += 4;
- extra_1 = * ((int *) buffer);
- fprintf_unfiltered (stream,
- ((index_reg_regno)
- ? "%#0x(%s),(%s)[%s*%1d]"
- : "%#0x(%s),(%s)"),
- extra_1,
- REGISTER_NAME (op_1_regno),
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (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_unfiltered (stream,
- ((index_reg_regno) ? "%s,%#0x(%s)[%s*%1d]" : "%s,%#0x(%s)"),
- REGISTER_NAME (op_1_regno),
- extra_1,
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (index_reg_regno),
- index_multiplier);
- break;
- case 11:
- read_memory (memaddr+4, buffer, MAXLEN);
- insn_size += 4;
- extra_1 = * ((int *) buffer);
- fprintf_unfiltered (stream,
- ((index_reg_regno) ?
- " $%#0x,%#0x(%s)[%s*%1d]" : " $%#0x,%#0x(%s)"),
- op_1_regno,
- extra_1,
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (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_unfiltered (stream,
- ((index_reg_regno) ?
- " $%#0x,%#0x(%s)[%s*%1d]" : " $%#0x,%#0x(%s)"),
- extra_1,
- extra_2,
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (index_reg_regno),
- index_multiplier);
- break;
-
- case 13:
- read_memory (memaddr+4, buffer, MAXLEN);
- insn_size += 4;
- extra_1 = * ((int *) buffer);
- fprintf_unfiltered (stream,
- ((index_reg_regno)
- ? " (%s),%#0x(%s)[%s*%1d]"
- : " (%s),%#0x(%s)"),
- REGISTER_NAME (op_1_regno),
- extra_1,
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (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_unfiltered (stream,
- ((index_reg_regno) ? "%#0x(%s),%#0x(%s)[%s*%1d]"
- : "%#0x(%s),%#0x(%s) "),
- extra_1,
- REGISTER_NAME (op_1_regno),
- extra_2,
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (index_reg_regno),
- index_multiplier);
- break;
-
- default:
- fprintf_unfiltered (stream,
- ((index_reg_regno) ? "%s,%s [%s*%1d]" : "%s,%s"),
- REGISTER_NAME (op_1_regno),
- REGISTER_NAME (op_2_regno),
- REGISTER_NAME (index_reg_regno),
- index_multiplier);
- fprintf_unfiltered (stream,
- "\t\t# unknown mode in %08x",
- insn);
- break;
- } /* switch */
- }
-
- {
- return insn_size;
- }
- abort ();
-}
diff --git a/contrib/gdb/gdb/pyr-xdep.c b/contrib/gdb/gdb/pyr-xdep.c
deleted file mode 100644
index dd6d9a9..0000000
--- a/contrib/gdb/gdb/pyr-xdep.c
+++ /dev/null
@@ -1,370 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-/* #include <fcntl.h> Can we live without this? */
-
-#include "gdbcore.h"
-#include <sys/user.h> /* After a.out.h */
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- register int 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, (PTRACE_ARG3_TYPE) regno, 0);
-
-#if defined(PYRAMID_CONTROL_FRAME_DEBUGGING)
- printf_unfiltered ("Fetching register %s, got %0x\n",
- REGISTER_NAME (regno),
- reg_buf[regno]);
-#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */
-
- if (reg_buf[regno] == -1 && errno == EIO) {
- printf_unfiltered("fetch_interior_registers: fetching register %s\n",
- REGISTER_NAME (regno));
- errno = 0;
- }
- supply_register (regno, reg_buf+regno);
- }
- /* that leaves regs 64, 65, and 66 */
- datum = ptrace (3, inferior_pid,
- (PTRACE_ARG3_TYPE) (((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,
- (PTRACE_ARG3_TYPE) (datum+((32+15)*4)), 0);
- if (inferior_saved_pc > 0) break;
-#if defined(PYRAMID_CONTROL_FRAME_DEBUGGING)
- printf_unfiltered("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_unfiltered (gdb_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). */
-
-void
-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, (PTRACE_ARG3_TYPE) 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, (PTRACE_ARG3_TYPE) 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 corefile.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 corefile.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 program 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_unfiltered ("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_unfiltered ("Control stack pointer = %s\n",
- local_hex_string (u.u_pcb.pcb_csp));
- printf_unfiltered ("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 (REGISTER_NAME (regno))
- + 30);
- strcpy (buffer, "Reading register ");
- strcat (buffer, REGISTER_NAME (regno));
-
- perror_with_name (buffer);
- }
-
- if (val < 0)
- perror_with_name (filename);
-#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING
- printf_unfiltered ("[reg %s(%d), offset in file %s=0x%0x, addr =0x%0x, =%0x]\n",
- REGISTER_NAME (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_unfiltered ("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_unfiltered ("No core file now.\n");
-}
diff --git a/contrib/gdb/gdb/remote-adapt.c b/contrib/gdb/gdb/remote-adapt.c
deleted file mode 100644
index b22f180..0000000
--- a/contrib/gdb/gdb/remote-adapt.c
+++ /dev/null
@@ -1,1443 +0,0 @@
-/* Remote debugging interface for AMD 290*0 Adapt Monitor Version 2.1d18.
- Copyright 1990, 1991, 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 "defs.h"
-#include "gdb_string.h"
-#include "inferior.h"
-#include "wait.h"
-#include "value.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include "terminal.h"
-#include "target.h"
-#include "gdbcore.h"
-
-/* This processor is getting rusty but I am trying to keep it
- up to date at least with data structure changes.
- Activate this block to compile just this file.
- */
-#define COMPILE_CHECK 0
-#if COMPILE_CHECK
-#define Q_REGNUM 0
-#define VAB_REGNUM 0
-#define CPS_REGNUM 0
-#define IPA_REGNUM 0
-#define IPB_REGNUM 0
-#define GR1_REGNUM 0
-#define LR0_REGNUM 0
-#define IPC_REGNUM 0
-#define CR_REGNUM 0
-#define BP_REGNUM 0
-#define FC_REGNUM 0
-#define INTE_REGNUM 0
-#define EXO_REGNUM 0
-#define GR96_REGNUM 0
-#define NPC_REGNUM
-#define FPE_REGNUM 0
-#define PC2_REGNUM 0
-#define FPS_REGNUM 0
-#define ALU_REGNUM 0
-#define LRU_REGNUM 0
-#define TERMINAL int
-#define RAW 1
-#define ANYP 1
-extern int a29k_freeze_mode ;
-extern int processor_type ;
-extern char * processor_name ;
-#endif
-
-/* External data declarations */
-extern int stop_soon_quietly; /* for wait_for_inferior */
-
-/* Forward data declarations */
-extern struct target_ops adapt_ops; /* Forward declaration */
-
-/* Forward function declarations */
-static void adapt_fetch_registers ();
-static void adapt_store_registers ();
-static void adapt_close ();
-static int adapt_clear_breakpoints();
-
-#define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400)
-#define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
-
-/* Can't seem to get binary coff working */
-#define ASCII_COFF /* Adapt will be downloaded with ascii coff */
-
-/* FIXME: Replace with `set remotedebug'. */
-#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++,(char *) &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;
-{
- fprintf (adapt_stream, "K");
- fprintf (adapt_stream, "\r");
- expect_prompt ();
-}
-/*
- * 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];
-
- 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 ();
-}
-
-/* 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;
-
- if (args && *args)
- error ("Can't pass arguments to remote adapt process.");
-
- if (execfile == 0 || exec_bfd == 0)
- error ("No executable 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, TARGET_SIGNAL_DEFAULT, 0);
-#endif
-
- } else {
- printf_filtered("Adapt not open yet.\n");
- }
-}
-
-/* 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;
-
- /* 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*)xmalloc(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);
-#if ! defined(COMPILE_CHECK)
-#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+");
-#endif /* compile_check */
- push_target (&adapt_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 ("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();
-
- /* Print out some stuff, letting the user now what's going on */
- printf_filtered("Connected to an Adapt via %s.\n", 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 != a29k_freeze_mode) {
- fprintf_filtered(gdb_stderr,
- "Freeze-mode debugging not available, and can only be done on an A29050.\n");
- }
-}
-
-/* Close out all files and local state before this target loses control. */
-
-static void
-adapt_close (quitting)
- int quitting;
-{
-
- /* 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
-}
-
-/* Attach to the target that is already loaded and possibly running */
-static void
-adapt_attach (args, from_tty)
- char *args;
- int from_tty;
-{
-
- if (from_tty)
- printf_filtered ("Attaching to remote program %s.\n", prog_name);
-
- /* 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 */
-}
-
-
-/* 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;
-{
-
- 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);
-}
-
-/* Tell the remote machine to resume. */
-
-void
-adapt_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
-{
- 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();
- }
-}
-
-/* Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-int
-adapt_wait (status)
- struct target_waitstatus *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;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- if (need_artificial_trap != 0)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- 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')
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- else
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
- timeout = old_timeout;
- immediate_quit = old_immediate_quit;
- 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;
-
-/*
- * 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, (char *) &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,(char *) &sreg_buf[0]);
- supply_register(IPA_REGNUM,(char *) &sreg_buf[1]);
- supply_register(IPB_REGNUM,(char *) &sreg_buf[2]);
- supply_register(Q_REGNUM, (char *) &sreg_buf[3]);
- /* Skip ALU */
- supply_register(BP_REGNUM, (char *) &sreg_buf[5]);
- supply_register(FC_REGNUM, (char *) &sreg_buf[6]);
- supply_register(CR_REGNUM, (char *) &sreg_buf[7]);
-
- /* There doesn't seem to be any way to get these. */
- {
- int val = -1;
- supply_register (FPE_REGNUM, (char *) &val);
- supply_register (INTE_REGNUM, (char *) &val);
- supply_register (FPS_REGNUM, (char *) &val);
- supply_register (EXO_REGNUM, (char *) &val);
- }
-
- write (adapt_desc, "dw gr1,gr1\r", 11);
- expect ("GR001 ");
- get_hex_regs (1, GR1_REGNUM);
- expect_prompt ();
-}
-
-/* Fetch register REGNO, or all registers if REGNO is -1.
- */
-static void
-adapt_fetch_register (regno)
- int regno;
-{
- 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 ();
- }
-}
-
-/* Store the remote registers from the contents of the block REGS. */
-
-static void
-adapt_store_registers ()
-{
- int i, j;
-
- 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. */
-void
-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 ();
- }
-}
-
-/* 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;
-
- /* 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);
- 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. */
-
- 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;
- }
- 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 */
-{
- if (num_brkpts < MAX_BREAKS) {
- num_brkpts++;
- fprintf (adapt_stream, "B %x", addr);
- fprintf (adapt_stream, "\r");
- expect_prompt ();
- return(0); /* Success */
- } else {
- fprintf_filtered(gdb_stderr,
- "Too many break points, break point not installed\n");
- return(1); /* Failure */
- }
-
-}
-static int
-adapt_remove_breakpoint(addr, save)
-CORE_ADDR addr;
-char *save; /* Throw away, let adapt save instructions */
-{
- if (num_brkpts > 0) {
- num_brkpts--;
- fprintf (adapt_stream, "BR %x", addr);
- fprintf (adapt_stream, "\r");
- fflush (adapt_stream);
- expect_prompt ();
- }
- return(0);
-}
-
-/* Clear the adapts notion of what the break points are */
-static int
-adapt_clear_breakpoints()
-{
- if (adapt_stream) {
- fprintf (adapt_stream, "BR"); /* Clear all break points */
- fprintf (adapt_stream, "\r");
- fflush(adapt_stream);
- expect_prompt ();
- }
- num_brkpts = 0;
-}
-static void
-adapt_mourn()
-{
- adapt_clear_breakpoints();
- pop_target (); /* Pop back to no-child state */
- generic_mourn_inferior ();
-}
-
-/* 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<i ; j++) /* Put everthing we matched */
- putchar(str[j]);
- i=0;
- }
- putchar(c);
- }
- }
-
-}
-
-
-/* Put a command string, in args, out to the adapt. The adapt is assumed to
- be in raw mode, all writing/reading done through adapt_desc.
- Ouput from the adapt is placed on the users terminal until the
- prompt from the adapt is seen.
- FIXME: Can't handle commands that take input. */
-
-void
-adapt_com (args, fromtty)
- char *args;
- int fromtty;
-{
- if (!adapt_stream) {
- printf_filtered("Adapt not open. Use the 'target' command to open.\n");
- return;
- }
-
- /* Clear all input so only command relative output is displayed */
- slurp_input();
-
- switch(islower(args[0]) ? toupper(args[0]) : args[0]) {
- default:
- printf_filtered("Unknown/Unimplemented adapt command '%s'\n",args);
- break;
- case 'G': /* Go, begin execution */
- write(adapt_desc,args,strlen(args));
- write(adapt_desc,"\r",1);
- expect_prompt();
- break;
- case 'B': /* Break points, B or BR */
- case 'C': /* Check current 29k status (running/halted) */
- case 'D': /* Display data/registers */
- case 'I': /* Input from i/o space */
- case 'J': /* Jam an instruction */
- case 'K': /* Kill, stop execution */
- case 'L': /* Disassemble */
- case 'O': /* Output to i/o space */
- case 'T': /* Trace */
- case 'P': /* Pulse an input line */
- case 'X': /* Examine special purpose registers */
- case 'Z': /* Display trace buffer */
- write(adapt_desc,args,strlen(args));
- write(adapt_desc,"\r",1);
- expect(args); /* Don't display the command */
- display_until("# ");
- break;
- /* Begin commands that take input in the form 'c x,y[,z...]' */
- case 'S': /* Set memory or register */
- if (strchr(args,',')) { /* Assume it is properly formatted */
- write(adapt_desc,args,strlen(args));
- write(adapt_desc,"\r",1);
- expect_prompt();
- }
- break;
- }
-}
-
-/* Define the target subroutine names */
-
-struct target_ops adapt_ops ;
-
-static void
-init_adapt_ops(void)
-{
- adapt_ops.to_shortname = "adapt";
- adapt_ops.to_longname = "Remote AMD `Adapt' target";
- adapt_ops.to_doc = "Remote debug an AMD 290*0 using an `Adapt' monitor via RS232";
- adapt_ops.to_open = adapt_open;
- adapt_ops.to_close = adapt_close;
- adapt_ops.to_attach = adapt_attach;
- adapt_ops.to_post_attach = NULL;
- adapt_ops.to_require_attach = NULL;
- adapt_ops.to_detach = adapt_detach;
- adapt_ops.to_require_detach = NULL;
- adapt_ops.to_resume = adapt_resume;
- adapt_ops.to_wait = adapt_wait;
- adapt_ops.to_post_wait = NULL;
- adapt_ops.to_fetch_registers = adapt_fetch_register;
- adapt_ops.to_store_registers = adapt_store_register;
- adapt_ops.to_prepare_to_store = adapt_prepare_to_store;
- adapt_ops.to_xfer_memory = adapt_xfer_inferior_memory;
- adapt_ops.to_files_info = adapt_files_info;
- adapt_ops.to_insert_breakpoint = adapt_insert_breakpoint;
- adapt_ops.to_remove_breakpoint = adapt_remove_breakpoint;
- adapt_ops.to_terminal_init = 0;
- adapt_ops.to_terminal_inferior = 0;
- adapt_ops.to_terminal_ours_for_output = 0;
- adapt_ops.to_terminal_ours = 0;
- adapt_ops.to_terminal_info = 0;
- adapt_ops.to_kill = adapt_kill;
- adapt_ops.to_load = adapt_load;
- adapt_ops.to_lookup_symbol = 0;
- adapt_ops.to_create_inferior = adapt_create_inferior;
- adapt_ops.to_post_startup_inferior = NULL;
- adapt_ops.to_acknowledge_created_inferior = NULL;
- adapt_ops.to_clone_and_follow_inferior = NULL;
- adapt_ops.to_post_follow_inferior_by_clone = NULL;
- adapt_ops.to_insert_fork_catchpoint = NULL;
- adapt_ops.to_remove_fork_catchpoint = NULL;
- adapt_ops.to_insert_vfork_catchpoint = NULL;
- adapt_ops.to_remove_vfork_catchpoint = NULL;
- adapt_ops.to_has_forked = NULL;
- adapt_ops.to_has_vforked = NULL;
- adapt_ops.to_can_follow_vfork_prior_to_exec = NULL;
- adapt_ops.to_post_follow_vfork = NULL;
- adapt_ops.to_insert_exec_catchpoint = NULL;
- adapt_ops.to_remove_exec_catchpoint = NULL;
- adapt_ops.to_has_execd = NULL;
- adapt_ops.to_reported_exec_events_per_exec_call = NULL;
- adapt_ops.to_has_exited = NULL;
- adapt_ops.to_mourn_inferior = adapt_mourn;
- adapt_ops.to_can_run = 0;
- adapt_ops.to_notice_signals = 0;
- adapt_ops.to_thread_alive = 0;
- adapt_ops.to_stop = 0 ; /* process_stratum; */
- adapt_ops.to_pid_to_exec_file = NULL;
- adapt_ops.to_core_file_to_sym_file = NULL;
- adapt_ops.to_stratum = 0;
- adapt_ops.DONT_USE = 0 ;
- adapt_ops.to_has_all_memory = 1;
- adapt_ops.to_has_memory = 1;
- adapt_ops.to_has_stack = 1;
- adapt_ops.to_has_registers = 1;
- adapt_ops.to_has_execution = 0;
- adapt_ops.to_sections = 0;
- adapt_ops.to_sections_end = 0 ;
- adapt_ops.to_magic = OPS_MAGIC;
-} /* init_adapt_ops */
-
-void
-_initialize_remote_adapt ()
-{
- init_adapt_ops() ;
- add_target (&adapt_ops);
- add_com ("adapt <command>", class_obscure, adapt_com,
- "Send a command to the AMD Adapt remote monitor.");
-}
diff --git a/contrib/gdb/gdb/remote-array.c b/contrib/gdb/gdb/remote-array.c
deleted file mode 100644
index 624871c..0000000
--- a/contrib/gdb/gdb/remote-array.c
+++ /dev/null
@@ -1,1497 +0,0 @@
-/* Remote debugging interface for Array Tech RAID controller..
- Copyright 90, 91, 92, 93, 94, 1995, 1998 Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Rob Savoye for Cygnus.
-
- This module talks to a debug monitor called 'MONITOR', which
- We communicate with MONITOR via either a direct serial line, or a TCP
- (or possibly TELNET) stream to a terminal multiplexor,
- which in turn talks to the target board.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "wait.h"
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <ctype.h>
-#include <signal.h>
-#include <sys/types.h>
-#include "gdb_string.h"
-#include "command.h"
-#include "serial.h"
-#include "monitor.h"
-#include "remote-utils.h"
-
-extern int baud_rate;
-
-#define ARRAY_PROMPT ">> "
-
-#define SWAP_TARGET_AND_HOST(buffer,len) \
- do \
- { \
- if (TARGET_BYTE_ORDER != HOST_BYTE_ORDER) \
- { \
- char tmp; \
- char *p = (char *)(buffer); \
- char *q = ((char *)(buffer)) + len - 1; \
- for (; p < q; p++, q--) \
- { \
- tmp = *q; \
- *q = *p; \
- *p = tmp; \
- } \
- } \
- } \
- while (0)
-
-static void debuglogs PARAMS((int, char *, ...));
-static void array_open();
-static void array_close();
-static void array_detach();
-static void array_attach();
-static void array_resume();
-static void array_fetch_register();
-static void array_store_register();
-static void array_fetch_registers();
-static void array_store_registers();
-static void array_prepare_to_store();
-static void array_files_info();
-static void array_kill();
-static void array_create_inferior();
-static void array_mourn_inferior();
-static void make_gdb_packet();
-static int array_xfer_memory();
-static int array_wait();
-static int array_insert_breakpoint();
-static int array_remove_breakpoint();
-static int tohex();
-static int to_hex();
-static int from_hex();
-static int array_send_packet();
-static int array_get_packet();
-static unsigned long ascii2hexword();
-static void hexword2ascii();
-
-extern char *version;
-
-#define LOG_FILE "monitor.log"
-#if defined (LOG_FILE)
-FILE *log_file;
-#endif
-
-static int timeout = 30;
-/* Having this larger than 400 causes us to be incompatible with m68k-stub.c
- and i386-stub.c. Normally, no one would notice because it only matters
- for writing large chunks of memory (e.g. in downloads). Also, this needs
- to be more than 400 if required to hold the registers (see below, where
- we round it up based on REGISTER_BYTES). */
-#define PBUFSIZ 400
-
-/*
- * Descriptor for I/O to remote machine. Initialize it to NULL so that
- * array_open knows that we don't have a file open when the program starts.
- */
-serial_t array_desc = NULL;
-
-/*
- * this array of registers need to match the indexes used by GDB. The
- * whole reason this exists is cause the various ROM monitors use
- * different strings than GDB does, and doesn't support all the
- * registers either. So, typing "info reg sp" becomes a "r30".
- */
-extern char *tmp_mips_processor_type;
-extern int mips_set_processor_type();
-
-static struct target_ops array_ops ;
-
-static void
-init_array_ops(void)
-{
- array_ops.to_shortname = "array";
- array_ops.to_longname =
- "Debug using the standard GDB remote protocol for the Array Tech target.",
- array_ops.to_doc =
- "Debug using the standard GDB remote protocol for the Array Tech target.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya)." ;
- array_ops.to_open = array_open;
- array_ops.to_close = array_close;
- array_ops.to_attach = NULL;
- array_ops.to_post_attach = NULL;
- array_ops.to_require_attach = NULL;
- array_ops.to_detach = array_detach;
- array_ops.to_require_detach = NULL;
- array_ops.to_resume = array_resume;
- array_ops.to_wait = array_wait;
- array_ops.to_post_wait = NULL;
- array_ops.to_fetch_registers = array_fetch_registers;
- array_ops.to_store_registers = array_store_registers;
- array_ops.to_prepare_to_store = array_prepare_to_store;
- array_ops.to_xfer_memory = array_xfer_memory;
- array_ops.to_files_info = array_files_info;
- array_ops.to_insert_breakpoint = array_insert_breakpoint;
- array_ops.to_remove_breakpoint = array_remove_breakpoint;
- array_ops.to_terminal_init = 0;
- array_ops.to_terminal_inferior = 0;
- array_ops.to_terminal_ours_for_output = 0;
- array_ops.to_terminal_ours = 0;
- array_ops.to_terminal_info = 0;
- array_ops.to_kill = array_kill;
- array_ops.to_load = 0;
- array_ops.to_lookup_symbol = 0;
- array_ops.to_create_inferior = array_create_inferior;
- array_ops.to_post_startup_inferior = NULL;
- array_ops.to_acknowledge_created_inferior = NULL;
- array_ops.to_clone_and_follow_inferior = NULL;
- array_ops.to_post_follow_inferior_by_clone = NULL;
- array_ops.to_insert_fork_catchpoint = NULL;
- array_ops.to_remove_fork_catchpoint = NULL;
- array_ops.to_insert_vfork_catchpoint = NULL;
- array_ops.to_remove_vfork_catchpoint = NULL;
- array_ops.to_has_forked = NULL;
- array_ops.to_has_vforked = NULL;
- array_ops.to_can_follow_vfork_prior_to_exec = NULL;
- array_ops.to_post_follow_vfork = NULL;
- array_ops.to_insert_exec_catchpoint = NULL;
- array_ops.to_remove_exec_catchpoint = NULL;
- array_ops.to_has_execd = NULL;
- array_ops.to_reported_exec_events_per_exec_call = NULL;
- array_ops.to_has_exited = NULL;
- array_ops.to_mourn_inferior = array_mourn_inferior;
- array_ops.to_can_run = 0;
- array_ops.to_notice_signals = 0;
- array_ops.to_thread_alive = 0;
- array_ops.to_stop = 0;
- array_ops.to_pid_to_exec_file = NULL;
- array_ops.to_core_file_to_sym_file = NULL;
- array_ops.to_stratum = process_stratum;
- array_ops.DONT_USE = 0;
- array_ops.to_has_all_memory = 1;
- array_ops.to_has_memory = 1;
- array_ops.to_has_stack = 1;
- array_ops.to_has_registers = 1;
- array_ops.to_has_execution = 1;
- array_ops.to_sections = 0;
- array_ops.to_sections_end = 0;
- array_ops.to_magic = OPS_MAGIC;
-};
-
-/*
- * printf_monitor -- send data to monitor. Works just like printf.
- */
-static void
-#ifdef ANSI_PROTOTYPES
-printf_monitor(char *pattern, ...)
-#else
-printf_monitor(va_alist)
- va_dcl
-#endif
-{
- va_list args;
- char buf[PBUFSIZ];
- int i;
-
-#ifdef ANSI_PROTOTYPES
- va_start(args, pattern);
-#else
- char *pattern;
- va_start(args);
- pattern = va_arg(args, char *);
-#endif
-
- vsprintf(buf, pattern, args);
-
- debuglogs (1, "printf_monitor(), Sending: \"%s\".", buf);
-
- if (strlen(buf) > PBUFSIZ)
- error ("printf_monitor(): string too long");
- if (SERIAL_WRITE(array_desc, buf, strlen(buf)))
- fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
-}
-/*
- * write_monitor -- send raw data to monitor.
- */
-static void
-write_monitor(data, len)
- char data[];
- int len;
-{
- if (SERIAL_WRITE(array_desc, data, len))
- fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
-
- *(data + len+1) = '\0';
- debuglogs (1, "write_monitor(), Sending: \"%s\".", data);
-
-}
-
-/*
- * debuglogs -- deal with debugging info to multiple sources. This takes
- * two real args, the first one is the level to be compared against
- * the sr_get_debug() value, the second arg is a printf buffer and args
- * to be formatted and printed. A CR is added after each string is printed.
- */
-static void
-#ifdef ANSI_PROTOTYPES
-debuglogs(int level, char *pattern, ...)
-#else
-debuglogs(va_alist)
- va_dcl
-#endif
-{
- va_list args;
- char *p;
- unsigned char buf[PBUFSIZ];
- char newbuf[PBUFSIZ];
- int i;
-
-#ifdef ANSI_PROTOTYPES
- va_start(args, pattern);
-#else
- char *pattern;
- int level;
- va_start(args);
- level = va_arg(args, int); /* get the debug level */
- pattern = va_arg(args, char *); /* get the printf style pattern */
-#endif
-
- if ((level <0) || (level > 100)) {
- error ("Bad argument passed to debuglogs(), needs debug level");
- return;
- }
-
- vsprintf(buf, pattern, args); /* format the string */
-
- /* convert some characters so it'll look right in the log */
- p = newbuf;
- for (i = 0 ; buf[i] != '\0'; i++) {
- if (i > PBUFSIZ)
- error ("Debug message too long");
- switch (buf[i]) {
- case '\n': /* newlines */
- *p++ = '\\';
- *p++ = 'n';
- continue;
- case '\r': /* carriage returns */
- *p++ = '\\';
- *p++ = 'r';
- continue;
- case '\033': /* escape */
- *p++ = '\\';
- *p++ = 'e';
- continue;
- case '\t': /* tab */
- *p++ = '\\';
- *p++ = 't';
- continue;
- case '\b': /* backspace */
- *p++ = '\\';
- *p++ = 'b';
- continue;
- default: /* no change */
- *p++ = buf[i];
- }
-
- if (buf[i] < 26) { /* modify control characters */
- *p++ = '^';
- *p++ = buf[i] + 'A';
- continue;
- }
- if (buf[i] >= 128) { /* modify control characters */
- *p++ = '!';
- *p++ = buf[i] + 'A';
- continue;
- }
- }
- *p = '\0'; /* terminate the string */
-
- if (sr_get_debug() > level)
- printf_unfiltered ("%s\n", newbuf);
-
-#ifdef LOG_FILE /* write to the monitor log */
- if (log_file != 0x0) {
- fputs (newbuf, log_file);
- fputc ('\n', log_file);
- fflush (log_file);
- }
-#endif
-}
-
-/* readchar -- read a character from the remote system, doing all the fancy
- * timeout stuff.
- */
-static int
-readchar(timeout)
- int timeout;
-{
- int c;
-
- c = SERIAL_READCHAR(array_desc, abs(timeout));
-
- if (sr_get_debug() > 5) {
- putchar(c & 0x7f);
- debuglogs (5, "readchar: timeout = %d\n", timeout);
- }
-
-#ifdef LOG_FILE
- if (isascii (c))
- putc(c & 0x7f, log_file);
-#endif
-
- if (c >= 0)
- return c & 0x7f;
-
- if (c == SERIAL_TIMEOUT) {
- if (timeout <= 0)
- return c; /* Polls shouldn't generate timeout errors */
- error("Timeout reading from remote system.");
-#ifdef LOG_FILE
- fputs ("ERROR: Timeout reading from remote system", log_file);
-#endif
- }
- perror_with_name("readchar");
-}
-
-/*
- * expect -- scan input from the remote system, until STRING is found.
- * If DISCARD is non-zero, then discard non-matching input, else print
- * it out. Let the user break out immediately.
- */
-static void
-expect (string, discard)
- char *string;
- int discard;
-{
- char *p = string;
- int c;
-
-
- debuglogs (1, "Expecting \"%s\".", string);
-
- immediate_quit = 1;
- while (1) {
- c = readchar(timeout);
- if (!isascii (c))
- continue;
- if (c == *p++) {
- if (*p == '\0') {
- immediate_quit = 0;
- debuglogs (4, "Matched");
- return;
- }
- } else {
- if (!discard) {
- fputc_unfiltered (c, gdb_stdout);
- }
- p = string;
- }
- }
-}
-
-/* Keep discarding input until we see the MONITOR array_cmds->prompt.
-
- The convention for dealing with the expect_prompt is that you
- o give your command
- o *then* wait for the expect_prompt.
-
- Thus the last thing that a procedure does with the serial line
- will be an expect_prompt(). Exception: array_resume does not
- wait for the expect_prompt, because the terminal is being handed over
- to the inferior. However, the next thing which happens after that
- is a array_wait which does wait for the expect_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(discard)
- int discard;
-{
- expect (ARRAY_PROMPT, discard);
-}
-
-/*
- * junk -- ignore junk characters. Returns a 1 if junk, 0 otherwise
- */
-static int
-junk(ch)
- char ch;
-{
- switch (ch) {
- case '\0':
- case ' ':
- case '-':
- case '\t':
- case '\r':
- case '\n':
- if (sr_get_debug() > 5)
- debuglogs (5, "Ignoring \'%c\'.", ch);
- return 1;
- default:
- if (sr_get_debug() > 5)
- debuglogs (5, "Accepting \'%c\'.", ch);
- return 0;
- }
-}
-
-/*
- * get_hex_digit -- Get a hex digit from the remote system & return its value.
- * If ignore is nonzero, ignore spaces, newline & tabs.
- */
-static int
-get_hex_digit(ignore)
- int ignore;
-{
- static int ch;
- while (1) {
- ch = readchar(timeout);
- if (junk(ch))
- continue;
- if (sr_get_debug() > 4) {
- debuglogs (4, "get_hex_digit() got a 0x%x(%c)", ch, ch);
- } else {
-#ifdef LOG_FILE /* write to the monitor log */
- if (log_file != 0x0) {
- fputs ("get_hex_digit() got a 0x", log_file);
- fputc (ch, log_file);
- fputc ('\n', log_file);
- fflush (log_file);
- }
-#endif
- }
-
- 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)
- ;
- else {
- expect_prompt(1);
- debuglogs (4, "Invalid hex digit from remote system. (0x%x)", ch);
- error("Invalid hex digit from remote system. (0x%x)", ch);
- }
- }
-}
-
-/* get_hex_byte -- Get a byte from monitor 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;
- debuglogs (4, "get_hex_byte() -- Read first nibble 0x%x", val);
-
- val |= get_hex_digit (0);
- debuglogs (4, "get_hex_byte() -- Read second nibble 0x%x", val);
- *byt = val;
-
- debuglogs (4, "get_hex_byte() -- Read a 0x%x", val);
-}
-
-/*
- * get_hex_word -- Get N 32-bit words from remote, each preceded by a space,
- * and put them in registers starting at REGNO.
- */
-static int
-get_hex_word ()
-{
- long val, newval;
- int i;
-
- val = 0;
-
-#if 0
- if (HOST_BYTE_ORDER == BIG_ENDIAN) {
-#endif
- for (i = 0; i < 8; i++)
- val = (val << 4) + get_hex_digit (i == 0);
-#if 0
- } else {
- for (i = 7; i >= 0; i--)
- val = (val << 4) + get_hex_digit (i == 0);
- }
-#endif
-
- debuglogs (4, "get_hex_word() got a 0x%x for a %s host.", val, (HOST_BYTE_ORDER == BIG_ENDIAN) ? "big endian" : "little endian");
-
- return val;
-}
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-static void
-array_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- int entry_pt;
-
- if (args && *args)
- error("Can't pass arguments to remote MONITOR process");
-
- if (execfile == 0 || exec_bfd == 0)
- error("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
-/* The "process" (board) is already stopped awaiting our commands, and
- the program is already downloaded. We just set its PC and go. */
-
- clear_proceed_status ();
-
- /* Tell wait_for_inferior that we've started a new process. */
- 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 ();
-
- /* insert_step_breakpoint (); FIXME, do we need this? */
-
- /* Let 'er rip... */
- proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-/*
- * array_open -- open a connection to a remote debugger.
- * NAME is the filename used for communication.
- */
-static int baudrate = 9600;
-static char dev_name[100];
-
-static void
-array_open(args, name, from_tty)
- char *args;
- char *name;
- int from_tty;
-{
- char packet[PBUFSIZ];
-
- if (args == NULL)
- error ("Use `target %s DEVICE-NAME' to use a serial port, or \n\
-`target %s HOST-NAME:PORT-NUMBER' to use a network connection.", name, name);
-
-/* if (is_open) */
- array_close(0);
-
- target_preopen (from_tty);
- unpush_target (&array_ops);
-
- tmp_mips_processor_type = "lsi33k"; /* change the default from r3051 */
- mips_set_processor_type_command ("lsi33k", 0);
-
- strcpy(dev_name, args);
- array_desc = SERIAL_OPEN(dev_name);
-
- if (array_desc == NULL)
- perror_with_name(dev_name);
-
- if (baud_rate != -1) {
- if (SERIAL_SETBAUDRATE (array_desc, baud_rate)) {
- SERIAL_CLOSE (array_desc);
- perror_with_name (name);
- }
- }
-
- SERIAL_RAW(array_desc);
-
-#if defined (LOG_FILE)
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- perror_with_name (LOG_FILE);
- fprintf (log_file, "GDB %s (%s", version);
- fprintf (log_file, " --target %s)\n", array_ops.to_shortname);
- fprintf (log_file, "Remote target %s connected to %s\n\n", array_ops.to_shortname, dev_name);
-#endif
-
- /* see if the target is alive. For a ROM monitor, we can just try to force the
- expect_prompt to print a few times. For the GDB remote protocol, the application
- being debugged is sitting at a breakpoint and waiting for GDB to initialize
- the connection. We force it to give us an empty packet to see if it's alive.
- */
- debuglogs (3, "Trying to ACK the target's debug stub");
- /* unless your are on the new hardware, the old board won't initialize
- because the '@' doesn't flush output like it does on the new ROMS.
- */
- printf_monitor ("@"); /* ask for the last signal */
- expect_prompt(1); /* See if we get a expect_prompt */
-#ifdef TEST_ARRAY /* skip packet for testing */
- make_gdb_packet (packet, "?"); /* ask for a bogus packet */
- if (array_send_packet (packet) == 0)
- error ("Couldn't transmit packet\n");
- printf_monitor ("@\n"); /* force it to flush stdout */
- expect_prompt(1); /* See if we get a expect_prompt */
-#endif
- push_target (&array_ops);
- if (from_tty)
- printf("Remote target %s connected to %s\n", array_ops.to_shortname, dev_name);
-}
-
-/*
- * array_close -- Close out all files and local state before this
- * target loses control.
- */
-
-static void
-array_close (quitting)
- int quitting;
-{
- SERIAL_CLOSE(array_desc);
- array_desc = NULL;
-
- debuglogs (1, "array_close (quitting=%d)", quitting);
-
-#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");
- }
-#endif
-}
-
-/*
- * array_detach -- terminate the open connection to the remote
- * debugger. Use this when you want to detach and do something
- * else with your gdb.
- */
-static void
-array_detach (from_tty)
- int from_tty;
-{
-
- debuglogs (1, "array_detach ()");
-
- pop_target(); /* calls array_close to do the real work */
- if (from_tty)
- printf ("Ending remote %s debugging\n", target_shortname);
-}
-
-/*
- * array_attach -- attach GDB to the target.
- */
-static void
-array_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- if (from_tty)
- printf ("Starting remote %s debugging\n", target_shortname);
-
- debuglogs (1, "array_attach (args=%s)", args);
-
- printf_monitor ("go %x\n");
- /* swallow the echo. */
- expect ("go %x\n", 1);
-}
-
-/*
- * array_resume -- Tell the remote machine to resume.
- */
-static void
-array_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
-{
- debuglogs (1, "array_resume (step=%d, sig=%d)", step, sig);
-
- if (step) {
- printf_monitor ("s\n");
- } else {
- printf_monitor ("go\n");
- }
-}
-
-#define TMPBUFSIZ 5
-
-/*
- * array_wait -- Wait until the remote machine stops, then return,
- * storing status in status just as `wait' would.
- */
-static int
-array_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- int old_timeout = timeout;
- int result, i;
- char c;
- serial_t tty_desc;
- serial_ttystate ttystate;
-
- debuglogs(1, "array_wait (), printing extraneous text.");
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- timeout = 0; /* Don't time out -- user program is running. */
-
-#if !defined(__GO32__) && !defined(__MSDOS__) && !defined(_WIN32)
- tty_desc = SERIAL_FDOPEN (0);
- ttystate = SERIAL_GET_TTY_STATE (tty_desc);
- SERIAL_RAW (tty_desc);
-
- i = 0;
- /* poll on the serial port and the keyboard. */
- while (1) {
- c = readchar(timeout);
- if (c > 0) {
- if (c == *(ARRAY_PROMPT + i)) {
- if (++i >= strlen (ARRAY_PROMPT)) { /* matched the prompt */
- debuglogs (4, "array_wait(), got the expect_prompt.");
- break;
- }
- } else { /* not the prompt */
- i = 0;
- }
- fputc_unfiltered (c, gdb_stdout);
- gdb_flush (gdb_stdout);
- }
- c = SERIAL_READCHAR(tty_desc, timeout);
- if (c > 0) {
- SERIAL_WRITE(array_desc, &c, 1);
- /* do this so it looks like there's keyboard echo */
- if (c == 3) /* exit on Control-C */
- break;
-#if 0
- fputc_unfiltered (c, gdb_stdout);
- gdb_flush (gdb_stdout);
-#endif
- }
- }
- SERIAL_SET_TTY_STATE (tty_desc, ttystate);
-#else
- expect_prompt(1);
- debuglogs (4, "array_wait(), got the expect_prompt.");
-#endif
-
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
-
- timeout = old_timeout;
-
- return 0;
-}
-
-/*
- * array_fetch_registers -- read the remote registers into the
- * block regs.
- */
-static void
-array_fetch_registers (ignored)
- int ignored;
-{
- int regno, i;
- char *p;
- unsigned char packet[PBUFSIZ];
- char regs[REGISTER_BYTES];
-
- debuglogs (1, "array_fetch_registers (ignored=%d)\n", ignored);
-
- memset (packet, 0, PBUFSIZ);
- /* Unimplemented registers read as all bits zero. */
- memset (regs, 0, REGISTER_BYTES);
- make_gdb_packet (packet, "g");
- if (array_send_packet (packet) == 0)
- error ("Couldn't transmit packet\n");
- if (array_get_packet (packet) == 0)
- error ("Couldn't receive packet\n");
- /* FIXME: read bytes from packet */
- debuglogs (4, "array_fetch_registers: Got a \"%s\" back\n", packet);
- for (regno = 0; regno <= PC_REGNUM+4; regno++) {
- /* supply register stores in target byte order, so swap here */
- /* FIXME: convert from ASCII hex to raw bytes */
- i = ascii2hexword (packet + (regno * 8));
- debuglogs (5, "Adding register %d = %x\n", regno, i);
- SWAP_TARGET_AND_HOST (&i, 4);
- supply_register (regno, (char *)&i);
- }
-}
-
-/*
- * This is unused by targets like this one that use a
- * protocol based on GDB's remote protocol.
- */
-static void
-array_fetch_register (ignored)
- int ignored;
-{
- array_fetch_registers ();
-}
-
-/*
- * Get all the registers from the targets. They come back in a large array.
- */
-static void
-array_store_registers (ignored)
- int ignored;
-{
- int regno;
- unsigned long i;
- char packet[PBUFSIZ];
- char buf[PBUFSIZ];
- char num[9];
-
- debuglogs (1, "array_store_registers()");
-
- memset (packet, 0, PBUFSIZ);
- memset (buf, 0, PBUFSIZ);
- buf[0] = 'G';
-
- /* Unimplemented registers read as all bits zero. */
- /* FIXME: read bytes from packet */
- for (regno = 0; regno < 41; regno++) { /* FIXME */
- /* supply register stores in target byte order, so swap here */
- /* FIXME: convert from ASCII hex to raw bytes */
- i = (unsigned long)read_register (regno);
- hexword2ascii (num, i);
- strcpy (buf+(regno * 8)+1, num);
- }
- *(buf + (regno * 8) + 2) = 0;
- make_gdb_packet (packet, buf);
- if (array_send_packet (packet) == 0)
- error ("Couldn't transmit packet\n");
- if (array_get_packet (packet) == 0)
- error ("Couldn't receive packet\n");
-
- registers_changed ();
-}
-
-/*
- * This is unused by targets like this one that use a
- * protocol based on GDB's remote protocol.
- */
-static void
-array_store_register (ignored)
- int ignored;
-{
- array_store_registers ();
-}
-
-/* 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
-array_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static void
-array_files_info ()
-{
- printf ("\tAttached to %s at %d baud.\n",
- dev_name, baudrate);
-}
-
-/*
- * array_write_inferior_memory -- Copy LEN bytes of data from debugger
- * memory at MYADDR to inferior's memory at MEMADDR. Returns length moved.
- */
-static int
-array_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- unsigned long i;
- int j;
- char packet[PBUFSIZ];
- char buf[PBUFSIZ];
- char num[9];
- char *p;
-
- debuglogs (1, "array_write_inferior_memory (memaddr=0x%x, myaddr=0x%x, len=%d)", memaddr, myaddr, len);
- memset (buf, '\0', PBUFSIZ); /* this also sets the string terminator */
- p = buf;
-
- *p++ = 'M'; /* The command to write memory */
- hexword2ascii (num, memaddr); /* convert the address */
- strcpy (p, num); /* copy the address */
- p += 8;
- *p++ = ','; /* add comma delimeter */
- hexword2ascii (num, len); /* Get the length as a 4 digit number */
- *p++ = num[4];
- *p++ = num[5];
- *p++ = num[6];
- *p++ = num[7];
- *p++ = ':'; /* add the colon delimeter */
- for (j = 0; j < len; j++) { /* copy the data in after converting it */
- *p++ = tohex ((myaddr[j] >> 4) & 0xf);
- *p++ = tohex (myaddr[j] & 0xf);
- }
-
- make_gdb_packet (packet, buf);
- if (array_send_packet (packet) == 0)
- error ("Couldn't transmit packet\n");
- if (array_get_packet (packet) == 0)
- error ("Couldn't receive packet\n");
-
- return len;
-}
-
-/*
- * array_read_inferior_memory -- read LEN bytes from inferior memory
- * at MEMADDR. Put the result at debugger address MYADDR. Returns
- * length moved.
- */
-static int
-array_read_inferior_memory(memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- int j;
- char buf[20];
- char packet[PBUFSIZ];
- int count; /* Number of bytes read so far. */
- unsigned long startaddr; /* Starting address of this pass. */
- int len_this_pass; /* Number of bytes to read in this pass. */
-
- debuglogs (1, "array_read_inferior_memory (memaddr=0x%x, myaddr=0x%x, len=%d)", memaddr, myaddr, len);
-
- /* 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
- array_read_bytes (CORE_ADDR_MAX - 4, foo, 4)
- works--it never adds len To memaddr and gets 0. */
- /* However, something like
- array_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) {
- errno = EIO;
- return 0;
- }
-
- for (count = 0, startaddr = memaddr; count < len; startaddr += len_this_pass)
- {
- /* Try to align to 16 byte boundry (why?) */
- len_this_pass = 16;
- if ((startaddr % 16) != 0)
- {
- len_this_pass -= startaddr % 16;
- }
- /* Only transfer bytes we need */
- if (len_this_pass > (len - count))
- {
- len_this_pass = (len - count);
- }
- /* Fetch the bytes */
- debuglogs (3, "read %d bytes from inferior address %x", len_this_pass,
- startaddr);
- sprintf (buf, "m%08x,%04x", startaddr, len_this_pass);
- make_gdb_packet (packet, buf);
- if (array_send_packet (packet) == 0)
- {
- error ("Couldn't transmit packet\n");
- }
- if (array_get_packet (packet) == 0)
- {
- error ("Couldn't receive packet\n");
- }
- if (*packet == 0)
- {
- error ("Got no data in the GDB packet\n");
- }
- /* Pick packet apart and xfer bytes to myaddr */
- debuglogs (4, "array_read_inferior_memory: Got a \"%s\" back\n", packet);
- for (j = 0; j < len_this_pass ; j++)
- {
- /* extract the byte values */
- myaddr[count++] = from_hex (*(packet+(j*2))) * 16 + from_hex (*(packet+(j*2)+1));
- debuglogs (5, "myaddr[%d] set to %x\n", count-1, myaddr[count-1]);
- }
- }
- return (count);
-}
-
-/* FIXME-someday! merge these two. */
-static int
-array_xfer_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* ignored */
-{
- if (write)
- return array_write_inferior_memory (memaddr, myaddr, len);
- else
- return array_read_inferior_memory (memaddr, myaddr, len);
-}
-
-static void
-array_kill (args, from_tty)
- char *args;
- int from_tty;
-{
- return; /* ignore attempts to kill target system */
-}
-
-/* Clean up when a program exits.
- The program actually lives on in the remote processor's RAM, and may be
- run again without a download. Don't leave it full of breakpoint
- instructions. */
-
-static void
-array_mourn_inferior ()
-{
- remove_breakpoints ();
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-
-#define MAX_ARRAY_BREAKPOINTS 16
-
-static CORE_ADDR breakaddr[MAX_ARRAY_BREAKPOINTS] = {0};
-
-/*
- * array_insert_breakpoint -- add a breakpoint
- */
-static int
-array_insert_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
-{
- int i;
- int bp_size = 0;
- CORE_ADDR bp_addr = addr;
-
- debuglogs (1, "array_insert_breakpoint() addr = 0x%x", addr);
- BREAKPOINT_FROM_PC (&bp_addr, &bp_size);
-
- for (i = 0; i <= MAX_ARRAY_BREAKPOINTS; i++) {
- if (breakaddr[i] == 0) {
- breakaddr[i] = addr;
- if (sr_get_debug() > 4)
- printf ("Breakpoint at %x\n", addr);
- array_read_inferior_memory (bp_addr, shadow, bp_size);
- printf_monitor("b 0x%x\n", addr);
- expect_prompt(1);
- return 0;
- }
- }
-
- fprintf(stderr, "Too many breakpoints (> 16) for monitor\n");
- return 1;
-}
-
-/*
- * _remove_breakpoint -- Tell the monitor to remove a breakpoint
- */
-static int
-array_remove_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
-{
- int i;
-
- debuglogs (1, "array_remove_breakpoint() addr = 0x%x", addr);
-
- for (i = 0; i < MAX_ARRAY_BREAKPOINTS; i++) {
- if (breakaddr[i] == addr) {
- breakaddr[i] = 0;
- /* some monitors remove breakpoints based on the address */
- printf_monitor("bd %x\n", i);
- expect_prompt(1);
- return 0;
- }
- }
- fprintf(stderr, "Can't find breakpoint associated with 0x%x\n", addr);
- return 1;
-}
-
-static void
-array_stop ()
-{
- debuglogs (1, "array_stop()");
- printf_monitor("\003");
- expect_prompt(1);
-}
-
-/*
- * array_command -- put a command string, in args, out to MONITOR.
- * Output from MONITOR is placed on the users terminal until the
- * expect_prompt is seen. FIXME
- */
-static void
-monitor_command (args, fromtty)
- char *args;
- int fromtty;
-{
- debuglogs (1, "monitor_command (args=%s)", args);
-
- if (array_desc == NULL)
- error("monitor target not open.");
-
- if (!args)
- error("Missing command.");
-
- printf_monitor ("%s\n", args);
- expect_prompt(0);
-}
-
-/*
- * make_gdb_packet -- make a GDB packet. The data is always ASCII.
- * A debug packet whose contents are <data>
- * is encapsulated for transmission in the form:
- *
- * $ <data> # CSUM1 CSUM2
- *
- * <data> must be ASCII alphanumeric and cannot include characters
- * '$' or '#'. If <data> starts with two characters followed by
- * ':', then the existing stubs interpret this as a sequence number.
- *
- * CSUM1 and CSUM2 are ascii hex representation of an 8-bit
- * checksum of <data>, the most significant nibble is sent first.
- * the hex digits 0-9,a-f are used.
- *
- */
-static void
-make_gdb_packet (buf, data)
- char *buf, *data;
-{
- int i;
- unsigned char csum = 0;
- int cnt;
- char *p;
-
- debuglogs (3, "make_gdb_packet(%s)\n", data);
- cnt = strlen (data);
- if (cnt > PBUFSIZ)
- error ("make_gdb_packet(): to much data\n");
-
- /* start with the packet header */
- p = buf;
- *p++ = '$';
-
- /* calculate the checksum */
- for (i = 0; i < cnt; i++) {
- csum += data[i];
- *p++ = data[i];
- }
-
- /* terminate the data with a '#' */
- *p++ = '#';
-
- /* add the checksum as two ascii digits */
- *p++ = tohex ((csum >> 4) & 0xf);
- *p++ = tohex (csum & 0xf);
- *p = 0x0; /* Null terminator on string */
-}
-
-/*
- * array_send_packet -- send a GDB packet to the target with error handling. We
- * get a '+' (ACK) back if the packet is received and the checksum
- * matches. Otherwise a '-' (NAK) is returned. It returns a 1 for a
- * successful transmition, or a 0 for a failure.
- */
-static int
-array_send_packet (packet)
- char *packet;
-{
- int c, retries, i;
- char junk[PBUFSIZ];
-
- retries = 0;
-
-#if 0
- /* scan the packet to make sure it only contains valid characters.
- this may sound silly, but sometimes a garbled packet will hang
- the target board. We scan the whole thing, then print the error
- message.
- */
- for (i = 0; i < strlen(packet); i++) {
- debuglogs (5, "array_send_packet(): Scanning \'%c\'\n", packet[i]);
- /* legit hex numbers or command */
- if ((isxdigit(packet[i])) || (isalpha(packet[i])))
- continue;
- switch (packet[i]) {
- case '+': /* ACK */
- case '-': /* NAK */
- case '#': /* end of packet */
- case '$': /* start of packet */
- continue;
- default: /* bogus character */
- retries++;
- debuglogs (4, "array_send_packet(): Found a non-ascii digit \'%c\' in the packet.\n", packet[i]);
- }
- }
-#endif
-
- if (retries > 0)
- error ("Can't send packet, found %d non-ascii characters", retries);
-
- /* ok, try to send the packet */
- retries = 0;
- while (retries++ <= 10) {
- printf_monitor ("%s", packet);
-
- /* read until either a timeout occurs (-2) or '+' is read */
- while (retries <= 10) {
- c = readchar (-timeout);
- debuglogs (3, "Reading a GDB protocol packet... Got a '%c'\n", c);
- switch (c) {
- case '+':
- debuglogs (3, "Got Ack\n");
- return 1;
- case SERIAL_TIMEOUT:
- debuglogs (3, "Timed out reading serial port\n");
- printf_monitor("@"); /* resync with the monitor */
- expect_prompt(1); /* See if we get a expect_prompt */
- break; /* Retransmit buffer */
- case '-':
- debuglogs (3, "Got NAK\n");
- printf_monitor("@"); /* resync with the monitor */
- expect_prompt(1); /* See if we get a expect_prompt */
- break;
- case '$':
- /* it's probably an old response, or the echo of our command.
- * just gobble up the packet and ignore it.
- */
- debuglogs (3, "Got a junk packet\n");
- i = 0;
- do {
- c = readchar (timeout);
- junk[i++] = c;
- } while (c != '#');
- c = readchar (timeout);
- junk[i++] = c;
- c = readchar (timeout);
- junk[i++] = c;
- junk[i++] = '\0';
- debuglogs (3, "Reading a junk packet, got a \"%s\"\n", junk);
- continue; /* Now, go look for next packet */
- default:
- continue;
- }
- retries++;
- debuglogs (3, "Retransmitting packet \"%s\"\n", packet);
- break; /* Here to retransmit */
- }
- } /* outer while */
- return 0;
-}
-
-/*
- * array_get_packet -- get a GDB packet from the target. Basically we read till we
- * see a '#', then check the checksum. It returns a 1 if it's gotten a
- * packet, or a 0 it the packet wasn't transmitted correctly.
- */
-static int
-array_get_packet (packet)
- char *packet;
-{
- int c;
- int retries;
- unsigned char csum;
- unsigned char pktcsum;
- char *bp;
-
- csum = 0;
- bp = packet;
-
- memset (packet, 1, PBUFSIZ);
- retries = 0;
- while (retries <= 10) {
- do {
- c = readchar (timeout);
- if (c == SERIAL_TIMEOUT) {
- debuglogs (3, "array_get_packet: got time out from serial port.\n");
- }
- debuglogs (3, "Waiting for a '$', got a %c\n", c);
- } while (c != '$');
-
- retries = 0;
- while (retries <= 10) {
- c = readchar (timeout);
- debuglogs (3, "array_get_packet: got a '%c'\n", c);
- switch (c) {
- case SERIAL_TIMEOUT:
- debuglogs (3, "Timeout in mid-packet, retrying\n");
- return 0;
- case '$':
- debuglogs (3, "Saw new packet start in middle of old one\n");
- return 0; /* Start a new packet, count retries */
- case '#':
- *bp = '\0';
- pktcsum = from_hex (readchar (timeout)) << 4;
- pktcsum |= from_hex (readchar (timeout));
- if (csum == 0)
- debuglogs (3, "\nGDB packet checksum zero, must be a bogus packet\n");
- if (csum == pktcsum) {
- debuglogs (3, "\nGDB packet checksum correct, packet data is \"%s\",\n", packet);
- printf_monitor ("@");
- expect_prompt (1);
- return 1;
- }
- debuglogs (3, "Bad checksum, sentsum=0x%x, csum=0x%x\n", pktcsum, csum);
- return 0;
- case '*': /* Run length encoding */
- debuglogs (5, "Run length encoding in packet\n");
- csum += c;
- c = readchar (timeout);
- csum += c;
- c = c - ' ' + 3; /* Compute repeat count */
-
- if (c > 0 && c < 255 && bp + c - 1 < packet + PBUFSIZ - 1) {
- memset (bp, *(bp - 1), c);
- bp += c;
- continue;
- }
- *bp = '\0';
- printf_filtered ("Repeat count %d too large for buffer.\n", c);
- return 0;
-
- default:
- if ((!isxdigit(c)) && (!ispunct(c)))
- debuglogs (4, "Got a non-ascii digit \'%c\'.\\n", c);
- if (bp < packet + PBUFSIZ - 1) {
- *bp++ = c;
- csum += c;
- continue;
- }
-
- *bp = '\0';
- puts_filtered ("Remote packet too long.\n");
- return 0;
- }
- }
- }
- return 0; /* exceeded retries */
-}
-
-/*
- * ascii2hexword -- convert an ascii number represented by 8 digits to a hex value.
- */
-static unsigned long
-ascii2hexword (mem)
- unsigned char *mem;
-{
- unsigned long val;
- int i;
- char buf[9];
-
- val = 0;
- for (i = 0; i < 8; i++) {
- val <<= 4;
- if (mem[i] >= 'A' && mem[i] <= 'F')
- val = val + mem[i] - 'A' + 10;
- if (mem[i] >= 'a' && mem[i] <= 'f')
- val = val + mem[i] - 'a' + 10;
- if (mem[i] >= '0' && mem[i] <= '9')
- val = val + mem[i] - '0';
- buf[i] = mem[i];
- }
- buf[8] = '\0';
- debuglogs (4, "ascii2hexword() got a 0x%x from %s(%x).\n", val, buf, mem);
- return val;
-}
-
-/*
- * ascii2hexword -- convert a hex value to an ascii number represented by 8
- * digits.
- */
-static void
-hexword2ascii (mem, num)
- unsigned char *mem;
- unsigned long num;
-{
- int i;
- unsigned char ch;
-
- debuglogs (4, "hexword2ascii() converting %x ", num);
- for (i = 7; i >= 0; i--) {
- mem[i] = tohex ((num >> 4) & 0xf);
- mem[i] = tohex (num & 0xf);
- num = num >> 4;
- }
- mem[8] = '\0';
- debuglogs (4, "\tto a %s", mem);
-}
-
-/* Convert hex digit A to a number. */
-static int
-from_hex (a)
- int a;
-{
- if (a == 0)
- return 0;
-
- debuglogs (4, "from_hex got a 0x%x(%c)\n",a,a);
- if (a >= '0' && a <= '9')
- return a - '0';
- if (a >= 'a' && a <= 'f')
- return a - 'a' + 10;
- if (a >= 'A' && a <= 'F')
- return a - 'A' + 10;
- else {
- error ("Reply contains invalid hex digit 0x%x", a);
- }
-}
-
-/* Convert number NIB to a hex digit. */
-static int
-tohex (nib)
- int nib;
-{
- if (nib < 10)
- return '0'+nib;
- else
- return 'a'+nib-10;
-}
-
-/*
- * _initialize_remote_monitors -- setup a few addtitional commands that
- * are usually only used by monitors.
- */
-void
-_initialize_remote_monitors ()
-{
- /* generic monitor command */
- add_com ("monitor", class_obscure, monitor_command,
- "Send a command to the debug monitor.");
-
-}
-
-/*
- * _initialize_array -- do any special init stuff for the target.
- */
-void
-_initialize_array ()
-{
- init_array_ops() ;
- add_target (&array_ops);
-}
diff --git a/contrib/gdb/gdb/remote-bug.c b/contrib/gdb/gdb/remote-bug.c
deleted file mode 100644
index 2efd710..0000000
--- a/contrib/gdb/gdb/remote-bug.c
+++ /dev/null
@@ -1,1099 +0,0 @@
-/* Remote debugging interface for Motorola's MVME187BUG monitor, an embedded
- monitor for the m88k.
-
- Copyright 1992, 1993 Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by K. Richard Pixley.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "wait.h"
-
-#include "gdb_string.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <errno.h>
-
-#include "terminal.h"
-#include "gdbcore.h"
-#include "gdbcmd.h"
-
-#include "remote-utils.h"
-
-
-extern int sleep();
-
-/* External data declarations */
-extern int stop_soon_quietly; /* for wait_for_inferior */
-
-/* Forward data declarations */
-extern struct target_ops bug_ops; /* Forward declaration */
-
-/* Forward function declarations */
-static int bug_clear_breakpoints PARAMS((void));
-
-static int bug_read_memory PARAMS((CORE_ADDR memaddr,
- unsigned char *myaddr,
- int len));
-
-static int bug_write_memory PARAMS((CORE_ADDR memaddr,
- unsigned char *myaddr,
- int len));
-
-/* This variable is somewhat arbitrary. It's here so that it can be
- set from within a running gdb. */
-
-static int srec_max_retries = 3;
-
-/* Each S-record download to the target consists of an S0 header
- record, some number of S3 data records, and one S7 termination
- record. I call this download a "frame". Srec_frame says how many
- bytes will be represented in each frame. */
-
-#define SREC_SIZE 160
-static int srec_frame = SREC_SIZE;
-
-/* This variable determines how many bytes will be represented in each
- S3 s-record. */
-
-static int srec_bytes = 40;
-
-/* At one point it appeared to me as though the bug monitor could not
- really be expected to receive two sequential characters at 9600
- baud reliably. Echo-pacing is an attempt to force data across the
- line even in this condition. Specifically, in echo-pace mode, each
- character is sent one at a time and we look for the echo before
- sending the next. This is excruciatingly slow. */
-
-static int srec_echo_pace = 0;
-
-/* How long to wait after an srec for a possible error message.
- Similar to the above, I tried sleeping after sending each S3 record
- in hopes that I might actually see error messages from the bug
- monitor. This might actually work if we were to use sleep
- intervals smaller than 1 second. */
-
-static int srec_sleep = 0;
-
-/* Every srec_noise records, flub the checksum. This is a debugging
- feature. Set the variable to something other than 1 in order to
- inject *deliberate* checksum errors. One might do this if one
- wanted to test error handling and recovery. */
-
-static int srec_noise = 0;
-
-/* Called when SIGALRM signal sent due to alarm() timeout. */
-
-/* Number of SIGTRAPs we need to simulate. That is, the next
- NEED_ARTIFICIAL_TRAP calls to bug_wait should just return
- SIGTRAP without actually waiting for anything. */
-
-static int need_artificial_trap = 0;
-
-/*
- * Download a file specified in 'args', to the bug.
- */
-
-static void
-bug_load (args, fromtty)
- char *args;
- int fromtty;
-{
- bfd *abfd;
- asection *s;
- char buffer[1024];
-
- sr_check_open ();
-
- dcache_flush (gr_get_dcache());
- inferior_pid = 0;
- abfd = bfd_openr (args, 0);
- if (!abfd)
- {
- printf_filtered ("Unable to open file %s\n", args);
- return;
- }
-
- if (bfd_check_format (abfd, bfd_object) == 0)
- {
- printf_filtered ("File is not an object file\n");
- return;
- }
-
- s = abfd->sections;
- while (s != (asection *) NULL)
- {
- srec_frame = SREC_SIZE;
- if (s->flags & SEC_LOAD)
- {
- int i;
-
- char *buffer = xmalloc (srec_frame);
-
- printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma, s->vma + s->_raw_size);
- gdb_flush (gdb_stdout);
- for (i = 0; i < s->_raw_size; i += srec_frame)
- {
- if (srec_frame > s->_raw_size - i)
- srec_frame = s->_raw_size - i;
-
- bfd_get_section_contents (abfd, s, buffer, i, srec_frame);
- bug_write_memory (s->vma + i, buffer, srec_frame);
- printf_filtered ("*");
- gdb_flush (gdb_stdout);
- }
- printf_filtered ("\n");
- free (buffer);
- }
- s = s->next;
- }
- sprintf (buffer, "rs ip %lx", (unsigned long) abfd->start_address);
- sr_write_cr (buffer);
- gr_expect_prompt ();
-}
-
-#if 0
-static char *
-get_word (p)
- char **p;
-{
- char *s = *p;
- char *word;
- char *copy;
- size_t len;
-
- while (isspace (*s))
- s++;
-
- word = s;
-
- len = 0;
-
- while (*s && !isspace (*s))
- {
- s++;
- len++;
-
- }
- copy = xmalloc (len + 1);
- memcpy (copy, word, len);
- copy[len] = 0;
- *p = s;
- return copy;
-}
-#endif
-
-static struct gr_settings bug_settings = {
- NULL, /* dcache */
- "Bug>", /* prompt */
- &bug_ops, /* ops */
- bug_clear_breakpoints, /* clear_all_breakpoints */
- bug_read_memory, /* readfunc */
- bug_write_memory, /* writefunc */
- gr_generic_checkin, /* checkin */
-};
-
-static char *cpu_check_strings[] = {
- "=",
- "Invalid Register",
-};
-
-static void
-bug_open (args, from_tty)
- char *args;
- int from_tty;
-{
- if (args == NULL)
- args = "";
-
- gr_open(args, from_tty, &bug_settings);
- /* decide *now* whether we are on an 88100 or an 88110 */
- sr_write_cr("rs cr06");
- sr_expect("rs cr06");
-
- switch (gr_multi_scan(cpu_check_strings, 0))
- {
- case 0: /* this is an m88100 */
- target_is_m88110 = 0;
- break;
- case 1: /* this is an m88110 */
- target_is_m88110 = 1;
- break;
- default:
- abort();
- }
-}
-
-/* Tell the remote machine to resume. */
-
-void
-bug_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
-{
- dcache_flush (gr_get_dcache());
-
- if (step)
- {
- sr_write_cr("t");
-
- /* Force the next bug_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
- sr_write_cr ("g");
-
- return;
-}
-
-/* Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-static char *wait_strings[] = {
- "At Breakpoint",
- "Exception: Data Access Fault (Local Bus Timeout)",
- "\r8??\?-Bug>", /* The '\?' avoids creating a trigraph */
- "\r197-Bug>",
- NULL,
-};
-
-int
-bug_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- int old_timeout = sr_get_timeout();
- int old_immediate_quit = immediate_quit;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- /* read off leftovers from resume so that the rest can be passed
- back out as stdout. */
- if (need_artificial_trap == 0)
- {
- sr_expect("Effective address: ");
- (void) sr_get_hex_word();
- sr_expect ("\r\n");
- }
-
- sr_set_timeout(-1); /* Don't time out -- user program is running. */
- immediate_quit = 1; /* Helps ability to QUIT */
-
- switch (gr_multi_scan(wait_strings, need_artificial_trap == 0))
- {
- case 0: /* breakpoint case */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- /* user output from the target can be discarded here. (?) */
- gr_expect_prompt();
- break;
-
- case 1: /* bus error */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_BUS;
- /* user output from the target can be discarded here. (?) */
- gr_expect_prompt();
- break;
-
- case 2: /* normal case */
- case 3:
- if (need_artificial_trap != 0)
- {
- /* stepping */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- need_artificial_trap--;
- break;
- }
- else
- {
- /* exit case */
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- break;
- }
-
- case -1: /* trouble */
- default:
- fprintf_filtered (gdb_stderr,
- "Trouble reading target during wait\n");
- break;
- }
-
- sr_set_timeout(old_timeout);
- immediate_quit = old_immediate_quit;
- return 0;
-}
-
-/* Return the name of register number REGNO
- in the form input and output by bug.
-
- Returns a pointer to a static buffer containing the answer. */
-static char *
-get_reg_name (regno)
- int regno;
-{
- static char *rn[] = {
- "r00", "r01", "r02", "r03", "r04", "r05", "r06", "r07",
- "r08", "r09", "r10", "r11", "r12", "r13", "r14", "r15",
- "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
- "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
-
- /* these get confusing because we omit a few and switch some ordering around. */
-
- "cr01", /* 32 = psr */
- "fcr62", /* 33 = fpsr*/
- "fcr63", /* 34 = fpcr */
- "ip", /* this is something of a cheat. */
- /* 35 = sxip */
- "cr05", /* 36 = snip */
- "cr06", /* 37 = sfip */
-
- "x00", "x01", "x02", "x03", "x04", "x05", "x06", "x07",
- "x08", "x09", "x10", "x11", "x12", "x13", "x14", "x15",
- "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23",
- "x24", "x25", "x26", "x27", "x28", "x29", "x30", "x31",
- };
-
- return rn[regno];
-}
-
-#if 0 /* not currently used */
-/* Read from remote while the input matches STRING. Return zero on
- success, -1 on failure. */
-
-static int
-bug_scan (s)
- char *s;
-{
- int c;
-
- while (*s)
- {
- c = sr_readchar();
- if (c != *s++)
- {
- fflush(stdout);
- printf("\nNext character is '%c' - %d and s is \"%s\".\n", c, c, --s);
- return(-1);
- }
- }
-
- return(0);
-}
-#endif /* never */
-
-static int
-bug_srec_write_cr (s)
- char *s;
-{
- char *p = s;
-
- if (srec_echo_pace)
- for (p = s; *p; ++p)
- {
- if (sr_get_debug() > 0)
- printf ("%c", *p);
-
- do
- SERIAL_WRITE(sr_get_desc(), p, 1);
- while (sr_pollchar() != *p);
- }
- else
- {
- sr_write_cr (s);
-/* return(bug_scan (s) || bug_scan ("\n")); */
- }
-
- return(0);
-}
-
-/* Store register REGNO, or all if REGNO == -1. */
-
-static void
-bug_fetch_register(regno)
- int regno;
-{
- sr_check_open();
-
- if (regno == -1)
- {
- int i;
-
- for (i = 0; i < NUM_REGS; ++i)
- bug_fetch_register(i);
- }
- else if (target_is_m88110 && regno == SFIP_REGNUM)
- {
- /* m88110 has no sfip. */
- long l = 0;
- supply_register(regno, (char *) &l);
- }
- else if (regno < XFP_REGNUM)
- {
- char buffer[MAX_REGISTER_RAW_SIZE];
-
- sr_write ("rs ", 3);
- sr_write_cr (get_reg_name(regno));
- sr_expect ("=");
- store_unsigned_integer (buffer, REGISTER_RAW_SIZE (regno),
- sr_get_hex_word());
- gr_expect_prompt ();
- supply_register (regno, buffer);
- }
- else
- {
- /* Float register so we need to parse a strange data format. */
- long p;
- unsigned char fpreg_buf[10];
-
- sr_write("rs ", 3);
- sr_write(get_reg_name(regno), strlen(get_reg_name(regno)));
- sr_write_cr(";d");
- sr_expect("rs");
- sr_expect(get_reg_name(regno));
- sr_expect(";d");
- sr_expect("=");
-
- /* sign */
- p = sr_get_hex_digit(1);
- fpreg_buf[0] = p << 7;
-
- /* exponent */
- sr_expect("_");
- p = sr_get_hex_digit(1);
- fpreg_buf[0] += (p << 4);
- fpreg_buf[0] += sr_get_hex_digit(1);
-
- fpreg_buf[1] = sr_get_hex_digit(1) << 4;
-
- /* fraction */
- sr_expect("_");
- fpreg_buf[1] += sr_get_hex_digit(1);
-
- fpreg_buf[2] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
- fpreg_buf[3] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
- fpreg_buf[4] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
- fpreg_buf[5] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
- fpreg_buf[6] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
- fpreg_buf[7] = (sr_get_hex_digit(1) << 4) + sr_get_hex_digit(1);
- fpreg_buf[8] = 0;
- fpreg_buf[9] = 0;
-
- gr_expect_prompt();
- supply_register(regno, fpreg_buf);
- }
-
- return;
-}
-
-/* Store register REGNO, or all if REGNO == -1. */
-
-static void
-bug_store_register (regno)
- int regno;
-{
- char buffer[1024];
- sr_check_open();
-
- if (regno == -1)
- {
- int i;
-
- for (i = 0; i < NUM_REGS; ++i)
- bug_store_register(i);
- }
- else
- {
- char *regname;
-
- regname = get_reg_name(regno);
-
- if (target_is_m88110 && regno == SFIP_REGNUM)
- return;
- else if (regno < XFP_REGNUM)
- sprintf(buffer, "rs %s %08x",
- regname,
- read_register(regno));
- else
- {
- unsigned char *fpreg_buf =
- (unsigned char *)&registers[REGISTER_BYTE(regno)];
-
- sprintf(buffer, "rs %s %1x_%02x%1x_%1x%02x%02x%02x%02x%02x%02x;d",
- regname,
- /* sign */
- (fpreg_buf[0] >> 7) & 0xf,
- /* exponent */
- fpreg_buf[0] & 0x7f,
- (fpreg_buf[1] >> 8) & 0xf,
- /* fraction */
- fpreg_buf[1] & 0xf,
- fpreg_buf[2],
- fpreg_buf[3],
- fpreg_buf[4],
- fpreg_buf[5],
- fpreg_buf[6],
- fpreg_buf[7]);
- }
-
- sr_write_cr(buffer);
- gr_expect_prompt();
- }
-
- return;
-}
-
-int
-bug_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;
-
- /* Round ending address up; get number of longwords that makes. */
- register int count;
-
- /* Allocate buffer of that many longwords. */
- register int *buffer;
-
- addr = memaddr & -sizeof (int);
- count = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (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] = gr_fetch_word (addr);
- }
-
- if (count > 1) /* FIXME, avoid if even boundary */
- {
- buffer[count - 1]
- = gr_fetch_word (addr + (count - 1) * sizeof (int));
- }
-
- /* Copy data to be written over corresponding part of buffer */
-
- memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
-
- /* Write the entire buffer. */
-
- for (i = 0; i < count; i++, addr += sizeof (int))
- {
- errno = 0;
- gr_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] = gr_fetch_word (addr);
- if (errno)
- {
- return 0;
- }
- QUIT;
- }
-
- /* Copy appropriate bytes out of the buffer. */
- memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
- }
-
- return len;
-}
-
-static void
-start_load()
-{
- char *command;
-
- command = (srec_echo_pace ? "lo 0 ;x" : "lo 0");
-
- sr_write_cr (command);
- sr_expect (command);
- sr_expect ("\r\n");
- bug_srec_write_cr ("S0030000FC");
- return;
-}
-
-/* This is an extremely vulnerable and fragile function. I've made
- considerable attempts to make this deterministic, but I've
- certainly forgotten something. The trouble is that S-records are
- only a partial file format, not a protocol. Worse, apparently the
- m88k bug monitor does not run in real time while receiving
- S-records. Hence, we must pay excruciating attention to when and
- where error messages are returned, and what has actually been sent.
-
- Each call represents a chunk of memory to be sent to the target.
- We break that chunk into an S0 header record, some number of S3
- data records each containing srec_bytes, and an S7 termination
- record. */
-
-static char *srecord_strings[] = {
- "S-RECORD",
- "-Bug>",
- NULL,
-};
-
-static int
-bug_write_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- int done;
- int checksum;
- int x;
- int retries;
- char *buffer = alloca ((srec_bytes + 8) << 1);
-
- retries = 0;
-
- do
- {
- done = 0;
-
- if (retries > srec_max_retries)
- return(-1);
-
- if (retries > 0)
- {
- if (sr_get_debug() > 0)
- printf("\n<retrying...>\n");
-
- /* This gr_expect_prompt call is extremely important. Without
- it, we will tend to resend our packet so fast that it
- will arrive before the bug monitor is ready to receive
- it. This would lead to a very ugly resend loop. */
-
- gr_expect_prompt();
- }
-
- start_load();
-
- while (done < len)
- {
- int thisgo;
- int idx;
- char *buf = buffer;
- CORE_ADDR address;
-
- checksum = 0;
- thisgo = len - done;
- if (thisgo > srec_bytes)
- thisgo = srec_bytes;
-
- address = memaddr + done;
- sprintf (buf, "S3%02X%08X", thisgo + 4 + 1, address);
- buf += 12;
-
- checksum += (thisgo + 4 + 1
- + (address & 0xff)
- + ((address >> 8) & 0xff)
- + ((address >> 16) & 0xff)
- + ((address >> 24) & 0xff));
-
- for (idx = 0; idx < thisgo; idx++)
- {
- sprintf (buf, "%02X", myaddr[idx + done]);
- checksum += myaddr[idx + done];
- buf += 2;
- }
-
- if (srec_noise > 0)
- {
- /* FIXME-NOW: insert a deliberate error every now and then.
- This is intended for testing/debugging the error handling
- stuff. */
- static int counter = 0;
- if (++counter > srec_noise)
- {
- counter = 0;
- ++checksum;
- }
- }
-
- sprintf(buf, "%02X", ~checksum & 0xff);
- bug_srec_write_cr (buffer);
-
- if (srec_sleep != 0)
- sleep(srec_sleep);
-
- /* This pollchar is probably redundant to the gr_multi_scan
- below. Trouble is, we can't be sure when or where an
- error message will appear. Apparently, when running at
- full speed from a typical sun4, error messages tend to
- appear to arrive only *after* the s7 record. */
-
- if ((x = sr_pollchar()) != 0)
- {
- if (sr_get_debug() > 0)
- printf("\n<retrying...>\n");
-
- ++retries;
-
- /* flush any remaining input and verify that we are back
- at the prompt level. */
- gr_expect_prompt();
- /* start all over again. */
- start_load();
- done = 0;
- continue;
- }
-
- done += thisgo;
- }
-
- bug_srec_write_cr("S7060000000000F9");
- ++retries;
-
- /* Having finished the load, we need to figure out whether we
- had any errors. */
- } while (gr_multi_scan(srecord_strings, 0) == 0);;
-
- return(0);
-}
-
-/* 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.
- */
-
-/* Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns errno value. */
-static int
-bug_read_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- char request[100];
- char *buffer;
- char *p;
- char type;
- char size;
- unsigned char c;
- unsigned int inaddr;
- unsigned int checksum;
-
- sprintf(request, "du 0 %x:&%d", memaddr, len);
- sr_write_cr(request);
-
- p = buffer = alloca(len);
-
- /* scan up through the header */
- sr_expect("S0030000FC");
-
- while (p < buffer + len)
- {
- /* scan off any white space. */
- while (sr_readchar() != 'S') ;;
-
- /* what kind of s-rec? */
- type = sr_readchar();
-
- /* scan record size */
- sr_get_hex_byte(&size);
- checksum = size;
- --size;
- inaddr = 0;
-
- switch (type)
- {
- case '7':
- case '8':
- case '9':
- goto done;
-
- case '3':
- sr_get_hex_byte(&c);
- inaddr = (inaddr << 8) + c;
- checksum += c;
- --size;
- /* intentional fall through */
- case '2':
- sr_get_hex_byte(&c);
- inaddr = (inaddr << 8) + c;
- checksum += c;
- --size;
- /* intentional fall through */
- case '1':
- sr_get_hex_byte(&c);
- inaddr = (inaddr << 8) + c;
- checksum += c;
- --size;
- sr_get_hex_byte(&c);
- inaddr = (inaddr << 8) + c;
- checksum += c;
- --size;
- break;
-
- default:
- /* bonk */
- error("reading s-records.");
- }
-
- if (inaddr < memaddr
- || (memaddr + len) < (inaddr + size))
- error("srec out of memory range.");
-
- if (p != buffer + inaddr - memaddr)
- error("srec out of sequence.");
-
- for (; size; --size, ++p)
- {
- sr_get_hex_byte(p);
- checksum += *p;
- }
-
- sr_get_hex_byte(&c);
- if (c != (~checksum & 0xff))
- error("bad s-rec checksum");
- }
-
- done:
- gr_expect_prompt();
- if (p != buffer + len)
- return(1);
-
- memcpy(myaddr, buffer, len);
- return(0);
-}
-
-#define MAX_BREAKS 16
-static int num_brkpts = 0;
-static int
-bug_insert_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save; /* Throw away, let bug save instructions */
-{
- sr_check_open ();
-
- if (num_brkpts < MAX_BREAKS)
- {
- char buffer[100];
-
- num_brkpts++;
- sprintf (buffer, "br %x", addr);
- sr_write_cr (buffer);
- gr_expect_prompt ();
- return(0);
- }
- else
- {
- fprintf_filtered (gdb_stderr,
- "Too many break points, break point not installed\n");
- return(1);
- }
-
-}
-static int
-bug_remove_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save; /* Throw away, let bug save instructions */
-{
- if (num_brkpts > 0)
- {
- char buffer[100];
-
- num_brkpts--;
- sprintf (buffer, "nobr %x", addr);
- sr_write_cr (buffer);
- gr_expect_prompt ();
-
- }
- return (0);
-}
-
-/* Clear the bugs notion of what the break points are */
-static int
-bug_clear_breakpoints ()
-{
-
- if (sr_is_open())
- {
- sr_write_cr ("nobr");
- sr_expect("nobr");
- gr_expect_prompt ();
- }
- num_brkpts = 0;
- return(0);
-}
-
-struct target_ops bug_ops ;
-
-static void
-init_bug_ops(void)
-{
- bug_ops.to_shortname = "bug"; "Remote BUG monitor",
- bug_ops.to_longname = "Use the mvme187 board running the BUG monitor connected by a serial line.";
- bug_ops.to_doc = " ";
- bug_ops.to_open = bug_open;
- bug_ops.to_close = gr_close;
- bug_ops.to_attach = 0;
- bug_ops.to_post_attach = NULL;
- bug_ops.to_require_attach = NULL;
- bug_ops.to_detach = gr_detach;
- bug_ops.to_require_detach = NULL;
- bug_ops.to_resume = bug_resume;
- bug_ops.to_wait = bug_wait;
- bug_ops.to_post_wait = NULL;
- bug_ops.to_fetch_registers = bug_fetch_register;
- bug_ops.to_store_registers = bug_store_register;
- bug_ops.to_prepare_to_store = gr_prepare_to_store;
- bug_ops.to_xfer_memory = bug_xfer_memory;
- bug_ops.to_files_info = gr_files_info;
- bug_ops.to_insert_breakpoint = bug_insert_breakpoint;
- bug_ops.to_remove_breakpoint = bug_remove_breakpoint;
- bug_ops.to_terminal_init = 0;
- bug_ops.to_terminal_inferior = 0;
- bug_ops.to_terminal_ours_for_output = 0;
- bug_ops.to_terminal_ours = 0;
- bug_ops.to_terminal_info = 0;
- bug_ops.to_kill = gr_kill;
- bug_ops.to_load = bug_load;
- bug_ops.to_lookup_symbol = 0;
- bug_ops.to_create_inferior = gr_create_inferior;
- bug_ops.to_post_startup_inferior = NULL;
- bug_ops.to_acknowledge_created_inferior = NULL;
- bug_ops.to_clone_and_follow_inferior = NULL;
- bug_ops.to_post_follow_inferior_by_clone = NULL;
- bug_ops.to_insert_fork_catchpoint = NULL;
- bug_ops.to_remove_fork_catchpoint = NULL;
- bug_ops.to_insert_vfork_catchpoint = NULL;
- bug_ops.to_remove_vfork_catchpoint = NULL;
- bug_ops.to_has_forked = NULL;
- bug_ops.to_has_vforked = NULL;
- bug_ops.to_can_follow_vfork_prior_to_exec = NULL;
- bug_ops.to_post_follow_vfork = NULL;
- bug_ops.to_insert_exec_catchpoint = NULL;
- bug_ops.to_remove_exec_catchpoint = NULL;
- bug_ops.to_has_execd = NULL;
- bug_ops.to_reported_exec_events_per_exec_call = NULL;
- bug_ops.to_has_exited = NULL;
- bug_ops.to_mourn_inferior = gr_mourn;
- bug_ops.to_can_run = 0;
- bug_ops.to_notice_signals = 0;
- bug_ops.to_thread_alive = 0 ;
- bug_ops.to_stop = 0;
- bug_ops.to_pid_to_exec_file = NULL;
- bug_ops.to_core_file_to_sym_file = NULL;
- bug_ops.to_stratum = process_stratum ;
- bug_ops.DONT_USE = 0;
- bug_ops.to_has_all_memory = 1;
- bug_ops.to_has_memory = 1;
- bug_ops.to_has_stack = 1;
- bug_ops.to_has_registers = 0;
- bug_ops.to_has_execution = 0;
- bug_ops.to_sections = 0 ;
- bug_ops.to_sections_end = 0 ;
- bug_ops.to_magic = OPS_MAGIC; /* Always the last thing */
-} /* init_bug_ops */
-
-void
-_initialize_remote_bug ()
-{
- init_bug_ops() ;
- add_target (&bug_ops);
-
- add_show_from_set
- (add_set_cmd ("srec-bytes", class_support, var_uinteger,
- (char *) &srec_bytes,
- "\
-Set the number of bytes represented in each S-record.\n\
-This affects the communication protocol with the remote target.",
- &setlist),
- &showlist);
-
- add_show_from_set
- (add_set_cmd ("srec-max-retries", class_support, var_uinteger,
- (char *) &srec_max_retries,
- "\
-Set the number of retries for shipping S-records.\n\
-This affects the communication protocol with the remote target.",
- &setlist),
- &showlist);
-
-#if 0
- /* This needs to set SREC_SIZE, not srec_frame which gets changed at the
- end of a download. But do we need the option at all? */
- add_show_from_set
- (add_set_cmd ("srec-frame", class_support, var_uinteger,
- (char *) &srec_frame,
- "\
-Set the number of bytes in an S-record frame.\n\
-This affects the communication protocol with the remote target.",
- &setlist),
- &showlist);
-#endif /* 0 */
-
- add_show_from_set
- (add_set_cmd ("srec-noise", class_support, var_zinteger,
- (char *) &srec_noise,
- "\
-Set number of S-record to send before deliberately flubbing a checksum.\n\
-Zero means flub none at all. This affects the communication protocol\n\
-with the remote target.",
- &setlist),
- &showlist);
-
- add_show_from_set
- (add_set_cmd ("srec-sleep", class_support, var_zinteger,
- (char *) &srec_sleep,
- "\
-Set number of seconds to sleep after an S-record for a possible error message to arrive.\n\
-This affects the communication protocol with the remote target.",
- &setlist),
- &showlist);
-
- add_show_from_set
- (add_set_cmd ("srec-echo-pace", class_support, var_boolean,
- (char *) &srec_echo_pace,
- "\
-Set echo-verification.\n\
-When on, use verification by echo when downloading S-records. This is\n\
-much slower, but generally more reliable.",
- &setlist),
- &showlist);
-}
diff --git a/contrib/gdb/gdb/remote-e7000.c b/contrib/gdb/gdb/remote-e7000.c
deleted file mode 100644
index 92e69b3..0000000
--- a/contrib/gdb/gdb/remote-e7000.c
+++ /dev/null
@@ -1,2258 +0,0 @@
-/* Remote debugging interface for Hitachi E7000 ICE, for GDB
- Copyright 1993, 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
-
- Written by Steve Chamberlain for Cygnus Support.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* The E7000 is an in-circuit emulator for the Hitachi H8/300-H and
- Hitachi-SH processor. It has serial port and a lan port.
-
- The monitor command set makes it difficult to load large ammounts of
- data over the lan without using ftp - so try not to issue load
- commands when communicating over ethernet; use the ftpload command.
-
- The monitor pauses for a second when dumping srecords to the serial
- line too, so we use a slower per byte mechanism but without the
- startup overhead. Even so, it's pretty slow... */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "gdbarch.h"
-#include "inferior.h"
-#include "target.h"
-#include "wait.h"
-#include "value.h"
-#include "command.h"
-#include <signal.h>
-#include "gdb_string.h"
-#include "gdbcmd.h"
-#include <sys/types.h>
-#include "serial.h"
-#include "remote-utils.h"
-#include "symfile.h"
-#include <time.h>
-#include <ctype.h>
-
-
-#if 1
-#define HARD_BREAKPOINTS /* Now handled by set option. */
-#define BC_BREAKPOINTS use_hard_breakpoints
-#endif
-
-#define CTRLC 0x03
-#define ENQ 0x05
-#define ACK 0x06
-#define CTRLZ 0x1a
-
-extern void notice_quit PARAMS ((void));
-
-extern void report_transfer_performance PARAMS ((unsigned long,
- time_t, time_t));
-
-extern char *sh_processor_type;
-
-/* Local function declarations. */
-
-static void e7000_close PARAMS ((int));
-
-static void e7000_fetch_register PARAMS ((int));
-
-static void e7000_store_register PARAMS ((int));
-
-static void e7000_command PARAMS ((char *, int));
-
-static void e7000_login_command PARAMS ((char *, int));
-
-static void e7000_ftp_command PARAMS ((char *, int));
-
-static void e7000_drain_command PARAMS ((char *, int));
-
-static void expect PARAMS ((char *));
-
-static void expect_full_prompt PARAMS ((void));
-
-static void expect_prompt PARAMS ((void));
-
-static int e7000_parse_device PARAMS ((char *args, char *dev_name,
- int baudrate));
-/* Variables. */
-
-static serial_t e7000_desc;
-
-/* Allow user to chose between using hardware breakpoints or memory. */
-static int use_hard_breakpoints = 0; /* use sw breakpoints by default */
-
-/* Nonzero if using the tcp serial driver. */
-
-static int using_tcp; /* direct tcp connection to target */
-static int using_tcp_remote; /* indirect connection to target
- via tcp to controller */
-
-/* Nonzero if using the pc isa card. */
-
-static int using_pc;
-
-extern struct target_ops e7000_ops; /* Forward declaration */
-
-char *ENQSTRING = "\005";
-
-/* Nonzero if some routine (as opposed to the user) wants echoing.
- FIXME: Do this reentrantly with an extra parameter. */
-
-static int echo;
-
-static int ctrl_c;
-
-static int timeout = 20;
-
-/* Send data to e7000debug. */
-
-static void
-puts_e7000debug (buf)
- char *buf;
-{
- if (!e7000_desc)
- error ("Use \"target e7000 ...\" first.");
-
- if (remote_debug)
- printf_unfiltered ("Sending %s\n", buf);
-
- if (SERIAL_WRITE (e7000_desc, buf, strlen (buf)))
- fprintf_unfiltered (gdb_stderr, "SERIAL_WRITE failed: %s\n", safe_strerror (errno));
-
- /* And expect to see it echoed, unless using the pc interface */
-#if 0
- if (!using_pc)
-#endif
- expect (buf);
-}
-
-static void
-putchar_e7000 (x)
- int x;
-{
- char b[1];
-
- b[0] = x;
- SERIAL_WRITE (e7000_desc, b, 1);
-}
-
-static void
-write_e7000 (s)
- char *s;
-{
- SERIAL_WRITE (e7000_desc, s, strlen (s));
-}
-
-static int
-normal (x)
- int x;
-{
- if (x == '\n')
- return '\r';
- return x;
-}
-
-/* Read a character from the remote system, doing all the fancy timeout
- stuff. Handles serial errors and EOF. If TIMEOUT == 0, and no chars,
- returns -1, else returns next char. Discards chars > 127. */
-
-static int
-readchar (timeout)
- int timeout;
-{
- int c;
-
- do
- {
- c = SERIAL_READCHAR (e7000_desc, timeout);
- }
- while (c > 127);
-
- if (c == SERIAL_TIMEOUT)
- {
- if (timeout == 0)
- return -1;
- echo = 0;
- error ("Timeout reading from remote system.");
- }
- else if (c < 0)
- error ("Serial communication error");
-
- if (remote_debug)
- {
- putchar_unfiltered (c);
- gdb_flush (gdb_stdout);
- }
-
- return normal (c);
-}
-
-#if 0
-char *
-tl (x)
-{
- static char b[8][10];
- static int p;
-
- p++;
- p &= 7;
- if (x >= ' ')
- {
- b[p][0] = x;
- b[p][1] = 0;
- }
- else
- {
- sprintf(b[p], "<%d>", x);
- }
-
- return b[p];
-}
-#endif
-
-/* Scan input from the remote system, until STRING is found. If
- DISCARD is non-zero, then discard non-matching input, else print it
- out. Let the user break out immediately. */
-
-static void
-expect (string)
- char *string;
-{
- char *p = string;
- int c;
- int nl = 0;
-
- while (1)
- {
- c = readchar (timeout);
-#if 0
- notice_quit ();
- if (quit_flag == 1)
- {
- if (ctrl_c)
- {
- putchar_e7000(CTRLC);
- --ctrl_c;
- }
- else
- {
- quit ();
- }
- }
-#endif
-
- if (echo)
- {
- if (c == '\r' || c == '\n')
- {
- if (!nl)
- putchar_unfiltered ('\n');
- nl = 1;
- }
- else
- {
- nl = 0;
- putchar_unfiltered (c);
- }
- gdb_flush (gdb_stdout);
- }
- if (normal (c) == normal (*p++))
- {
- if (*p == '\0')
- return;
- }
- else
- {
- p = string;
-
- if (normal (c) == normal (string[0]))
- p++;
- }
- }
-}
-
-/* Keep discarding input until we see the e7000 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: e7000_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
- e7000_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 ()
-{
- expect (":");
-}
-
-static void
-expect_full_prompt ()
-{
- expect ("\r:");
-}
-
-static int
-convert_hex_digit (ch)
- int ch;
-{
- 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;
- return -1;
-}
-
-static int
-get_hex (start)
- int *start;
-{
- int value = convert_hex_digit (*start);
- int try;
-
- *start = readchar (timeout);
- while ((try = convert_hex_digit (*start)) >= 0)
- {
- value <<= 4;
- value += try;
- *start = readchar (timeout);
- }
- return value;
-}
-
-#if 0
-/* 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++, (char *) &val);
- }
-}
-#endif
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-
-static void
-e7000_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- int entry_pt;
-
- if (args && *args)
- error ("Can't pass arguments to remote E7000DEBUG process");
-
- if (execfile == 0 || exec_bfd == 0)
- error ("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
-#ifdef CREATE_INFERIOR_HOOK
- CREATE_INFERIOR_HOOK (0); /* No process-ID */
-#endif
-
- /* The "process" (board) is already stopped awaiting our commands, and
- the program is already downloaded. We just set its PC and go. */
-
- clear_proceed_status ();
-
- /* Tell wait_for_inferior that we've started a new process. */
- 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 ();
-
- /* insert_step_breakpoint (); FIXME, do we need this? */
- proceed ((CORE_ADDR) entry_pt, -1, 0); /* Let 'er rip... */
-}
-
-/* Open a connection to a remote debugger. NAME is the filename used
- for communication. */
-
-static int baudrate = 9600;
-static char dev_name[100];
-
-static char *machine = "";
-static char *user = "";
-static char *passwd = "";
-static char *dir = "";
-
-/* Grab the next token and buy some space for it */
-
-static char *
-next (ptr)
- char **ptr;
-{
- char *p = *ptr;
- char *s;
- char *r;
- int l = 0;
-
- while (*p && *p == ' ')
- p++;
- s = p;
- while (*p && (*p != ' ' && *p != '\t'))
- {
- l++;
- p++;
- }
- r = xmalloc (l + 1);
- memcpy (r, s, l);
- r[l] = 0;
- *ptr = p;
- return r;
-}
-
-static void
-e7000_login_command (args, from_tty)
- char *args;
- int from_tty;
-{
- if (args)
- {
- machine = next (&args);
- user = next (&args);
- passwd = next (&args);
- dir = next (&args);
- if (from_tty)
- {
- printf_unfiltered ("Set info to %s %s %s %s\n", machine, user, passwd, dir);
- }
- }
- else
- {
- error ("Syntax is ftplogin <machine> <user> <passwd> <directory>");
- }
-}
-
-/* Start an ftp transfer from the E7000 to a host */
-
-static void
-e7000_ftp_command (args, from_tty)
- char *args;
- int from_tty;
-{
- /* FIXME: arbitrary limit on machine names and such. */
- char buf[200];
-
- int oldtimeout = timeout;
- timeout = remote_timeout;
-
- sprintf (buf, "ftp %s\r", machine);
- puts_e7000debug (buf);
- expect (" Username : ");
- sprintf (buf, "%s\r", user);
- puts_e7000debug (buf);
- expect (" Password : ");
- write_e7000 (passwd);
- write_e7000 ("\r");
- expect ("success\r");
- expect ("FTP>");
- sprintf (buf, "cd %s\r", dir);
- puts_e7000debug (buf);
- expect ("FTP>");
- sprintf (buf, "ll 0;s:%s\r", args);
- puts_e7000debug (buf);
- expect ("FTP>");
- puts_e7000debug ("bye\r");
- expect (":");
- timeout = oldtimeout;
-}
-
-static int
-e7000_parse_device (args, dev_name, baudrate)
- char *args;
- char *dev_name;
- int baudrate;
-{
- char junk[128];
- int n = 0;
- if (args && strcasecmp (args, "pc") == 0)
- {
- strcpy (dev_name, args);
- using_pc = 1;
- }
- else
- {
- /* FIXME! temp hack to allow use with port master -
- target tcp_remote <device> */
- if (args && strncmp (args, "tcp", 10) == 0)
- {
- char com_type[128];
- n = sscanf (args, " %s %s %d %s", com_type, dev_name, &baudrate, junk);
- using_tcp_remote=1;
- n--;
- }
- else if (args)
- {
- n = sscanf (args, " %s %d %s", dev_name, &baudrate, junk);
- }
-
- if (n != 1 && n != 2)
- {
- error ("Bad arguments. Usage:\ttarget e7000 <device> <speed>\n\
-or \t\ttarget e7000 <host>[:<port>]\n\
-or \t\ttarget e7000 tcp_remote <host>[:<port>]\n\
-or \t\ttarget e7000 pc\n");
- }
-
-#if !defined(__GO32__) && !defined(_WIN32)
- /* FIXME! test for ':' is ambiguous */
- if (n == 1 && strchr (dev_name, ':') == 0)
- {
- /* Default to normal telnet port */
- /* serial_open will use this to determine tcp communication */
- strcat (dev_name, ":23");
- }
-#endif
- if (!using_tcp_remote && strchr (dev_name, ':'))
- using_tcp = 1;
- }
-
- return n;
-}
-
-/* Stub for catch_errors. */
-
-static int
-e7000_start_remote (dummy)
- char *dummy;
-{
- int loop;
- int sync;
- int try;
- int quit_trying;
-
- immediate_quit = 1; /* Allow user to interrupt it */
-
- /* Hello? Are you there? */
- sync = 0;
- loop = 0;
- try = 0;
- quit_trying = 20;
- putchar_e7000 (CTRLC);
- while (!sync && ++try <= quit_trying)
- {
- int c;
-
- printf_unfiltered ("[waiting for e7000...]\n");
-
- write_e7000 ("\r");
- c = readchar (1);
-
- /* FIXME! this didn't seem right-> while (c != SERIAL_TIMEOUT)
- * we get stuck in this loop ...
- * We may never timeout, and never sync up :-(
- */
- while (!sync && c != -1)
- {
- /* Dont echo cr's */
- if (c != '\r')
- {
- putchar_unfiltered (c);
- gdb_flush (gdb_stdout);
- }
- /* Shouldn't we either break here, or check for sync in inner loop? */
- if (c == ':')
- sync = 1;
-
- if (loop++ == 20)
- {
- putchar_e7000 (CTRLC);
- loop = 0;
- }
-
- QUIT ;
-
- if (quit_flag)
- {
- putchar_e7000 (CTRLC);
- /* Was-> quit_flag = 0; */
- c = -1;
- quit_trying = try+1; /* we don't want to try anymore */
- }
- else
- {
- c = readchar (1);
- }
- }
- }
-
- if (!sync)
- {
- fprintf_unfiltered (gdb_stderr, "Giving up after %d tries...\n",try);
- error ("Unable to syncronize with target.\n");
- }
-
- puts_e7000debug ("\r");
- expect_prompt ();
- puts_e7000debug ("b -\r"); /* Clear breakpoints */
- expect_prompt ();
-
- immediate_quit = 0;
-
-/* This is really the job of start_remote however, that makes an assumption
- that the target is about to print out a status message of some sort. That
- doesn't happen here. */
-
- flush_cached_frames ();
- registers_changed ();
- stop_pc = read_pc ();
- set_current_frame (create_new_frame (read_fp (), stop_pc));
- select_frame (get_current_frame (), 0);
- print_stack_frame (selected_frame, -1, 1);
-
- return 1;
-}
-
-static void
-e7000_open (args, from_tty)
- char *args;
- int from_tty;
-{
- int n;
-
- target_preopen (from_tty);
-
- n = e7000_parse_device (args, dev_name, baudrate);
-
- push_target (&e7000_ops);
-
- e7000_desc = SERIAL_OPEN (dev_name);
-
- if (!e7000_desc)
- perror_with_name (dev_name);
-
- SERIAL_SETBAUDRATE (e7000_desc, baudrate);
- SERIAL_RAW (e7000_desc);
-
-#ifdef GDB_TARGET_IS_H8300
- h8300hmode = 1;
-#endif
-
- /* Start the remote connection; if error (0), discard this target.
- In particular, if the user quits, be sure to discard it
- (we'd be in an inconsistent state otherwise). */
- if (!catch_errors (e7000_start_remote, (char *)0,
- "Couldn't establish connection to remote target\n", RETURN_MASK_ALL))
- if (from_tty)
- printf_filtered ("Remote target %s connected to %s\n", target_shortname,
- dev_name);
-}
-
-/* Close out all files and local state before this target loses control. */
-
-static void
-e7000_close (quitting)
- int quitting;
-{
- if (e7000_desc)
- {
- SERIAL_CLOSE (e7000_desc);
- e7000_desc = 0;
- }
-}
-
-/* Terminate the open connection to the remote debugger. Use this
- when you want to detach and do something else with your gdb. */
-
-static void
-e7000_detach (from_tty)
- int from_tty;
-{
- pop_target (); /* calls e7000_close to do the real work */
- if (from_tty)
- printf_unfiltered ("Ending remote %s debugging\n", target_shortname);
-}
-
-/* Tell the remote machine to resume. */
-
-static void
-e7000_resume (pid, step, sig)
- int pid, step, sig;
-{
- if (step)
- puts_e7000debug ("S\r");
- else
- puts_e7000debug ("G\r");
-}
-
-/* Read the remote registers into the block REGS.
-
- For the H8/300 a register dump looks like:
-
- PC=00021A CCR=80:I*******
- ER0 - ER3 0000000A 0000002E 0000002E 00000000
- ER4 - ER7 00000000 00000000 00000000 00FFEFF6
- 000218 MOV.B R1L,R2L
- STEP NORMAL END or
- BREAK POINT
- */
-
-#ifdef GDB_TARGET_IS_H8300
-
-char *want_h8300h = "PC=%p CCR=%c\n\
- ER0 - ER3 %0 %1 %2 %3\n\
- ER4 - ER7 %4 %5 %6 %7\n";
-
-char *want_nopc_h8300h = "%p CCR=%c\n\
- ER0 - ER3 %0 %1 %2 %3\n\
- ER4 - ER7 %4 %5 %6 %7";
-
-char *want_h8300s = "PC=%p CCR=%c\n\
- MACH=\n\
- ER0 - ER3 %0 %1 %2 %3\n\
- ER4 - ER7 %4 %5 %6 %7\n";
-
-char *want_nopc_h8300s = "%p CCR=%c EXR=%9\n\
- ER0 - ER3 %0 %1 %2 %3\n\
- ER4 - ER7 %4 %5 %6 %7";
-
-#endif
-
-#ifdef GDB_TARGET_IS_SH
-
-char *want = "PC=%16 SR=%22\n\
-PR=%17 GBR=%18 VBR=%19\n\
-MACH=%20 MACL=%21\n\
-R0-7 %0 %1 %2 %3 %4 %5 %6 %7\n\
-R8-15 %8 %9 %10 %11 %12 %13 %14 %15\n";
-
-char *want_nopc = "%16 SR=%22\n\
- PR=%17 GBR=%18 VBR=%19\n\
- MACH=%20 MACL=%21\n\
- R0-7 %0 %1 %2 %3 %4 %5 %6 %7\n\
- R8-15 %8 %9 %10 %11 %12 %13 %14 %15";
-
-char *want_sh3 = "PC=%16 SR=%22\n\
-PR=%17 GBR=%18 VBR=%19\n\
-MACH=%20 MACL=%21 SSR=%23 SPC=%24\n\
-R0-7 %0 %1 %2 %3 %4 %5 %6 %7\n\
-R8-15 %8 %9 %10 %11 %12 %13 %14 %15\n\
-R0_BANK0-R3_BANK0 %25 %26 %27 %28\n\
-R4_BANK0-R7_BANK0 %29 %30 %31 %32\n\
-R0_BANK1-R3_BANK1 %33 %34 %35 %36\n\
-R4_BANK1-R7_BANK1 %37 %38 %39 %40";
-
-char *want_sh3_nopc = "%16 SR=%22\n\
- PR=%17 GBR=%18 VBR=%19\n\
- MACH=%20 MACL=%21 SSR=%22 SPC=%23\n\
- R0-7 %0 %1 %2 %3 %4 %5 %6 %7\n\
- R8-15 %8 %9 %10 %11 %12 %13 %14 %15\n\
- R0_BANK0-R3_BANK0 %25 %26 %27 %28\n\
- R4_BANK0-R7_BANK0 %29 %30 %31 %32\n\
- R0_BANK1-R3_BANK1 %33 %34 %35 %36\n\
- R4_BANK1-R7_BANK1 %37 %38 %39 %40";
-
-#endif
-
-static int
-gch ()
-{
- return readchar (timeout);
-}
-
-static unsigned int
-gbyte ()
-{
- int high = convert_hex_digit (gch ());
- int low = convert_hex_digit (gch ());
-
- return (high << 4) + low;
-}
-
-void
-fetch_regs_from_dump (nextchar, want)
- int (*nextchar)();
- char *want;
-{
- int regno;
- char buf[MAX_REGISTER_RAW_SIZE];
-
- int thischar = nextchar ();
-
- while (*want)
- {
- switch (*want)
- {
- case '\n':
- /* Skip to end of line and then eat all new line type stuff */
- while (thischar != '\n' && thischar != '\r')
- thischar = nextchar ();
- while (thischar == '\n' || thischar == '\r')
- thischar = nextchar ();
- want++;
- break;
-
- case ' ':
- while (thischar == ' '
- || thischar == '\t'
- || thischar == '\r'
- || thischar == '\n')
- thischar = nextchar ();
- want++;
- break;
-
- default:
- if (*want == thischar)
- {
- want++;
- if (*want)
- thischar = nextchar ();
-
- }
- else if (thischar == ' ' || thischar == '\n' || thischar == '\r')
- {
- thischar = nextchar ();
- }
- else {
- error ("out of sync in fetch registers wanted <%s>, got <%c 0x%x>",
- want, thischar, thischar);
- }
-
- break;
- case '%':
- /* Got a register command */
- want++;
- switch (*want)
- {
-#ifdef PC_REGNUM
- case 'p':
- regno = PC_REGNUM;
- want++;
- break;
-#endif
-#ifdef CCR_REGNUM
- case 'c':
- regno = CCR_REGNUM;
- want++;
- break;
-#endif
-#ifdef SP_REGNUM
- case 's':
- regno = SP_REGNUM;
- want++;
- break;
-#endif
-#ifdef FP_REGNUM
- case 'f':
- regno = FP_REGNUM;
- want++;
- break;
-#endif
-
- default:
- if (isdigit (want[0]))
- {
- if (isdigit (want[1]))
- {
- regno = (want[0] - '0') * 10 + want[1] - '0';
- want += 2;
- }
- else
- {
- regno = want[0] - '0';
- want++;
- }
- }
-
- else
- abort ();
- }
- store_signed_integer (buf,
- REGISTER_RAW_SIZE(regno),
- (LONGEST) get_hex (&thischar, nextchar));
- supply_register (regno, buf);
- break;
- }
- }
-}
-
-static void
-e7000_fetch_registers ()
-{
- int regno;
- char *wanted;
-
- puts_e7000debug ("R\r");
-
-#ifdef GDB_TARGET_IS_SH
- wanted = want;
- if (TARGET_ARCHITECTURE->arch == bfd_arch_sh)
- switch (TARGET_ARCHITECTURE->mach)
- {
- case bfd_mach_sh3:
- case bfd_mach_sh3e:
- wanted = want_sh3;
- }
-#else
- if (h8300smode)
- wanted = want_h8300s;
- else
- wanted = want_h8300h;
-#endif
- fetch_regs_from_dump (gch, wanted);
-
- /* And supply the extra ones the simulator uses */
- for (regno = NUM_REALREGS; regno < NUM_REGS; regno++)
- {
- int buf = 0;
-
- supply_register (regno, (char *) (&buf));
- }
-}
-
-/* Fetch register REGNO, or all registers if REGNO is -1. Returns
- errno value. */
-
-static void
-e7000_fetch_register (regno)
- int regno;
-{
- e7000_fetch_registers ();
-}
-
-/* Store the remote registers from the contents of the block REGS. */
-
-static void
-e7000_store_registers ()
-{
- int regno;
-
- for (regno = 0; regno < NUM_REALREGS; regno++)
- e7000_store_register (regno);
-
- registers_changed ();
-}
-
-/* Store register REGNO, or all if REGNO == 0. Return errno value. */
-
-static void
-e7000_store_register (regno)
- int regno;
-{
- char buf[200];
-
- if (regno == -1)
- {
- e7000_store_registers ();
- return;
- }
-
-#ifdef GDB_TARGET_IS_H8300
- if (regno <= 7)
- {
- sprintf (buf, ".ER%d %x\r", regno, read_register (regno));
- puts_e7000debug (buf);
- }
- else if (regno == PC_REGNUM)
- {
- sprintf (buf, ".PC %x\r", read_register (regno));
- puts_e7000debug (buf);
- }
- else if (regno == CCR_REGNUM)
- {
- sprintf (buf, ".CCR %x\r", read_register (regno));
- puts_e7000debug (buf);
- }
-#endif /* GDB_TARGET_IS_H8300 */
-
-#ifdef GDB_TARGET_IS_SH
- switch (regno)
- {
- default:
- sprintf (buf, ".R%d %x\r", regno, read_register (regno));
- puts_e7000debug (buf);
- break;
-
- case PC_REGNUM:
- sprintf (buf, ".PC %x\r", read_register (regno));
- puts_e7000debug (buf);
- break;
-
- case SR_REGNUM:
- sprintf (buf, ".SR %x\r", read_register (regno));
- puts_e7000debug (buf);
- break;
-
- case PR_REGNUM:
- sprintf (buf, ".PR %x\r", read_register (regno));
- puts_e7000debug (buf);
- break;
-
- case GBR_REGNUM:
- sprintf (buf, ".GBR %x\r", read_register (regno));
- puts_e7000debug (buf);
- break;
-
- case VBR_REGNUM:
- sprintf (buf, ".VBR %x\r", read_register (regno));
- puts_e7000debug (buf);
- break;
-
- case MACH_REGNUM:
- sprintf (buf, ".MACH %x\r", read_register (regno));
- puts_e7000debug (buf);
- break;
-
- case MACL_REGNUM:
- sprintf (buf, ".MACL %x\r", read_register (regno));
- puts_e7000debug (buf);
- break;
- }
-
-#endif /* GDB_TARGET_IS_SH */
-
- expect_prompt ();
-}
-
-/* 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
-e7000_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static void
-e7000_files_info ()
-{
- printf_unfiltered ("\tAttached to %s at %d baud.\n", dev_name, baudrate);
-}
-
-static int
-stickbyte (where, what)
- char *where;
- unsigned int what;
-{
- static CONST char digs[] = "0123456789ABCDEF";
-
- where[0] = digs[(what >> 4) & 0xf];
- where[1] = digs[(what & 0xf) & 0xf];
-
- return what;
-}
-
-/* Write a small ammount of memory. */
-
-static int
-write_small (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- int i;
- char buf[200];
-
- for (i = 0; i < len; i++)
- {
- if (((memaddr + i) & 3) == 0 && (i + 3 < len))
- {
- /* Can be done with a long word */
- sprintf (buf, "m %x %x%02x%02x%02x;l\r",
- memaddr + i,
- myaddr[i], myaddr[i + 1], myaddr[i + 2], myaddr[i + 3]);
- puts_e7000debug (buf);
- i += 3;
- }
- else
- {
- sprintf (buf, "m %x %x\r", memaddr + i, myaddr[i]);
- puts_e7000debug (buf);
- }
- }
-
- expect_prompt ();
-
- return len;
-}
-
-/* Write a large ammount of memory, this only works with the serial
- mode enabled. Command is sent as
-
- il ;s:s\r ->
- <- il ;s:s\r
- <- ENQ
- ACK ->
- <- LO s\r
- Srecords...
- ^Z ->
- <- ENQ
- ACK ->
- <- :
- */
-
-static int
-write_large (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- int i;
-#define maxstride 128
- int stride;
-
- puts_e7000debug ("IL ;S:FK\r");
- expect (ENQSTRING);
- putchar_e7000 (ACK);
- expect ("LO FK\r");
-
- for (i = 0; i < len; i += stride)
- {
- char compose[maxstride * 2 + 50];
- int address = i + memaddr;
- int j;
- int check_sum;
- int where = 0;
- int alen;
-
- stride = len - i;
- if (stride > maxstride)
- stride = maxstride;
-
- compose[where++] = 'S';
- check_sum = 0;
- if (address >= 0xffffff)
- alen = 4;
- else if (address >= 0xffff)
- alen = 3;
- else
- alen = 2;
- /* Insert type. */
- compose[where++] = alen - 1 + '0';
- /* Insert length. */
- check_sum += stickbyte (compose + where, alen + stride + 1);
- where += 2;
- while (alen > 0)
- {
- alen--;
- check_sum += stickbyte (compose + where, address >> (8 * (alen)));
- where += 2;
- }
-
- for (j = 0; j < stride; j++)
- {
- check_sum += stickbyte (compose + where, myaddr[i + j]);
- where += 2;
- }
- stickbyte (compose + where, ~check_sum);
- where += 2;
- compose[where++] = '\r';
- compose[where++] = '\n';
- compose[where++] = 0;
-
- SERIAL_WRITE (e7000_desc, compose, where);
- j = readchar (0);
- if (j == -1)
- {
- /* This is ok - nothing there */
- }
- else if (j == ENQ)
- {
- /* Hmm, it's trying to tell us something */
- expect (":");
- error ("Error writing memory");
- }
- else
- {
- printf_unfiltered ("@%d}@", j);
- while ((j = readchar (0)) > 0)
- {
- printf_unfiltered ("@{%d}@",j);
- }
- }
- }
-
- /* Send the trailer record */
- write_e7000 ("S70500000000FA\r");
- putchar_e7000 (CTRLZ);
- expect (ENQSTRING);
- putchar_e7000 (ACK);
- expect (":");
-
- return len;
-}
-
-/* Copy LEN bytes of data from debugger memory at MYADDR to inferior's
- memory at MEMADDR. Returns length moved.
-
- Can't use the Srecord load over ethernet, so don't use fast method
- then. */
-
-static int
-e7000_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- if (len < 16 || using_tcp || using_pc)
- return write_small (memaddr, myaddr, len);
- else
- return write_large (memaddr, myaddr, len);
-}
-
-/* Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns length moved.
-
- Small transactions we send
- m <addr>;l
- and receive
- 00000000 12345678 ?
- */
-
-static int
-e7000_read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- int count;
- int c;
- int i;
- char buf[200];
- /* Starting address of this pass. */
-
-/* printf("READ INF %x %x %d\n", memaddr, myaddr, len);*/
- if (((memaddr - 1) + len) < memaddr)
- {
- errno = EIO;
- return 0;
- }
-
- sprintf (buf, "m %x;l\r", memaddr);
- puts_e7000debug (buf);
-
- for (count = 0; count < len; count += 4)
- {
- /* Suck away the address */
- c = gch ();
- while (c != ' ')
- c = gch ();
- c = gch ();
- if (c == '*')
- { /* Some kind of error */
- puts_e7000debug (".\r"); /* Some errors leave us in memory input mode */
- expect_full_prompt();
- return -1;
- }
- while (c != ' ')
- c = gch ();
-
- /* Now read in the data */
- for (i = 0; i < 4; i++)
- {
- int b = gbyte();
- if (count + i < len) {
- myaddr[count + i] = b;
- }
- }
-
- /* Skip the trailing ? and send a . to end and a cr for more */
- gch ();
- gch ();
- if (count + 4 >= len)
- puts_e7000debug(".\r");
- else
- puts_e7000debug("\r");
-
- }
- expect_prompt();
- return len;
-}
-
-
-
-/*
- For large transfers we used to send
-
-
- d <addr> <endaddr>\r
-
- and receive
- <ADDRESS> < D A T A > < ASCII CODE >
- 00000000 5F FD FD FF DF 7F DF FF 01 00 01 00 02 00 08 04 "_..............."
- 00000010 FF D7 FF 7F D7 F1 7F FF 00 05 00 00 08 00 40 00 "..............@."
- 00000020 7F FD FF F7 7F FF FF F7 00 00 00 00 00 00 00 00 "................"
-
- A cost in chars for each transaction of 80 + 5*n-bytes.
-
- Large transactions could be done with the srecord load code, but
- there is a pause for a second before dumping starts, which slows the
- average rate down!
-*/
-
-static int
-e7000_read_inferior_memory_large (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- int count;
- int c;
- char buf[200];
-
- /* Starting address of this pass. */
-
- if (((memaddr - 1) + len) < memaddr)
- {
- errno = EIO;
- return 0;
- }
-
- sprintf (buf, "d %x %x\r", memaddr, memaddr + len - 1);
- puts_e7000debug (buf);
-
- count = 0;
- c = gch ();
-
- /* skip down to the first ">" */
- while( c != '>' )
- c = gch ();
- /* now skip to the end of that line */
- while( c != '\r' )
- c = gch ();
- c = gch ();
-
- while (count < len)
- {
- /* get rid of any white space before the address */
- while (c <= ' ')
- c = gch ();
-
- /* Skip the address */
- get_hex (&c);
-
- /* read in the bytes on the line */
- while (c != '"' && count < len)
- {
- if (c == ' ')
- c = gch ();
- else
- {
- myaddr[count++] = get_hex (&c);
- }
- }
- /* throw out the rest of the line */
- while( c != '\r' )
- c = gch ();
- }
-
- /* wait for the ":" prompt */
- while (c != ':')
- c = gch ();
-
- return len;
-}
-
-#if 0
-
-static int
-fast_but_for_the_pause_e7000_read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- int loop;
- int c;
- char buf[200];
-
- if (((memaddr - 1) + len) < memaddr)
- {
- errno = EIO;
- return 0;
- }
-
- sprintf (buf, "is %x@%x:s\r", memaddr, len);
- puts_e7000debug (buf);
- gch ();
- c = gch ();
- if (c != ENQ)
- {
- /* Got an error */
- error ("Memory read error");
- }
- putchar_e7000 (ACK);
- expect ("SV s");
- loop = 1;
- while (loop)
- {
- int type;
- int length;
- int addr;
- int i;
-
- c = gch ();
- switch (c)
- {
- case ENQ: /* ENQ, at the end */
- loop = 0;
- break;
- case 'S':
- /* Start of an Srecord */
- type = gch ();
- length = gbyte ();
- switch (type)
- {
- case '7': /* Termination record, ignore */
- case '0':
- case '8':
- case '9':
- /* Header record - ignore it */
- while (length--)
- {
- gbyte ();
- }
- break;
- case '1':
- case '2':
- case '3':
- {
- int alen;
-
- alen = type - '0' + 1;
- addr = 0;
- while (alen--)
- {
- addr = (addr << 8) + gbyte ();
- length--;
- }
-
- for (i = 0; i < length - 1; i++)
- myaddr[i + addr - memaddr] = gbyte ();
-
- gbyte (); /* Ignore checksum */
- }
- }
- }
- }
-
- putchar_e7000 (ACK);
- expect ("TOP ADDRESS =");
- expect ("END ADDRESS =");
- expect (":");
-
- return len;
-}
-
-#endif
-
-static int
-e7000_xfer_inferior_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* ignored */
-{
- if (write)
- return e7000_write_inferior_memory( memaddr, myaddr, len);
- else
- if( len < 16 )
- return e7000_read_inferior_memory( memaddr, myaddr, len);
- else
- return e7000_read_inferior_memory_large( memaddr, myaddr, len);
-}
-
-static void
-e7000_kill (args, from_tty)
- char *args;
- int from_tty;
-{
-}
-
-static void
-e7000_load (args, from_tty)
- char *args;
- int from_tty;
-{
- struct cleanup *old_chain;
- asection *section;
- bfd *pbfd;
- bfd_vma entry;
-#define WRITESIZE 0x1000
- char buf[2 + 4 + 4 + WRITESIZE]; /* `DT' + <addr> + <len> + <data> */
- char *filename;
- int quiet;
- int nostart;
- time_t start_time, end_time; /* Start and end times of download */
- unsigned long data_count; /* Number of bytes transferred to memory */
- int oldtimeout = timeout;
-
- timeout = remote_timeout;
-
-
- /* FIXME! change test to test for type of download */
- if (!using_tcp)
- {
- generic_load (args, from_tty);
- return;
- }
-
- /* for direct tcp connections, we can do a fast binary download */
- buf[0] = 'D';
- buf[1] = 'T';
- quiet = 0;
- nostart = 0;
- filename = NULL;
-
- while (*args != '\000')
- {
- char *arg;
-
- while (isspace (*args)) args++;
-
- arg = args;
-
- while ((*args != '\000') && !isspace (*args)) args++;
-
- if (*args != '\000')
- *args++ = '\000';
-
- if (*arg != '-')
- filename = arg;
- else if (strncmp (arg, "-quiet", strlen (arg)) == 0)
- quiet = 1;
- else if (strncmp (arg, "-nostart", strlen (arg)) == 0)
- nostart = 1;
- else
- error ("unknown option `%s'", arg);
- }
-
- if (!filename)
- filename = get_exec_file (1);
-
- pbfd = bfd_openr (filename, gnutarget);
- if (pbfd == NULL)
- {
- perror_with_name (filename);
- return;
- }
- old_chain = make_cleanup ((make_cleanup_func) bfd_close, pbfd);
-
- if (!bfd_check_format (pbfd, bfd_object))
- error ("\"%s\" is not an object file: %s", filename,
- bfd_errmsg (bfd_get_error ()));
-
- start_time = time (NULL);
- data_count = 0;
-
- puts_e7000debug ("mw\r");
-
- expect ("\nOK");
-
- for (section = pbfd->sections; section; section = section->next)
- {
- if (bfd_get_section_flags (pbfd, section) & SEC_LOAD)
- {
- bfd_vma section_address;
- bfd_size_type section_size;
- file_ptr fptr;
-
- section_address = bfd_get_section_vma (pbfd, section);
- section_size = bfd_get_section_size_before_reloc (section);
-
- if (!quiet)
- printf_filtered ("[Loading section %s at 0x%x (%d bytes)]\n",
- bfd_get_section_name (pbfd, section),
- section_address,
- section_size);
-
- fptr = 0;
-
- data_count += section_size;
-
- while (section_size > 0)
- {
- int count;
- static char inds[] = "|/-\\";
- static int k = 0;
-
- QUIT;
-
- count = min (section_size, WRITESIZE);
-
- buf[2] = section_address >> 24;
- buf[3] = section_address >> 16;
- buf[4] = section_address >> 8;
- buf[5] = section_address;
-
- buf[6] = count >> 24;
- buf[7] = count >> 16;
- buf[8] = count >> 8;
- buf[9] = count;
-
- bfd_get_section_contents (pbfd, section, buf + 10, fptr, count);
-
- if (SERIAL_WRITE (e7000_desc, buf, count + 10))
- fprintf_unfiltered (gdb_stderr,
- "e7000_load: SERIAL_WRITE failed: %s\n",
- safe_strerror(errno));
-
- expect ("OK");
-
- if (!quiet)
- {
- printf_unfiltered ("\r%c", inds[k++ % 4]);
- gdb_flush (gdb_stdout);
- }
-
- section_address += count;
- fptr += count;
- section_size -= count;
- }
- }
- }
-
- write_e7000 ("ED");
-
- expect_prompt ();
-
- end_time = time (NULL);
-
-/* Finally, make the PC point at the start address */
-
- if (exec_bfd)
- write_pc (bfd_get_start_address (exec_bfd));
-
- inferior_pid = 0; /* No process now */
-
-/* This is necessary because many things were based on the PC at the time that
- we attached to the monitor, which is no longer valid now that we have loaded
- new code (and just changed the PC). Another way to do this might be to call
- normal_stop, except that the stack may not be valid, and things would get
- horribly confused... */
-
- clear_symtab_users ();
-
- if (!nostart)
- {
- entry = bfd_get_start_address (pbfd);
-
- if (!quiet)
- printf_unfiltered ("[Starting %s at 0x%x]\n", filename, entry);
-
-/* start_routine (entry);*/
- }
-
- report_transfer_performance (data_count, start_time, end_time);
-
- do_cleanups (old_chain);
- timeout = oldtimeout;
-}
-
-/* Clean up when a program exits.
-
- The program actually lives on in the remote processor's RAM, and may be
- run again without a download. Don't leave it full of breakpoint
- instructions. */
-
-static void
-e7000_mourn_inferior ()
-{
- remove_breakpoints ();
- unpush_target (&e7000_ops);
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-
-#define MAX_BREAKPOINTS 200
-#ifdef HARD_BREAKPOINTS
-#define MAX_E7000DEBUG_BREAKPOINTS (BC_BREAKPOINTS ? 5 : MAX_BREAKPOINTS)
-#else
-#define MAX_E7000DEBUG_BREAKPOINTS MAX_BREAKPOINTS
-#endif
-
-/* Since we can change to soft breakpoints dynamically, we must define
- more than enough. Was breakaddr[MAX_E7000DEBUG_BREAKPOINTS]. */
-static CORE_ADDR breakaddr[MAX_BREAKPOINTS] = {0};
-
-static int
-e7000_insert_breakpoint (addr, shadow)
- CORE_ADDR addr;
- unsigned char *shadow;
-{
- int i;
- char buf[200];
-#if 0
- static char nop[2] = NOP;
-#endif
-
- for (i = 0; i <= MAX_E7000DEBUG_BREAKPOINTS; i++)
- if (breakaddr[i] == 0)
- {
- breakaddr[i] = addr;
- /* Save old contents, and insert a nop in the space */
-#ifdef HARD_BREAKPOINTS
- if (BC_BREAKPOINTS)
- {
- sprintf (buf, "BC%d A=%x\r", i+1, addr);
- puts_e7000debug (buf);
- }
- else
- {
- sprintf (buf, "B %x\r", addr);
- puts_e7000debug (buf);
- }
-#else
-#if 0
- e7000_read_inferior_memory (addr, shadow, 2);
- e7000_write_inferior_memory (addr, nop, 2);
-#endif
-
- sprintf (buf, "B %x\r", addr);
- puts_e7000debug (buf);
-#endif
- expect_prompt ();
- return 0;
- }
-
- error ("Too many breakpoints ( > %d) for the E7000\n",
- MAX_E7000DEBUG_BREAKPOINTS);
- return 1;
-}
-
-static int
-e7000_remove_breakpoint (addr, shadow)
- CORE_ADDR addr;
- unsigned char *shadow;
-{
- int i;
- char buf[200];
-
- for (i = 0; i < MAX_E7000DEBUG_BREAKPOINTS; i++)
- if (breakaddr[i] == addr)
- {
- breakaddr[i] = 0;
-#ifdef HARD_BREAKPOINTS
- if (BC_BREAKPOINTS)
- {
- sprintf (buf, "BC%d - \r", i+1);
- puts_e7000debug (buf);
- }
- else
- {
- sprintf (buf, "B - %x\r", addr);
- puts_e7000debug (buf);
- }
- expect_prompt ();
-#else
- sprintf (buf, "B - %x\r", addr);
- puts_e7000debug (buf);
- expect_prompt ();
-
-#if 0
- /* Replace the insn under the break */
- e7000_write_inferior_memory (addr, shadow, 2);
-#endif
-#endif
-
- return 0;
- }
-
- warning ("Can't find breakpoint associated with 0x%x\n", addr);
- return 1;
-}
-
-/* Put a command string, in args, out to STDBUG. Output from STDBUG
- is placed on the users terminal until the prompt is seen. */
-
-static void
-e7000_command (args, fromtty)
- char *args;
- int fromtty;
-{
- /* FIXME: arbitrary limit on length of args. */
- char buf[200];
-
- echo = 0;
-
- if (!e7000_desc)
- error ("e7000 target not open.");
- if (!args)
- {
- puts_e7000debug ("\r");
- }
- else
- {
- sprintf (buf, "%s\r", args);
- puts_e7000debug (buf);
- }
-
- echo++;
- ctrl_c = 2;
- expect_full_prompt ();
- echo--;
- ctrl_c = 0;
- printf_unfiltered ("\n");
-
- /* Who knows what the command did... */
- registers_changed ();
-}
-
-
-static void
-e7000_drain_command (args, fromtty)
- char *args;
- int fromtty;
-
-{
- int c;
-
- puts_e7000debug("end\r");
- putchar_e7000 (CTRLC);
-
- while ((c = readchar (1) != -1))
- {
- if (quit_flag)
- {
- putchar_e7000(CTRLC);
- quit_flag = 0;
- }
- if (c > ' ' && c < 127)
- printf_unfiltered ("%c", c & 0xff);
- else
- printf_unfiltered ("<%x>", c & 0xff);
- }
-}
-
-#define NITEMS 7
-
-static int
-why_stop ()
-{
- static char *strings[NITEMS] = {
- "STEP NORMAL",
- "BREAK POINT",
- "BREAK KEY",
- "BREAK CONDI",
- "CYCLE ACCESS",
- "ILLEGAL INSTRUCTION",
- "WRITE PROTECT",
- };
- char *p[NITEMS];
- int c;
- int i;
-
- for (i = 0; i < NITEMS; ++i)
- p[i] = strings[i];
-
- c = gch ();
- while (1)
- {
- for (i = 0; i < NITEMS; i++)
- {
- if (c == *(p[i]))
- {
- p[i]++;
- if (*(p[i]) == 0)
- {
- /* found one of the choices */
- return i;
- }
- }
- else
- p[i] = strings[i];
- }
-
- c = gch ();
- }
-}
-
-/* Suck characters, if a string match, then return the strings index
- otherwise echo them. */
-
-int
-expect_n (strings)
-char **strings;
-{
- char *(ptr[10]);
- int n;
- int c;
- char saveaway[100];
- char *buffer = saveaway;
- /* Count number of expect strings */
-
- for (n = 0; strings[n]; n++)
- {
- ptr[n] = strings[n];
- }
-
- while (1)
- {
- int i;
- int gotone = 0;
-
- c = readchar (1);
- if (c == -1)
- {
- printf_unfiltered ("[waiting for e7000...]\n");
- }
-#ifdef __GO32__
- if (kbhit ())
- {
- int k = getkey();
-
- if (k == 1)
- quit_flag = 1;
- }
-#endif
- if (quit_flag)
- {
- putchar_e7000 (CTRLC); /* interrupt the running program */
- quit_flag = 0;
- }
-
- for (i = 0; i < n; i++)
- {
- if (c == ptr[i][0])
- {
- ptr[i]++;
- if (ptr[i][0] == 0)
- {
- /* Gone all the way */
- return i;
- }
- gotone = 1;
- }
- else
- {
- ptr[i] = strings[i];
- }
- }
-
- if (gotone)
- {
- /* Save it up incase we find that there was no match */
- *buffer ++ = c;
- }
- else
- {
- if (buffer != saveaway)
- {
- *buffer++ = 0;
- printf_unfiltered ("%s", buffer);
- buffer = saveaway;
- }
- if (c != -1)
- {
- putchar_unfiltered (c);
- gdb_flush (gdb_stdout);
- }
- }
- }
-}
-
-/* We subtract two from the pc here rather than use
- DECR_PC_AFTER_BREAK since the e7000 doesn't always add two to the
- pc, and the simulators never do. */
-
-static void
-sub2_from_pc ()
-{
- char buf[4];
- char buf2[200];
-
- store_signed_integer (buf,
- REGISTER_RAW_SIZE(PC_REGNUM),
- read_register (PC_REGNUM) -2);
- supply_register (PC_REGNUM, buf);
- sprintf (buf2, ".PC %x\r", read_register (PC_REGNUM));
- puts_e7000debug (buf2);
-}
-
-#define WAS_SLEEP 0
-#define WAS_INT 1
-#define WAS_RUNNING 2
-#define WAS_OTHER 3
-
-static char *estrings[] = {
- "** SLEEP",
- "BREAK !",
- "** PC",
- "PC",
- NULL
-};
-
-/* Wait until the remote machine stops, then return, storing status in
- STATUS just as `wait' would. */
-
-static int
-e7000_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- int stop_reason;
- int regno;
- int running_count = 0;
- int had_sleep = 0;
- int loop = 1;
- char *wanted_nopc;
-
- /* Then echo chars until PC= string seen */
- gch (); /* Drop cr */
- gch (); /* and space */
-
- while (loop)
- {
- switch (expect_n (estrings))
- {
- case WAS_OTHER:
- /* how did this happen ? */
- loop = 0;
- break;
- case WAS_SLEEP:
- had_sleep = 1;
- putchar_e7000 (CTRLC);
- loop = 0;
- break;
- case WAS_INT:
- loop = 0;
- break;
- case WAS_RUNNING:
- running_count++;
- if (running_count == 20)
- {
- printf_unfiltered ("[running...]\n");
- running_count = 0;
- }
- break;
- default:
- /* error? */
- break;
- }
- }
-
- /* Skip till the PC= */
- expect ("=");
-
-#ifdef GDB_TARGET_IS_SH
- wanted_nopc = want_nopc;
- if (TARGET_ARCHITECTURE->arch == bfd_arch_sh)
- switch (TARGET_ARCHITECTURE->mach)
- {
- case bfd_mach_sh3:
- case bfd_mach_sh3e:
- wanted_nopc = want_sh3_nopc;
- }
-#else
- if (h8300smode)
- wanted_nopc = want_nopc_h8300s;
- else
- wanted_nopc = want_nopc_h8300h;
-#endif
- fetch_regs_from_dump (gch, wanted_nopc);
-
- /* And supply the extra ones the simulator uses */
- for (regno = NUM_REALREGS; regno < NUM_REGS; regno++)
- {
- int buf = 0;
- supply_register (regno, (char *) &buf);
- }
-
- stop_reason = why_stop ();
- expect_full_prompt ();
-
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
-
- switch (stop_reason)
- {
- case 1: /* Breakpoint */
- write_pc (read_pc ()); /* PC is always off by 2 for breakpoints */
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case 0: /* Single step */
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case 2: /* Interrupt */
- if (had_sleep)
- {
- status->value.sig = TARGET_SIGNAL_TRAP;
- sub2_from_pc ();
- }
- else
- {
- status->value.sig = TARGET_SIGNAL_INT;
- }
- break;
- case 3:
- break;
- case 4:
- printf_unfiltered ("a cycle address error?\n");
- status->value.sig = TARGET_SIGNAL_UNKNOWN;
- break;
- case 5:
- status->value.sig = TARGET_SIGNAL_ILL;
- break;
- case 6:
- status->value.sig = TARGET_SIGNAL_SEGV;
- break;
- case 7: /* Anything else (NITEMS + 1) */
- printf_unfiltered ("a write protect error?\n");
- status->value.sig = TARGET_SIGNAL_UNKNOWN;
- break;
- default:
- /* Get the user's attention - this should never happen. */
- abort ();
- }
-
- return 0;
-}
-
-/* Stop the running program. */
-
-static void
-e7000_stop ()
-{
- /* Sending a ^C is supposed to stop the running program. */
- putchar_e7000 (CTRLC);
-}
-
-/* Define the target subroutine names. */
-
-struct target_ops e7000_ops ;
-
-static void
-init_e7000_ops(void)
-{
- e7000_ops.to_shortname = "e7000";
- e7000_ops.to_longname = "Remote Hitachi e7000 target";
- e7000_ops.to_doc = "Use a remote Hitachi e7000 ICE connected by a serial line;\n\
-or a network connection.\n\
-Arguments are the name of the device for the serial line,\n\
-the speed to connect at in bits per second.\n\
-eg\n\
-target e7000 /dev/ttya 9600\n\
-target e7000 foobar" ;
- e7000_ops.to_open = e7000_open;
- e7000_ops.to_close = e7000_close;
- e7000_ops.to_attach = 0;
- e7000_ops.to_post_attach = NULL;
- e7000_ops.to_require_attach = NULL;
- e7000_ops.to_detach = e7000_detach;
- e7000_ops.to_require_detach = NULL;
- e7000_ops.to_resume = e7000_resume;
- e7000_ops.to_wait = e7000_wait;
- e7000_ops.to_post_wait = NULL;
- e7000_ops.to_fetch_registers = e7000_fetch_register;
- e7000_ops.to_store_registers = e7000_store_register;
- e7000_ops.to_prepare_to_store = e7000_prepare_to_store;
- e7000_ops.to_xfer_memory = e7000_xfer_inferior_memory;
- e7000_ops.to_files_info = e7000_files_info;
- e7000_ops.to_insert_breakpoint = e7000_insert_breakpoint;
- e7000_ops.to_remove_breakpoint = e7000_remove_breakpoint;
- e7000_ops.to_terminal_init = 0;
- e7000_ops.to_terminal_inferior = 0;
- e7000_ops.to_terminal_ours_for_output = 0;
- e7000_ops.to_terminal_ours = 0;
- e7000_ops.to_terminal_info = 0;
- e7000_ops.to_kill = e7000_kill;
- e7000_ops.to_load = e7000_load;
- e7000_ops.to_lookup_symbol = 0;
- e7000_ops.to_create_inferior = e7000_create_inferior;
- e7000_ops.to_post_startup_inferior = NULL;
- e7000_ops.to_acknowledge_created_inferior = NULL;
- e7000_ops.to_clone_and_follow_inferior = NULL;
- e7000_ops.to_post_follow_inferior_by_clone = NULL;
- e7000_ops.to_insert_fork_catchpoint = NULL;
- e7000_ops.to_remove_fork_catchpoint = NULL;
- e7000_ops.to_insert_vfork_catchpoint = NULL;
- e7000_ops.to_remove_vfork_catchpoint = NULL;
- e7000_ops.to_has_forked = NULL;
- e7000_ops.to_has_vforked = NULL;
- e7000_ops.to_can_follow_vfork_prior_to_exec = NULL;
- e7000_ops.to_post_follow_vfork = NULL;
- e7000_ops.to_insert_exec_catchpoint = NULL;
- e7000_ops.to_remove_exec_catchpoint = NULL;
- e7000_ops.to_has_execd = NULL;
- e7000_ops.to_reported_exec_events_per_exec_call = NULL;
- e7000_ops.to_has_exited = NULL;
- e7000_ops.to_mourn_inferior = e7000_mourn_inferior;
- e7000_ops.to_can_run = 0;
- e7000_ops.to_notice_signals = 0;
- e7000_ops.to_thread_alive = 0;
- e7000_ops.to_stop = e7000_stop;
- e7000_ops.to_pid_to_exec_file = NULL;
- e7000_ops.to_core_file_to_sym_file = NULL;
- e7000_ops.to_stratum = process_stratum;
- e7000_ops.DONT_USE = 0;
- e7000_ops.to_has_all_memory = 1;
- e7000_ops.to_has_memory = 1;
- e7000_ops.to_has_stack = 1;
- e7000_ops.to_has_registers = 1;
- e7000_ops.to_has_execution = 1;
- e7000_ops.to_sections = 0;
- e7000_ops.to_sections_end = 0;
- e7000_ops.to_magic = OPS_MAGIC;
-};
-
-void
-_initialize_remote_e7000 ()
-{
- init_e7000_ops() ;
- add_target (&e7000_ops);
-
- add_com ("e7000", class_obscure, e7000_command,
- "Send a command to the e7000 monitor.");
-
- add_com ("ftplogin", class_obscure, e7000_login_command,
- "Login to machine and change to directory.");
-
- add_com ("ftpload", class_obscure, e7000_ftp_command,
- "Fetch and load a file from previously described place.");
-
- add_com ("drain", class_obscure, e7000_drain_command,
- "Drain pending e7000 text buffers.");
-
- add_show_from_set (add_set_cmd ("usehardbreakpoints", no_class,
- var_integer, (char *)&use_hard_breakpoints,
- "Set use of hardware breakpoints for all breakpoints.\n", &setlist),
- &showlist);
-}
diff --git a/contrib/gdb/gdb/remote-eb.c b/contrib/gdb/gdb/remote-eb.c
deleted file mode 100644
index d3a3c41..0000000
--- a/contrib/gdb/gdb/remote-eb.c
+++ /dev/null
@@ -1,1056 +0,0 @@
-/* Remote debugging interface for AMD 29000 EBMON on IBM PC, for GDB.
- Copyright 1990, 1991, 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This is like remote.c but is for an esoteric situation--
- having a a29k 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 "defs.h"
-#include "gdb_string.h"
-
-#include "inferior.h"
-#include "bfd.h"
-#include "symfile.h"
-#include "wait.h"
-#include "value.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include "terminal.h"
-#include "target.h"
-#include "gdbcore.h"
-
-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 = 24;
-
-/* 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++, (char *) &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. */
-static void
-eb_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- int entry_pt;
-
- if (args && *args)
- error ("Can't pass arguments to remote EBMON process");
-
- if (execfile == 0 || exec_bfd == 0)
- error ("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
- {
- /* 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 (args != NULL)
- fprintf(eb_stream, " %s", args);
-
- fprintf (eb_stream, "\n");
- fflush (eb_stream);
-
- expect_prompt ();
-
- need_gi = 1;
- }
-
-/* The "process" (board) is already stopped awaiting our commands, and
- the program is already downloaded. We just set its PC and go. */
-
- clear_proceed_status ();
-
- /* Tell wait_for_inferior that we've started a new process. */
- 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 ();
-
- /* insert_step_breakpoint (); FIXME, do we need this? */
- proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0); /* Let 'er rip... */
-}
-
-/* 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 (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 (pid, step, sig)
- int pid, step;
- enum target_signal 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)
- struct target_waitstatus *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;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- if (need_artificial_trap != 0)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- 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')
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- else
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 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, (char *) &val);
- supply_register (INTE_REGNUM, (char *) &val);
- supply_register (FPS_REGNUM, (char *) &val);
- supply_register (EXO_REGNUM, (char *) &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. */
-void
-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 ();
- }
-}
-
-/* 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-someday! 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_read_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 length moved. */
-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 len;
-}
-
-/* Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns length moved. */
-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) {
- errno = EIO;
- return 0;
- }
-
- 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 len;
-}
-
-static void
-eb_kill (args, from_tty)
- char *args;
- int from_tty;
-{
- return; /* Ignore attempts to kill target system */
-}
-
-/* Clean up when a program exits.
-
- The program actually lives on in the remote processor's RAM, and may be
- run again without a download. Don't leave it full of breakpoint
- instructions. */
-
-void
-eb_mourn_inferior ()
-{
- remove_breakpoints ();
- unpush_target (&eb_ops);
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-/* Define the target subroutine names */
-
-struct target_ops eb_ops ;
-
-static void
-init_eb_ops(void)
-{
- eb_ops.to_shortname = "amd-eb";
- eb_ops.to_longname = "Remote serial AMD EBMON target";
- eb_ops.to_doc = "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_ops.to_open = eb_open;
- eb_ops.to_close = eb_close;
- eb_ops.to_attach = 0;
- eb_ops.to_post_attach = NULL;
- eb_ops.to_require_attach = NULL;
- eb_ops.to_detach = eb_detach;
- eb_ops.to_require_detach = NULL;
- eb_ops.to_resume = eb_resume;
- eb_ops.to_wait = eb_wait;
- eb_ops.to_post_wait = NULL;
- eb_ops.to_fetch_registers = eb_fetch_register;
- eb_ops.to_store_registers = eb_store_register;
- eb_ops.to_prepare_to_store = eb_prepare_to_store;
- eb_ops.to_xfer_memory = eb_xfer_inferior_memory;
- eb_ops.to_files_info = eb_files_info;
- eb_ops.to_insert_breakpoint = 0;
- eb_ops.to_remove_breakpoint = 0; /* Breakpoints */
- eb_ops.to_terminal_init = 0;
- eb_ops.to_terminal_inferior = 0;
- eb_ops.to_terminal_ours_for_output = 0;
- eb_ops.to_terminal_ours = 0;
- eb_ops.to_terminal_info = 0; /* Terminal handling */
- eb_ops.to_kill = eb_kill;
- eb_ops.to_load = generic_load; /* load */
- eb_ops.to_lookup_symbol = 0; /* lookup_symbol */
- eb_ops.to_create_inferior = eb_create_inferior;
- eb_ops.to_post_startup_inferior = NULL;
- eb_ops.to_acknowledge_created_inferior = NULL;
- eb_ops.to_clone_and_follow_inferior = NULL;
- eb_ops.to_post_follow_inferior_by_clone = NULL;
- eb_ops.to_insert_fork_catchpoint = NULL;
- eb_ops.to_remove_fork_catchpoint = NULL;
- eb_ops.to_insert_vfork_catchpoint = NULL;
- eb_ops.to_remove_vfork_catchpoint = NULL;
- eb_ops.to_has_forked = NULL;
- eb_ops.to_has_vforked = NULL;
- eb_ops.to_can_follow_vfork_prior_to_exec = NULL;
- eb_ops.to_post_follow_vfork = NULL;
- eb_ops.to_insert_exec_catchpoint = NULL;
- eb_ops.to_remove_exec_catchpoint = NULL;
- eb_ops.to_has_execd = NULL;
- eb_ops.to_reported_exec_events_per_exec_call = NULL;
- eb_ops.to_has_exited = NULL;
- eb_ops.to_mourn_inferior = eb_mourn_inferior;
- eb_ops.to_can_run = 0; /* can_run */
- eb_ops.to_notice_signals = 0; /* notice_signals */
- eb_ops.to_thread_alive = 0; /* thread-alive */
- eb_ops.to_stop = 0; /* to_stop */
- eb_ops.to_pid_to_exec_file = NULL;
- eb_ops.to_core_file_to_sym_file = NULL;
- eb_ops.to_stratum = process_stratum;
- eb_ops.DONT_USE = 0; /* next */
- eb_ops.to_has_all_memory = 1;
- eb_ops.to_has_memory = 1;
- eb_ops.to_has_stack = 1;
- eb_ops.to_has_registers = 1;
- eb_ops.to_has_execution = 1; /* all mem, mem, stack, regs, exec */
- eb_ops.to_sections = 0; /* sections */
- eb_ops.to_sections_end = 0; /* sections end */
- eb_ops.to_magic = OPS_MAGIC; /* Always the last thing */
-};
-
-void
-_initialize_remote_eb ()
-{
- init_eb_ops() ;
- add_target (&eb_ops);
-}
diff --git a/contrib/gdb/gdb/remote-es.c b/contrib/gdb/gdb/remote-es.c
deleted file mode 100644
index d26e85b..0000000
--- a/contrib/gdb/gdb/remote-es.c
+++ /dev/null
@@ -1,2202 +0,0 @@
-/* Memory-access and commands for remote es1800 processes, for GDB.
- Copyright (C) 1988, 1992 Free Software Foundation, Inc.
-
- This file is added to GDB to make it possible to do debugging via an
- ES-1800 emulator. The code was originally written by Johan Holmberg
- TT/SJ Ericsson Telecom AB and later modified by Johan Henriksson
- TT/SJ. It was modified for gdb 4.0 by TX/DK Jan Nordenand by TX/DKG
- Harald Johansen.
-
-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 this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
-/* Emulator communication protocol.
- All values are encoded in ascii hex digits.
-
- Request
-Command
-Reply
- read registers:
-DR<cr>
- - 0 - - 1 - - 2 - - 3 - - 4 - - 5 - -- 6 - - 7 -
-D = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
-A = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
- PC = XXXXXX SSP = XXXXXX USP = XXXXXX SR = XXXXXXXX
- >
-Each byte of register data is described by two hex digits.
-
- write regs
-D0=XXXXXXXX<cr>
- >D1=XXXXXXXX<cr>
- >D2=XXXXXXXX<cr>
- >D3=XXXXXXXX<cr>
- >D4=XXXXXXXX<cr>
- >D5=XXXXXXXX<cr>
- >D6=XXXXXXXX<cr>
- >D7=XXXXXXXX<cr>
- >A0=XXXXXXXX<cr>
- >A1=XXXXXXXX<cr>
- >A2=XXXXXXXX<cr>
- >A3=XXXXXXXX<cr>
- >A4=XXXXXXXX<cr>
- >A5=XXXXXXXX<cr>
- >A6=XXXXXXXX<cr>
- >A7=XXXXXXXX<cr>
- >SR=XXXXXXXX<cr>
- >PC=XXXXXX<cr>
- >
-Each byte of register data is described by two hex digits.
-
- read mem
-@.BAA..AA
-$FFFFFFXX
- >
-AA..AA is address, XXXXXXX is the contents
-
- write mem
- @.BAA..AA=$XXXXXXXX
- >
-AA..AA is address, XXXXXXXX is data
-
- cont
-PC=$AA..AA
- >RBK
-R>
-AA..AA is address to resume. If AA..AA is omitted, resume at same address.
-
- step
-PC=$AA..AA
- >STP
-R>
-AA..AA is address to resume. If AA..AA is omitted, resume at same address.
-
- kill req
-STP
- >
-*/
-
-
-#include <stdio.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <errno.h>
-#include <ctype.h>
-#include <setjmp.h>
-#include <fcntl.h>
-#include "defs.h"
-#include "gdb_string.h"
-#include "frame.h"
-#include "inferior.h"
-#include "target.h"
-#include "wait.h"
-#include "command.h"
-#include "remote-utils.h"
-#include "gdbcore.h"
-#include "serial.h"
-
-/* Prototypes for local functions */
-
-static void
-es1800_child_detach PARAMS ((char *, int));
-
-static void
-es1800_child_open PARAMS ((char *, int));
-
-static void
-es1800_transparent PARAMS ((char *, int));
-
-static void
-es1800_create_inferior PARAMS ((char *, char *, char **));
-
-static void
-es1800_load PARAMS ((char *, int));
-
-static void
-es1800_kill PARAMS ((void));
-
-static int
-verify_break PARAMS ((int));
-
-static int
-es1800_remove_breakpoint PARAMS ((CORE_ADDR, char *));
-
-static int
-es1800_insert_breakpoint PARAMS ((CORE_ADDR, char *));
-
-static void
-es1800_files_info PARAMS ((struct target_ops *));
-
-static int
-es1800_xfer_inferior_memory PARAMS ((CORE_ADDR, char *, int, int,
- struct target_ops *));
-
-static void
-es1800_prepare_to_store PARAMS ((void));
-
-static int es1800_wait PARAMS ((int, struct target_waitstatus *));
-
-static void es1800_resume PARAMS ((int, int, enum target_signal));
-
-static void
-es1800_detach PARAMS ((char *, int));
-
-static void
-es1800_attach PARAMS ((char *, int));
-
-static int
-damn_b PARAMS ((char *));
-
-static void
-es1800_open PARAMS ((char *, int));
-
-static void
-es1800_timer PARAMS ((void));
-
-static void
-es1800_reset PARAMS ((char *));
-
-static void
-es1800_request_quit PARAMS ((void));
-
-static int
-readchar PARAMS ((void));
-
-static void
-expect PARAMS ((char *, int));
-
-static void
-expect_prompt PARAMS ((void));
-
-static void
-download PARAMS ((FILE *, int, int));
-
-#if 0
-static void
-bfd_copy PARAMS ((bfd *, bfd *));
-#endif
-
-static void
-get_break_addr PARAMS ((int, CORE_ADDR *));
-
-static int
-fromhex PARAMS ((int));
-
-static int
-tohex PARAMS ((int));
-
-static void
-es1800_close PARAMS ((int));
-
-static void
-es1800_fetch_registers PARAMS ((void));
-
-static void
-es1800_fetch_register PARAMS ((int));
-
-static void
-es1800_store_register PARAMS ((int));
-
-static void
-es1800_read_bytes PARAMS ((CORE_ADDR, char *, int));
-
-static void
-es1800_write_bytes PARAMS ((CORE_ADDR, char *, int));
-
-static void
-send_with_reply PARAMS ((char *, char *, int));
-
-static void
-send_command PARAMS ((char *));
-
-static void
-send PARAMS ((char *));
-
-static void
-getmessage PARAMS ((char *, int));
-
-static void
-es1800_mourn_inferior PARAMS ((void));
-
-static void
-es1800_create_break_insn PARAMS ((char *, int));
-
-static void
-es1800_init_break PARAMS ((char *, int));
-
-/* Local variables */
-
-/* FIXME: Convert this to use "set remotedebug" instead. */
-#define LOG_FILE "es1800.log"
-#if defined (LOG_FILE)
-static FILE *log_file;
-#endif
-
-extern struct target_ops es1800_ops; /* Forward decl */
-extern struct target_ops es1800_child_ops; /* Forward decl */
-
-static int kiodebug;
-static int timeout = 100;
-static char *savename; /* Name of i/o device used */
-static serial_ttystate es1800_saved_ttystate;
-static int es1800_fc_save; /* Save fcntl state */
-
-/* indicates that the emulator uses 32-bit data-adress (68020-mode)
- instead of 24-bit (68000 -mode) */
-
-static int m68020;
-
-#define MODE (m68020 ? "M68020" : "M68000" )
-#define ES1800_BREAK_VEC (0xf)
-
-/* Descriptor for I/O to remote machine. Initialize it to NULL so that
- es1800_open knows that we don't have a file open when the program
- starts. */
-
-static serial_t es1800_desc = NULL;
-
-#define PBUFSIZ 1000
-#define HDRLEN sizeof("@.BAAAAAAAA=$VV\r")
-
-/* Maximum number of bytes to read/write at once. The value here
- is chosen to fill up a packet. */
-
-#define MAXBUFBYTES ((PBUFSIZ-150)*16/75 )
-
-static int es1800_break_vec = 0;
-static char es1800_break_insn[2];
-static long es1800_break_address;
-static void (*old_sigint)(); /* Old signal-handler for sigint */
-static jmp_buf interrupt;
-
-/* Local signalhandler to allow breaking tranfers or program run.
- Rely on global variables: old_sigint(), interrupt */
-
-static void
-es1800_request_quit ()
-{
- /* restore original signalhandler */
- signal (SIGINT, old_sigint);
- longjmp (interrupt, 1);
-}
-
-
-/* Reset emulator.
- Sending reset character(octal 32) to emulator.
- quit - return to '(esgdb)' prompt or continue */
-
-static void
-es1800_reset (quit)
- char *quit;
-{
- char buf[80];
-
- if (quit)
- {
- printf ("\nResetting emulator... ");
- }
- strcpy (buf, "\032");
- send (buf);
- expect_prompt ();
- if (quit)
- {
- error ("done\n");
- }
-}
-
-
-/* Open a connection to a remote debugger and push the new target
- onto the stack. Check if the emulator is responding and find out
- what kind of processor the emulator is connected to.
- Initiate the breakpoint handling in the emulator.
-
- name - the filename used for communication (ex. '/dev/tta')
- from_tty - says whether to be verbose or not */
-
-static void
-es1800_open (name, from_tty)
- char *name;
- int from_tty;
-{
- char buf[PBUFSIZ];
- char *p;
- int i, fcflag;
-
- m68020 = 0;
-
- if (!name) /* no device name given in target command */
- {
- error_no_arg ("serial port device name");
- }
-
- target_preopen (from_tty);
- es1800_close (0);
-
- /* open the device and configure it for communication */
-
-#ifndef DEBUG_STDIN
-
- es1800_desc = SERIAL_OPEN (name);
- if (es1800_desc == NULL)
- {
- perror_with_name (name);
- }
- savename = savestring (name, strlen (name));
-
- es1800_saved_ttystate = SERIAL_GET_TTY_STATE (es1800_desc);
-
- if ((fcflag = fcntl (es1800_desc->fd, F_GETFL, 0)) == -1)
- {
- perror_with_name ("fcntl serial");
- }
- es1800_fc_save = fcflag;
-
- fcflag = (fcflag & (FREAD | FWRITE)); /* mask out any funny stuff */
- if (fcntl (es1800_desc->fd, F_SETFL, fcflag) == -1)
- {
- perror_with_name ("fcntl serial");
- }
-
- if (baud_rate != -1)
- {
- if (SERIAL_SETBAUDRATE (es1800_desc, baud_rate))
- {
- SERIAL_CLOSE (es1800_desc);
- perror_with_name (name);
- }
- }
-
- SERIAL_RAW (es1800_desc);
-
- /* If there is something sitting in the buffer we might take it as a
- response to a command, which would be bad. */
- SERIAL_FLUSH_INPUT (es1800_desc);
-
-#endif /* DEBUG_STDIN */
-
- push_target (&es1800_ops); /* Switch to using remote target now */
- if (from_tty)
- {
- printf ("Remote ES1800 debugging using %s\n", name);
- }
-
-#if defined (LOG_FILE)
-
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- {
- perror_with_name (LOG_FILE);
- }
-
-#endif /* LOG_FILE */
-
- /* Hello? Are you there?, also check mode */
-
- /* send_with_reply( "DB 0 TO 1", buf, sizeof(buf)); */
- /* for (p = buf, i = 0; *p++ =='0';) */ /* count the number of zeros */
- /* i++; */
-
- send ("\032");
- getmessage (buf, sizeof (buf)); /* send reset character */
-
- if (from_tty)
- {
- printf ("Checking mode.... ");
- }
- /* m68020 = (i==8); */ /* if eight zeros then we are in m68020 mode */
-
- /* What kind of processor am i talking to ?*/
- p = buf;
- while (*p++ != '\n') {;}
- while (*p++ != '\n') {;}
- while (*p++ != '\n') {;}
- for (i = 0; i < 20; i++, p++) {;}
- m68020 = !strncmp (p, "68020", 5);
- if (from_tty)
- {
- printf ("You are in %s(%c%c%c%c%c)-mode\n", MODE, p[0], p[1], p[2],
- p[3], p[4]);
- }
-
- /* if no init_break statement is present in .gdb file we have to check
- whether to download a breakpoint routine or not */
-
-#if 0
- if ((es1800_break_vec == 0) || (verify_break (es1800_break_vec) != 0)
- && query ("No breakpoint routine in ES 1800 emulator!\nDownload a breakpoint routine to the emulator? "))
- {
- CORE_ADDR memaddress;
- printf ("Give the start address of the breakpoint routine: ");
- scanf ("%li", &memaddress);
- es1800_init_break ((es1800_break_vec ? es1800_break_vec :
- ES1800_BREAK_VEC), memaddress);
- }
-#endif
-
-}
-
-/* Close out all files and local state before this target loses control.
- quitting - are we quitting gdb now? */
-
-static void
-es1800_close (quitting)
- int quitting;
-{
- if (es1800_desc != NULL)
- {
- printf ("\nClosing connection to emulator...\n");
- if (SERIAL_SET_TTY_STATE (es1800_desc, es1800_saved_ttystate) < 0)
- print_sys_errmsg ("warning: unable to restore tty state", errno);
- fcntl (es1800_desc->fd, F_SETFL, es1800_fc_save);
- SERIAL_CLOSE (es1800_desc);
- es1800_desc = NULL;
- }
- if (savename != NULL)
- {
- free (savename);
- }
- savename = NULL;
-
-#if defined (LOG_FILE)
-
- if (log_file != NULL)
- {
- if (ferror (log_file))
- {
- printf ("Error writing log file.\n");
- }
- if (fclose (log_file) != 0)
- {
- printf ("Error closing log file.\n");
- }
- log_file = NULL;
- }
-
-#endif /* LOG_FILE */
-
-}
-
-/* Attaches to a process on the target side
- proc_id - the id of the process to be attached.
- from_tty - says whether to be verbose or not */
-
-static void
-es1800_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- error ("Cannot attach to pid %s, this feature is not implemented yet.",
- args);
-}
-
-
-/* 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.
-
- args - arguments given to the 'detach' command
- from_tty - says whether to be verbose or not */
-
-static void
-es1800_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 es1800 remote debugging.\n");
- }
-}
-
-
-/* Tell the remote machine to resume.
- step - single-step or run free
- siggnal - the signal value to be given to the target (0 = no signal) */
-
-static void
-es1800_resume (pid, step, siggnal)
- int pid;
- int step;
- enum target_signal siggnal;
-{
- char buf[PBUFSIZ];
-
- if (siggnal)
- {
- error ("Can't send signals to a remote system.");
- }
- if (step)
- {
- strcpy (buf,"STP\r");
- send (buf);
- }
- else
- {
- send_command ("RBK");
- }
-}
-
-/* Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would.
- status - */
-
-static int
-es1800_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- unsigned char buf[PBUFSIZ];
- int old_timeout = timeout;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- timeout = 0; /* Don't time out -- user program is running. */
- if (!setjmp (interrupt))
- {
- old_sigint = signal (SIGINT, es1800_request_quit);
- while (1)
- {
- getmessage (buf, sizeof(buf));
- if (strncmp ( buf, "\r\n* BREAK *", 11) == 0)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- send_command ("STP"); /* Restore stack and PC and such */
- if (m68020)
- {
- send_command ("STP");
- }
- break;
- }
- if (strncmp (buf, "STP\r\n ", 6) == 0)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- }
- if (buf[strlen (buf) - 2] == 'R')
- {
- printf ("Unexpected emulator reply: \n%s\n", buf);
- }
- else
- {
- printf ("Unexpected stop: \n%s\n", buf);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_QUIT;
- break;
- }
- }
- }
- else
- {
- fflush (stdin);
- printf ("\nStopping emulator...");
- if (!setjmp (interrupt))
- {
- old_sigint = signal (SIGINT, es1800_request_quit);
- send_command ("STP");
- printf (" emulator stopped\n");
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_INT;
- }
- else
- {
- fflush (stdin);
- es1800_reset ((char*) 1);
- }
- }
- signal (SIGINT, old_sigint);
- timeout = old_timeout;
- return (0);
-}
-
-
-/* Fetch register values from remote machine.
- regno - the register to be fetched (fetch all registers if -1) */
-
-static void
-es1800_fetch_register (regno)
- int regno;
-{
- char buf[PBUFSIZ];
- int k;
- int r;
- char *p;
- static char regtab[18][4] =
- {
- "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
- "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
- "SR ", "PC "
- };
-
- if ((regno < 15) || (regno == 16) || (regno == 17))
- {
- r = regno * 4;
- send_with_reply (regtab[regno], buf, sizeof (buf));
- p = buf;
- for (k = 0; k < 4; k++)
- {
- if ((p[k*2 + 1] == 0) || (p[k*2 + 2] == 0))
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] = (fromhex (p[k*2 + 1]) * 16) + fromhex (p[k*2 + 2]);
- }
- }
- else
- {
- es1800_fetch_registers ();
- }
-}
-
-/* Read the remote registers into REGISTERS.
- Always fetches all registers. */
-
-static void
-es1800_fetch_registers ()
-{
- char buf[PBUFSIZ];
- char SR_buf[PBUFSIZ];
- int i;
- int k;
- int r;
- char *p;
-
- send_with_reply ("DR", buf, sizeof (buf));
-
- /* Reply is edited to a string that describes registers byte by byte,
- each byte encoded as two hex characters. */
-
- p = buf;
- r = 0;
-
- /* parsing row one - D0-D7-registers */
-
- while (*p++ != '\n') {;}
- for (i = 4; i < 70; i += (i == 39 ? 3 : 1))
- {
- for (k = 0; k < 4; k++)
- {
- if (p[i+0] == 0 || p[i+1] == 0)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] = (fromhex (p[i+0]) * 16) + fromhex (p[i+1]);
- i += 2;
- }
- }
- p += i;
-
- /* parsing row two - A0-A6-registers */
-
- while (*p++ != '\n') {;}
- for (i = 4; i < 61; i += (i == 39 ? 3 : 1))
- {
- for (k = 0; k < 4; k++)
- {
- if (p[i+0] == 0 || p[i+1] == 0)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] = (fromhex (p[i+0])) * 16 + fromhex (p[i+1]);
- i += 2;
- }
- }
- p += i;
-
- while (*p++ != '\n') {;}
-
- /* fetch SSP-, SR- and PC-registers */
-
- /* first - check STATUS-word and decide which stackpointer to use */
-
- send_with_reply ("SR", SR_buf, sizeof (SR_buf));
- p = SR_buf;
- p += 5;
-
- if (m68020)
- {
- if (*p == '3') /* use masterstackpointer MSP */
- {
- send_with_reply ("MSP", buf, sizeof (buf));
- }
- else if (*p == '2') /* use interruptstackpointer ISP */
- {
- send_with_reply ("ISP", buf, sizeof (buf));
- }
- else /* use userstackpointer USP */
- {
- send_with_reply ("USP", buf, sizeof (buf));
- }
- p = buf;
- for (k = 0; k<4; k++)
- {
- if (p[k*2+1] == 0 || p[k*2+2] == 0)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] = fromhex (buf[k*2+1]) * 16 + fromhex (buf[k*2+2]);
- }
-
- p = SR_buf;
- for (k = 0; k < 4; k++)
- {
- if (p[k*2+1] == 0 || p[k*2+2] == 0)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] =
- fromhex (SR_buf[k*2+1]) * 16 + fromhex (SR_buf[k*2+2]);
- }
- send_with_reply ("PC", buf, sizeof (buf));
- p = buf;
- for (k = 0; k<4; k++)
- {
- if (p[k*2+1] == 0 || p[k*2+2] == 0)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] = fromhex (buf[k*2+1]) * 16 + fromhex (buf[k*2+2]);
- }
- }
- else /* 68000-mode */
- {
- if (*p == '2') /* use supervisorstackpointer SSP */
- {
- send_with_reply ("SSP", buf, sizeof (buf));
- }
- else /* use userstackpointer USP */
- {
- send_with_reply ("USP", buf, sizeof (buf));
- }
-
- /* fetch STACKPOINTER */
-
- p = buf;
- for (k = 0; k < 4; k++)
- {
- if (p[k*2 + 1] == 0 || p[k*2 + 2] == 0)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] = fromhex (buf[k*2+1]) * 16 + fromhex (buf[k*2+2]);
- }
-
- /* fetch STATUS */
-
- p = SR_buf;
- for (k = 0; k < 4; k++)
- {
- if (p[k*2+1] == 0 || p[k*2+2] == 0)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] =
- fromhex (SR_buf[k*2+1]) * 16 + fromhex (SR_buf[k*2+2]);
- }
-
- /* fetch PC */
-
- send_with_reply ("PC", buf, sizeof (buf));
- p = buf;
- for (k = 0; k < 4; k++)
- {
- if (p[k*2+1] == 0 || p[k*2+2] == 0)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- registers[r++] = fromhex (buf[k*2+1]) * 16 + fromhex (buf[k*2+2]);
- }
- }
-}
-
-/* Store register value, located in REGISTER, on the target processor.
- regno - the register-number of the register to store
- (-1 means store them all)
- FIXME: Return errno value. */
-
-static void
-es1800_store_register(regno)
- int regno;
-{
-
- static char regtab[18][4] =
- {
- "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
- "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
- "SR ", "PC "
- };
-
- char buf[PBUFSIZ];
- char SR_buf[PBUFSIZ];
- char stack_pointer[4];
- char *p;
- int i;
- int j;
- int k;
- unsigned char *r;
-
- r = (unsigned char *) registers;
-
- if (regno == -1) /* write all registers */
- {
- j = 0;
- k = 18;
- }
- else /* write one register */
- {
- j = regno;
- k = regno+1;
- r += regno * 4;
- }
-
- if ((regno == -1) || (regno == 15))
- {
- /* fetch current status */
- send_with_reply ("SR", SR_buf, sizeof (SR_buf));
- p = SR_buf;
- p += 5;
- if (m68020)
- {
- if (*p == '3') /* use masterstackpointer MSP */
- {
- strcpy (stack_pointer,"MSP");
- }
- else
- {
- if (*p == '2') /* use interruptstackpointer ISP */
- {
- strcpy (stack_pointer,"ISP");
- }
- else
- {
- strcpy (stack_pointer,"USP"); /* use userstackpointer USP */
- }
- }
- }
- else /* 68000-mode */
- {
- if (*p == '2') /* use supervisorstackpointer SSP */
- {
- strcpy (stack_pointer,"SSP");
- }
- else
- {
- strcpy (stack_pointer,"USP");/* use userstackpointer USP */
- }
- }
- strcpy (regtab[15],stack_pointer);
- }
-
- for (i = j; i<k; i++)
- {
- buf[0] = regtab[i][0];
- buf[1] = regtab[i][1];
- buf[2] = regtab[i][2];
- buf[3] = '=';
- buf[4] = '$';
- buf[5] = tohex ((*r >> 4) & 0x0f);
- buf[6] = tohex (*r++ & 0x0f);
- buf[7] = tohex ((*r >> 4) & 0x0f);
- buf[8] = tohex (*r++ & 0x0f);
- buf[9] = tohex ((*r >> 4) & 0x0f);
- buf[10] = tohex (*r++ & 0x0f);
- buf[11] = tohex ((*r >> 4) & 0x0f);
- buf[12] = tohex (*r++ & 0x0f);
- buf[13] = 0;
-
- send_with_reply (buf, buf, sizeof (buf)); /* FIXME, reply not used? */
- }
-}
-
-
-/* Prepare to store registers. */
-
-static void
-es1800_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-/* 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 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);
- }
-}
-
-/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
- to or from debugger address MYADDR. Write to inferior if WRITE is
- nonzero. Returns length of data written or read; 0 for error.
-
- memaddr - the target's address
- myaddr - gdb's address
- len - number of bytes
- write - write if != 0 otherwise read */
-
-static int
-es1800_xfer_inferior_memory (memaddr, myaddr, len, write, tops)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *tops; /* Unused */
-{
- int origlen = len;
- int xfersize;
-
- while (len > 0)
- {
- xfersize = len > MAXBUFBYTES ? MAXBUFBYTES : len;
- if (write)
- {
- es1800_write_bytes (memaddr, myaddr, xfersize);
- }
- else
- {
- es1800_read_bytes (memaddr, myaddr, xfersize);
- }
- memaddr += xfersize;
- myaddr += xfersize;
- len -= xfersize;
- }
- return (origlen); /* no error possible */
-}
-
-
-/* Write memory data directly to the emulator.
- 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.
-
- memaddr - the target's address
- myaddr - gdb's address
- len - number of bytes */
-
-static void
-es1800_write_bytes (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- char buf[PBUFSIZ];
- int i;
- char *p;
-
- p = myaddr;
- for (i = 0; i < len; i++)
- {
- sprintf (buf, "@.B$%x=$%x", memaddr+i, (*p++) & 0xff);
- send_with_reply (buf, buf, sizeof (buf)); /* FIXME send_command? */
- }
-}
-
-
-/* Read memory data directly from the emulator.
- This does not use the data cache; the data cache uses this.
-
- memaddr - the target's address
- myaddr - gdb's address
- len - number of bytes */
-
-static void
-es1800_read_bytes (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- static int DB_tab[16] = {8,11,14,17,20,23,26,29,34,37,40,43,46,49,52,55};
- char buf[PBUFSIZ];
- int i;
- int low_addr;
- char *p;
- char *b;
-
- if (len > PBUFSIZ / 2 - 1)
- {
- abort ();
- }
-
- if (len == 1) /* The emulator does not like expressions like: */
- {
- len = 2; /* DB.B $20018 TO $20018 */
- }
-
- /* Reply describes registers byte by byte, each byte encoded as two hex
- characters. */
-
- sprintf (buf, "DB.B $%x TO $%x", memaddr, memaddr+len-1);
- send_with_reply (buf, buf, sizeof (buf));
- b = buf;
- low_addr = memaddr&0x0f;
- for (i = low_addr; i < low_addr + len; i++)
- {
- if ((!(i % 16)) && i)
- { /* if (i = 16,32,48) */
- while (*p++!='\n') {;}
- b = p;
- }
- p = b + DB_tab[i%16] + (m68020 ? 2 : 0);
- if (p[0] == 32 || p[1] == 32)
- {
- error ("Emulator reply is too short: %s", buf);
- }
- myaddr[i-low_addr] = fromhex (p[0]) * 16 + fromhex (p[1]);
- }
-}
-
-/* Information about the current target */
-
-static void
-es1800_files_info (tops)
- struct target_ops *tops; /* Unused */
-{
- printf ("ES1800 Attached to %s at %d baud in %s mode\n", savename, 19200,
- MODE);
-}
-
-
-/* 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... */
-
-static int
-es1800_insert_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- int val;
-
- val = target_read_memory (addr, contents_cache, sizeof (es1800_break_insn));
-
- if (val == 0)
- {
- val = target_write_memory (addr, es1800_break_insn,
- sizeof (es1800_break_insn));
- }
-
- return (val);
-}
-
-
-/* Write back the stashed 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. */
-
-static int
-es1800_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
-
- return (target_write_memory (addr, contents_cache,
- sizeof (es1800_break_insn)));
-}
-
-/* create_break_insn ()
- Primitive datastructures containing the es1800 breakpoint instruction */
-
-static void
-es1800_create_break_insn (ins, vec)
- char *ins;
- int vec;
-{
- if (vec == 15)
- {
- ins[0] = 0x4e;
- ins[1] = 0x4f;
- }
-}
-
-
-/* verify_break ()
- Seach for breakpoint routine in emulator memory.
- returns non-zero on failure
- vec - trap vector used for breakpoints */
-
-static int
-verify_break (vec)
- int vec;
-{
- CORE_ADDR memaddress;
- char buf[8];
- char *instr = "NqNqNqNs"; /* breakpoint routine */
- int status;
-
- get_break_addr (vec, &memaddress);
-
- if (memaddress)
- {
- status = target_read_memory (memaddress, buf, 8);
- if (status != 0)
- {
- memory_error (status, memaddress);
- }
- return (STRCMP (instr, buf));
- }
- return (-1);
-}
-
-
-/* get_break_addr ()
- find address of breakpint routine
- vec - trap vector used for breakpoints
- addrp - store the address here */
-
-static void
-get_break_addr (vec, addrp)
- int vec;
- CORE_ADDR *addrp;
-{
- CORE_ADDR memaddress = 0;
- int status;
- int k;
- char buf[PBUFSIZ];
- char base_addr[4];
- char *p;
-
- if (m68020)
- {
- send_with_reply ("VBR ", buf, sizeof (buf));
- p = buf;
- for (k = 0; k < 4; k++)
- {
- if ((p[k*2 + 1] == 0) || (p[k*2 + 2] == 0))
- {
- error ("Emulator reply is too short: %s", buf);
- }
- base_addr[k] = (fromhex (p[k*2 + 1]) * 16) + fromhex (p[k*2 + 2]);
- }
- /* base addr of exception vector table */
- memaddress = *((CORE_ADDR *) base_addr);
- }
-
- memaddress += (vec + 32) * 4; /* address of trap vector */
- status = target_read_memory (memaddress, (char *) addrp, 4);
- if (status != 0)
- {
- memory_error (status, memaddress);
- }
-}
-
-
-/* Kill an inferior process */
-
-static void
-es1800_kill ()
-{
- if (inferior_pid != 0)
- {
- inferior_pid = 0;
- es1800_mourn_inferior ();
- }
-}
-
-
-/* Load a file to the ES1800 emulator.
- Converts the file from a.out format into Extended Tekhex format
- before the file is loaded.
- Also loads the trap routine, and sets the ES1800 breakpoint on it
- filename - the a.out to be loaded
- from_tty - says whether to be verbose or not
- FIXME Uses emulator overlay memory for trap routine */
-
-static void
-es1800_load (filename, from_tty)
- char *filename;
- int from_tty;
-{
-
- FILE *instream;
- char loadname[15];
- char buf[160];
- struct cleanup *old_chain;
- int es1800_load_format = 5;
-
- if (es1800_desc == NULL)
- {
- printf ("No emulator attached, type emulator-command first\n");
- return;
- }
-
- filename = tilde_expand (filename);
- make_cleanup (free, filename);
-
- switch (es1800_load_format)
- {
- case 2: /* Extended Tekhex */
- if (from_tty)
- {
- printf ("Converting \"%s\" to Extended Tekhex Format\n", filename);
- }
- sprintf (buf, "tekhex %s", filename);
- system (buf);
- sprintf (loadname, "out.hex");
- break;
-
- case 5: /* Motorola S-rec */
- if (from_tty)
- {
- printf ("Converting \"%s\" to Motorola S-record format\n",
- filename);
- }
- /* in the future the source code in copy (part of binutils-1.93) will
- be included in this file */
- sprintf (buf,
- "copy -s \"a.out-sunos-big\" -d \"srec\" %s /tmp/out.hex",
- filename);
- system (buf);
- sprintf (loadname, "/tmp/out.hex");
- break;
-
- default:
- error ("Downloading format not defined\n");
- }
-
- breakpoint_init_inferior ();
- inferior_pid = 0;
- if (from_tty)
- {
- printf ("Downloading \"%s\" to the ES 1800\n",filename);
- }
- if ((instream = fopen (loadname, "r")) == NULL)
- {
- perror_with_name ("fopen:");
- }
-
- old_chain = make_cleanup (fclose, instream);
- immediate_quit++;
-
- es1800_reset (0);
-
- download (instream, from_tty, es1800_load_format);
-
- /* if breakpoint routine is not present anymore we have to check
- whether to download a new breakpoint routine or not */
-
- if ((verify_break (es1800_break_vec) != 0)
- && query ("No breakpoint routine in ES 1800 emulator!\nDownload a breakpoint routine to the emulator? "))
- {
- char buf[128];
- printf ("Using break vector 0x%x\n", es1800_break_vec);
- sprintf (buf, "0x%x ", es1800_break_vec);
- printf ("Give the start address of the breakpoint routine: ");
- fgets (buf + strlen (buf), sizeof (buf) - strlen (buf), stdin);
- es1800_init_break (buf, 0);
- }
-
- do_cleanups (old_chain);
- expect_prompt ();
- readchar (); /* FIXME I am getting a ^G = 7 after the prompt */
- printf ("\n");
-
- if (fclose (instream) == EOF)
- {
- ;
- }
-
- if (es1800_load_format != 2)
- {
- sprintf (buf, "/usr/bin/rm %s", loadname);
- system (buf);
- }
-
- symbol_file_command (filename, from_tty); /* reading symbol table */
- immediate_quit--;
-}
-
-#if 0
-
-#define NUMCPYBYTES 20
-
-static void
-bfd_copy (from_bfd, to_bfd)
- bfd *from_bfd;
- bfd *to_bfd;
-{
- asection *p, *new;
- int i;
- char buf[NUMCPYBYTES];
-
- for (p = from_bfd->sections; p != NULL; p = p->next)
- {
- printf (" Copying section %s. Size = %x.\n", p->name, p->_cooked_size);
- printf (" vma = %x, offset = %x, output_sec = %x\n",
- p->vma, p->output_offset, p->output_section);
- new = bfd_make_section (to_bfd, p->name);
- if (p->_cooked_size &&
- !bfd_set_section_size (to_bfd, new, p->_cooked_size))
- {
- error ("Wrong BFD size!\n");
- }
- if (!bfd_set_section_flags (to_bfd, new, p->flags))
- {
- error ("bfd_set_section_flags");
- }
- new->vma = p->vma;
-
- for (i = 0; (i + NUMCPYBYTES) < p->_cooked_size ; i += NUMCPYBYTES)
- {
- if (!bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
- (bfd_size_type) NUMCPYBYTES))
- {
- error ("bfd_get_section_contents\n");
- }
- if (!bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
- (bfd_size_type) NUMCPYBYTES))
- {
- error ("bfd_set_section_contents\n");
- }
- }
- bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
- (bfd_size_type) (p->_cooked_size - i));
- bfd_set_section_contents (to_bfd, new, (PTR) buf,(file_ptr) i,
- (bfd_size_type) (p->_cooked_size - i));
- }
-}
-
-#endif
-
-/* Start an process on the es1800 and set inferior_pid to the new
- process' pid.
- execfile - the file to run
- args - arguments passed to the program
- env - the environment vector to pass */
-
-static void
-es1800_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- int entry_pt;
- int pid;
-#if 0
- struct expression *expr;
- register struct cleanup *old_chain = 0;
- register value val;
-#endif
-
- if (args && *args)
- {
- error ("Can't pass arguments to remote ES1800 process");
- }
-
-#if 0
- if (query ("Use 'start' as entry point? "))
- {
- expr = parse_c_expression ("start");
- old_chain = make_cleanup (free_current_contents, &expr);
- val = evaluate_expression (expr);
- entry_pt = (val->location).address;
- }
- else
- {
- printf ("Enter the program's entry point (in hexadecimal): ");
- scanf ("%x", &entry_pt);
- }
-#endif
-
- if (execfile == 0 || exec_bfd == 0)
- {
- error ("No executable file specified");
- }
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
- pid = 42;
-
- /* Now that we have a child process, make it our target. */
-
- push_target (&es1800_child_ops);
-
- /* The "process" (board) is already stopped awaiting our commands, and
- the program is already downloaded. We just set its PC and go. */
-
- inferior_pid = pid; /* Needed for wait_for_inferior below */
-
- clear_proceed_status ();
-
- /* Tell wait_for_inferior that we've started a new process. */
-
- 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; */
- /* insert_step_breakpoint (); FIXME, do we need this? */
-
- /* Let 'er rip... */
- proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0);
-
-}
-
-
-/* The process has died, clean up. */
-
-static void
-es1800_mourn_inferior ()
-{
- remove_breakpoints ();
- unpush_target (&es1800_child_ops);
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-
-/* ES1800-protocol specific routines */
-
-/* Keep discarding input from the remote system, until STRING is found.
- Let the user break out immediately.
- string - the string to expect
- nowait - break out if string not the emulator's first respond otherwise
- read until string is found (== 0) */
-
-static void
-expect (string, nowait)
- char *string;
- int nowait;
-{
- char c;
- char *p = string;
-
- immediate_quit++;
- while (1)
- {
- c = readchar ();
- if (isalpha (c))
- {
- c = toupper (c);
- }
- if (c == toupper (*p))
- {
- p++;
- if (*p == '\0')
- {
- immediate_quit--;
- return;
- }
- }
- else if (!nowait)
- {
- p = string;
- }
- else
- {
- printf ("\'%s\' expected\n" , string);
- printf ("char %d is %d", p - string, c);
- error ("\n" );
- }
- }
-}
-
-/* Keep discarding input until we see the prompt. */
-
-static void
-expect_prompt ()
-{
- expect (">", 0);
-}
-
-
-/* Read one character */
-
-#ifdef DEBUG_STDIN
-
-/* read from stdin */
-
-static int
-readchar ()
-{
- char buf[1];
-
- buf[0] = '\0';
- printf ("readchar, give one character\n");
- read (0, buf, 1);
-
-#if defined (LOG_FILE)
- putc (buf[0] & 0x7f, log_file);
-#endif
-
- return (buf[0] & 0x7f);
-}
-
-#else /* !DEBUG_STDIN */
-
-/* Read a character from the remote system, doing all the fancy
- timeout stuff. */
-
-static int
-readchar ()
-{
- int ch;
-
- ch = SERIAL_READCHAR (es1800_desc, timeout);
-
- /* FIXME: doing an error() here will probably cause trouble, at least if from
- es1800_wait. */
- if (ch == SERIAL_TIMEOUT)
- error ("Timeout reading from remote system.");
- else if (ch == SERIAL_ERROR)
- perror_with_name ("remote read");
-
-#if defined (LOG_FILE)
- putc (ch & 0x7f, log_file);
- fflush (log_file);
-#endif
-
- return (ch);
-}
-
-#endif /* DEBUG_STDIN */
-
-
-/* Send a command to the emulator and save the reply.
- Report an error if we get an error reply.
- string - the es1800 command
- buf - containing the emulator reply on return
- len - size of buf */
-
-static void
-send_with_reply (string, buf, len)
- char *string, *buf;
- int len;
-{
- send (string);
- SERIAL_WRITE (es1800_desc, "\r", 1);
-
-#ifndef DEBUG_STDIN
- expect (string, 1);
- expect ("\r\n", 0);
-#endif
-
- getmessage (buf, len);
-}
-
-
-/* Send the command in STR to the emulator adding \r. check
- the echo for consistency.
- string - the es1800 command */
-
-static void
-send_command (string)
- char *string;
-{
- send (string);
- SERIAL_WRITE (es1800_desc, "\r", 1);
-
-#ifndef DEBUG_STDIN
- expect (string, 0);
- expect_prompt ();
-#endif
-
-}
-
-/* Send a string
- string - the es1800 command */
-
-static void
-send (string)
- char *string;
-{
- if (kiodebug)
- {
- fprintf (stderr, "Sending: %s\n", string);
- }
- SERIAL_WRITE (es1800_desc, string, strlen (string));
-}
-
-
-/* Read a message from the emulator and store it in BUF.
- buf - containing the emulator reply on return
- len - size of buf */
-
-static void
-getmessage (buf, len)
- char *buf;
- int len;
-{
- char *bp;
- int c;
- int prompt_found = 0;
- extern kiodebug;
-
-#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
-
- bp = buf;
- c = readchar ();
- do
- {
- if (c)
- {
- if (len-- < 2) /* char and terminaling NULL */
- {
- error ("input buffer overrun\n");
- }
- *bp++ = c;
- }
- c = readchar ();
- if ((c == '>') && (*(bp - 1) == ' '))
- {
- prompt_found = 1;
- }
- }
- while (!prompt_found);
- *bp = 0;
-
- if (kiodebug)
- {
- fprintf (stderr,"message received :%s\n", buf);
- }
-}
-
-static void
-download (instream, from_tty, format)
-FILE *instream;
- int from_tty;
- int format;
-{
- char c;
- char buf[160];
- int i = 0;
-
- send_command ("SET #2,$1A"); /* reset char = ^Z */
- send_command ("SET #3,$11,$13"); /* XON XOFF */
- if (format == 2)
- {
- send_command ("SET #26,#2");
- }
- else
- {
- send_command ("SET #26,#5"); /* Format=Extended Tekhex */
- }
- send_command ("DFB = $10");
- send_command ("PUR");
- send_command ("CES");
- send ("DNL\r");
- expect ("DNL", 1);
- if (from_tty)
- {
- printf (" 0 records loaded...\r");
- }
- while (fgets (buf, 160, instream))
- {
- send (buf);
- if (from_tty)
- {
- printf ("%5d\b\b\b\b\b",++i);
- fflush (stdout);
- }
- if ((c = readchar ()) != 006)
- {
- error ("expected ACK");
- }
- }
- if (from_tty)
- {
- printf ("- All");
- }
-}
-
-/* Additional commands */
-
-#if defined (TIOCGETP) && defined (FNDELAY) && defined (EWOULDBLOCK)
-#define PROVIDE_TRANSPARENT
-#endif
-
-#ifdef PROVIDE_TRANSPARENT
-/* Talk directly to the emulator
- FIXME, uses busy wait, and is SUNOS (or at least BSD) specific */
-
-/*ARGSUSED*/
-static void
-es1800_transparent (args, from_tty)
- char *args;
- int from_tty;
-{
- int console;
- struct sgttyb modebl;
- int fcflag;
- int cc;
- struct sgttyb console_mode_save;
- int console_fc_save;
- int es1800_fc_save;
- int inputcnt = 80;
- char inputbuf[80];
- int consolecnt = 0;
- char consolebuf[80];
- int es1800_cnt = 0;
- char es1800_buf[80];
- int i;
-
- dont_repeat ();
- if (es1800_desc == NULL)
- {
- printf ("No emulator attached, type emulator-command first\n");
- return;
- }
-
- printf ("\n");
- printf ("You are now communicating directly with the ES 1800 emulator.\n");
- printf ("To leave this mode (transparent mode), press ^E.\n");
- printf ("\n");
- printf (" >");
- fflush (stdout);
-
- if ((console = open ("/dev/tty", O_RDWR)) == -1)
- {
- perror_with_name ("/dev/tty:");
- }
-
- if ((fcflag = fcntl (console, F_GETFL, 0)) == -1)
- {
- perror_with_name ("fcntl console");
- }
-
- console_fc_save = fcflag;
- fcflag = fcflag | FNDELAY;
-
- if (fcntl (console, F_SETFL, fcflag) == -1)
- {
- perror_with_name ("fcntl console");
- }
-
- if (ioctl (console, TIOCGETP, &modebl))
- {
- perror_with_name ("ioctl console");
- }
-
- console_mode_save = modebl;
- modebl.sg_flags = RAW;
-
- if (ioctl (console, TIOCSETP, &modebl))
- {
- perror_with_name ("ioctl console");
- }
-
- if ((fcflag = fcntl (es1800_desc->fd, F_GETFL, 0)) == -1)
- {
- perror_with_name ("fcntl serial");
- }
-
- es1800_fc_save = fcflag;
- fcflag = fcflag | FNDELAY;
-
- if (fcntl (es1800_desc->fd, F_SETFL, fcflag) == -1)
- {
- perror_with_name ("fcntl serial");
- }
-
- while (1)
- {
- cc = read (console, inputbuf, inputcnt);
- if (cc != -1)
- {
- if ((*inputbuf & 0x7f) == 0x05)
- {
- break;
- }
- for (i = 0; i < cc; )
- {
- es1800_buf[es1800_cnt++] = inputbuf[i++];
- }
- if ((cc = SERIAL_WRITE (es1800_desc, es1800_buf, es1800_cnt)) == -1)
- {
- perror_with_name ("FEL! write:");
- }
- es1800_cnt -= cc;
- if (es1800_cnt && cc)
- {
- for (i = 0; i < es1800_cnt; i++)
- {
- es1800_buf[i] = es1800_buf[cc+i];
- }
- }
- }
- else if (errno != EWOULDBLOCK)
- {
- perror_with_name ("FEL! read:");
- }
-
- cc = read (es1800_desc->fd,inputbuf,inputcnt);
- if (cc != -1)
- {
- for (i = 0; i < cc; )
- {
- consolebuf[consolecnt++] = inputbuf[i++];
- }
- if ((cc = write (console,consolebuf,consolecnt)) == -1)
- {
- perror_with_name ("FEL! write:");
- }
- consolecnt -= cc;
- if (consolecnt && cc)
- {
- for (i = 0; i < consolecnt; i++)
- {
- consolebuf[i] = consolebuf[cc+i];
- }
- }
- }
- else if (errno != EWOULDBLOCK)
- {
- perror_with_name ("FEL! read:");
- }
- }
-
- console_fc_save = console_fc_save & !FNDELAY;
- if (fcntl (console, F_SETFL, console_fc_save) == -1)
- {
- perror_with_name ("FEL! fcntl");
- }
-
- if (ioctl (console, TIOCSETP, &console_mode_save))
- {
- perror_with_name ("FEL! ioctl");
- }
-
- close (console);
-
- if (fcntl (es1800_desc->fd, F_SETFL, es1800_fc_save) == -1)
- {
- perror_with_name ("FEL! fcntl");
- }
-
- printf ("\n");
-
-}
-#endif /* PROVIDE_TRANSPARENT */
-
-static void
-es1800_init_break (args, from_tty)
- char *args;
- int from_tty;
-{
- CORE_ADDR memaddress = 0;
- char buf[PBUFSIZ];
- char base_addr[4];
- char *space_index;
- char *p;
- int k;
-
- if (args == NULL)
- {
- error_no_arg ("a trap vector");
- }
-
- if (!(space_index = strchr (args, ' ')))
- {
- error ("Two arguments needed (trap vector and address of break routine).\n");
- }
-
- *space_index = '\0';
-
- es1800_break_vec = strtol (args, (char **) NULL, 0);
- es1800_break_address = parse_and_eval_address (space_index + 1);
-
- es1800_create_break_insn (es1800_break_insn, es1800_break_vec);
-
- if (m68020)
- {
- send_with_reply ("VBR ", buf, sizeof (buf));
- p = buf;
- for (k = 0; k < 4; k++)
- {
- if ((p[k*2 + 1] == 0) || (p[k*2 + 2] == 0))
- {
- error ("Emulator reply is too short: %s", buf);
- }
- base_addr[k] = (fromhex (p[k*2 + 1]) * 16) + fromhex (p[k*2 + 2]);
- }
- /* base addr of exception vector table */
- memaddress = *((CORE_ADDR *) base_addr);
- }
-
- memaddress += (es1800_break_vec + 32) * 4; /* address of trap vector */
-
- sprintf (buf, "@.L%lx=$%lx", memaddress, es1800_break_address);
- send_command (buf); /* set the address of the break routine in the */
- /* trap vector */
-
- sprintf (buf, "@.L%lx=$4E714E71", es1800_break_address); /* NOP; NOP */
- send_command (buf);
- sprintf (buf, "@.L%lx=$4E714E73", es1800_break_address + 4); /* NOP; RTE */
- send_command (buf);
-
- sprintf (buf, "AC2=$%lx", es1800_break_address + 4);
- /* breakpoint at es1800-break_address */
- send_command (buf);
- send_command ("WHEN AC2 THEN BRK"); /* ie in exception routine */
-
- if (from_tty)
- {
- printf ("Breakpoint (trap $%x) routine at address: %lx\n",
- es1800_break_vec, es1800_break_address);
- }
-}
-
-static void
-es1800_child_open (arg, from_tty)
- char *arg;
- int from_tty;
-{
- error ("Use the \"run\" command to start a child process.");
-}
-
-static void
-es1800_child_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 debugging the process %d.\n", inferior_pid);
- }
-}
-
-
-/* Define the target subroutine names */
-
-struct target_ops es1800_ops ;
-
-static void
-init_es1800_ops(void)
-{
- es1800_ops.to_shortname = "es1800";
- es1800_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
- es1800_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya)." ;
- es1800_ops.to_open = es1800_open;
- es1800_ops.to_close = es1800_close;
- es1800_ops.to_attach = es1800_attach;
- es1800_ops.to_post_attach = NULL;
- es1800_ops.to_require_attach = NULL;
- es1800_ops.to_detach = es1800_detach;
- es1800_ops.to_require_detach = NULL;
- es1800_ops.to_resume = es1800_resume;
- es1800_ops.to_wait = NULL;
- es1800_ops.to_post_wait = NULL;
- es1800_ops.to_fetch_registers = NULL;
- es1800_ops.to_store_registers = NULL;
- es1800_ops.to_prepare_to_store = es1800_prepare_to_store;
- es1800_ops.to_xfer_memory = es1800_xfer_inferior_memory;
- es1800_ops.to_files_info = es1800_files_info;
- es1800_ops.to_insert_breakpoint = es1800_insert_breakpoint;
- es1800_ops.to_remove_breakpoint = es1800_remove_breakpoint;
- es1800_ops.to_terminal_init = NULL;
- es1800_ops.to_terminal_inferior = NULL;
- es1800_ops.to_terminal_ours_for_output = NULL;
- es1800_ops.to_terminal_ours = NULL;
- es1800_ops.to_terminal_info = NULL;
- es1800_ops.to_kill = NULL;
- es1800_ops.to_load = es1800_load;
- es1800_ops.to_lookup_symbol = NULL;
- es1800_ops.to_create_inferior = es1800_create_inferior;
- es1800_ops.to_post_startup_inferior = NULL;
- es1800_ops.to_acknowledge_created_inferior = NULL;
- es1800_ops.to_clone_and_follow_inferior = NULL;
- es1800_ops.to_post_follow_inferior_by_clone = NULL;
- es1800_ops.to_insert_fork_catchpoint = NULL;
- es1800_ops.to_remove_fork_catchpoint = NULL;
- es1800_ops.to_insert_vfork_catchpoint = NULL;
- es1800_ops.to_remove_vfork_catchpoint = NULL;
- es1800_ops.to_has_forked = NULL;
- es1800_ops.to_has_vforked = NULL;
- es1800_ops.to_can_follow_vfork_prior_to_exec = NULL;
- es1800_ops.to_post_follow_vfork = NULL;
- es1800_ops.to_insert_exec_catchpoint = NULL;
- es1800_ops.to_remove_exec_catchpoint = NULL;
- es1800_ops.to_has_execd = NULL;
- es1800_ops.to_reported_exec_events_per_exec_call = NULL;
- es1800_ops.to_has_exited = NULL;
- es1800_ops.to_mourn_inferior = NULL;
- es1800_ops.to_can_run = 0;
- es1800_ops.to_notice_signals = 0;
- es1800_ops.to_thread_alive = 0;
- es1800_ops.to_stop = 0;
- es1800_ops.to_pid_to_exec_file = NULL;
- es1800_ops.to_core_file_to_sym_file = NULL;
- es1800_ops.to_stratum = core_stratum;
- es1800_ops.DONT_USE = 0;
- es1800_ops.to_has_all_memory = 0;
- es1800_ops.to_has_memory = 1;
- es1800_ops.to_has_stack = 0;
- es1800_ops.to_has_registers = 0;
- es1800_ops.to_has_execution = 0;
- es1800_ops.to_sections = NULL;
- es1800_ops.to_sections_end = NULL;
- es1800_ops.to_magic = OPS_MAGIC ;
-}
-
-/* Define the target subroutine names */
-
-struct target_ops es1800_child_ops ;
-
-static void
-init_es1800_child_ops(void)
-{
- es1800_child_ops.to_shortname = "es1800_process";
- es1800_child_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
- es1800_child_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
- es1800_child_ops.to_open = es1800_child_open;
- es1800_child_ops.to_close = NULL;
- es1800_child_ops.to_attach = es1800_attach;
- es1800_child_ops.to_post_attach = NULL;
- es1800_child_ops.to_require_attach = NULL;
- es1800_child_ops.to_detach = es1800_child_detach;
- es1800_child_ops.to_require_detach = NULL;
- es1800_child_ops.to_resume = es1800_resume;
- es1800_child_ops.to_wait = es1800_wait;
- es1800_child_ops.to_post_wait = NULL;
- es1800_child_ops.to_fetch_registers = es1800_fetch_register;
- es1800_child_ops.to_store_registers = es1800_store_register;
- es1800_child_ops.to_prepare_to_store = es1800_prepare_to_store;
- es1800_child_ops.to_xfer_memory = es1800_xfer_inferior_memory;
- es1800_child_ops.to_files_info = es1800_files_info;
- es1800_child_ops.to_insert_breakpoint = es1800_insert_breakpoint;
- es1800_child_ops.to_remove_breakpoint = es1800_remove_breakpoint;
- es1800_child_ops.to_terminal_init = NULL;
- es1800_child_ops.to_terminal_inferior = NULL;
- es1800_child_ops.to_terminal_ours_for_output = NULL;
- es1800_child_ops.to_terminal_ours = NULL;
- es1800_child_ops.to_terminal_info = NULL;
- es1800_child_ops.to_kill = es1800_kill;
- es1800_child_ops.to_load = es1800_load;
- es1800_child_ops.to_lookup_symbol = NULL;
- es1800_child_ops.to_create_inferior = es1800_create_inferior;
- es1800_child_ops.to_post_startup_inferior = NULL;
- es1800_child_ops.to_acknowledge_created_inferior = NULL;
- es1800_child_ops.to_clone_and_follow_inferior = NULL;
- es1800_child_ops.to_post_follow_inferior_by_clone = NULL;
- es1800_child_ops.to_insert_fork_catchpoint = NULL;
- es1800_child_ops.to_remove_fork_catchpoint = NULL;
- es1800_child_ops.to_insert_vfork_catchpoint = NULL;
- es1800_child_ops.to_remove_vfork_catchpoint = NULL;
- es1800_child_ops.to_has_forked = NULL;
- es1800_child_ops.to_has_vforked = NULL;
- es1800_child_ops.to_can_follow_vfork_prior_to_exec = NULL;
- es1800_child_ops.to_post_follow_vfork = NULL;
- es1800_child_ops.to_insert_exec_catchpoint = NULL;
- es1800_child_ops.to_remove_exec_catchpoint = NULL;
- es1800_child_ops.to_has_execd = NULL;
- es1800_child_ops.to_reported_exec_events_per_exec_call = NULL;
- es1800_child_ops.to_has_exited = NULL;
- es1800_child_ops.to_mourn_inferior = es1800_mourn_inferior;
- es1800_child_ops.to_can_run = 0;
- es1800_child_ops.to_notice_signals = 0;
- es1800_child_ops.to_thread_alive = 0;
- es1800_child_ops.to_stop = 0;
- es1800_child_ops.to_pid_to_exec_file = NULL;
- es1800_child_ops.to_core_file_to_sym_file = NULL;
- es1800_child_ops.to_stratum = process_stratum;
- es1800_child_ops.DONT_USE = 0;
- es1800_child_ops.to_has_all_memory = 1;
- es1800_child_ops.to_has_memory = 1;
- es1800_child_ops.to_has_stack = 1;
- es1800_child_ops.to_has_registers = 1;
- es1800_child_ops.to_has_execution = 1;
- es1800_child_ops.to_sections = NULL;
- es1800_child_ops.to_sections_end = NULL;
- es1800_child_ops.to_magic = OPS_MAGIC;
-}
-
-void
-_initialize_es1800 ()
-{
- init_es1800_ops() ;
- init_es1800_child_ops() ;
- add_target (&es1800_ops);
- add_target (&es1800_child_ops);
-#ifdef PROVIDE_TRANSPARENT
- add_com ("transparent", class_support, es1800_transparent,
- "Start transparent communication with the ES 1800 emulator.");
-#endif /* PROVIDE_TRANSPARENT */
- add_com ("init_break", class_support, es1800_init_break,
- "Download break routine and initialize break facility on ES 1800");
-}
diff --git a/contrib/gdb/gdb/remote-est.c b/contrib/gdb/gdb/remote-est.c
deleted file mode 100644
index 27fd8aa..0000000
--- a/contrib/gdb/gdb/remote-est.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/* Remote debugging interface for EST-300 ICE, for GDB
- Copyright 1995 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
-
- Written by Steve Chamberlain for Cygnus Support.
- Re-written by Stu Grossman of Cygnus Support
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "monitor.h"
-#include "serial.h"
-
-static void est_open PARAMS ((char *args, int from_tty));
-
-static void
-est_supply_register (regname, regnamelen, val, vallen)
- char *regname;
- int regnamelen;
- char *val;
- int vallen;
-{
- int regno;
-
- if (regnamelen != 2)
- return;
-
- switch (regname[0])
- {
- case 'S':
- if (regname[1] != 'R')
- return;
- regno = PS_REGNUM;
- break;
- case 'P':
- if (regname[1] != 'C')
- return;
- regno = PC_REGNUM;
- break;
- case 'D':
- if (regname[1] < '0' || regname[1] > '7')
- return;
- regno = regname[1] - '0' + D0_REGNUM;
- break;
- case 'A':
- if (regname[1] < '0' || regname[1] > '7')
- return;
- regno = regname[1] - '0' + A0_REGNUM;
- break;
- default:
- return;
- }
-
- monitor_supply_register (regno, val);
-}
-
-/*
- * This array of registers needs to match the indexes used by GDB. The
- * whole reason this exists is because the various ROM monitors use
- * different names than GDB does, and don't support all the
- * registers either. So, typing "info reg sp" becomes a "r30".
- */
-
-static char *est_regnames[NUM_REGS] =
-{
- "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
- "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
- "SR", "PC",
-};
-
-/*
- * Define the monitor command strings. Since these are passed directly
- * through to a printf style function, we need can include formatting
- * strings. We also need a CR or LF on the end.
- */
-
-static struct target_ops est_ops;
-
-static char *est_inits[] = {"he\r", /* Resets the prompt, and clears repeated cmds */
- NULL};
-
-static struct monitor_ops est_cmds ;
-
-static void
-init_est_cmds(void)
-{
- est_cmds.flags = MO_CLR_BREAK_USES_ADDR | MO_FILL_USES_ADDR | MO_NEED_REGDUMP_AFTER_CONT |
- MO_SREC_ACK | MO_SREC_ACK_PLUS ;
- est_cmds.init = est_inits; /* Init strings */
- est_cmds.cont = "go\r"; /* continue command */
- est_cmds.step = "sidr\r"; /* single step */
- est_cmds.stop = "\003"; /* ^C interrupts the program */
- est_cmds.set_break = "sb %x\r"; /* set a breakpoint */
- est_cmds.clr_break = "rb %x\r"; /* clear a breakpoint */
- est_cmds.clr_all_break = "rb\r"; /* clear all breakpoints */
- est_cmds.fill = "bfb %x %x %x\r"; /* fill (start end val) */
- est_cmds.setmem.cmdb = "smb %x %x\r"; /* setmem.cmdb (addr, value) */
- est_cmds.setmem.cmdw = "smw %x %x\r"; /* setmem.cmdw (addr, value) */
- est_cmds.setmem.cmdl = "sml %x %x\r"; /* setmem.cmdl (addr, value) */
- est_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
- est_cmds.setmem.resp_delim = NULL; /* setreg.resp_delim */
- est_cmds.setmem.term = NULL; /* setreg.term */
- est_cmds.setmem.term_cmd = NULL; /* setreg.term_cmd */
- est_cmds.getmem.cmdb = "dmb %x %x\r"; /* getmem.cmdb (addr, len) */
- est_cmds.getmem.cmdw = "dmw %x %x\r"; /* getmem.cmdw (addr, len) */
- est_cmds.getmem.cmdl = "dml %x %x\r"; /* getmem.cmdl (addr, len) */
- est_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */
- est_cmds.getmem.resp_delim = ": "; /* getmem.resp_delim */
- est_cmds.getmem.term = NULL; /* getmem.term */
- est_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */
- est_cmds.setreg.cmd = "sr %s %x\r"; /* setreg.cmd (name, value) */
- est_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */
- est_cmds.setreg.term = NULL; /* setreg.term */
- est_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
- est_cmds.getreg.cmd = "dr %s\r"; /* getreg.cmd (name) */
- est_cmds.getreg.resp_delim = " = "; /* getreg.resp_delim */
- est_cmds.getreg.term = NULL; /* getreg.term */
- est_cmds.getreg.term_cmd = NULL ; /* getreg.term_cmd */
- est_cmds.dump_registers = "dr\r"; /* dump_registers */
- est_cmds.register_pattern = "\\(\\w+\\) = \\([0-9a-fA-F]+\\)"; /* register_pattern */
- est_cmds.supply_register = est_supply_register; /* supply_register */
- est_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
- est_cmds.load = "dl\r"; /* download command */
- est_cmds.loadresp = "+"; /* load response */
- est_cmds.prompt = ">BKM>"; /* monitor command prompt */
- est_cmds.line_term = "\r"; /* end-of-line terminator */
- est_cmds.cmd_end = NULL; /* optional command terminator */
- est_cmds.target = &est_ops; /* target operations */
- est_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */
- est_cmds.regnames = est_regnames; /* registers names */
- est_cmds.magic = MONITOR_OPS_MAGIC ; /* magic */
-} /* init_est_cmds */
-
-static void
-est_open(args, from_tty)
- char *args;
- int from_tty;
-{
- monitor_open (args, &est_cmds, from_tty);
-}
-
-void
-_initialize_est ()
-{
- init_est_cmds() ;
- init_monitor_ops (&est_ops);
-
- est_ops.to_shortname = "est";
- est_ops.to_longname = "EST background debug monitor";
- est_ops.to_doc = "Debug via the EST BDM.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
- est_ops.to_open = est_open;
-
- add_target (&est_ops);
-}
diff --git a/contrib/gdb/gdb/remote-hms.c b/contrib/gdb/gdb/remote-hms.c
deleted file mode 100644
index 3ca8455..0000000
--- a/contrib/gdb/gdb/remote-hms.c
+++ /dev/null
@@ -1,1500 +0,0 @@
-/* Remote debugging interface for Hitachi HMS Monitor Version 1.0
- Copyright 1995 Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Steve Chamberlain
- (sac@cygnus.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "monitor.h"
-#include "serial.h"
-
-static void hms_open PARAMS ((char *args, int from_tty));
-static void
-hms_supply_register (regname, regnamelen, val, vallen)
- char *regname;
- int regnamelen;
- char *val;
- int vallen;
-{
- int regno;
-
- if (regnamelen != 2)
- return;
- if (regname[0] != 'P')
- return;
- /* We scan off all the registers in one go */
-
- val = monitor_supply_register (PC_REGNUM, val);
- /* Skip the ccr string */
- while (*val != '=' && *val)
- val++;
-
- val = monitor_supply_register (CCR_REGNUM, val + 1);
-
- /* Skip up to rest of regs */
- while (*val != '=' && *val)
- val++;
-
- for (regno = 0; regno < 7; regno++)
- {
- val = monitor_supply_register (regno, val + 1);
- }
-}
-
-/*
- * This array of registers needs to match the indexes used by GDB. The
- * whole reason this exists is because the various ROM monitors use
- * different names than GDB does, and don't support all the
- * registers either. So, typing "info reg sp" becomes a "r30".
- */
-
-static char *hms_regnames[NUM_REGS] =
-{
- "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "CCR", "PC"
-};
-
-/*
- * Define the monitor command strings. Since these are passed directly
- * through to a printf style function, we need can include formatting
- * strings. We also need a CR or LF on the end.
- */
-
-static struct target_ops hms_ops;
-
-static char *hms_inits[] =
-{"\003", /* Resets the prompt, and clears repeated cmds */
- NULL};
-
-static struct monitor_ops hms_cmds ;
-
-static void
-init_hms_cmds(void)
-{
- hms_cmds.flags = MO_CLR_BREAK_USES_ADDR | MO_FILL_USES_ADDR | MO_GETMEM_NEEDS_RANGE;
- hms_cmds.init = hms_inits; /* Init strings */
- hms_cmds.cont = "g\r"; /* continue command */
- hms_cmds.step = "s\r"; /* single step */
- hms_cmds.stop = "\003"; /* ^C interrupts the program */
- hms_cmds.set_break = "b %x\r"; /* set a breakpoint */
- hms_cmds.clr_break = "b - %x\r"; /* clear a breakpoint */
- hms_cmds.clr_all_break = "b -\r"; /* clear all breakpoints */
- hms_cmds.fill = "f %x %x %x\r"; /* fill (start end val) */
- hms_cmds.setmem.cmdb = "m.b %x=%x\r"; /* setmem.cmdb (addr, value) */
- hms_cmds.setmem.cmdw = "m.w %x=%x\r"; /* setmem.cmdw (addr, value) */
- hms_cmds.setmem.cmdl = NULL; /* setmem.cmdl (addr, value) */
- hms_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */
- hms_cmds.setmem.resp_delim = NULL;/* setreg.resp_delim */
- hms_cmds.setmem.term = NULL; /* setreg.term */
- hms_cmds.setmem.term_cmd = NULL; /* setreg.term_cmd */
- hms_cmds.getmem.cmdb = "m.b %x %x\r"; /* getmem.cmdb (addr, addr) */
- hms_cmds.getmem.cmdw = "m.w %x %x\r"; /* getmem.cmdw (addr, addr) */
- hms_cmds.getmem.cmdl = NULL; /* getmem.cmdl (addr, addr) */
- hms_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, addr) */
- hms_cmds.getmem.resp_delim = ": ";/* getmem.resp_delim */
- hms_cmds.getmem.term = ">"; /* getmem.term */
- hms_cmds.getmem.term_cmd = "\003";/* getmem.term_cmd */
- hms_cmds.setreg.cmd = "r %s=%x\r";/* setreg.cmd (name, value) */
- hms_cmds.setreg.resp_delim = NULL;/* setreg.resp_delim */
- hms_cmds.setreg.term = NULL; /* setreg.term */
- hms_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */
- hms_cmds.getreg.cmd = "r %s\r"; /* getreg.cmd (name) */
- hms_cmds.getreg.resp_delim = " (";/* getreg.resp_delim */
- hms_cmds.getreg.term = ":"; /* getreg.term */
- hms_cmds.getreg.term_cmd = "\003";/* getreg.term_cmd */
- hms_cmds.dump_registers = "r\r"; /* dump_registers */
- hms_cmds.register_pattern = "\\(\\w+\\)=\\([0-9a-fA-F]+\\)"; /* register_pattern */
- hms_cmds.supply_register = hms_supply_register; /* supply_register */
- hms_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */
- hms_cmds.load = "tl\r"; /* download command */
- hms_cmds.loadresp = NULL; /* load response */
- hms_cmds.prompt = ">"; /* monitor command prompt */
- hms_cmds.line_term = "\r"; /* end-of-command delimitor */
- hms_cmds.cmd_end = NULL; /* optional command terminator */
- hms_cmds.target = &hms_ops; /* target operations */
- hms_cmds.stopbits = SERIAL_1_STOPBITS;/* number of stop bits */
- hms_cmds.regnames = hms_regnames; /* registers names */
- hms_cmds.magic = MONITOR_OPS_MAGIC; /* magic */
-} /* init_hms-cmds */
-
-static void
-hms_open (args, from_tty)
- char *args;
- int from_tty;
-{
- monitor_open (args, &hms_cmds, from_tty);
-}
-
-int write_dos_tick_delay;
-
-void
-_initialize_remote_hms ()
-{
- init_hms_cmds() ;
- init_monitor_ops (&hms_ops);
-
- hms_ops.to_shortname = "hms";
- hms_ops.to_longname = "Hitachi Microsystems H8/300 debug monitor";
- hms_ops.to_doc = "Debug via the HMS monitor.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
- hms_ops.to_open = hms_open;
- /* By trial and error I've found that this delay doesn't break things */
- write_dos_tick_delay = 1;
- add_target (&hms_ops);
-}
-
-#if 0
-/* This is kept here because we used to support the H8/500 in this module,
- and I haven't done the H8/500 yet */
-#include "defs.h"
-#include "inferior.h"
-#include "wait.h"
-#include "value.h"
-#include "gdb_string.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <errno.h>
-#include "terminal.h"
-#include "target.h"
-#include "gdbcore.h"
-#include "serial.h"
-#include "remote-utils.h"
-/* External data declarations */
-extern int stop_soon_quietly; /* for wait_for_inferior */
-
-/* Forward data declarations */
-extern struct target_ops hms_ops; /* Forward declaration */
-
-/* Forward function declarations */
-static void hms_fetch_registers ();
-static int hms_store_registers ();
-static void hms_close ();
-static int hms_clear_breakpoints ();
-
-extern struct target_ops hms_ops;
-static void hms_drain ();
-static void add_commands ();
-static void remove_commands ();
-
-static int quiet = 1; /* FIXME - can be removed after Dec '94 */
-
-
-
-/***********************************************************************
- * I/O stuff stolen from remote-eb.c
- ***********************************************************************/
-
-static int timeout = 2;
-
-static const char *dev_name;
-
-/* Descriptor for I/O to remote machine. Initialize it to -1 so that
- hms_open knows that we don't have a file open when the program
- starts. */
-
-static int before = 0xdead;
-static int is_open = 0;
-static int after = 0xdead;
-int
-check_open ()
-{
- if (before != 0xdead
- || after != 0xdead)
- printf ("OUTCH! \n");
- if (!is_open)
- {
- error ("remote device not open");
- }
-}
-
-#define ON 1
-#define OFF 0
-
-/* Read a character from the remote system, doing all the fancy
- timeout stuff. */
-static int
-readchar ()
-{
- int buf;
-
- buf = SERIAL_READCHAR (desc, timeout);
-
- if (buf == SERIAL_TIMEOUT)
- {
- hms_write (".\r\n", 3);
- error ("Timeout reading from remote system.");
- }
- if (buf == SERIAL_ERROR)
- {
- error ("Serial port error!");
- }
-
- if (!quiet || remote_debug)
- printf_unfiltered ("%c", buf);
-
- return buf & 0x7f;
-}
-
-static void
-flush ()
-{
- while (1)
- {
- int b = SERIAL_READCHAR (desc, 0);
- if (b == SERIAL_TIMEOUT)
- return;
- }
-}
-
-static int
-readchar_nofail ()
-{
- int buf;
-
- buf = SERIAL_READCHAR (desc, timeout);
- if (buf == SERIAL_TIMEOUT)
- buf = 0;
- if (!quiet || remote_debug)
- printf_unfiltered ("%c", buf);
-
- 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;
- char c;
- immediate_quit = 1;
- while (1)
- {
- c = readchar ();
- if (c == *p)
- {
- p++;
- if (*p == '\0')
- {
- immediate_quit = 0;
- return;
- }
- }
- else
- {
- p = string;
- if (c == *p)
- p++;
- }
- }
-}
-
-/* Keep discarding input until we see the hms 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: hms_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 hms_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 ()
-{
- expect ("HMS>");
-}
-
-/* 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 hms_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 hms, 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;
-}
-
-/* Called when SIGALRM signal sent due to alarm() timeout. */
-
-/* Number of SIGTRAPs we need to simulate. That is, the next
- NEED_ARTIFICIAL_TRAP calls to hms_wait should just return
- SIGTRAP without actually waiting for anything. */
-
-static int need_artificial_trap = 0;
-
-void
-hms_kill (arg, from_tty)
- char *arg;
- int from_tty;
-{
-
-}
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-void
-hms_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- int entry_pt;
- char buffer[100];
-
- if (args && *args)
- error ("Can't pass arguments to remote hms process.");
-
- if (execfile == 0 || exec_bfd == 0)
- error ("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
- check_open ();
-
- hms_kill (NULL, NULL);
- hms_clear_breakpoints ();
- init_wait_for_inferior ();
- hms_write_cr ("");
- expect_prompt ();
-
- insert_breakpoints (); /* Needed to get correct instruction in cache */
- proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-/* Open a connection to a remote debugger.
- NAME is the filename used for communication, then a space,
- then the baud rate.
- */
-
-static char *
-find_end_of_word (s)
- char *s;
-{
- while (*s && !isspace (*s))
- s++;
- return s;
-}
-
-static char *
-get_word (p)
- char **p;
-{
- char *s = *p;
- char *word;
- char *copy;
- size_t len;
-
- while (isspace (*s))
- s++;
-
- word = s;
-
- len = 0;
-
- while (*s && !isspace (*s))
- {
- s++;
- len++;
-
- }
- copy = xmalloc (len + 1);
- memcpy (copy, word, len);
- copy[len] = 0;
- *p = s;
- return copy;
-}
-
-static int baudrate = 9600;
-
-static int
-is_baudrate_right ()
-{
- int ok;
-
- /* Put this port into NORMAL mode, send the 'normal' character */
-
- hms_write ("\001", 1); /* Control A */
- hms_write ("\r\n", 2); /* Cr */
-
- while (1)
- {
- ok = SERIAL_READCHAR (desc, timeout);
- if (ok < 0)
- break;
- }
-
- hms_write ("r", 1);
-
- if (readchar_nofail () == 'r')
- return 1;
-
- /* Not the right baudrate, or the board's not on */
- return 0;
-}
-static void
-set_rate ()
-{
- if (!SERIAL_SETBAUDRATE (desc, baudrate))
- error ("Can't set baudrate");
-}
-
-
-
-/* Close out all files and local state before this target loses control. */
-
-static void
-hms_close (quitting)
- int quitting;
-{
- /* Clear any break points */
- remove_commands ();
- hms_clear_breakpoints ();
- sleep (1); /* Let any output make it all the way back */
- if (is_open)
- {
- SERIAL_WRITE (desc, "R\r\n", 3);
- SERIAL_CLOSE (desc);
- }
- is_open = 0;
-}
-
-/* Terminate the open connection to the remote debugger. Use this
- when you want to detach and do something else with your gdb. */ void
-hms_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- if (is_open)
- {
- hms_clear_breakpoints ();
- }
-
- pop_target (); /* calls hms_close to do the real work
- */
- if (from_tty)
- printf_filtered ("Ending remote %s debugging\n",
- target_shortname);
-}
-
-/* Tell the remote machine to resume. */
-
-void
-hms_resume (pid, step, sig)
- int pid, step;
- enum target_signal
- sig;
-{
- if (step)
- {
- hms_write_cr ("s");
- expect ("Step>");
-
- /* Force the next hms_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
- {
- hms_write_cr ("g");
- expect ("g");
- }
-}
-
-/* Wait until the remote machine stops, then return, storing status in
- STATUS just as `wait' would. */
-
-int
-hms_wait (pid, status)
- int pid;
- struct target_waitstatus *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[] = "At breakpoint:";
-
- /* 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[] = "HMS>";
- 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;
- int swallowed_cr = 0;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- if (need_artificial_trap != 0)
- {
- status->kind =
- TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- need_artificial_trap--;
- return 0;
- }
-
- timeout = 5; /* Don't time out for a while - 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)
- putchar_unfiltered (*p);
- swallowed_p = swallowed;
-
- if ((ch != '\r' && ch != '\n') || swallowed_cr > 10)
- {
- putchar_unfiltered (ch);
- swallowed_cr = 10;
- }
- swallowed_cr++;
-
- }
- }
- if (*bp == '\0')
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- expect_prompt ();
- }
- else
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer =
- TARGET_SIGNAL_STOP;
- }
-
- timeout = old_timeout;
- immediate_quit = old_immediate_quit;
- return
- 0;
-}
-
-/* Return the name of register number REGNO in the form input and
- output by hms.
-
- Returns a pointer to a static buffer containing the answer. */
-static char *
-get_reg_name (regno)
- int regno;
-{
- static char *rn[] =
- REGISTER_NAMES;
-
- return rn[regno];
-}
-
-/* Read the remote registers. */
-
-static int
-gethex (length, start, ok)
- unsigned int length;
- char *start;
- int *ok;
-{
- int result = 0;
-
- while (length--)
- {
- result <<= 4;
- if (*start >= 'a' && *start <= 'f')
- {
- result += *start - 'a' + 10;
- }
- else if (*start >= 'A' &&
- *start <= 'F')
- {
- result += *start - 'A' + 10;
- }
- else if
- (*start >= '0' && *start <= '9')
- {
- result += *start - '0';
- }
- else
- *ok = 0;
- start++;
-
- }
- return result;
-}
-static int
-timed_read (buf, n, timeout)
- char
- *buf;
-
-{
- int i;
- char c;
-
- i = 0;
- while (i < n)
- {
- c = readchar ();
-
- if (c == 0)
- return i;
- buf[i] = c;
- i++;
-
- }
- return i;
-}
-
-hms_write (a, l)
- char *a;
-{
- int i;
-
- SERIAL_WRITE (desc, a, l);
-
- if (!quiet || remote_debug)
- {
- printf_unfiltered ("<");
- for (i = 0; i < l; i++)
- {
- printf_unfiltered ("%c", a[i]);
- }
- printf_unfiltered (">");
- }
-}
-
-hms_write_cr (s)
- char *s;
-{
- hms_write (s, strlen (s));
- hms_write ("\r\n", 2);
-}
-
-#ifdef GDB_TARGET_IS_H8500
-
-/* H8/500 monitor reg dump looks like:
-
- HMS>r
- PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00
- R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE
- HMS>
-
-
- */
-
-supply_val (n, size, ptr, segptr)
- int n;
- int size;
- char *ptr;
- char *segptr;
-{
- int ok;
- char raw[4];
- switch (size)
- {
- case 2:
- raw[0] = gethex (2, ptr, &ok);
- raw[1] = gethex (2, ptr + 2, &ok);
- supply_register (n, raw);
- break;
- case 1:
- raw[0] = gethex (2, ptr, &ok);
- supply_register (n, raw);
- break;
- case 4:
- {
- int v = gethex (4, ptr, &ok);
- v |= gethex (2, segptr, &ok) << 16;
- raw[0] = 0;
- raw[1] = (v >> 16) & 0xff;
- raw[2] = (v >> 8) & 0xff;
- raw[3] = (v >> 0) & 0xff;
- supply_register (n, raw);
- }
- }
-
-}
-static void
-hms_fetch_register (dummy)
- int dummy;
-{
-#define REGREPLY_SIZE 108
- char linebuf[REGREPLY_SIZE + 1];
- int i;
- int s;
- int gottok;
-
- LONGEST reg[NUM_REGS];
- check_open ();
-
- do
- {
-
- hms_write_cr ("r");
- expect ("r");
- s = timed_read (linebuf + 1, REGREPLY_SIZE, 1);
-
- linebuf[REGREPLY_SIZE] = 0;
- gottok = 0;
- if (linebuf[3] == 'P' &&
- linebuf[4] == 'C' &&
- linebuf[5] == ':' &&
- linebuf[105] == 'H' &&
- linebuf[106] == 'M' &&
- linebuf[107] == 'S')
- {
-
- /*
- 012
- r**
- -------1---------2---------3---------4---------5-----
- 345678901234567890123456789012345678901234567890123456
- PC:8000 SR:070C .7NZ.. CP:00 DP:00 EP:00 TP:00 BR:00**
- ---6---------7---------8---------9--------10----
- 789012345678901234567890123456789012345678901234
- R0-R7: FF5A 0001 F4FE F500 0000 F528 F528 F4EE**
-
- 56789
- HMS>
- */
- gottok = 1;
-
-
- supply_val (PC_REGNUM, 4, linebuf + 6, linebuf + 29);
-
- supply_val (CCR_REGNUM, 2, linebuf + 14);
- supply_val (SEG_C_REGNUM, 1, linebuf + 29);
- supply_val (SEG_D_REGNUM, 1, linebuf + 35);
- supply_val (SEG_E_REGNUM, 1, linebuf + 41);
- supply_val (SEG_T_REGNUM, 1, linebuf + 47);
- for (i = 0; i < 8; i++)
- {
- static int sr[8] =
- {35, 35, 35, 35,
- 41, 41, 47, 47};
-
- char raw[4];
- char *src = linebuf + 64 + 5 * i;
- char *segsrc = linebuf + sr[i];
- supply_val (R0_REGNUM + i, 2, src);
- supply_val (PR0_REGNUM + i, 4, src, segsrc);
- }
- }
- if (!gottok)
- {
- hms_write_cr ("");
- expect ("HMS>");
- }
- }
- while (!gottok);
-}
-#endif
-
-#ifdef GDB_TARGET_IS_H8300
-static void
-hms_fetch_register (dummy)
- int dummy;
-{
-#define REGREPLY_SIZE 79
- char linebuf[REGREPLY_SIZE + 1];
- int i;
- int s;
- int gottok;
-
- ULONGEST reg[NUM_REGS];
-
- check_open ();
-
- do
- {
- hms_write_cr ("r");
-
- s = timed_read (linebuf, 1, 1);
-
- while (linebuf[0] != 'r')
- s = timed_read (linebuf, 1, 1);
-
- s = timed_read (linebuf + 1, REGREPLY_SIZE - 1, 1);
-
- linebuf[REGREPLY_SIZE] = 0;
- gottok = 0;
- if (linebuf[0] == 'r' &&
- linebuf[3] == 'P' &&
- linebuf[4] == 'C' &&
- linebuf[5] == '=' &&
- linebuf[75] == 'H' &&
- linebuf[76] == 'M' &&
- linebuf[77] == 'S')
- {
- /*
- PC=XXXX CCR=XX:XXXXXXXX R0-R7= XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
- 5436789012345678901234567890123456789012345678901234567890123456789012
- 0 1 2 3 4 5 6
- */
- gottok = 1;
-
- reg[PC_REGNUM] = gethex (4, linebuf + 6, &gottok);
- reg[CCR_REGNUM] = gethex (2, linebuf + 15, &gottok);
- for (i = 0; i < 8; i++)
- {
- reg[i] = gethex (4, linebuf + 34 + 5 * i, &gottok);
- }
- }
- }
- while (!gottok);
- for (i = 0; i < NUM_REGS; i++)
- {
- char swapped[2];
-
- swapped[1] = reg[i];
- swapped[0] = (reg[i]) >> 8;
-
- supply_register (i, swapped);
- }
-}
-#endif
-/* Store register REGNO, or all if REGNO == -1.
- Return errno value. */
-static void
-hms_store_register (regno)
- int regno;
-{
- if (regno == -1)
- {
- for (regno = 0; regno < NUM_REGS; regno++)
- {
- hms_store_register (regno);
- }
- }
- else
- {
- char *name = get_reg_name (regno);
- char buffer[100];
- /* Some regs dont really exist */
- if (!(name[0] == 'p' && name[1] == 'r')
- && !(name[0] == 'c' && name[1] == 'y')
- && !(name[0] == 't' && name[1] == 'i')
- && !(name[0] == 'i' && name[1] == 'n'))
- {
- sprintf (buffer, "r %s=%x", name, read_register (regno));
- hms_write_cr (buffer);
- expect_prompt ();
- }
- }
-}
-
-
-/* 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
-hms_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static CORE_ADDR
-translate_addr (addr)
- CORE_ADDR addr;
-{
-
- return (addr);
-
-}
-
-
-int
-hms_xfer_inferior_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* ignored */
-{
-
- return len;
-}
-
-int
-hms_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- bfd_vma addr;
- int done;
- int todo;
- char buffer[100];
- done = 0;
- hms_write_cr (".");
- expect_prompt ();
- while (done < len)
- {
- char *ptr = buffer;
- int thisgo;
- int idx;
-
- thisgo = len - done;
- if (thisgo > 20)
- thisgo = 20;
-
- sprintf (ptr, "M.B %4x =", memaddr + done);
- ptr += 10;
- for (idx = 0; idx < thisgo; idx++)
- {
- sprintf (ptr, "%2x ", myaddr[idx + done]);
- ptr += 3;
- }
- hms_write_cr (buffer);
- expect_prompt ();
- done += thisgo;
- }
-}
-
-void
-hms_files_info ()
-{
- char *file = "nothing";
-
- if (exec_bfd)
- file = bfd_get_filename (exec_bfd);
-
- if (exec_bfd)
-#ifdef __GO32__
- printf_filtered ("\tAttached to DOS asynctsr and running program %s\n", file);
-#else
- printf_filtered ("\tAttached to %s at %d baud and running program %s\n", dev_name, baudrate, file);
-#endif
- printf_filtered ("\ton an H8/300 processor.\n");
-}
-
-/* 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.
- */
-
-/* Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns errno value. */
-int
-hms_read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- /* Align to nearest low 16 bits */
- int i;
-
- CORE_ADDR start = memaddr;
- CORE_ADDR end = memaddr + len - 1;
-
- int ok = 1;
-
- /*
- AAAA: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX '................'
- 012345678901234567890123456789012345678901234567890123456789012345
- 0 1 2 3 4 5 6
- */
- char buffer[66];
-
- if (memaddr & 0xf)
- abort ();
- if (len != 16)
- abort ();
-
- sprintf (buffer, "m %4x %4x", start & 0xffff, end & 0xffff);
-
- flush ();
- hms_write_cr (buffer);
- /* drop the echo and newline */
- for (i = 0; i < 13; i++)
- readchar ();
-
- /* Grab the lines as they come out and fill the area */
- /* Skip over cr */
- while (1)
- {
- int p;
- int i;
- int addr;
- size_t idx;
-
- char byte[16];
-
- buffer[0] = readchar ();
- while (buffer[0] == '\r'
- || buffer[0] == '\n')
- buffer[0] = readchar ();
-
- if (buffer[0] == 'M')
- break;
-
- for (i = 1; i < 50; i++)
- {
- buffer[i] = readchar ();
- }
- /* sometimes we loose characters in the ascii representation of the
- data. I don't know where. So just scan for the end of line */
- i = readchar ();
- while (i != '\n' && i != '\r')
- i = readchar ();
-
- /* Now parse the line */
-
- addr = gethex (4, buffer, &ok);
- idx = 6;
- for (p = 0; p < 16; p += 2)
- {
- byte[p] = gethex (2, buffer + idx, &ok);
- byte[p + 1] = gethex (2, buffer + idx + 2, &ok);
- idx += 5;
- }
-
- for (p = 0; p < 16; p++)
- {
- if (addr + p >= memaddr &&
- addr + p < memaddr + len)
- {
- myaddr[(addr + p) - memaddr] = byte[p];
-
- }
-
- }
- }
-#ifdef GDB_TARGET_IS_H8500
- expect ("ore>");
-#endif
-#ifdef GDB_TARGET_IS_H8300
- expect ("emory>");
-#endif
- hms_write_cr (".");
-
- expect_prompt ();
- return len;
-}
-
-
-
-#define MAX_BREAKS 16
-static int num_brkpts = 0;
-static int
-hms_insert_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save; /* Throw away, let hms save instructions */
-{
- check_open ();
-
- if (num_brkpts < MAX_BREAKS)
- {
- char buffer[100];
-
- num_brkpts++;
- sprintf (buffer, "b %x", addr & 0xffff);
- hms_write_cr (buffer);
- expect_prompt ();
- return (0);
- }
- else
- {
- fprintf_filtered (gdb_stderr,
- "Too many break points, break point not installed\n");
- return (1);
- }
-
-}
-static int
-hms_remove_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save; /* Throw away, let hms save instructions */
-{
- if (num_brkpts > 0)
- {
- char buffer[100];
-
- num_brkpts--;
- sprintf (buffer, "b - %x", addr & 0xffff);
- hms_write_cr (buffer);
- expect_prompt ();
-
- }
- return (0);
-}
-
-/* Clear the hmss notion of what the break points are */
-static int
-hms_clear_breakpoints ()
-{
-
- if (is_open)
- {
- hms_write_cr ("b -");
- expect_prompt ();
- }
- num_brkpts = 0;
-}
-static void
-hms_mourn ()
-{
- hms_clear_breakpoints ();
- unpush_target (&hms_ops);
- generic_mourn_inferior ();
-}
-
-/* Put a command string, in args, out to the hms. The hms is assumed to
- be in raw mode, all writing/reading done through desc.
- Ouput from the hms is placed on the users terminal until the
- prompt from the hms is seen.
- FIXME: Can't handle commands that take input. */
-
-void
-hms_com (args, fromtty)
- char *args;
- int fromtty;
-{
- check_open ();
-
- if (!args)
- return;
-
- /* Clear all input so only command relative output is displayed */
-
- hms_write_cr (args);
-/* hms_write ("\030", 1); */
- expect_prompt ();
-}
-
-static void
-hms_open (name, from_tty)
- char *name;
- int from_tty;
-{
- unsigned int prl;
- char *p;
-
- if (name == 0)
- {
- name = "";
- }
- if (is_open)
- hms_close (0);
- dev_name = strdup (name);
-
- if (!(desc = SERIAL_OPEN (dev_name)))
- perror_with_name ((char *) dev_name);
-
- SERIAL_RAW (desc);
- is_open = 1;
- push_target (&hms_ops);
- dcache_ptr = dcache_init (hms_read_inferior_memory,
- hms_write_inferior_memory);
- remote_dcache = 1;
- /* Hello? Are you there? */
- SERIAL_WRITE (desc, "\r\n", 2);
- expect_prompt ();
-
- /* Clear any break points */
- hms_clear_breakpoints ();
-
- printf_filtered ("Connected to remote board running HMS monitor.\n");
- add_commands ();
-/* hms_drain (); */
-}
-
-/* Define the target subroutine names */
-
-struct target_ops hms_ops ;
-
-static void
-init_hms_ops(void)
-{
- hms_ops.to_shortname = "hms";
- hms_ops.to_longname = "Remote HMS monitor";
- hms_ops.to_doc = "Use the H8 evaluation board running the HMS monitor connected\n\
-by a serial line.";
- hms_ops.to_open = hms_open;
- hms_ops.to_close = hms_close;
- hms_ops.to_attach = 0;
- hms_ops.to_post_attach = NULL;
- hms_ops.to_require_attach = NULL;
- hms_ops.to_detach = hms_detach;
- hms_ops.to_require_detach = NULL;
- hms_ops.to_resume = hms_resume;
- hms_ops.to_wait = hms_wait;
- hms_ops.to_post_wait = NULL;
- hms_ops.to_fetch_registers = hms_fetch_register;
- hms_ops.to_store_registers = hms_store_register;
- hms_ops.to_prepare_to_store = hms_prepare_to_store;
- hms_ops.to_xfer_memory = hms_xfer_inferior_memory;
- hms_ops.to_files_info = hms_files_info;
- hms_ops.to_insert_breakpoint = hms_insert_breakpoint;
- hms_ops.to_remove_breakpoint = hms_remove_breakpoint;
- hms_ops.to_terminal_init = 0;
- hms_ops.to_terminal_inferior = 0;
- hms_ops.to_terminal_ours_for_output = 0;
- hms_ops.to_terminal_ours = 0;
- hms_ops.to_terminal_info = 0;
- hms_ops.to_kill = hms_kill;
- hms_ops.to_load = generic_load;
- hms_ops.to_lookup_symbol = 0;
- hms_ops.to_create_inferior = hms_create_inferior;
- hms_ops.to_post_startup_inferior = NULL;
- hms_ops.to_acknowledge_created_inferior = NULL;
- hms_ops.to_clone_and_follow_inferior = NULL;
- hms_ops.to_post_follow_inferior_by_clone = NULL;
- hms_ops.to_insert_fork_catchpoint = NULL;
- hms_ops.to_remove_fork_catchpoint = NULL;
- hms_ops.to_insert_vfork_catchpoint = NULL;
- hms_ops.to_remove_vfork_catchpoint = NULL;
- hms_ops.to_has_forked = NULL;
- hms_ops.to_has_vforked = NULL;
- hms_ops.to_can_follow_vfork_prior_to_exec = NULL;
- hms_ops.to_post_follow_vfork = NULL;
- hms_ops.to_insert_exec_catchpoint = NULL;
- hms_ops.to_remove_exec_catchpoint = NULL;
- hms_ops.to_has_execd = NULL;
- hms_ops.to_reported_exec_events_per_exec_call = NULL;
- hms_ops.to_has_exited = NULL;
- hms_ops.to_mourn_inferior = hms_mourn;
- hms_ops.to_can_run = 0;
- hms_ops.to_notice_signals = 0;
- hms_ops.to_thread_alive = 0;
- hms_ops.to_stop = 0;
- hms_ops.to_pid_to_exec_file = NULL;
- hms_ops.to_core_file_to_sym_file = NULL;
- hms_ops.to_stratum = process_stratum;
- hms_ops.DONT_USE = 0;
- hms_ops.to_has_all_memory = 1;
- hms_ops.to_has_memory = 1;
- hms_ops.to_has_stack = 1;
- hms_ops.to_has_registers = 1;
- hms_ops.to_has_execution = 1;
- hms_ops.to_sections = 0;
- hms_ops.to_sections_end = 0;
- hms_ops.to_magic = OPS_MAGIC;
-};
-
-hms_quiet () /* FIXME - this routine can be removed after Dec '94 */
-{
- quiet = !quiet;
- if (quiet)
- printf_filtered ("Snoop disabled\n");
- else
- printf_filtered ("Snoop enabled\n");
-
- printf_filtered ("`snoop' is obsolete, please use `set remotedebug'.\n");
-}
-
-hms_device (s)
- char *s;
-{
- if (s)
- {
- dev_name = get_word (&s);
- }
-}
-
-static
-hms_speed (s)
- char *s;
-{
- check_open ();
-
- if (s)
- {
- char buffer[100];
- int newrate = atoi (s);
- int which = 0;
-
- if (SERIAL_SETBAUDRATE (desc, newrate))
- error ("Can't use %d baud\n", newrate);
-
- printf_filtered ("Checking target is in sync\n");
-
- printf_filtered ("Sending commands to set target to %d\n",
- baudrate);
-
- sprintf (buffer, "tm %d. N 8 1", baudrate);
- hms_write_cr (buffer);
- }
-}
-
-/***********************************************************************/
-
-static void
-hms_drain (args, fromtty)
- char *args;
- int fromtty;
-{
- int c;
- while (1)
- {
- c = SERIAL_READCHAR (desc, 1);
- if (c == SERIAL_TIMEOUT)
- break;
- if (c == SERIAL_ERROR)
- break;
- if (c > ' ' && c < 127)
- printf ("%c", c & 0xff);
- else
- printf ("<%x>", c & 0xff);
- }
-}
-
-static void
-add_commands ()
-{
-
- add_com ("hms_drain", class_obscure, hms_drain,
- "Drain pending hms text buffers.");
-}
-
-static void
-remove_commands ()
-{
- extern struct cmd_list_element *cmdlist;
- delete_cmd ("hms-drain", &cmdlist);
-}
-
-
-void
-_initialize_remote_hms ()
-{
- init_hms_ops() ;
- add_target (&hms_ops);
-
- add_com ("hms <command>", class_obscure, hms_com,
- "Send a command to the HMS monitor.");
-
- /* FIXME - hms_quiet and `snoop' can be removed after Dec '94 */
- add_com ("snoop", class_obscure, hms_quiet,
- "Show what commands are going to the monitor (OBSOLETE - see 'set remotedebug')");
-
- add_com ("device", class_obscure, hms_device,
- "Set the terminal line for HMS communications");
-
- add_com ("speed", class_obscure, hms_speed,
- "Set the terminal line speed for HMS communications");
-
- dev_name = NULL;
-}
-#endif
-
diff --git a/contrib/gdb/gdb/remote-mips.c b/contrib/gdb/gdb/remote-mips.c
deleted file mode 100644
index c92f8b7..0000000
--- a/contrib/gdb/gdb/remote-mips.c
+++ /dev/null
@@ -1,3655 +0,0 @@
-/* Remote debugging interface for MIPS remote debugging protocol.
- Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Ian Lance Taylor
- <ian@cygnus.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "bfd.h"
-#include "symfile.h"
-#include "wait.h"
-#include "gdbcmd.h"
-#include "gdbcore.h"
-#include "serial.h"
-#include "target.h"
-#include "remote-utils.h"
-#include "gdb_string.h"
-
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-/* Microsoft C's stat.h doesn't define all the POSIX file modes. */
-#ifndef S_IROTH
-#define S_IROTH S_IREAD
-#endif
-
-extern void mips_set_processor_type_command PARAMS ((char *, int));
-
-
-/* Breakpoint types. Values 0, 1, and 2 must agree with the watch
- types passed by breakpoint.c to target_insert_watchpoint.
- Value 3 is our own invention, and is used for ordinary instruction
- breakpoints. Value 4 is used to mark an unused watchpoint in tables. */
-enum break_type {
- BREAK_WRITE, /* 0 */
- BREAK_READ, /* 1 */
- BREAK_ACCESS, /* 2 */
- BREAK_FETCH, /* 3 */
- BREAK_UNUSED /* 4 */
-};
-
-/* Prototypes for local functions. */
-
-static int mips_readchar PARAMS ((int timeout));
-
-static int mips_receive_header PARAMS ((unsigned char *hdr, int *pgarbage,
- int ch, int timeout));
-
-static int mips_receive_trailer PARAMS ((unsigned char *trlr, int *pgarbage,
- int *pch, int timeout));
-
-static int mips_cksum PARAMS ((const unsigned char *hdr,
- const unsigned char *data,
- int len));
-
-static void mips_send_packet PARAMS ((const char *s, int get_ack));
-
-static void mips_send_command PARAMS ((const char *cmd, int prompt));
-
-static int mips_receive_packet PARAMS ((char *buff, int throw_error,
- int timeout));
-
-static CORE_ADDR mips_request PARAMS ((int cmd, CORE_ADDR addr,
- CORE_ADDR data, int *perr, int timeout,
- char *buff));
-
-static void mips_initialize PARAMS ((void));
-
-static void mips_open PARAMS ((char *name, int from_tty));
-
-static void pmon_open PARAMS ((char *name, int from_tty));
-
-static void ddb_open PARAMS ((char *name, int from_tty));
-
-static void lsi_open PARAMS ((char *name, int from_tty));
-
-static void mips_close PARAMS ((int quitting));
-
-static void mips_detach PARAMS ((char *args, int from_tty));
-
-static void mips_resume PARAMS ((int pid, int step,
- enum target_signal siggnal));
-
-static int mips_wait PARAMS ((int pid, struct target_waitstatus *status));
-
-static int mips_map_regno PARAMS ((int regno));
-
-static void mips_fetch_registers PARAMS ((int regno));
-
-static void mips_prepare_to_store PARAMS ((void));
-
-static void mips_store_registers PARAMS ((int regno));
-
-static unsigned int mips_fetch_word PARAMS ((CORE_ADDR addr));
-
-static int mips_store_word PARAMS ((CORE_ADDR addr, unsigned int value,
- char *old_contents));
-
-static int mips_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
- int write, struct target_ops *ignore));
-
-static void mips_files_info PARAMS ((struct target_ops *ignore));
-
-static void mips_create_inferior PARAMS ((char *execfile, char *args,
- char **env));
-
-static void mips_mourn_inferior PARAMS ((void));
-
-static int pmon_makeb64 PARAMS ((unsigned long v, char *p, int n, int *chksum));
-
-static int pmon_zeroset PARAMS ((int recsize, char **buff, int *amount,
- unsigned int *chksum));
-
-static int pmon_checkset PARAMS ((int recsize, char **buff, int *value));
-
-static void pmon_make_fastrec PARAMS ((char **outbuf, unsigned char *inbuf,
- int *inptr, int inamount, int *recsize,
- unsigned int *csum, unsigned int *zerofill));
-
-static int pmon_check_ack PARAMS ((char *mesg));
-
-static void pmon_start_download PARAMS ((void));
-
-static void pmon_end_download PARAMS ((int final, int bintotal));
-
-static void pmon_download PARAMS ((char *buffer, int length));
-
-static void pmon_load_fast PARAMS ((char *file));
-
-static void mips_load PARAMS ((char *file, int from_tty));
-
-static int mips_make_srec PARAMS ((char *buffer, int type, CORE_ADDR memaddr,
- unsigned char *myaddr, int len));
-
-static int set_breakpoint PARAMS ((CORE_ADDR addr, int len,
- enum break_type type));
-
-static int clear_breakpoint PARAMS ((CORE_ADDR addr, int len,
- enum break_type type));
-
-static int common_breakpoint PARAMS ((int set, CORE_ADDR addr, int len,
- enum break_type type));
-
-/* Forward declarations. */
-extern struct target_ops mips_ops;
-extern struct target_ops pmon_ops;
-extern struct target_ops ddb_ops;
-
-/* The MIPS remote debugging interface is built on top of a simple
- packet protocol. Each packet is organized as follows:
-
- SYN The first character is always a SYN (ASCII 026, or ^V). SYN
- may not appear anywhere else in the packet. Any time a SYN is
- seen, a new packet should be assumed to have begun.
-
- TYPE_LEN
- This byte contains the upper five bits of the logical length
- of the data section, plus a single bit indicating whether this
- is a data packet or an acknowledgement. The documentation
- indicates that this bit is 1 for a data packet, but the actual
- board uses 1 for an acknowledgement. The value of the byte is
- 0x40 + (ack ? 0x20 : 0) + (len >> 6)
- (we always have 0 <= len < 1024). Acknowledgement packets do
- not carry data, and must have a data length of 0.
-
- LEN1 This byte contains the lower six bits of the logical length of
- the data section. The value is
- 0x40 + (len & 0x3f)
-
- SEQ This byte contains the six bit sequence number of the packet.
- The value is
- 0x40 + seq
- An acknowlegment packet contains the sequence number of the
- packet being acknowledged plus 1 modulo 64. Data packets are
- transmitted in sequence. There may only be one outstanding
- unacknowledged data packet at a time. The sequence numbers
- are independent in each direction. If an acknowledgement for
- the previous packet is received (i.e., an acknowledgement with
- the sequence number of the packet just sent) the packet just
- sent should be retransmitted. If no acknowledgement is
- received within a timeout period, the packet should be
- retransmitted. This has an unfortunate failure condition on a
- high-latency line, as a delayed acknowledgement may lead to an
- endless series of duplicate packets.
-
- DATA The actual data bytes follow. The following characters are
- escaped inline with DLE (ASCII 020, or ^P):
- SYN (026) DLE S
- DLE (020) DLE D
- ^C (003) DLE C
- ^S (023) DLE s
- ^Q (021) DLE q
- The additional DLE characters are not counted in the logical
- length stored in the TYPE_LEN and LEN1 bytes.
-
- CSUM1
- CSUM2
- CSUM3
- These bytes contain an 18 bit checksum of the complete
- contents of the packet excluding the SEQ byte and the
- CSUM[123] bytes. The checksum is simply the twos complement
- addition of all the bytes treated as unsigned characters. The
- values of the checksum bytes are:
- CSUM1: 0x40 + ((cksum >> 12) & 0x3f)
- CSUM2: 0x40 + ((cksum >> 6) & 0x3f)
- CSUM3: 0x40 + (cksum & 0x3f)
-
- It happens that the MIPS remote debugging protocol always
- communicates with ASCII strings. Because of this, this
- implementation doesn't bother to handle the DLE quoting mechanism,
- since it will never be required. */
-
-/* The SYN character which starts each packet. */
-#define SYN '\026'
-
-/* The 0x40 used to offset each packet (this value ensures that all of
- the header and trailer bytes, other than SYN, are printable ASCII
- characters). */
-#define HDR_OFFSET 0x40
-
-/* The indices of the bytes in the packet header. */
-#define HDR_INDX_SYN 0
-#define HDR_INDX_TYPE_LEN 1
-#define HDR_INDX_LEN1 2
-#define HDR_INDX_SEQ 3
-#define HDR_LENGTH 4
-
-/* The data/ack bit in the TYPE_LEN header byte. */
-#define TYPE_LEN_DA_BIT 0x20
-#define TYPE_LEN_DATA 0
-#define TYPE_LEN_ACK TYPE_LEN_DA_BIT
-
-/* How to compute the header bytes. */
-#define HDR_SET_SYN(data, len, seq) (SYN)
-#define HDR_SET_TYPE_LEN(data, len, seq) \
- (HDR_OFFSET \
- + ((data) ? TYPE_LEN_DATA : TYPE_LEN_ACK) \
- + (((len) >> 6) & 0x1f))
-#define HDR_SET_LEN1(data, len, seq) (HDR_OFFSET + ((len) & 0x3f))
-#define HDR_SET_SEQ(data, len, seq) (HDR_OFFSET + (seq))
-
-/* Check that a header byte is reasonable. */
-#define HDR_CHECK(ch) (((ch) & HDR_OFFSET) == HDR_OFFSET)
-
-/* Get data from the header. These macros evaluate their argument
- multiple times. */
-#define HDR_IS_DATA(hdr) \
- (((hdr)[HDR_INDX_TYPE_LEN] & TYPE_LEN_DA_BIT) == TYPE_LEN_DATA)
-#define HDR_GET_LEN(hdr) \
- ((((hdr)[HDR_INDX_TYPE_LEN] & 0x1f) << 6) + (((hdr)[HDR_INDX_LEN1] & 0x3f)))
-#define HDR_GET_SEQ(hdr) ((unsigned int)(hdr)[HDR_INDX_SEQ] & 0x3f)
-
-/* The maximum data length. */
-#define DATA_MAXLEN 1023
-
-/* The trailer offset. */
-#define TRLR_OFFSET HDR_OFFSET
-
-/* The indices of the bytes in the packet trailer. */
-#define TRLR_INDX_CSUM1 0
-#define TRLR_INDX_CSUM2 1
-#define TRLR_INDX_CSUM3 2
-#define TRLR_LENGTH 3
-
-/* How to compute the trailer bytes. */
-#define TRLR_SET_CSUM1(cksum) (TRLR_OFFSET + (((cksum) >> 12) & 0x3f))
-#define TRLR_SET_CSUM2(cksum) (TRLR_OFFSET + (((cksum) >> 6) & 0x3f))
-#define TRLR_SET_CSUM3(cksum) (TRLR_OFFSET + (((cksum) ) & 0x3f))
-
-/* Check that a trailer byte is reasonable. */
-#define TRLR_CHECK(ch) (((ch) & TRLR_OFFSET) == TRLR_OFFSET)
-
-/* Get data from the trailer. This evaluates its argument multiple
- times. */
-#define TRLR_GET_CKSUM(trlr) \
- ((((trlr)[TRLR_INDX_CSUM1] & 0x3f) << 12) \
- + (((trlr)[TRLR_INDX_CSUM2] & 0x3f) << 6) \
- + ((trlr)[TRLR_INDX_CSUM3] & 0x3f))
-
-/* The sequence number modulos. */
-#define SEQ_MODULOS (64)
-
-/* PMON commands to load from the serial port or UDP socket. */
-#define LOAD_CMD "load -b -s tty0\r"
-#define LOAD_CMD_UDP "load -b -s udp\r"
-
-/* The target vectors for the four different remote MIPS targets.
- These are initialized with code in _initialize_remote_mips instead
- of static initializers, to make it easier to extend the target_ops
- vector later. */
-struct target_ops mips_ops, pmon_ops, ddb_ops, lsi_ops;
-
-enum mips_monitor_type {
- /* IDT/SIM monitor being used: */
- MON_IDT,
- /* PMON monitor being used: */
- MON_PMON, /* 3.0.83 [COGENT,EB,FP,NET] Algorithmics Ltd. Nov 9 1995 17:19:50 */
- MON_DDB, /* 2.7.473 [DDBVR4300,EL,FP,NET] Risq Modular Systems, Thu Jun 6 09:28:40 PDT 1996 */
- MON_LSI, /* 4.3.12 [EB,FP], LSI LOGIC Corp. Tue Feb 25 13:22:14 1997 */
- /* Last and unused value, for sizing vectors, etc. */
- MON_LAST
-};
-static enum mips_monitor_type mips_monitor = MON_LAST;
-
-/* The monitor prompt text. If the user sets the PMON prompt
- to some new value, the GDB `set monitor-prompt' command must also
- be used to inform GDB about the expected prompt. Otherwise, GDB
- will not be able to connect to PMON in mips_initialize().
- If the `set monitor-prompt' command is not used, the expected
- default prompt will be set according the target:
- target prompt
- ----- -----
- pmon PMON>
- ddb NEC010>
- lsi PMON>
-*/
-static char *mips_monitor_prompt;
-
-/* Set to 1 if the target is open. */
-static int mips_is_open;
-
-/* Currently active target description (if mips_is_open == 1) */
-static struct target_ops *current_ops;
-
-/* Set to 1 while the connection is being initialized. */
-static int mips_initializing;
-
-/* Set to 1 while the connection is being brought down. */
-static int mips_exiting;
-
-/* The next sequence number to send. */
-static unsigned int mips_send_seq;
-
-/* The next sequence number we expect to receive. */
-static unsigned int mips_receive_seq;
-
-/* The time to wait before retransmitting a packet, in seconds. */
-static int mips_retransmit_wait = 3;
-
-/* The number of times to try retransmitting a packet before giving up. */
-static int mips_send_retries = 10;
-
-/* The number of garbage characters to accept when looking for an
- SYN for the next packet. */
-static int mips_syn_garbage = 1050;
-
-/* The time to wait for a packet, in seconds. */
-static int mips_receive_wait = 5;
-
-/* Set if we have sent a packet to the board but have not yet received
- a reply. */
-static int mips_need_reply = 0;
-
-/* Handle used to access serial I/O stream. */
-static serial_t mips_desc;
-
-/* UDP handle used to download files to target. */
-static serial_t udp_desc;
-static int udp_in_use;
-
-/* TFTP filename used to download files to DDB board, in the form
- host:filename. */
-static char *tftp_name; /* host:filename */
-static char *tftp_localname; /* filename portion of above */
-static int tftp_in_use;
-static FILE *tftp_file;
-
-/* Counts the number of times the user tried to interrupt the target (usually
- via ^C. */
-static int interrupt_count;
-
-/* If non-zero, means that the target is running. */
-static int mips_wait_flag = 0;
-
-/* If non-zero, monitor supports breakpoint commands. */
-static monitor_supports_breakpoints = 0;
-
-/* Data cache header. */
-
-#if 0 /* not used (yet?) */
-static DCACHE *mips_dcache;
-#endif
-
-/* Non-zero means that we've just hit a read or write watchpoint */
-static int hit_watchpoint;
-
-/* Table of breakpoints/watchpoints (used only on LSI PMON target).
- The table is indexed by a breakpoint number, which is an integer
- from 0 to 255 returned by the LSI PMON when a breakpoint is set.
-*/
-#define MAX_LSI_BREAKPOINTS 256
-struct lsi_breakpoint_info
-{
- enum break_type type; /* type of breakpoint */
- CORE_ADDR addr; /* address of breakpoint */
- int len; /* length of region being watched */
- unsigned long value; /* value to watch */
-} lsi_breakpoints [MAX_LSI_BREAKPOINTS];
-
-/* Error/warning codes returned by LSI PMON for breakpoint commands.
- Warning values may be ORed together; error values may not. */
-#define W_WARN 0x100 /* This bit is set if the error code is a warning */
-#define W_MSK 0x101 /* warning: Range feature is supported via mask */
-#define W_VAL 0x102 /* warning: Value check is not supported in hardware */
-#define W_QAL 0x104 /* warning: Requested qualifiers are not supported in hardware */
-
-#define E_ERR 0x200 /* This bit is set if the error code is an error */
-#define E_BPT 0x200 /* error: No such breakpoint number */
-#define E_RGE 0x201 /* error: Range is not supported */
-#define E_QAL 0x202 /* error: The requested qualifiers can not be used */
-#define E_OUT 0x203 /* error: Out of hardware resources */
-#define E_NON 0x204 /* error: Hardware breakpoint not supported */
-
-struct lsi_error
-{
- int code; /* error code */
- char *string; /* string associated with this code */
-};
-
-struct lsi_error lsi_warning_table[] =
-{
- { W_MSK, "Range feature is supported via mask" },
- { W_VAL, "Value check is not supported in hardware" },
- { W_QAL, "Requested qualifiers are not supported in hardware" },
- { 0, NULL }
-};
-
-struct lsi_error lsi_error_table[] =
-{
- { E_BPT, "No such breakpoint number" },
- { E_RGE, "Range is not supported" },
- { E_QAL, "The requested qualifiers can not be used" },
- { E_OUT, "Out of hardware resources" },
- { E_NON, "Hardware breakpoint not supported" },
- { 0, NULL }
-};
-
-/* Set to 1 with the 'set monitor-warnings' command to enable printing
- of warnings returned by PMON when hardware breakpoints are used. */
-static int monitor_warnings;
-
-
-static void
-close_ports()
-{
- mips_is_open = 0;
- SERIAL_CLOSE (mips_desc);
-
- if (udp_in_use)
- {
- SERIAL_CLOSE (udp_desc);
- udp_in_use = 0;
- }
- tftp_in_use = 0;
-}
-
-/* Handle low-level error that we can't recover from. Note that just
- error()ing out from target_wait or some such low-level place will cause
- all hell to break loose--the rest of GDB will tend to get left in an
- inconsistent state. */
-
-static NORETURN void
-#ifdef ANSI_PROTOTYPES
-mips_error (char *string, ...)
-#else
-mips_error (va_alist)
- va_dcl
-#endif
-{
- va_list args;
-
-#ifdef ANSI_PROTOTYPES
- va_start (args, string);
-#else
- char *string;
- va_start (args);
- string = va_arg (args, char *);
-#endif
-
- target_terminal_ours ();
- wrap_here(""); /* Force out any buffered output */
- gdb_flush (gdb_stdout);
- if (error_pre_print)
- fprintf_filtered (gdb_stderr, error_pre_print);
- vfprintf_filtered (gdb_stderr, string, args);
- fprintf_filtered (gdb_stderr, "\n");
- va_end (args);
- gdb_flush (gdb_stderr);
-
- /* Clean up in such a way that mips_close won't try to talk to the
- board (it almost surely won't work since we weren't able to talk to
- it). */
- close_ports ();
-
- printf_unfiltered ("Ending remote MIPS debugging.\n");
- target_mourn_inferior ();
-
- return_to_top_level (RETURN_ERROR);
-}
-
-/* putc_readable - print a character, displaying non-printable chars in
- ^x notation or in hex. */
-
-static void
-putc_readable (ch)
- int ch;
-{
- if (ch == '\n')
- putchar_unfiltered ('\n');
- else if (ch == '\r')
- printf_unfiltered ("\\r");
- else if (ch < 0x20) /* ASCII control character */
- printf_unfiltered ("^%c", ch + '@');
- else if (ch >= 0x7f) /* non-ASCII characters (rubout or greater) */
- printf_unfiltered ("[%02x]", ch & 0xff);
- else
- putchar_unfiltered (ch);
-}
-
-
-/* puts_readable - print a string, displaying non-printable chars in
- ^x notation or in hex. */
-
-static void
-puts_readable (string)
- char *string;
-{
- int c;
-
- while ((c = *string++) != '\0')
- putc_readable (c);
-}
-
-
-/* Wait until STRING shows up in mips_desc. Returns 1 if successful, else 0 if
- timed out. TIMEOUT specifies timeout value in seconds.
-*/
-
-int
-mips_expect_timeout (string, timeout)
- char *string;
- int timeout;
-{
- char *p = string;
-
- if (remote_debug)
- {
- printf_unfiltered ("Expected \"");
- puts_readable (string);
- printf_unfiltered ("\", got \"");
- }
-
- immediate_quit = 1;
- while (1)
- {
- int c;
-
-/* Must use SERIAL_READCHAR here cuz mips_readchar would get confused if we
- were waiting for the mips_monitor_prompt... */
-
- c = SERIAL_READCHAR (mips_desc, timeout);
-
- if (c == SERIAL_TIMEOUT)
- {
- if (remote_debug)
- printf_unfiltered ("\": FAIL\n");
- return 0;
- }
-
- if (remote_debug)
- putc_readable (c);
-
- if (c == *p++)
- {
- if (*p == '\0')
- {
- immediate_quit = 0;
- if (remote_debug)
- printf_unfiltered ("\": OK\n");
- return 1;
- }
- }
- else
- {
- p = string;
- if (c == *p)
- p++;
- }
- }
-}
-
-/* Wait until STRING shows up in mips_desc. Returns 1 if successful, else 0 if
- timed out. The timeout value is hard-coded to 2 seconds. Use
- mips_expect_timeout if a different timeout value is needed.
-*/
-
-int
-mips_expect (string)
- char *string;
-{
- return mips_expect_timeout (string, 2);
-}
-
-/* Read the required number of characters into the given buffer (which
- is assumed to be large enough). The only failure is a timeout. */
-int
-mips_getstring (string, n)
- char *string;
- int n;
-{
- char *p = string;
- int c;
-
- immediate_quit = 1;
- while (n > 0)
- {
- c = SERIAL_READCHAR (mips_desc, 2);
-
- if (c == SERIAL_TIMEOUT) {
- fprintf_unfiltered (gdb_stderr,
- "Failed to read %d characters from target (TIMEOUT)\n", n);
- return 0;
- }
-
- *p++ = c;
- n--;
- }
-
- return 1;
-}
-
-/* Read a character from the remote, aborting on error. Returns
- SERIAL_TIMEOUT on timeout (since that's what SERIAL_READCHAR
- returns). FIXME: If we see the string mips_monitor_prompt from
- the board, then we are debugging on the main console port, and we
- have somehow dropped out of remote debugging mode. In this case,
- we automatically go back in to remote debugging mode. This is a
- hack, put in because I can't find any way for a program running on
- the remote board to terminate without also ending remote debugging
- mode. I assume users won't have any trouble with this; for one
- thing, the IDT documentation generally assumes that the remote
- debugging port is not the console port. This is, however, very
- convenient for DejaGnu when you only have one connected serial
- port. */
-
-static int
-mips_readchar (timeout)
- int timeout;
-{
- int ch;
- static int state = 0;
- int mips_monitor_prompt_len = strlen (mips_monitor_prompt);
-
-#ifdef MAINTENANCE_CMDS
- {
- int i;
-
- i = timeout;
- if (i == -1 && watchdog > 0)
- i = watchdog;
- }
-#endif
-
- if (state == mips_monitor_prompt_len)
- timeout = 1;
- ch = SERIAL_READCHAR (mips_desc, timeout);
-#ifdef MAINTENANCE_CMDS
- if (ch == SERIAL_TIMEOUT && timeout == -1) /* Watchdog went off */
- {
- target_mourn_inferior ();
- error ("Watchdog has expired. Target detached.\n");
- }
-#endif
- if (ch == SERIAL_EOF)
- mips_error ("End of file from remote");
- if (ch == SERIAL_ERROR)
- mips_error ("Error reading from remote: %s", safe_strerror (errno));
- if (remote_debug > 1)
- {
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- if (ch != SERIAL_TIMEOUT)
- printf_unfiltered ("Read '%c' %d 0x%x\n", ch, ch, ch);
- else
- printf_unfiltered ("Timed out in read\n");
- }
-
- /* If we have seen mips_monitor_prompt and we either time out, or
- we see a @ (which was echoed from a packet we sent), reset the
- board as described above. The first character in a packet after
- the SYN (which is not echoed) is always an @ unless the packet is
- more than 64 characters long, which ours never are. */
- if ((ch == SERIAL_TIMEOUT || ch == '@')
- && state == mips_monitor_prompt_len
- && ! mips_initializing
- && ! mips_exiting)
- {
- if (remote_debug > 0)
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- printf_unfiltered ("Reinitializing MIPS debugging mode\n");
-
- mips_need_reply = 0;
- mips_initialize ();
-
- state = 0;
-
- /* At this point, about the only thing we can do is abort the command
- in progress and get back to command level as quickly as possible. */
-
- error ("Remote board reset, debug protocol re-initialized.");
- }
-
- if (ch == mips_monitor_prompt[state])
- ++state;
- else
- state = 0;
-
- return ch;
-}
-
-/* Get a packet header, putting the data in the supplied buffer.
- PGARBAGE is a pointer to the number of garbage characters received
- so far. CH is the last character received. Returns 0 for success,
- or -1 for timeout. */
-
-static int
-mips_receive_header (hdr, pgarbage, ch, timeout)
- unsigned char *hdr;
- int *pgarbage;
- int ch;
- int timeout;
-{
- int i;
-
- while (1)
- {
- /* Wait for a SYN. mips_syn_garbage is intended to prevent
- sitting here indefinitely if the board sends us one garbage
- character per second. ch may already have a value from the
- last time through the loop. */
- while (ch != SYN)
- {
- ch = mips_readchar (timeout);
- if (ch == SERIAL_TIMEOUT)
- return -1;
- if (ch != SYN)
- {
- /* Printing the character here lets the user of gdb see
- what the program is outputting, if the debugging is
- being done on the console port. Don't use _filtered;
- we can't deal with a QUIT out of target_wait. */
- if (! mips_initializing || remote_debug > 0)
- {
- putc_readable (ch);
- gdb_flush (gdb_stdout);
- }
-
- ++*pgarbage;
- if (mips_syn_garbage > 0
- && *pgarbage > mips_syn_garbage)
- mips_error ("Debug protocol failure: more than %d characters before a sync.",
- mips_syn_garbage);
- }
- }
-
- /* Get the packet header following the SYN. */
- for (i = 1; i < HDR_LENGTH; i++)
- {
- ch = mips_readchar (timeout);
- if (ch == SERIAL_TIMEOUT)
- return -1;
- /* Make sure this is a header byte. */
- if (ch == SYN || ! HDR_CHECK (ch))
- break;
-
- hdr[i] = ch;
- }
-
- /* If we got the complete header, we can return. Otherwise we
- loop around and keep looking for SYN. */
- if (i >= HDR_LENGTH)
- return 0;
- }
-}
-
-/* Get a packet header, putting the data in the supplied buffer.
- PGARBAGE is a pointer to the number of garbage characters received
- so far. The last character read is returned in *PCH. Returns 0
- for success, -1 for timeout, -2 for error. */
-
-static int
-mips_receive_trailer (trlr, pgarbage, pch, timeout)
- unsigned char *trlr;
- int *pgarbage;
- int *pch;
- int timeout;
-{
- int i;
- int ch;
-
- for (i = 0; i < TRLR_LENGTH; i++)
- {
- ch = mips_readchar (timeout);
- *pch = ch;
- if (ch == SERIAL_TIMEOUT)
- return -1;
- if (! TRLR_CHECK (ch))
- return -2;
- trlr[i] = ch;
- }
- return 0;
-}
-
-/* Get the checksum of a packet. HDR points to the packet header.
- DATA points to the packet data. LEN is the length of DATA. */
-
-static int
-mips_cksum (hdr, data, len)
- const unsigned char *hdr;
- const unsigned char *data;
- int len;
-{
- register const unsigned char *p;
- register int c;
- register int cksum;
-
- cksum = 0;
-
- /* The initial SYN is not included in the checksum. */
- c = HDR_LENGTH - 1;
- p = hdr + 1;
- while (c-- != 0)
- cksum += *p++;
-
- c = len;
- p = data;
- while (c-- != 0)
- cksum += *p++;
-
- return cksum;
-}
-
-/* Send a packet containing the given ASCII string. */
-
-static void
-mips_send_packet (s, get_ack)
- const char *s;
- int get_ack;
-{
- /* unsigned */ int len;
- unsigned char *packet;
- register int cksum;
- int try;
-
- len = strlen (s);
- if (len > DATA_MAXLEN)
- mips_error ("MIPS protocol data packet too long: %s", s);
-
- packet = (unsigned char *) alloca (HDR_LENGTH + len + TRLR_LENGTH + 1);
-
- packet[HDR_INDX_SYN] = HDR_SET_SYN (1, len, mips_send_seq);
- packet[HDR_INDX_TYPE_LEN] = HDR_SET_TYPE_LEN (1, len, mips_send_seq);
- packet[HDR_INDX_LEN1] = HDR_SET_LEN1 (1, len, mips_send_seq);
- packet[HDR_INDX_SEQ] = HDR_SET_SEQ (1, len, mips_send_seq);
-
- memcpy (packet + HDR_LENGTH, s, len);
-
- cksum = mips_cksum (packet, packet + HDR_LENGTH, len);
- packet[HDR_LENGTH + len + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
- packet[HDR_LENGTH + len + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
- packet[HDR_LENGTH + len + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
-
- /* Increment the sequence number. This will set mips_send_seq to
- the sequence number we expect in the acknowledgement. */
- mips_send_seq = (mips_send_seq + 1) % SEQ_MODULOS;
-
- /* We can only have one outstanding data packet, so we just wait for
- the acknowledgement here. Keep retransmitting the packet until
- we get one, or until we've tried too many times. */
- for (try = 0; try < mips_send_retries; try++)
- {
- int garbage;
- int ch;
-
- if (remote_debug > 0)
- {
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- packet[HDR_LENGTH + len + TRLR_LENGTH] = '\0';
- printf_unfiltered ("Writing \"%s\"\n", packet + 1);
- }
-
- if (SERIAL_WRITE (mips_desc, packet,
- HDR_LENGTH + len + TRLR_LENGTH) != 0)
- mips_error ("write to target failed: %s", safe_strerror (errno));
-
- if (! get_ack)
- return;
-
- garbage = 0;
- ch = 0;
- while (1)
- {
- unsigned char hdr[HDR_LENGTH + 1];
- unsigned char trlr[TRLR_LENGTH + 1];
- int err;
- unsigned int seq;
-
- /* Get the packet header. If we time out, resend the data
- packet. */
- err = mips_receive_header (hdr, &garbage, ch, mips_retransmit_wait);
- if (err != 0)
- break;
-
- ch = 0;
-
- /* If we get a data packet, assume it is a duplicate and
- ignore it. FIXME: If the acknowledgement is lost, this
- data packet may be the packet the remote sends after the
- acknowledgement. */
- if (HDR_IS_DATA (hdr)) {
- int i;
-
- /* Ignore any errors raised whilst attempting to ignore
- packet. */
-
- len = HDR_GET_LEN (hdr);
-
- for (i = 0; i < len; i++)
- {
- int rch;
-
- rch = mips_readchar (2);
- if (rch == SYN)
- {
- ch = SYN;
- break;
- }
- if (rch == SERIAL_TIMEOUT)
- break;
- /* ignore the character */
- }
-
- if (i == len)
- (void) mips_receive_trailer (trlr, &garbage, &ch, 2);
-
- /* We don't bother checking the checksum, or providing an
- ACK to the packet. */
- continue;
- }
-
- /* If the length is not 0, this is a garbled packet. */
- if (HDR_GET_LEN (hdr) != 0)
- continue;
-
- /* Get the packet trailer. */
- err = mips_receive_trailer (trlr, &garbage, &ch,
- mips_retransmit_wait);
-
- /* If we timed out, resend the data packet. */
- if (err == -1)
- break;
-
- /* If we got a bad character, reread the header. */
- if (err != 0)
- continue;
-
- /* If the checksum does not match the trailer checksum, this
- is a bad packet; ignore it. */
- if (mips_cksum (hdr, (unsigned char *) NULL, 0)
- != TRLR_GET_CKSUM (trlr))
- continue;
-
- if (remote_debug > 0)
- {
- hdr[HDR_LENGTH] = '\0';
- trlr[TRLR_LENGTH] = '\0';
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- printf_unfiltered ("Got ack %d \"%s%s\"\n",
- HDR_GET_SEQ (hdr), hdr + 1, trlr);
- }
-
- /* If this ack is for the current packet, we're done. */
- seq = HDR_GET_SEQ (hdr);
- if (seq == mips_send_seq)
- return;
-
- /* If this ack is for the last packet, resend the current
- packet. */
- if ((seq + 1) % SEQ_MODULOS == mips_send_seq)
- break;
-
- /* Otherwise this is a bad ack; ignore it. Increment the
- garbage count to ensure that we do not stay in this loop
- forever. */
- ++garbage;
- }
- }
-
- mips_error ("Remote did not acknowledge packet");
-}
-
-/* Receive and acknowledge a packet, returning the data in BUFF (which
- should be DATA_MAXLEN + 1 bytes). The protocol documentation
- implies that only the sender retransmits packets, so this code just
- waits silently for a packet. It returns the length of the received
- packet. If THROW_ERROR is nonzero, call error() on errors. If not,
- don't print an error message and return -1. */
-
-static int
-mips_receive_packet (buff, throw_error, timeout)
- char *buff;
- int throw_error;
- int timeout;
-{
- int ch;
- int garbage;
- int len;
- unsigned char ack[HDR_LENGTH + TRLR_LENGTH + 1];
- int cksum;
-
- ch = 0;
- garbage = 0;
- while (1)
- {
- unsigned char hdr[HDR_LENGTH];
- unsigned char trlr[TRLR_LENGTH];
- int i;
- int err;
-
- if (mips_receive_header (hdr, &garbage, ch, timeout) != 0)
- {
- if (throw_error)
- mips_error ("Timed out waiting for remote packet");
- else
- return -1;
- }
-
- ch = 0;
-
- /* An acknowledgement is probably a duplicate; ignore it. */
- if (! HDR_IS_DATA (hdr))
- {
- len = HDR_GET_LEN (hdr);
- /* Check if the length is valid for an ACK, we may aswell
- try and read the remainder of the packet: */
- if (len == 0)
- {
- /* Ignore the error condition, since we are going to
- ignore the packet anyway. */
- (void) mips_receive_trailer (trlr, &garbage, &ch, timeout);
- }
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- if (remote_debug > 0)
- printf_unfiltered ("Ignoring unexpected ACK\n");
- continue;
- }
-
- len = HDR_GET_LEN (hdr);
- for (i = 0; i < len; i++)
- {
- int rch;
-
- rch = mips_readchar (timeout);
- if (rch == SYN)
- {
- ch = SYN;
- break;
- }
- if (rch == SERIAL_TIMEOUT)
- {
- if (throw_error)
- mips_error ("Timed out waiting for remote packet");
- else
- return -1;
- }
- buff[i] = rch;
- }
-
- if (i < len)
- {
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- if (remote_debug > 0)
- printf_unfiltered ("Got new SYN after %d chars (wanted %d)\n",
- i, len);
- continue;
- }
-
- err = mips_receive_trailer (trlr, &garbage, &ch, timeout);
- if (err == -1)
- {
- if (throw_error)
- mips_error ("Timed out waiting for packet");
- else
- return -1;
- }
- if (err == -2)
- {
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- if (remote_debug > 0)
- printf_unfiltered ("Got SYN when wanted trailer\n");
- continue;
- }
-
- /* If this is the wrong sequence number, ignore it. */
- if (HDR_GET_SEQ (hdr) != mips_receive_seq)
- {
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- if (remote_debug > 0)
- printf_unfiltered ("Ignoring sequence number %d (want %d)\n",
- HDR_GET_SEQ (hdr), mips_receive_seq);
- continue;
- }
-
- if (mips_cksum (hdr, buff, len) == TRLR_GET_CKSUM (trlr))
- break;
-
- if (remote_debug > 0)
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- printf_unfiltered ("Bad checksum; data %d, trailer %d\n",
- mips_cksum (hdr, buff, len),
- TRLR_GET_CKSUM (trlr));
-
- /* The checksum failed. Send an acknowledgement for the
- previous packet to tell the remote to resend the packet. */
- ack[HDR_INDX_SYN] = HDR_SET_SYN (0, 0, mips_receive_seq);
- ack[HDR_INDX_TYPE_LEN] = HDR_SET_TYPE_LEN (0, 0, mips_receive_seq);
- ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
- ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
-
- cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
-
- ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
- ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
- ack[HDR_LENGTH + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
-
- if (remote_debug > 0)
- {
- ack[HDR_LENGTH + TRLR_LENGTH] = '\0';
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- printf_unfiltered ("Writing ack %d \"%s\"\n", mips_receive_seq,
- ack + 1);
- }
-
- if (SERIAL_WRITE (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH) != 0)
- {
- if (throw_error)
- mips_error ("write to target failed: %s", safe_strerror (errno));
- else
- return -1;
- }
- }
-
- if (remote_debug > 0)
- {
- buff[len] = '\0';
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- printf_unfiltered ("Got packet \"%s\"\n", buff);
- }
-
- /* We got the packet. Send an acknowledgement. */
- mips_receive_seq = (mips_receive_seq + 1) % SEQ_MODULOS;
-
- ack[HDR_INDX_SYN] = HDR_SET_SYN (0, 0, mips_receive_seq);
- ack[HDR_INDX_TYPE_LEN] = HDR_SET_TYPE_LEN (0, 0, mips_receive_seq);
- ack[HDR_INDX_LEN1] = HDR_SET_LEN1 (0, 0, mips_receive_seq);
- ack[HDR_INDX_SEQ] = HDR_SET_SEQ (0, 0, mips_receive_seq);
-
- cksum = mips_cksum (ack, (unsigned char *) NULL, 0);
-
- ack[HDR_LENGTH + TRLR_INDX_CSUM1] = TRLR_SET_CSUM1 (cksum);
- ack[HDR_LENGTH + TRLR_INDX_CSUM2] = TRLR_SET_CSUM2 (cksum);
- ack[HDR_LENGTH + TRLR_INDX_CSUM3] = TRLR_SET_CSUM3 (cksum);
-
- if (remote_debug > 0)
- {
- ack[HDR_LENGTH + TRLR_LENGTH] = '\0';
- /* Don't use _filtered; we can't deal with a QUIT out of
- target_wait, and I think this might be called from there. */
- printf_unfiltered ("Writing ack %d \"%s\"\n", mips_receive_seq,
- ack + 1);
- }
-
- if (SERIAL_WRITE (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH) != 0)
- {
- if (throw_error)
- mips_error ("write to target failed: %s", safe_strerror (errno));
- else
- return -1;
- }
-
- return len;
-}
-
-/* Optionally send a request to the remote system and optionally wait
- for the reply. This implements the remote debugging protocol,
- which is built on top of the packet protocol defined above. Each
- request has an ADDR argument and a DATA argument. The following
- requests are defined:
-
- \0 don't send a request; just wait for a reply
- i read word from instruction space at ADDR
- d read word from data space at ADDR
- I write DATA to instruction space at ADDR
- D write DATA to data space at ADDR
- r read register number ADDR
- R set register number ADDR to value DATA
- c continue execution (if ADDR != 1, set pc to ADDR)
- s single step (if ADDR != 1, set pc to ADDR)
-
- The read requests return the value requested. The write requests
- return the previous value in the changed location. The execution
- requests return a UNIX wait value (the approximate signal which
- caused execution to stop is in the upper eight bits).
-
- If PERR is not NULL, this function waits for a reply. If an error
- occurs, it sets *PERR to 1 and sets errno according to what the
- target board reports. */
-
-static CORE_ADDR
-mips_request (cmd, addr, data, perr, timeout, buff)
- int cmd;
- CORE_ADDR addr;
- CORE_ADDR data;
- int *perr;
- int timeout;
- char *buff;
-{
- char myBuff[DATA_MAXLEN + 1];
- int len;
- int rpid;
- char rcmd;
- int rerrflg;
- unsigned long rresponse;
-
- if (buff == (char *) NULL)
- buff = myBuff;
-
- if (cmd != '\0')
- {
- if (mips_need_reply)
- fatal ("mips_request: Trying to send command before reply");
- sprintf (buff, "0x0 %c 0x%s 0x%s", cmd, paddr_nz (addr), paddr_nz (data));
- mips_send_packet (buff, 1);
- mips_need_reply = 1;
- }
-
- if (perr == (int *) NULL)
- return 0;
-
- if (! mips_need_reply)
- fatal ("mips_request: Trying to get reply before command");
-
- mips_need_reply = 0;
-
- len = mips_receive_packet (buff, 1, timeout);
- buff[len] = '\0';
-
- if (sscanf (buff, "0x%x %c 0x%x 0x%lx",
- &rpid, &rcmd, &rerrflg, &rresponse) != 4
- || (cmd != '\0' && rcmd != cmd))
- mips_error ("Bad response from remote board");
-
- if (rerrflg != 0)
- {
- *perr = 1;
-
- /* FIXME: This will returns MIPS errno numbers, which may or may
- not be the same as errno values used on other systems. If
- they stick to common errno values, they will be the same, but
- if they don't, they must be translated. */
- errno = rresponse;
-
- return 0;
- }
-
- *perr = 0;
- return rresponse;
-}
-
-static void
-mips_initialize_cleanups (arg)
- PTR arg;
-{
- mips_initializing = 0;
-}
-
-static void
-mips_exit_cleanups (arg)
- PTR arg;
-{
- mips_exiting = 0;
-}
-
-static void
-mips_send_command (cmd, prompt)
- const char *cmd;
- int prompt;
-{
- SERIAL_WRITE (mips_desc, cmd, strlen(cmd));
- mips_expect (cmd);
- mips_expect ("\n");
- if (prompt)
- mips_expect (mips_monitor_prompt);
-}
-
-/* Enter remote (dbx) debug mode: */
-static void
-mips_enter_debug ()
-{
- /* Reset the sequence numbers, ready for the new debug sequence: */
- mips_send_seq = 0;
- mips_receive_seq = 0;
-
- if (mips_monitor != MON_IDT)
- mips_send_command ("debug\r", 0);
- else /* assume IDT monitor by default */
- mips_send_command ("db tty0\r", 0);
-
- sleep(1);
- SERIAL_WRITE (mips_desc, "\r", sizeof "\r" - 1);
-
- /* We don't need to absorb any spurious characters here, since the
- mips_receive_header will eat up a reasonable number of characters
- whilst looking for the SYN, however this avoids the "garbage"
- being displayed to the user. */
- if (mips_monitor != MON_IDT)
- mips_expect ("\r");
-
- {
- char buff[DATA_MAXLEN + 1];
- if (mips_receive_packet (buff, 1, 3) < 0)
- mips_error ("Failed to initialize (didn't receive packet).");
- }
-}
-
-/* Exit remote (dbx) debug mode, returning to the monitor prompt: */
-static int
-mips_exit_debug ()
-{
- int err;
- struct cleanup *old_cleanups = make_cleanup (mips_exit_cleanups, NULL);
-
- mips_exiting = 1;
-
- if (mips_monitor != MON_IDT)
- {
- /* The DDB (NEC) and MiniRISC (LSI) versions of PMON exit immediately,
- so we do not get a reply to this command: */
- mips_request ('x', (unsigned int) 0, (unsigned int) 0, NULL,
- mips_receive_wait, NULL);
- mips_need_reply = 0;
- if (!mips_expect (" break!"))
- return -1;
- }
- else
- mips_request ('x', (unsigned int) 0, (unsigned int) 0, &err,
- mips_receive_wait, NULL);
-
- if (!mips_expect (mips_monitor_prompt))
- return -1;
-
- do_cleanups (old_cleanups);
-
- return 0;
-}
-
-/* Initialize a new connection to the MIPS board, and make sure we are
- really connected. */
-
-static void
-mips_initialize ()
-{
- int err;
- struct cleanup *old_cleanups = make_cleanup (mips_initialize_cleanups, NULL);
- int j;
-
- /* What is this code doing here? I don't see any way it can happen, and
- it might mean mips_initializing didn't get cleared properly.
- So I'll make it a warning. */
-
- if (mips_initializing)
- {
- warning ("internal error: mips_initialize called twice");
- return;
- }
-
- mips_wait_flag = 0;
- mips_initializing = 1;
-
- /* At this point, the packit protocol isn't responding. We'll try getting
- into the monitor, and restarting the protocol. */
-
- /* Force the system into the monitor. After this we *should* be at
- the mips_monitor_prompt. */
- if (mips_monitor != MON_IDT)
- j = 0; /* start by checking if we are already at the prompt */
- else
- j = 1; /* start by sending a break */
- for (; j <= 4; j++)
- {
- switch (j)
- {
- case 0: /* First, try sending a CR */
- SERIAL_FLUSH_INPUT (mips_desc);
- SERIAL_WRITE (mips_desc, "\r", 1);
- break;
- case 1: /* First, try sending a break */
- SERIAL_SEND_BREAK (mips_desc);
- break;
- case 2: /* Then, try a ^C */
- SERIAL_WRITE (mips_desc, "\003", 1);
- break;
- case 3: /* Then, try escaping from download */
- {
- if (mips_monitor != MON_IDT)
- {
- char tbuff[7];
-
- /* We shouldn't need to send multiple termination
- sequences, since the target performs line (or
- block) reads, and then processes those
- packets. In-case we were downloading a large packet
- we flush the output buffer before inserting a
- termination sequence. */
- SERIAL_FLUSH_OUTPUT (mips_desc);
- sprintf (tbuff, "\r/E/E\r");
- SERIAL_WRITE (mips_desc, tbuff, 6);
- }
- else
- {
- char srec[10];
- int i;
-
- /* We are possibly in binary download mode, having
- aborted in the middle of an S-record. ^C won't
- work because of binary mode. The only reliable way
- out is to send enough termination packets (8 bytes)
- to fill up and then overflow the largest size
- S-record (255 bytes in this case). This amounts to
- 256/8 + 1 packets.
- */
-
- mips_make_srec (srec, '7', 0, NULL, 0);
-
- for (i = 1; i <= 33; i++)
- {
- SERIAL_WRITE (mips_desc, srec, 8);
-
- if (SERIAL_READCHAR (mips_desc, 0) >= 0)
- break; /* Break immediatly if we get something from
- the board. */
- }
- }
- }
- break;
- case 4:
- mips_error ("Failed to initialize.");
- }
-
- if (mips_expect (mips_monitor_prompt))
- break;
- }
-
- if (mips_monitor != MON_IDT)
- {
- /* Sometimes PMON ignores the first few characters in the first
- command sent after a load. Sending a blank command gets
- around that. */
- mips_send_command ("\r", -1);
-
- /* Ensure the correct target state: */
- if (mips_monitor != MON_LSI)
- mips_send_command ("set regsize 64\r", -1);
- mips_send_command ("set hostport tty0\r", -1);
- mips_send_command ("set brkcmd \"\"\r", -1);
- /* Delete all the current breakpoints: */
- mips_send_command ("db *\r", -1);
- /* NOTE: PMON does not have breakpoint support through the
- "debug" mode, only at the monitor command-line. */
- }
-
- mips_enter_debug ();
-
- /* Clear all breakpoints: */
- if ((mips_monitor == MON_IDT
- && clear_breakpoint (-1, 0, BREAK_UNUSED) == 0)
- || mips_monitor == MON_LSI)
- monitor_supports_breakpoints = 1;
- else
- monitor_supports_breakpoints = 0;
-
- do_cleanups (old_cleanups);
-
- /* If this doesn't call error, we have connected; we don't care if
- the request itself succeeds or fails. */
-
- mips_request ('r', (unsigned int) 0, (unsigned int) 0, &err,
- mips_receive_wait, NULL);
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
-}
-
-/* Open a connection to the remote board. */
-static void
-common_open (ops, name, from_tty, new_monitor, new_monitor_prompt)
- struct target_ops *ops;
- char *name;
- int from_tty;
- enum mips_monitor_type new_monitor;
- char *new_monitor_prompt;
-{
- char *ptype;
- char *serial_port_name;
- char *remote_name = 0;
- char *local_name = 0;
- char **argv;
-
- if (name == 0)
- error (
-"To open a MIPS remote debugging connection, you need to specify what serial\n\
-device is attached to the target board (e.g., /dev/ttya).\n"
-"If you want to use TFTP to download to the board, specify the name of a\n"
-"temporary file to be used by GDB for downloads as the second argument.\n"
-"This filename must be in the form host:filename, where host is the name\n"
-"of the host running the TFTP server, and the file must be readable by the\n"
-"world. If the local name of the temporary file differs from the name as\n"
-"seen from the board via TFTP, specify that name as the third parameter.\n");
-
- /* Parse the serial port name, the optional TFTP name, and the
- optional local TFTP name. */
- if ((argv = buildargv (name)) == NULL)
- nomem(0);
- make_cleanup ((make_cleanup_func) freeargv, argv);
-
- serial_port_name = strsave (argv[0]);
- if (argv[1]) /* remote TFTP name specified? */
- {
- remote_name = argv[1];
- if (argv[2]) /* local TFTP filename specified? */
- local_name = argv[2];
- }
-
- target_preopen (from_tty);
-
- if (mips_is_open)
- unpush_target (current_ops);
-
- /* Open and initialize the serial port. */
- mips_desc = SERIAL_OPEN (serial_port_name);
- if (mips_desc == (serial_t) NULL)
- perror_with_name (serial_port_name);
-
- if (baud_rate != -1)
- {
- if (SERIAL_SETBAUDRATE (mips_desc, baud_rate))
- {
- SERIAL_CLOSE (mips_desc);
- perror_with_name (serial_port_name);
- }
- }
-
- SERIAL_RAW (mips_desc);
-
- /* Open and initialize the optional download port. If it is in the form
- hostname#portnumber, it's a UDP socket. If it is in the form
- hostname:filename, assume it's the TFTP filename that must be
- passed to the DDB board to tell it where to get the load file. */
- if (remote_name)
- {
- if (strchr (remote_name, '#'))
- {
- udp_desc = SERIAL_OPEN (remote_name);
- if (!udp_desc)
- perror_with_name ("Unable to open UDP port");
- udp_in_use = 1;
- }
- else
- {
- /* Save the remote and local names of the TFTP temp file. If
- the user didn't specify a local name, assume it's the same
- as the part of the remote name after the "host:". */
- if (tftp_name)
- free (tftp_name);
- if (tftp_localname)
- free (tftp_localname);
- if (local_name == NULL)
- if ((local_name = strchr (remote_name, ':')) != NULL)
- local_name++; /* skip over the colon */
- if (local_name == NULL)
- local_name = remote_name; /* local name same as remote name */
- tftp_name = strsave (remote_name);
- tftp_localname = strsave (local_name);
- tftp_in_use = 1;
- }
- }
-
- current_ops = ops;
- mips_is_open = 1;
-
- /* Reset the expected monitor prompt if it's never been set before. */
- if (mips_monitor_prompt == NULL)
- mips_monitor_prompt = strsave (new_monitor_prompt);
- mips_monitor = new_monitor;
-
- mips_initialize ();
-
- if (from_tty)
- printf_unfiltered ("Remote MIPS debugging using %s\n", serial_port_name);
-
- /* Switch to using remote target now. */
- push_target (ops);
-
- /* FIXME: Should we call start_remote here? */
-
- /* Try to figure out the processor model if possible. */
- ptype = mips_read_processor_type ();
- if (ptype)
- mips_set_processor_type_command (strsave (ptype), 0);
-
-/* This is really the job of start_remote however, that makes an assumption
- that the target is about to print out a status message of some sort. That
- doesn't happen here (in fact, it may not be possible to get the monitor to
- send the appropriate packet). */
-
- flush_cached_frames ();
- registers_changed ();
- stop_pc = read_pc ();
- set_current_frame (create_new_frame (read_fp (), stop_pc));
- select_frame (get_current_frame (), 0);
- print_stack_frame (selected_frame, -1, 1);
- free (serial_port_name);
-}
-
-static void
-mips_open (name, from_tty)
- char *name;
- int from_tty;
-{
- common_open (&mips_ops, name, from_tty, MON_IDT, TARGET_MONITOR_PROMPT);
-}
-
-static void
-pmon_open (name, from_tty)
- char *name;
- int from_tty;
-{
- common_open (&pmon_ops, name, from_tty, MON_PMON, "PMON> ");
-}
-
-static void
-ddb_open (name, from_tty)
- char *name;
- int from_tty;
-{
- common_open (&ddb_ops, name, from_tty, MON_DDB, "NEC010>");
-}
-
-static void
-lsi_open (name, from_tty)
- char *name;
- int from_tty;
-{
- int i;
-
- /* Clear the LSI breakpoint table. */
- for (i = 0; i < MAX_LSI_BREAKPOINTS; i++)
- lsi_breakpoints[i].type = BREAK_UNUSED;
-
- common_open (&lsi_ops, name, from_tty, MON_LSI, "PMON> ");
-}
-
-/* Close a connection to the remote board. */
-
-static void
-mips_close (quitting)
- int quitting;
-{
- if (mips_is_open)
- {
- /* Get the board out of remote debugging mode. */
- (void) mips_exit_debug ();
-
- close_ports ();
- }
-}
-
-/* Detach from the remote board. */
-
-static void
-mips_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- if (args)
- error ("Argument given to \"detach\" when remotely debugging.");
-
- pop_target ();
-
- mips_close (1);
-
- if (from_tty)
- printf_unfiltered ("Ending remote MIPS debugging.\n");
-}
-
-/* Tell the target board to resume. This does not wait for a reply
- from the board, except in the case of single-stepping on LSI boards,
- where PMON does return a reply. */
-
-static void
-mips_resume (pid, step, siggnal)
- int pid, step;
- enum target_signal siggnal;
-{
- int err;
-
- /* LSI PMON requires returns a reply packet "0x1 s 0x0 0x57f" after
- a single step, so we wait for that. */
- mips_request (step ? 's' : 'c',
- (unsigned int) 1,
- (unsigned int) siggnal,
- mips_monitor == MON_LSI && step ? &err : (int *) NULL,
- mips_receive_wait, NULL);
-}
-
-/* Return the signal corresponding to SIG, where SIG is the number which
- the MIPS protocol uses for the signal. */
-enum target_signal
-mips_signal_from_protocol (sig)
- int sig;
-{
- /* We allow a few more signals than the IDT board actually returns, on
- the theory that there is at least *some* hope that perhaps the numbering
- for these signals is widely agreed upon. */
- if (sig <= 0
- || sig > 31)
- return TARGET_SIGNAL_UNKNOWN;
-
- /* Don't want to use target_signal_from_host because we are converting
- from MIPS signal numbers, not host ones. Our internal numbers
- match the MIPS numbers for the signals the board can return, which
- are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP. */
- return (enum target_signal) sig;
-}
-
-/* Wait until the remote stops, and return a wait status. */
-
-static int
-mips_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- int rstatus;
- int err;
- char buff[DATA_MAXLEN];
- int rpc, rfp, rsp;
- char flags[20];
- int nfields;
- int i;
-
- interrupt_count = 0;
- hit_watchpoint = 0;
-
- /* If we have not sent a single step or continue command, then the
- board is waiting for us to do something. Return a status
- indicating that it is stopped. */
- if (! mips_need_reply)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- return 0;
- }
-
- /* No timeout; we sit here as long as the program continues to execute. */
- mips_wait_flag = 1;
- rstatus = mips_request ('\000', (unsigned int) 0, (unsigned int) 0, &err, -1,
- buff);
- mips_wait_flag = 0;
- if (err)
- mips_error ("Remote failure: %s", safe_strerror (errno));
-
- /* On returning from a continue, the PMON monitor seems to start
- echoing back the messages we send prior to sending back the
- ACK. The code can cope with this, but to try and avoid the
- unnecessary serial traffic, and "spurious" characters displayed
- to the user, we cheat and reset the debug protocol. The problems
- seems to be caused by a check on the number of arguments, and the
- command length, within the monitor causing it to echo the command
- as a bad packet. */
- if (mips_monitor == MON_PMON)
- {
- mips_exit_debug ();
- mips_enter_debug ();
- }
-
- /* See if we got back extended status. If so, pick out the pc, fp, sp, etc... */
-
- nfields = sscanf (buff, "0x%*x %*c 0x%*x 0x%*x 0x%x 0x%x 0x%x 0x%*x %s",
- &rpc, &rfp, &rsp, flags);
- if (nfields >= 3)
- {
- char buf[MAX_REGISTER_RAW_SIZE];
-
- store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), rpc);
- supply_register (PC_REGNUM, buf);
-
- store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), rfp);
- supply_register (30, buf); /* This register they are avoiding and so it is unnamed */
-
- store_unsigned_integer (buf, REGISTER_RAW_SIZE (SP_REGNUM), rsp);
- supply_register (SP_REGNUM, buf);
-
- store_unsigned_integer (buf, REGISTER_RAW_SIZE (FP_REGNUM), 0);
- supply_register (FP_REGNUM, buf);
-
- if (nfields == 9)
- {
- int i;
-
- for (i = 0; i <= 2; i++)
- if (flags[i] == 'r' || flags[i] == 'w')
- hit_watchpoint = 1;
- else if (flags[i] == '\000')
- break;
- }
- }
-
- if (strcmp (target_shortname, "lsi") == 0)
- {
-#if 0
- /* If this is an LSI PMON target, see if we just hit a hardrdware watchpoint.
- Right now, PMON doesn't give us enough information to determine which
- breakpoint we hit. So we have to look up the PC in our own table
- of breakpoints, and if found, assume it's just a normal instruction
- fetch breakpoint, not a data watchpoint. FIXME when PMON
- provides some way to tell us what type of breakpoint it is. */
- int i;
- CORE_ADDR pc = read_pc();
-
- hit_watchpoint = 1;
- for (i = 0; i < MAX_LSI_BREAKPOINTS; i++)
- {
- if (lsi_breakpoints[i].addr == pc
- && lsi_breakpoints[i].type == BREAK_FETCH)
- {
- hit_watchpoint = 0;
- break;
- }
- }
-#else
- /* If a data breakpoint was hit, PMON returns the following packet:
- 0x1 c 0x0 0x57f 0x1
- The return packet from an ordinary breakpoint doesn't have the
- extra 0x01 field tacked onto the end. */
- if (nfields == 1 && rpc == 1)
- hit_watchpoint = 1;
-#endif
- }
-
- /* NOTE: The following (sig) numbers are defined by PMON:
- SPP_SIGTRAP 5 breakpoint
- SPP_SIGINT 2
- SPP_SIGSEGV 11
- SPP_SIGBUS 10
- SPP_SIGILL 4
- SPP_SIGFPE 8
- SPP_SIGTERM 15 */
-
- /* Translate a MIPS waitstatus. We use constants here rather than WTERMSIG
- and so on, because the constants we want here are determined by the
- MIPS protocol and have nothing to do with what host we are running on. */
- if ((rstatus & 0xff) == 0)
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = (((rstatus) >> 8) & 0xff);
- }
- else if ((rstatus & 0xff) == 0x7f)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = mips_signal_from_protocol (((rstatus) >> 8) & 0xff);
-
- /* If the stop PC is in the _exit function, assume
- we hit the 'break 0x3ff' instruction in _exit, so this
- is not a normal breakpoint. */
- if (strcmp (target_shortname, "lsi") == 0)
- {
- char *func_name;
- CORE_ADDR func_start;
- CORE_ADDR pc = read_pc();
-
- find_pc_partial_function (pc, &func_name, &func_start, NULL);
- if (func_name != NULL && strcmp (func_name, "_exit") == 0
- && func_start == pc)
- status->kind = TARGET_WAITKIND_EXITED;
- }
- }
- else
- {
- status->kind = TARGET_WAITKIND_SIGNALLED;
- status->value.sig = mips_signal_from_protocol (rstatus & 0x7f);
- }
-
- return 0;
-}
-
-/* We have to map between the register numbers used by gdb and the
- register numbers used by the debugging protocol. This function
- assumes that we are using tm-mips.h. */
-
-#define REGNO_OFFSET 96
-
-static int
-mips_map_regno (regno)
- int regno;
-{
- if (regno < 32)
- return regno;
- if (regno >= FP0_REGNUM && regno < FP0_REGNUM + 32)
- return regno - FP0_REGNUM + 32;
- switch (regno)
- {
- case PC_REGNUM:
- return REGNO_OFFSET + 0;
- case CAUSE_REGNUM:
- return REGNO_OFFSET + 1;
- case HI_REGNUM:
- return REGNO_OFFSET + 2;
- case LO_REGNUM:
- return REGNO_OFFSET + 3;
- case FCRCS_REGNUM:
- return REGNO_OFFSET + 4;
- case FCRIR_REGNUM:
- return REGNO_OFFSET + 5;
- default:
- /* FIXME: Is there a way to get the status register? */
- return 0;
- }
-}
-
-/* Fetch the remote registers. */
-
-static void
-mips_fetch_registers (regno)
- int regno;
-{
- unsigned LONGEST val;
- int err;
-
- if (regno == -1)
- {
- for (regno = 0; regno < NUM_REGS; regno++)
- mips_fetch_registers (regno);
- return;
- }
-
- if (regno == FP_REGNUM || regno == ZERO_REGNUM)
- /* FP_REGNUM on the mips is a hack which is just supposed to read
- zero (see also mips-nat.c). */
- val = 0;
- else
- {
- /* If PMON doesn't support this register, don't waste serial
- bandwidth trying to read it. */
- int pmon_reg = mips_map_regno (regno);
- if (regno != 0 && pmon_reg == 0)
- val = 0;
- else
- {
- /* Unfortunately the PMON version in the Vr4300 board has been
- compiled without the 64bit register access commands. This
- means we cannot get hold of the full register width. */
- if (mips_monitor == MON_DDB)
- val = (unsigned)mips_request ('t', (unsigned int) pmon_reg,
- (unsigned int) 0, &err, mips_receive_wait, NULL);
- else
- val = mips_request ('r', (unsigned int) pmon_reg,
- (unsigned int) 0, &err, mips_receive_wait, NULL);
- if (err)
- mips_error ("Can't read register %d: %s", regno,
- safe_strerror (errno));
- }
- }
-
- {
- char buf[MAX_REGISTER_RAW_SIZE];
-
- /* We got the number the register holds, but gdb expects to see a
- value in the target byte ordering. */
- store_unsigned_integer (buf, REGISTER_RAW_SIZE (regno), val);
- supply_register (regno, buf);
- }
-}
-
-/* Prepare to store registers. The MIPS protocol can store individual
- registers, so this function doesn't have to do anything. */
-
-static void
-mips_prepare_to_store ()
-{
-}
-
-/* Store remote register(s). */
-
-static void
-mips_store_registers (regno)
- int regno;
-{
- int err;
-
- if (regno == -1)
- {
- for (regno = 0; regno < NUM_REGS; regno++)
- mips_store_registers (regno);
- return;
- }
-
- mips_request ('R', (unsigned int) mips_map_regno (regno),
- read_register (regno),
- &err, mips_receive_wait, NULL);
- if (err)
- mips_error ("Can't write register %d: %s", regno, safe_strerror (errno));
-}
-
-/* Fetch a word from the target board. */
-
-static unsigned int
-mips_fetch_word (addr)
- CORE_ADDR addr;
-{
- unsigned int val;
- int err;
-
- /* FIXME! addr was cast to uint! */
- val = mips_request ('d', addr, (unsigned int) 0, &err,
- mips_receive_wait, NULL);
- if (err)
- {
- /* Data space failed; try instruction space. */
- /* FIXME! addr was cast to uint! */
- val = mips_request ('i', addr, (unsigned int) 0, &err,
- mips_receive_wait, NULL);
- if (err)
- mips_error ("Can't read address 0x%s: %s",
- paddr_nz (addr), safe_strerror (errno));
- }
- return val;
-}
-
-/* Store a word to the target board. Returns errno code or zero for
- success. If OLD_CONTENTS is non-NULL, put the old contents of that
- memory location there. */
-
-/* FIXME! make sure only 32-bit quantities get stored! */
-static int
-mips_store_word (addr, val, old_contents)
- CORE_ADDR addr;
- unsigned int val;
- char *old_contents;
-{
- int err;
- unsigned int oldcontents;
-
- oldcontents = mips_request ('D', addr, (unsigned int) val,
- &err,
- mips_receive_wait, NULL);
- if (err)
- {
- /* Data space failed; try instruction space. */
- oldcontents = mips_request ('I', addr,
- (unsigned int) val, &err,
- mips_receive_wait, NULL);
- if (err)
- return errno;
- }
- if (old_contents != NULL)
- store_unsigned_integer (old_contents, 4, oldcontents);
- return 0;
-}
-
-/* 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. Note that protocol gives us the correct value
- for a longword, since it transfers values in ASCII. We want the
- byte values, so we have to swap the longword values. */
-
-static int
-mips_xfer_memory (memaddr, myaddr, len, write, ignore)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *ignore;
-{
- register int i;
- /* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr &~ 3;
- /* Round ending address up; get number of longwords that makes. */
- register int count = (((memaddr + len) - addr) + 3) / 4;
- /* Allocate buffer of that many longwords. */
- register char *buffer = alloca (count * 4);
-
- int status;
-
- if (write)
- {
- /* Fill start and end extra bytes of buffer with existing data. */
- if (addr != memaddr || len < 4)
- {
- /* Need part of initial word -- fetch it. */
- store_unsigned_integer (&buffer[0], 4, mips_fetch_word (addr));
- }
-
- if (count > 1)
- {
- /* Need part of last word -- fetch it. FIXME: we do this even
- if we don't need it. */
- store_unsigned_integer (&buffer[(count - 1) * 4], 4,
- mips_fetch_word (addr + (count - 1) * 4));
- }
-
- /* Copy data to be written over corresponding part of buffer */
-
- memcpy ((char *) buffer + (memaddr & 3), myaddr, len);
-
- /* Write the entire buffer. */
-
- for (i = 0; i < count; i++, addr += 4)
- {
- status = mips_store_word (addr,
- extract_unsigned_integer (&buffer[i*4], 4),
- NULL);
- /* Report each kilobyte (we download 32-bit words at a time) */
- if (i % 256 == 255)
- {
- printf_unfiltered ("*");
- gdb_flush (gdb_stdout);
- }
- if (status)
- {
- errno = status;
- return 0;
- }
- /* FIXME: Do we want a QUIT here? */
- }
- if (count >= 256)
- printf_unfiltered ("\n");
- }
- else
- {
- /* Read all the longwords */
- for (i = 0; i < count; i++, addr += 4)
- {
- store_unsigned_integer (&buffer[i*4], 4, mips_fetch_word (addr));
- QUIT;
- }
-
- /* Copy appropriate bytes out of the buffer. */
- memcpy (myaddr, buffer + (memaddr & 3), len);
- }
- return len;
-}
-
-/* Print info on this target. */
-
-static void
-mips_files_info (ignore)
- struct target_ops *ignore;
-{
- printf_unfiltered ("Debugging a MIPS board over a serial line.\n");
-}
-
-/* Kill the process running on the board. This will actually only
- work if we are doing remote debugging over the console input. I
- think that if IDT/sim had the remote debug interrupt enabled on the
- right port, we could interrupt the process with a break signal. */
-
-static void
-mips_kill ()
-{
- if (!mips_wait_flag)
- return;
-
- interrupt_count++;
-
- if (interrupt_count >= 2)
- {
- interrupt_count = 0;
-
- target_terminal_ours ();
-
- if (query ("Interrupted while waiting for the program.\n\
-Give up (and stop debugging it)? "))
- {
- /* Clean up in such a way that mips_close won't try to talk to the
- board (it almost surely won't work since we weren't able to talk to
- it). */
- mips_wait_flag = 0;
- close_ports();
-
- printf_unfiltered ("Ending remote MIPS debugging.\n");
- target_mourn_inferior ();
-
- return_to_top_level (RETURN_QUIT);
- }
-
- target_terminal_inferior ();
- }
-
- if (remote_debug > 0)
- printf_unfiltered ("Sending break\n");
-
- SERIAL_SEND_BREAK (mips_desc);
-
-#if 0
- if (mips_is_open)
- {
- char cc;
-
- /* Send a ^C. */
- cc = '\003';
- SERIAL_WRITE (mips_desc, &cc, 1);
- sleep (1);
- target_mourn_inferior ();
- }
-#endif
-}
-
-/* Start running on the target board. */
-
-static void
-mips_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- CORE_ADDR entry_pt;
-
- if (args && *args)
- {
- warning ("\
-Can't pass arguments to remote MIPS board; arguments ignored.");
- /* And don't try to use them on the next "run" command. */
- execute_command ("set args", 0);
- }
-
- if (execfile == 0 || exec_bfd == 0)
- error ("No executable file specified");
-
- entry_pt = (CORE_ADDR) bfd_get_start_address (exec_bfd);
-
- init_wait_for_inferior ();
-
- /* FIXME: Should we set inferior_pid here? */
-
- proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-/* Clean up after a process. Actually nothing to do. */
-
-static void
-mips_mourn_inferior ()
-{
- if (current_ops != NULL)
- unpush_target (current_ops);
- generic_mourn_inferior ();
-}
-
-/* We can write a breakpoint and read the shadow contents in one
- operation. */
-
-/* Insert a breakpoint. On targets that don't have built-in 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 (this
- is accomplished via BREAKPOINT_MAX). */
-
-static int
-mips_insert_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- if (monitor_supports_breakpoints)
- return set_breakpoint (addr, MIPS_INSTLEN, BREAK_FETCH);
- else
- return memory_insert_breakpoint (addr, contents_cache);
-}
-
-static int
-mips_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- if (monitor_supports_breakpoints)
- return clear_breakpoint (addr, MIPS_INSTLEN, BREAK_FETCH);
- else
- return memory_remove_breakpoint (addr, contents_cache);
-}
-
-#if 0 /* currently not used */
-/* PMON does not currently provide support for the debug mode 'b'
- commands to manipulate breakpoints. However, if we wanted to use
- the monitor breakpoints (rather than the GDB BREAK_INSN version)
- then this code performs the work needed to leave debug mode,
- set/clear the breakpoint, and then return to debug mode. */
-
-#define PMON_MAX_BP (33) /* 32 SW, 1 HW */
-static CORE_ADDR mips_pmon_bp_info[PMON_MAX_BP];
-/* NOTE: The code relies on this vector being zero-initialised by the system */
-
-static int
-pmon_insert_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- int status;
-
- if (monitor_supports_breakpoints)
- {
- char tbuff[12]; /* space for breakpoint command */
- int bpnum;
- CORE_ADDR bpaddr;
-
- /* PMON does not support debug level breakpoint set/remove: */
- if (mips_exit_debug ())
- mips_error ("Failed to exit debug mode");
-
- sprintf (tbuff, "b %08x\r", addr);
- mips_send_command (tbuff, 0);
-
- mips_expect ("Bpt ");
-
- if (!mips_getstring (tbuff, 2))
- return 1;
- tbuff[2] = '\0'; /* terminate the string */
- if (sscanf (tbuff, "%d", &bpnum) != 1)
- {
- fprintf_unfiltered (gdb_stderr,
- "Invalid decimal breakpoint number from target: %s\n", tbuff);
- return 1;
- }
-
- mips_expect (" = ");
-
- /* Lead in the hex number we are expecting: */
- tbuff[0] = '0';
- tbuff[1] = 'x';
-
- /* FIXME!! only 8 bytes! need to expand for Bfd64;
- which targets return 64-bit addresses? PMON returns only 32! */
- if (!mips_getstring (&tbuff[2], 8))
- return 1;
- tbuff[10] = '\0'; /* terminate the string */
-
- if (sscanf (tbuff, "0x%08x", &bpaddr) != 1)
- {
- fprintf_unfiltered (gdb_stderr,
- "Invalid hex address from target: %s\n", tbuff);
- return 1;
- }
-
- if (bpnum >= PMON_MAX_BP)
- {
- fprintf_unfiltered (gdb_stderr,
- "Error: Returned breakpoint number %d outside acceptable range (0..%d)\n",
- bpnum, PMON_MAX_BP - 1);
- return 1;
- }
-
- if (bpaddr != addr)
- fprintf_unfiltered (gdb_stderr, "Warning: Breakpoint addresses do not match: 0x%x != 0x%x\n", addr, bpaddr);
-
- mips_pmon_bp_info[bpnum] = bpaddr;
-
- mips_expect ("\r\n");
- mips_expect (mips_monitor_prompt);
-
- mips_enter_debug ();
-
- return 0;
- }
-
- return mips_store_word (addr, BREAK_INSN, contents_cache);
-}
-
-static int
-pmon_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- if (monitor_supports_breakpoints)
- {
- int bpnum;
- char tbuff[7]; /* enough for delete breakpoint command */
-
- for (bpnum = 0; bpnum < PMON_MAX_BP; bpnum++)
- if (mips_pmon_bp_info[bpnum] == addr)
- break;
-
- if (bpnum >= PMON_MAX_BP)
- {
- fprintf_unfiltered (gdb_stderr,
- "pmon_remove_breakpoint: Failed to find breakpoint at address 0x%s\n",
- paddr_nz (addr));
- return 1;
- }
-
- if (mips_exit_debug ())
- mips_error ("Failed to exit debug mode");
-
- sprintf (tbuff, "db %02d\r", bpnum);
-
- mips_send_command (tbuff, -1);
- /* NOTE: If the breakpoint does not exist then a "Bpt <dd> not
- set" message will be returned. */
-
- mips_enter_debug ();
-
- return 0;
- }
-
- return target_write_memory (addr, contents_cache, BREAK_INSN_SIZE);
-}
-#endif
-
-
-/* Tell whether this target can support a hardware breakpoint. CNT
- is the number of hardware breakpoints already installed. This
- implements the TARGET_CAN_USE_HARDWARE_WATCHPOINT macro. */
-
-int
-remote_mips_can_use_hardware_watchpoint (cnt)
- int cnt;
-{
- return cnt < MAX_LSI_BREAKPOINTS && strcmp (target_shortname, "lsi") == 0;
-}
-
-
-/* Compute a don't care mask for the region bounding ADDR and ADDR + LEN - 1.
- This is used for memory ref breakpoints. */
-
-static unsigned long
-calculate_mask (addr, len)
- CORE_ADDR addr;
- int len;
-{
- unsigned long mask;
- int i;
-
- mask = addr ^ (addr + len - 1);
-
- for (i = 32; i >= 0; i--)
- if (mask == 0)
- break;
- else
- mask >>= 1;
-
- mask = (unsigned long) 0xffffffff >> i;
-
- return mask;
-}
-
-
-/* Insert a hardware breakpoint. This works only on LSI targets, which
- implement ordinary breakpoints using hardware facilities. */
-
-int
-remote_mips_insert_hw_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- if (strcmp (target_shortname, "lsi") == 0)
- return mips_insert_breakpoint (addr, contents_cache);
- else
- return -1;
-}
-
-
-/* Remove a hardware breakpoint. This works only on LSI targets, which
- implement ordinary breakpoints using hardware facilities. */
-
-int
-remote_mips_remove_hw_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- if (strcmp (target_shortname, "lsi") == 0)
- return mips_remove_breakpoint (addr, contents_cache);
- else
- return -1;
-}
-
-/* Set a data watchpoint. ADDR and LEN should be obvious. TYPE is 0
- for a write watchpoint, 1 for a read watchpoint, or 2 for a read/write
- watchpoint. */
-
-int
-remote_mips_set_watchpoint (addr, len, type)
- CORE_ADDR addr;
- int len;
- int type;
-{
- if (set_breakpoint (addr, len, type))
- return -1;
-
- return 0;
-}
-
-int
-remote_mips_remove_watchpoint (addr, len, type)
- CORE_ADDR addr;
- int len;
- int type;
-{
- if (clear_breakpoint (addr, len, type))
- return -1;
-
- return 0;
-}
-
-int
-remote_mips_stopped_by_watchpoint ()
-{
- return hit_watchpoint;
-}
-
-
-/* Insert a breakpoint. */
-
-static int
-set_breakpoint (addr, len, type)
- CORE_ADDR addr;
- int len;
- enum break_type type;
-{
- return common_breakpoint (1, addr, len, type);
-}
-
-
-/* Clear a breakpoint. */
-
-static int
-clear_breakpoint (addr, len, type)
- CORE_ADDR addr;
- int len;
- enum break_type type;
-{
- return common_breakpoint (0, addr, len, type);
-}
-
-
-/* Check the error code from the return packet for an LSI breakpoint
- command. If there's no error, just return 0. If it's a warning,
- print the warning text and return 0. If it's an error, print
- the error text and return 1. <ADDR> is the address of the breakpoint
- that was being set. <RERRFLG> is the error code returned by PMON.
- This is a helper function for common_breakpoint. */
-
-static int
-check_lsi_error (addr, rerrflg)
- CORE_ADDR addr;
- int rerrflg;
-{
- struct lsi_error *err;
- char *saddr = paddr_nz (addr); /* printable address string */
-
- if (rerrflg == 0) /* no error */
- return 0;
-
- /* Warnings can be ORed together, so check them all. */
- if (rerrflg & W_WARN)
- {
- if (monitor_warnings)
- {
- int found = 0;
- for (err = lsi_warning_table; err->code != 0; err++)
- {
- if ((err->code & rerrflg) == err->code)
- {
- found = 1;
- fprintf_unfiltered (gdb_stderr,
- "common_breakpoint (0x%s): Warning: %s\n",
- saddr,
- err->string);
- }
- }
- if (!found)
- fprintf_unfiltered (gdb_stderr,
- "common_breakpoint (0x%s): Unknown warning: 0x%x\n",
- saddr,
- rerrflg);
- }
- return 0;
- }
-
- /* Errors are unique, i.e. can't be ORed together. */
- for (err = lsi_error_table; err->code != 0; err++)
- {
- if ((err->code & rerrflg) == err->code)
- {
- fprintf_unfiltered (gdb_stderr,
- "common_breakpoint (0x%s): Error: %s\n",
- saddr,
- err->string);
- return 1;
- }
- }
- fprintf_unfiltered (gdb_stderr,
- "common_breakpoint (0x%s): Unknown error: 0x%x\n",
- saddr,
- rerrflg);
- return 1;
-}
-
-
-/* This routine sends a breakpoint command to the remote target.
-
- <SET> is 1 if setting a breakpoint, or 0 if clearing a breakpoint.
- <ADDR> is the address of the breakpoint.
- <LEN> the length of the region to break on.
- <TYPE> is the type of breakpoint:
- 0 = write (BREAK_WRITE)
- 1 = read (BREAK_READ)
- 2 = read/write (BREAK_ACCESS)
- 3 = instruction fetch (BREAK_FETCH)
-
- Return 0 if successful; otherwise 1. */
-
-static int
-common_breakpoint (set, addr, len, type)
- int set;
- CORE_ADDR addr;
- int len;
- enum break_type type;
-{
- char buf[DATA_MAXLEN + 1];
- char cmd, rcmd;
- int rpid, rerrflg, rresponse, rlen;
- int nfields;
-
- addr = ADDR_BITS_REMOVE (addr);
-
- if (mips_monitor == MON_LSI)
- {
- if (set == 0) /* clear breakpoint */
- {
- /* The LSI PMON "clear breakpoint" has this form:
- <pid> 'b' <bptn> 0x0
- reply:
- <pid> 'b' 0x0 <code>
-
- <bptn> is a breakpoint number returned by an earlier 'B' command.
- Possible return codes: OK, E_BPT. */
-
- int i;
-
- /* Search for the breakpoint in the table. */
- for (i = 0; i < MAX_LSI_BREAKPOINTS; i++)
- if (lsi_breakpoints[i].type == type
- && lsi_breakpoints[i].addr == addr
- && lsi_breakpoints[i].len == len)
- break;
-
- /* Clear the table entry and tell PMON to clear the breakpoint. */
- if (i == MAX_LSI_BREAKPOINTS)
- {
- warning ("common_breakpoint: Attempt to clear bogus breakpoint at %s\n",
- paddr_nz (addr));
- return 1;
- }
-
- lsi_breakpoints[i].type = BREAK_UNUSED;
- sprintf (buf, "0x0 b 0x%x 0x0", i);
- mips_send_packet (buf, 1);
-
- rlen = mips_receive_packet (buf, 1, mips_receive_wait);
- buf[rlen] = '\0';
-
- nfields = sscanf (buf, "0x%x b 0x0 0x%x", &rpid, &rerrflg);
- if (nfields != 2)
- mips_error ("common_breakpoint: Bad response from remote board: %s", buf);
-
- return (check_lsi_error (addr, rerrflg));
- }
- else /* set a breakpoint */
- {
- /* The LSI PMON "set breakpoint" command has this form:
- <pid> 'B' <addr> 0x0
- reply:
- <pid> 'B' <bptn> <code>
-
- The "set data breakpoint" command has this form:
-
- <pid> 'A' <addr1> <type> [<addr2> [<value>]]
-
- where: type= "0x1" = read
- "0x2" = write
- "0x3" = access (read or write)
-
- The reply returns two values:
- bptn - a breakpoint number, which is a small integer with
- possible values of zero through 255.
- code - an error return code, a value of zero indicates a
- succesful completion, other values indicate various
- errors and warnings.
-
- Possible return codes: OK, W_QAL, E_QAL, E_OUT, E_NON.
-
- */
-
- if (type == BREAK_FETCH) /* instruction breakpoint */
- {
- cmd = 'B';
- sprintf (buf, "0x0 B 0x%s 0x0", paddr_nz (addr));
- }
- else /* watchpoint */
- {
- cmd = 'A';
- sprintf (buf, "0x0 A 0x%s 0x%x 0x%s", paddr_nz (addr),
- type == BREAK_READ ? 1 : (type == BREAK_WRITE ? 2 : 3),
- paddr_nz (addr + len - 1));
- }
- mips_send_packet (buf, 1);
-
- rlen = mips_receive_packet (buf, 1, mips_receive_wait);
- buf[rlen] = '\0';
-
- nfields = sscanf (buf, "0x%x %c 0x%x 0x%x",
- &rpid, &rcmd, &rresponse, &rerrflg);
- if (nfields != 4 || rcmd != cmd || rresponse > 255)
- mips_error ("common_breakpoint: Bad response from remote board: %s", buf);
-
- if (rerrflg != 0)
- if (check_lsi_error (addr, rerrflg))
- return 1;
-
- /* rresponse contains PMON's breakpoint number. Record the
- information for this breakpoint so we can clear it later. */
- lsi_breakpoints[rresponse].type = type;
- lsi_breakpoints[rresponse].addr = addr;
- lsi_breakpoints[rresponse].len = len;
-
- return 0;
- }
- }
- else
- {
- /* On non-LSI targets, the breakpoint command has this form:
- 0x0 <CMD> <ADDR> <MASK> <FLAGS>
- <MASK> is a don't care mask for addresses.
- <FLAGS> is any combination of `r', `w', or `f' for read/write/fetch.
- */
- unsigned long mask;
-
- mask = calculate_mask (addr, len);
- addr &= ~mask;
-
- if (set) /* set a breakpoint */
- {
- char *flags;
- switch (type)
- {
- case BREAK_WRITE: /* write */
- flags = "w";
- break;
- case BREAK_READ: /* read */
- flags = "r";
- break;
- case BREAK_ACCESS: /* read/write */
- flags = "rw";
- break;
- case BREAK_FETCH: /* fetch */
- flags = "f";
- break;
- default:
- abort ();
- }
-
- cmd = 'B';
- sprintf (buf, "0x0 B 0x%s 0x%s %s", paddr_nz (addr),
- paddr_nz (mask), flags);
- }
- else
- {
- cmd = 'b';
- sprintf (buf, "0x0 b 0x%s", paddr_nz (addr));
- }
-
- mips_send_packet (buf, 1);
-
- rlen = mips_receive_packet (buf, 1, mips_receive_wait);
- buf[rlen] = '\0';
-
- nfields = sscanf (buf, "0x%x %c 0x%x 0x%x",
- &rpid, &rcmd, &rerrflg, &rresponse);
-
- if (nfields != 4 || rcmd != cmd)
- mips_error ("common_breakpoint: Bad response from remote board: %s",
- buf);
-
- if (rerrflg != 0)
- {
- /* Ddb returns "0x0 b 0x16 0x0\000", whereas
- Cogent returns "0x0 b 0xffffffff 0x16\000": */
- if (mips_monitor == MON_DDB)
- rresponse = rerrflg;
- if (rresponse != 22) /* invalid argument */
- fprintf_unfiltered (gdb_stderr,
- "common_breakpoint (0x%s): Got error: 0x%x\n",
- paddr_nz (addr), rresponse);
- return 1;
- }
- }
- return 0;
-}
-
-static void
-send_srec (srec, len, addr)
- char *srec;
- int len;
- CORE_ADDR addr;
-{
- while (1)
- {
- int ch;
-
- SERIAL_WRITE (mips_desc, srec, len);
-
- ch = mips_readchar (2);
-
- switch (ch)
- {
- case SERIAL_TIMEOUT:
- error ("Timeout during download.");
- break;
- case 0x6: /* ACK */
- return;
- case 0x15: /* NACK */
- fprintf_unfiltered (gdb_stderr, "Download got a NACK at byte %d! Retrying.\n", addr);
- continue;
- default:
- error ("Download got unexpected ack char: 0x%x, retrying.\n", ch);
- }
- }
-}
-
-/* Download a binary file by converting it to S records. */
-
-static void
-mips_load_srec (args)
- char *args;
-{
- bfd *abfd;
- asection *s;
- char *buffer, srec[1024];
- unsigned int i;
- unsigned int srec_frame = 200;
- int reclen;
- static int hashmark = 1;
-
- buffer = alloca (srec_frame * 2 + 256);
-
- abfd = bfd_openr (args, 0);
- if (!abfd)
- {
- printf_filtered ("Unable to open file %s\n", args);
- return;
- }
-
- if (bfd_check_format (abfd, bfd_object) == 0)
- {
- printf_filtered ("File is not an object file\n");
- return;
- }
-
-/* This actually causes a download in the IDT binary format: */
- mips_send_command (LOAD_CMD, 0);
-
- for (s = abfd->sections; s; s = s->next)
- {
- if (s->flags & SEC_LOAD)
- {
- unsigned int numbytes;
-
- /* FIXME! vma too small?? */
- printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, s->vma,
- s->vma + s->_raw_size);
- gdb_flush (gdb_stdout);
-
- for (i = 0; i < s->_raw_size; i += numbytes)
- {
- numbytes = min (srec_frame, s->_raw_size - i);
-
- bfd_get_section_contents (abfd, s, buffer, i, numbytes);
-
- reclen = mips_make_srec (srec, '3', s->vma + i, buffer, numbytes);
- send_srec (srec, reclen, s->vma + i);
-
- if (hashmark)
- {
- putchar_unfiltered ('#');
- gdb_flush (gdb_stdout);
- }
-
- } /* Per-packet (or S-record) loop */
-
- putchar_unfiltered ('\n');
- } /* Loadable sections */
- }
- if (hashmark)
- putchar_unfiltered ('\n');
-
- /* Write a type 7 terminator record. no data for a type 7, and there
- is no data, so len is 0. */
-
- reclen = mips_make_srec (srec, '7', abfd->start_address, NULL, 0);
-
- send_srec (srec, reclen, abfd->start_address);
-
- SERIAL_FLUSH_INPUT (mips_desc);
-}
-
-/*
- * mips_make_srec -- make an srecord. This writes each line, one at a
- * time, each with it's own header and trailer line.
- * An srecord looks like this:
- *
- * byte count-+ address
- * start ---+ | | data +- checksum
- * | | | |
- * S01000006F6B692D746573742E73726563E4
- * S315000448600000000000000000FC00005900000000E9
- * S31A0004000023C1400037DE00F023604000377B009020825000348D
- * S30B0004485A0000000000004E
- * S70500040000F6
- *
- * S<type><length><address><data><checksum>
- *
- * Where
- * - length
- * is the number of bytes following upto the checksum. Note that
- * this is not the number of chars following, since it takes two
- * chars to represent a byte.
- * - type
- * is one of:
- * 0) header record
- * 1) two byte address data record
- * 2) three byte address data record
- * 3) four byte address data record
- * 7) four byte address termination record
- * 8) three byte address termination record
- * 9) two byte address termination record
- *
- * - address
- * is the start address of the data following, or in the case of
- * a termination record, the start address of the image
- * - data
- * is the data.
- * - checksum
- * is the sum of all the raw byte data in the record, from the length
- * upwards, modulo 256 and subtracted from 255.
- *
- * This routine returns the length of the S-record.
- *
- */
-
-static int
-mips_make_srec (buf, type, memaddr, myaddr, len)
- char *buf;
- int type;
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- unsigned char checksum;
- int i;
-
- /* Create the header for the srec. addr_size is the number of bytes in the address,
- and 1 is the number of bytes in the count. */
-
- /* FIXME!! bigger buf required for 64-bit! */
- buf[0] = 'S';
- buf[1] = type;
- buf[2] = len + 4 + 1; /* len + 4 byte address + 1 byte checksum */
- /* This assumes S3 style downloads (4byte addresses). There should
- probably be a check, or the code changed to make it more
- explicit. */
- buf[3] = memaddr >> 24;
- buf[4] = memaddr >> 16;
- buf[5] = memaddr >> 8;
- buf[6] = memaddr;
- memcpy (&buf[7], myaddr, len);
-
- /* Note that the checksum is calculated on the raw data, not the
- hexified data. It includes the length, address and the data
- portions of the packet. */
- checksum = 0;
- buf += 2; /* Point at length byte */
- for (i = 0; i < len + 4 + 1; i++)
- checksum += *buf++;
-
- *buf = ~checksum;
-
- return len + 8;
-}
-
-/* The following manifest controls whether we enable the simple flow
- control support provided by the monitor. If enabled the code will
- wait for an affirmative ACK between transmitting packets. */
-#define DOETXACK (1)
-
-/* The PMON fast-download uses an encoded packet format constructed of
- 3byte data packets (encoded as 4 printable ASCII characters), and
- escape sequences (preceded by a '/'):
-
- 'K' clear checksum
- 'C' compare checksum (12bit value, not included in checksum calculation)
- 'S' define symbol name (for addr) terminated with "," and padded to 4char boundary
- 'Z' zero fill multiple of 3bytes
- 'B' byte (12bit encoded value, of 8bit data)
- 'A' address (36bit encoded value)
- 'E' define entry as original address, and exit load
-
- The packets are processed in 4 character chunks, so the escape
- sequences that do not have any data (or variable length data)
- should be padded to a 4 character boundary. The decoder will give
- an error if the complete message block size is not a multiple of
- 4bytes (size of record).
-
- The encoding of numbers is done in 6bit fields. The 6bit value is
- used to index into this string to get the specific character
- encoding for the value: */
-static char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.";
-
-/* Convert the number of bits required into an encoded number, 6bits
- at a time (range 0..63). Keep a checksum if required (passed
- pointer non-NULL). The function returns the number of encoded
- characters written into the buffer. */
-static int
-pmon_makeb64 (v, p, n, chksum)
- unsigned long v;
- char *p;
- int n;
- int *chksum;
-{
- int count = (n / 6);
-
- if ((n % 12) != 0) {
- fprintf_unfiltered(gdb_stderr,
- "Fast encoding bitcount must be a multiple of 12bits: %dbit%s\n",n,(n == 1)?"":"s");
- return(0);
- }
- if (n > 36) {
- fprintf_unfiltered(gdb_stderr,
- "Fast encoding cannot process more than 36bits at the moment: %dbits\n",n);
- return(0);
- }
-
- /* Deal with the checksum: */
- if (chksum != NULL) {
- switch (n) {
- case 36: *chksum += ((v >> 24) & 0xFFF);
- case 24: *chksum += ((v >> 12) & 0xFFF);
- case 12: *chksum += ((v >> 0) & 0xFFF);
- }
- }
-
- do {
- n -= 6;
- *p++ = encoding[(v >> n) & 0x3F];
- } while (n > 0);
-
- return(count);
-}
-
-/* Shorthand function (that could be in-lined) to output the zero-fill
- escape sequence into the data stream. */
-static int
-pmon_zeroset (recsize, buff, amount, chksum)
- int recsize;
- char **buff;
- int *amount;
- unsigned int *chksum;
-{
- int count;
-
- sprintf(*buff,"/Z");
- count = pmon_makeb64 (*amount, (*buff + 2), 12, chksum);
- *buff += (count + 2);
- *amount = 0;
- return(recsize + count + 2);
-}
-
-static int
-pmon_checkset (recsize, buff, value)
- int recsize;
- char **buff;
- int *value;
-{
- int count;
-
- /* Add the checksum (without updating the value): */
- sprintf (*buff, "/C");
- count = pmon_makeb64 (*value, (*buff + 2), 12, NULL);
- *buff += (count + 2);
- sprintf (*buff, "\n");
- *buff += 2; /* include zero terminator */
- /* Forcing a checksum validation clears the sum: */
- *value = 0;
- return(recsize + count + 3);
-}
-
-/* Amount of padding we leave after at the end of the output buffer,
- for the checksum and line termination characters: */
-#define CHECKSIZE (4 + 4 + 4 + 2)
-/* zero-fill, checksum, transfer end and line termination space. */
-
-/* The amount of binary data loaded from the object file in a single
- operation: */
-#define BINCHUNK (1024)
-
-/* Maximum line of data accepted by the monitor: */
-#define MAXRECSIZE (550)
-/* NOTE: This constant depends on the monitor being used. This value
- is for PMON 5.x on the Cogent Vr4300 board. */
-
-static void
-pmon_make_fastrec (outbuf, inbuf, inptr, inamount, recsize, csum, zerofill)
- char **outbuf;
- unsigned char *inbuf;
- int *inptr;
- int inamount;
- int *recsize;
- unsigned int *csum;
- unsigned int *zerofill;
-{
- int count = 0;
- char *p = *outbuf;
-
- /* This is a simple check to ensure that our data will fit within
- the maximum allowable record size. Each record output is 4bytes
- in length. We must allow space for a pending zero fill command,
- the record, and a checksum record. */
- while ((*recsize < (MAXRECSIZE - CHECKSIZE)) && ((inamount - *inptr) > 0)) {
- /* Process the binary data: */
- if ((inamount - *inptr) < 3) {
- if (*zerofill != 0)
- *recsize = pmon_zeroset (*recsize, &p, zerofill, csum);
- sprintf (p, "/B");
- count = pmon_makeb64 (inbuf[*inptr], &p[2], 12, csum);
- p += (2 + count);
- *recsize += (2 + count);
- (*inptr)++;
- } else {
- unsigned int value = ((inbuf[*inptr + 0] << 16) | (inbuf[*inptr + 1] << 8) | inbuf[*inptr + 2]);
- /* Simple check for zero data. TODO: A better check would be
- to check the last, and then the middle byte for being zero
- (if the first byte is not). We could then check for
- following runs of zeros, and if above a certain size it is
- worth the 4 or 8 character hit of the byte insertions used
- to pad to the start of the zeroes. NOTE: This also depends
- on the alignment at the end of the zero run. */
- if (value == 0x00000000) {
- (*zerofill)++;
- if (*zerofill == 0xFFF) /* 12bit counter */
- *recsize = pmon_zeroset (*recsize, &p, zerofill, csum);
- }else {
- if (*zerofill != 0)
- *recsize = pmon_zeroset (*recsize, &p, zerofill, csum);
- count = pmon_makeb64 (value, p, 24, csum);
- p += count;
- *recsize += count;
- }
- *inptr += 3;
- }
- }
-
- *outbuf = p;
- return;
-}
-
-static int
-pmon_check_ack(mesg)
- char *mesg;
-{
-#if defined(DOETXACK)
- int c;
-
- if (!tftp_in_use)
- {
- c = SERIAL_READCHAR (udp_in_use ? udp_desc : mips_desc, 2);
- if ((c == SERIAL_TIMEOUT) || (c != 0x06))
- {
- fprintf_unfiltered (gdb_stderr,
- "Failed to receive valid ACK for %s\n", mesg);
- return(-1); /* terminate the download */
- }
- }
-#endif /* DOETXACK */
- return(0);
-}
-
-/* pmon_download - Send a sequence of characters to the PMON download port,
- which is either a serial port or a UDP socket. */
-
-static void
-pmon_start_download ()
-{
- if (tftp_in_use)
- {
- /* Create the temporary download file. */
- if ((tftp_file = fopen (tftp_localname, "w")) == NULL)
- perror_with_name (tftp_localname);
- }
- else
- {
- mips_send_command (udp_in_use ? LOAD_CMD_UDP : LOAD_CMD, 0);
- mips_expect ("Downloading from ");
- mips_expect (udp_in_use ? "udp" : "tty0");
- mips_expect (", ^C to abort\r\n");
- }
-}
-
-static int
-mips_expect_download (char *string)
-{
- if (!mips_expect (string))
- {
- fprintf_unfiltered (gdb_stderr, "Load did not complete successfully.\n");
- if (tftp_in_use)
- remove (tftp_localname); /* Remove temporary file */
- return 0;
- }
- else
- return 1;
-}
-
-static void
-pmon_end_download (final, bintotal)
- int final;
- int bintotal;
-{
- char hexnumber[9]; /* includes '\0' space */
-
- if (tftp_in_use)
- {
- static char *load_cmd_prefix = "load -b -s ";
- char *cmd;
- struct stat stbuf;
-
- /* Close off the temporary file containing the load data. */
- fclose (tftp_file);
- tftp_file = NULL;
-
- /* Make the temporary file readable by the world. */
- if (stat (tftp_localname, &stbuf) == 0)
- chmod (tftp_localname, stbuf.st_mode | S_IROTH);
-
- /* Must reinitialize the board to prevent PMON from crashing. */
- mips_send_command ("initEther\r", -1);
-
- /* Send the load command. */
- cmd = xmalloc (strlen (load_cmd_prefix) + strlen (tftp_name) + 2);
- strcpy (cmd, load_cmd_prefix);
- strcat (cmd, tftp_name);
- strcat (cmd, "\r");
- mips_send_command (cmd, 0);
- free (cmd);
- if (!mips_expect_download ("Downloading from "))
- return;
- if (!mips_expect_download (tftp_name))
- return;
- if (!mips_expect_download (", ^C to abort\r\n"))
- return;
- }
-
- /* Wait for the stuff that PMON prints after the load has completed.
- The timeout value for use in the tftp case (15 seconds) was picked
- arbitrarily but might be too small for really large downloads. FIXME. */
- if (mips_monitor == MON_LSI)
- {
- pmon_check_ack ("termination");
- mips_expect_timeout ("Entry address is ", tftp_in_use ? 15 : 2);
- }
- else
- mips_expect_timeout ("Entry Address = ", tftp_in_use ? 15 : 2);
-
- sprintf (hexnumber,"%x",final);
- mips_expect (hexnumber);
- mips_expect ("\r\n");
- if (mips_monitor != MON_LSI)
- pmon_check_ack ("termination");
- mips_expect ("\r\ntotal = 0x");
- sprintf (hexnumber,"%x",bintotal);
- mips_expect (hexnumber);
- if (!mips_expect_download (" bytes\r\n"))
- return;
-
- if (tftp_in_use)
- remove (tftp_localname); /* Remove temporary file */
-}
-
-static void
-pmon_download (buffer, length)
- char *buffer;
- int length;
-{
- if (tftp_in_use)
- fwrite (buffer, 1, length, tftp_file);
- else
- SERIAL_WRITE (udp_in_use ? udp_desc : mips_desc, buffer, length);
-}
-
-static void
-pmon_load_fast (file)
- char *file;
-{
- bfd *abfd;
- asection *s;
- unsigned char *binbuf;
- char *buffer;
- int reclen;
- unsigned int csum = 0;
- int hashmark = !tftp_in_use;
- int bintotal = 0;
- int final = 0;
- int finished = 0;
-
- buffer = (char *)xmalloc(MAXRECSIZE + 1);
- binbuf = (unsigned char *)xmalloc(BINCHUNK);
-
- abfd = bfd_openr(file,0);
- if (!abfd)
- {
- printf_filtered ("Unable to open file %s\n",file);
- return;
- }
-
- if (bfd_check_format(abfd,bfd_object) == 0)
- {
- printf_filtered("File is not an object file\n");
- return;
- }
-
- /* Setup the required download state: */
- mips_send_command ("set dlproto etxack\r", -1);
- mips_send_command ("set dlecho off\r", -1);
- /* NOTE: We get a "cannot set variable" message if the variable is
- already defined to have the argument we give. The code doesn't
- care, since it just scans to the next prompt anyway. */
- /* Start the download: */
- pmon_start_download();
-
- /* Zero the checksum */
- sprintf(buffer,"/Kxx\n");
- reclen = strlen(buffer);
- pmon_download (buffer, reclen);
- finished = pmon_check_ack("/Kxx");
-
- for (s = abfd->sections; s && !finished; s = s->next)
- if (s->flags & SEC_LOAD) /* only deal with loadable sections */
- {
- bintotal += s->_raw_size;
- final = (s->vma + s->_raw_size);
-
- printf_filtered ("%s\t: 0x%4x .. 0x%4x ", s->name, (unsigned int)s->vma,
- (unsigned int)(s->vma + s->_raw_size));
- gdb_flush (gdb_stdout);
-
- /* Output the starting address */
- sprintf(buffer,"/A");
- reclen = pmon_makeb64(s->vma,&buffer[2],36,&csum);
- buffer[2 + reclen] = '\n';
- buffer[3 + reclen] = '\0';
- reclen += 3; /* for the initial escape code and carriage return */
- pmon_download (buffer, reclen);
- finished = pmon_check_ack("/A");
-
- if (!finished)
- {
- unsigned int binamount;
- unsigned int zerofill = 0;
- char *bp = buffer;
- unsigned int i;
-
- reclen = 0;
-
- for (i = 0; ((i < s->_raw_size) && !finished); i += binamount) {
- int binptr = 0;
-
- binamount = min (BINCHUNK, s->_raw_size - i);
-
- bfd_get_section_contents (abfd, s, binbuf, i, binamount);
-
- /* This keeps a rolling checksum, until we decide to output
- the line: */
- for (; ((binamount - binptr) > 0);) {
- pmon_make_fastrec (&bp, binbuf, &binptr, binamount, &reclen, &csum, &zerofill);
- if (reclen >= (MAXRECSIZE - CHECKSIZE)) {
- reclen = pmon_checkset (reclen, &bp, &csum);
- pmon_download (buffer, reclen);
- finished = pmon_check_ack("data record");
- if (finished) {
- zerofill = 0; /* do not transmit pending zerofills */
- break;
- }
-
- if (hashmark) {
- putchar_unfiltered ('#');
- gdb_flush (gdb_stdout);
- }
-
- bp = buffer;
- reclen = 0; /* buffer processed */
- }
- }
- }
-
- /* Ensure no out-standing zerofill requests: */
- if (zerofill != 0)
- reclen = pmon_zeroset (reclen, &bp, &zerofill, &csum);
-
- /* and then flush the line: */
- if (reclen > 0) {
- reclen = pmon_checkset (reclen, &bp, &csum);
- /* Currently pmon_checkset outputs the line terminator by
- default, so we write out the buffer so far: */
- pmon_download (buffer, reclen);
- finished = pmon_check_ack("record remnant");
- }
- }
-
- putchar_unfiltered ('\n');
- }
-
- /* Terminate the transfer. We know that we have an empty output
- buffer at this point. */
- sprintf (buffer, "/E/E\n"); /* include dummy padding characters */
- reclen = strlen (buffer);
- pmon_download (buffer, reclen);
-
- if (finished) { /* Ignore the termination message: */
- SERIAL_FLUSH_INPUT (udp_in_use ? udp_desc : mips_desc);
- } else { /* Deal with termination message: */
- pmon_end_download (final, bintotal);
- }
-
- return;
-}
-
-/* mips_load -- download a file. */
-
-static void
-mips_load (file, from_tty)
- char *file;
- int from_tty;
-{
- /* Get the board out of remote debugging mode. */
- if (mips_exit_debug ())
- error ("mips_load: Couldn't get into monitor mode.");
-
- if (mips_monitor != MON_IDT)
- pmon_load_fast (file);
- else
- mips_load_srec (file);
-
- mips_initialize ();
-
- /* Finally, make the PC point at the start address */
- if (mips_monitor != MON_IDT)
- {
- /* Work around problem where PMON monitor updates the PC after a load
- to a different value than GDB thinks it has. The following ensures
- that the write_pc() WILL update the PC value: */
- register_valid[PC_REGNUM] = 0;
- }
- if (exec_bfd)
- write_pc (bfd_get_start_address (exec_bfd));
-
- inferior_pid = 0; /* No process now */
-
-/* This is necessary because many things were based on the PC at the time that
- we attached to the monitor, which is no longer valid now that we have loaded
- new code (and just changed the PC). Another way to do this might be to call
- normal_stop, except that the stack may not be valid, and things would get
- horribly confused... */
-
- clear_symtab_users ();
-}
-
-
-/* Pass the command argument as a packet to PMON verbatim. */
-
-static void
-pmon_command (args, from_tty)
- char *args;
- int from_tty;
-{
- char buf[DATA_MAXLEN + 1];
- int rlen;
-
- sprintf (buf, "0x0 %s", args);
- mips_send_packet (buf, 1);
- printf_filtered ("Send packet: %s\n", buf);
-
- rlen = mips_receive_packet (buf, 1, mips_receive_wait);
- buf[rlen] = '\0';
- printf_filtered ("Received packet: %s\n", buf);
-}
-
-void
-_initialize_remote_mips ()
-{
- /* Initialize the fields in mips_ops that are common to all four targets. */
- mips_ops.to_longname = "Remote MIPS debugging over serial line";
- mips_ops.to_close = mips_close;
- mips_ops.to_detach = mips_detach;
- mips_ops.to_resume = mips_resume;
- mips_ops.to_fetch_registers = mips_fetch_registers;
- mips_ops.to_store_registers = mips_store_registers;
- mips_ops.to_prepare_to_store = mips_prepare_to_store;
- mips_ops.to_xfer_memory = mips_xfer_memory;
- mips_ops.to_files_info = mips_files_info;
- mips_ops.to_insert_breakpoint = mips_insert_breakpoint;
- mips_ops.to_remove_breakpoint = mips_remove_breakpoint;
- mips_ops.to_kill = mips_kill;
- mips_ops.to_load = mips_load;
- mips_ops.to_create_inferior = mips_create_inferior;
- mips_ops.to_mourn_inferior = mips_mourn_inferior;
- mips_ops.to_stratum = process_stratum;
- mips_ops.to_has_all_memory = 1;
- mips_ops.to_has_memory = 1;
- mips_ops.to_has_stack = 1;
- mips_ops.to_has_registers = 1;
- mips_ops.to_has_execution = 1;
- mips_ops.to_magic = OPS_MAGIC;
-
- /* Copy the common fields to all four target vectors. */
- pmon_ops = ddb_ops = lsi_ops = mips_ops;
-
- /* Initialize target-specific fields in the target vectors. */
- mips_ops.to_shortname = "mips";
- mips_ops.to_doc = "\
-Debug a board using the MIPS remote debugging protocol over a serial line.\n\
-The argument is the device it is connected to or, if it contains a colon,\n\
-HOST:PORT to access a board over a network";
- mips_ops.to_open = mips_open;
- mips_ops.to_wait = mips_wait;
-
- pmon_ops.to_shortname = "pmon";
- pmon_ops.to_doc = "\
-Debug a board using the PMON MIPS remote debugging protocol over a serial\n\
-line. The argument is the device it is connected to or, if it contains a\n\
-colon, HOST:PORT to access a board over a network";
- pmon_ops.to_open = pmon_open;
- pmon_ops.to_wait = mips_wait;
-
- ddb_ops.to_shortname = "ddb";
- ddb_ops.to_doc = "\
-Debug a board using the PMON MIPS remote debugging protocol over a serial\n\
-line. The first argument is the device it is connected to or, if it contains\n\
-a colon, HOST:PORT to access a board over a network. The optional second\n\
-parameter is the temporary file in the form HOST:FILENAME to be used for\n\
-TFTP downloads to the board. The optional third parameter is the local name\n\
-of the TFTP temporary file, if it differs from the filename seen by the board.";
- ddb_ops.to_open = ddb_open;
- ddb_ops.to_wait = mips_wait;
-
- lsi_ops.to_shortname = "lsi";
- lsi_ops.to_doc = pmon_ops.to_doc;
- lsi_ops.to_open = lsi_open;
- lsi_ops.to_wait = mips_wait;
-
- /* Add the targets. */
- add_target (&mips_ops);
- add_target (&pmon_ops);
- add_target (&ddb_ops);
- add_target (&lsi_ops);
-
- add_show_from_set (
- add_set_cmd ("timeout", no_class, var_zinteger,
- (char *) &mips_receive_wait,
- "Set timeout in seconds for remote MIPS serial I/O.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("retransmit-timeout", no_class, var_zinteger,
- (char *) &mips_retransmit_wait,
- "Set retransmit timeout in seconds for remote MIPS serial I/O.\n\
-This is the number of seconds to wait for an acknowledgement to a packet\n\
-before resending the packet.", &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("syn-garbage-limit", no_class, var_zinteger,
- (char *) &mips_syn_garbage,
-"Set the maximum number of characters to ignore when scanning for a SYN.\n\
-This is the maximum number of characters GDB will ignore when trying to\n\
-synchronize with the remote system. A value of -1 means that there is no limit\n\
-(Note that these characters are printed out even though they are ignored.)",
- &setlist),
- &showlist);
-
- add_show_from_set
- (add_set_cmd ("monitor-prompt", class_obscure, var_string,
- (char *) &mips_monitor_prompt,
- "Set the prompt that GDB expects from the monitor.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("monitor-warnings", class_obscure, var_zinteger,
- (char *)&monitor_warnings,
- "Set printing of monitor warnings.\n"
- "When enabled, monitor warnings about hardware breakpoints "
- "will be displayed.",
- &setlist),
- &showlist);
-
- add_com ("pmon <command>", class_obscure, pmon_command,
- "Send a packet to PMON (must be in debug mode).");
-}
diff --git a/contrib/gdb/gdb/remote-mm.c b/contrib/gdb/gdb/remote-mm.c
deleted file mode 100644
index 19455b4..0000000
--- a/contrib/gdb/gdb/remote-mm.c
+++ /dev/null
@@ -1,1673 +0,0 @@
-/* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB.
- Copyright 1990, 1991, 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 "defs.h"
-#include "inferior.h"
-#include "wait.h"
-#include "value.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include "gdb_string.h"
-#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 DRAIN_INPUT() (msg_recv_serial((union msg_t*)0))
-
-extern int stop_soon_quietly; /* for wait_for_inferior */
-
-static void mm_resume();
-static void mm_fetch_registers ();
-static int fetch_register ();
-static void 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();
-
-#define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400)
-#define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
-
-/* FIXME: Replace with `set remotedebug'. */
-#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];
-
- if (args && *args)
- error ("Can't pass arguments to remote mm process (yet).");
-
- if (execfile == 0 /* || exec_bfd == 0 */ )
- error ("No executable 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. */
- init_wait_for_inferior ();
- clear_proceed_status ();
- stop_soon_quietly = 1;
- proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
- normal_stop ();
-}
-/**************************************************** REMOTE_MOURN_INFERIOR */
-static void
-mm_mourn()
-{
- pop_target (); /* Pop back to no-child state */
- generic_mourn_inferior ();
-}
-
-/********************************************************************** 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;
-
- /* 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 : <command> <serial-device> <baud-rate> [progname]");
- dev_name = (char*)xmalloc (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);
-
- a29k_get_processor_type ();
-
- /* Print out some stuff, letting the user now what's going on */
- printf_filtered("Connected to MiniMon via %s.\n", 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 != a29k_freeze_mode) {
- fprintf_filtered(gdb_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 */
-}
-
-/**************************************************************** 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;
-{
- 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");
-}
-
-/************************************************************* 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;
-{
-
- if (!mm_stream)
- error ("MiniMon not opened yet, use the 'target minimon' command.\n");
-
- 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);
-}
-/********************************************************** 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;
-{
- 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 */
-}
-
-
-/*************************************************************** REMOTE_RESUME
-** Tell the remote machine to resume. */
-
-static void
-mm_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
-{
- if (sig != TARGET_SIGNAL_0)
- warning ("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);
- }
-}
-
-/***************************************************************** REMOTE_WAIT
-** Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-static int
-mm_wait (status)
- struct target_waitstatus *status;
-{
- int i, result;
- int old_timeout = timeout;
- int old_immediate_quit = immediate_quit;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 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);
- gdb_flush(gdb_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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- 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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_BUS;
- }
- 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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_FPE;
- }
- 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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ILL;
- }
- 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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_SEGV;
- }
- 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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ILL;
- }
- 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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ALRM;
- }
- else if (in_msg_buf->halt_msg.trap_number== 15)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- 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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_INT;
- }
- 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);
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ILL;
- } /* BREAK message was sent */
- else if (in_msg_buf->halt_msg.trap_number== 75)
- {
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- }
- else
-exit:
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
-
- timeout = old_timeout; /* Restore original timeout value */
- immediate_quit = old_immediate_quit;
- 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;
- }
-
-/* 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; regno<GR64_REGNUM+32; regno++) {
- supply_register (regno, data_p++);
- }
-#endif /* GR64_REGNUM */
-
-/* Global Registers gr96-gr127 */
- 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 = 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; regno<GR96_REGNUM+32; regno++) {
- supply_register (regno, data_p++);
- }
-
-/* Local Registers */
- out_msg_buf->read_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; regno<LR0_REGNUM+128; regno++) {
- supply_register (regno, data_p++);
- }
-
-/* Protected Special Registers */
- out_msg_buf->read_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 (INTE_REGNUM, &val);
- supply_register (FPS_REGNUM, &val);
- supply_register (EXO_REGNUM, &val);
- }
-}
-
-
-/****************************************************** 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 void
-mm_store_registers (regno)
-int regno;
-{
- int result;
-
- if (regno >= 0) {
- store_register(regno);
- return;
- }
-
- 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 ; regno<GR64_REGNUM+32 ; regno++)
- {
- out_msg_buf->write_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 ; regno<GR96_REGNUM+32 ; regno++)
- {
- out_msg_buf->write_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 ();
-}
-
-/*************************************************** 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;
-{
- 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)) {
- return 0; /* Success */
- } else {
- return 1; /* Failure */
- }
-}
-
-/************************************************* REMOTE_DELETE_BREAKPOINT */
-static int
-mm_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- 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)) {
- return 0; /* Success */
- } else {
- return 1; /* Failure */
- }
-}
-
-
-/******************************************************* REMOTE_KILL */
-static void
-mm_kill(arg,from_tty)
-char *arg;
-int from_tty;
-{
- char buf[4];
-
-#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
-}
-
-
-
-/***************************************************************************/
-/*
- * 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, 0, 0, 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;
-
- 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;
- }
- }
- 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;
-
- 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 ; i<in_msg_buf->read_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;
- 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;
- }
- return result;
-}
-/*****************************************************************************/
-/* Store a single register indicated by 'regno'.
- * Returns 0/-1 on success/failure.
- */
-static int
-store_register (regno)
- int regno;
-{
- int result;
-
- 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;
- }
- 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 INTE_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 */
-{
- int retries=0;
- while(msg_recv_serial(msg_buf) && (retries++<MAX_RETRIES));
- if (retries >= MAX_RETRIES) {
- printf("Expected msg %s, ",msg_str(msgcode));
- printf("no message received!\n");
- 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));
- }
- return(0); /* Failure */
- }
- 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 ;
-
-static void
-init_mm_ops(void)
-{
- mm_ops.to_shortname = "minimon";
- mm_ops.to_longname = "Remote AMD/Minimon target";
- mm_ops.to_doc = "Remote debug an AMD 290*0 using the MiniMon dbg core on the target";
- mm_ops.to_open = mm_open;
- mm_ops.to_close = mm_close;
- mm_ops.to_attach = mm_attach;
- mm_ops.to_post_attach = NULL;
- mm_ops.to_require_attach = NULL;
- mm_ops.to_detach = mm_detach;
- mm_ops.to_require_detach = NULL;
- mm_ops.to_resume = mm_resume;
- mm_ops.to_wait = mm_wait;
- mm_ops.to_post_wait = NULL;
- mm_ops.to_fetch_registers = mm_fetch_registers;
- mm_ops.to_store_registers = mm_store_registers;
- mm_ops.to_prepare_to_store = mm_prepare_to_store;
- mm_ops.to_xfer_memory = mm_xfer_inferior_memory;
- mm_ops.to_files_info = mm_files_info;
- mm_ops.to_insert_breakpoint = mm_insert_breakpoint;
- mm_ops.to_remove_breakpoint = mm_remove_breakpoint;
- mm_ops.to_terminal_init = 0;
- mm_ops.to_terminal_inferior = 0;
- mm_ops.to_terminal_ours_for_output = 0;
- mm_ops.to_terminal_ours = 0;
- mm_ops.to_terminal_info = 0;
- mm_ops.to_kill = mm_kill;
- mm_ops.to_load = mm_load;
- mm_ops.to_lookup_symbol = 0;
- mm_ops.to_create_inferior = mm_create_inferior;
- mm_ops.to_post_startup_inferior = NULL;
- mm_ops.to_acknowledge_created_inferior = NULL;
- mm_ops.to_clone_and_follow_inferior = NULL;
- mm_ops.to_post_follow_inferior_by_clone = NULL;
- mm_ops.to_insert_fork_catchpoint = NULL;
- mm_ops.to_remove_fork_catchpoint = NULL;
- mm_ops.to_insert_vfork_catchpoint = NULL;
- mm_ops.to_remove_vfork_catchpoint = NULL;
- mm_ops.to_has_forked = NULL;
- mm_ops.to_has_vforked = NULL;
- mm_ops.to_can_follow_vfork_prior_to_exec = NULL;
- mm_ops.to_post_follow_vfork = NULL;
- mm_ops.to_insert_exec_catchpoint = NULL;
- mm_ops.to_remove_exec_catchpoint = NULL;
- mm_ops.to_has_execd = NULL;
- mm_ops.to_reported_exec_events_per_exec_call = NULL;
- mm_ops.to_has_exited = NULL;
- mm_ops.to_mourn_inferior = mm_mourn;
- mm_ops.to_can_run = 0;
- mm_ops.to_notice_signals = 0;
- mm_ops.to_thread_alive = 0;
- mm_ops.to_stop = 0;
- mm_ops.to_pid_to_exec_file = NULL;
- mm_ops.to_core_file_to_sym_file = NULL;
- mm_ops.to_stratum = process_stratum;
- mm_ops.DONT_USE = 0;
- mm_ops.to_has_all_memory = 1;
- mm_ops.to_has_memory = 1;
- mm_ops.to_has_stack = 1;
- mm_ops.to_has_registers = 1;
- mm_ops.to_has_execution = 1;
- mm_ops.to_sections = 0;
- mm_ops.to_sections_end = 0;
- mm_ops.to_magic = OPS_MAGIC;
-};
-
-void
-_initialize_remote_mm()
-{
- init_mm_ops() ;
- add_target (&mm_ops);
-}
-
-#ifdef NO_HIF_SUPPORT
-service_HIF(msg)
-union msg_t *msg;
-{
- return(0); /* Emulate a failure */
-}
-#endif
diff --git a/contrib/gdb/gdb/remote-nindy.c b/contrib/gdb/gdb/remote-nindy.c
deleted file mode 100644
index 58e89b8..0000000
--- a/contrib/gdb/gdb/remote-nindy.c
+++ /dev/null
@@ -1,852 +0,0 @@
-/* Memory-access and commands for remote NINDY process, for GDB.
- Copyright 1990, 1991, 1992, 1993 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:
- *
- * <info>#<checksum>
- *
- * where
- * # is a literal character
- *
- * <info> ASCII information; all numeric information is in the
- * form of hex digits ('0'-'9' and lowercase 'a'-'f').
- *
- * <checksum>
- * is a pair of ASCII hex digits representing an 8-bit
- * checksum formed by adding together each of the
- * characters in <info>.
- *
- * 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 "defs.h"
-#include <signal.h>
-#include <sys/types.h>
-#include <setjmp.h>
-
-#include "frame.h"
-#include "inferior.h"
-#include "bfd.h"
-#include "symfile.h"
-#include "target.h"
-#include "gdbcore.h"
-#include "command.h"
-#include "floatformat.h"
-
-#include "wait.h"
-#include <sys/file.h>
-#include <ctype.h>
-#include "serial.h"
-#include "nindy-share/env.h"
-#include "nindy-share/stop.h"
-
-#include "dcache.h"
-#include "remote-utils.h"
-
-static DCACHE *nindy_dcache;
-
-extern int unlink();
-extern char *getenv();
-extern char *mktemp();
-
-extern void generic_mourn_inferior ();
-
-extern struct target_ops nindy_ops;
-extern FILE *instream;
-
-extern char ninStopWhy ();
-extern int ninMemGet ();
-extern int ninMemPut ();
-
-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
-
-/* From nindy-share/nindy.c. */
-extern serial_t nindy_serial;
-
-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
-nindy_fetch_registers PARAMS ((int));
-
-static void
-nindy_store_registers PARAMS ((int));
-
-static char *savename;
-
-static void
-nindy_close (quitting)
- int quitting;
-{
- if (nindy_serial != NULL)
- SERIAL_CLOSE (nindy_serial);
- nindy_serial = NULL;
-
- if (savename)
- free (savename);
- savename = 0;
-}
-
-/* Open a connection to a remote debugger.
- FIXME, there should be "set" commands for the options that are
- now specified with gdb command-line options (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;
-{
- char baudrate[1024];
-
- if (!name)
- error_no_arg ("serial port device name");
-
- target_preopen (from_tty);
-
- nindy_close (0);
-
- have_regs = regs_changed = 0;
- nindy_dcache = dcache_init(ninMemGet, ninMemPut);
-
- /* Allow user to interrupt the following -- we could hang if there's
- no NINDY at the other end of the remote tty. */
- immediate_quit++;
- /* If baud_rate is -1, then ninConnect will not recognize the baud rate
- and will deal with the situation in a (more or less) reasonable
- fashion. */
- sprintf(baudrate, "%d", baud_rate);
- ninConnect(name, baudrate,
- nindy_initial_brk, !from_tty, nindy_old_protocol);
- immediate_quit--;
-
- if (nindy_serial == NULL)
- {
- perror_with_name (name);
- }
-
- savename = savestring (name, strlen (name));
- push_target (&nindy_ops);
-
- target_fetch_registers(-1);
-
- init_thread_list ();
- init_wait_for_inferior ();
- clear_proceed_status ();
- normal_stop ();
-}
-
-/* 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 ()
-{
- /* FIXME: this lies about the baud rate if we autobauded. */
- printf_unfiltered("\tAttached to %s at %d bits per second%s%s.\n", savename,
- baud_rate,
- nindy_old_protocol? " in old protocol": "",
- nindy_initial_brk? " with initial break": "");
-}
-
-/* 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 (pid, step, siggnal)
- int pid, step;
- enum target_signal siggnal;
-{
- if (siggnal != TARGET_SIGNAL_0 && siggnal != stop_signal)
- warning ("Can't send signals to remote NINDY targets.");
-
- dcache_flush(nindy_dcache);
- if ( regs_changed )
- {
- nindy_store_registers (-1);
- regs_changed = 0;
- }
- have_regs = 0;
- ninGo( step );
-}
-
-/* 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. */
-
-struct clean_up_tty_args {
- serial_ttystate state;
- serial_t serial;
-};
-static struct clean_up_tty_args tty_args;
-
-static void
-clean_up_tty (ptrarg)
- PTR ptrarg;
-{
- struct clean_up_tty_args *args = (struct clean_up_tty_args *) ptrarg;
- SERIAL_SET_TTY_STATE (args->serial, args->state);
- free (args->state);
- warning ("\n\nYou may need to reset the 80960 and/or reload your program.\n");
-}
-
-/* Recover from ^Z or ^C while remote process is running */
-static void (*old_ctrlc)();
-#ifdef SIGTSTP
-static void (*old_ctrlz)();
-#endif
-
-static void
-clean_up_int()
-{
- SERIAL_SET_TTY_STATE (tty_args.serial, tty_args.state);
- free (tty_args.state);
-
- 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");
-}
-
-/* Wait until the remote machine stops. While waiting, operate in passthrough
- * mode; i.e., pass everything NINDY sends to gdb_stdout, and everything from
- * stdin to NINDY.
- *
- * Return to caller, storing status in 'status' just as `wait' would.
- */
-
-static int
-nindy_wait( pid, status )
- int pid;
- struct target_waitstatus *status;
-{
- fd_set fds;
- int c;
- char buf[2];
- int i, n;
- unsigned char stop_exit;
- unsigned char stop_code;
- struct cleanup *old_cleanups;
- long ip_value, fp_value, sp_value; /* Reg values from stop */
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- /* OPERATE IN PASSTHROUGH MODE UNTIL NINDY SENDS A DLE CHARACTER */
-
- /* Save current tty attributes, and restore them when done. */
- tty_args.serial = SERIAL_FDOPEN (0);
- tty_args.state = SERIAL_GET_TTY_STATE (tty_args.serial);
- old_ctrlc = signal( SIGINT, clean_up_int );
-#ifdef SIGTSTP
- old_ctrlz = signal( SIGTSTP, clean_up_int );
-#endif
-
- old_cleanups = make_cleanup (clean_up_tty, &tty_args);
-
- /* Pass input from keyboard to NINDY as it arrives. NINDY will interpret
- <CR> and perform echo. */
- /* This used to set CBREAK and clear ECHO and CRMOD. I hope this is close
- enough. */
- SERIAL_RAW (tty_args.serial);
-
- while (1)
- {
- /* Input on remote */
- c = SERIAL_READCHAR (nindy_serial, -1);
- if (c == SERIAL_ERROR)
- {
- error ("Cannot read from serial line");
- }
- else if (c == 0x1b) /* ESC */
- {
- c = SERIAL_READCHAR (nindy_serial, -1);
- c &= ~0x40;
- }
- else if (c != 0x10) /* DLE */
- /* Write out any characters preceding DLE */
- {
- buf[0] = (char)c;
- write (1, buf, 1);
- }
- else
- {
- 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,
- (char *)&ip_value);
- supply_register (FP_REGNUM,
- (char *)&fp_value);
- supply_register (SP_REGNUM,
- (char *)&sp_value);
- break;
- }
- }
- }
-
- SERIAL_SET_TTY_STATE (tty_args.serial, tty_args.state);
- free (tty_args.state);
- discard_cleanups (old_cleanups);
-
- if (stop_exit)
- {
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = stop_code;
- }
- else
- {
- /* nindy has some special stop code need to be handled */
- if (stop_code == STOP_GDB_BPT)
- stop_code = TRACE_STEP;
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = i960_fault_to_signal (stop_code);
- }
- return inferior_pid;
-}
-
-/* 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 void
-nindy_fetch_registers(regno)
- int regno;
-{
- struct nindy_regs nindy_regs;
- int regnum;
-
- immediate_quit++;
- ninRegsGet( (char *) &nindy_regs );
- immediate_quit--;
-
- memcpy (&registers[REGISTER_BYTE (R0_REGNUM)], nindy_regs.local_regs, 16*4);
- memcpy (&registers[REGISTER_BYTE (G0_REGNUM)], nindy_regs.global_regs, 16*4);
- memcpy (&registers[REGISTER_BYTE (PCW_REGNUM)], nindy_regs.pcw_acw, 2*4);
- memcpy (&registers[REGISTER_BYTE (IP_REGNUM)], nindy_regs.ip, 1*4);
- memcpy (&registers[REGISTER_BYTE (TCW_REGNUM)], nindy_regs.tcw, 1*4);
- memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], nindy_regs.fp_as_double, 4 * 8);
-
- registers_fetched ();
-}
-
-static void
-nindy_prepare_to_store()
-{
- /* Fetch all regs if they aren't already here. */
- read_register_bytes (0, NULL, REGISTER_BYTES);
-}
-
-static void
-nindy_store_registers(regno)
- int regno;
-{
- struct nindy_regs nindy_regs;
- int regnum;
-
- memcpy (nindy_regs.local_regs, &registers[REGISTER_BYTE (R0_REGNUM)], 16*4);
- memcpy (nindy_regs.global_regs, &registers[REGISTER_BYTE (G0_REGNUM)], 16*4);
- memcpy (nindy_regs.pcw_acw, &registers[REGISTER_BYTE (PCW_REGNUM)], 2*4);
- memcpy (nindy_regs.ip, &registers[REGISTER_BYTE (IP_REGNUM)], 1*4);
- memcpy (nindy_regs.tcw, &registers[REGISTER_BYTE (TCW_REGNUM)], 1*4);
- memcpy (nindy_regs.fp_as_double, &registers[REGISTER_BYTE (FP0_REGNUM)], 8*4);
-
- immediate_quit++;
- ninRegsPut( (char *) &nindy_regs );
- immediate_quit--;
-}
-
-/* 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 (nindy_dcache, 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 (nindy_dcache, 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, should_write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int should_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 (should_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 */
-
- memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, 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. */
- memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
- }
- return len;
-}
-
-static void
-nindy_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- int entry_pt;
- int pid;
-
- if (args && *args)
- error ("Can't pass arguments to remote NINDY process");
-
- if (execfile == 0 || exec_bfd == 0)
- error ("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
- pid = 42;
-
- /* The "process" (board) is already stopped awaiting our commands, and
- the program is already downloaded. We just set its PC and go. */
-
- inferior_pid = pid; /* Needed for wait_for_inferior below */
-
- clear_proceed_status ();
-
- /* Tell wait_for_inferior that we've started a new process. */
- 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 ();
-
- /* insert_step_breakpoint (); FIXME, do we need this? */
- /* Let 'er rip... */
- proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-static void
-reset_command(args, from_tty)
- char *args;
- int from_tty;
-{
- if (nindy_serial == NULL)
- {
- error( "No target system to reset -- use 'target nindy' command.");
- }
- if ( query("Really reset the target system?",0,0) )
- {
- SERIAL_SEND_BREAK (nindy_serial);
- tty_flush (nindy_serial);
- }
-}
-
-void
-nindy_kill (args, from_tty)
- char *args;
- int from_tty;
-{
- return; /* Ignore attempts to kill target system */
-}
-
-/* Clean up when a program exits.
-
- The program actually lives on in the remote processor's RAM, and may be
- run again without a download. Don't leave it full of breakpoint
- instructions. */
-
-void
-nindy_mourn_inferior ()
-{
- remove_breakpoints ();
- unpush_target (&nindy_ops);
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-
-/* Pass the args the way catch_errors wants them. */
-static int
-nindy_open_stub (arg)
- char *arg;
-{
- nindy_open (arg, 1);
- return 1;
-}
-
-static void
-nindy_load( filename, from_tty )
- char *filename;
- int from_tty;
-{
- asection *s;
- /* Can't do unix style forking on a VMS system, so we'll use bfd to do
- all the work for us
- */
-
- bfd *file = bfd_openr(filename,0);
- if (!file)
- {
- perror_with_name(filename);
- return;
- }
-
- if (!bfd_check_format(file, bfd_object))
- {
- error("can't prove it's an object file\n");
- return;
- }
-
- for ( s = file->sections; s; s=s->next)
- {
- if (s->flags & SEC_LOAD)
- {
- char *buffer = xmalloc(s->_raw_size);
- bfd_get_section_contents(file, s, buffer, 0, s->_raw_size);
- printf("Loading section %s, size %x vma %x\n",
- s->name,
- s->_raw_size,
- s->vma);
- ninMemPut(s->vma, buffer, s->_raw_size);
- free(buffer);
- }
- }
- bfd_close(file);
-}
-
-static int
-load_stub (arg)
- char *arg;
-{
- target_load (arg, 1);
- return 1;
-}
-
-/* This routine is run as a hook, just before the main command loop is
- entered. If gdb is configured for the i960, but has not had its
- nindy target specified yet, this will loop prompting the user to do so.
-
- Unlike the loop provided by Intel, we actually let the user get out
- of this with a RETURN. This is useful when e.g. simply examining
- an i960 object file on the host system. */
-
-void
-nindy_before_main_loop ()
-{
- char ttyname[100];
- char *p, *p2;
-
- while (target_stack->target_ops != &nindy_ops) /* What is this crap??? */
- { /* remote tty not specified yet */
- if ( instream == stdin ){
- printf_unfiltered("\nAttach /dev/ttyNN -- specify NN, or \"quit\" to quit: ");
- gdb_flush( gdb_stdout );
- }
- fgets( ttyname, sizeof(ttyname)-1, stdin );
-
- /* Strip leading and trailing whitespace */
- for ( p = ttyname; isspace(*p); p++ ){
- ;
- }
- if ( *p == '\0' ){
- return; /* User just hit spaces or return, wants out */
- }
- for ( p2= p; !isspace(*p2) && (*p2 != '\0'); p2++ ){
- ;
- }
- *p2= '\0';
- if ( STREQ("quit",p) ){
- exit(1);
- }
-
- if (catch_errors (nindy_open_stub, p, "", RETURN_MASK_ALL))
- {
- /* Now that we have a tty open for talking to the remote machine,
- download the executable file if one was specified. */
- if (exec_bfd)
- {
- catch_errors (load_stub, bfd_get_filename (exec_bfd), "",
- RETURN_MASK_ALL);
- }
- }
- }
-}
-
-/* Define the target subroutine names */
-
-struct target_ops nindy_ops ;
-
-static void
-init_nindy_ops(void)
-{
- nindy_ops.to_shortname = "nindy"; "Remote serial target in i960 NINDY-specific protocol",
- nindy_ops.to_longname = "Use a remote i960 system running NINDY connected by a serial line.\n\
-Specify the name of the device the serial line is connected to.\n\
-The speed (baud rate), whether to use the old NINDY protocol,\n\
-and whether to send a break on startup, are controlled by options\n\
-specified when you started GDB." ;
- nindy_ops.to_doc = "";
- nindy_ops.to_open = nindy_open;
- nindy_ops.to_close = nindy_close;
- nindy_ops.to_attach = 0;
- nindy_ops.to_post_attach = NULL;
- nindy_ops.to_require_attach = NULL;
- nindy_ops.to_detach = nindy_detach;
- nindy_ops.to_require_detach = NULL;
- nindy_ops.to_resume = nindy_resume;
- nindy_ops.to_wait = nindy_wait;
- nindy_ops.to_post_wait = NULL;
- nindy_ops.to_fetch_registers = nindy_fetch_registers;
- nindy_ops.to_store_registers = nindy_store_registers;
- nindy_ops.to_prepare_to_store = nindy_prepare_to_store;
- nindy_ops.to_xfer_memory = nindy_xfer_inferior_memory;
- nindy_ops.to_files_info = nindy_files_info;
- nindy_ops.to_insert_breakpoint = memory_insert_breakpoint;
- nindy_ops.to_remove_breakpoint = memory_remove_breakpoint;
- nindy_ops.to_terminal_init = 0;
- nindy_ops.to_terminal_inferior = 0;
- nindy_ops.to_terminal_ours_for_output = 0;
- nindy_ops.to_terminal_ours = 0;
- nindy_ops.to_terminal_info = 0; /* Terminal crud */
- nindy_ops.to_kill = nindy_kill;
- nindy_ops.to_load = nindy_load;
- nindy_ops.to_lookup_symbol = 0; /* lookup_symbol */
- nindy_ops.to_create_inferior = nindy_create_inferior;
- nindy_ops.to_post_startup_inferior = NULL;
- nindy_ops.to_acknowledge_created_inferior = NULL;
- nindy_ops.to_clone_and_follow_inferior = NULL;
- nindy_ops.to_post_follow_inferior_by_clone = NULL;
- nindy_ops.to_insert_fork_catchpoint = NULL;
- nindy_ops.to_remove_fork_catchpoint = NULL;
- nindy_ops.to_insert_vfork_catchpoint = NULL;
- nindy_ops.to_remove_vfork_catchpoint = NULL;
- nindy_ops.to_has_forked = NULL;
- nindy_ops.to_has_vforked = NULL;
- nindy_ops.to_can_follow_vfork_prior_to_exec = NULL;
- nindy_ops.to_post_follow_vfork = NULL;
- nindy_ops.to_insert_exec_catchpoint = NULL;
- nindy_ops.to_remove_exec_catchpoint = NULL;
- nindy_ops.to_has_execd = NULL;
- nindy_ops.to_reported_exec_events_per_exec_call = NULL;
- nindy_ops.to_has_exited = NULL;
- nindy_ops.to_mourn_inferior = nindy_mourn_inferior;
- nindy_ops.to_can_run = 0; /* can_run */
- nindy_ops.to_notice_signals = 0; /* notice_signals */
- nindy_ops.to_thread_alive = 0; /* to_thread_alive */
- nindy_ops.to_stop = 0; /* to_stop */
- nindy_ops.to_pid_to_exec_file = NULL;
- nindy_ops.to_core_file_to_sym_file = NULL;
- nindy_ops.to_stratum = process_stratum;
- nindy_ops.DONT_USE = 0; /* next */
- nindy_ops.to_has_all_memory = 1;
- nindy_ops.to_has_memory = 1;
- nindy_ops.to_has_stack = 1;
- nindy_ops.to_has_registers = 1;
- nindy_ops.to_has_execution = 1; /* all mem, mem, stack, regs, exec */
- nindy_ops.to_sections = 0;
- nindy_ops.to_sections_end = 0; /* Section pointers */
- nindy_ops.to_magic = OPS_MAGIC; /* Always the last thing */
-}
-
-void
-_initialize_nindy ()
-{
- init_nindy_ops() ;
- add_target (&nindy_ops);
- add_com ("reset", class_obscure, reset_command,
- "Send a 'break' to the remote target system.\n\
-Only useful if the target has been equipped with a circuit\n\
-to perform a hard reset when a break is detected.");
-}
diff --git a/contrib/gdb/gdb/remote-nrom.c b/contrib/gdb/gdb/remote-nrom.c
deleted file mode 100644
index 4999a68..0000000
--- a/contrib/gdb/gdb/remote-nrom.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/* Remote debugging with the XLNT Designs, Inc (XDI) NetROM.
- Copyright 1990, 1991, 1992, 1995 Free Software Foundation, Inc.
- Contributed by:
- Roger Moyers
- XLNT Designs, Inc.
- 15050 Avenue of Science, Suite 106
- San Diego, CA 92128
- (619)487-9320
- roger@xlnt.com
- Adapted from work done at Cygnus Support in remote-nindy.c,
- later merged in by Stan Shebs at 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "gdbcmd.h"
-#include "serial.h"
-#include "target.h"
-
-/* Default ports used to talk with the NetROM. */
-
-#define DEFAULT_NETROM_LOAD_PORT 1236
-#define DEFAULT_NETROM_CONTROL_PORT 1237
-
-static void nrom_close PARAMS ((int quitting));
-
-/* New commands. */
-
-static void nrom_passthru PARAMS ((char *, int));
-
-/* We talk to the NetROM over these sockets. */
-
-static serial_t load_desc = NULL;
-static serial_t ctrl_desc = NULL;
-
-static int load_port = DEFAULT_NETROM_LOAD_PORT;
-static int control_port = DEFAULT_NETROM_CONTROL_PORT;
-
-static char nrom_hostname[100];
-
-/* Forward data declaration. */
-
-extern struct target_ops nrom_ops;
-
-/* Scan input from the remote system, until STRING is found. Print chars that
- don't match. */
-
-static int
-expect (string)
- char *string;
-{
- char *p = string;
- int c;
-
- immediate_quit = 1;
-
- while (1)
- {
- c = SERIAL_READCHAR (ctrl_desc, 5);
-
- if (c == *p++)
- {
- if (*p == '\0')
- {
- immediate_quit = 0;
-
- return 0;
- }
- }
- else
- {
- fputc_unfiltered (c, gdb_stdout);
- p = string;
- if (c == *p)
- p++;
- }
- }
-}
-
-static void
-nrom_kill ()
-{
- nrom_close (0);
-}
-
-static serial_t
-open_socket (name, port)
- char *name;
- int port;
-{
- char sockname[100];
- serial_t desc;
-
- sprintf (sockname, "%s:%d", name, port);
- desc = SERIAL_OPEN (sockname);
- if (!desc)
- perror_with_name (sockname);
-
- return desc;
-}
-
-static void
-load_cleanup ()
-{
- SERIAL_CLOSE (load_desc);
- load_desc = NULL;
-}
-
-/* Download a file specified in ARGS to the netROM. */
-
-static void
-nrom_load (args, fromtty)
- char *args;
- int fromtty;
-{
- int fd, rd_amt, fsize;
- bfd *pbfd;
- asection *section;
- char *downloadstring = "download 0\n";
- struct cleanup *old_chain;
-
- /* Tell the netrom to get ready to download. */
- if (SERIAL_WRITE (ctrl_desc, downloadstring, strlen (downloadstring)))
- error ("nrom_load: control_send() of `%s' failed", downloadstring);
-
- expect ("Waiting for a connection...\n");
-
- load_desc = open_socket (nrom_hostname, load_port);
-
- old_chain = make_cleanup (load_cleanup, 0);
-
- pbfd = bfd_openr (args, 0);
-
- if (pbfd)
- {
- make_cleanup (bfd_close, pbfd);
-
- if (!bfd_check_format (pbfd, bfd_object))
- error ("\"%s\": not in executable format: %s",
- args, bfd_errmsg (bfd_get_error ()));
-
- for (section = pbfd->sections; section; section = section->next)
- {
- if (bfd_get_section_flags (pbfd, section) & SEC_ALLOC)
- {
- bfd_vma section_address;
- unsigned long section_size;
- const char *section_name;
-
- section_name = bfd_get_section_name (pbfd, section);
- section_address = bfd_get_section_vma (pbfd, section);
- section_size = bfd_section_size (pbfd, section);
-
- if (bfd_get_section_flags (pbfd, section) & SEC_LOAD)
- {
- file_ptr fptr;
-
- printf_filtered ("[Loading section %s at %x (%d bytes)]\n",
- section_name, section_address,
- section_size);
-
- fptr = 0;
-
- while (section_size > 0)
- {
- char buffer[1024];
- int count;
-
- count = min (section_size, 1024);
-
- bfd_get_section_contents (pbfd, section, buffer, fptr,
- count);
-
- SERIAL_WRITE (load_desc, buffer, count);
- section_address += count;
- fptr += count;
- section_size -= count;
- }
- }
- else /* BSS and such */
- {
- printf_filtered ("[section %s: not loading]\n",
- section_name);
- }
- }
- }
- }
- else
- error ("\"%s\": Could not open", args);
-
- do_cleanups (old_chain);
-}
-
-/* Open a connection to the remote NetROM devices. */
-
-static void
-nrom_open (name, from_tty)
- char *name;
- int from_tty;
-{
- int errn;
-
- if (!name || strchr (name, '/') || strchr (name, ':'))
- error (
-"To open a NetROM connection, you must specify the hostname\n\
-or IP address of the NetROM device you wish to use.");
-
- strcpy (nrom_hostname, name);
-
- target_preopen (from_tty);
-
- unpush_target (&nrom_ops);
-
- ctrl_desc = open_socket (nrom_hostname, control_port);
-
- push_target (&nrom_ops);
-
- if (from_tty)
- printf_filtered ("Connected to NetROM device \"%s\"\n", nrom_hostname);
-}
-
-/* Close out all files and local state before this target loses control. */
-
-static void
-nrom_close (quitting)
- int quitting;
-{
- if (load_desc)
- SERIAL_CLOSE (load_desc);
- if (ctrl_desc)
- SERIAL_CLOSE (ctrl_desc);
-}
-
-/* Pass arguments directly to the NetROM. */
-
-static void
-nrom_passthru (args, fromtty)
- char *args;
- int fromtty;
-{
- char buf[1024];
-
- sprintf (buf, "%s\n", args);
- if (SERIAL_WRITE (ctrl_desc, buf, strlen (buf)))
- error ("nrom_reset: control_send() of `%s'failed", args);
-}
-
-static void
-nrom_mourn()
-{
- unpush_target (&nrom_ops);
- generic_mourn_inferior ();
-}
-
-/* Define the target vector. */
-
-struct target_ops nrom_ops ;
-
-static void
-init_nrom_ops(void)
-{
- nrom_ops.to_shortname = "nrom";
- nrom_ops.to_longname = "Remote XDI `NetROM' target";
- nrom_ops.to_doc = "Remote debug using a NetROM over Ethernet";
- nrom_ops.to_open = nrom_open;
- nrom_ops.to_close = nrom_close;
- nrom_ops.to_attach = NULL;
- nrom_ops.to_post_attach = NULL;
- nrom_ops.to_require_attach = NULL;
- nrom_ops.to_detach = NULL;
- nrom_ops.to_require_detach = NULL;
- nrom_ops.to_resume = NULL;
- nrom_ops.to_wait = NULL;
- nrom_ops.to_post_wait = NULL;
- nrom_ops.to_fetch_registers = NULL;
- nrom_ops.to_store_registers = NULL;
- nrom_ops.to_prepare_to_store = NULL;
- nrom_ops.to_xfer_memory = NULL;
- nrom_ops.to_files_info = NULL;
- nrom_ops.to_insert_breakpoint = NULL;
- nrom_ops.to_remove_breakpoint = NULL;
- nrom_ops.to_terminal_init = NULL;
- nrom_ops.to_terminal_inferior = NULL;
- nrom_ops.to_terminal_ours_for_output = NULL;
- nrom_ops.to_terminal_ours = NULL;
- nrom_ops.to_terminal_info = NULL;
- nrom_ops.to_kill = nrom_kill;
- nrom_ops.to_load = nrom_load;
- nrom_ops.to_lookup_symbol = NULL;
- nrom_ops.to_create_inferior = NULL;
- nrom_ops.to_post_startup_inferior = NULL;
- nrom_ops.to_acknowledge_created_inferior = NULL;
- nrom_ops.to_clone_and_follow_inferior = NULL;
- nrom_ops.to_post_follow_inferior_by_clone = NULL;
- nrom_ops.to_insert_fork_catchpoint = NULL;
- nrom_ops.to_remove_fork_catchpoint = NULL;
- nrom_ops.to_insert_vfork_catchpoint = NULL;
- nrom_ops.to_remove_vfork_catchpoint = NULL;
- nrom_ops.to_has_forked = NULL;
- nrom_ops.to_has_vforked = NULL;
- nrom_ops.to_can_follow_vfork_prior_to_exec = NULL;
- nrom_ops.to_post_follow_vfork = NULL;
- nrom_ops.to_insert_exec_catchpoint = NULL;
- nrom_ops.to_remove_exec_catchpoint = NULL;
- nrom_ops.to_has_execd = NULL;
- nrom_ops.to_reported_exec_events_per_exec_call = NULL;
- nrom_ops.to_has_exited = NULL;
- nrom_ops.to_mourn_inferior = nrom_mourn;
- nrom_ops.to_can_run = NULL;
- nrom_ops.to_notice_signals = 0;
- nrom_ops.to_thread_alive = 0;
- nrom_ops.to_stop = 0;
- nrom_ops.to_pid_to_exec_file = NULL;
- nrom_ops.to_core_file_to_sym_file = NULL;
- nrom_ops.to_stratum = download_stratum;
- nrom_ops.DONT_USE = NULL;
- nrom_ops.to_has_all_memory = 1;
- nrom_ops.to_has_memory = 1;
- nrom_ops.to_has_stack = 1;
- nrom_ops.to_has_registers = 1;
- nrom_ops.to_has_execution = 0;
- nrom_ops.to_sections = NULL;
- nrom_ops.to_sections_end = NULL;
- nrom_ops.to_magic = OPS_MAGIC ;
-};
-
-void
-_initialize_remote_nrom ()
-{
- init_nrom_ops() ;
- add_target (&nrom_ops);
-
- add_show_from_set (
- add_set_cmd ("nrom_load_port", no_class, var_zinteger, (char *)&load_port,
- "Set the port to use for NetROM downloads\n", &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("nrom_control_port", no_class, var_zinteger, (char *)&control_port,
- "Set the port to use for NetROM debugger services\n", &setlist),
- &showlist);
-
- add_cmd ("nrom", no_class, nrom_passthru,
- "Pass arguments as command to NetROM",
- &cmdlist);
-}
diff --git a/contrib/gdb/gdb/remote-os9k.c b/contrib/gdb/gdb/remote-os9k.c
deleted file mode 100644
index 2abfa83..0000000
--- a/contrib/gdb/gdb/remote-os9k.c
+++ /dev/null
@@ -1,1264 +0,0 @@
-/* Remote debugging interface for boot monitors, for GDB.
- Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file was derived from remote-eb.c, which did a similar job, but for
- an AMD-29K running EBMON. That file was in turn derived from remote.c
- as mentioned in the following comment (left in for comic relief):
-
- "This is like remote.c but is for a different situation--
- having a PC running os9000 hook up with a unix machine with
- a serial line, and running ctty com2 on the PC. os9000 has a debug
- monitor called ROMBUG running. 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."
-
- In reality, this module talks to a debug monitor called 'ROMBUG', which
- We communicate with ROMBUG via a direct serial line, the network version
- of ROMBUG is not available yet.
-*/
-
-/* FIXME This file needs to be rewritten if it's to work again, either
- to self-contained or to use the new monitor interface. */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "wait.h"
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <signal.h>
-#include "gdb_string.h"
-#include <sys/types.h>
-#include "command.h"
-#include "serial.h"
-#include "monitor.h"
-#include "remote-utils.h"
-#include "symtab.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "gdb-stabs.h"
-
-struct cmd_list_element *showlist;
-extern struct target_ops rombug_ops; /* Forward declaration */
-extern struct monitor_ops rombug_cmds; /* Forward declaration */
-extern struct cmd_list_element *setlist;
-extern struct cmd_list_element *unsetlist;
-extern int attach_flag;
-
-static void rombug_close();
-static void rombug_fetch_register();
-static void rombug_fetch_registers();
-static void rombug_store_register();
-#if 0
-static int sr_get_debug(); /* flag set by "set remotedebug" */
-#endif
-static int hashmark; /* flag set by "set hash" */
-static int rombug_is_open = 0;
-
-/* FIXME: Replace with sr_get_debug (). */
-#define LOG_FILE "monitor.log"
-FILE *log_file;
-static int monitor_log = 0;
-static int tty_xon = 0;
-static int tty_xoff = 0;
-
-static int timeout = 10;
-static int is_trace_mode = 0;
-/* Descriptor for I/O to remote machine. Initialize it to NULL*/
-static serial_t monitor_desc = NULL;
-
-static CORE_ADDR bufaddr = 0;
-static int buflen = 0;
-static char readbuf[16];
-
-/* Send data to monitor. Works just like printf. */
-static void
-#ifdef ANSI_PROTOTYPES
-printf_monitor(char *pattern, ...)
-#else
-printf_monitor(va_alist)
- va_dcl
-#endif
-{
- va_list args;
- char buf[200];
- int i;
-
-#ifdef ANSI_PROTOTYPES
- va_start (args, pattern);
-#else
- char *pattern;
- va_start(args);
- pattern = va_arg(args, char *);
-#endif
-
- vsprintf(buf, pattern, args);
- va_end(args);
-
- if (SERIAL_WRITE(monitor_desc, buf, strlen(buf)))
- fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
-}
-
-/* Read a character from the remote system, doing all the fancy timeout stuff*/
-static int
-readchar(timeout)
- int timeout;
-{
- int c;
-
- c = SERIAL_READCHAR(monitor_desc, timeout);
-
- if (sr_get_debug())
- putchar(c & 0x7f);
-
- if (monitor_log && isascii(c))
- putc(c & 0x7f, log_file);
-
- if (c >= 0)
- return c & 0x7f;
-
- if (c == SERIAL_TIMEOUT)
- {
- if (timeout == 0)
- return c; /* Polls shouldn't generate timeout errors */
-
- error("Timeout reading from remote system.");
- }
-
- perror_with_name("remote-monitor");
-}
-
-/* Scan input from the remote system, until STRING is found. If DISCARD is
- non-zero, then discard non-matching input, else print it out.
- Let the user break out immediately. */
-static void
-expect(string, discard)
- char *string;
- int discard;
-{
- char *p = string;
- int c;
-
- if (sr_get_debug())
- printf ("Expecting \"%s\"\n", string);
-
- immediate_quit = 1;
- while (1)
- {
- c = readchar(timeout);
- if (!isascii (c))
- continue;
- if (c == *p++)
- {
- if (*p == '\0')
- {
- immediate_quit = 0;
- if (sr_get_debug())
- printf ("\nMatched\n");
- return;
- }
- }
- else
- {
- if (!discard)
- {
- fwrite(string, 1, (p - 1) - string, stdout);
- putchar((char)c);
- fflush(stdout);
- }
- p = string;
- }
- }
-}
-
-/* Keep discarding input until we see the ROMBUG 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: rombug_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 rombug_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(discard)
- int discard;
-{
- if (monitor_log)
- /* 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);
-
- if (is_trace_mode) {
- expect("trace", discard);
- } else {
- expect (PROMPT, discard);
- }
-}
-
-/* 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(timeout);
- 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(1);
- error("Invalid hex digit from remote system.");
- }
- }
-}
-
-/* Get a byte from monitor 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;
- unsigned char b;
-
- for (i = 0; i < n; i++)
- {
- int j;
-
- val = 0;
- for (j = 0; j < 4; j++)
- {
- get_hex_byte (&b);
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
- val = (val << 8) + b;
- else
- val = val + (b << (j*8));
- }
- supply_register (regno++, (char *) &val);
- }
-}
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-static void
-rombug_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- int entry_pt;
-
- if (args && *args)
- error("Can't pass arguments to remote ROMBUG process");
-
- if (execfile == 0 || exec_bfd == 0)
- error("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
- if (monitor_log)
- fputs ("\nIn Create_inferior()", log_file);
-
-
-/* The "process" (board) is already stopped awaiting our commands, and
- the program is already downloaded. We just set its PC and go. */
-
- init_wait_for_inferior ();
- proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-/* Open a connection to a remote debugger.
- NAME is the filename used for communication. */
-
-static char dev_name[100];
-
-static void
-rombug_open(args, from_tty)
- char *args;
- int from_tty;
-{
- if (args == NULL)
- error ("Use `target RomBug DEVICE-NAME' to use a serial port, or \n\
-`target RomBug HOST-NAME:PORT-NUMBER' to use a network connection.");
-
- target_preopen(from_tty);
-
- if (rombug_is_open)
- unpush_target(&rombug_ops);
-
- strcpy(dev_name, args);
- monitor_desc = SERIAL_OPEN(dev_name);
- if (monitor_desc == NULL)
- perror_with_name(dev_name);
-
- /* if baud rate is set by 'set remotebaud' */
- if (SERIAL_SETBAUDRATE (monitor_desc, sr_get_baud_rate()))
- {
- SERIAL_CLOSE (monitor_desc);
- perror_with_name ("RomBug");
- }
- SERIAL_RAW(monitor_desc);
- if (tty_xon || tty_xoff)
- {
- struct hardware_ttystate { struct termios t;} *tty_s;
-
- tty_s =(struct hardware_ttystate *)SERIAL_GET_TTY_STATE(monitor_desc);
- if (tty_xon) tty_s->t.c_iflag |= IXON;
- if (tty_xoff) tty_s->t.c_iflag |= IXOFF;
- SERIAL_SET_TTY_STATE(monitor_desc, (serial_ttystate) tty_s);
- }
-
- rombug_is_open = 1;
-
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- perror_with_name (LOG_FILE);
-
- push_monitor (&rombug_cmds);
- printf_monitor("\r"); /* CR wakes up monitor */
- expect_prompt(1);
- push_target (&rombug_ops);
- attach_flag = 1;
-
- if (from_tty)
- printf("Remote %s connected to %s\n", target_shortname,
- dev_name);
-
- rombug_fetch_registers();
-
- printf_monitor ("ov e \r");
- expect_prompt(1);
- bufaddr = 0;
- buflen = 0;
-}
-
-/*
- * Close out all files and local state before this target loses control.
- */
-
-static void
-rombug_close (quitting)
- int quitting;
-{
- if (rombug_is_open) {
- SERIAL_CLOSE(monitor_desc);
- monitor_desc = NULL;
- rombug_is_open = 0;
- }
-
- if (log_file) {
- if (ferror(log_file))
- fprintf(stderr, "Error writing log file.\n");
- if (fclose(log_file) != 0)
- fprintf(stderr, "Error closing log file.\n");
- log_file = 0;
- }
-}
-
-int
-rombug_link(mod_name, text_reloc)
- char *mod_name;
- CORE_ADDR *text_reloc;
-{
- int i, j;
- unsigned long val;
- unsigned char b;
-
- printf_monitor("l %s \r", mod_name);
- expect_prompt(1);
- printf_monitor(".r \r");
- expect(REG_DELIM, 1);
- for (i=0; i <= 7; i++)
- {
- val = 0;
- for (j = 0; j < 4; j++)
- {
- get_hex_byte(&b);
- val = (val << 8) + b;
- }
- }
- expect_prompt(1);
- *text_reloc = val;
- return 1;
-}
-
-/* Terminate the open connection to the remote debugger.
- Use this when you want to detach and do something else
- with your gdb. */
-static void
-rombug_detach (from_tty)
- int from_tty;
-{
- if (attach_flag) {
- printf_monitor (GO_CMD);
- attach_flag = 0;
- }
- pop_target(); /* calls rombug_close to do the real work */
- if (from_tty)
- printf ("Ending remote %s debugging\n", target_shortname);
-}
-
-/*
- * Tell the remote machine to resume.
- */
-static void
-rombug_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
-{
- if (monitor_log)
- fprintf (log_file, "\nIn Resume (step=%d, sig=%d)\n", step, sig);
-
- if (step)
- {
- is_trace_mode = 1;
- printf_monitor (STEP_CMD);
- /* wait for the echo. **
- expect (STEP_CMD, 1);
- */
- }
- else
- {
- printf_monitor (GO_CMD);
- /* swallow the echo. **
- expect (GO_CMD, 1);
- */
- }
- bufaddr = 0;
- buflen= 0;
-}
-
-/*
- * Wait until the remote machine stops, then return,
- * storing status in status just as `wait' would.
- */
-
-static int
-rombug_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- int old_timeout = timeout;
- struct section_offsets *offs;
- CORE_ADDR addr, pc;
- struct obj_section *obj_sec;
-
- if (monitor_log)
- fputs ("\nIn wait ()", log_file);
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- timeout = -1; /* Don't time out -- user program is running. */
- expect ("eax:", 0); /* output any message before register display */
- expect_prompt(1); /* Wait for prompt, outputting extraneous text */
-
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- timeout = old_timeout;
- rombug_fetch_registers();
- bufaddr = 0;
- buflen = 0;
- pc = read_register(PC_REGNUM);
- addr = read_register(DATABASE_REG);
- obj_sec = find_pc_section (pc);
- if (obj_sec != NULL)
- {
- if (obj_sec->objfile != symfile_objfile)
- new_symfile_objfile(obj_sec->objfile, 1, 0);
- offs = ((struct section_offsets *)
- alloca (sizeof (struct section_offsets)
- + (symfile_objfile->num_sections * sizeof (offs->offsets))));
- memcpy (offs, symfile_objfile->section_offsets,
- (sizeof (struct section_offsets) +
- (symfile_objfile->num_sections * sizeof (offs->offsets))));
- ANOFFSET (offs, SECT_OFF_DATA) = addr;
- ANOFFSET (offs, SECT_OFF_BSS) = addr;
-
- objfile_relocate(symfile_objfile, offs);
- }
-
- return 0;
-}
-
-/* Return the name of register number regno in the form input and output by
- monitor. Currently, register_names just happens to contain exactly what
- monitor wants. Lets take advantage of that just as long as possible! */
-
-static char *
-get_reg_name (regno)
- int regno;
-{
- static char buf[50];
- char *p;
- char *b;
-
- b = buf;
-
- if (regno < 0)
- return ("");
-/*
- for (p = REGISTER_NAME (regno); *p; p++)
- *b++ = toupper(*p);
- *b = '\000';
-*/
- p = (char *)REGISTER_NAME (regno);
- return p;
-/*
- return buf;
-*/
-}
-
-/* read the remote registers into the block regs. */
-
-static void
-rombug_fetch_registers ()
-{
- int regno, j, i;
- long val;
- unsigned char b;
-
- printf_monitor (GET_REG);
- expect("eax:", 1);
- expect("\n", 1);
- get_hex_regs(1, 0);
- get_hex_regs(1, 3);
- get_hex_regs(1, 1);
- get_hex_regs(1, 2);
- get_hex_regs(1, 6);
- get_hex_regs(1, 7);
- get_hex_regs(1, 5);
- get_hex_regs(1, 4);
- for (regno = 8; regno <= 15; regno++)
- {
- expect(REG_DELIM, 1);
- if (regno >= 8 && regno <= 13)
- {
- val = 0;
- for (j = 0; j < 2; j++)
- {
- get_hex_byte (&b);
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
- val = (val << 8) + b;
- else
- val = val + (b << (j*8));
- }
-
- if (regno == 8) i = 10;
- if (regno >= 9 && regno <= 12) i = regno + 3;
- if (regno == 13) i = 11;
- supply_register (i, (char *) &val);
- }
- else if (regno == 14)
- {
- get_hex_regs(1, PC_REGNUM);
- }
- else if (regno == 15)
- {
- get_hex_regs(1, 9);
- }
- else
- {
- val = 0;
- supply_register(regno, (char *) &val);
- }
- }
- is_trace_mode = 0;
- expect_prompt (1);
-}
-
-/* Fetch register REGNO, or all registers if REGNO is -1.
- Returns errno value. */
-static void
-rombug_fetch_register (regno)
- int regno;
-{
- int val, j;
- unsigned char b;
-
- if (monitor_log) {
- fprintf (log_file, "\nIn Fetch Register (reg=%s)\n", get_reg_name (regno));
- fflush (log_file);
- }
-
- if (regno < 0)
- {
- rombug_fetch_registers ();
- }
- else
- {
- char *name = get_reg_name (regno);
- printf_monitor (GET_REG);
- if (regno >= 10 && regno <= 15)
- {
- expect ("\n", 1);
- expect ("\n", 1);
- expect (name, 1);
- expect (REG_DELIM, 1);
- val = 0;
- for (j = 0; j < 2; j++)
- {
- get_hex_byte (&b);
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
- val = (val << 8) + b;
- else
- val = val + (b << (j*8));
- }
- supply_register (regno, (char *) &val);
- }
- else if (regno == 8 || regno == 9)
- {
- expect ("\n", 1);
- expect ("\n", 1);
- expect ("\n", 1);
- expect (name, 1);
- expect (REG_DELIM, 1);
- get_hex_regs (1, regno);
- }
- else
- {
- expect (name, 1);
- expect (REG_DELIM, 1);
- expect("\n", 1);
- get_hex_regs(1, 0);
- get_hex_regs(1, 3);
- get_hex_regs(1, 1);
- get_hex_regs(1, 2);
- get_hex_regs(1, 6);
- get_hex_regs(1, 7);
- get_hex_regs(1, 5);
- get_hex_regs(1, 4);
- }
- expect_prompt (1);
- }
- return;
-}
-
-/* Store the remote registers from the contents of the block REGS. */
-
-static void
-rombug_store_registers ()
-{
- int regno;
-
- for (regno = 0; regno <= PC_REGNUM; regno++)
- rombug_store_register(regno);
-
- registers_changed ();
-}
-
-/* Store register REGNO, or all if REGNO == 0.
- return errno value. */
-static void
-rombug_store_register (regno)
- int regno;
-{
-char *name;
-
- if (monitor_log)
- fprintf (log_file, "\nIn Store_register (regno=%d)\n", regno);
-
- if (regno == -1)
- rombug_store_registers ();
- else
- {
- if (sr_get_debug())
- printf ("Setting register %s to 0x%x\n", get_reg_name (regno), read_register (regno));
-
- name = get_reg_name(regno);
- if (name == 0) return;
- printf_monitor (SET_REG, name, read_register (regno));
-
- is_trace_mode = 0;
- expect_prompt (1);
- }
-}
-
-/* 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
-rombug_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static void
-rombug_files_info ()
-{
- printf ("\tAttached to %s at %d baud.\n",
- dev_name, sr_get_baud_rate());
-}
-
-/* Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR. Returns length moved. */
-static int
-rombug_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- int i;
- char buf[10];
-
- if (monitor_log)
- fprintf (log_file, "\nIn Write_inferior_memory (memaddr=%x, len=%d)\n", memaddr, len);
-
- printf_monitor (MEM_SET_CMD, memaddr);
- for (i = 0; i < len; i++)
- {
- expect (CMD_DELIM, 1);
- printf_monitor ("%x \r", myaddr[i]);
- if (sr_get_debug())
- printf ("\nSet 0x%x to 0x%x\n", memaddr + i, myaddr[i]);
- }
- expect (CMD_DELIM, 1);
- if (CMD_END)
- printf_monitor (CMD_END);
- is_trace_mode = 0;
- expect_prompt (1);
-
- bufaddr = 0;
- buflen = 0;
- return len;
-}
-
-/* Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns length moved. */
-static int
-rombug_read_inferior_memory(memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- int i, j;
-
- /* 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;
-
- if (monitor_log)
- fprintf (log_file, "\nIn Read_inferior_memory (memaddr=%x, len=%d)\n", memaddr, len);
-
- /* 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
- rombug_read_bytes (CORE_ADDR_MAX - 4, foo, 4)
- works--it never adds len To memaddr and gets 0. */
- /* However, something like
- rombug_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) {
- errno = EIO;
- return 0;
- }
- if (bufaddr <= memaddr && (memaddr+len) <= (bufaddr+buflen))
- {
- memcpy(myaddr, &readbuf[memaddr-bufaddr], len);
- return len;
- }
-
- 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);
- if (sr_get_debug())
- printf ("\nDisplay %d bytes at %x\n", len_this_pass, startaddr);
-
- printf_monitor (MEM_DIS_CMD, startaddr, 8);
- expect ("- ", 1);
- for (i = 0; i < 16; i++)
- {
- get_hex_byte (&readbuf[i]);
- }
- bufaddr = startaddr;
- buflen = 16;
- memcpy(&myaddr[count], readbuf, len_this_pass);
- count += len_this_pass;
- startaddr += len_this_pass;
- expect(CMD_DELIM, 1);
- }
- if (CMD_END)
- printf_monitor (CMD_END);
- is_trace_mode = 0;
- expect_prompt (1);
-
- return len;
-}
-
-/* FIXME-someday! merge these two. */
-static int
-rombug_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 rombug_write_inferior_memory (memaddr, myaddr, len);
- else
- return rombug_read_inferior_memory (memaddr, myaddr, len);
-}
-
-static void
-rombug_kill (args, from_tty)
- char *args;
- int from_tty;
-{
- return; /* ignore attempts to kill target system */
-}
-
-/* Clean up when a program exits.
- The program actually lives on in the remote processor's RAM, and may be
- run again without a download. Don't leave it full of breakpoint
- instructions. */
-
-static void
-rombug_mourn_inferior ()
-{
- remove_breakpoints ();
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-
-#define MAX_MONITOR_BREAKPOINTS 16
-
-static CORE_ADDR breakaddr[MAX_MONITOR_BREAKPOINTS] = {0};
-
-static int
-rombug_insert_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
-{
- int i;
- CORE_ADDR bp_addr = addr;
- int bp_size = 0;
-
- if (monitor_log)
- fprintf (log_file, "\nIn Insert_breakpoint (addr=%x)\n", addr);
- BREAKPOINT_FROM_PC (&bp_addr, &bp_size);
-
- for (i = 0; i <= MAX_MONITOR_BREAKPOINTS; i++)
- if (breakaddr[i] == 0)
- {
- breakaddr[i] = addr;
- if (sr_get_debug())
- printf ("Breakpoint at %x\n", addr);
- rombug_read_inferior_memory (bp_addr, shadow, bp_size);
- printf_monitor(SET_BREAK_CMD, addr);
- is_trace_mode = 0;
- expect_prompt(1);
- return 0;
- }
-
- fprintf(stderr, "Too many breakpoints (> 16) for monitor\n");
- return 1;
-}
-
-/*
- * _remove_breakpoint -- Tell the monitor to remove a breakpoint
- */
-static int
-rombug_remove_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
-{
- int i;
-
- if (monitor_log)
- fprintf (log_file, "\nIn Remove_breakpoint (addr=%x)\n", addr);
-
- for (i = 0; i < MAX_MONITOR_BREAKPOINTS; i++)
- if (breakaddr[i] == addr)
- {
- breakaddr[i] = 0;
- printf_monitor(CLR_BREAK_CMD, addr);
- is_trace_mode = 0;
- expect_prompt(1);
- return 0;
- }
-
- fprintf(stderr, "Can't find breakpoint associated with 0x%x\n", addr);
- return 1;
-}
-
-/* Load a file. This is usually an srecord, which is ascii. No
- protocol, just sent line by line. */
-
-#define DOWNLOAD_LINE_SIZE 100
-static void
-rombug_load (arg)
- char *arg;
-{
-/* this part comment out for os9* */
-#if 0
- FILE *download;
- char buf[DOWNLOAD_LINE_SIZE];
- int i, bytes_read;
-
- if (sr_get_debug())
- printf ("Loading %s to monitor\n", arg);
-
- download = fopen (arg, "r");
- if (download == NULL)
- {
- error (sprintf (buf, "%s Does not exist", arg));
- return;
- }
-
- printf_monitor (LOAD_CMD);
-/* expect ("Waiting for S-records from host... ", 1); */
-
- while (!feof (download))
- {
- bytes_read = fread (buf, sizeof (char), DOWNLOAD_LINE_SIZE, download);
- if (hashmark)
- {
- putchar ('.');
- fflush (stdout);
- }
-
- if (SERIAL_WRITE(monitor_desc, buf, bytes_read)) {
- fprintf(stderr, "SERIAL_WRITE failed: (while downloading) %s\n", safe_strerror(errno));
- break;
- }
- i = 0;
- while (i++ <=200000) {} ; /* Ugly HACK, probably needs flow control */
- if (bytes_read < DOWNLOAD_LINE_SIZE)
- {
- if (!feof (download))
- error ("Only read %d bytes\n", bytes_read);
- break;
- }
- }
-
- if (hashmark)
- {
- putchar ('\n');
- }
- if (!feof (download))
- error ("Never got EOF while downloading");
- fclose (download);
-#endif 0
-}
-
-/* Put a command string, in args, out to MONITOR.
- Output from MONITOR is placed on the users terminal until the prompt
- is seen. */
-
-static void
-rombug_command (args, fromtty)
- char *args;
- int fromtty;
-{
- if (monitor_desc == NULL)
- error("monitor target not open.");
-
- if (monitor_log)
- fprintf (log_file, "\nIn command (args=%s)\n", args);
-
- if (!args)
- error("Missing command.");
-
- printf_monitor("%s\r", args);
- expect_prompt(0);
-}
-
-#if 0
-/* Connect the user directly to MONITOR. This command acts just like the
- 'cu' or 'tip' command. Use <CR>~. or <CR>~^D to break out. */
-
-static struct ttystate ttystate;
-
-static void
-cleanup_tty()
-{ printf("\r\n[Exiting connect mode]\r\n");
- /*SERIAL_RESTORE(0, &ttystate);*/
-}
-
-static void
-connect_command (args, fromtty)
- char *args;
- int fromtty;
-{
- fd_set readfds;
- int numfds;
- int c;
- char cur_esc = 0;
-
- dont_repeat();
-
- if (monitor_desc == NULL)
- error("monitor target not open.");
-
- if (args)
- fprintf("This command takes no args. They have been ignored.\n");
-
- printf("[Entering connect mode. Use ~. or ~^D to escape]\n");
-
- serial_raw(0, &ttystate);
-
- make_cleanup(cleanup_tty, 0);
-
- FD_ZERO(&readfds);
-
- while (1)
- {
- do
- {
- FD_SET(0, &readfds);
- FD_SET(monitor_desc, &readfds);
- numfds = select(sizeof(readfds)*8, &readfds, 0, 0, 0);
- }
- while (numfds == 0);
-
- if (numfds < 0)
- perror_with_name("select");
-
- if (FD_ISSET(0, &readfds))
- { /* tty input, send to monitor */
- c = getchar();
- if (c < 0)
- perror_with_name("connect");
-
- printf_monitor("%c", c);
- switch (cur_esc)
- {
- case 0:
- if (c == '\r')
- cur_esc = c;
- break;
- case '\r':
- if (c == '~')
- cur_esc = c;
- else
- cur_esc = 0;
- break;
- case '~':
- if (c == '.' || c == '\004')
- return;
- else
- cur_esc = 0;
- }
- }
-
- if (FD_ISSET(monitor_desc, &readfds))
- {
- while (1)
- {
- c = readchar(0);
- if (c < 0)
- break;
- putchar(c);
- }
- fflush(stdout);
- }
- }
-}
-#endif
-
-/*
- * Define the monitor command strings. Since these are passed directly
- * through to a printf style function, we need can include formatting
- * strings. We also need a CR or LF on the end.
- */
-#warning FIXME: monitor interface pattern strings, stale struct decl
-struct monitor_ops rombug_cmds = {
- "g \r", /* execute or usually GO command */
- "g \r", /* continue command */
- "t \r", /* single step */
- "b %x\r", /* set a breakpoint */
- "k %x\r", /* clear a breakpoint */
- "c %x\r", /* set memory to a value */
- "d %x %d\r", /* display memory */
- "$%08X", /* prompt memory commands use */
- ".%s %x\r", /* set a register */
- ":", /* delimiter between registers */
- ". \r", /* read a register */
- "mf \r", /* download command */
- "RomBug: ", /* monitor command prompt */
- ": ", /* end-of-command delimitor */
- ".\r" /* optional command terminator */
-};
-
-struct target_ops rombug_ops ;
-
-static void
-init_rombug_ops(void)
-{
- rombug_ops.to_shortname = "rombug";
- rombug_ops.to_longname = "Microware's ROMBUG debug monitor";
- rombug_ops.to_doc = "Use a remote computer running the ROMBUG debug monitor.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).",
- rombug_ops.to_open = rombug_open;
- rombug_ops.to_close = rombug_close;
- rombug_ops.to_attach = 0;
- rombug_ops.to_post_attach = NULL;
- rombug_ops.to_require_attach = NULL;
- rombug_ops.to_detach = rombug_detach;
- rombug_ops.to_require_detach = NULL;
- rombug_ops.to_resume = rombug_resume;
- rombug_ops.to_wait = rombug_wait;
- rombug_ops.to_post_wait = NULL;
- rombug_ops.to_fetch_registers = rombug_fetch_register;
- rombug_ops.to_store_registers = rombug_store_register;
- rombug_ops.to_prepare_to_store = rombug_prepare_to_store;
- rombug_ops.to_xfer_memory = rombug_xfer_inferior_memory;
- rombug_ops.to_files_info = rombug_files_info;
- rombug_ops.to_insert_breakpoint = rombug_insert_breakpoint;
- rombug_ops.to_remove_breakpoint = rombug_remove_breakpoint; /* Breakpoints */
- rombug_ops.to_terminal_init = 0;
- rombug_ops.to_terminal_inferior = 0;
- rombug_ops.to_terminal_ours_for_output = 0;
- rombug_ops.to_terminal_ours = 0;
- rombug_ops.to_terminal_info = 0; /* Terminal handling */
- rombug_ops.to_kill = rombug_kill;
- rombug_ops.to_load = rombug_load; /* load */
- rombug_ops.to_lookup_symbol = rombug_link; /* lookup_symbol */
- rombug_ops.to_create_inferior = rombug_create_inferior;
- rombug_ops.to_post_startup_inferior = NULL;
- rombug_ops.to_acknowledge_created_inferior = NULL;
- rombug_ops.to_clone_and_follow_inferior = NULL;
- rombug_ops.to_post_follow_inferior_by_clone = NULL;
- rombug_ops.to_insert_fork_catchpoint = NULL;
- rombug_ops.to_remove_fork_catchpoint = NULL;
- rombug_ops.to_insert_vfork_catchpoint = NULL;
- rombug_ops.to_remove_vfork_catchpoint = NULL;
- rombug_ops.to_has_forked = NULL;
- rombug_ops.to_has_vforked = NULL;
- rombug_ops.to_can_follow_vfork_prior_to_exec = NULL;
- rombug_ops.to_post_follow_vfork = NULL;
- rombug_ops.to_insert_exec_catchpoint = NULL;
- rombug_ops.to_remove_exec_catchpoint = NULL;
- rombug_ops.to_has_execd = NULL;
- rombug_ops.to_reported_exec_events_per_exec_call = NULL;
- rombug_ops.to_has_exited = NULL;
- rombug_ops.to_mourn_inferior = rombug_mourn_inferior;
- rombug_ops.to_can_run = 0; /* can_run */
- rombug_ops.to_notice_signals = 0; /* notice_signals */
- rombug_ops.to_thread_alive = 0;
- rombug_ops.to_stop = 0; /* to_stop */
- rombug_ops.to_pid_to_exec_file = NULL;
- rombug_ops.to_core_file_to_sym_file = NULL;
- rombug_ops.to_stratum = process_stratum;
- rombug_ops.DONT_USE = 0; /* next */
- rombug_ops.to_has_all_memory = 1;
- rombug_ops.to_has_memory = 1;
- rombug_ops.to_has_stack = 1;
- rombug_ops.to_has_registers = 1;
- rombug_ops.to_has_execution = 1; /* has execution */
- rombug_ops.to_sections = 0;
- rombug_ops.to_sections_end = 0; /* Section pointers */
- rombug_ops.to_magic = OPS_MAGIC; /* Always the last thing */
-}
-
-void
-_initialize_remote_os9k ()
-{
- init_rombug_ops() ;
- add_target (&rombug_ops);
-
- add_show_from_set (
- add_set_cmd ("hash", no_class, var_boolean, (char *)&hashmark,
- "Set display of activity while downloading a file.\nWhen enabled, a period \'.\' is displayed.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("timeout", no_class, var_zinteger,
- (char *) &timeout,
- "Set timeout in seconds for remote MIPS serial I/O.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("remotelog", no_class, var_zinteger,
- (char *) &monitor_log,
- "Set monitor activity log on(=1) or off(=0).",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("remotexon", no_class, var_zinteger,
- (char *) &tty_xon,
- "Set remote tty line XON control",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("remotexoff", no_class, var_zinteger,
- (char *) &tty_xoff,
- "Set remote tty line XOFF control",
- &setlist),
- &showlist);
-
- add_com ("rombug <command>", class_obscure, rombug_command,
- "Send a command to the debug monitor.");
-#if 0
- add_com ("connect", class_obscure, connect_command,
- "Connect the terminal directly up to a serial based command monitor.\nUse <CR>~. or <CR>~^D to break out.");
-#endif
-}
diff --git a/contrib/gdb/gdb/remote-pa.c b/contrib/gdb/gdb/remote-pa.c
deleted file mode 100644
index 1121e15..0000000
--- a/contrib/gdb/gdb/remote-pa.c
+++ /dev/null
@@ -1,1540 +0,0 @@
-/* Remote target communications for serial-line targets in custom GDB protocol
- Copyright 1988, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Remote communication protocol.
-
- A debug packet whose contents are <data>
- is encapsulated for transmission in the form:
-
- $ <data> # CSUM1 CSUM2
-
- <data> must be ASCII alphanumeric and cannot include characters
- '$' or '#'. If <data> starts with two characters followed by
- ':', then the existing stubs interpret this as a sequence number.
-
- CSUM1 and CSUM2 are ascii hex representation of an 8-bit
- checksum of <data>, 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
-
- <data> is as follows:
- 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
-
- write reg Pn...=r... Write register n... with value r...,
- which contains two hex digits for each
- byte in the register (target byte
- order).
- reply OK for success
- ENN for an error
- (not supported by all stubs).
-
- read mem mAA..AA,LLLL AA..AA is address, LLLL is length.
- reply XX..XX XX..XX is mem contents
- Can be fewer bytes than requested
- if able to read only part of the data.
- 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 (this includes the case
- where only part of the data was
- written).
-
- 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"
-
- or... TAAn...:r...;n:r...;n...:r...;
- AA = signal number
- n... = register number
- r... = register contents
- or... WAA The process exited, and AA is
- the exit status. This is only
- applicable for certains sorts of
- targets.
- kill request k
-
- toggle debug d toggle debug flag (see 386 & 68k stubs)
- reset r reset -- see sparc stub.
- reserved <other> On other requests, the stub should
- ignore the request and send an empty
- response ($#<checksum>). This way
- we can extend the protocol and GDB
- can tell whether the stub it is
- talking to uses the old or the new.
- search tAA:PP,MM Search backwards starting at address
- AA for a match with pattern PP and
- mask MM. PP and MM are 4 bytes.
- Not supported by all stubs.
-
- general query qXXXX Request info about XXXX.
- general set QXXXX=yyyy Set value of XXXX to yyyy.
- query sect offs qOffsets Get section offsets. Reply is
- Text=xxx;Data=yyy;Bss=zzz
- console output Otext Send text to stdout. Only comes from
- remote target.
-
- Responses can be run-length encoded to save space. A '*' means that
- the next character is an ASCII encoding giving a repeat count which
- stands for that many repititions of the character preceding the '*'.
- The encoding is n+29, yielding a printable character where n >=3
- (which is where rle starts to win). Don't use an n > 126.
-
- So
- "0* " means the same as "0000". */
-
-#include "defs.h"
-#include "gdb_string.h"
-#include <fcntl.h>
-#include "frame.h"
-#include "inferior.h"
-#include "bfd.h"
-#include "symfile.h"
-#include "target.h"
-#include "wait.h"
-#include "terminal.h"
-#include "gdbcmd.h"
-#include "objfiles.h"
-#include "gdb-stabs.h"
-#include "remote-utils.h"
-#include "dcache.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <signal.h>
-#include "serial.h"
-
-/* Prototypes for local functions */
-
-static int
-remote_write_bytes PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
-
-static int
-remote_read_bytes PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
-
-static void
-remote_files_info PARAMS ((struct target_ops *ignore));
-
-static int
-remote_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
- int should_write, struct target_ops *target));
-
-static void
-remote_prepare_to_store PARAMS ((void));
-
-static void
-remote_fetch_registers PARAMS ((int regno));
-
-static void
-remote_resume PARAMS ((int pid, int step, enum target_signal siggnal));
-
-static int
-remote_start_remote PARAMS ((char *dummy));
-
-static void
-remote_open PARAMS ((char *name, int from_tty));
-
-static void
-remote_close PARAMS ((int quitting));
-
-static void
-remote_store_registers PARAMS ((int regno));
-
-static void
-getpkt PARAMS ((char *buf, int forever));
-
-static void
-putpkt PARAMS ((char *buf));
-
-static void
-remote_send PARAMS ((char *buf));
-
-static int
-readchar PARAMS ((int timeout));
-
-static int
-remote_wait PARAMS ((int pid, struct target_waitstatus *status));
-
-static int
-tohex PARAMS ((int nib));
-
-static int
-fromhex PARAMS ((int a));
-
-static void
-remote_detach PARAMS ((char *args, int from_tty));
-
-static void
-remote_interrupt PARAMS ((int signo));
-
-static void
-remote_interrupt_twice PARAMS ((int signo));
-
-static void
-interrupt_query PARAMS ((void));
-
-static void
-hppro_load PARAMS ((char *name, int from_tty));
-
-extern struct target_ops remote_ops; /* Forward decl */
-
-/* This was 5 seconds, which is a long time to sit and wait.
- Unless this is going though some terminal server or multiplexer or
- other form of hairy serial connection, I would think 2 seconds would
- be plenty. */
-static int remote_timeout = 2;
-
-/* Descriptor for I/O to remote machine. Initialize it to NULL so that
- remote_open knows that we don't have a file open when the program
- starts. */
-extern serial_t remote_desc;
-
-/* Having this larger than 400 causes us to be incompatible with m68k-stub.c
- and i386-stub.c. Normally, no one would notice because it only matters
- for writing large chunks of memory (e.g. in downloads). Also, this needs
- to be more than 400 if required to hold the registers (see below, where
- we round it up based on REGISTER_BYTES). */
-#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)
-
-/* Round up PBUFSIZ to hold all the registers, at least. */
-/* The blank line after the #if seems to be required to work around a
- bug in HP's PA compiler. */
-#if REGISTER_BYTES > MAXBUFBYTES
-
-#undef PBUFSIZ
-#define PBUFSIZ (REGISTER_BYTES * 2 + 32)
-#endif
-
-/* Should we try the 'P' request? If this is set to one when the stub
- doesn't support 'P', the only consequence is some unnecessary traffic. */
-static int stub_supports_P = 1;
-
-/* sets the download protocol, choices are srec, generic, boot */
-char *loadtype;
-static char *loadtype_str;
-static void set_loadtype_command
-PARAMS ((char *, int, struct cmd_list_element *));
-
-static void
-hppro_load (file, from_tty)
- char *file;
- int from_tty;
-{
- puts ("Loading... HA!");
-}
-
-
-/* Clean up connection to a remote debugger. */
-
-/* ARGSUSED */
-static void
-remote_close (quitting)
- int quitting;
-{
- if (remote_desc)
- SERIAL_CLOSE (remote_desc);
- remote_desc = NULL;
-}
-
-/* Query the remote side for the text, data and bss offsets. */
-
-static void
-get_offsets ()
-{
- unsigned char buf[PBUFSIZ];
- int nvals;
- CORE_ADDR text_addr, data_addr, bss_addr;
- struct section_offsets *offs;
-
- putpkt ("qOffsets");
-
- getpkt (buf, 0);
-
- if (buf[0] == '\000')
- return; /* Return silently. Stub doesn't support this
- command. */
- if (buf[0] == 'E')
- {
- warning ("Remote failure reply: %s", buf);
- return;
- }
-
- nvals = sscanf (buf, "Text=%lx;Data=%lx;Bss=%lx", &text_addr, &data_addr,
- &bss_addr);
- if (nvals != 3)
- error ("Malformed response to offset query, %s", buf);
-
- if (symfile_objfile == NULL)
- return;
-
- offs = (struct section_offsets *) alloca (sizeof (struct section_offsets)
- + symfile_objfile->num_sections
- * sizeof (offs->offsets));
- memcpy (offs, symfile_objfile->section_offsets,
- sizeof (struct section_offsets)
- + symfile_objfile->num_sections
- * sizeof (offs->offsets));
-
- /* FIXME: This code assumes gdb-stabs.h is being used; it's broken
- for xcoff, dwarf, sdb-coff, etc. But there is no simple
- canonical representation for this stuff. (Just what does "text"
- as seen by the stub mean, anyway? I think it means all sections
- with SEC_CODE set, but we currently have no way to deal with that). */
-
- ANOFFSET (offs, SECT_OFF_TEXT) = text_addr;
-
- /* This is a temporary kludge to force data and bss to use the same offsets
- because that's what nlmconv does now. The real solution requires changes
- to the stub and remote.c that I don't have time to do right now. */
-
- ANOFFSET (offs, SECT_OFF_DATA) = data_addr;
- ANOFFSET (offs, SECT_OFF_BSS) = data_addr;
-
- objfile_relocate (symfile_objfile, offs);
-}
-
-#define INBUFSIZE 10
-
-void
-boot_board()
-{
- char c;
- char buf[INBUFSIZE];
- char *ptr;
-
- /* See if we can connect to the boot ROM command line */
- ptr = buf;
- while (1) {
- SERIAL_WRITE (remote_desc, "\r\n", 2);
- c = readchar (2);
- if ((sr_get_debug() > 2) && (isascii(c)))
- putchar (c);
- if (c == SERIAL_TIMEOUT) {
- if (sr_get_debug())
- puts_filtered ("Timed out.\n");
- break;
- }
- if (c == '&') {
- if (sr_get_debug() > 2)
- puts ("Got ACK from stub");
- break;
- }
- if (c == '>') {
- if (sr_get_debug() > 2)
- puts ("Got prompt from ROM monitor");
- break;
- }
- }
-
-}
-
-/* Stub for catch_errors. */
-static int
-remote_start_remote (dummy)
- char *dummy;
-{
- int timeout;
-
- immediate_quit = 1; /* Allow user to interrupt it */
-
- /* Ack any packet which the remote side has already sent. */
-
- if (sr_get_debug())
- puts ("Trying a '+' to ACK the target.");
-
- SERIAL_WRITE (remote_desc, "+", 1);
-
-#if 0
- boot_board();
-
- get_offsets (); /* Get text, data & bss offsets */
-#endif
-
- putpkt ("?"); /* initiate a query from remote machine */
- immediate_quit = 0;
-
- start_remote (); /* Initialize gdb process mechanisms */
-
- return 1;
-}
-
-/* Open a connection to a remote debugger.
- NAME is the filename used for communication. */
-
-static DCACHE *remote_dcache;
-
-static void
-remote_open (name, from_tty)
- char *name;
- int from_tty;
-{
- 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);
-
- unpush_target (&remote_ops);
-
- remote_dcache = dcache_init (remote_read_bytes, remote_write_bytes);
-
- remote_desc = SERIAL_OPEN (name);
- if (!remote_desc)
- perror_with_name (name);
-
- if (baud_rate != -1)
- {
- if (SERIAL_SETBAUDRATE (remote_desc, baud_rate))
- {
- SERIAL_CLOSE (remote_desc);
- perror_with_name (name);
- }
- }
-
- SERIAL_RAW (remote_desc);
-
- /* If there is something sitting in the buffer we might take it as a
- response to a command, which would be bad. */
- SERIAL_FLUSH_INPUT (remote_desc);
-
- if (from_tty)
- {
- puts_filtered ("Remote debugging using ");
- puts_filtered (name);
- puts_filtered ("\n");
- }
- push_target (&remote_ops); /* Switch to using remote target now */
-
- /* Start out by trying the 'P' request to set registers. We set this each
- time that we open a new target so that if the user switches from one
- stub to another, we can (if the target is closed and reopened) cope. */
- stub_supports_P = 1;
-
- /* Without this, some commands which require an active target (such as kill)
- won't work. This variable serves (at least) double duty as both the pid
- of the target process (if it has such), and as a flag indicating that a
- target is active. These functions should be split out into seperate
- variables, especially since GDB will someday have a notion of debugging
- several processes. */
-
- inferior_pid = 42000;
-
- /* Start the remote connection; if error (0), discard this target.
- In particular, if the user quits, be sure to discard it
- (we'd be in an inconsistent state otherwise). */
- if (!catch_errors (remote_start_remote, (char *)0,
- "Couldn't establish connection to remote target\n", RETURN_MASK_ALL))
- pop_target();
-}
-
-/* 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)
- puts_filtered ("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");
-}
-
-/* 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. */
-
-static void
-remote_resume (pid, step, siggnal)
- int pid, step;
- enum target_signal siggnal;
-{
- char buf[PBUFSIZ];
-
- if (siggnal)
- {
- target_terminal_ours_for_output ();
- printf_filtered
- ("Can't send signals to a remote system. %s not sent.\n",
- target_signal_to_name (siggnal)); target_terminal_inferior ();
- }
-
- dcache_flush (remote_dcache);
-
- strcpy (buf, step ? "s": "c");
-
- putpkt (buf);
-}
-
-/* Send ^C to target to halt it. Target will respond, and send us a
- packet. */
-
-static void
-remote_interrupt (signo)
- int signo;
-{
- /* If this doesn't work, try more severe steps. */
- signal (signo, remote_interrupt_twice);
-
- if (remote_debug)
- printf_unfiltered ("remote_interrupt called\n");
-
- SERIAL_WRITE (remote_desc, "\003", 1); /* Send a ^C */
-}
-
-static void (*ofunc)();
-
-/* The user typed ^C twice. */
-static void
-remote_interrupt_twice (signo)
- int signo;
-{
- signal (signo, ofunc);
-
- interrupt_query ();
-
- signal (signo, remote_interrupt);
-}
-
-/* Ask the user what to do when an interrupt is received. */
-
-static void
-interrupt_query ()
-{
- target_terminal_ours ();
-
- if (query ("Interrupted while waiting for the program.\n\
-Give up (and stop debugging it)? "))
- {
- target_mourn_inferior ();
- return_to_top_level (RETURN_QUIT);
- }
-
- target_terminal_inferior ();
-}
-
-/* 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). */
-
-static int
-remote_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- unsigned char buf[PBUFSIZ];
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- while (1)
- {
- unsigned char *p;
-
- ofunc = (void (*)()) signal (SIGINT, remote_interrupt);
- getpkt ((char *) buf, 1);
- signal (SIGINT, ofunc);
-
- switch (buf[0])
- {
- case 'E': /* Error of some sort */
- warning ("Remote failure reply: %s", buf);
- continue;
- case 'T': /* Status with PC, SP, FP, ... */
- {
- int i;
- long regno;
- char regs[MAX_REGISTER_RAW_SIZE];
-
- /* Expedited reply, containing Signal, {regno, reg} repeat */
- /* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where
- ss = signal number
- n... = register number
- r... = register contents
- */
-
- p = &buf[3]; /* after Txx */
-
- while (*p)
- {
- unsigned char *p1;
-
- regno = strtol (p, (char **) &p1, 16); /* Read the register number */
-
- if (p1 == p)
- warning ("Remote sent badly formed register number: %s\nPacket: '%s'\n",
- p1, buf);
-
- p = p1;
-
- if (*p++ != ':')
- warning ("Malformed packet (missing colon): %s\nPacket: '%s'\n",
- p, buf);
-
- if (regno >= NUM_REGS)
- warning ("Remote sent bad register number %d: %s\nPacket: '%s'\n",
- regno, p, buf);
-
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i++)
- {
- if (p[0] == 0 || p[1] == 0)
- warning ("Remote reply is too short: %s", buf);
- regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
- p += 2;
- }
-
- if (*p++ != ';')
- warning ("Remote register badly formatted: %s", buf);
-
- supply_register (regno, regs);
- }
- }
- /* fall through */
- case 'S': /* Old style status, just signal only */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = (enum target_signal)
- (((fromhex (buf[1])) << 4) + (fromhex (buf[2])));
-
- return inferior_pid;
- case 'W': /* Target exited */
- {
- /* The remote process exited. */
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = (fromhex (buf[1]) << 4) + fromhex (buf[2]);
- return inferior_pid;
- }
- case 'O': /* Console output */
- fputs_filtered (buf + 1, gdb_stdout);
- continue;
- default:
- warning ("Invalid remote reply: %s", buf);
- continue;
- }
- }
- return inferior_pid;
-}
-
-/* Number of bytes of registers this stub implements. */
-static int register_bytes_found;
-
-/* Read the remote registers into the block REGS. */
-/* Currently we just read all the registers, so we don't use regno. */
-/* ARGSUSED */
-static void
-remote_fetch_registers (regno)
- int regno;
-{
- char buf[PBUFSIZ];
- int i;
- char *p;
- char regs[REGISTER_BYTES];
-
- sprintf (buf, "g");
- remote_send (buf);
-
- /* Unimplemented registers read as all bits zero. */
- memset (regs, 0, REGISTER_BYTES);
-
- /* We can get out of synch in various cases. If the first character
- in the buffer is not a hex character, assume that has happened
- and try to fetch another packet to read. */
- while ((buf[0] < '0' || buf[0] > '9')
- && (buf[0] < 'a' || buf[0] > 'f'))
- {
- if (remote_debug)
- printf_unfiltered ("Bad register packet; fetching a new packet\n");
- getpkt (buf, 0);
- }
-
- /* 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)
- break;
- if (p[1] == 0)
- {
- warning ("Remote reply is of odd length: %s", buf);
- /* Don't change register_bytes_found in this case, and don't
- print a second warning. */
- goto supply_them;
- }
- regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
- p += 2;
- }
-
- if (i != register_bytes_found)
- {
- register_bytes_found = i;
-#ifdef REGISTER_BYTES_OK
- if (!REGISTER_BYTES_OK (i))
- warning ("Remote reply is too short: %s", buf);
-#endif
- }
-
- supply_them:
- for (i = 0; i < NUM_REGS; i++)
- supply_register (i, &regs[REGISTER_BYTE(i)]);
-}
-
-/* Prepare to store registers. Since we may send them all (using a
- 'G' request), we have to read out the ones we don't want to change
- first. */
-
-static void
-remote_prepare_to_store ()
-{
- /* Make sure the entire registers array is valid. */
- read_register_bytes (0, (char *)NULL, REGISTER_BYTES);
-}
-
-/* Store register REGNO, or all registers if REGNO == -1, from the contents
- of REGISTERS. FIXME: ignores errors. */
-
-static void
-remote_store_registers (regno)
- int regno;
-{
- char buf[PBUFSIZ];
- int i;
- char *p;
-
- if (regno >= 0 && stub_supports_P)
- {
- /* Try storing a single register. */
- char *regp;
-
- sprintf (buf, "P%x=", regno);
- p = buf + strlen (buf);
- regp = &registers[REGISTER_BYTE (regno)];
- for (i = 0; i < REGISTER_RAW_SIZE (regno); ++i)
- {
- *p++ = tohex ((regp[i] >> 4) & 0xf);
- *p++ = tohex (regp[i] & 0xf);
- }
- *p = '\0';
- remote_send (buf);
- if (buf[0] != '\0')
- {
- /* The stub understands the 'P' request. We are done. */
- return;
- }
-
- /* The stub does not support the 'P' request. Use 'G' instead,
- and don't try using 'P' in the future (it will just waste our
- time). */
- stub_supports_P = 0;
- }
-
- buf[0] = 'G';
-
- /* Command describes registers byte by byte,
- each byte encoded as two hex characters. */
-
- p = buf + 1;
- /* remote_prepare_to_store insures that register_bytes_found gets set. */
- for (i = 0; i < register_bytes_found; i++)
- {
- *p++ = tohex ((registers[i] >> 4) & 0xf);
- *p++ = tohex (registers[i] & 0xf);
- }
- *p = '\0';
-
- remote_send (buf);
-}
-
-#if 0
-
-/* Use of the data cache is disabled because it loses for looking at
- and changing hardware I/O ports and the like. Accepting `volatile'
- would perhaps be one way to fix it. Another idea would be to use the
- executable file for the text segment (for all SEC_CODE sections?
- For all SEC_READONLY sections?). This has problems if you want to
- actually see what the memory contains (e.g. self-modifying code,
- clobbered memory, user downloaded the wrong thing). */
-
-/* Read a word from remote address ADDR and return it.
- This goes through the data cache. */
-
-static int
-remote_fetch_word (addr)
- CORE_ADDR addr;
-{
- return dcache_fetch (remote_dcache, addr);
-}
-
-/* Write a word WORD into remote address ADDR.
- This goes through the data cache. */
-
-static void
-remote_store_word (addr, word)
- CORE_ADDR addr;
- int word;
-{
- dcache_poke (remote_dcache, 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.
-
- Returns number of bytes transferred, or 0 for error. */
-
-static int
-remote_write_bytes (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- char buf[PBUFSIZ];
- int i;
- char *p;
-
- /* FIXME-32x64: Need a version of print_address_numeric which puts the
- result in a buffer like sprintf. */
- sprintf (buf, "M%lx,%x:", (unsigned long) memaddr, len);
-
- /* We send target system values byte by byte, in increasing byte addresses,
- 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';
-
- putpkt (buf);
- getpkt (buf, 0);
-
- if (buf[0] == 'E')
- {
- /* There is no correspondance between what the remote protocol uses
- for errors and errno codes. We would like a cleaner way of
- representing errors (big enough to include errno codes, bfd_error
- codes, and others). But for now just return EIO. */
- errno = EIO;
- return 0;
- }
- return len;
-}
-
-/* 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.
-
- Returns number of bytes transferred, or 0 for error. */
-
-static int
-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 ();
-
- /* FIXME-32x64: Need a version of print_address_numeric which puts the
- result in a buffer like sprintf. */
- sprintf (buf, "m%lx,%x", (unsigned long) memaddr, len);
- putpkt (buf);
- getpkt (buf, 0);
-
- if (buf[0] == 'E')
- {
- /* There is no correspondance between what the remote protocol uses
- for errors and errno codes. We would like a cleaner way of
- representing errors (big enough to include errno codes, bfd_error
- codes, and others). But for now just return EIO. */
- errno = EIO;
- return 0;
- }
-
- /* Reply describes memory 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)
- /* Reply is short. This means that we were able to read only part
- of what we wanted to. */
- break;
- myaddr[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
- p += 2;
- }
- return i;
-}
-
-/* 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. */
-
-/* ARGSUSED */
-static int
-remote_xfer_memory(memaddr, myaddr, len, should_write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int should_write;
- struct target_ops *target; /* ignored */
-{
- int xfersize;
- int bytes_xferred;
- int total_xferred = 0;
-
- while (len > 0)
- {
- if (len > MAXBUFBYTES)
- xfersize = MAXBUFBYTES;
- else
- xfersize = len;
-
- if (should_write)
- bytes_xferred = remote_write_bytes (memaddr, myaddr, xfersize);
- else
- bytes_xferred = remote_read_bytes (memaddr, myaddr, xfersize);
-
- /* If we get an error, we are done xferring. */
- if (bytes_xferred == 0)
- break;
-
- memaddr += bytes_xferred;
- myaddr += bytes_xferred;
- len -= bytes_xferred;
- total_xferred += bytes_xferred;
- }
- return total_xferred;
-}
-
-#if 0
-/* Enable after 4.12. */
-
-void
-remote_search (len, data, mask, startaddr, increment, lorange, hirange
- addr_found, data_found)
- int len;
- char *data;
- char *mask;
- CORE_ADDR startaddr;
- int increment;
- CORE_ADDR lorange;
- CORE_ADDR hirange;
- CORE_ADDR *addr_found;
- char *data_found;
-{
- if (increment == -4 && len == 4)
- {
- long mask_long, data_long;
- long data_found_long;
- CORE_ADDR addr_we_found;
- char buf[PBUFSIZ];
- long returned_long[2];
- char *p;
-
- mask_long = extract_unsigned_integer (mask, len);
- data_long = extract_unsigned_integer (data, len);
- sprintf (buf, "t%x:%x,%x", startaddr, data_long, mask_long);
- putpkt (buf);
- getpkt (buf, 0);
- if (buf[0] == '\0')
- {
- /* The stub doesn't support the 't' request. We might want to
- remember this fact, but on the other hand the stub could be
- switched on us. Maybe we should remember it only until
- the next "target remote". */
- generic_search (len, data, mask, startaddr, increment, lorange,
- hirange, addr_found, data_found);
- return;
- }
-
- if (buf[0] == 'E')
- /* There is no correspondance between what the remote protocol uses
- for errors and errno codes. We would like a cleaner way of
- representing errors (big enough to include errno codes, bfd_error
- codes, and others). But for now just use EIO. */
- memory_error (EIO, startaddr);
- p = buf;
- addr_we_found = 0;
- while (*p != '\0' && *p != ',')
- addr_we_found = (addr_we_found << 4) + fromhex (*p++);
- if (*p == '\0')
- error ("Protocol error: short return for search");
-
- data_found_long = 0;
- while (*p != '\0' && *p != ',')
- data_found_long = (data_found_long << 4) + fromhex (*p++);
- /* Ignore anything after this comma, for future extensions. */
-
- if (addr_we_found < lorange || addr_we_found >= hirange)
- {
- *addr_found = 0;
- return;
- }
-
- *addr_found = addr_we_found;
- *data_found = store_unsigned_integer (data_we_found, len);
- return;
- }
- generic_search (len, data, mask, startaddr, increment, lorange,
- hirange, addr_found, data_found);
-}
-#endif /* 0 */
-
-static void
-remote_files_info (ignore)
- struct target_ops *ignore;
-{
- puts_filtered ("Debugging a target over a serial line.\n");
-}
-
-/* Stuff for dealing with the packets which are part of this protocol.
- See comment at top of file for details. */
-
-/* Read a single character from the remote end, masking it down to 7 bits. */
-
-static int
-readchar (timeout)
- int timeout;
-{
- int ch;
-
- ch = SERIAL_READCHAR (remote_desc, timeout);
-
- switch (ch)
- {
- case SERIAL_EOF:
- error ("Remote connection closed");
- case SERIAL_ERROR:
- perror_with_name ("Remote communication error");
- case SERIAL_TIMEOUT:
- return ch;
- default:
- return ch & 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, 0);
-
- 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[PBUFSIZ];
- int cnt = strlen (buf);
- int ch;
- char *p;
-
- /* Copy the packet into buffer BUF2, encapsulating it
- and giving it a checksum. */
-
- if (cnt > sizeof(buf2) - 5) /* Prosanity check */
- abort();
-
- 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. */
-
- while (1)
- {
- int started_error_output = 0;
-
- if (remote_debug)
- {
- *p = '\0';
- printf_unfiltered ("Sending packet: %s...", buf2);
- gdb_flush(gdb_stdout);
- }
- if (SERIAL_WRITE (remote_desc, buf2, p - buf2))
- perror_with_name ("putpkt: write failed");
-
- /* read until either a timeout occurs (-2) or '+' is read */
- while (1)
- {
- ch = readchar (remote_timeout);
-
- if (remote_debug)
- {
- switch (ch)
- {
- case '+':
- case SERIAL_TIMEOUT:
- case '$':
- if (started_error_output)
- {
- putchar_unfiltered ('\n');
- started_error_output = 0;
- }
- }
- }
-
- switch (ch)
- {
- case '+':
- if (remote_debug)
- printf_unfiltered("Got Ack\n");
- return;
- case SERIAL_TIMEOUT:
- break; /* Retransmit buffer */
- case '$':
- {
- unsigned char junkbuf[PBUFSIZ];
-
- /* It's probably an old response, and we're out of sync. Just
- gobble up the packet and ignore it. */
- getpkt (junkbuf, 0);
- continue; /* Now, go look for + */
- }
- default:
- if (remote_debug)
- {
- if (!started_error_output)
- {
- started_error_output = 1;
- printf_unfiltered ("putpkt: Junk: ");
- }
- putchar_unfiltered (ch & 0177);
- }
- continue;
- }
- break; /* Here to retransmit */
- }
-
-#if 0
- /* This is wrong. If doing a long backtrace, the user should be
- able to get out next time we call QUIT, without anything as violent
- as interrupt_query. If we want to provide a way out of here
- without getting to the next QUIT, it should be based on hitting
- ^C twice as in remote_wait. */
- if (quit_flag)
- {
- quit_flag = 0;
- interrupt_query ();
- }
-#endif
- }
-}
-
-/* Come here after finding the start of the frame. Collect the rest into BUF,
- verifying the checksum, length, and handling run-length compression.
- Returns 0 on any error, 1 on success. */
-
-static int
-read_frame (buf)
- char *buf;
-{
- unsigned char csum;
- char *bp;
- int c;
-
- csum = 0;
- bp = buf;
-
- while (1)
- {
- c = readchar (remote_timeout);
-
- switch (c)
- {
- case SERIAL_TIMEOUT:
- if (remote_debug)
- puts_filtered ("Timeout in mid-packet, retrying\n");
- return 0;
- case '$':
- if (remote_debug)
- puts_filtered ("Saw new packet start in middle of old one\n");
- return 0; /* Start a new packet, count retries */
- case '#':
- {
- unsigned char pktcsum;
-
- *bp = '\000';
-
- pktcsum = fromhex (readchar (remote_timeout)) << 4;
- pktcsum |= fromhex (readchar (remote_timeout));
-
- if (csum == pktcsum)
- return 1;
-
- printf_filtered ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=",
- pktcsum, csum);
- puts_filtered (buf);
- puts_filtered ("\n");
-
- return 0;
- }
- case '*': /* Run length encoding */
- csum += c;
- c = readchar (remote_timeout);
- csum += c;
- c = c - ' ' + 3; /* Compute repeat count */
-
- if (bp + c - 1 < buf + PBUFSIZ - 1)
- {
- memset (bp, *(bp - 1), c);
- bp += c;
- continue;
- }
-
- *bp = '\0';
- printf_filtered ("Repeat count %d too large for buffer: ", c);
- puts_filtered (buf);
- puts_filtered ("\n");
- return 0;
-
- default:
- if (bp < buf + PBUFSIZ - 1)
- {
- *bp++ = c;
- csum += c;
- continue;
- }
-
- *bp = '\0';
- puts_filtered ("Remote packet too long: ");
- puts_filtered (buf);
- puts_filtered ("\n");
-
- return 0;
- }
- }
-}
-
-/* Read a packet from the remote machine, with error checking,
- and store it in BUF. BUF is expected to be of size PBUFSIZ.
- If FOREVER, wait forever rather than timing out; this is used
- while the target is executing user code. */
-
-static void
-getpkt (buf, forever)
- char *buf;
- int forever;
-{
- char *bp;
- int c;
- int tries;
- int timeout;
- int val;
-
- if (forever)
- timeout = -1;
- else
- timeout = remote_timeout;
-
-#define MAX_TRIES 10
-
- for (tries = 1; tries <= MAX_TRIES; tries++)
- {
- /* This can loop forever if the remote side sends us characters
- continuously, but if it pauses, we'll get a zero from readchar
- because of timeout. Then we'll count that as a retry. */
-
- /* Note that we will only wait forever prior to the start of a packet.
- After that, we expect characters to arrive at a brisk pace. They
- should show up within remote_timeout intervals. */
-
- do
- {
- c = readchar (timeout);
-
- if (c == SERIAL_TIMEOUT)
- {
- if (remote_debug)
- puts_filtered ("Timed out.\n");
- goto retry;
- }
- }
- while (c != '$');
-
- /* We've found the start of a packet, now collect the data. */
-
- val = read_frame (buf);
-
- if (val == 1)
- {
- if (remote_debug)
- fprintf_unfiltered (gdb_stderr, "Packet received: %s\n", buf);
- SERIAL_WRITE (remote_desc, "+", 1);
- return;
- }
-
- /* Try the whole thing again. */
-retry:
- SERIAL_WRITE (remote_desc, "-", 1);
- }
-
- /* We have tried hard enough, and just can't receive the packet. Give up. */
-
- printf_unfiltered ("Ignoring packet error, continuing...\n");
- SERIAL_WRITE (remote_desc, "+", 1);
-}
-
-static void
-remote_kill ()
-{
- putpkt ("k");
- /* Don't wait for it to die. I'm not really sure it matters whether
- we do or not. For the existing stubs, kill is a noop. */
- target_mourn_inferior ();
-}
-
-static void
-remote_mourn ()
-{
- unpush_target (&remote_ops);
- generic_mourn_inferior ();
-}
-
-#ifdef REMOTE_BREAKPOINT
-
-/* On some machines, e.g. 68k, we may use a different breakpoint instruction
- than other targets. */
-static unsigned char break_insn[] = REMOTE_BREAKPOINT;
-
-#else /* No REMOTE_BREAKPOINT. */
-
-/* Same old breakpoint instruction. This code does nothing different
- than mem-break.c. */
-static unsigned char break_insn[] = BREAKPOINT;
-
-#endif /* No REMOTE_BREAKPOINT. */
-
-/* Insert a breakpoint on targets 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 (this
- is accomplished via BREAKPOINT_MAX). */
-
-static int
-remote_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, (char *)break_insn, sizeof break_insn);
-
- return val;
-}
-
-static int
-remote_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- return target_write_memory (addr, contents_cache, sizeof break_insn);
-}
-
-/* Define the target subroutine names */
-
-struct target_ops remote_hppro_ops = {
- "hppro", /* to_shortname */
- "Remote serial target for HP-PRO targets", /* to_longname */
- "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
-This is for targets that supports the HP-PRO standard.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya) or telnet port.", /* to_doc */
- remote_open, /* to_open */
- remote_close, /* to_close */
- NULL, /* to_attach */
- remote_detach, /* to_detach */
- remote_resume, /* to_resume */
- remote_wait, /* to_wait */
- remote_fetch_registers, /* to_fetch_registers */
- remote_store_registers, /* to_store_registers */
- remote_prepare_to_store, /* to_prepare_to_store */
- remote_xfer_memory, /* to_xfer_memory */
- remote_files_info, /* to_files_info */
-
- remote_insert_breakpoint, /* to_insert_breakpoint */
- remote_remove_breakpoint, /* to_remove_breakpoint */
-
- NULL, /* to_terminal_init */
- NULL, /* to_terminal_inferior */
- NULL, /* to_terminal_ours_for_output */
- NULL, /* to_terminal_ours */
- NULL, /* to_terminal_info */
- remote_kill, /* to_kill */
- hppro_load, /* to_load */
- NULL, /* to_lookup_symbol */
- NULL, /* to_create_inferior */
- remote_mourn, /* to_mourn_inferior */
- 0, /* to_can_run */
- 0, /* to_notice_signals */
- 0, /* to_thread_alive */
- 0, /* to_stop */
- process_stratum, /* to_stratum */
- NULL, /* to_next */
- 1, /* to_has_all_memory */
- 1, /* to_has_memory */
- 1, /* to_has_stack */
- 1, /* to_has_registers */
- 1, /* to_has_execution */
- NULL, /* sections */
- NULL, /* sections_end */
- OPS_MAGIC /* to_magic */
-};
-
-void
-_initialize_remote_hppro ()
-{
- struct cmd_list_element *c;
- add_target (&remote_hppro_ops);
-
- /* this sets the type of download protocol */
- c = add_set_cmd ("loadtype", no_class, var_string, (char *)&loadtype_str,
- "Set the type of the remote load protocol.\n", &setlist);
- c->function.sfunc = set_loadtype_command;
- add_show_from_set (c, &showlist);
- loadtype_str = savestring ("generic", 8);
-
- /* this adds a command to boot the board */
- add_com ("boot", class_support, boot_board,
- "Boot the damn target board.\n");
-}
-
-static void
-set_loadtype_command (ignore, from_tty, c)
- char *ignore;
- int from_tty;
- struct cmd_list_element *c;
-{
- loadtype_str = savestring (*(char **) c->var, strlen (*(char **) c->var));
-}
-
diff --git a/contrib/gdb/gdb/remote-rdp.c b/contrib/gdb/gdb/remote-rdp.c
deleted file mode 100644
index 1d596a4..0000000
--- a/contrib/gdb/gdb/remote-rdp.c
+++ /dev/null
@@ -1,1512 +0,0 @@
-/* Remote debugging for the ARM RDP interface.
- Copyright 1994, 1995 Free Software Foundation, Inc.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-
- */
-
-
-/*
- Much of this file (in particular the SWI stuff) is based on code by
- David Taylor (djt1000@uk.ac.cam.hermes).
-
- I hacked on and simplified it by removing a lot of sexy features he
- had added, and some of the (unix specific) workarounds he'd done
- for other GDB problems - which if they still exist should be fixed
- in GDB, not in a remote-foo thing . I also made it conform more to
- the doc I have; which may be wrong.
-
- Steve Chamberlain (sac@cygnus.com).
- */
-
-
-#include "defs.h"
-#include "inferior.h"
-#include "wait.h"
-#include "value.h"
-#include "callback.h"
-#include "command.h"
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <ctype.h>
-#include <fcntl.h>
-#include "symfile.h"
-#include "remote-utils.h"
-#include "gdb_string.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include "gdbcore.h"
-
-
-extern struct target_ops remote_rdp_ops;
-static serial_t io;
-static host_callback *callback = &default_callback;
-
-struct
- {
- int step_info;
- int break_info;
- int model_info;
- int target_info;
- int can_step;
- char command_line[10];
- int rdi_level;
- int rdi_stopped_status;
- }
-ds;
-
-
-
-/* Definitions for the RDP protocol. */
-
-#define RDP_MOUTHFULL (1<<6)
-#define FPU_COPRO_NUMBER 1
-
-#define RDP_OPEN 0
-#define RDP_OPEN_TYPE_COLD 0
-#define RDP_OPEN_TYPE_WARM 1
-#define RDP_OPEN_TYPE_BAUDRATE 2
-
-#define RDP_OPEN_BAUDRATE_9600 1
-#define RDP_OPEN_BAUDRATE_19200 2
-#define RDP_OPEN_BAUDRATE_38400 3
-
-#define RDP_OPEN_TYPE_RETURN_SEX (1<<3)
-
-#define RDP_CLOSE 1
-
-#define RDP_MEM_READ 2
-
-#define RDP_MEM_WRITE 3
-
-#define RDP_CPU_READ 4
-#define RDP_CPU_WRITE 5
-#define RDP_CPU_READWRITE_MODE_CURRENT 255
-#define RDP_CPU_READWRITE_MASK_PC (1<<16)
-#define RDP_CPU_READWRITE_MASK_CPSR (1<<17)
-#define RDP_CPU_READWRITE_MASK_SPSR (1<<18)
-
-#define RDP_COPRO_READ 6
-#define RDP_COPRO_WRITE 7
-#define RDP_FPU_READWRITE_MASK_FPS (1<<8)
-
-#define RDP_SET_BREAK 0xa
-#define RDP_SET_BREAK_TYPE_PC_EQUAL 0
-#define RDP_SET_BREAK_TYPE_GET_HANDLE (0x10)
-
-#define RDP_CLEAR_BREAK 0xb
-
-#define RDP_EXEC 0x10
-#define RDP_EXEC_TYPE_SYNC 0
-
-#define RDP_STEP 0x11
-
-#define RDP_INFO 0x12
-#define RDP_INFO_ABOUT_STEP 2
-#define RDP_INFO_ABOUT_STEP_GT_1 1
-#define RDP_INFO_ABOUT_STEP_TO_JMP 2
-#define RDP_INFO_ABOUT_STEP_1 4
-#define RDP_INFO_ABOUT_TARGET 0
-#define RDP_INFO_ABOUT_BREAK 1
-#define RDP_INFO_ABOUT_BREAK_COMP 1
-#define RDP_INFO_ABOUT_BREAK_RANGE 2
-#define RDP_INFO_ABOUT_BREAK_BYTE_READ 4
-#define RDP_INFO_ABOUT_BREAK_HALFWORD_READ 8
-#define RDP_INFO_ABOUT_BREAK_WORD_READ (1<<4)
-#define RDP_INFO_ABOUT_BREAK_BYTE_WRITE (1<<5)
-#define RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE (1<<6)
-#define RDP_INFO_ABOUT_BREAK_WORD_WRITE (1<<7)
-#define RDP_INFO_ABOUT_BREAK_MASK (1<<8)
-#define RDP_INFO_ABOUT_BREAK_THREAD_BREAK (1<<9)
-#define RDP_INFO_ABOUT_BREAK_THREAD_WATCH (1<<10)
-#define RDP_INFO_ABOUT_BREAK_COND (1<<11)
-#define RDP_INFO_VECTOR_CATCH (0x180)
-#define RDP_INFO_ICEBREAKER (7)
-#define RDP_INFO_SET_CMDLINE (0x300)
-
-#define RDP_SELECT_CONFIG (0x16)
-#define RDI_ConfigCPU 0
-#define RDI_ConfigSystem 1
-#define RDI_MatchAny 0
-#define RDI_MatchExactly 1
-#define RDI_MatchNoEarlier 2
-
-#define RDP_RESET 0x7f
-
-/* Returns from RDP */
-#define RDP_RES_STOPPED 0x20
-#define RDP_RES_SWI 0x21
-#define RDP_RES_FATAL 0x5e
-#define RDP_RES_VALUE 0x5f
-#define RDP_RES_VALUE_LITTLE_ENDIAN 240
-#define RDP_RES_VALUE_BIG_ENDIAN 241
-#define RDP_RES_RESET 0x7f
-#define RDP_RES_AT_BREAKPOINT 143
-#define RDP_RES_IDUNNO 0xe6
-#define RDP_OSOpReply 0x13
-#define RDP_OSOpWord 2
-#define RDP_OSOpNothing 0
-
-static int timeout = 2;
-
-static char * commandline = NULL;
-
-static int
-remote_rdp_xfer_inferior_memory PARAMS ((CORE_ADDR memaddr,
- char *myaddr,
- int len,
- int write,
- struct target_ops * target));
-
-
-/* Stuff for talking to the serial layer. */
-
-static unsigned char
-get_byte ()
-{
- int c = SERIAL_READCHAR (io, timeout);
-
- if (remote_debug)
- printf ("[%02x]\n", c);
-
- if (c == SERIAL_TIMEOUT)
- {
- if (timeout == 0)
- return (unsigned char) c;
-
- error ("Timeout reading from remote_system");
- }
-
- return c;
-}
-
-/* Note that the target always speaks little-endian to us,
- even if it's a big endian machine. */
-static unsigned int
-get_word ()
-{
- unsigned int val = 0;
- unsigned int c;
- int n;
- for (n = 0; n < 4; n++)
- {
- c = get_byte ();
- val |= c << (n * 8);
- }
- return val;
-}
-
-static void
-put_byte (val)
- char val;
-{
- if (remote_debug)
- printf ("(%02x)\n", val);
- SERIAL_WRITE (io, &val, 1);
-}
-
-static void
-put_word (val)
- int val;
-{
- /* We always send in little endian */
- unsigned char b[4];
- b[0] = val;
- b[1] = val >> 8;
- b[2] = val >> 16;
- b[3] = val >> 24;
-
- if (remote_debug)
- printf ("(%04x)", val);
-
- SERIAL_WRITE (io, b, 4);
-}
-
-
-
-/* Stuff for talking to the RDP layer. */
-
-/* This is a bit more fancy that need be so that it syncs even in nasty cases.
-
- I'be been unable to make it reliably sync up with the change
- baudrate open command. It likes to sit and say it's been reset,
- with no more action. So I took all that code out. I'd rather sync
- reliably at 9600 than wait forever for a possible 19200 connection.
-
- */
-static void
-rdp_init (cold, tty)
- int cold;
- int tty;
-{
- int sync = 0;
- int type = cold ? RDP_OPEN_TYPE_COLD : RDP_OPEN_TYPE_WARM;
- int baudtry = 9600;
-
- time_t now = time (0);
- time_t stop_time = now + 10; /* Try and sync for 10 seconds, then give up */
-
-
- while (time (0) < stop_time && !sync)
- {
- int restype;
- QUIT;
-
- SERIAL_FLUSH_INPUT (io);
- SERIAL_FLUSH_OUTPUT (io);
-
- if (tty)
- printf_unfiltered ("Trying to connect at %d baud.\n", baudtry);
-
- /*
- ** It seems necessary to reset an EmbeddedICE to get it going.
- ** This has the side benefit of displaying the startup banner.
- */
- if (cold)
- {
- put_byte (RDP_RESET);
- while ((restype = SERIAL_READCHAR (io, 1)) > 0)
- {
- switch (restype)
- {
- case SERIAL_TIMEOUT:
- break;
- case RDP_RESET:
- /* Sent at start of reset process: ignore */
- break;
- default:
- printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
- break;
- }
- }
-
- if (restype == 0)
- {
- /* Got end-of-banner mark */
- printf_filtered ("\n");
- }
- }
-
- put_byte (RDP_OPEN);
-
- put_byte (type | RDP_OPEN_TYPE_RETURN_SEX );
- put_word (0);
-
- while (!sync && (restype = SERIAL_READCHAR (io, 1)) > 0)
- {
- if (remote_debug)
- printf_unfiltered ("[%02x]\n", restype);
-
- switch (restype)
- {
- case SERIAL_TIMEOUT:
- break;
-
- case RDP_RESET:
- while ((restype = SERIAL_READCHAR (io, 1)) == RDP_RESET)
- ;
- do
- {
- printf_unfiltered ("%c", isgraph (restype) ? restype : ' ');
- }
- while ((restype = SERIAL_READCHAR (io, 1)) > 0);
-
- if (tty)
- {
- printf_unfiltered ("\nThe board has sent notification that it was reset.\n");
- printf_unfiltered ("Waiting for it to settle down...\n");
- }
- sleep (3);
- if (tty)
- printf_unfiltered ("\nTrying again.\n");
- cold = 0;
- break;
-
- default:
- break;
-
- case RDP_RES_VALUE:
- {
- int resval = SERIAL_READCHAR (io, 1);
-
- if (remote_debug)
- printf_unfiltered ("[%02x]\n", resval);
-
- switch (resval)
- {
- case SERIAL_TIMEOUT:
- break;
- case RDP_RES_VALUE_LITTLE_ENDIAN:
- target_byte_order = LITTLE_ENDIAN;
- sync = 1;
- break;
- case RDP_RES_VALUE_BIG_ENDIAN:
- target_byte_order = BIG_ENDIAN;
- sync = 1;
- break;
- default:
- break;
- }
- }
- }
- }
- }
-
- if (!sync)
- {
- error ("Couldn't reset the board, try pressing the reset button");
- }
-}
-
-
-#ifdef ANSI_PROTOTYPES
-void
-send_rdp (char *template,...)
-#else
-void
-send_rdp (char *template, va_alist)
- va_dcl
-#endif
-{
- char buf[200];
- char *dst = buf;
- va_list alist;
-#ifdef ANSI_PROTOTYPES
- va_start (alist, template);
-#else
- va_start (alist);
-#endif
-
- while (*template)
- {
- unsigned int val;
- int *pi;
- int *pstat;
- char *pc;
- int i;
- switch (*template++)
- {
- case 'b':
- val = va_arg (alist, int);
- *dst++ = val;
- break;
- case 'w':
- val = va_arg (alist, int);
- *dst++ = val;
- *dst++ = val >> 8;
- *dst++ = val >> 16;
- *dst++ = val >> 24;
- break;
- case 'S':
- val = get_byte ();
- if (val != RDP_RES_VALUE)
- {
- printf_unfiltered ("got bad res value of %d, %x\n", val, val);
- }
- break;
- case 'V':
- pstat = va_arg (alist, int *);
- pi = va_arg (alist, int *);
-
- *pstat = get_byte ();
- /* Check the result was zero, if not read the syndrome */
- if (*pstat)
- {
- *pi = get_word ();
- }
- break;
- case 'Z':
- /* Check the result code */
- switch (get_byte ())
- {
- case 0:
- /* Success */
- break;
- case 253:
- /* Target can't do it; never mind */
- printf_unfiltered ("RDP: Insufficient privilege\n");
- return;
- case 254:
- /* Target can't do it; never mind */
- printf_unfiltered ("RDP: Unimplemented message\n");
- return;
- case 255:
- error ("Command garbled");
- break;
- default:
- error ("Corrupt reply from target");
- break;
- }
- break;
- case 'W':
- /* Read a word from the target */
- pi = va_arg (alist, int *);
- *pi = get_word ();
- break;
- case 'P':
- /* Read in some bytes from the target. */
- pc = va_arg (alist, char *);
- val = va_arg (alist, int);
- for (i = 0; i < val; i++)
- {
- pc[i] = get_byte ();
- }
- break;
- case 'p':
- /* send what's being pointed at */
- pc = va_arg (alist, char *);
- val = va_arg (alist, int);
- dst = buf;
- SERIAL_WRITE (io, pc, val);
- break;
- case '-':
- /* Send whats in the queue */
- if (dst != buf)
- {
- SERIAL_WRITE (io, buf, dst - buf);
- dst = buf;
- }
- break;
- case 'B':
- pi = va_arg (alist, int *);
- *pi = get_byte ();
- break;
- default:
- abort ();
- }
- }
- va_end (args);
-
- if (dst != buf)
- abort ();
-}
-
-
-static int
-rdp_write (memaddr, buf, len)
- CORE_ADDR memaddr;
- char *buf;
- int len;
-{
- int res;
- int val;
-
- send_rdp ("bww-p-SV", RDP_MEM_WRITE, memaddr, len, buf, len, &res, &val);
-
- if (res)
- {
- return val;
- }
- return len;
-}
-
-
-static int
-rdp_read (memaddr, buf, len)
- CORE_ADDR memaddr;
- char *buf;
- int len;
-{
- int res;
- int val;
- send_rdp ("bww-S-P-V",
- RDP_MEM_READ, memaddr, len,
- buf, len,
- &res, &val);
- if (res)
- {
- return val;
- }
- return len;
-}
-
-static void
-rdp_fetch_one_register (mask, buf)
- int mask;
- char *buf;
-{
- int val;
- send_rdp ("bbw-SWZ", RDP_CPU_READ, RDP_CPU_READWRITE_MODE_CURRENT, mask, &val);
- store_signed_integer (buf, 4, val);
-}
-
-static void
-rdp_fetch_one_fpu_register (mask, buf)
- int mask;
- char *buf;
-{
-#if 0
- /* !!! Since the PIE board doesn't work as documented,
- and it doesn't have FPU hardware anyway and since it
- slows everything down, I've disabled this. */
- int val;
- if (mask == RDP_FPU_READWRITE_MASK_FPS)
- {
- /* this guy is only a word */
- send_rdp ("bbw-SWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, &val);
- store_signed_integer (buf, 4, val);
- }
- else
- {
- /* There are 12 bytes long
- !! fixme about endianness
- */
- int dummy; /* I've seen these come back as four words !! */
- send_rdp ("bbw-SWWWWZ", RDP_COPRO_READ, FPU_COPRO_NUMBER, mask, buf + 0, buf + 4, buf + 8, &dummy);
- }
-#endif
- memset (buf, 0, MAX_REGISTER_RAW_SIZE);
-}
-
-
-static void
-rdp_store_one_register (mask, buf)
- int mask;
- char *buf;
-{
- int val = extract_unsigned_integer (buf, 4);
-
- send_rdp ("bbww-SZ",
- RDP_CPU_WRITE, RDP_CPU_READWRITE_MODE_CURRENT, mask, val);
-}
-
-
-static void
-rdp_store_one_fpu_register (mask, buf)
- int mask;
- char *buf;
-{
-#if 0
- /* See comment in fetch_one_fpu_register */
- if (mask == RDP_FPU_READWRITE_MASK_FPS)
- {
- int val = extract_unsigned_integer (buf, 4);
- /* this guy is only a word */
- send_rdp ("bbww-SZ", RDP_COPRO_WRITE,
- FPU_COPRO_NUMBER,
- mask, val);
- }
- else
- {
- /* There are 12 bytes long
- !! fixme about endianness
- */
- int dummy = 0;
- /* I've seen these come as four words, not the three advertized !! */
- printf ("Sending mask %x\n", mask);
- send_rdp ("bbwwwww-SZ",
- RDP_COPRO_WRITE,
- FPU_COPRO_NUMBER,
- mask,
- *(int *) (buf + 0),
- *(int *) (buf + 4),
- *(int *) (buf + 8),
- 0);
-
- printf ("done mask %x\n", mask);
- }
-#endif
-}
-
-
-/* Convert between GDB requests and the RDP layer. */
-
-static void
-remote_rdp_fetch_register (regno)
- int regno;
-{
- if (regno == -1)
- {
- for (regno = 0; regno < NUM_REGS; regno++)
- remote_rdp_fetch_register (regno);
- }
- else
- {
- char buf[MAX_REGISTER_RAW_SIZE];
- if (regno < 15)
- rdp_fetch_one_register (1 << regno, buf);
- else if (regno == PC_REGNUM)
- rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_PC, buf);
- else if (regno == PS_REGNUM)
- rdp_fetch_one_register (RDP_CPU_READWRITE_MASK_CPSR, buf);
- else if (regno == FPS_REGNUM)
- rdp_fetch_one_fpu_register (RDP_FPU_READWRITE_MASK_FPS, buf);
- else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
- rdp_fetch_one_fpu_register (1 << (regno - F0_REGNUM), buf);
- else
- {
- printf ("Help me with fetch reg %d\n", regno);
- }
- supply_register (regno, buf);
- }
-}
-
-
-static void
-remote_rdp_store_register (regno)
- int regno;
-{
- if (regno == -1)
- {
- for (regno = 0; regno < NUM_REGS; regno++)
- remote_rdp_store_register (regno);
- }
- else
- {
- char tmp[MAX_REGISTER_RAW_SIZE];
- read_register_gen (regno, tmp);
- if (regno < 15)
- rdp_store_one_register (1 << regno, tmp);
- else if (regno == PC_REGNUM)
- rdp_store_one_register (RDP_CPU_READWRITE_MASK_PC, tmp);
- else if (regno == PS_REGNUM)
- rdp_store_one_register (RDP_CPU_READWRITE_MASK_CPSR, tmp);
- else if (regno >= F0_REGNUM && regno <= F7_REGNUM)
- rdp_store_one_fpu_register (1 << (regno - F0_REGNUM), tmp);
- else
- {
- printf ("Help me with reg %d\n", regno);
- }
- }
-}
-
-static void
-remote_rdp_kill ()
-{
- callback->shutdown (callback);
-}
-
-
-static void
-rdp_info ()
-{
- send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_STEP,
- &ds.step_info);
- send_rdp ("bw-S-W-Z", RDP_INFO, RDP_INFO_ABOUT_BREAK,
- &ds.break_info);
- send_rdp ("bw-S-WW-Z", RDP_INFO, RDP_INFO_ABOUT_TARGET,
- &ds.target_info,
- &ds.model_info);
-
- ds.can_step = ds.step_info & RDP_INFO_ABOUT_STEP_1;
-
- ds.rdi_level = (ds.target_info >> 5) & 3;
-}
-
-
-static void
-rdp_execute_start ()
-{
- /* Start it off, but don't wait for it */
- send_rdp ("bb-", RDP_EXEC, RDP_EXEC_TYPE_SYNC);
-}
-
-
-static void
-rdp_set_command_line (command, args)
- char * command;
- char * args;
-{
- /*
- ** We could use RDP_INFO_SET_CMDLINE to send this, but EmbeddedICE systems
- ** don't implement that, and get all confused at the unexpected text.
- ** Instead, just keep a copy, and send it when the target does a SWI_GetEnv
- */
-
- if (commandline != NULL)
- free (commandline);
-
- commandline = malloc (strlen (command) + strlen (args) + 2);
- if (commandline != NULL)
- {
- strcpy (commandline, command);
- strcat (commandline, " ");
- strcat (commandline, args);
- }
-}
-
-static void
-rdp_catch_vectors ()
-{
- /*
- ** We want the target monitor to intercept the abort vectors
- ** i.e. stop the program if any of these are used.
- */
- send_rdp ("bww-SZ", RDP_INFO, RDP_INFO_VECTOR_CATCH,
- /*
- ** Specify a bitmask including
- ** the reset vector
- ** the undefined instruction vector
- ** the prefetch abort vector
- ** the data abort vector
- ** the address exception vector
- */
- (1<<0)|(1<<1)|(1<<3)|(1<<4)|(1<<5)
- );
-}
-
-
-
-#define a_byte 1
-#define a_word 2
-#define a_string 3
-
-
-typedef struct
-{
- CORE_ADDR n;
- const char *s;
-}
-argsin;
-
-#define ABYTE 1
-#define AWORD 2
-#define ASTRING 3
-#define ADDRLEN 4
-
-#define SWI_WriteC 0x0
-#define SWI_Write0 0x2
-#define SWI_ReadC 0x4
-#define SWI_CLI 0x5
-#define SWI_GetEnv 0x10
-#define SWI_Exit 0x11
-#define SWI_EnterOS 0x16
-
-#define SWI_GetErrno 0x60
-#define SWI_Clock 0x61
-
-#define SWI_Time 0x63
-#define SWI_Remove 0x64
-#define SWI_Rename 0x65
-#define SWI_Open 0x66
-
-#define SWI_Close 0x68
-#define SWI_Write 0x69
-#define SWI_Read 0x6a
-#define SWI_Seek 0x6b
-#define SWI_Flen 0x6c
-
-#define SWI_IsTTY 0x6e
-#define SWI_TmpNam 0x6f
-#define SWI_InstallHandler 0x70
-#define SWI_GenerateError 0x71
-
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-static int translate_open_mode[] =
-{
- O_RDONLY, /* "r" */
- O_RDONLY+O_BINARY, /* "rb" */
- O_RDWR, /* "r+" */
- O_RDWR +O_BINARY, /* "r+b" */
- O_WRONLY +O_CREAT+O_TRUNC, /* "w" */
- O_WRONLY+O_BINARY+O_CREAT+O_TRUNC, /* "wb" */
- O_RDWR +O_CREAT+O_TRUNC, /* "w+" */
- O_RDWR +O_BINARY+O_CREAT+O_TRUNC, /* "w+b" */
- O_WRONLY +O_APPEND+O_CREAT,/* "a" */
- O_WRONLY+O_BINARY+O_APPEND+O_CREAT,/* "ab" */
- O_RDWR +O_APPEND+O_CREAT,/* "a+" */
- O_RDWR +O_BINARY+O_APPEND+O_CREAT /* "a+b" */
-};
-
-static int
-exec_swi (swi, args)
- int swi;
- argsin *args;
-{
- int i;
- char c;
- switch (swi)
- {
- case SWI_WriteC:
- callback->write_stdout (callback, &c, 1);
- return 0;
- case SWI_Write0:
- for (i = 0; i < args->n; i++)
- callback->write_stdout (callback, args->s, strlen (args->s));
- return 0;
- case SWI_ReadC:
- callback->read_stdin (callback, &c, 1);
- args->n = c;
- return 1;
- case SWI_CLI:
- args->n = callback->system (callback, args->s);
- return 1;
- case SWI_GetErrno:
- args->n = callback->get_errno (callback);
- return 1;
- case SWI_Time:
- args->n = callback->time (callback, NULL);
- return 1;
-
- case SWI_Clock :
- /* return number of centi-seconds... */
- args->n =
-#ifdef CLOCKS_PER_SEC
- (CLOCKS_PER_SEC >= 100)
- ? (clock() / (CLOCKS_PER_SEC / 100))
- : ((clock() * 100) / CLOCKS_PER_SEC) ;
-#else
- /* presume unix... clock() returns microseconds */
- clock() / 10000 ;
-#endif
- return 1 ;
-
- case SWI_Remove:
- args->n = callback->unlink (callback, args->s);
- return 1;
- case SWI_Rename:
- args->n = callback->rename (callback, args[0].s, args[1].s);
- return 1;
-
- case SWI_Open:
- /* Now we need to decode the Demon open mode */
- i = translate_open_mode[args[1].n];
-
- /* Filename ":tt" is special: it denotes stdin/out */
- if (strcmp(args->s,":tt")==0)
- {
- if (i == O_RDONLY ) /* opening tty "r" */
- args->n = 0 /* stdin */ ;
- else
- args->n = 1 /* stdout */ ;
- }
- else
- args->n = callback->open (callback, args->s, i);
- return 1;
-
- case SWI_Close:
- args->n = callback->close (callback, args->n);
- return 1;
-
- case SWI_Write:
- /* Return the number of bytes *not* written */
- args->n = args[1].n -
- callback->write (callback, args[0].n, args[1].s, args[1].n);
- return 1;
-
- case SWI_Read:
- {
- char *copy = alloca (args[2].n);
- int done = callback->read (callback, args[0].n, copy, args[2].n);
- if (done > 0)
- remote_rdp_xfer_inferior_memory (args[1].n, copy, done, 1, 0);
- args->n = args[2].n-done;
- return 1;
- }
-
- case SWI_Seek:
- /* Return non-zero on failure */
- args->n = callback->lseek (callback, args[0].n, args[1].n, 0) < 0;
- return 1;
-
- case SWI_Flen:
- {
- long old = callback->lseek (callback, args->n, 0, SEEK_CUR);
- args->n = callback->lseek (callback, args->n, 0, SEEK_END);
- callback->lseek (callback, args->n, old, 0);
- return 1;
- }
-
- case SWI_IsTTY:
- args->n = callback->isatty (callback, args->n);
- return 1;
-
- case SWI_GetEnv:
- if (commandline != NULL)
- {
- int len = strlen (commandline);
- if (len > 255)
- {
- len = 255;
- commandline [255]='\0';
- }
- remote_rdp_xfer_inferior_memory (args[0].n,
- commandline, len+1, 1, 0);
- }
- else
- remote_rdp_xfer_inferior_memory (args[0].n, "", 1, 1, 0);
- return 1;
-
- default:
- return 0;
- }
-}
-
-
-static void
-handle_swi ()
-{
- argsin args[3];
- char *buf;
- int len;
- int count = 0;
-
- int swino = get_word ();
- int type = get_byte ();
- while (type != 0)
- {
- switch (type & 0x3)
- {
- case ABYTE:
- args[count].n = get_byte ();
- break;
-
- case AWORD:
- args[count].n = get_word ();
- break;
-
- case ASTRING:
- /* If the word is under 32 bytes it will be sent otherwise
- an address to it is passed. Also: Special case of 255 */
-
- len = get_byte ();
- if (len > 32)
- {
- if (len == 255)
- {
- len = get_word ();
- }
- buf = alloca (len);
- remote_rdp_xfer_inferior_memory (get_word (),
- buf,
- len,
- 0,
- 0);
- }
- else
- {
- int i;
- buf = alloca (len + 1);
- for (i = 0; i < len; i++)
- buf[i] = get_byte ();
- buf[i] = 0;
- }
- args[count].n = len;
- args[count].s = buf;
- break;
-
- default:
- error ("Unimplented SWI argument");
- }
-
- type = type >> 2;
- count++;
- }
-
- if (exec_swi (swino, args))
- {
- /* We have two options here reply with either a byte or a word
- which is stored in args[0].n. There is no harm in replying with
- a word all the time, so thats what I do! */
- send_rdp ("bbw-", RDP_OSOpReply, RDP_OSOpWord, args[0].n);
- }
- else
- {
- send_rdp ("bb-", RDP_OSOpReply, RDP_OSOpNothing);
- }
-}
-
-static void
-rdp_execute_finish ()
-{
- int running = 1;
-
- while (running)
- {
- int res;
- res = SERIAL_READCHAR (io, 1);
- while (res == SERIAL_TIMEOUT)
- {
- QUIT;
- printf_filtered ("Waiting for target..\n");
- res = SERIAL_READCHAR (io, 1);
- }
-
- switch (res)
- {
- case RDP_RES_SWI:
- handle_swi ();
- break;
- case RDP_RES_VALUE:
- send_rdp ("B", &ds.rdi_stopped_status);
- running = 0;
- break;
- case RDP_RESET:
- printf_filtered ("Target reset\n");
- running = 0;
- break;
- default:
- printf_filtered ("Ignoring %x\n", res);
- break;
- }
- }
-}
-
-
-static void
-rdp_execute ()
-{
- rdp_execute_start ();
- rdp_execute_finish ();
-}
-
-static int
-remote_rdp_insert_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save;
-{
- int res;
- if (ds.rdi_level > 0)
- {
- send_rdp ("bwb-SWB",
- RDP_SET_BREAK,
- addr,
- RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
- save,
- &res);
- }
- else
- {
- send_rdp ("bwb-SB",
- RDP_SET_BREAK,
- addr,
- RDP_SET_BREAK_TYPE_PC_EQUAL,
- &res);
- }
- return res;
-}
-
-static int
-remote_rdp_remove_breakpoint (addr, save)
- CORE_ADDR addr;
- char *save;
-{
- int res;
- if (ds.rdi_level > 0)
- {
- send_rdp ("b-p-S-B",
- RDP_CLEAR_BREAK,
- save, 4,
- &res);
- }
- else
- {
- send_rdp ("bw-S-B",
- RDP_CLEAR_BREAK,
- addr,
- &res);
- }
- return res;
-}
-
-static void
-rdp_step ()
-{
- if (ds.can_step && 0)
- {
- /* The pie board can't do steps so I can't test this, and
- the other code will always work. */
- int status;
- send_rdp ("bbw-S-B",
- RDP_STEP, 0, 1,
- &status);
- }
- else
- {
- char handle[4];
- CORE_ADDR pc = read_register (PC_REGNUM);
- pc = arm_get_next_pc (pc);
- remote_rdp_insert_breakpoint (pc, &handle);
- rdp_execute ();
- remote_rdp_remove_breakpoint (pc, &handle);
- }
-}
-
-static void
-remote_rdp_open (args, from_tty)
- char *args;
- int from_tty;
-{
- int not_icebreaker;
-
- if (!args)
- error_no_arg ("serial port device name");
-
- baud_rate = 9600;
-
- target_preopen (from_tty);
-
- io = SERIAL_OPEN (args);
-
- if (!io)
- perror_with_name (args);
-
- SERIAL_RAW (io);
-
- rdp_init (1, from_tty);
-
-
- if (from_tty)
- {
- printf_unfiltered ("Remote RDP debugging using %s at %d baud\n", args, baud_rate);
- }
-
- rdp_info ();
-
- /* Need to set up the vector interception state */
- rdp_catch_vectors();
-
- /*
- ** If it's an EmbeddedICE, we need to set the processor config.
- ** Assume we can always have ARM7TDI...
- */
- send_rdp ("bw-SB", RDP_INFO, RDP_INFO_ICEBREAKER, & not_icebreaker);
- if (!not_icebreaker)
- {
- const char * CPU = "ARM7TDI";
- int ICEversion;
- int len = strlen (CPU);
-
- send_rdp ("bbbbw-p-SWZ",
- RDP_SELECT_CONFIG,
- RDI_ConfigCPU, /* Aspect: set the CPU */
- len, /* The number of bytes in the name */
- RDI_MatchAny, /* We'll take whatever we get */
- 0, /* We'll take whatever version's there */
- CPU,len,
- & ICEversion);
- }
-
- /* command line initialised on 'run'*/
-
- push_target (& remote_rdp_ops);
-
- callback->init (callback);
- flush_cached_frames ();
- registers_changed ();
- stop_pc = read_pc ();
- set_current_frame (create_new_frame (read_fp (), stop_pc));
- select_frame (get_current_frame (), 0);
- print_stack_frame (selected_frame, -1, 1);
-}
-
-
-
-/* Close out all files and local state before this target loses control. */
-
-static void
-remote_rdp_close (quitting)
- int quitting;
-{
- callback->shutdown (callback);
- if (io)
- SERIAL_CLOSE (io);
- io = 0;
-}
-
-
-/* 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. */
-
-static void
-remote_rdp_resume (pid, step, siggnal)
- int pid, step;
- enum target_signal siggnal;
-{
- if (step)
- rdp_step ();
- else
- rdp_execute ();
-}
-
-/* Wait for inferior process to do something. Return pid of child,
- or -1 in case of error; store status through argument pointer STATUS,
- just as `wait' would. */
-
-static int
-remote_rdp_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- switch (ds.rdi_stopped_status)
- {
- default:
- case RDP_RES_RESET:
- case RDP_RES_SWI:
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = read_register (0);
- break;
- case RDP_RES_AT_BREAKPOINT:
- status->kind = TARGET_WAITKIND_STOPPED;
- /* The signal in sigrc is a host signal. That probably
- should be fixed. */
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
-#if 0
- case rdp_signalled:
- status->kind = TARGET_WAITKIND_SIGNALLED;
- /* The signal in sigrc is a host signal. That probably
- should be fixed. */
- status->value.sig = target_signal_from_host (sigrc);
- break;
-#endif
- }
-
- return inferior_pid;
-}
-
-/* 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
-remote_rdp_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static int
-remote_rdp_xfer_inferior_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* ignored */
-{
- /* I infer from D Taylor's code that there's a limit on the amount
- we can transfer in one chunk.. */
- int done = 0;
- while (done < len)
- {
- int justdone;
- int thisbite = len - done;
- if (thisbite > RDP_MOUTHFULL)
- thisbite = RDP_MOUTHFULL;
-
- QUIT;
-
- if (write)
- {
- justdone = rdp_write (memaddr + done, myaddr + done, thisbite);
- }
- else
- {
- justdone = rdp_read (memaddr + done, myaddr + done, thisbite);
- }
-
- done += justdone;
-
- if (justdone != thisbite)
- break;
- }
- return done;
-}
-
-
-
-struct yn
-{
- const char *name;
- int bit;
-};
-static struct yn stepinfo[] =
-{
- {"Step more than one instruction", RDP_INFO_ABOUT_STEP_GT_1},
- {"Step to jump", RDP_INFO_ABOUT_STEP_TO_JMP},
- {"Step one instruction", RDP_INFO_ABOUT_STEP_1},
- {0}
-};
-
-static struct yn breakinfo[] =
-{
- {"comparison breakpoints supported", RDP_INFO_ABOUT_BREAK_COMP},
- {"range breakpoints supported", RDP_INFO_ABOUT_BREAK_RANGE},
- {"watchpoints for byte reads supported", RDP_INFO_ABOUT_BREAK_BYTE_READ},
- {"watchpoints for half-word reads supported", RDP_INFO_ABOUT_BREAK_HALFWORD_READ},
- {"watchpoints for word reads supported", RDP_INFO_ABOUT_BREAK_WORD_READ},
- {"watchpoints for byte writes supported", RDP_INFO_ABOUT_BREAK_BYTE_WRITE},
- {"watchpoints for half-word writes supported", RDP_INFO_ABOUT_BREAK_HALFWORD_WRITE},
- {"watchpoints for word writes supported", RDP_INFO_ABOUT_BREAK_WORD_WRITE},
- {"mask break/watch-points supported", RDP_INFO_ABOUT_BREAK_MASK},
-{"thread-specific breakpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_BREAK},
-{"thread-specific watchpoints supported", RDP_INFO_ABOUT_BREAK_THREAD_WATCH},
- {"conditional breakpoints supported", RDP_INFO_ABOUT_BREAK_COND},
- {0}
-};
-
-
-static void
-dump_bits (t, info)
- struct yn *t;
- int info;
-{
- while (t->name)
- {
- printf_unfiltered (" %-45s : %s\n", t->name, (info & t->bit) ? "Yes" : "No");
- t++;
- }
-}
-
-static void
-remote_rdp_files_info (target)
- struct target_ops *target;
-{
- printf_filtered ("Target capabilities:\n");
- dump_bits (stepinfo, ds.step_info);
- dump_bits (breakinfo, ds.break_info);
- printf_unfiltered ("target level RDI %x\n", (ds.target_info >> 5) & 3);
-}
-
-
-static void
-remote_rdp_create_inferior (exec_file, allargs, env)
- char * exec_file;
- char * allargs;
- char ** env;
-{
- CORE_ADDR entry_point;
-
- if (exec_file == 0 || exec_bfd == 0)
- error ("No executable file specified.");
-
- entry_point = (CORE_ADDR) bfd_get_start_address (exec_bfd);
-
- remote_rdp_kill ();
- remove_breakpoints ();
- init_wait_for_inferior ();
-
- /* This gives us a chance to set up the command line */
- rdp_set_command_line (exec_file, allargs);
-
- inferior_pid = 42;
- insert_breakpoints (); /* Needed to get correct instruction in cache */
-
- /*
- ** RDP targets don't provide any facility to set the top of memory,
- ** so we don't bother to look for MEMSIZE in the environment.
- */
-
- /* Let's go! */
- proceed (entry_point, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-/* Accept any stray run/attach commands */
-static int
-remote_rdp_can_run()
-{
- return 1;
-}
-
-/* Attach doesn't need to do anything */
-static void
-remote_rdp_attach(args, from_tty)
- char * args;
- int from_tty;
-{
- return;
-}
-
-/* Define the target subroutine names */
-
-struct target_ops remote_rdp_ops ;
-
-static void
-init_remote_rdp_ops(void)
-{
- remote_rdp_ops.to_shortname = "rdp";
- remote_rdp_ops.to_longname = "Remote Target using the RDProtocol";
- remote_rdp_ops.to_doc = "Use a remote ARM system which uses the ARM Remote Debugging Protocol";
- remote_rdp_ops.to_open = remote_rdp_open;
- remote_rdp_ops.to_close = remote_rdp_close;
- remote_rdp_ops.to_attach = remote_rdp_attach;
- remote_rdp_ops.to_post_attach = NULL;
- remote_rdp_ops.to_require_attach = NULL;
- remote_rdp_ops.to_detach = NULL;
- remote_rdp_ops.to_require_detach = NULL;
- remote_rdp_ops.to_resume = remote_rdp_resume;
- remote_rdp_ops.to_wait = remote_rdp_wait;
- remote_rdp_ops.to_post_wait = NULL;
- remote_rdp_ops.to_fetch_registers = remote_rdp_fetch_register;
- remote_rdp_ops.to_store_registers = remote_rdp_store_register;
- remote_rdp_ops.to_prepare_to_store = remote_rdp_prepare_to_store;
- remote_rdp_ops.to_xfer_memory = remote_rdp_xfer_inferior_memory;
- remote_rdp_ops.to_files_info = remote_rdp_files_info;
- remote_rdp_ops.to_insert_breakpoint = remote_rdp_insert_breakpoint;
- remote_rdp_ops.to_remove_breakpoint = remote_rdp_remove_breakpoint;
- remote_rdp_ops.to_terminal_init = NULL;
- remote_rdp_ops.to_terminal_inferior = NULL;
- remote_rdp_ops.to_terminal_ours_for_output = NULL;
- remote_rdp_ops.to_terminal_ours = NULL;
- remote_rdp_ops.to_terminal_info = NULL;
- remote_rdp_ops.to_kill = remote_rdp_kill;
- remote_rdp_ops.to_load = generic_load;
- remote_rdp_ops.to_lookup_symbol = NULL;
- remote_rdp_ops.to_create_inferior = remote_rdp_create_inferior;
- remote_rdp_ops.to_post_startup_inferior = NULL;
- remote_rdp_ops.to_acknowledge_created_inferior = NULL;
- remote_rdp_ops.to_clone_and_follow_inferior = NULL;
- remote_rdp_ops.to_post_follow_inferior_by_clone = NULL;
- remote_rdp_ops.to_insert_fork_catchpoint = NULL;
- remote_rdp_ops.to_remove_fork_catchpoint = NULL;
- remote_rdp_ops.to_insert_vfork_catchpoint = NULL;
- remote_rdp_ops.to_remove_vfork_catchpoint = NULL;
- remote_rdp_ops.to_has_forked = NULL;
- remote_rdp_ops.to_has_vforked = NULL;
- remote_rdp_ops.to_can_follow_vfork_prior_to_exec = NULL;
- remote_rdp_ops.to_post_follow_vfork = NULL;
- remote_rdp_ops.to_insert_exec_catchpoint = NULL;
- remote_rdp_ops.to_remove_exec_catchpoint = NULL;
- remote_rdp_ops.to_has_execd = NULL;
- remote_rdp_ops.to_reported_exec_events_per_exec_call = NULL;
- remote_rdp_ops.to_has_exited = NULL;
- remote_rdp_ops.to_mourn_inferior = generic_mourn_inferior;
- remote_rdp_ops.to_can_run = remote_rdp_can_run;
- remote_rdp_ops.to_notice_signals = 0;
- remote_rdp_ops.to_thread_alive = 0;
- remote_rdp_ops.to_stop = 0;
- remote_rdp_ops.to_pid_to_exec_file = NULL;
- remote_rdp_ops.to_core_file_to_sym_file = NULL;
- remote_rdp_ops.to_stratum = process_stratum;
- remote_rdp_ops.DONT_USE = NULL;
- remote_rdp_ops.to_has_all_memory = 1;
- remote_rdp_ops.to_has_memory = 1;
- remote_rdp_ops.to_has_stack = 1;
- remote_rdp_ops.to_has_registers = 1;
- remote_rdp_ops.to_has_execution = 1;
- remote_rdp_ops.to_sections = NULL;
- remote_rdp_ops.to_sections_end = NULL;
- remote_rdp_ops.to_magic = OPS_MAGIC;
-}
-
-void
-_initialize_remote_rdp ()
-{
- init_remote_rdp_ops() ;
- add_target (&remote_rdp_ops);
-}
diff --git a/contrib/gdb/gdb/remote-sim.c b/contrib/gdb/gdb/remote-sim.c
deleted file mode 100644
index e10fced..0000000
--- a/contrib/gdb/gdb/remote-sim.c
+++ /dev/null
@@ -1,1003 +0,0 @@
-/* Generic remote debugging interface for simulators.
- Copyright 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
- Contributed by Cygnus Support.
- Steve Chamberlain (sac@cygnus.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "inferior.h"
-#include "wait.h"
-#include "value.h"
-#include "gdb_string.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <errno.h>
-#include "terminal.h"
-#include "target.h"
-#include "gdbcore.h"
-#include "callback.h"
-#include "remote-sim.h"
-#include "remote-utils.h"
-#include "command.h"
-
-/* Prototypes */
-
-static void dump_mem PARAMS ((char *buf, int len));
-
-static void init_callbacks PARAMS ((void));
-
-static void end_callbacks PARAMS ((void));
-
-static int gdb_os_write_stdout PARAMS ((host_callback *, const char *, int));
-
-static void gdb_os_flush_stdout PARAMS ((host_callback *));
-
-static int gdb_os_write_stderr PARAMS ((host_callback *, const char *, int));
-
-static void gdb_os_flush_stderr PARAMS ((host_callback *));
-
-static int gdb_os_poll_quit PARAMS ((host_callback *));
-
-/* printf_filtered is depreciated */
-static void gdb_os_printf_filtered PARAMS ((host_callback *, const char *, ...));
-
-static void gdb_os_vprintf_filtered PARAMS ((host_callback *, const char *, va_list));
-
-static void gdb_os_evprintf_filtered PARAMS ((host_callback *, const char *, va_list));
-
-static void gdb_os_error PARAMS ((host_callback *, const char *, ...));
-
-static void gdbsim_fetch_register PARAMS ((int regno));
-
-static void gdbsim_store_register PARAMS ((int regno));
-
-static void gdbsim_kill PARAMS ((void));
-
-static void gdbsim_load PARAMS ((char *prog, int fromtty));
-
-static void gdbsim_create_inferior PARAMS ((char *exec_file, char *args, char **env));
-
-static void gdbsim_open PARAMS ((char *args, int from_tty));
-
-static void gdbsim_close PARAMS ((int quitting));
-
-static void gdbsim_detach PARAMS ((char *args, int from_tty));
-
-static void gdbsim_resume PARAMS ((int pid, int step, enum target_signal siggnal));
-
-static int gdbsim_wait PARAMS ((int pid, struct target_waitstatus *status));
-
-static void gdbsim_prepare_to_store PARAMS ((void));
-
-static int gdbsim_xfer_inferior_memory PARAMS ((CORE_ADDR memaddr,
- char *myaddr, int len,
- int write,
- struct target_ops *target));
-
-static void gdbsim_files_info PARAMS ((struct target_ops *target));
-
-static void gdbsim_mourn_inferior PARAMS ((void));
-
-static void gdbsim_stop PARAMS ((void));
-
-void simulator_command PARAMS ((char *args, int from_tty));
-
-/* Naming convention:
-
- sim_* are the interface to the simulator (see remote-sim.h).
- gdbsim_* are stuff which is internal to gdb. */
-
-/* Forward data declarations */
-extern struct target_ops gdbsim_ops;
-
-static int program_loaded = 0;
-
-/* We must keep track of whether the simulator has been opened or not because
- GDB can call a target's close routine twice, but sim_close doesn't allow
- this. We also need to record the result of sim_open so we can pass it
- back to the other sim_foo routines. */
-static SIM_DESC gdbsim_desc = 0;
-
-static void
-dump_mem (buf, len)
- char *buf;
- int len;
-{
- if (len <= 8)
- {
- if (len == 8 || len == 4)
- {
- long l[2];
- memcpy (l, buf, len);
- printf_filtered ("\t0x%x", l[0]);
- printf_filtered (len == 8 ? " 0x%x\n" : "\n", l[1]);
- }
- else
- {
- int i;
- printf_filtered ("\t");
- for (i = 0; i < len; i++)
- printf_filtered ("0x%x ", buf[i]);
- printf_filtered ("\n");
- }
- }
-}
-
-static host_callback gdb_callback;
-static int callbacks_initialized = 0;
-
-/* Initialize gdb_callback. */
-
-static void
-init_callbacks ()
-{
- if (! callbacks_initialized)
- {
- gdb_callback = default_callback;
- gdb_callback.init (&gdb_callback);
- gdb_callback.write_stdout = gdb_os_write_stdout;
- gdb_callback.flush_stdout = gdb_os_flush_stdout;
- gdb_callback.write_stderr = gdb_os_write_stderr;
- gdb_callback.flush_stderr = gdb_os_flush_stderr;
- gdb_callback.printf_filtered = gdb_os_printf_filtered;
- gdb_callback.vprintf_filtered = gdb_os_vprintf_filtered;
- gdb_callback.evprintf_filtered = gdb_os_evprintf_filtered;
- gdb_callback.error = gdb_os_error;
- gdb_callback.poll_quit = gdb_os_poll_quit;
- gdb_callback.magic = HOST_CALLBACK_MAGIC;
- callbacks_initialized = 1;
- }
-}
-
-/* Release callbacks (free resources used by them). */
-
-static void
-end_callbacks ()
-{
- if (callbacks_initialized)
- {
- gdb_callback.shutdown (&gdb_callback);
- callbacks_initialized = 0;
- }
-}
-
-/* GDB version of os_write_stdout callback. */
-
-static int
-gdb_os_write_stdout (p, buf, len)
- host_callback *p;
- const char *buf;
- int len;
-{
- int i;
- char b[2];
-
- for (i = 0; i < len; i++)
- {
- b[0] = buf[i];
- b[1] = 0;
- if (target_output_hook)
- target_output_hook (b);
- else
- fputs_filtered (b, gdb_stdout);
- }
- return len;
-}
-
-/* GDB version of os_flush_stdout callback. */
-
-static void
-gdb_os_flush_stdout (p)
- host_callback *p;
-{
- gdb_flush (gdb_stdout);
-}
-
-/* GDB version of os_write_stderr callback. */
-
-static int
-gdb_os_write_stderr (p, buf, len)
- host_callback *p;
- const char *buf;
- int len;
-{
- int i;
- char b[2];
-
- for (i = 0; i < len; i++)
- {
- b[0] = buf[i];
- b[1] = 0;
- if (target_output_hook)
- target_output_hook (b);
- else
- fputs_filtered (b, gdb_stderr);
- }
- return len;
-}
-
-/* GDB version of os_flush_stderr callback. */
-
-static void
-gdb_os_flush_stderr (p)
- host_callback *p;
-{
- gdb_flush (gdb_stderr);
-}
-
-/* GDB version of printf_filtered callback. */
-
-/* VARARGS */
-static void
-#ifdef ANSI_PROTOTYPES
-gdb_os_printf_filtered (host_callback *p, const char *format, ...)
-#else
-gdb_os_printf_filtered (p, va_alist)
- host_callback *p;
- va_dcl
-#endif
-{
- va_list args;
-#ifdef ANSI_PROTOTYPES
- va_start (args, format);
-#else
- char *format;
-
- va_start (args);
- format = va_arg (args, char *);
-#endif
-
- vfprintf_filtered (gdb_stdout, format, args);
-
- va_end (args);
-}
-
-/* GDB version of error vprintf_filtered. */
-
-/* VARARGS */
-static void
-#ifdef ANSI_PROTOTYPES
-gdb_os_vprintf_filtered (host_callback *p, const char *format, va_list ap)
-#else
-gdb_os_vprintf_filtered (p, format, ap)
- host_callback *p;
- char *format;
- va_list ap;
-#endif
-{
- vfprintf_filtered (gdb_stdout, format, ap);
-}
-
-/* GDB version of error evprintf_filtered. */
-
-/* VARARGS */
-static void
-#ifdef ANSI_PROTOTYPES
-gdb_os_evprintf_filtered (host_callback *p, const char *format, va_list ap)
-#else
-gdb_os_evprintf_filtered (p, format, ap)
- host_callback *p;
- char *format;
- va_list ap;
-#endif
-{
- vfprintf_filtered (gdb_stderr, format, ap);
-}
-
-/* GDB version of error callback. */
-
-/* VARARGS */
-static void
-#ifdef ANSI_PROTOTYPES
-gdb_os_error (host_callback *p, const char *format, ...)
-#else
-gdb_os_error (p, va_alist)
- host_callback *p;
- va_dcl
-#endif
-{
- if (error_hook)
- (*error_hook) ();
- else
- {
- va_list args;
-#ifdef ANSI_PROTOTYPES
- va_start (args, format);
-#else
- char *format;
-
- va_start (args);
- format = va_arg (args, char *);
-#endif
-
- error_begin ();
- vfprintf_filtered (gdb_stderr, format, args);
- fprintf_filtered (gdb_stderr, "\n");
- va_end (args);
- return_to_top_level (RETURN_ERROR);
- }
-}
-
-static void
-gdbsim_fetch_register (regno)
- int regno;
-{
- static int warn_user = 1;
- if (regno == -1)
- {
- for (regno = 0; regno < NUM_REGS; regno++)
- gdbsim_fetch_register (regno);
- }
- else if (REGISTER_NAME (regno) != NULL && *REGISTER_NAME (regno) != '\0')
- {
- char buf[MAX_REGISTER_RAW_SIZE];
- int nr_bytes = sim_fetch_register (gdbsim_desc, regno, buf, REGISTER_RAW_SIZE (regno));
- if (nr_bytes == 0)
- /* register not applicable, supply zero's */
- memset (buf, 0, MAX_REGISTER_RAW_SIZE);
- else if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno)
- && warn_user)
- {
- printf_unfiltered ("Size of register %s (%d) incorrect (%d instead of %d))",
- REGISTER_NAME (regno), regno,
- nr_bytes, REGISTER_RAW_SIZE (regno));
- warn_user = 0;
- }
- supply_register (regno, buf);
- if (sr_get_debug ())
- {
- printf_filtered ("gdbsim_fetch_register: %d", regno);
- /* FIXME: We could print something more intelligible. */
- dump_mem (buf, REGISTER_RAW_SIZE (regno));
- }
- }
-}
-
-
-static void
-gdbsim_store_register (regno)
- int regno;
-{
- if (regno == -1)
- {
- for (regno = 0; regno < NUM_REGS; regno++)
- gdbsim_store_register (regno);
- }
- else if (REGISTER_NAME (regno) != NULL && *REGISTER_NAME (regno) != '\0')
- {
- char tmp[MAX_REGISTER_RAW_SIZE];
- int nr_bytes;
- read_register_gen (regno, tmp);
- nr_bytes = sim_store_register (gdbsim_desc, regno, tmp, REGISTER_RAW_SIZE (regno));
- if (nr_bytes > 0 && nr_bytes != REGISTER_RAW_SIZE (regno))
- fatal ("Register size different to expected");
- if (sr_get_debug ())
- {
- printf_filtered ("gdbsim_store_register: %d", regno);
- /* FIXME: We could print something more intelligible. */
- dump_mem (tmp, REGISTER_RAW_SIZE (regno));
- }
- }
-}
-
-/* Kill the running program. This may involve closing any open files
- and releasing other resources acquired by the simulated program. */
-
-static void
-gdbsim_kill ()
-{
- if (sr_get_debug ())
- printf_filtered ("gdbsim_kill\n");
-
- /* There is no need to `kill' running simulator - the simulator is
- not running */
- inferior_pid = 0;
-}
-
-/* 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. */
-
-static void
-gdbsim_load (prog, fromtty)
- char *prog;
- int fromtty;
-{
- if (sr_get_debug ())
- printf_filtered ("gdbsim_load: prog \"%s\"\n", prog);
-
- inferior_pid = 0;
-
- /* FIXME: We will print two messages on error.
- Need error to either not print anything if passed NULL or need
- another routine that doesn't take any arguments. */
- if (sim_load (gdbsim_desc, prog, NULL, fromtty) == SIM_RC_FAIL)
- error ("unable to load program");
-
- /* FIXME: If a load command should reset the targets registers then
- a call to sim_create_inferior() should go here. */
-
- program_loaded = 1;
-}
-
-
-/* Start an inferior process and set inferior_pid to its pid.
- EXEC_FILE is the file to run.
- ARGS 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. */
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-
-static void
-gdbsim_create_inferior (exec_file, args, env)
- char *exec_file;
- char *args;
- char **env;
-{
- int len;
- char *arg_buf,**argv;
-
- if (exec_file == 0 || exec_bfd == 0)
- warning ("No executable file specified.");
- if (! program_loaded)
- warning ("No program loaded.");
-
- if (sr_get_debug ())
- printf_filtered ("gdbsim_create_inferior: exec_file \"%s\", args \"%s\"\n",
- (exec_file ? exec_file: "(NULL)"),
- args);
-
- gdbsim_kill ();
- remove_breakpoints ();
- init_wait_for_inferior ();
-
- if (exec_file != NULL)
- {
- len = strlen (exec_file) + 1 + strlen (args) + 1 + /*slop*/ 10;
- arg_buf = (char *) alloca (len);
- arg_buf[0] = '\0';
- strcat (arg_buf, exec_file);
- strcat (arg_buf, " ");
- strcat (arg_buf, args);
- argv = buildargv (arg_buf);
- make_cleanup ((make_cleanup_func) freeargv, argv);
- }
- else
- argv = NULL;
- sim_create_inferior (gdbsim_desc, exec_bfd, argv, env);
-
- inferior_pid = 42;
- insert_breakpoints (); /* Needed to get correct instruction in cache */
-
- clear_proceed_status ();
-
- /* NB: Entry point already set by sim_create_inferior. */
- proceed ((CORE_ADDR)-1, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-/* 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. */
-/* Called when selecting the simulator. EG: (gdb) target sim name. */
-
-static void
-gdbsim_open (args, from_tty)
- char *args;
- int from_tty;
-{
- int len;
- char *arg_buf;
- char **argv;
-
- if (sr_get_debug ())
- printf_filtered ("gdbsim_open: args \"%s\"\n", args ? args : "(null)");
-
- /* Remove current simulator if one exists. Only do this if the simulator
- has been opened because sim_close requires it.
- This is important because the call to push_target below will cause
- sim_close to be called if the simulator is already open, but push_target
- is called after sim_open! We can't move the call to push_target before
- the call to sim_open because sim_open may invoke `error'. */
- if (gdbsim_desc != NULL)
- unpush_target (&gdbsim_ops);
-
- len = (7 + 1 /* gdbsim */
- + strlen (" -E little")
- + strlen (" --architecture=xxxxxxxxxx")
- + (args ? strlen (args) : 0)
- + 50) /* slack */;
- arg_buf = (char *) alloca (len);
- strcpy (arg_buf, "gdbsim"); /* 7 */
- /* Specify the byte order for the target when it is both selectable
- and explicitly specified by the user (not auto detected). */
- if (TARGET_BYTE_ORDER_SELECTABLE_P
- && !TARGET_BYTE_ORDER_AUTO)
- {
- switch (TARGET_BYTE_ORDER)
- {
- case BIG_ENDIAN:
- strcat (arg_buf, " -E big");
- break;
- case LITTLE_ENDIAN:
- strcat (arg_buf, " -E little");
- break;
- default:
- fatal ("Value of TARGET_BYTE_ORDER unknown");
- }
- }
- /* Specify the architecture of the target when it has been
- explicitly specified */
- if (!TARGET_ARCHITECTURE_AUTO)
- {
- strcat (arg_buf, " --architecture=");
- strcat (arg_buf, TARGET_ARCHITECTURE->printable_name);
- }
- /* finally, any explicit args */
- if (args)
- {
- strcat (arg_buf, " "); /* 1 */
- strcat (arg_buf, args);
- }
- argv = buildargv (arg_buf);
- if (argv == NULL)
- error ("Insufficient memory available to allocate simulator arg list.");
- make_cleanup ((make_cleanup_func) freeargv, argv);
-
- init_callbacks ();
- gdbsim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, argv);
-
- if (gdbsim_desc == 0)
- error ("unable to create simulator instance");
-
- push_target (&gdbsim_ops);
- target_fetch_registers (-1);
- printf_filtered ("Connected to the simulator.\n");
-}
-
-/* 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. */
-/* Close out all files and local state before this target loses control. */
-
-static void
-gdbsim_close (quitting)
- int quitting;
-{
- if (sr_get_debug ())
- printf_filtered ("gdbsim_close: quitting %d\n", quitting);
-
- program_loaded = 0;
-
- if (gdbsim_desc != NULL)
- {
- sim_close (gdbsim_desc, quitting);
- gdbsim_desc = NULL;
- }
-
- end_callbacks ();
-}
-
-/* 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. */
-/* Terminate the open connection to the remote debugger.
- Use this when you want to detach and do something else with your gdb. */
-
-static void
-gdbsim_detach (args,from_tty)
- char *args;
- int from_tty;
-{
- if (sr_get_debug ())
- printf_filtered ("gdbsim_detach: args \"%s\"\n", args);
-
- pop_target (); /* calls gdbsim_close to do the real work */
- if (from_tty)
- printf_filtered ("Ending simulator %s debugging\n", target_shortname);
-}
-
-/* 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. */
-
-static enum target_signal resume_siggnal;
-static int resume_step;
-
-static void
-gdbsim_resume (pid, step, siggnal)
- int pid, step;
- enum target_signal siggnal;
-{
- if (inferior_pid != 42)
- error ("The program is not being run.");
-
- if (sr_get_debug ())
- printf_filtered ("gdbsim_resume: step %d, signal %d\n", step, siggnal);
-
- resume_siggnal = siggnal;
- resume_step = step;
-}
-
-/* Notify the simulator of an asynchronous request to stop.
-
- The simulator shall ensure that the stop request is eventually
- delivered to the simulator. If the call is made while the
- simulator is not running then the stop request is processed when
- the simulator is next resumed.
-
- For simulators that do not support this operation, just abort */
-
-static void
-gdbsim_stop ()
-{
- if (! sim_stop (gdbsim_desc))
- {
- quit ();
- }
-}
-
-/* GDB version of os_poll_quit callback.
- Taken from gdb/util.c - should be in a library */
-
-static int
-gdb_os_poll_quit (p)
- host_callback *p;
-{
- notice_quit ();
- if (quit_flag) /* gdb's idea of quit */
- {
- quit_flag = 0; /* we've stolen it */
- return 1;
- }
- else if (immediate_quit)
- {
- return 1;
- }
- return 0;
-}
-
-/* Wait for inferior process to do something. Return pid of child,
- or -1 in case of error; store status through argument pointer STATUS,
- just as `wait' would. */
-
-static void
-gdbsim_cntrl_c (signo)
- int signo;
-{
- gdbsim_stop ();
-}
-
-static int
-gdbsim_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- static RETSIGTYPE (*prev_sigint) ();
- int sigrc = 0;
- enum sim_stop reason = sim_running;
-
- if (sr_get_debug ())
- printf_filtered ("gdbsim_wait\n");
-
-#if defined (HAVE_SIGACTION) && defined (SA_RESTART)
- {
- struct sigaction sa, osa;
- sa.sa_handler = gdbsim_cntrl_c;
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = 0;
- sigaction (SIGINT, &sa, &osa);
- prev_sigint = osa.sa_handler;
- }
-#else
- prev_sigint = signal (SIGINT, gdbsim_cntrl_c);
-#endif
- sim_resume (gdbsim_desc, resume_step,
- target_signal_to_host (resume_siggnal));
- signal (SIGINT, prev_sigint);
- resume_step = 0;
-
- sim_stop_reason (gdbsim_desc, &reason, &sigrc);
-
- switch (reason)
- {
- case sim_exited:
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = sigrc;
- break;
- case sim_stopped:
- switch (sigrc)
- {
- case SIGABRT:
- quit ();
- break;
- case SIGINT:
- case SIGTRAP:
- default:
- status->kind = TARGET_WAITKIND_STOPPED;
- /* The signal in sigrc is a host signal. That probably
- should be fixed. */
- status->value.sig = target_signal_from_host (sigrc);
- break;
- }
- break;
- case sim_signalled:
- status->kind = TARGET_WAITKIND_SIGNALLED;
- /* The signal in sigrc is a host signal. That probably
- should be fixed. */
- status->value.sig = target_signal_from_host (sigrc);
- break;
- case sim_running:
- case sim_polling:
- /* FIXME: Is this correct? */
- break;
- }
-
- return inferior_pid;
-}
-
-/* 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
-gdbsim_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static int
-gdbsim_xfer_inferior_memory (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target; /* ignored */
-{
- if (! program_loaded)
- error ("No program loaded.");
-
- if (sr_get_debug ())
- {
- printf_filtered ("gdbsim_xfer_inferior_memory: myaddr 0x%x, memaddr 0x%x, len %d, write %d\n",
- myaddr, memaddr, len, write);
- if (sr_get_debug () && write)
- dump_mem(myaddr, len);
- }
-
- if (write)
- {
- len = sim_write (gdbsim_desc, memaddr, myaddr, len);
- }
- else
- {
- len = sim_read (gdbsim_desc, memaddr, myaddr, len);
- if (sr_get_debug () && len > 0)
- dump_mem(myaddr, len);
- }
- return len;
-}
-
-static void
-gdbsim_files_info (target)
- struct target_ops *target;
-{
- char *file = "nothing";
-
- if (exec_bfd)
- file = bfd_get_filename (exec_bfd);
-
- if (sr_get_debug ())
- printf_filtered ("gdbsim_files_info: file \"%s\"\n", file);
-
- if (exec_bfd)
- {
- printf_filtered ("\tAttached to %s running program %s\n",
- target_shortname, file);
- sim_info (gdbsim_desc, 0);
- }
-}
-
-/* Clear the simulator's notion of what the break points are. */
-
-static void
-gdbsim_mourn_inferior ()
-{
- if (sr_get_debug ())
- printf_filtered ("gdbsim_mourn_inferior:\n");
-
- remove_breakpoints ();
- generic_mourn_inferior ();
-}
-
-static int
-gdbsim_insert_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
-#ifdef SIM_HAS_BREAKPOINTS
- SIM_RC retcode;
-
- retcode = sim_set_breakpoint (gdbsim_desc, addr);
-
- switch (retcode)
- {
- case SIM_RC_OK:
- return 0;
- case SIM_RC_INSUFFICIENT_RESOURCES:
- return ENOMEM;
- default:
- return EIO;
- }
-#else
- return memory_insert_breakpoint (addr, contents_cache);
-#endif
-}
-
-static int
-gdbsim_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
-#ifdef SIM_HAS_BREAKPOINTS
- SIM_RC retcode;
-
- retcode = sim_clear_breakpoint (gdbsim_desc, addr);
-
- switch (retcode)
- {
- case SIM_RC_OK:
- case SIM_RC_UNKNOWN_BREAKPOINT:
- return 0;
- case SIM_RC_INSUFFICIENT_RESOURCES:
- return ENOMEM;
- default:
- return EIO;
- }
-#else
- return memory_remove_breakpoint (addr, contents_cache);
-#endif
-}
-
-/* Pass the command argument through to the simulator verbatim. The
- simulator must do any command interpretation work. */
-
-void
-simulator_command (args, from_tty)
- char *args;
- int from_tty;
-{
- if (gdbsim_desc == NULL)
- {
-
- /* PREVIOUSLY: The user may give a command before the simulator
- is opened. [...] (??? assuming of course one wishes to
- continue to allow commands to be sent to unopened simulators,
- which isn't entirely unreasonable). */
-
- /* The simulator is a builtin abstraction of a remote target.
- Consistent with that model, access to the simulator, via sim
- commands, is restricted to the period when the channel to the
- simulator is open. */
-
- error ("Not connected to the simulator target");
- }
-
- sim_do_command (gdbsim_desc, args);
-
- /* Invalidate the register cache, in case the simulator command does
- something funny. */
- registers_changed ();
-}
-
-/* Define the target subroutine names */
-
-struct target_ops gdbsim_ops ;
-
-static void
-init_gdbsim_ops(void)
-{
- gdbsim_ops.to_shortname = "sim";
- gdbsim_ops.to_longname = "simulator";
- gdbsim_ops.to_doc = "Use the compiled-in simulator.";
- gdbsim_ops.to_open = gdbsim_open;
- gdbsim_ops.to_close = gdbsim_close;
- gdbsim_ops.to_attach = NULL;
- gdbsim_ops.to_post_attach = NULL;
- gdbsim_ops.to_require_attach = NULL;
- gdbsim_ops.to_detach = gdbsim_detach;
- gdbsim_ops.to_require_detach = NULL;
- gdbsim_ops.to_resume = gdbsim_resume;
- gdbsim_ops.to_wait = gdbsim_wait;
- gdbsim_ops.to_post_wait = NULL;
- gdbsim_ops.to_fetch_registers = gdbsim_fetch_register;
- gdbsim_ops.to_store_registers = gdbsim_store_register;
- gdbsim_ops.to_prepare_to_store = gdbsim_prepare_to_store;
- gdbsim_ops.to_xfer_memory = gdbsim_xfer_inferior_memory;
- gdbsim_ops.to_files_info = gdbsim_files_info;
- gdbsim_ops.to_insert_breakpoint = gdbsim_insert_breakpoint;
- gdbsim_ops.to_remove_breakpoint = gdbsim_remove_breakpoint;
- gdbsim_ops.to_terminal_init = NULL;
- gdbsim_ops.to_terminal_inferior = NULL;
- gdbsim_ops.to_terminal_ours_for_output = NULL;
- gdbsim_ops.to_terminal_ours = NULL;
- gdbsim_ops.to_terminal_info = NULL;
- gdbsim_ops.to_kill = gdbsim_kill;
- gdbsim_ops.to_load = gdbsim_load;
- gdbsim_ops.to_lookup_symbol = NULL;
- gdbsim_ops.to_create_inferior = gdbsim_create_inferior;
- gdbsim_ops.to_post_startup_inferior = NULL;
- gdbsim_ops.to_acknowledge_created_inferior = NULL;
- gdbsim_ops.to_clone_and_follow_inferior = NULL;
- gdbsim_ops.to_post_follow_inferior_by_clone = NULL;
- gdbsim_ops.to_insert_fork_catchpoint = NULL;
- gdbsim_ops.to_remove_fork_catchpoint = NULL;
- gdbsim_ops.to_insert_vfork_catchpoint = NULL;
- gdbsim_ops.to_remove_vfork_catchpoint = NULL;
- gdbsim_ops.to_has_forked = NULL;
- gdbsim_ops.to_has_vforked = NULL;
- gdbsim_ops.to_can_follow_vfork_prior_to_exec = NULL;
- gdbsim_ops.to_post_follow_vfork = NULL;
- gdbsim_ops.to_insert_exec_catchpoint = NULL;
- gdbsim_ops.to_remove_exec_catchpoint = NULL;
- gdbsim_ops.to_has_execd = NULL;
- gdbsim_ops.to_reported_exec_events_per_exec_call = NULL;
- gdbsim_ops.to_has_exited = NULL;
- gdbsim_ops.to_mourn_inferior = gdbsim_mourn_inferior;
- gdbsim_ops.to_can_run = 0;
- gdbsim_ops.to_notice_signals = 0;
- gdbsim_ops.to_thread_alive = 0;
- gdbsim_ops.to_stop = gdbsim_stop;
- gdbsim_ops.to_pid_to_exec_file = NULL;
- gdbsim_ops.to_core_file_to_sym_file = NULL;
- gdbsim_ops.to_stratum = process_stratum;
- gdbsim_ops.DONT_USE = NULL;
- gdbsim_ops.to_has_all_memory = 1;
- gdbsim_ops.to_has_memory = 1;
- gdbsim_ops.to_has_stack = 1;
- gdbsim_ops.to_has_registers = 1;
- gdbsim_ops.to_has_execution = 1;
- gdbsim_ops.to_sections = NULL;
- gdbsim_ops.to_sections_end = NULL;
- gdbsim_ops.to_magic = OPS_MAGIC;
-
-#ifdef TARGET_REDEFINE_DEFAULT_OPS
- TARGET_REDEFINE_DEFAULT_OPS (&gdbsim_ops);
-#endif
-}
-
-void
-_initialize_remote_sim ()
-{
- init_gdbsim_ops() ;
- add_target (&gdbsim_ops);
-
- add_com ("sim <command>", class_obscure, simulator_command,
- "Send a command to the simulator.");
-}
diff --git a/contrib/gdb/gdb/remote-st.c b/contrib/gdb/gdb/remote-st.c
deleted file mode 100644
index 1efdbfa..0000000
--- a/contrib/gdb/gdb/remote-st.c
+++ /dev/null
@@ -1,879 +0,0 @@
-/* Remote debugging interface for Tandem ST2000 phone switch, for GDB.
- Copyright 1990, 1991, 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This file was derived from remote-eb.c, which did a similar job, but for
- an AMD-29K running EBMON. That file was in turn derived from remote.c
- as mentioned in the following comment (left in for comic relief):
-
- "This is like remote.c but is for an esoteric situation--
- having an a29k 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."
-
- In reality, this module talks to a debug monitor called 'STDEBUG', which
- runs in a phone switch. We communicate with STDEBUG via either a direct
- serial line, or a TCP (or possibly TELNET) stream to a terminal multiplexor,
- which in turn talks to the phone switch. */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "target.h"
-#include "wait.h"
-#ifdef ANSI_PROTOTYPES
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <signal.h>
-#include "gdb_string.h"
-#include <sys/types.h>
-#include "serial.h"
-
-extern struct target_ops st2000_ops; /* Forward declaration */
-
-static void st2000_close();
-static void st2000_fetch_register();
-static void st2000_store_register();
-
-#define LOG_FILE "st2000.log"
-#if defined (LOG_FILE)
-FILE *log_file;
-#endif
-
-static int timeout = 24;
-
-/* Descriptor for I/O to remote machine. Initialize it to -1 so that
- st2000_open knows that we don't have a file open when the program
- starts. */
-
-static serial_t st2000_desc;
-
-/* Send data to stdebug. Works just like printf. */
-
-static void
-#ifdef ANSI_PROTOTYPES
-printf_stdebug(char *pattern, ...)
-#else
-printf_stdebug(va_alist)
- va_dcl
-#endif
-{
- va_list args;
- char buf[200];
-
-#ifdef ANSI_PROTOTYPES
- va_start(args, pattern);
-#else
- char *pattern;
- va_start(args);
- pattern = va_arg(args, char *);
-#endif
-
- vsprintf(buf, pattern, args);
- va_end(args);
-
- if (SERIAL_WRITE(st2000_desc, buf, strlen(buf)))
- fprintf(stderr, "SERIAL_WRITE failed: %s\n", safe_strerror(errno));
-}
-
-/* Read a character from the remote system, doing all the fancy timeout
- stuff. */
-
-static int
-readchar(timeout)
- int timeout;
-{
- int c;
-
- c = SERIAL_READCHAR(st2000_desc, timeout);
-
-#ifdef LOG_FILE
- putc(c & 0x7f, log_file);
-#endif
-
- if (c >= 0)
- return c & 0x7f;
-
- if (c == SERIAL_TIMEOUT)
- {
- if (timeout == 0)
- return c; /* Polls shouldn't generate timeout errors */
-
- error("Timeout reading from remote system.");
- }
-
- perror_with_name("remote-st2000");
-}
-
-/* Scan input from the remote system, until STRING is found. If DISCARD is
- non-zero, then discard non-matching input, else print it out.
- Let the user break out immediately. */
-static void
-expect(string, discard)
- char *string;
- int discard;
-{
- char *p = string;
- int c;
-
- immediate_quit = 1;
- while (1)
- {
- c = readchar(timeout);
- if (c == *p++)
- {
- if (*p == '\0')
- {
- immediate_quit = 0;
- return;
- }
- }
- else
- {
- if (!discard)
- {
- fwrite(string, 1, (p - 1) - string, stdout);
- putchar((char)c);
- fflush(stdout);
- }
- p = string;
- }
- }
-}
-
-/* Keep discarding input until we see the STDEBUG 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: st2000_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 st2000_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(discard)
- int discard;
-{
-#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 ("dbug> ", discard);
-}
-
-/* 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(timeout);
- 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(1);
- error("Invalid hex digit from remote system.");
- }
- }
-}
-
-/* Get a byte from stdebug 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++, (char *) &val);
- }
-}
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-static void
-st2000_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- int entry_pt;
-
- if (args && *args)
- error("Can't pass arguments to remote STDEBUG process");
-
- if (execfile == 0 || exec_bfd == 0)
- error("No executable file specified");
-
- entry_pt = (int) bfd_get_start_address (exec_bfd);
-
-/* The "process" (board) is already stopped awaiting our commands, and
- the program is already downloaded. We just set its PC and go. */
-
- clear_proceed_status ();
-
- /* Tell wait_for_inferior that we've started a new process. */
- 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 ();
-
- /* insert_step_breakpoint (); FIXME, do we need this? */
- /* Let 'er rip... */
- proceed ((CORE_ADDR)entry_pt, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-/* Open a connection to a remote debugger.
- NAME is the filename used for communication. */
-
-static int baudrate = 9600;
-static char dev_name[100];
-
-static void
-st2000_open(args, from_tty)
- char *args;
- int from_tty;
-{
- int n;
- char junk[100];
-
- target_preopen(from_tty);
-
- n = sscanf(args, " %s %d %s", dev_name, &baudrate, junk);
-
- if (n != 2)
- error("Bad arguments. Usage: target st2000 <device> <speed>\n\
-or target st2000 <host> <port>\n");
-
- st2000_close(0);
-
- st2000_desc = SERIAL_OPEN(dev_name);
-
- if (!st2000_desc)
- perror_with_name(dev_name);
-
- SERIAL_SETBAUDRATE(st2000_desc, baudrate);
-
- SERIAL_RAW(st2000_desc);
-
- push_target(&st2000_ops);
-
-#if defined (LOG_FILE)
- log_file = fopen (LOG_FILE, "w");
- if (log_file == NULL)
- perror_with_name (LOG_FILE);
-#endif
-
- /* Hello? Are you there? */
- printf_stdebug("\003"); /* ^C wakes up dbug */
-
- expect_prompt(1);
-
- if (from_tty)
- printf("Remote %s connected to %s\n", target_shortname,
- dev_name);
-}
-
-/* Close out all files and local state before this target loses control. */
-
-static void
-st2000_close (quitting)
- int quitting;
-{
- SERIAL_CLOSE(st2000_desc);
-
-#if defined (LOG_FILE)
- if (log_file) {
- if (ferror(log_file))
- fprintf(stderr, "Error writing log file.\n");
- if (fclose(log_file) != 0)
- fprintf(stderr, "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. */
-static void
-st2000_detach (from_tty)
- int from_tty;
-{
- pop_target(); /* calls st2000_close to do the real work */
- if (from_tty)
- printf ("Ending remote %s debugging\n", target_shortname);
-}
-
-/* Tell the remote machine to resume. */
-
-static void
-st2000_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
-{
- if (step)
- {
- printf_stdebug ("ST\r");
- /* Wait for the echo. */
- expect ("ST\r", 1);
- }
- else
- {
- printf_stdebug ("GO\r");
- /* Swallow the echo. */
- expect ("GO\r", 1);
- }
-}
-
-/* Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-static int
-st2000_wait (status)
- struct target_waitstatus *status;
-{
- int old_timeout = timeout;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
- timeout = 0; /* Don't time out -- user program is running. */
-
- expect_prompt(0); /* Wait for prompt, outputting extraneous text */
-
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
-
- timeout = old_timeout;
-
- return 0;
-}
-
-/* Return the name of register number REGNO in the form input and output by
- STDEBUG. Currently, REGISTER_NAMES just happens to contain exactly what
- STDEBUG wants. Lets take advantage of that just as long as possible! */
-
-static char *
-get_reg_name (regno)
- int regno;
-{
- static char buf[50];
- const char *p;
- char *b;
-
- b = buf;
-
- for (p = REGISTER_NAME (regno); *p; p++)
- *b++ = toupper(*p);
- *b = '\000';
-
- return buf;
-}
-
-/* Read the remote registers into the block REGS. */
-
-static void
-st2000_fetch_registers ()
-{
- int regno;
-
- /* Yeah yeah, I know this is horribly inefficient. But it isn't done
- very often... I'll clean it up later. */
-
- for (regno = 0; regno <= PC_REGNUM; regno++)
- st2000_fetch_register(regno);
-}
-
-/* Fetch register REGNO, or all registers if REGNO is -1.
- Returns errno value. */
-static void
-st2000_fetch_register (regno)
- int regno;
-{
- if (regno == -1)
- st2000_fetch_registers ();
- else
- {
- char *name = get_reg_name (regno);
- printf_stdebug ("DR %s\r", name);
- expect (name, 1);
- expect (" : ", 1);
- get_hex_regs (1, regno);
- expect_prompt (1);
- }
- return;
-}
-
-/* Store the remote registers from the contents of the block REGS. */
-
-static void
-st2000_store_registers ()
-{
- int regno;
-
- for (regno = 0; regno <= PC_REGNUM; regno++)
- st2000_store_register(regno);
-
- registers_changed ();
-}
-
-/* Store register REGNO, or all if REGNO == 0.
- Return errno value. */
-static void
-st2000_store_register (regno)
- int regno;
-{
- if (regno == -1)
- st2000_store_registers ();
- else
- {
- printf_stdebug ("PR %s %x\r", get_reg_name (regno),
- read_register (regno));
-
- expect_prompt (1);
- }
-}
-
-/* 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
-st2000_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-static void
-st2000_files_info ()
-{
- printf ("\tAttached to %s at %d baud.\n",
- dev_name, baudrate);
-}
-
-/* Copy LEN bytes of data from debugger memory at MYADDR
- to inferior's memory at MEMADDR. Returns length moved. */
-static int
-st2000_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned char *myaddr;
- int len;
-{
- int i;
-
- for (i = 0; i < len; i++)
- {
- printf_stdebug ("PM.B %x %x\r", memaddr + i, myaddr[i]);
- expect_prompt (1);
- }
- return len;
-}
-
-/* Read LEN bytes from inferior memory at MEMADDR. Put the result
- at debugger address MYADDR. Returns length moved. */
-static int
-st2000_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
- st2000_read_bytes (CORE_ADDR_MAX - 4, foo, 4)
- works--it never adds len to memaddr and gets 0. */
- /* However, something like
- st2000_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) {
- errno = EIO;
- return 0;
- }
-
- 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);
-
- printf_stdebug ("DI.L %x %x\r", startaddr, len_this_pass);
- expect (": ", 1);
-
- for (i = 0; i < len_this_pass; i++)
- get_hex_byte (&myaddr[count++]);
-
- expect_prompt (1);
-
- startaddr += len_this_pass;
- }
- return len;
-}
-
-/* FIXME-someday! Merge these two. */
-static int
-st2000_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 st2000_write_inferior_memory (memaddr, myaddr, len);
- else
- return st2000_read_inferior_memory (memaddr, myaddr, len);
-}
-
-static void
-st2000_kill (args, from_tty)
- char *args;
- int from_tty;
-{
- return; /* Ignore attempts to kill target system */
-}
-
-/* Clean up when a program exits.
-
- The program actually lives on in the remote processor's RAM, and may be
- run again without a download. Don't leave it full of breakpoint
- instructions. */
-
-static void
-st2000_mourn_inferior ()
-{
- remove_breakpoints ();
- unpush_target (&st2000_ops);
- generic_mourn_inferior (); /* Do all the proper things now */
-}
-
-#define MAX_STDEBUG_BREAKPOINTS 16
-
-static CORE_ADDR breakaddr[MAX_STDEBUG_BREAKPOINTS] = {0};
-
-static int
-st2000_insert_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
-{
- int i;
- CORE_ADDR bp_addr = addr;
- int bp_size = 0;
-
- BREAKPOINT_FROM_PC (&bp_addr, &bp_size);
-
- for (i = 0; i <= MAX_STDEBUG_BREAKPOINTS; i++)
- if (breakaddr[i] == 0)
- {
- breakaddr[i] = addr;
-
- st2000_read_inferior_memory (bp_addr, shadow, bp_size);
- printf_stdebug("BR %x H\r", addr);
- expect_prompt(1);
- return 0;
- }
-
- fprintf(stderr, "Too many breakpoints (> 16) for STDBUG\n");
- return 1;
-}
-
-static int
-st2000_remove_breakpoint (addr, shadow)
- CORE_ADDR addr;
- char *shadow;
-{
- int i;
-
- for (i = 0; i < MAX_STDEBUG_BREAKPOINTS; i++)
- if (breakaddr[i] == addr)
- {
- breakaddr[i] = 0;
-
- printf_stdebug("CB %d\r", i);
- expect_prompt(1);
- return 0;
- }
-
- fprintf(stderr, "Can't find breakpoint associated with 0x%x\n", addr);
- return 1;
-}
-
-
-/* Put a command string, in args, out to STDBUG. Output from STDBUG is placed
- on the users terminal until the prompt is seen. */
-
-static void
-st2000_command (args, fromtty)
- char *args;
- int fromtty;
-{
- if (!st2000_desc)
- error("st2000 target not open.");
-
- if (!args)
- error("Missing command.");
-
- printf_stdebug("%s\r", args);
- expect_prompt(0);
-}
-
-/* Connect the user directly to STDBUG. This command acts just like the
- 'cu' or 'tip' command. Use <CR>~. or <CR>~^D to break out. */
-
-/*static struct ttystate ttystate;*/
-
-static void
-cleanup_tty()
-{
- printf("\r\n[Exiting connect mode]\r\n");
-/* SERIAL_RESTORE(0, &ttystate);*/
-}
-
-#if 0
-/* This all should now be in serial.c */
-
-static void
-connect_command (args, fromtty)
- char *args;
- int fromtty;
-{
- fd_set readfds;
- int numfds;
- int c;
- char cur_esc = 0;
-
- dont_repeat();
-
- if (st2000_desc < 0)
- error("st2000 target not open.");
-
- if (args)
- fprintf("This command takes no args. They have been ignored.\n");
-
- printf("[Entering connect mode. Use ~. or ~^D to escape]\n");
-
- serial_raw(0, &ttystate);
-
- make_cleanup(cleanup_tty, 0);
-
- FD_ZERO(&readfds);
-
- while (1)
- {
- do
- {
- FD_SET(0, &readfds);
- FD_SET(st2000_desc, &readfds);
- numfds = select(sizeof(readfds)*8, &readfds, 0, 0, 0);
- }
- while (numfds == 0);
-
- if (numfds < 0)
- perror_with_name("select");
-
- if (FD_ISSET(0, &readfds))
- { /* tty input, send to stdebug */
- c = getchar();
- if (c < 0)
- perror_with_name("connect");
-
- printf_stdebug("%c", c);
- switch (cur_esc)
- {
- case 0:
- if (c == '\r')
- cur_esc = c;
- break;
- case '\r':
- if (c == '~')
- cur_esc = c;
- else
- cur_esc = 0;
- break;
- case '~':
- if (c == '.' || c == '\004')
- return;
- else
- cur_esc = 0;
- }
- }
-
- if (FD_ISSET(st2000_desc, &readfds))
- {
- while (1)
- {
- c = readchar(0);
- if (c < 0)
- break;
- putchar(c);
- }
- fflush(stdout);
- }
- }
-}
-#endif /* 0 */
-
-/* Define the target subroutine names */
-
-struct target_ops st2000_ops ;
-
-static void
-init_st2000_ops(void)
-{
- st2000_ops.to_shortname = "st2000";
- st2000_ops.to_longname = "Remote serial Tandem ST2000 target";
- st2000_ops.to_doc = "Use a remote computer running STDEBUG connected by a serial line;\n\
-or a network connection.\n\
-Arguments are the name of the device for the serial line,\n\
-the speed to connect at in bits per second." ;
- st2000_ops.to_open = st2000_open;
- st2000_ops.to_close = st2000_close;
- st2000_ops.to_attach = 0;
- st2000_run_ops.to_post_attach = NULL;
- st2000_ops.to_require_attach = NULL;
- st2000_ops.to_detach = st2000_detach;
- st2000_ops.to_require_detach = NULL;
- st2000_ops.to_resume = st2000_resume;
- st2000_ops.to_wait = st2000_wait;
- st2000_ops.to_post_wait = NULL;
- st2000_ops.to_fetch_registers = st2000_fetch_register;
- st2000_ops.to_store_registers = st2000_store_register;
- st2000_ops.to_prepare_to_store = st2000_prepare_to_store;
- st2000_ops.to_xfer_memory = st2000_xfer_inferior_memory;
- st2000_ops.to_files_info = st2000_files_info;
- st2000_ops.to_insert_breakpoint = st2000_insert_breakpoint;
- st2000_ops.to_remove_breakpoint = st2000_remove_breakpoint; /* Breakpoints */
- st2000_ops.to_terminal_init = 0;
- st2000_ops.to_terminal_inferior = 0;
- st2000_ops.to_terminal_ours_for_output = 0;
- st2000_ops.to_terminal_ours = 0;
- st2000_ops.to_terminal_info = 0; /* Terminal handling */
- st2000_ops.to_kill = st2000_kill;
- st2000_ops.to_load = 0; /* load */
- st2000_ops.to_lookup_symbol = 0; /* lookup_symbol */
- st2000_ops.to_create_inferior = st2000_create_inferior;
- st2000_ops.to_post_startup_inferior = NULL;
- st2000_ops.to_acknowledge_created_inferior = NULL;
- st2000_ops.to_clone_and_follow_inferior = NULL;
- st2000_ops.to_post_follow_inferior_by_clone = NULL;
- st2000_run_ops.to_insert_fork_catchpoint = NULL;
- st2000_run_ops.to_remove_fork_catchpoint = NULL;
- st2000_run_ops.to_insert_vfork_catchpoint = NULL;
- st2000_run_ops.to_remove_vfork_catchpoint = NULL;
- st2000_ops.to_has_forked = NULL;
- st2000_ops.to_has_vforked = NULL;
- st2000_run_ops.to_can_follow_vfork_prior_to_exec = NULL;
- st2000_ops.to_post_follow_vfork = NULL;
- st2000_run_ops.to_insert_exec_catchpoint = NULL;
- st2000_run_ops.to_remove_exec_catchpoint = NULL;
- st2000_run_ops.to_has_execd = NULL;
- st2000_run_ops.to_reported_exec_events_per_exec_call = NULL;
- st2000_run_ops.to_has_exited = NULL;
- st2000_ops.to_mourn_inferior = st2000_mourn_inferior;
- st2000_ops.to_can_run = 0; /* can_run */
- st2000_ops.to_notice_signals = 0; /* notice_signals */
- st2000_ops.to_thread_alive = 0; /* thread alive */
- st2000_ops.to_stop = 0; /* to_stop */
- st2000_ops.to_pid_to_exec_file = NULL;
- st2000_run_ops.to_core_file_to_sym_file = NULL;
- st2000_ops.to_stratum = process_stratum;
- st2000_ops.DONT_USE = 0; /* next */
- st2000_ops.to_has_all_memory = 1;
- st2000_ops.to_has_memory = 1;
- st2000_ops.to_has_stack = 1;
- st2000_ops.to_has_registers = 1;
- st2000_ops.to_has_execution = 1; /* all mem, mem, stack, regs, exec */
- st2000_ops.to_sections = 0;
- st2000_ops.to_sections_end = 0; /* Section pointers */
- st2000_ops.to_magic = OPS_MAGIC; /* Always the last thing */
-} ;
-
-void
-_initialize_remote_st2000 ()
-{
- init_st2000_ops() ;
- add_target (&st2000_ops);
- add_com ("st2000 <command>", class_obscure, st2000_command,
- "Send a command to the STDBUG monitor.");
- add_com ("connect", class_obscure, connect_command,
- "Connect the terminal directly up to the STDBUG command monitor.\n\
-Use <CR>~. or <CR>~^D to break out.");
-}
diff --git a/contrib/gdb/gdb/remote-udi.c b/contrib/gdb/gdb/remote-udi.c
deleted file mode 100644
index 6397bca..0000000
--- a/contrib/gdb/gdb/remote-udi.c
+++ /dev/null
@@ -1,1694 +0,0 @@
-/* Remote debugging interface for AMD 29k interfaced via UDI, for GDB.
- Copyright 1990, 1992, 1995 Free Software Foundation, Inc.
- Written by Daniel Mann. Contributed by 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* This is like remote.c but uses the Universal Debug Interface (UDI) to
- talk to the target hardware (or simulator). UDI is a TCP/IP based
- protocol; for hardware that doesn't run TCP, an interface adapter
- daemon talks UDI on one side, and talks to the hardware (typically
- over a serial port) on the other side.
-
- - Originally written by Daniel Mann at AMD for MiniMON and gdb 3.91.6.
- - 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.
- - Daniel Mann at AMD took the 3.95 adaptions above and replaced
- MiniMON interface with UDI-p interface. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "wait.h"
-#include "value.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <errno.h>
-#include "gdb_string.h"
-#include "terminal.h"
-#include "target.h"
-#include "29k-share/udi/udiproc.h"
-#include "gdbcmd.h"
-#include "bfd.h"
-#include "gdbcore.h" /* For download function */
-
-/* access the register store directly, without going through
- the normal handler functions. This avoids an extra data copy. */
-
-extern int stop_soon_quietly; /* for wait_for_inferior */
-extern struct value *call_function_by_hand();
-static void udi_resume PARAMS ((int pid, int step, enum target_signal sig));
-static void udi_fetch_registers PARAMS ((int regno));
-static void udi_load PARAMS ((char *args, int from_tty));
-static void fetch_register PARAMS ((int regno));
-static void udi_store_registers PARAMS ((int regno));
-static int store_register PARAMS ((int regno));
-static int regnum_to_srnum PARAMS ((int regno));
-static void udi_close PARAMS ((int quitting));
-static CPUSpace udi_memory_space PARAMS ((CORE_ADDR addr));
-static int udi_write_inferior_memory PARAMS ((CORE_ADDR memaddr, char *myaddr,
- int len));
-static int udi_read_inferior_memory PARAMS ((CORE_ADDR memaddr, char *myaddr,
- int len));
-static void download PARAMS ((char *load_arg_string, int from_tty));
-char CoffFileName[100] = "";
-
-#define FREEZE_MODE (read_register(CPS_REGNUM) & 0x400)
-#define USE_SHADOW_PC ((processor_type == a29k_freeze_mode) && FREEZE_MODE)
-
-static int timeout = 5;
-extern struct target_ops udi_ops; /* Forward declaration */
-
-/* Special register enumeration.
-*/
-
-/******************************************************************* UDI DATA*/
-#define MAXDATA 2*1024 /* max UDI[read/write] byte size */
-/* Descriptor for I/O to remote machine. Initialize it to -1 so that
- udi_open knows that we don't have a file open when the program
- starts. */
-
-UDISessionId udi_session_id = -1;
-static char *udi_config_id;
-
-CPUOffset IMemStart = 0;
-CPUSizeT IMemSize = 0;
-CPUOffset DMemStart = 0;
-CPUSizeT DMemSize = 0;
-CPUOffset RMemStart = 0;
-CPUSizeT RMemSize = 0;
-UDIUInt32 CPUPRL;
-UDIUInt32 CoProcPRL;
-
-UDIMemoryRange address_ranges[2]; /* Text and data */
-UDIResource entry = {0, 0}; /* Entry point */
-CPUSizeT stack_sizes[2]; /* Regular and memory stacks */
-
-#define SBUF_MAX 1024 /* maximum size of string handling buffer */
-char sbuf[SBUF_MAX];
-
-typedef struct bkpt_entry_str
-{
- UDIResource Addr;
- UDIUInt32 PassCount;
- UDIBreakType Type;
- unsigned int BreakId;
-} bkpt_entry_t;
-#define BKPT_TABLE_SIZE 40
-static bkpt_entry_t bkpt_table[BKPT_TABLE_SIZE];
-extern char dfe_errmsg[]; /* error string */
-
-/* malloc'd name of the program on the remote system. */
-static char *prog_name = NULL;
-
-/* This is called not only when we first attach, but also when the
- user types "run" after having attached. */
-
-static void
-udi_create_inferior (execfile, args, env)
- char *execfile;
- char *args;
- char **env;
-{
- char *args1;
-
- if (execfile)
- {
- if (prog_name != NULL)
- free (prog_name);
- prog_name = savestring (execfile, strlen (execfile));
- }
- else if (entry.Offset)
- execfile = "";
- else
- error ("No image loaded into target.");
-
- if (udi_session_id < 0)
- {
- /* If the TIP is not open, open it. */
- if (UDIConnect (udi_config_id, &udi_session_id))
- error("UDIConnect() failed: %s\n", dfe_errmsg);
- /* We will need to download the program. */
- entry.Offset = 0;
- }
-
- inferior_pid = 40000;
-
- if (!entry.Offset)
- download(execfile, 0);
-
- args1 = alloca (strlen(execfile) + strlen(args) + 2);
-
- if (execfile[0] == '\0')
-
- /* It is empty. We need to quote it somehow, or else the target
- will think there is no argument being passed here. According
- to the UDI spec it is quoted "according to TIP OS rules" which
- I guess means quoting it like the Unix shell should work
- (sounds pretty bogus to me...). In fact it doesn't work (with
- isstip anyway), but passing in two quotes as the argument seems
- like a reasonable enough behavior anyway (I guess). */
-
- strcpy (args1, "''");
- else
- strcpy (args1, execfile);
- strcat (args1, " ");
- strcat (args1, args);
-
- UDIInitializeProcess (address_ranges, /* ProcessMemory[] */
- (UDIInt)2, /* NumberOfRanges */
- entry, /* EntryPoint */
- stack_sizes, /* *StackSizes */
- (UDIInt)2, /* NumberOfStacks */
- args1); /* ArgString */
-
- init_wait_for_inferior ();
- clear_proceed_status ();
- proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
-}
-
-static void
-udi_mourn()
-{
-#if 0
- /* Requiring "target udi" each time you run is a major pain. I suspect
- this was just blindy copied from remote.c, in which "target" and
- "run" are combined. Having a udi target without an inferior seems
- to work between "target udi" and "run", so why not now? */
- pop_target (); /* Pop back to no-child state */
-#endif
- /* But if we're going to want to run it again, we better remove the
- breakpoints... */
- remove_breakpoints ();
- generic_mourn_inferior ();
-}
-
-/******************************************************************** UDI_OPEN
-** Open a connection to remote TIP.
- NAME is the socket domain used for communication with the TIP,
- then a space and the socket name or TIP-host name.
- '<udi_udi_config_id>' for example.
- */
-
-/* XXX - need cleanups for udiconnect for various failures!!! */
-
-static void
-udi_open (name, from_tty)
- char *name;
- int from_tty;
-{
- unsigned int prl;
- char *p;
- int cnt;
- UDIMemoryRange KnownMemory[10];
- UDIUInt32 ChipVersions[10];
- UDIInt NumberOfRanges = 10;
- UDIInt NumberOfChips = 10;
- UDIPId PId;
- UDIUInt32 TIPId, TargetId, DFEId, DFE, TIP, DFEIPCId, TIPIPCId;
-
- target_preopen(from_tty);
-
- entry.Offset = 0;
-
- for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++)
- bkpt_table[cnt].Type = 0;
-
- if (udi_config_id)
- free (udi_config_id);
-
- if (!name)
- error("Usage: target udi config_id, where config_id appears in udi_soc file");
-
- udi_config_id = strdup (strtok (name, " \t"));
-
- if (UDIConnect (udi_config_id, &udi_session_id))
- /* FIXME: Should set udi_session_id to -1 here. */
- error("UDIConnect() failed: %s\n", dfe_errmsg);
-
- push_target (&udi_ops);
-
- /*
- ** Initialize target configuration structure (global)
- */
- if (UDIGetTargetConfig (KnownMemory, &NumberOfRanges,
- ChipVersions, &NumberOfChips))
- error ("UDIGetTargetConfig() failed");
- if (NumberOfChips > 2)
- fprintf_unfiltered(gdb_stderr,"Target has more than one processor\n");
- for (cnt=0; cnt < NumberOfRanges; cnt++)
- {
- switch(KnownMemory[cnt].Space)
- {
- default:
- fprintf_unfiltered(gdb_stderr, "UDIGetTargetConfig() unknown memory space\n");
- break;
- case UDI29KCP_S:
- break;
- case UDI29KIROMSpace:
- RMemStart = KnownMemory[cnt].Offset;
- RMemSize = KnownMemory[cnt].Size;
- break;
- case UDI29KIRAMSpace:
- IMemStart = KnownMemory[cnt].Offset;
- IMemSize = KnownMemory[cnt].Size;
- break;
- case UDI29KDRAMSpace:
- DMemStart = KnownMemory[cnt].Offset;
- DMemSize = KnownMemory[cnt].Size;
- break;
- }
- }
-
- a29k_get_processor_type ();
-
- if (UDICreateProcess (&PId))
- fprintf_unfiltered(gdb_stderr, "UDICreateProcess() failed\n");
-
- /* Print out some stuff, letting the user now what's going on */
- if (UDICapabilities (&TIPId, &TargetId, DFEId, DFE, &TIP, &DFEIPCId,
- &TIPIPCId, sbuf))
- error ("UDICapabilities() failed");
- if (from_tty)
- {
- printf_filtered ("Connected via UDI socket,\n\
- DFE-IPC version %x.%x.%x TIP-IPC version %x.%x.%x TIP version %x.%x.%x\n %s\n",
- (DFEIPCId>>8)&0xf, (DFEIPCId>>4)&0xf, DFEIPCId&0xf,
- (TIPIPCId>>8)&0xf, (TIPIPCId>>4)&0xf, TIPIPCId&0xf,
- (TargetId>>8)&0xf, (TargetId>>4)&0xf, TargetId&0xf,
- sbuf);
- }
-}
-
-/******************************************************************* UDI_CLOSE
- Close the open connection to the TIP process.
- Use this when you want to detach and do something else
- with your gdb. */
-static void
-udi_close (quitting) /*FIXME: how is quitting used */
- int quitting;
-{
- if (udi_session_id < 0)
- return;
-
- /* We should never get here if there isn't something valid in
- udi_session_id. */
-
- if (UDIDisconnect (udi_session_id, UDITerminateSession))
- {
- if (quitting)
- warning ("UDIDisconnect() failed in udi_close");
- else
- error ("UDIDisconnect() failed in udi_close");
- }
-
- /* Do not try to close udi_session_id again, later in the program. */
- udi_session_id = -1;
- inferior_pid = 0;
-
- printf_filtered (" Ending remote debugging\n");
-}
-
-/**************************************************************** UDI_ATACH */
-/* Attach to a program that is already loaded and running
- * Upon exiting the process's execution is stopped.
- */
-static void
-udi_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- UDIResource From;
- UDIInt32 PC_adds;
- UDICount Count = 1;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
- UDIError err;
-
- if (args == NULL)
- error_no_arg ("program to attach");
-
- if (udi_session_id < 0)
- error ("UDI connection not opened yet, use the 'target udi' command.\n");
-
- if (from_tty)
- printf_unfiltered ("Attaching to remote program %s...\n", prog_name);
-
- UDIStop();
- From.Space = UDI29KSpecialRegs;
- From.Offset = 11;
- if (err = UDIRead(From, &PC_adds, Count, Size, &CountDone, HostEndian))
- error ("UDIRead failed in udi_attach");
- printf_unfiltered ("Remote process is now halted, pc1 = 0x%x.\n", PC_adds);
-}
-/************************************************************* UDI_DETACH */
-/* Terminate the open connection to the TIP process.
- Use this when you want to detach and do something else
- with your gdb. Leave remote process running (with no breakpoints set). */
-static void
-udi_detach (args,from_tty)
- char *args;
- int from_tty;
-{
-
- remove_breakpoints(); /* Just in case there were any left in */
-
- if (UDIDisconnect (udi_session_id, UDIContinueSession))
- error ("UDIDisconnect() failed in udi_detach");
-
- /* Don't try to UDIDisconnect it again in udi_close, which is called from
- pop_target. */
- udi_session_id = -1;
- inferior_pid = 0;
-
- pop_target();
-
- if (from_tty)
- printf_unfiltered ("Detaching from TIP\n");
-}
-
-
-/****************************************************************** UDI_RESUME
-** Tell the remote machine to resume. */
-
-static void
-udi_resume (pid, step, sig)
- int pid, step;
- enum target_signal sig;
-{
- UDIError tip_error;
- UDIUInt32 Steps = 1;
- UDIStepType StepType = UDIStepNatural;
- UDIRange Range;
-
- if (step) /* step 1 instruction */
- {
- tip_error = UDIStep (Steps, StepType, Range);
- if (!tip_error)
- return;
-
- fprintf_unfiltered (gdb_stderr, "UDIStep() error = %d\n", tip_error);
- error ("failed in udi_resume");
- }
-
- if (UDIExecute())
- error ("UDIExecute() failed in udi_resume");
-}
-
-/******************************************************************** UDI_WAIT
-** Wait until the remote machine stops, then return,
- storing status in STATUS just as `wait' would. */
-
-static int
-udi_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- UDIInt32 MaxTime;
- UDIPId PId;
- UDIInt32 StopReason;
- UDISizeT CountDone;
- int old_timeout = timeout;
- int old_immediate_quit = immediate_quit;
- int i;
-
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
-
-/* wait for message to arrive. It should be:
- If the target stops executing, udi_wait() should return.
-*/
- timeout = 0; /* Wait indefinetly for a message */
- immediate_quit = 1; /* Helps ability to QUIT */
-
- while(1)
- {
- i = 0;
- MaxTime = UDIWaitForever;
- UDIWait(MaxTime, &PId, &StopReason);
- QUIT; /* Let user quit if they want */
-
- switch (StopReason & UDIGrossState)
- {
- case UDIStdoutReady:
- if (UDIGetStdout (sbuf, (UDISizeT)SBUF_MAX, &CountDone))
- /* This is said to happen if the program tries to output
- a whole bunch of output (more than SBUF_MAX, I would
- guess). It doesn't seem to happen with the simulator. */
- warning ("UDIGetStdout() failed in udi_wait");
- fwrite (sbuf, 1, CountDone, stdout);
- gdb_flush(gdb_stdout);
- continue;
-
- case UDIStderrReady:
- UDIGetStderr (sbuf, (UDISizeT)SBUF_MAX, &CountDone);
- fwrite (sbuf, 1, CountDone, stderr);
- gdb_flush(gdb_stderr);
- continue;
-
- case UDIStdinNeeded:
- {
- int ch;
- i = 0;
- do
- {
- ch = getchar ();
- if (ch == EOF)
- break;
- sbuf[i++] = ch;
- } while (i < SBUF_MAX && ch != '\n');
- UDIPutStdin (sbuf, (UDISizeT)i, &CountDone);
- continue;
- }
-
- case UDIRunning:
- /* In spite of the fact that we told UDIWait to wait forever, it will
- return spuriously sometimes. */
- case UDIStdinModeX:
- continue;
- default:
- break;
- }
- break;
- }
-
- switch (StopReason & UDIGrossState)
- {
- case UDITrapped:
- printf_unfiltered("Am290*0 received vector number %d\n", StopReason >> 24);
-
- switch ((StopReason >> 8 ) & 0xff)
- {
- case 0: /* Illegal opcode */
- printf_unfiltered(" (break point)\n");
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case 1: /* Unaligned Access */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_BUS;
- break;
- case 3:
- case 4:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_FPE;
- break;
- case 5: /* Protection Violation */
- status->kind = TARGET_WAITKIND_STOPPED;
- /* Why not SEGV? What is a Protection Violation? */
- status->value.sig = TARGET_SIGNAL_ILL;
- break;
- case 6:
- case 7:
- case 8: /* User Instruction Mapping Miss */
- case 9: /* User Data Mapping Miss */
- case 10: /* Supervisor Instruction Mapping Miss */
- case 11: /* Supervisor Data Mapping Miss */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_SEGV;
- break;
- case 12:
- case 13:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ILL;
- break;
- case 14: /* Timer */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_ALRM;
- break;
- case 15: /* Trace */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case 16: /* INTR0 */
- case 17: /* INTR1 */
- case 18: /* INTR2 */
- case 19: /* INTR3/Internal */
- case 20: /* TRAP0 */
- case 21: /* TRAP1 */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_INT;
- break;
- case 22: /* Floating-Point Exception */
- status->kind = TARGET_WAITKIND_STOPPED;
- /* Why not FPE? */
- status->value.sig = TARGET_SIGNAL_ILL;
- break;
- case 77: /* assert 77 */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- default:
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
- break;
- case UDINotExecuting:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TERM;
- break;
- case UDIStopped:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TSTP;
- break;
- case UDIWarned:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_URG;
- break;
- case UDIStepped:
- case UDIBreak:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case UDIWaiting:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_STOP;
- break;
- case UDIHalted:
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_KILL;
- break;
- case UDIExited:
- default:
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = 0;
- }
-
- timeout = old_timeout; /* Restore original timeout value */
- immediate_quit = old_immediate_quit;
- return inferior_pid;
-}
-
-#if 0
-/* Handy for debugging */
-udi_pc()
-{
- UDIResource From;
- UDIUInt32 *To;
- UDICount Count;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
- UDIError err;
- int pc[2];
- unsigned long myregs[256];
- int i;
-
- From.Space = UDI29KPC;
- From.Offset = 0;
- To = (UDIUInt32 *)pc;
- Count = 2;
-
- err = UDIRead(From, To, Count, Size, &CountDone, HostEndian);
-
- printf_unfiltered ("err = %d, CountDone = %d, pc[0] = 0x%x, pc[1] = 0x%x\n",
- err, CountDone, pc[0], pc[1]);
-
- udi_fetch_registers(-1);
-
- printf_unfiltered("other pc1 = 0x%x, pc0 = 0x%x\n", *(int *)&registers[4 * PC_REGNUM],
- *(int *)&registers[4 * NPC_REGNUM]);
-
- /* Now, read all the registers globally */
-
- From.Space = UDI29KGlobalRegs;
- From.Offset = 0;
- err = UDIRead(From, myregs, 256, 4, &CountDone, HostEndian);
-
- printf ("err = %d, CountDone = %d\n", err, CountDone);
-
- printf("\n");
-
- for (i = 0; i < 256; i += 2)
- printf("%d:\t%#10x\t%11d\t%#10x\t%11d\n", i, myregs[i], myregs[i],
- myregs[i+1], myregs[i+1]);
- printf("\n");
-
- return pc[0];
-}
-#endif
-
-/********************************************************** UDI_FETCH_REGISTERS
- * Read a remote register 'regno'.
- * If regno==-1 then read all the registers.
- */
-static void
-udi_fetch_registers (regno)
-int regno;
-{
- UDIResource From;
- UDIUInt32 *To;
- UDICount Count;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
- UDIError err;
- int i;
-
- if (regno >= 0) {
- fetch_register(regno);
- return;
- }
-
-/* Gr1/rsp */
-
- From.Space = UDI29KGlobalRegs;
- From.Offset = 1;
- To = (UDIUInt32 *)&registers[4 * GR1_REGNUM];
- Count = 1;
- if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIRead() failed in udi_fetch_registers");
-
- register_valid[GR1_REGNUM] = 1;
-
-#if defined(GR64_REGNUM) /* Read gr64-127 */
-
-/* Global Registers gr64-gr95 */
-
- From.Space = UDI29KGlobalRegs;
- From.Offset = 64;
- To = (UDIUInt32 *)&registers[4 * GR64_REGNUM];
- Count = 32;
- if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIRead() failed in udi_fetch_registers");
-
- for (i = GR64_REGNUM; i < GR64_REGNUM + 32; i++)
- register_valid[i] = 1;
-
-#endif /* GR64_REGNUM */
-
-/* Global Registers gr96-gr127 */
-
- From.Space = UDI29KGlobalRegs;
- From.Offset = 96;
- To = (UDIUInt32 *)&registers[4 * GR96_REGNUM];
- Count = 32;
- if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIRead() failed in udi_fetch_registers");
-
- for (i = GR96_REGNUM; i < GR96_REGNUM + 32; i++)
- register_valid[i] = 1;
-
-/* Local Registers */
-
- From.Space = UDI29KLocalRegs;
- From.Offset = 0;
- To = (UDIUInt32 *)&registers[4 * LR0_REGNUM];
- Count = 128;
- if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIRead() failed in udi_fetch_registers");
-
- for (i = LR0_REGNUM; i < LR0_REGNUM + 128; i++)
- register_valid[i] = 1;
-
-/* Protected Special Registers */
-
- From.Space = UDI29KSpecialRegs;
- From.Offset = 0;
- To = (UDIUInt32 *)&registers[4 * SR_REGNUM(0)];
- Count = 15;
- if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIRead() failed in udi_fetch_registers");
-
- for (i = SR_REGNUM(0); i < SR_REGNUM(0) + 15; i++)
- register_valid[i] = 1;
-
- 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 sr128-sr135 */
-
- From.Space = UDI29KSpecialRegs;
- From.Offset = 128;
- To = (UDIUInt32 *)&registers[4 * SR_REGNUM(128)];
- Count = 135-128 + 1;
- if (err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIRead() failed in udi_fetch_registers");
-
- for (i = SR_REGNUM(128); i < SR_REGNUM(128) + 135-128+1; i++)
- register_valid[i] = 1;
- }
-
- if (remote_debug)
- {
- printf_unfiltered("Fetching all registers\n");
- printf_unfiltered("Fetching PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n",
- read_register(NPC_REGNUM), read_register(PC_REGNUM),
- read_register(PC2_REGNUM));
- }
-
- /* There doesn't seem to be any way to get these. */
- {
- int val = -1;
- supply_register (FPE_REGNUM, (char *) &val);
- supply_register (INTE_REGNUM, (char *) &val);
- supply_register (FPS_REGNUM, (char *) &val);
- supply_register (EXO_REGNUM, (char *) &val);
- }
-}
-
-
-/********************************************************* UDI_STORE_REGISTERS
-** Store register regno into the target.
- * If regno==-1 then store all the registers.
- */
-
-static void
-udi_store_registers (regno)
-int regno;
-{
- UDIUInt32 *From;
- UDIResource To;
- UDICount Count;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
-
- if (regno >= 0)
- {
- store_register(regno);
- return;
- }
-
- if (remote_debug)
- {
- printf_unfiltered("Storing all registers\n");
- printf_unfiltered("PC0 = 0x%x, PC1 = 0x%x, PC2 = 0x%x\n", read_register(NPC_REGNUM),
- read_register(PC_REGNUM), read_register(PC2_REGNUM));
- }
-
-/* Gr1/rsp */
-
- From = (UDIUInt32 *)&registers[4 * GR1_REGNUM];
- To.Space = UDI29KGlobalRegs;
- To.Offset = 1;
- Count = 1;
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIWrite() failed in udi_store_regisetrs");
-
-#if defined(GR64_REGNUM)
-
-/* Global registers gr64-gr95 */
-
- From = (UDIUInt32 *)&registers[4 * GR64_REGNUM];
- To.Space = UDI29KGlobalRegs;
- To.Offset = 64;
- Count = 32;
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIWrite() failed in udi_store_regisetrs");
-
-#endif /* GR64_REGNUM */
-
-/* Global registers gr96-gr127 */
-
- From = (UDIUInt32 *)&registers[4 * GR96_REGNUM];
- To.Space = UDI29KGlobalRegs;
- To.Offset = 96;
- Count = 32;
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIWrite() failed in udi_store_regisetrs");
-
-/* Local Registers */
-
- From = (UDIUInt32 *)&registers[4 * LR0_REGNUM];
- To.Space = UDI29KLocalRegs;
- To.Offset = 0;
- Count = 128;
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIWrite() failed in udi_store_regisetrs");
-
-
-/* Protected Special Registers */ /* VAB through TMR */
-
- From = (UDIUInt32 *)&registers[4 * SR_REGNUM(0)];
- To.Space = UDI29KSpecialRegs;
- To.Offset = 0;
- Count = 10;
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIWrite() failed in udi_store_regisetrs");
-
-/* PC0, PC1, PC2 possibly as shadow registers */
-
- From = (UDIUInt32 *)&registers[4 * SR_REGNUM(10)];
- To.Space = UDI29KSpecialRegs;
- Count = 3;
- if (USE_SHADOW_PC)
- To.Offset = 20; /* SPC0 */
- else
- To.Offset = 10; /* PC0 */
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIWrite() failed in udi_store_regisetrs");
-
-/* PC1 via UDI29KPC */
-
- From = (UDIUInt32 *)&registers[4 * PC_REGNUM];
- To.Space = UDI29KPC;
- To.Offset = 0; /* PC1 */
- Count = 1;
- if (UDIWrite (From, To, Count, Size, &CountDone, HostEndian))
- error ("UDIWrite() failed in udi_store_regisetrs");
-
- /* LRU and MMU */
-
- From = (UDIUInt32 *)&registers[4 * SR_REGNUM(13)];
- To.Space = UDI29KSpecialRegs;
- To.Offset = 13;
- Count = 2;
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIWrite() failed in udi_store_regisetrs");
-
-/* Unprotected Special Registers */
-
- From = (UDIUInt32 *)&registers[4 * SR_REGNUM(128)];
- To.Space = UDI29KSpecialRegs;
- To.Offset = 128;
- Count = 135-128 +1;
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- error("UDIWrite() failed in udi_store_regisetrs");
-
- registers_changed ();
-}
-
-/****************************************************** UDI_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
-udi_prepare_to_store ()
-{
- /* Do nothing, since we can store individual regs */
-}
-
-/********************************************************** TRANSLATE_ADDR */
-static CORE_ADDR
-translate_addr(addr)
-CORE_ADDR addr;
-{
-#if defined(ULTRA3) && 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
-}
-/************************************************* UDI_XFER_INFERIOR_MEMORY */
-/* FIXME! Merge these two. */
-static int
-udi_xfer_inferior_memory (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
-{
-
- memaddr = translate_addr(memaddr);
-
- if (write)
- return udi_write_inferior_memory (memaddr, myaddr, len);
- else
- return udi_read_inferior_memory (memaddr, myaddr, len);
-}
-
-/********************************************************** UDI_FILES_INFO */
-static void
-udi_files_info ()
-{
- printf_unfiltered ("\tAttached to UDI socket to %s", udi_config_id);
- if (prog_name != NULL)
- printf_unfiltered ("and running program %s", prog_name);
- printf_unfiltered (".\n");
-}
-
-/**************************************************** UDI_INSERT_BREAKPOINT */
-static int
-udi_insert_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- int cnt;
- UDIError err;
-
- for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++)
- if (bkpt_table[cnt].Type == 0) /* Find first free slot */
- break;
-
- if(cnt >= BKPT_TABLE_SIZE)
- error("Too many breakpoints set");
-
- bkpt_table[cnt].Addr.Offset = addr;
- bkpt_table[cnt].Addr.Space = UDI29KIRAMSpace;
- bkpt_table[cnt].PassCount = 1;
- bkpt_table[cnt].Type = UDIBreakFlagExecute;
-
- err = UDISetBreakpoint(bkpt_table[cnt].Addr,
- bkpt_table[cnt].PassCount,
- bkpt_table[cnt].Type,
- &bkpt_table[cnt].BreakId);
-
- if (err == 0) return 0; /* Success */
-
- bkpt_table[cnt].Type = 0;
- error("UDISetBreakpoint returned error code %d\n", err);
-}
-
-/**************************************************** UDI_REMOVE_BREAKPOINT */
-static int
-udi_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
-{
- int cnt;
- UDIError err;
-
- for (cnt = 0; cnt < BKPT_TABLE_SIZE; cnt++)
- if (bkpt_table[cnt].Addr.Offset == addr) /* Find matching breakpoint */
- break;
-
- if(cnt >= BKPT_TABLE_SIZE)
- error("Can't find breakpoint in table");
-
- bkpt_table[cnt].Type = 0;
-
- err = UDIClearBreakpoint(bkpt_table[cnt].BreakId);
- if (err == 0) return 0; /* Success */
-
- error("UDIClearBreakpoint returned error code %d\n", err);
-}
-
-static void
-udi_kill(arg,from_tty)
- char *arg;
- int from_tty;
-{
-
-#if 0
-/*
-UDIStop does not really work as advertised. It causes the TIP to close it's
-connection, which usually results in GDB dying with a SIGPIPE. For now, we
-just invoke udi_close, which seems to get things right.
-*/
- UDIStop();
-
- udi_session_id = -1;
- inferior_pid = 0;
-
- if (from_tty)
- printf_unfiltered("Target has been stopped.");
-#endif /* 0 */
-#if 0
- udi_close(0);
- pop_target();
-#endif /* 0 */
-
- /* Keep the target around, e.g. so "run" can do the right thing when
- we are already debugging something. */
-
- if (UDIDisconnect (udi_session_id, UDITerminateSession))
- {
- warning ("UDIDisconnect() failed");
- }
-
- /* Do not try to close udi_session_id again, later in the program. */
- udi_session_id = -1;
- inferior_pid = 0;
-}
-
-/*
- Load a program into the target. Args are: `program {options}'. The options
- are used to control loading of the program, and are NOT passed onto the
- loaded code as arguments. (You need to use the `run' command to do that.)
-
- The options are:
- -ms %d Set mem stack size to %d
- -rs %d Set regular stack size to %d
- -i send init info (default)
- -noi don't send init info
- -[tT] Load Text section
- -[dD] Load Data section
- -[bB] Load BSS section
- -[lL] Load Lit section
- */
-
-static void
-download(load_arg_string, from_tty)
- char *load_arg_string;
- int from_tty;
-{
-#define DEFAULT_MEM_STACK_SIZE 0x6000
-#define DEFAULT_REG_STACK_SIZE 0x2000
-
- char *token;
- char *filename;
- asection *section;
- bfd *pbfd;
- UDIError err;
- int load_text = 1, load_data = 1, load_bss = 1, load_lit = 1;
-
- address_ranges[0].Space = UDI29KIRAMSpace;
- address_ranges[0].Offset = 0xffffffff;
- address_ranges[0].Size = 0;
-
- address_ranges[1].Space = UDI29KDRAMSpace;
- address_ranges[1].Offset = 0xffffffff;
- address_ranges[1].Size = 0;
-
- stack_sizes[0] = DEFAULT_REG_STACK_SIZE;
- stack_sizes[1] = DEFAULT_MEM_STACK_SIZE;
-
- dont_repeat ();
-
- filename = strtok(load_arg_string, " \t");
- if (!filename)
- error ("Must specify at least a file name with the load command");
-
- filename = tilde_expand (filename);
- make_cleanup ((make_cleanup_func) free, filename);
-
- while (token = strtok (NULL, " \t"))
- {
- if (token[0] == '-')
- {
- token++;
-
- if (STREQ (token, "ms"))
- stack_sizes[1] = atol (strtok (NULL, " \t"));
- else if (STREQ (token, "rs"))
- stack_sizes[0] = atol (strtok (NULL, " \t"));
- else
- {
- load_text = load_data = load_bss = load_lit = 0;
-
- while (*token)
- {
- switch (*token++)
- {
- case 't':
- case 'T':
- load_text = 1;
- break;
- case 'd':
- case 'D':
- load_data = 1;
- break;
- case 'b':
- case 'B':
- load_bss = 1;
- break;
- case 'l':
- case 'L':
- load_lit = 1;
- break;
- default:
- error ("Unknown UDI load option -%s", token-1);
- }
- }
- }
- }
- }
-
- pbfd = bfd_openr (filename, gnutarget);
-
- if (!pbfd)
- /* FIXME: should be using bfd_errmsg, not assuming it was
- bfd_error_system_call. */
- perror_with_name (filename);
-
- /* FIXME: should be checking for errors from bfd_close (for one thing,
- on error it does not free all the storage associated with the
- bfd). */
- make_cleanup ((make_cleanup_func) bfd_close, pbfd);
-
- QUIT;
- immediate_quit++;
-
- if (!bfd_check_format (pbfd, bfd_object))
- error ("It doesn't seem to be an object file");
-
- for (section = pbfd->sections; section; section = section->next)
- {
- if (bfd_get_section_flags (pbfd, section) & SEC_ALLOC)
- {
- UDIResource To;
- UDICount Count;
- unsigned long section_size, section_end;
- const char *section_name;
-
- section_name = bfd_get_section_name (pbfd, section);
- if (STREQ (section_name, ".text") && !load_text)
- continue;
- else if (STREQ (section_name, ".data") && !load_data)
- continue;
- else if (STREQ (section_name, ".bss") && !load_bss)
- continue;
- else if (STREQ (section_name, ".lit") && !load_lit)
- continue;
-
- To.Offset = bfd_get_section_vma (pbfd, section);
- section_size = bfd_section_size (pbfd, section);
- section_end = To.Offset + section_size;
-
- if (section_size == 0)
- /* This is needed at least in the BSS case, where the code
- below starts writing before it even checks the size. */
- continue;
-
- printf_unfiltered("[Loading section %s at %x (%d bytes)]\n",
- section_name,
- To.Offset,
- section_size);
-
- if (bfd_get_section_flags (pbfd, section) & SEC_CODE)
- {
- To.Space = UDI29KIRAMSpace;
-
- address_ranges[0].Offset = min (address_ranges[0].Offset,
- To.Offset);
- address_ranges[0].Size = max (address_ranges[0].Size,
- section_end
- - address_ranges[0].Offset);
- }
- else
- {
- To.Space = UDI29KDRAMSpace;
-
- address_ranges[1].Offset = min (address_ranges[1].Offset,
- To.Offset);
- address_ranges[1].Size = max (address_ranges[1].Size,
- section_end
- - address_ranges[1].Offset);
- }
-
- if (bfd_get_section_flags (pbfd, section) & SEC_LOAD) /* Text, data or lit */
- {
- file_ptr fptr;
-
- fptr = 0;
-
- while (section_size > 0)
- {
- char buffer[1024];
-
- Count = min (section_size, 1024);
-
- bfd_get_section_contents (pbfd, section, buffer, fptr,
- Count);
-
- err = UDIWrite ((UDIHostMemPtr)buffer, /* From */
- To, /* To */
- Count, /* Count */
- (UDISizeT)1, /* Size */
- &Count, /* CountDone */
- (UDIBool)0); /* HostEndian */
- if (err)
- error ("UDIWrite failed, error = %d", err);
-
- To.Offset += Count;
- fptr += Count;
- section_size -= Count;
- }
- }
- else /* BSS */
- {
- UDIResource From;
- unsigned long zero = 0;
-
- /* Write a zero byte at the vma */
- /* FIXME: Broken for sections of 1-3 bytes (we test for
- zero above). */
- err = UDIWrite ((UDIHostMemPtr)&zero, /* From */
- To, /* To */
- (UDICount)1, /* Count */
- (UDISizeT)4, /* Size */
- &Count, /* CountDone */
- (UDIBool)0); /* HostEndian */
- if (err)
- error ("UDIWrite failed, error = %d", err);
-
- From = To;
- To.Offset+=4;
-
- /* Now, duplicate it for the length of the BSS */
- err = UDICopy (From, /* From */
- To, /* To */
- (UDICount)(section_size/4 - 1), /* Count */
- (UDISizeT)4, /* Size */
- &Count, /* CountDone */
- (UDIBool)1); /* Direction */
- if (err)
- {
- char message[100];
- int xerr;
-
- xerr = UDIGetErrorMsg(err, 100, message, &Count);
- if (!xerr)
- fprintf_unfiltered (gdb_stderr, "Error is %s\n", message);
- else
- fprintf_unfiltered (gdb_stderr, "xerr is %d\n", xerr);
- error ("UDICopy failed, error = %d", err);
- }
- }
-
- }
- }
-
- entry.Space = UDI29KIRAMSpace;
- entry.Offset = bfd_get_start_address (pbfd);
-
- immediate_quit--;
-}
-
-/* Function to download an image into the remote target. */
-
-static void
-udi_load (args, from_tty)
- char *args;
- int from_tty;
-{
- download (args, from_tty);
-
- /* As a convenience, pick up any symbol info that is in the program
- being loaded. Note that we assume that the program is the``mainline'';
- if this is not always true, then this code will need to be augmented. */
- symbol_file_add (strtok (args, " \t"), from_tty, 0, 1, 0, 0, 0, 0);
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- reinit_frame_cache ();
-}
-
-/*************************************************** UDI_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
-udi_write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- int nwritten = 0;
- UDIUInt32 *From;
- UDIResource To;
- UDICount Count;
- UDISizeT Size = 1;
- UDICount CountDone = 0;
- UDIBool HostEndian = 0;
-
- To.Space = udi_memory_space(memaddr);
- From = (UDIUInt32*)myaddr;
-
- while (nwritten < len)
- { Count = len - nwritten;
- if (Count > MAXDATA) Count = MAXDATA;
- To.Offset = memaddr + nwritten;
- if(UDIWrite(From, To, Count, Size, &CountDone, HostEndian))
- { error("UDIWrite() failed in udi_write_inferior_memory");
- break;
- }
- else
- { nwritten += CountDone;
- From += CountDone;
- }
- }
- return(nwritten);
-}
-
-/**************************************************** UDI_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
-udi_read_inferior_memory(memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- int nread = 0;
- UDIResource From;
- UDIUInt32 *To;
- UDICount Count;
- UDISizeT Size = 1;
- UDICount CountDone = 0;
- UDIBool HostEndian = 0;
- UDIError err;
-
- From.Space = udi_memory_space(memaddr);
- To = (UDIUInt32*)myaddr;
-
- while (nread < len)
- { Count = len - nread;
- if (Count > MAXDATA) Count = MAXDATA;
- From.Offset = memaddr + nread;
- if(err = UDIRead(From, To, Count, Size, &CountDone, HostEndian))
- { error("UDIRead() failed in udi_read_inferior_memory");
- break;
- }
- else
- { nread += CountDone;
- To += CountDone;
- }
- }
- return(nread);
-}
-
-/********************************************************************* WARNING
-*/
-udi_warning(num)
-int num;
-{
- error ("ERROR while loading program into remote TIP: $d\n", num);
-}
-
-
-/*****************************************************************************/
-/* Fetch a single register indicatated by 'regno'.
- * Returns 0/-1 on success/failure.
- */
-static void
-fetch_register (regno)
- int regno;
-{
- UDIResource From;
- UDIUInt32 To;
- UDICount Count = 1;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
- UDIError err;
- int result;
-
- if (regno == GR1_REGNUM)
- {
- From.Space = UDI29KGlobalRegs;
- From.Offset = 1;
- }
- else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
- {
- From.Space = UDI29KGlobalRegs;
- From.Offset = (regno - GR96_REGNUM) + 96;;
- }
-
-#if defined(GR64_REGNUM)
-
- else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32 )
- {
- From.Space = UDI29KGlobalRegs;
- From.Offset = (regno - GR64_REGNUM) + 64;
- }
-
-#endif /* GR64_REGNUM */
-
- else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
- {
- From.Space = UDI29KLocalRegs;
- From.Offset = (regno - LR0_REGNUM);
- }
- else if (regno>=FPE_REGNUM && regno<=EXO_REGNUM)
- {
- int val = -1;
- /*supply_register(160 + (regno - FPE_REGNUM),(char *) &val);*/
- supply_register(regno, (char *) &val);
- return; /* Pretend Success */
- }
- else
- {
- From.Space = UDI29KSpecialRegs;
- From.Offset = regnum_to_srnum(regno);
- }
-
- if (err = UDIRead(From, &To, Count, Size, &CountDone, HostEndian))
- error("UDIRead() failed in udi_fetch_registers");
-
- supply_register(regno, (char *) &To);
-
- if (remote_debug)
- printf_unfiltered("Fetching register %s = 0x%x\n", REGISTER_NAME (regno), To);
-}
-/*****************************************************************************/
-/* Store a single register indicated by 'regno'.
- * Returns 0/-1 on success/failure.
- */
-static int
-store_register (regno)
- int regno;
-{
- int result;
- UDIUInt32 From;
- UDIResource To;
- UDICount Count = 1;
- UDISizeT Size = 4;
- UDICount CountDone;
- UDIBool HostEndian = 0;
-
- From = read_register (regno); /* get data value */
-
- if (remote_debug)
- printf_unfiltered("Storing register %s = 0x%x\n", REGISTER_NAME (regno), From);
-
- if (regno == GR1_REGNUM)
- {
- To.Space = UDI29KGlobalRegs;
- To.Offset = 1;
- result = UDIWrite(&From, To, Count, Size, &CountDone, HostEndian);
- /* 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 )
- {
- To.Space = UDI29KGlobalRegs;
- To.Offset = (regno - GR64_REGNUM) + 64;
- result = UDIWrite(&From, To, Count, Size, &CountDone, HostEndian);
- }
-#endif /* GR64_REGNUM */
- else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32)
- {
- To.Space = UDI29KGlobalRegs;
- To.Offset = (regno - GR96_REGNUM) + 96;
- result = UDIWrite(&From, To, Count, Size, &CountDone, HostEndian);
- }
- else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128)
- {
- To.Space = UDI29KLocalRegs;
- To.Offset = (regno - LR0_REGNUM);
- result = UDIWrite(&From, To, Count, Size, &CountDone, HostEndian);
- }
- else if (regno >= FPE_REGNUM && regno <= EXO_REGNUM)
- return 0; /* Pretend Success */
- else if (regno == PC_REGNUM)
- {
- /* PC1 via UDI29KPC */
-
- To.Space = UDI29KPC;
- To.Offset = 0; /* PC1 */
- result = UDIWrite (&From, To, Count, Size, &CountDone, HostEndian);
-
- /* Writing to this loc actually changes the values of pc0 & pc1 */
-
- register_valid[PC_REGNUM] = 0; /* pc1 */
- register_valid[NPC_REGNUM] = 0; /* pc0 */
- }
- else /* An unprotected or protected special register */
- {
- To.Space = UDI29KSpecialRegs;
- To.Offset = regnum_to_srnum(regno);
- result = UDIWrite(&From, To, Count, Size, &CountDone, HostEndian);
- }
-
- if (result != 0)
- error("UDIWrite() failed in store_registers");
-
- return 0;
-}
-/********************************************************** REGNUM_TO_SRNUM */
-/*
- * 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 INTE_REGNUM: return(161);
- case FPS_REGNUM: return(162);
- case EXO_REGNUM:return(164);
- default:
- return(255); /* Failure ? */
- }
-}
-/****************************************************************************/
-/*
- * Determine the Target 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 CPUSpace
-udi_memory_space(addr)
-CORE_ADDR addr;
-{
- UDIUInt32 tstart = IMemStart;
- UDIUInt32 tend = tstart + IMemSize;
- UDIUInt32 dstart = DMemStart;
- UDIUInt32 dend = tstart + DMemSize;
- UDIUInt32 rstart = RMemStart;
- UDIUInt32 rend = tstart + RMemSize;
-
- if (((UDIUInt32)addr >= tstart) && ((UDIUInt32)addr < tend)) {
- return UDI29KIRAMSpace;
- } else if (((UDIUInt32)addr >= dstart) && ((UDIUInt32)addr < dend)) {
- return UDI29KDRAMSpace;
- } else if (((UDIUInt32)addr >= rstart) && ((UDIUInt32)addr < rend)) {
- /* FIXME: how do we determine between D_ROM and I_ROM */
- return UDI29KIROMSpace;
- } else /* FIXME: what do me do now? */
- return UDI29KDRAMSpace; /* Hmmm! */
-}
-/*********************************************************************** STUBS
-*/
-
-void convert16() {;}
-void convert32() {;}
-GDB_FILE * EchoFile = 0; /* used for debugging */
-int QuietMode = 0; /* used for debugging */
-
-#ifdef NO_HIF_SUPPORT
-service_HIF(msg)
- union msg_t *msg;
-{
- return(0); /* Emulate a failure */
-}
-#endif
-
-/* Target_ops vector. Not static because there does not seem to be
- any portable way to do a forward declaration of a static variable.
- The RS/6000 doesn't like "extern" followed by "static"; SunOS
- /bin/cc doesn't like "static" twice. */
-
-struct target_ops udi_ops;
-
-static void
-init_udi_ops(void)
-{
- udi_ops.to_shortname = "udi";
- udi_ops.to_longname = "Remote UDI connected TIP";
- udi_ops.to_doc = "Remote debug an AMD 29k using UDI socket connection to TIP process.\n\
-Arguments are\n\
-`configuration-id AF_INET hostname port-number'\n\
-To connect via the network, where hostname and port-number specify the\n\
-host and port where you can connect via UDI.\n\
-configuration-id is unused.\n\
-\n\
-`configuration-id AF_UNIX socket-name tip-program'\n\
-To connect using a local connection to the \"tip.exe\" program which is\n\
- supplied by AMD. If socket-name specifies an AF_UNIX socket then the\n\
- tip program must already be started; connect to it using that socket.\n\
- If not, start up tip-program, which should be the name of the tip\n\
- program. If appropriate, the PATH environment variable is searched.\n\
- configuration-id is unused.\n\
-\n\
-`configuration-id'\n\
- Look up the configuration in ./udi_soc or /etc/udi_soc, which\n\
- are files containing lines in the above formats. configuration-id is\n\
- used to pick which line of the file to use." ;
- udi_ops.to_open = udi_open;
- udi_ops.to_close = udi_close;
- udi_ops.to_attach = udi_attach;
- udi_ops.to_detach = udi_detach;
- udi_ops.to_resume = udi_resume;
- udi_ops.to_wait = udi_wait;
- udi_ops.to_fetch_registers = udi_fetch_registers;
- udi_ops.to_store_registers = udi_store_registers;
- udi_ops.to_prepare_to_store = udi_prepare_to_store;
- udi_ops.to_xfer_memory = udi_xfer_inferior_memory;
- udi_ops.to_files_info = udi_files_info;
- udi_ops.to_insert_breakpoint = udi_insert_breakpoint;
- udi_ops.to_remove_breakpoint = udi_remove_breakpoint;
- udi_ops.to_terminal_init = 0;
- udi_ops.to_terminal_inferior = 0;
- udi_ops.to_terminal_ours_for_output = 0;
- udi_ops.to_terminal_ours = 0;
- udi_ops.to_terminal_info = 0;
- udi_ops.to_kill = udi_kill;
- udi_ops.to_load = udi_load;
- udi_ops.to_lookup_symbol = 0;
- udi_ops.to_create_inferior = udi_create_inferior;
- udi_ops.to_mourn_inferior = udi_mourn;
- udi_ops.to_can_run = 0;
- udi_ops.to_notice_signals = 0;
- udi_ops.to_thread_alive = 0;
- udi_ops.to_stop = 0;
- udi_ops.to_stratum = process_stratum;
- udi_ops.DONT_USE = 0;
- udi_ops.to_has_all_memory = 1;
- udi_ops.to_has_memory = 1;
- udi_ops.to_has_stack = 1;
- udi_ops.to_has_registers = 1;
- udi_ops.to_has_execution = 1;
- udi_ops.to_sections = 0;
- udi_ops.to_sections_end = 0;
- udi_ops.to_magic = OPS_MAGIC;
-};
-
-void
-_initialize_remote_udi ()
-{
- init_udi_ops() ;
- add_target (&udi_ops);
-}
diff --git a/contrib/gdb/gdb/remote-vx.c b/contrib/gdb/gdb/remote-vx.c
deleted file mode 100644
index 9ad86d4..0000000
--- a/contrib/gdb/gdb/remote-vx.c
+++ /dev/null
@@ -1,1467 +0,0 @@
-/* Memory-access and commands for remote VxWorks processes, for GDB.
- Copyright (C) 1990-95, 1997-98, 1999 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "wait.h"
-#include "target.h"
-#include "gdbcore.h"
-#include "command.h"
-#include "symtab.h"
-#include "complaints.h"
-#include "gdbcmd.h"
-#include "bfd.h" /* Required by objfiles.h. */
-#include "symfile.h" /* Required by objfiles.h. */
-#include "objfiles.h"
-#include "gdb-stabs.h"
-
-#include "gdb_string.h"
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#define malloc bogon_malloc /* Sun claims "char *malloc()" not void * */
-#define free bogon_free /* Sun claims "int free()" not void */
-#define realloc bogon_realloc /* Sun claims "char *realloc()", not void * */
-#include <rpc/rpc.h>
-#undef malloc
-#undef free
-#undef realloc
-#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
-#include <netdb.h>
-#include "vx-share/ptrace.h"
-#include "vx-share/xdr_ptrace.h"
-#include "vx-share/xdr_ld.h"
-#include "vx-share/xdr_rdb.h"
-#include "vx-share/dbgRpcLib.h"
-
-#include <symtab.h>
-
-/* Maximum number of bytes to transfer in a single
- PTRACE_{READ,WRITE}DATA request. */
-#define VX_MEMXFER_MAX 4096
-
-extern void vx_read_register ();
-extern void vx_write_register ();
-extern void symbol_file_command ();
-extern int stop_soon_quietly; /* for wait_for_inferior */
-
-static int net_step ();
-static int net_ptrace_clnt_call (); /* Forward decl */
-static enum clnt_stat net_clnt_call (); /* Forward decl */
-
-/* Target ops structure for accessing memory and such over the net */
-
-static struct target_ops vx_ops;
-
-/* Target ops structure for accessing VxWorks child processes over the net */
-
-static struct target_ops vx_run_ops;
-
-/* 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. */
-
-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;
-
- memset ((char *) &ldstruct, '\0', 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 == 0) /* 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? */
-
- memset ((char *) &ptrace_in, '\0', 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 */
-
-static int
-vx_insert_breakpoint (addr)
- int addr;
-{
- return net_break (addr, VX_BREAK_ADD);
-}
-
-/* returns 0 if successful, errno otherwise */
-
-static 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. */
-
-static 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;
-
- memset ((char *) &passArgs, '\0', sizeof (passArgs));
- memset ((char *) &taskStart, '\0', 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]));
-
- push_target (&vx_run_ops);
- inferior_pid = taskStart.pid;
-
- /* 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 ();
-
- 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, TARGET_SIGNAL_DEFAULT, 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;
-
- memset ((char *) arg_struct, '\0', 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. */
-
-static int
-net_wait (pEvent)
- RDB_EVENT *pEvent;
-{
- int pid;
- enum clnt_stat status;
-
- memset ((char *) pEvent, '\0', 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; */
- if (status == RPC_SUCCESS)
- return ((pEvent->status) ? 1 : 0);
- else if (status == RPC_TIMEDOUT)
- return (1);
- else
- return (-1);
-}
-
-/* Suspend the remote task.
- Returns -1 if suspend fails on target system, 0 otherwise. */
-
-static 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. */
-
-void
-net_read_registers (reg_buf, len, procnum)
- char *reg_buf;
- int len;
- u_long procnum;
-{
- int status;
- Rptrace ptrace_in;
- Ptrace_return ptrace_out;
- C_bytes out_data;
- char message[100];
-
- memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
- memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
-
- /* Initialize RPC input argument structure. */
-
- ptrace_in.pid = inferior_pid;
- ptrace_in.info.ttype = NOINFO;
-
- /* Initialize RPC return value structure. */
-
- out_data.bytes = reg_buf;
- out_data.len = len;
- ptrace_out.info.more_data = (caddr_t) &out_data;
-
- /* Call RPC; take an error exit if appropriate. */
-
- status = net_ptrace_clnt_call (procnum, &ptrace_in, &ptrace_out);
- if (status)
- error (rpcerr);
- if (ptrace_out.status == -1)
- {
- errno = ptrace_out.errno_num;
- sprintf (message, "reading %s registers", (procnum == PTRACE_GETREGS)
- ? "general-purpose"
- : "floating-point");
- perror_with_name (message);
- }
-}
-
-/* Write register values to a VxWorks target. REG_BUF points to a buffer
- containing the raw register values, LEN is the length of REG_BUF in
- bytes, and PROCNUM is the RPC procedure number (PTRACE_SETREGS or
- PTRACE_SETFPREGS). An error exit is taken if the RPC call fails or
- if an error status is returned by the remote debug server. This is
- a utility routine used by vx_write_register (). */
-
-void
-net_write_registers (reg_buf, len, procnum)
- char *reg_buf;
- int len;
- u_long procnum;
-{
- int status;
- Rptrace ptrace_in;
- Ptrace_return ptrace_out;
- C_bytes in_data;
- char message[100];
-
- memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
- memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
-
- /* Initialize RPC input argument structure. */
-
- in_data.bytes = reg_buf;
- in_data.len = len;
-
- ptrace_in.pid = inferior_pid;
- ptrace_in.info.ttype = DATA;
- ptrace_in.info.more_data = (caddr_t) &in_data;
-
- /* Call RPC; take an error exit if appropriate. */
-
- status = net_ptrace_clnt_call (procnum, &ptrace_in, &ptrace_out);
- if (status)
- error (rpcerr);
- if (ptrace_out.status == -1)
- {
- errno = ptrace_out.errno_num;
- sprintf (message, "writing %s registers", (procnum == PTRACE_SETREGS)
- ? "general-purpose"
- : "floating-point");
- perror_with_name (message);
- }
-}
-
-/* Prepare to store registers. Since we will store all of them,
- read out their current values now. */
-
-static void
-vx_prepare_to_store ()
-{
- /* Fetch all registers, if any of them are not yet fetched. */
- read_register_bytes (0, NULL, REGISTER_BYTES);
-}
-
-/* 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. */
-
-static 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;
- enum ptracereq request;
- int nleft, nxfer;
-
- memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
- memset ((char *) &ptrace_out, '\0', 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) */
- request = PTRACE_WRITEDATA;
- }
- else
- {
- ptrace_out.info.more_data = (caddr_t) &data;
- request = PTRACE_READDATA;
- }
- /* Loop until the entire request has been satisfied, transferring
- at most VX_MEMXFER_MAX bytes per iteration. Break from the loop
- if an error status is returned by the remote debug server. */
-
- nleft = len;
- status = 0;
-
- while (nleft > 0 && status == 0)
- {
- nxfer = min (nleft, VX_MEMXFER_MAX);
-
- ptrace_in.addr = (int) memaddr;
- ptrace_in.data = nxfer;
- data.bytes = (caddr_t) myaddr;
- data.len = nxfer;
-
- /* Request a block from the remote debug server; if RPC fails,
- report an error and return to debugger command level. */
-
- if (net_ptrace_clnt_call (request, &ptrace_in, &ptrace_out))
- error (rpcerr);
-
- status = ptrace_out.status;
- if (status == 0)
- {
- memaddr += nxfer;
- myaddr += nxfer;
- nleft -= nxfer;
- }
- else
- {
- /* A target-side error has ocurred. Set errno to the error
- code chosen by the target so that a later perror () will
- say something meaningful. */
-
- errno = ptrace_out.errno_num;
- }
- }
-
- /* Return the number of bytes transferred. */
-
- return (len - nleft);
-}
-
-static void
-vx_files_info ()
-{
- printf_unfiltered ("\tAttached to host `%s'", vx_host);
- printf_unfiltered (", which has %sfloating point", target_has_fp? "": "no ");
- printf_unfiltered (".\n");
-}
-
-static void
-vx_run_files_info ()
-{
- printf_unfiltered ("\tRunning %s VxWorks process %s",
- vx_running ? "child" : "attached",
- local_hex_string (inferior_pid));
- if (vx_running)
- printf_unfiltered (", function `%s'", vx_running);
- printf_unfiltered(".\n");
-}
-
-static void
-vx_resume (pid, step, siggnal)
- int pid;
- int step;
- enum target_signal siggnal;
-{
- int status;
- Rptrace ptrace_in;
- Ptrace_return ptrace_out;
- CORE_ADDR cont_addr;
-
- if (pid == -1)
- pid = inferior_pid;
-
- if (siggnal != 0 && siggnal != stop_signal)
- error ("Cannot send signals to VxWorks processes");
-
- /* Set CONT_ADDR to the address at which we are continuing,
- or to 1 if we are continuing from where the program stopped.
- This conforms to traditional ptrace () usage, but at the same
- time has special meaning for the VxWorks remote debug server.
- If the address is not 1, the server knows that the target
- program is jumping to a new address, which requires special
- handling if there is a breakpoint at the new address. */
-
- cont_addr = read_register (PC_REGNUM);
- if (cont_addr == stop_pc)
- cont_addr = 1;
-
- memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in));
- memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out));
-
- ptrace_in.pid = pid;
- ptrace_in.addr = cont_addr; /* Target side insists on this, or it panics. */
-
- if (step)
- status = net_step();
- else
- status = net_ptrace_clnt_call (PTRACE_CONT, &ptrace_in, &ptrace_out);
-
- if (status)
- error (rpcerr);
- if (ptrace_out.status == -1)
- {
- errno = ptrace_out.errno_num;
- perror_with_name ("Resuming remote process");
- }
-}
-
-static void
-vx_mourn_inferior ()
-{
- pop_target (); /* Pop back to no-child state */
- generic_mourn_inferior ();
-}
-
-
-static void vx_add_symbols PARAMS ((char *, int, CORE_ADDR, CORE_ADDR,
- CORE_ADDR));
-
-struct find_sect_args {
- CORE_ADDR text_start;
- CORE_ADDR data_start;
- CORE_ADDR bss_start;
-};
-
-static void find_sect PARAMS ((bfd *, asection *, void *));
-
-static void
-find_sect (abfd, sect, obj)
- bfd *abfd;
- asection *sect;
- PTR obj;
-{
- struct find_sect_args *args = (struct find_sect_args *)obj;
-
- if (bfd_get_section_flags (abfd, sect) & (SEC_CODE & SEC_READONLY))
- args->text_start = bfd_get_section_vma (abfd, sect);
- else if (bfd_get_section_flags (abfd, sect) & SEC_ALLOC)
- {
- if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
- {
- /* Exclude .ctor and .dtor sections which have SEC_CODE set but not
- SEC_DATA. */
- if (bfd_get_section_flags (abfd, sect) & SEC_DATA)
- args->data_start = bfd_get_section_vma (abfd, sect);
- }
- else
- args->bss_start = bfd_get_section_vma (abfd, sect);
- }
-}
-
-static void
-vx_add_symbols (name, from_tty, text_addr, data_addr, bss_addr)
- char *name;
- int from_tty;
- CORE_ADDR text_addr;
- CORE_ADDR data_addr;
- CORE_ADDR bss_addr;
-{
- struct section_offsets *offs;
- struct objfile *objfile;
- struct find_sect_args ss;
-
- /* It might be nice to suppress the breakpoint_re_set which happens here
- because we are going to do one again after the objfile_relocate. */
- objfile = symbol_file_add (name, from_tty, 0, 0, 0, 0, 0, 0);
-
- /* This is a (slightly cheesy) way of superceding the old symbols. A less
- cheesy way would be to find the objfile with the same name and
- free_objfile it. */
- objfile_to_front (objfile);
-
- offs = (struct section_offsets *)
- alloca (sizeof (struct section_offsets)
- + objfile->num_sections * sizeof (offs->offsets));
- memcpy (offs, objfile->section_offsets,
- sizeof (struct section_offsets)
- + objfile->num_sections * sizeof (offs->offsets));
-
- ss.text_start = 0;
- ss.data_start = 0;
- ss.bss_start = 0;
- bfd_map_over_sections (objfile->obfd, find_sect, &ss);
-
- /* Both COFF and b.out frontends use these SECT_OFF_* values. */
- ANOFFSET (offs, SECT_OFF_TEXT) = text_addr - ss.text_start;
- ANOFFSET (offs, SECT_OFF_DATA) = data_addr - ss.data_start;
- ANOFFSET (offs, SECT_OFF_BSS) = bss_addr - ss.bss_start;
- objfile_relocate (objfile, offs);
-}
-
-/* This function allows the addition of incrementally linked object files. */
-
-static 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 ();
-
- /* Refuse to load the module if a debugged task is running. Doing so
- can have a number of unpleasant consequences to the running task. */
-
- if (inferior_pid != 0 && target_has_execution)
- {
- if (query ("You may not load a module while the target task is running.\n\
-Kill the target task? "))
- target_kill ();
- else
- error ("Load cancelled.");
- }
-
- QUIT;
- immediate_quit++;
- if (net_load (arg_string, &text_addr, &data_addr, &bss_addr) == -1)
- error ("Load failed on target machine");
- immediate_quit--;
-
- vx_add_symbols (arg_string, from_tty, text_addr, data_addr, bss_addr);
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- reinit_frame_cache ();
-}
-
-/* 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);
-}
-
-/* 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. */
-
-static 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. */
-
-static int
-net_get_symbols (pLoadTable)
- ldtabl *pLoadTable; /* return pointer to ldtabl here */
-{
- enum clnt_stat status;
-
- memset ((char *) pLoadTable, '\0', 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};
-
-static int
-vx_lookup_symbol (name, pAddr)
- char *name; /* symbol name */
- CORE_ADDR *pAddr;
-{
- enum clnt_stat status;
- SYMBOL_ADDR symbolAddr;
-
- *pAddr = 0;
- memset ((char *) &symbolAddr, '\0', sizeof (symbolAddr));
-
- status = net_clnt_call (VX_SYMBOL_INQ, xdr_wrapstring, &name,
- xdr_SYMBOL_ADDR, &symbolAddr);
- if (status != RPC_SUCCESS)
- {
- complain (&cant_contact_target);
- 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. */
-
-static 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. */
-
-static void
-net_connect (host)
- char *host;
-{
- struct sockaddr_in destAddr;
- struct hostent *destHost;
- unsigned long addr;
-
- /* Get the internet address for the given host. Allow a numeric
- IP address or a hostname. */
-
- addr = inet_addr (host);
- if (addr == -1)
- {
- destHost = (struct hostent *) gethostbyname (host);
- if (destHost == NULL)
- /* FIXME: Probably should include hostname here in quotes.
- For example if the user types "target vxworks vx960 " it should
- say "Invalid host `vx960 '." not just "Invalid hostname". */
- error ("Invalid hostname. Couldn't find remote host address.");
- addr = * (unsigned long *) destHost->h_addr;
- }
-
- memset (&destAddr, '\0', sizeof (destAddr));
-
- destAddr.sin_addr.s_addr = 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");
-}
-
-static int
-vx_wait (pid_to_wait_for, status)
- int pid_to_wait_for;
- struct target_waitstatus *status;
-{
- register int pid;
- 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((unsigned long) pid));
- } while (pid == 0);
-
- /* The mostly likely kind. */
- status->kind = TARGET_WAITKIND_STOPPED;
-
- switch (rdbEvent.eventType)
- {
- case EVENT_EXIT:
- status->kind = TARGET_WAITKIND_EXITED;
- /* FIXME is it possible to distinguish between a
- normal vs abnormal exit in VxWorks? */
- status->value.integer = 0;
- break;
-
- case EVENT_START:
- /* Task was just started. */
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
-
- case EVENT_STOP:
- status->value.sig = TARGET_SIGNAL_TRAP;
- /* XXX was it stopped by a signal? act accordingly */
- break;
-
- case EVENT_BREAK: /* Breakpoint was hit. */
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
-
- case EVENT_SUSPEND: /* Task was suspended, probably by ^C. */
- status->value.sig = TARGET_SIGNAL_INT;
- break;
-
- case EVENT_BUS_ERR: /* Task made evil nasty reference. */
- status->value.sig = TARGET_SIGNAL_BUS;
- break;
-
- case EVENT_ZERO_DIV: /* Division by zero */
- status->value.sig = TARGET_SIGNAL_FPE;
- break;
-
- case EVENT_SIGNAL:
-#ifdef I80960
- status->value.sig = i960_fault_to_signal (rdbEvent.sigType);
-#else
- /* Back in the old days, before enum target_signal, this code used
- to add NSIG to the signal number and claim that PRINT_RANDOM_SIGNAL
- would take care of it. But PRINT_RANDOM_SIGNAL has never been
- defined except on the i960, so I don't really know what we are
- supposed to do on other architectures. */
- status->value.sig = TARGET_SIGNAL_UNKNOWN;
-#endif
- break;
- } /* switch */
- 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_unfiltered("\t%s: ", pLoadFile->name);
- vx_add_symbols (pLoadFile->name, 0, pLoadFile->txt_addr,
- pLoadFile->data_addr, pLoadFile->bss_addr);
- printf_unfiltered ("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;
- int symbols_added = 0;
-
- if (!args)
- error_no_arg ("target machine name");
-
- target_preopen (from_tty);
-
- unpush_target (&vx_ops);
- printf_unfiltered ("Attaching remote machine across net...\n");
- gdb_flush (gdb_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);
- /* This assumes that the kernel is never relocated. Hope that is an
- accurate assumption. */
- if (catch_errors
- (symbol_stub,
- bootFile,
- "Error while reading symbols from boot file:\n",
- RETURN_MASK_ALL))
- puts_filtered ("ok\n");
- }
- else if (from_tty)
- printf_unfiltered ("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
- /* FIXME: Is there something better to search than the PATH? (probably
- not the source path, since source might be in different directories
- than objects. */
-
- if (catch_errors (add_symbol_stub, (char *)pLoadFile, (char *)0,
- RETURN_MASK_ALL))
- symbols_added = 1;
-#endif
- }
- printf_filtered ("Done.\n");
-
- clnt_freeres (pClient, xdr_ldtabl, &loadTable);
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- if (symbols_added)
- reinit_frame_cache ();
-}
-
-/* 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;
-{
- unsigned long pid;
- char *cptr = 0;
- Rptrace ptrace_in;
- Ptrace_return ptrace_out;
- int status;
-
- if (!args)
- error_no_arg ("process-id to attach");
-
- pid = strtoul (args, &cptr, 0);
- if ((cptr == args) || (*cptr != '\0'))
- error ("Invalid process-id -- give a single number in decimal or 0xhex");
-
- if (from_tty)
- printf_unfiltered ("Attaching pid %s.\n",
- local_hex_string((unsigned long) pid));
-
- memset ((char *)&ptrace_in, '\0', sizeof (ptrace_in));
- memset ((char *)&ptrace_out, '\0', 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_num;
- perror_with_name ("Attaching remote process");
- }
-
- /* It worked... */
-
- inferior_pid = pid;
- push_target (&vx_run_ops);
-
- if (vx_running)
- free (vx_running);
- vx_running = 0;
-}
-
-/* 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_unfiltered ("Detaching pid %s.\n",
- local_hex_string((unsigned long) inferior_pid));
-
- if (args) /* FIXME, should be possible to leave suspended */
- signal = atoi (args);
-
- memset ((char *)&ptrace_in, '\0', sizeof (ptrace_in));
- memset ((char *)&ptrace_out, '\0', 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_num;
- 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 ()
-{
- Rptrace ptrace_in;
- Ptrace_return ptrace_out;
- int status;
-
- printf_unfiltered ("Killing pid %s.\n", local_hex_string((unsigned long) inferior_pid));
-
- memset ((char *)&ptrace_in, '\0', sizeof (ptrace_in));
- memset ((char *)&ptrace_out, '\0', sizeof (ptrace_out));
- ptrace_in.pid = inferior_pid;
-
- status = net_ptrace_clnt_call (PTRACE_KILL, &ptrace_in, &ptrace_out);
- if (status == -1)
- warning (rpcerr);
- else if (ptrace_out.status == -1)
- {
- errno = ptrace_out.errno_num;
- perror_with_name ("Killing VxWorks process");
- }
-
- /* If it gives good status, the process is *gone*, no events remain.
- If the kill failed, assume the process is gone anyhow. */
- inferior_pid = 0;
- pop_target (); /* go back to non-executing VxWorks connection */
-}
-
-/* Clean up from the VxWorks process target as it goes away. */
-
-static void
-vx_proc_close (quitting)
- int quitting;
-{
- inferior_pid = 0; /* No longer have a process. */
- if (vx_running)
- free (vx_running);
- vx_running = 0;
-}
-
-/* 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. */
-
-static 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.");
-}
-
-static void
-init_vx_ops ()
-{
- vx_ops.to_shortname = "vxworks";
- vx_ops.to_longname = "VxWorks target memory via RPC over TCP/IP";
- vx_ops.to_doc = "Use VxWorks target memory. \n\
-Specify the name of the machine to connect to.";
- vx_ops.to_open = vx_open;
- vx_ops.to_close = vx_close;
- vx_ops.to_attach = vx_attach;
- vx_ops.to_xfer_memory = vx_xfer_memory;
- vx_ops.to_files_info = vx_files_info;
- vx_ops.to_load = vx_load_command;
- vx_ops.to_lookup_symbol = vx_lookup_symbol;
- vx_ops.to_create_inferior = vx_create_inferior;
- vx_ops.to_stratum = core_stratum;
- vx_ops.to_has_all_memory = 1;
- vx_ops.to_has_memory = 1;
- vx_ops.to_magic = OPS_MAGIC; /* Always the last thing */
-};
-
-static void
-init_vx_run_ops ()
-{
- vx_run_ops.to_shortname = "vxprocess";
- vx_run_ops.to_longname = "VxWorks process";
- vx_run_ops.to_doc = "VxWorks process; started by the \"run\" command.";
- vx_run_ops.to_open = vx_proc_open;
- vx_run_ops.to_close = vx_proc_close;
- vx_run_ops.to_detach = vx_detach;
- vx_run_ops.to_resume = vx_resume;
- vx_run_ops.to_wait = vx_wait;
- vx_run_ops.to_fetch_registers = vx_read_register;
- vx_run_ops.to_store_registers = vx_write_register;
- vx_run_ops.to_prepare_to_store = vx_prepare_to_store;
- vx_run_ops.to_xfer_memory = vx_xfer_memory;
- vx_run_ops.to_files_info = vx_run_files_info;
- vx_run_ops.to_insert_breakpoint = vx_insert_breakpoint;
- vx_run_ops.to_remove_breakpoint = vx_remove_breakpoint;
- vx_run_ops.to_kill = vx_kill;
- vx_run_ops.to_load = vx_load_command;
- vx_run_ops.to_lookup_symbol = vx_lookup_symbol;
- vx_run_ops.to_mourn_inferior = vx_mourn_inferior ;
- vx_run_ops.to_stratum = process_stratum;
- vx_run_ops.to_has_memory = 1;
- vx_run_ops.to_has_stack = 1;
- vx_run_ops.to_has_registers = 1;
- vx_run_ops.to_has_execution = 1;
- vx_run_ops.to_magic = OPS_MAGIC;
-}
-
-void
-_initialize_vx ()
-{
- init_vx_ops ();
- add_target (&vx_ops);
- init_vx_run_ops ();
- add_target (&vx_run_ops);
-
- add_show_from_set
- (add_set_cmd ("vxworks-timeout", class_support, var_uinteger,
- (char *) &rpcTimeout.tv_sec,
- "Set seconds to wait for rpc calls to return.\n\
-Set the number of seconds to wait for rpc calls to return.", &setlist),
- &showlist);
-}
diff --git a/contrib/gdb/gdb/remote-vx29k.c b/contrib/gdb/gdb/remote-vx29k.c
deleted file mode 100644
index e6fc2c7..0000000
--- a/contrib/gdb/gdb/remote-vx29k.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* Am29k-dependent portions of the RPC protocol
- used with a VxWorks target
-
-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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "defs.h"
-
-#include "vx-share/regPacket.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 "gdb_string.h"
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-
-#ifdef _AIX /* IBM claims "void *malloc()" not char * */
-#define malloc bogon_malloc
-#endif
-
-#include <rpc/rpc.h>
-#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
-#include <netdb.h>
-#include "vx-share/ptrace.h"
-#include "vx-share/xdr_ptrace.h"
-#include "vx-share/xdr_ld.h"
-#include "vx-share/xdr_rdb.h"
-#include "vx-share/dbgRpcLib.h"
-
-/* get rid of value.h if possible */
-#include <value.h>
-#include <symtab.h>
-
-/* Flag set if target has fpu */
-
-extern int target_has_fp;
-
-/* Generic register read/write routines in remote-vx.c. */
-
-extern void net_read_registers ();
-extern void net_write_registers ();
-
-/* Read a register or registers from the VxWorks target.
- REGNO is the register to read, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_read_register (regno)
- int regno;
-{
- char am29k_greg_packet[AM29K_GREG_PLEN];
- char am29k_fpreg_packet[AM29K_FPREG_PLEN];
-
- /* Get general-purpose registers. When copying values into
- registers [], don't assume that a location in registers []
- is properly aligned for the target data type. */
-
- net_read_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_GETREGS);
-
- /* Now copy the register values into registers[].
- Note that this code depends on the ordering of the REGNUMs
- as defined in "tm-29k.h". */
-
- bcopy (&am29k_greg_packet[AM29K_R_GR96],
- &registers[REGISTER_BYTE (GR96_REGNUM)], 160 * AM29K_GREG_SIZE);
- bcopy (&am29k_greg_packet[AM29K_R_VAB],
- &registers[REGISTER_BYTE (VAB_REGNUM)], 15 * AM29K_GREG_SIZE);
- registers[REGISTER_BYTE (INTE_REGNUM)] = am29k_greg_packet[AM29K_R_INTE];
- bcopy (&am29k_greg_packet[AM29K_R_RSP],
- &registers[REGISTER_BYTE (GR1_REGNUM)], 5 * AM29K_GREG_SIZE);
-
- /* PAD For now, don't care about exop register */
-
- memset (&registers[REGISTER_BYTE (EXO_REGNUM)], '\0', AM29K_GREG_SIZE);
-
- /* 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)
- {
- net_read_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN,
- PTRACE_GETFPREGS);
- registers[REGISTER_BYTE (FPE_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPE];
- registers[REGISTER_BYTE (FPS_REGNUM)] = am29k_fpreg_packet[AM29K_R_FPS];
-
- /* PAD For now, don't care about registers (?) AI0 to q */
-
- memset (&registers[REGISTER_BYTE (161)], '\0', 21 * AM29K_FPREG_SIZE);
- }
- else
- {
- memset (&registers[REGISTER_BYTE (FPE_REGNUM)], '\0', AM29K_FPREG_SIZE);
- memset (&registers[REGISTER_BYTE (FPS_REGNUM)], '\0', AM29K_FPREG_SIZE);
-
- /* PAD For now, don't care about registers (?) AI0 to q */
-
- memset (&registers[REGISTER_BYTE (161)], '\0', 21 * AM29K_FPREG_SIZE);
- }
-
- /* Mark the register cache valid. */
-
- registers_fetched ();
-}
-
-/* Store a register or registers into the VxWorks target.
- REGNO is the register to store, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_write_register (regno)
- int regno;
-{
- char am29k_greg_packet[AM29K_GREG_PLEN];
- char am29k_fpreg_packet[AM29K_FPREG_PLEN];
-
- /* Store general purpose registers. When copying values from
- registers [], don't assume that a location in registers []
- is properly aligned for the target data type. */
-
- bcopy (&registers[REGISTER_BYTE (GR96_REGNUM)],
- &am29k_greg_packet[AM29K_R_GR96], 160 * AM29K_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (VAB_REGNUM)],
- &am29k_greg_packet[AM29K_R_VAB], 15 * AM29K_GREG_SIZE);
- am29k_greg_packet[AM29K_R_INTE] = registers[REGISTER_BYTE (INTE_REGNUM)];
- bcopy (&registers[REGISTER_BYTE (GR1_REGNUM)],
- &am29k_greg_packet[AM29K_R_RSP], 5 * AM29K_GREG_SIZE);
-
- net_write_registers (am29k_greg_packet, AM29K_GREG_PLEN, PTRACE_SETREGS);
-
- /* Store floating point registers if the target has them. */
-
- if (target_has_fp)
- {
- am29k_fpreg_packet[AM29K_R_FPE] = registers[REGISTER_BYTE (FPE_REGNUM)];
- am29k_fpreg_packet[AM29K_R_FPS] = registers[REGISTER_BYTE (FPS_REGNUM)];
-
- net_write_registers (am29k_fpreg_packet, AM29K_FPREG_PLEN,
- PTRACE_SETFPREGS);
- }
-}
-
-/* VxWorks zeroes fp when the task is initialized; we use this
- to terminate the frame chain. Chain means here the nominal address of
- a frame, that is, the return address (lr0) address in the stack. To
- obtain the frame pointer (lr1) contents, we must add 4 bytes.
- Note : may be we should modify init_frame_info() to get the frame pointer
- and store it into the frame_info struct rather than reading its
- contents when FRAME_CHAIN_VALID is invoked. */
-
-int
-vx29k_frame_chain_valid (chain, thisframe)
- CORE_ADDR chain;
- struct frame_info *thisframe; /* not used here */
-{
- int fp_contents;
-
- read_memory ((CORE_ADDR)(chain + 4), (char *) &fp_contents, 4);
- return (fp_contents != 0);
-}
-
diff --git a/contrib/gdb/gdb/remote-vx68.c b/contrib/gdb/gdb/remote-vx68.c
deleted file mode 100644
index c6ceda1..0000000
--- a/contrib/gdb/gdb/remote-vx68.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/* 68k-dependent portions of the RPC protocol
- used with a VxWorks target
-
-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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "defs.h"
-
-#include "vx-share/regPacket.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 "gdb_string.h"
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-
-#ifdef _AIX /* IBM claims "void *malloc()" not char * */
-#define malloc bogon_malloc
-#endif
-
-#include <rpc/rpc.h>
-
-#ifdef _AIX
-#undef malloc
-#endif
-
-#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
-#include <netdb.h>
-#include "vx-share/ptrace.h"
-#include "vx-share/xdr_ptrace.h"
-#include "vx-share/xdr_ld.h"
-#include "vx-share/xdr_rdb.h"
-#include "vx-share/dbgRpcLib.h"
-
-/* get rid of value.h if possible */
-#include <value.h>
-#include <symtab.h>
-
-/* Flag set if target has fpu */
-
-extern int target_has_fp;
-
-/* Generic register read/write routines in remote-vx.c. */
-
-extern void net_read_registers ();
-extern void net_write_registers ();
-
-/* Read a register or registers from the VxWorks target.
- REGNO is the register to read, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_read_register (regno)
- int regno;
-{
- char mc68k_greg_packet[MC68K_GREG_PLEN];
- char mc68k_fpreg_packet[MC68K_FPREG_PLEN];
-
- /* Get general-purpose registers. */
-
- net_read_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_GETREGS);
-
- bcopy (&mc68k_greg_packet[MC68K_R_D0], registers, 16 * MC68K_GREG_SIZE);
- bcopy (&mc68k_greg_packet[MC68K_R_SR], &registers[REGISTER_BYTE (PS_REGNUM)],
- MC68K_GREG_SIZE);
- bcopy (&mc68k_greg_packet[MC68K_R_PC], &registers[REGISTER_BYTE (PC_REGNUM)],
- MC68K_GREG_SIZE);
-
- /* Get floating-point registers, if the target system has them.
- Otherwise, zero them. */
-
- if (target_has_fp)
- {
- net_read_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN,
- PTRACE_GETFPREGS);
-
- bcopy (&mc68k_fpreg_packet[MC68K_R_FP0],
- &registers[REGISTER_BYTE (FP0_REGNUM)],
- MC68K_FPREG_SIZE * 8);
- bcopy (&mc68k_fpreg_packet[MC68K_R_FPCR],
- &registers[REGISTER_BYTE (FPC_REGNUM)],
- MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8));
- }
- else
- {
- bzero (&registers[REGISTER_BYTE (FP0_REGNUM)],
- MC68K_FPREG_SIZE * 8);
- bzero (&registers[REGISTER_BYTE (FPC_REGNUM)],
- MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8));
- }
-
- /* Mark the register cache valid. */
-
- registers_fetched ();
-}
-
-/* Store a register or registers into the VxWorks target.
- REGNO is the register to store, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_write_register (regno)
- int regno;
-{
- char mc68k_greg_packet[MC68K_GREG_PLEN];
- char mc68k_fpreg_packet[MC68K_FPREG_PLEN];
-
- /* Store general-purpose registers. */
-
- bcopy (registers, &mc68k_greg_packet[MC68K_R_D0], 16 * MC68K_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (PS_REGNUM)],
- &mc68k_greg_packet[MC68K_R_SR], MC68K_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (PC_REGNUM)],
- &mc68k_greg_packet[MC68K_R_PC], MC68K_GREG_SIZE);
-
- net_write_registers (mc68k_greg_packet, MC68K_GREG_PLEN, PTRACE_SETREGS);
-
- /* Store floating point registers if the target has them. */
-
- if (target_has_fp)
- {
- bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)],
- &mc68k_fpreg_packet[MC68K_R_FP0],
- MC68K_FPREG_SIZE * 8);
- bcopy (&registers[REGISTER_BYTE (FPC_REGNUM)],
- &mc68k_fpreg_packet[MC68K_R_FPCR],
- MC68K_FPREG_PLEN - (MC68K_FPREG_SIZE * 8));
-
- net_write_registers (mc68k_fpreg_packet, MC68K_FPREG_PLEN,
- PTRACE_SETFPREGS);
- }
-}
diff --git a/contrib/gdb/gdb/remote-vx960.c b/contrib/gdb/gdb/remote-vx960.c
deleted file mode 100644
index bb4fbee..0000000
--- a/contrib/gdb/gdb/remote-vx960.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/* i80960-dependent portions of the RPC protocol
- used with a VxWorks target
-
-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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "defs.h"
-
-#include "vx-share/regPacket.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 "gdb_string.h"
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-
-#ifdef _AIX /* IBM claims "void *malloc()" not char * */
-#define malloc bogon_malloc
-#endif
-
-#include <rpc/rpc.h>
-#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
-#include <netdb.h>
-#include "vx-share/ptrace.h"
-#include "vx-share/xdr_ptrace.h"
-#include "vx-share/xdr_ld.h"
-#include "vx-share/xdr_rdb.h"
-#include "vx-share/dbgRpcLib.h"
-
-/* get rid of value.h if possible */
-#include <value.h>
-#include <symtab.h>
-
-/* Flag set if target has fpu */
-
-extern int target_has_fp;
-
-/* 960 floating point format descriptor, from "i960-tdep.c." */
-
-extern struct ext_format ext_format_i960;
-
-/* Generic register read/write routines in remote-vx.c. */
-
-extern void net_read_registers ();
-extern void net_write_registers ();
-
-/* Read a register or registers from the VxWorks target.
- REGNO is the register to read, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_read_register (regno)
- int regno;
-{
- char i960_greg_packet[I960_GREG_PLEN];
- char i960_fpreg_packet[I960_FPREG_PLEN];
-
- /* Get general-purpose registers. When copying values into
- registers [], don't assume that a location in registers []
- is properly aligned for the target data type. */
-
- net_read_registers (i960_greg_packet, I960_GREG_PLEN, PTRACE_GETREGS);
-
- bcopy (&i960_greg_packet[I960_R_R0],
- &registers[REGISTER_BYTE (R0_REGNUM)], 16 * I960_GREG_SIZE);
- bcopy (&i960_greg_packet[I960_R_G0],
- &registers[REGISTER_BYTE (G0_REGNUM)], 16 * I960_GREG_SIZE);
- bcopy (&i960_greg_packet[I960_R_PCW],
- &registers[REGISTER_BYTE (PCW_REGNUM)], sizeof (int));
- bcopy (&i960_greg_packet[I960_R_ACW],
- &registers[REGISTER_BYTE (ACW_REGNUM)], sizeof (int));
- bcopy (&i960_greg_packet[I960_R_TCW],
- &registers[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)
- {
- net_read_registers (i960_fpreg_packet, I960_FPREG_PLEN,
- PTRACE_GETFPREGS);
- bcopy (&i960_fpreg_packet[I960_R_FP0],
- &registers[REGISTER_BYTE (FP0_REGNUM)],
- REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
- }
- else
- bzero (&registers[REGISTER_BYTE (FP0_REGNUM)],
- REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
-
- /* Mark the register cache valid. */
-
- registers_fetched ();
-}
-
-/* Store a register or registers into the VxWorks target.
- REGNO is the register to store, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_write_register (regno)
- int regno;
-{
- char i960_greg_packet[I960_GREG_PLEN];
- char i960_fpreg_packet[I960_FPREG_PLEN];
-
- /* Store floating-point registers. When copying values from
- registers [], don't assume that a location in registers []
- is properly aligned for the target data type. */
-
- bcopy (&registers[REGISTER_BYTE (R0_REGNUM)],
- &i960_greg_packet[I960_R_R0], 16 * I960_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (G0_REGNUM)],
- &i960_greg_packet[I960_R_G0], 16 * I960_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (PCW_REGNUM)],
- &i960_greg_packet[I960_R_PCW], sizeof (int));
- bcopy (&registers[REGISTER_BYTE (ACW_REGNUM)],
- &i960_greg_packet[I960_R_ACW], sizeof (int));
- bcopy (&registers[REGISTER_BYTE (TCW_REGNUM)],
- &i960_greg_packet[I960_R_TCW], sizeof (int));
-
- net_write_registers (i960_greg_packet, I960_GREG_PLEN, PTRACE_SETREGS);
-
- /* Store floating point registers if the target has them. */
-
- if (target_has_fp)
- {
- bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)],
- &i960_fpreg_packet[I960_R_FP0],
- REGISTER_RAW_SIZE (FP0_REGNUM) * 4);
-
- net_write_registers (i960_fpreg_packet, I960_FPREG_PLEN,
- PTRACE_SETFPREGS);
- }
-}
-
diff --git a/contrib/gdb/gdb/remote-vxmips.c b/contrib/gdb/gdb/remote-vxmips.c
deleted file mode 100644
index c65ac01..0000000
--- a/contrib/gdb/gdb/remote-vxmips.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* MIPS-dependent portions of the RPC protocol
- used with a VxWorks target
-
-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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "defs.h"
-
-#include "vx-share/regPacket.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 "gdb_string.h"
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <rpc/rpc.h>
-#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
-#include <netdb.h>
-#include "vx-share/ptrace.h"
-#include "vx-share/xdr_ptrace.h"
-#include "vx-share/xdr_ld.h"
-#include "vx-share/xdr_rdb.h"
-#include "vx-share/dbgRpcLib.h"
-
-/* get rid of value.h if possible */
-#include <value.h>
-#include <symtab.h>
-
-/* Flag set if target has fpu */
-
-extern int target_has_fp;
-
-/* Generic register read/write routines in remote-vx.c. */
-
-extern void net_read_registers ();
-extern void net_write_registers ();
-
-/* Read a register or registers from the VxWorks target.
- REGNO is the register to read, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_read_register (regno)
- int regno;
-{
- char mips_greg_packet[MIPS_GREG_PLEN];
- char mips_fpreg_packet[MIPS_FPREG_PLEN];
-
- /* Get general-purpose registers. */
-
- net_read_registers (mips_greg_packet, MIPS_GREG_PLEN, PTRACE_GETREGS);
-
- /* this code copies the registers obtained by RPC
- stored in a structure(s) like this :
-
- Register(s) Offset(s)
- gp 0-31 0x00
- hi 0x80
- lo 0x84
- sr 0x88
- pc 0x8c
-
- into a stucture like this:
-
- 0x00 GP 0-31
- 0x80 SR
- 0x84 LO
- 0x88 HI
- 0x8C BAD --- Not available currently
- 0x90 CAUSE --- Not available currently
- 0x94 PC
- 0x98 FP 0-31
- 0x118 FCSR
- 0x11C FIR --- Not available currently
- 0x120 FP --- Not available currently
-
- structure is 0x124 (292) bytes in length */
-
- /* Copy the general registers. */
-
- bcopy (&mips_greg_packet[MIPS_R_GP0], &registers[0], 32 * MIPS_GREG_SIZE);
-
- /* Copy SR, LO, HI, and PC. */
-
- bcopy (&mips_greg_packet[MIPS_R_SR],
- &registers[REGISTER_BYTE (PS_REGNUM)], MIPS_GREG_SIZE);
- bcopy (&mips_greg_packet[MIPS_R_LO],
- &registers[REGISTER_BYTE (LO_REGNUM)], MIPS_GREG_SIZE);
- bcopy (&mips_greg_packet[MIPS_R_HI],
- &registers[REGISTER_BYTE (HI_REGNUM)], MIPS_GREG_SIZE);
- bcopy (&mips_greg_packet[MIPS_R_PC],
- &registers[REGISTER_BYTE (PC_REGNUM)], MIPS_GREG_SIZE);
-
- /* 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)
- {
- net_read_registers (mips_fpreg_packet, MIPS_FPREG_PLEN,
- PTRACE_GETFPREGS);
-
- /* Copy the floating point registers. */
-
- bcopy (&mips_fpreg_packet[MIPS_R_FP0],
- &registers[REGISTER_BYTE (FP0_REGNUM)],
- REGISTER_RAW_SIZE (FP0_REGNUM) * 32);
-
- /* Copy the floating point control/status register (fpcsr). */
-
- bcopy (&mips_fpreg_packet[MIPS_R_FPCSR],
- &registers[REGISTER_BYTE (FCRCS_REGNUM)],
- REGISTER_RAW_SIZE (FCRCS_REGNUM));
- }
- else
- {
- bzero ((char *) &registers[REGISTER_BYTE (FP0_REGNUM)],
- REGISTER_RAW_SIZE (FP0_REGNUM) * 32);
- bzero ((char *) &registers[REGISTER_BYTE (FCRCS_REGNUM)],
- REGISTER_RAW_SIZE (FCRCS_REGNUM));
- }
-
- /* Mark the register cache valid. */
-
- registers_fetched ();
-}
-
-/* Store a register or registers into the VxWorks target.
- REGNO is the register to store, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-vx_write_register (regno)
- int regno;
-{
- char mips_greg_packet[MIPS_GREG_PLEN];
- char mips_fpreg_packet[MIPS_FPREG_PLEN];
-
- /* Store general registers. */
-
- bcopy (&registers[0], &mips_greg_packet[MIPS_R_GP0], 32 * MIPS_GREG_SIZE);
-
- /* Copy SR, LO, HI, and PC. */
-
- bcopy (&registers[REGISTER_BYTE (PS_REGNUM)],
- &mips_greg_packet[MIPS_R_SR], MIPS_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (LO_REGNUM)],
- &mips_greg_packet[MIPS_R_LO], MIPS_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (HI_REGNUM)],
- &mips_greg_packet[MIPS_R_HI], MIPS_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (PC_REGNUM)],
- &mips_greg_packet[MIPS_R_PC], MIPS_GREG_SIZE);
-
- net_write_registers (mips_greg_packet, MIPS_GREG_PLEN, PTRACE_SETREGS);
-
- /* Store floating point registers if the target has them. */
-
- if (target_has_fp)
- {
- /* Copy the floating point data registers. */
-
- bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)],
- &mips_fpreg_packet[MIPS_R_FP0],
- REGISTER_RAW_SIZE (FP0_REGNUM) * 32);
-
- /* Copy the floating point control/status register (fpcsr). */
-
- bcopy (&registers[REGISTER_BYTE (FCRCS_REGNUM)],
- &mips_fpreg_packet[MIPS_R_FPCSR],
- REGISTER_RAW_SIZE (FCRCS_REGNUM));
-
- net_write_registers (mips_fpreg_packet, MIPS_FPREG_PLEN,
- PTRACE_SETFPREGS);
- }
-}
diff --git a/contrib/gdb/gdb/remote-vxsparc.c b/contrib/gdb/gdb/remote-vxsparc.c
deleted file mode 100644
index 0682542..0000000
--- a/contrib/gdb/gdb/remote-vxsparc.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/* sparc-dependent portions of the RPC protocol
- used with a VxWorks target
-
-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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "defs.h"
-
-#include "vx-share/regPacket.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 "gdb_string.h"
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-
-#ifdef _AIX /* IBM claims "void *malloc()" not char * */
-#define malloc bogon_malloc
-#endif
-
-#include <rpc/rpc.h>
-#include <sys/time.h> /* UTek's <rpc/rpc.h> doesn't #incl this */
-#include <netdb.h>
-#include "vx-share/ptrace.h"
-#include "vx-share/xdr_ptrace.h"
-#include "vx-share/xdr_ld.h"
-#include "vx-share/xdr_rdb.h"
-#include "vx-share/dbgRpcLib.h"
-
-/* get rid of value.h if possible */
-#include <value.h>
-#include <symtab.h>
-
-/* Flag set if target has fpu */
-
-extern int target_has_fp;
-
-/* sparc floating point format descriptor, from "sparc-tdep.c." */
-
-extern struct ext_format ext_format_sparc;
-
-/* Generic register read/write routines in remote-vx.c. */
-
-extern void net_read_registers ();
-extern void net_write_registers ();
-
-/* Read a register or registers from the VxWorks target.
- REGNO is the register to read, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_read_register (regno)
- int regno;
-{
- char sparc_greg_packet[SPARC_GREG_PLEN];
- char sparc_fpreg_packet[SPARC_FPREG_PLEN];
- CORE_ADDR sp;
-
- /* Get general-purpose registers. When copying values into
- registers [], don't assume that a location in registers []
- is properly aligned for the target data type. */
-
- net_read_registers (sparc_greg_packet, SPARC_GREG_PLEN, PTRACE_GETREGS);
-
- /* Now copy the register values into registers[].
- Note that this code depends on the ordering of the REGNUMs
- as defined in "tm-sparc.h". */
-
- bcopy (&sparc_greg_packet[SPARC_R_G0],
- &registers[REGISTER_BYTE (G0_REGNUM)], 32 * SPARC_GREG_SIZE);
- bcopy (&sparc_greg_packet[SPARC_R_Y],
- &registers[REGISTER_BYTE (Y_REGNUM)], 6 * SPARC_GREG_SIZE);
-
- /* Now write the local and in registers to the register window
- spill area in the frame. VxWorks does not do this for the
- active frame automatically; it greatly simplifies debugging
- (FRAME_FIND_SAVED_REGS, in particular, depends on this). */
-
- sp = extract_address (&registers[REGISTER_BYTE (SP_REGNUM)],
- REGISTER_RAW_SIZE (CORE_ADDR));
- write_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
- 16 * REGISTER_RAW_SIZE (L0_REGNUM));
-
- /* 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)
- {
- net_read_registers (sparc_fpreg_packet, SPARC_FPREG_PLEN,
- PTRACE_GETFPREGS);
- bcopy (&sparc_fpreg_packet[SPARC_R_FP0],
- &registers[REGISTER_BYTE (FP0_REGNUM)], 32 * SPARC_FPREG_SIZE);
- bcopy (&sparc_fpreg_packet[SPARC_R_FSR],
- &registers[REGISTER_BYTE (FPS_REGNUM)], 1 * SPARC_FPREG_SIZE);
- }
- else
- {
- bzero (&registers[REGISTER_BYTE (FP0_REGNUM)], 32 * SPARC_FPREG_SIZE);
- bzero (&registers[REGISTER_BYTE (FPS_REGNUM)], 1 * SPARC_FPREG_SIZE);
- }
-
- /* Mark the register cache valid. */
-
- registers_fetched ();
-}
-
-/* Store a register or registers into the VxWorks target.
- REGNO is the register to store, or -1 for all; currently,
- it is ignored. FIXME look at regno to improve efficiency. */
-
-void
-vx_write_register (regno)
- int regno;
-{
- char sparc_greg_packet[SPARC_GREG_PLEN];
- char sparc_fpreg_packet[SPARC_FPREG_PLEN];
- int in_gp_regs;
- int in_fp_regs;
- CORE_ADDR sp;
-
- /* Store general purpose registers. When copying values from
- registers [], don't assume that a location in registers []
- is properly aligned for the target data type. */
-
- in_gp_regs = 1;
- in_fp_regs = 1;
- if (regno >= 0)
- {
- if ((G0_REGNUM <= regno && regno <= I7_REGNUM)
- || (Y_REGNUM <= regno && regno <= NPC_REGNUM))
- in_fp_regs = 0;
- else
- in_gp_regs = 0;
- }
- if (in_gp_regs)
- {
- bcopy (&registers[REGISTER_BYTE (G0_REGNUM)],
- &sparc_greg_packet[SPARC_R_G0], 32 * SPARC_GREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (Y_REGNUM)],
- &sparc_greg_packet[SPARC_R_Y], 6 * SPARC_GREG_SIZE);
-
- net_write_registers (sparc_greg_packet, SPARC_GREG_PLEN, PTRACE_SETREGS);
-
- /* If this is a local or in register, or we're storing all
- registers, update the register window spill area. */
-
- if (regno < 0 || (L0_REGNUM <= regno && regno <= I7_REGNUM))
- {
- sp = extract_address (&registers[REGISTER_BYTE (SP_REGNUM)],
- REGISTER_RAW_SIZE (CORE_ADDR));
- write_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
- 16 * REGISTER_RAW_SIZE (L0_REGNUM));
- }
- }
-
- /* Store floating point registers if the target has them. */
-
- if (in_fp_regs && target_has_fp)
- {
- bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)],
- &sparc_fpreg_packet[SPARC_R_FP0], 32 * SPARC_FPREG_SIZE);
- bcopy (&registers[REGISTER_BYTE (FPS_REGNUM)],
- &sparc_fpreg_packet[SPARC_R_FSR], 1 * SPARC_FPREG_SIZE);
-
- net_write_registers (sparc_fpreg_packet, SPARC_FPREG_PLEN,
- PTRACE_SETFPREGS);
- }
-}
diff --git a/contrib/gdb/gdb/remote.c b/contrib/gdb/gdb/remote.c
index f5b6f7c..ab4ccf2 100644
--- a/contrib/gdb/gdb/remote.c
+++ b/contrib/gdb/gdb/remote.c
@@ -1,6 +1,5 @@
/* Remote target communications for serial-line targets in custom GDB protocol
- Copyright 1988, 91, 92, 93, 94, 95, 96, 97, 1998
- Free Software Foundation, Inc.
+ Copyright 1988, 1991, 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
This file is part of GDB.
@@ -90,13 +89,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
where only part of the data was
written).
- write mem XAA..AA,LLLL:XX..XX
- (binary) AA..AA is address,
- LLLL is number of bytes,
- XX..XX is binary data
- reply OK for success
- ENN for an error
-
continue cAA..AA AA..AA is address to resume
If AA..AA is omitted,
resume at same address.
@@ -105,11 +97,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
If AA..AA is omitted,
resume at same address.
- continue with Csig;AA..AA Continue with signal sig (hex signal
- signal number). If ;AA..AA is omitted,
- resume at same address.
+ continue with Csig;AA Continue with signal sig (hex signal
+ signal number).
- step with Ssig;AA..AA Like 'C' but step not continue.
+ step with Ssig;AA Like 'C' but step not continue.
signal
last signal ? Reply the current reason for stopping.
@@ -142,10 +133,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
or... XAA The process terminated with signal
AA.
or... OXX..XX XX..XX is hex encoding of ASCII data. This
- can happen at any time while the
- program is running and the debugger
- should continue to wait for
- 'W', 'T', etc.
+ can happen at any time while the program is
+ running and the debugger should
+ continue to wait for 'W', 'T', etc.
thread alive TXX Find out if the thread XX is alive.
reply OK thread is still alive
@@ -187,7 +177,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "gdb_string.h"
-#include <ctype.h>
#include <fcntl.h>
#include "frame.h"
#include "inferior.h"
@@ -199,7 +188,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "gdbcmd.h"
#include "objfiles.h"
#include "gdb-stabs.h"
-#include "gdbthread.h"
+#include "thread.h"
#include "dcache.h"
@@ -220,9 +209,9 @@ static int remote_read_bytes PARAMS ((CORE_ADDR memaddr,
static void remote_files_info PARAMS ((struct target_ops *ignore));
-static int remote_xfer_memory PARAMS ((CORE_ADDR memaddr, char * myaddr,
+static int remote_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr,
int len, int should_write,
- struct target_ops * target));
+ struct target_ops *target));
static void remote_prepare_to_store PARAMS ((void));
@@ -231,14 +220,13 @@ static void remote_fetch_registers PARAMS ((int regno));
static void remote_resume PARAMS ((int pid, int step,
enum target_signal siggnal));
-static int remote_start_remote PARAMS ((PTR));
+static int remote_start_remote PARAMS ((char *dummy));
static void remote_open PARAMS ((char *name, int from_tty));
static void extended_remote_open PARAMS ((char *name, int from_tty));
-static void remote_open_1 PARAMS ((char *, int, struct target_ops *,
- int extended_p));
+static void remote_open_1 PARAMS ((char *, int, struct target_ops *));
static void remote_close PARAMS ((int quitting));
@@ -254,174 +242,39 @@ static void extended_remote_create_inferior PARAMS ((char *, char *, char **));
static void remote_mourn_1 PARAMS ((struct target_ops *));
+static void getpkt PARAMS ((char *buf, int forever));
+
+static int putpkt PARAMS ((char *buf));
+
static void remote_send PARAMS ((char *buf));
static int readchar PARAMS ((int timeout));
-static int remote_wait PARAMS ((int pid, struct target_waitstatus * status));
+static int remote_wait PARAMS ((int pid, struct target_waitstatus *status));
static void remote_kill PARAMS ((void));
static int tohex PARAMS ((int nib));
+static int fromhex PARAMS ((int a));
+
static void remote_detach PARAMS ((char *args, int from_tty));
static void remote_interrupt PARAMS ((int signo));
-static void interrupt_query PARAMS ((void));
-
-static void set_thread PARAMS ((int, int));
-
-static int remote_thread_alive PARAMS ((int));
-
-static void get_offsets PARAMS ((void));
-
-static int read_frame PARAMS ((char *));
-
-static int remote_insert_breakpoint PARAMS ((CORE_ADDR, char *));
-
-static int remote_remove_breakpoint PARAMS ((CORE_ADDR, char *));
-
-static int hexnumlen PARAMS ((ULONGEST num));
-
-static void init_remote_ops PARAMS ((void));
-
-static void init_extended_remote_ops PARAMS ((void));
-
-static void remote_stop PARAMS ((void));
-
-static int ishex PARAMS ((int ch, int *val));
-
-static int stubhex PARAMS ((int ch));
-
-static int remote_query PARAMS ((int/*char*/, char *, char *, int *));
-
-static int hexnumstr PARAMS ((char *, ULONGEST));
-
-static CORE_ADDR remote_address_masked PARAMS ((CORE_ADDR));
-
-static void print_packet PARAMS ((char *));
-
-static unsigned long crc32 PARAMS ((unsigned char *, int, unsigned int));
-
-static void compare_sections_command PARAMS ((char *, int));
-
-static void packet_command PARAMS ((char *, int));
-
-static int stub_unpack_int PARAMS ((char *buff, int fieldlength));
-
-char *unpack_varlen_hex PARAMS ((char *buff, int *result));
-
-static char *unpack_nibble PARAMS ((char *buf, int *val));
-
-static char *pack_nibble PARAMS ((char *buf, int nibble));
-
-static char *pack_hex_byte PARAMS ((char *pkt, int/*unsigned char*/ byte));
-
-static char *unpack_byte PARAMS ((char *buf, int *value));
-
-static char *pack_int PARAMS ((char *buf, int value));
-
-static char *unpack_int PARAMS ((char *buf, int *value));
-
-static char *unpack_string PARAMS ((char *src, char *dest, int length));
-
-static char *pack_threadid PARAMS ((char *pkt, threadref *id));
-
-static char *unpack_threadid PARAMS ((char *inbuf, threadref *id));
-
-void int_to_threadref PARAMS ((threadref *id, int value));
-
-static int threadref_to_int PARAMS ((threadref *ref));
-
-static void copy_threadref PARAMS ((threadref *dest, threadref *src));
-
-static int threadmatch PARAMS ((threadref *dest, threadref *src));
-
-static char *pack_threadinfo_request PARAMS ((char *pkt, int mode,
- threadref *id));
-
-static int remote_unpack_thread_info_response PARAMS ((char *pkt,
- threadref *expectedref,
- struct gdb_ext_thread_info *info));
-
-
-static int remote_get_threadinfo PARAMS ((threadref *threadid,
- int fieldset, /*TAG mask */
- struct gdb_ext_thread_info *info));
+static void remote_interrupt_twice PARAMS ((int signo));
-static int adapt_remote_get_threadinfo PARAMS ((gdb_threadref *ref,
- int selection,
- struct gdb_ext_thread_info *info));
-
-static char *pack_threadlist_request PARAMS ((char *pkt, int startflag,
- int threadcount,
- threadref *nextthread));
-
-static int parse_threadlist_response PARAMS ((char *pkt,
- int result_limit,
- threadref *original_echo,
- threadref *resultlist,
- int *doneflag));
-
-static int remote_get_threadlist PARAMS ((int startflag,
- threadref *nextthread,
- int result_limit,
- int *done,
- int *result_count,
- threadref *threadlist));
-
-typedef int (*rmt_thread_action) (threadref *ref, void *context);
-
-static int remote_threadlist_iterator PARAMS ((rmt_thread_action stepfunction,
- void *context, int looplimit));
-
-static int remote_newthread_step PARAMS ((threadref *ref, void *context));
-
-static int remote_current_thread PARAMS ((int oldpid));
-
-int remote_find_new_threads PARAMS ((void));
-
-static void record_currthread PARAMS ((int currthread));
-
-static void init_remote_threads PARAMS ((void));
-
-/* exported functions */
-
-extern int fromhex PARAMS ((int a));
-
-extern void getpkt PARAMS ((char *buf, int forever));
-
-extern int putpkt PARAMS ((char *buf));
-
-static int putpkt_binary PARAMS ((char *buf, int cnt));
-
-void remote_console_output PARAMS ((char *));
-
-static void check_binary_download PARAMS ((CORE_ADDR addr));
-
-/* Define the target subroutine names */
-
-void open_remote_target PARAMS ((char *, int, struct target_ops *, int));
-
-void _initialize_remote PARAMS ((void));
-
-/* */
-
-static struct target_ops remote_ops;
-
-static struct target_ops extended_remote_ops;
+static void interrupt_query PARAMS ((void));
-static struct target_thread_vector remote_thread_vec;
+extern struct target_ops remote_ops; /* Forward decl */
+extern struct target_ops extended_remote_ops; /* Forward decl */
/* This was 5 seconds, which is a long time to sit and wait.
Unless this is going though some terminal server or multiplexer or
other form of hairy serial connection, I would think 2 seconds would
be plenty. */
-/* Changed to allow option to set timeout value.
- was static int remote_timeout = 2; */
-extern int remote_timeout;
+static int remote_timeout = 2;
/* This variable chooses whether to send a ^C or a break when the user
requests program interruption. Although ^C is usually what remote
@@ -430,26 +283,10 @@ extern int remote_timeout;
static int remote_break;
-/* Has the user attempted to interrupt the target? If so, then offer
- the user the opportunity to bail out completely if he interrupts
- again. */
-static int interrupted_already = 0;
-
/* Descriptor for I/O to remote machine. Initialize it to NULL so that
remote_open knows that we don't have a file open when the program
starts. */
-static serial_t remote_desc = NULL;
-
-/* This variable (available to the user via "set remotebinarydownload")
- dictates whether downloads are sent in binary (via the 'X' packet).
- We assume that the stub can, and attempt to do it. This will be cleared if
- the stub does not understand it. This switch is still needed, though
- in cases when the packet is supported in the stub, but the connection
- does not allow it (i.e., 7-bit serial connection only). */
-static int remote_binary_download = 1;
-
-/* Have we already checked whether binary downloads work? */
-static int remote_binary_checked;
+serial_t remote_desc = NULL;
/* Having this larger than 400 causes us to be incompatible with m68k-stub.c
and i386-stub.c. Normally, no one would notice because it only matters
@@ -471,76 +308,192 @@ static int remote_binary_checked;
#define PBUFSIZ (REGISTER_BYTES * 2 + 32)
#endif
+/* Should we try the 'P' request? If this is set to one when the stub
+ doesn't support 'P', the only consequence is some unnecessary traffic. */
+static int stub_supports_P = 1;
-/* This variable sets the number of bytes to be written to the target
- in a single packet. Normally PBUFSIZ is satisfactory, but some
- targets need smaller values (perhaps because the receiving end
- is slow). */
+
+/*
+ * Support for quasi-interactive control of device through GDB port.
+ * While we're waiting for an event to occur, chat with the running device.
+ */
+#define REMOTE_CHAT
+#ifdef REMOTE_CHAT
+
+extern int quit_flag;
+
+static char tty_input[256];
+static int escape_count;
+static int echo_check;
+static int remote_chat = 0;
+
+enum read_stat {
+ READ_MORE,
+ FATAL_ERROR,
+ ENTER_DEBUG
+};
+
+static enum read_stat
+readtarget()
+{
+ int j;
+ int data;
+
+ /* Loop until the socket doesn't have any more data */
+ while ((data = readchar(0)) >= 0) {
+
+ /* Check for the escape sequence */
+ if (data == '|') {
+ /* If this is the fourth escape, get out */
+ if (++escape_count == 4)
+ return (ENTER_DEBUG);
+ continue; /* Not the fourth, continue */
+
+ } else {
+ /*
+ * Not an escape any more, Ensure any pending ones are flushed
+ */
+ for (j = 1; j <= escape_count; j++)
+ putchar('|');
+ escape_count = 0;
+ }
-static int remote_write_size = PBUFSIZ;
+ if (data == '\r') /* If this is a return character */
+ continue; /* just supress it */
-/* This variable sets the number of bits in an address that are to be
- sent in a memory ("M" or "m") packet. Normally, after stripping
- leading zeros, the entire address would be sent. This variable
- restricts the address to REMOTE_ADDRESS_SIZE bits. HISTORY: The
- initial implementation of remote.c restricted the address sent in
- memory packets to ``host::sizeof long'' bytes - (typically 32
- bits). Consequently, for 64 bit targets, the upper 32 bits of an
- address was never sent. Since fixing this bug may cause a break in
- some remote targets this variable is principly provided to
- facilitate backward compatibility. */
+ if (echo_check != -1) { /* If we are checking for an echo */
+ /* If this might be an echo */
+ if (tty_input[echo_check] == data) {
+ echo_check++; /* Note one more character match */
+ continue; /* Go and loop */
+ } else {
-static int remote_address_size;
+ if ((data == '\n') && (tty_input[echo_check] == '\r')) {
+ /* If this is the end of the line */
+ echo_check = -1; /* No more echo supression */
+ continue; /* Go and loop */
+ }
+
+ /* Not an echo, print out the data */
+ for (j = 0; j < echo_check; j++)
+ putchar(tty_input[j]);
-/* This is the size (in chars) of the first response to the `g' command. This
- is used to limit the size of the memory read and write commands to prevent
- stub buffers from overflowing. The size does not include headers and
- trailers, it is only the payload size. */
+ echo_check = -1;/* No more echo checking */
+ }
+ }
+ putchar(data); /* Output the character */
+ }
+ return (READ_MORE); /* Indicate to read some more */
+}
-static int remote_register_buf_size = 0;
+static enum read_stat
+readtty()
+{
+ enum read_stat status;
+ int tty_bc;
-/* Should we try the 'P' request? If this is set to one when the stub
- doesn't support 'P', the only consequence is some unnecessary traffic. */
-static int stub_supports_P = 1;
+ /* First, read a buffer full from the terminal */
+ if ((tty_bc = read(fileno(stdin), tty_input, sizeof(tty_input) - 1)) < 0) {
+ perror_with_name("readtty: read failed");
+ return (FATAL_ERROR);
+ }
-/* These are pointers to hook functions that may be set in order to
- modify resume/wait behavior for a particular architecture. */
+ /* Turn trailing newlines into returns */
+ if (tty_input[tty_bc - 1] == '\n')
+ tty_input[tty_bc - 1] = '\r';
-void (*target_resume_hook) PARAMS ((void));
-void (*target_wait_loop_hook) PARAMS ((void));
+ if ((tty_input[0] == '~') && (tty_bc == 3))
+ switch (tty_input[1]) {
+ case 'b': /* ~b\n = send break & gdb */
+ SERIAL_SEND_BREAK (remote_desc);
+ /* fall through */
-
+ case 'c': /* ~c\n = return to gdb */
+ return (ENTER_DEBUG);
+ }
+
+ /* Make this a zero terminated string and write it out */
+ tty_input[tty_bc] = '\0';
-/* These are the threads which we last sent to the remote system.
- -1 for all or -2 for not sent yet. */
-static int general_thread;
-static int cont_thread;
+ if (SERIAL_WRITE(remote_desc, tty_input, tty_bc)) {
+ perror_with_name("readtty: write failed");
+ return (FATAL_ERROR);
+ }
-/* Call this function as a result of
- 1) A halt indication (T packet) containing a thread id
- 2) A direct query of currthread
- 3) Successful execution of set thread
- */
+ return (READ_MORE);
+}
-static void
-record_currthread (currthread)
- int currthread;
+static int
+remote_talk()
{
-#if 0 /* target_wait must not modify inferior_pid! */
- inferior_pid = currthread;
-#endif
- general_thread = currthread;
-#if 0 /* setting cont_thread has a different meaning
- from having the target report its thread id. */
- cont_thread = currthread;
-#endif
- /* If this is a new thread, add it to GDB's thread list.
- If we leave it up to WFI to do this, bad things will happen. */
- if (!in_thread_list (currthread))
- add_thread (currthread);
+ fd_set input;
+ int tablesize;
+ enum read_stat status;
+ int panic_flag = 0;
+ char buf[4];
+
+ escape_count = 0;
+ echo_check = -1;
+
+ tablesize = getdtablesize();
+
+ for (;;) {
+
+ /*
+ * Check for anything from our socket - doesn't block. Note that this
+ * must be done *before* the select as there may be buffered I/O
+ * waiting to be processed.
+ */
+ if ((status = readtarget()) != READ_MORE)
+ return (status);
+
+ fflush(stdout); /* Flush output before blocking */
+
+ /* Now block on more socket input or TTY input */
+ FD_ZERO(&input);
+ FD_SET(fileno(stdin), &input);
+ FD_SET(remote_desc->fd, &input);
+
+ status = select(tablesize, &input, 0, 0, 0);
+ if ((status < 0) && (errno != EINTR)) {
+ perror_with_name("remote_talk: select");
+ return (FATAL_ERROR);
+ }
+
+ /* Handle Control-C typed */
+ if (quit_flag) {
+ if ((++panic_flag) == 3) {
+ printf("\nAre you repeating Control-C to terminate "
+ "the session? (y/n) [n] ");
+ fgets(buf, 3, stdin);
+ if (buf[0] == 'y') {
+ pop_target(); /* Clean up */
+ error("Debugging terminated by user interrupt");
+ }
+ panic_flag = 0;
+ }
+ quit_flag = 0;
+ SERIAL_WRITE(remote_desc, "\003", 1);
+ continue;
+ }
+
+ /* Handle terminal input */
+ if (FD_ISSET(fileno(stdin), &input)) {
+ panic_flag = 0;
+ status = readtty();
+ if (status != READ_MORE)
+ return (status);
+ echo_check = 0;
+ }
+ }
}
-#define MAGIC_NULL_PID 42000
+#endif /* REMOTE_CHAT */
+
+/* These are the threads which we last sent to the remote system. -1 for all
+ or -2 for not sent yet. */
+int general_thread;
+int cont_thread;
static void
set_thread (th, gen)
@@ -549,13 +502,11 @@ set_thread (th, gen)
{
char buf[PBUFSIZ];
int state = gen ? general_thread : cont_thread;
-
if (state == th)
return;
-
buf[0] = 'H';
buf[1] = gen ? 'g' : 'c';
- if (th == MAGIC_NULL_PID)
+ if (th == 42000)
{
buf[2] = '0';
buf[3] = '\0';
@@ -582,681 +533,14 @@ remote_thread_alive (th)
buf[0] = 'T';
if (th < 0)
- sprintf (&buf[1], "-%08x", -th);
+ sprintf (&buf[1], "-%x", -th);
else
- sprintf (&buf[1], "%08x", th);
+ sprintf (&buf[1], "%x", th);
putpkt (buf);
getpkt (buf, 0);
return (buf[0] == 'O' && buf[1] == 'K');
}
-/* About these extended threadlist and threadinfo packets. They are
- variable length packets but, the fields within them are often fixed
- length. They are redundent enough to send over UDP as is the
- remote protocol in general. There is a matching unit test module
- in libstub. */
-
-#define BUF_THREAD_ID_SIZE (OPAQUETHREADBYTES*2)
-
-/* encode 64 bits in 16 chars of hex */
-
-static const char hexchars[] = "0123456789abcdef";
-
-static int
-ishex (ch, val)
- int ch;
- int *val;
-{
- if ((ch >= 'a') && (ch <= 'f'))
- {
- *val = ch - 'a' + 10;
- return 1;
- }
- if ((ch >= 'A') && (ch <= 'F'))
- {
- *val = ch - 'A' + 10;
- return 1;
- }
- if ((ch >= '0') && (ch <= '9'))
- {
- *val = ch - '0';
- return 1;
- }
- return 0;
-}
-
-static int
-stubhex (ch)
- int 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;
-}
-
-static int
-stub_unpack_int (buff, fieldlength)
- char *buff;
- int fieldlength;
-{
- int nibble;
- int retval = 0;
-
- while (fieldlength)
- {
- nibble = stubhex (*buff++);
- retval |= nibble;
- fieldlength--;
- if (fieldlength)
- retval = retval << 4;
- }
- return retval;
-}
-
-char *
-unpack_varlen_hex (buff, result)
- char *buff; /* packet to parse */
- int *result;
-{
- int nibble;
- int retval = 0;
-
- while (ishex (*buff, &nibble))
- {
- buff++;
- retval = retval << 4;
- retval |= nibble & 0x0f;
- }
- *result = retval;
- return buff;
-}
-
-static char *
-unpack_nibble (buf, val)
- char *buf;
- int *val;
-{
- ishex (*buf++, val);
- return buf;
-}
-
-static char *
-pack_nibble (buf, nibble)
- char *buf;
- int nibble;
-{
- *buf++ = hexchars[(nibble & 0x0f)];
- return buf;
-}
-
-static char *
-pack_hex_byte (pkt, byte)
- char *pkt;
- int byte;
-{
- *pkt++ = hexchars[(byte >> 4) & 0xf];
- *pkt++ = hexchars[(byte & 0xf)];
- return pkt;
-}
-
-static char *
-unpack_byte (buf, value)
- char *buf;
- int *value;
-{
- *value = stub_unpack_int (buf, 2);
- return buf + 2;
-}
-
-static char *
-pack_int (buf, value)
- char *buf;
- int value;
-{
- buf = pack_hex_byte (buf, (value >> 24) & 0xff);
- buf = pack_hex_byte (buf, (value >> 16) & 0xff);
- buf = pack_hex_byte (buf, (value >> 8) & 0x0ff);
- buf = pack_hex_byte (buf, (value & 0xff));
- return buf;
-}
-
-static char *
-unpack_int (buf, value)
- char *buf;
- int *value;
-{
- *value = stub_unpack_int (buf, 8);
- return buf + 8;
-}
-
-#if 0 /* currently unused, uncomment when needed */
-static char *pack_string PARAMS ((char *pkt, char *string));
-
-static char *
-pack_string (pkt, string)
- char *pkt;
- char *string;
-{
- char ch;
- int len;
-
- len = strlen (string);
- if (len > 200)
- len = 200; /* Bigger than most GDB packets, junk??? */
- pkt = pack_hex_byte (pkt, len);
- while (len-- > 0)
- {
- ch = *string++;
- if ((ch == '\0') || (ch == '#'))
- ch = '*'; /* Protect encapsulation */
- *pkt++ = ch;
- }
- return pkt;
-}
-#endif /* 0 (unused) */
-
-static char *
-unpack_string (src, dest, length)
- char *src;
- char *dest;
- int length;
-{
- while (length--)
- *dest++ = *src++;
- *dest = '\0';
- return src;
-}
-
-static char *
-pack_threadid (pkt, id)
- char *pkt;
- threadref *id;
-{
- char *limit;
- unsigned char *altid;
-
- altid = (unsigned char *) id;
- limit = pkt + BUF_THREAD_ID_SIZE;
- while (pkt < limit)
- pkt = pack_hex_byte (pkt, *altid++);
- return pkt;
-}
-
-
-static char *
-unpack_threadid (inbuf, id)
- char *inbuf;
- threadref *id;
-{
- char *altref;
- char *limit = inbuf + BUF_THREAD_ID_SIZE;
- int x, y;
-
- altref = (char *) id;
-
- while (inbuf < limit)
- {
- x = stubhex (*inbuf++);
- y = stubhex (*inbuf++);
- *altref++ = (x << 4) | y;
- }
- return inbuf;
-}
-
-/* Externally, threadrefs are 64 bits but internally, they are still
- ints. This is due to a mismatch of specifications. We would like
- to use 64bit thread references internally. This is an adapter
- function. */
-
-void
-int_to_threadref (id, value)
- threadref *id;
- int value;
-{
- unsigned char *scan;
-
- scan = (unsigned char *) id;
- {
- int i = 4;
- while (i--)
- *scan++ = 0;
- }
- *scan++ = (value >> 24) & 0xff;
- *scan++ = (value >> 16) & 0xff;
- *scan++ = (value >> 8) & 0xff;
- *scan++ = (value & 0xff);
-}
-
-static int
-threadref_to_int (ref)
- threadref *ref;
-{
- int i, value = 0;
- unsigned char *scan;
-
- scan = (char *) ref;
- scan += 4;
- i = 4;
- while (i-- > 0)
- value = (value << 8) | ((*scan++) & 0xff);
- return value;
-}
-
-static void
-copy_threadref (dest, src)
- threadref *dest;
- threadref *src;
-{
- int i;
- unsigned char *csrc, *cdest;
-
- csrc = (unsigned char *) src;
- cdest = (unsigned char *) dest;
- i = 8;
- while (i--)
- *cdest++ = *csrc++;
-}
-
-static int
-threadmatch (dest, src)
- threadref *dest;
- threadref *src;
-{
- /* things are broken right now, so just assume we got a match */
-#if 0
- unsigned char *srcp, *destp;
- int i, result;
- srcp = (char *) src;
- destp = (char *) dest;
-
- result = 1;
- while (i-- > 0)
- result &= (*srcp++ == *destp++) ? 1 : 0;
- return result;
-#endif
- return 1;
-}
-
-/*
- threadid:1, # always request threadid
- context_exists:2,
- display:4,
- unique_name:8,
- more_display:16
-*/
-
-/* Encoding: 'Q':8,'P':8,mask:32,threadid:64 */
-
-static char *
-pack_threadinfo_request (pkt, mode, id)
- char *pkt;
- int mode;
- threadref *id;
-{
- *pkt++ = 'q'; /* Info Query */
- *pkt++ = 'P'; /* process or thread info */
- pkt = pack_int (pkt, mode); /* mode */
- pkt = pack_threadid (pkt, id); /* threadid */
- *pkt = '\0'; /* terminate */
- return pkt;
-}
-
-/* These values tag the fields in a thread info response packet */
-/* Tagging the fields allows us to request specific fields and to
- add more fields as time goes by */
-
-#define TAG_THREADID 1 /* Echo the thread identifier */
-#define TAG_EXISTS 2 /* Is this process defined enough to
- fetch registers and its stack */
-#define TAG_DISPLAY 4 /* A short thing maybe to put on a window */
-#define TAG_THREADNAME 8 /* string, maps 1-to-1 with a thread is */
-#define TAG_MOREDISPLAY 16 /* Whatever the kernel wants to say about
- the process*/
-
-static int
-remote_unpack_thread_info_response (pkt, expectedref, info)
- char *pkt;
- threadref *expectedref;
- struct gdb_ext_thread_info *info;
-{
- int mask, length;
- unsigned int tag;
- threadref ref;
- char *limit = pkt + PBUFSIZ; /* plausable parsing limit */
- int retval = 1;
-
- /* info->threadid = 0; FIXME: implement zero_threadref */
- info->active = 0;
- info->display[0] = '\0';
- info->shortname[0] = '\0';
- info->more_display[0] = '\0';
-
- /* Assume the characters indicating the packet type have been stripped */
- pkt = unpack_int (pkt, &mask); /* arg mask */
- pkt = unpack_threadid (pkt, &ref);
-
- if (mask == 0)
- warning ("Incomplete response to threadinfo request\n");
- if (!threadmatch (&ref, expectedref))
- { /* This is an answer to a different request */
- warning ("ERROR RMT Thread info mismatch\n");
- return 0;
- }
- copy_threadref (&info->threadid, &ref);
-
- /* Loop on tagged fields , try to bail if somthing goes wrong */
-
- while ((pkt < limit) && mask && *pkt) /* packets are terminated with nulls */
- {
- pkt = unpack_int (pkt, &tag); /* tag */
- pkt = unpack_byte (pkt, &length); /* length */
- if (!(tag & mask)) /* tags out of synch with mask */
- {
- warning ("ERROR RMT: threadinfo tag mismatch\n");
- retval = 0;
- break;
- }
- if (tag == TAG_THREADID)
- {
- if (length != 16)
- {
- warning ("ERROR RMT: length of threadid is not 16\n");
- retval = 0;
- break;
- }
- pkt = unpack_threadid (pkt, &ref);
- mask = mask & ~TAG_THREADID;
- continue;
- }
- if (tag == TAG_EXISTS)
- {
- info->active = stub_unpack_int (pkt, length);
- pkt += length;
- mask = mask & ~(TAG_EXISTS);
- if (length > 8)
- {
- warning ("ERROR RMT: 'exists' length too long\n");
- retval = 0;
- break;
- }
- continue;
- }
- if (tag == TAG_THREADNAME)
- {
- pkt = unpack_string (pkt, &info->shortname[0], length);
- mask = mask & ~TAG_THREADNAME;
- continue;
- }
- if (tag == TAG_DISPLAY)
- {
- pkt = unpack_string (pkt, &info->display[0], length);
- mask = mask & ~TAG_DISPLAY;
- continue;
- }
- if (tag == TAG_MOREDISPLAY)
- {
- pkt = unpack_string (pkt, &info->more_display[0], length);
- mask = mask & ~TAG_MOREDISPLAY;
- continue;
- }
- warning ("ERROR RMT: unknown thread info tag\n");
- break; /* Not a tag we know about */
- }
- return retval;
-}
-
-static int
-remote_get_threadinfo (threadid, fieldset, info)
- threadref *threadid;
- int fieldset; /* TAG mask */
- struct gdb_ext_thread_info *info;
-{
- int result;
- char threadinfo_pkt[PBUFSIZ];
-
- pack_threadinfo_request (threadinfo_pkt, fieldset, threadid);
- putpkt (threadinfo_pkt);
- getpkt (threadinfo_pkt, 0);
- result = remote_unpack_thread_info_response (threadinfo_pkt + 2, threadid,
- info);
- return result;
-}
-
-/* Unfortunately, 61 bit thread-ids are bigger than the internal
- representation of a threadid. */
-
-static int
-adapt_remote_get_threadinfo (ref, selection, info)
- gdb_threadref *ref;
- int selection;
- struct gdb_ext_thread_info *info;
-{
- threadref lclref;
-
- int_to_threadref (&lclref, *ref);
- return remote_get_threadinfo (&lclref, selection, info);
-}
-
-/* Format: i'Q':8,i"L":8,initflag:8,batchsize:16,lastthreadid:32 */
-
-static char *
-pack_threadlist_request (pkt, startflag, threadcount, nextthread)
- char *pkt;
- int startflag;
- int threadcount;
- threadref *nextthread;
-{
- *pkt++ = 'q'; /* info query packet */
- *pkt++ = 'L'; /* Process LIST or threadLIST request */
- pkt = pack_nibble (pkt, startflag); /* initflag 1 bytes */
- pkt = pack_hex_byte (pkt, threadcount); /* threadcount 2 bytes */
- pkt = pack_threadid (pkt, nextthread); /* 64 bit thread identifier */
- *pkt = '\0';
- return pkt;
-}
-
-/* Encoding: 'q':8,'M':8,count:16,done:8,argthreadid:64,(threadid:64)* */
-
-static int
-parse_threadlist_response (pkt, result_limit, original_echo, resultlist,
- doneflag)
- char *pkt;
- int result_limit;
- threadref *original_echo;
- threadref *resultlist;
- int *doneflag;
-{
- char *limit;
- int count, resultcount, done;
-
- resultcount = 0;
- /* Assume the 'q' and 'M chars have been stripped. */
- limit = pkt + (PBUFSIZ - BUF_THREAD_ID_SIZE); /* done parse past here */
- pkt = unpack_byte (pkt, &count); /* count field */
- pkt = unpack_nibble (pkt, &done);
- /* The first threadid is the argument threadid. */
- pkt = unpack_threadid (pkt, original_echo); /* should match query packet */
- while ((count-- > 0) && (pkt < limit))
- {
- pkt = unpack_threadid (pkt, resultlist++);
- if (resultcount++ >= result_limit)
- break;
- }
- if (doneflag)
- *doneflag = done;
- return resultcount;
-}
-
-static int
-remote_get_threadlist (startflag, nextthread, result_limit,
- done, result_count, threadlist)
- int startflag;
- threadref *nextthread;
- int result_limit;
- int *done;
- int *result_count;
- threadref *threadlist;
-
-{
- static threadref echo_nextthread;
- char threadlist_packet[PBUFSIZ];
- char t_response[PBUFSIZ];
- int result = 1;
-
- /* Trancate result limit to be smaller than the packet size */
- if ((((result_limit + 1) * BUF_THREAD_ID_SIZE) + 10) >= PBUFSIZ)
- result_limit = (PBUFSIZ / BUF_THREAD_ID_SIZE) - 2;
-
- pack_threadlist_request (threadlist_packet,
- startflag, result_limit, nextthread);
- putpkt (threadlist_packet);
- getpkt (t_response, 0);
-
- *result_count =
- parse_threadlist_response (t_response + 2, result_limit, &echo_nextthread,
- threadlist, done);
-
- if (!threadmatch (&echo_nextthread, nextthread))
- {
- /* FIXME: This is a good reason to drop the packet */
- /* Possably, there is a duplicate response */
- /* Possabilities :
- retransmit immediatly - race conditions
- retransmit after timeout - yes
- exit
- wait for packet, then exit
- */
- warning ("HMM: threadlist did not echo arg thread, dropping it\n");
- return 0; /* I choose simply exiting */
- }
- if (*result_count <= 0)
- {
- if (*done != 1)
- {
- warning ("RMT ERROR : failed to get remote thread list\n");
- result = 0;
- }
- return result; /* break; */
- }
- if (*result_count > result_limit)
- {
- *result_count = 0;
- warning ("RMT ERROR: threadlist response longer than requested\n");
- return 0;
- }
- return result;
-}
-
-/* This is the interface between remote and threads, remotes upper interface */
-
-/* remote_find_new_threads retrieves the thread list and for each
- thread in the list, looks up the thread in GDB's internal list,
- ading the thread if it does not already exist. This involves
- getting partial thread lists from the remote target so, polling the
- quit_flag is required. */
-
-
-/* About this many threadisds fit in a packet. */
-
-#define MAXTHREADLISTRESULTS 32
-
-static int
-remote_threadlist_iterator (stepfunction, context, looplimit)
- rmt_thread_action stepfunction;
- void *context;
- int looplimit;
-{
- int done, i, result_count;
- int startflag = 1;
- int result = 1;
- int loopcount = 0;
- static threadref nextthread;
- static threadref resultthreadlist[MAXTHREADLISTRESULTS];
-
- done = 0;
- while (!done)
- {
- if (loopcount++ > looplimit)
- {
- result = 0;
- warning ("Remote fetch threadlist -infinite loop-\n");
- break;
- }
- if (!remote_get_threadlist (startflag, &nextthread, MAXTHREADLISTRESULTS,
- &done, &result_count, resultthreadlist))
- {
- result = 0;
- break;
- }
- /* clear for later iterations */
- startflag = 0;
- /* Setup to resume next batch of thread references, set nextthread. */
- if (result_count >= 1)
- copy_threadref (&nextthread, &resultthreadlist[result_count - 1]);
- i = 0;
- while (result_count--)
- if (!(result = (*stepfunction) (&resultthreadlist[i++], context)))
- break;
- }
- return result;
-}
-
-static int
-remote_newthread_step (ref, context)
- threadref *ref;
- void *context;
-{
- int pid;
-
- pid = threadref_to_int (ref);
- if (!in_thread_list (pid))
- add_thread (pid);
- return 1; /* continue iterator */
-}
-
-#define CRAZY_MAX_THREADS 1000
-
-static int
-remote_current_thread (oldpid)
- int oldpid;
-{
- char buf[PBUFSIZ];
-
- putpkt ("qC");
- getpkt (buf, 0);
- if (buf[0] == 'Q' && buf[1] == 'C')
- return strtol (&buf[2], NULL, 16);
- else
- return oldpid;
-}
-
-int
-remote_find_new_threads ()
-{
- int ret;
-
- ret = remote_threadlist_iterator (remote_newthread_step, 0,
- CRAZY_MAX_THREADS);
- if (inferior_pid == MAGIC_NULL_PID) /* ack ack ack */
- inferior_pid = remote_current_thread (inferior_pid);
- return ret;
-}
-
-/* Initialize the thread vector which is used by threads.c */
-/* The thread stub is a package, it has an initializer */
-
-static void
-init_remote_threads ()
-{
- remote_thread_vec.find_new_threads = remote_find_new_threads;
- remote_thread_vec.get_thread_info = adapt_remote_get_threadinfo;
-}
-
-
/* Restart the remote side; this is an extended protocol operation. */
static void
@@ -1293,61 +577,32 @@ remote_close (quitting)
static void
get_offsets ()
{
- char buf[PBUFSIZ], *ptr;
- int lose;
+ char buf[PBUFSIZ];
+ int nvals;
CORE_ADDR text_addr, data_addr, bss_addr;
struct section_offsets *offs;
+#ifdef REMOTE_CHAT
+ if (remote_chat)
+ (void) remote_talk();
+#endif /* REMOTE_CHAT */
+
putpkt ("qOffsets");
getpkt (buf, 0);
if (buf[0] == '\000')
- return; /* Return silently. Stub doesn't support
- this command. */
+ return; /* Return silently. Stub doesn't support this
+ command. */
if (buf[0] == 'E')
{
warning ("Remote failure reply: %s", buf);
return;
}
- /* Pick up each field in turn. This used to be done with scanf, but
- scanf will make trouble if CORE_ADDR size doesn't match
- conversion directives correctly. The following code will work
- with any size of CORE_ADDR. */
- text_addr = data_addr = bss_addr = 0;
- ptr = buf;
- lose = 0;
-
- if (strncmp (ptr, "Text=", 5) == 0)
- {
- ptr += 5;
- /* Don't use strtol, could lose on big values. */
- while (*ptr && *ptr != ';')
- text_addr = (text_addr << 4) + fromhex (*ptr++);
- }
- else
- lose = 1;
-
- if (!lose && strncmp (ptr, ";Data=", 6) == 0)
- {
- ptr += 6;
- while (*ptr && *ptr != ';')
- data_addr = (data_addr << 4) + fromhex (*ptr++);
- }
- else
- lose = 1;
-
- if (!lose && strncmp (ptr, ";Bss=", 5) == 0)
- {
- ptr += 5;
- while (*ptr && *ptr != ';')
- bss_addr = (bss_addr << 4) + fromhex (*ptr++);
- }
- else
- lose = 1;
-
- if (lose)
+ nvals = sscanf (buf, "Text=%lx;Data=%lx;Bss=%lx", &text_addr, &data_addr,
+ &bss_addr);
+ if (nvals != 3)
error ("Malformed response to offset query, %s", buf);
if (symfile_objfile == NULL)
@@ -1377,7 +632,7 @@ get_offsets ()
static int
remote_start_remote (dummy)
- PTR dummy;
+ char *dummy;
{
immediate_quit = 1; /* Allow user to interrupt it */
@@ -1387,8 +642,6 @@ remote_start_remote (dummy)
/* Let the stub know that we want it to return the thread. */
set_thread (-1, 0);
- inferior_pid = remote_current_thread (inferior_pid);
-
get_offsets (); /* Get text, data & bss offsets */
putpkt ("?"); /* initiate a query from remote machine */
@@ -1406,7 +659,7 @@ remote_open (name, from_tty)
char *name;
int from_tty;
{
- remote_open_1 (name, from_tty, &remote_ops, 0);
+ remote_open_1 (name, from_tty, &remote_ops);
}
/* Open a connection to a remote debugger using the extended
@@ -1417,23 +670,29 @@ extended_remote_open (name, from_tty)
char *name;
int from_tty;
{
- remote_open_1 (name, from_tty, &extended_remote_ops, 1/*extended_p*/);
+ char buf[PBUFSIZ];
+
+ /* Do the basic remote open stuff. */
+ remote_open_1 (name, from_tty, &extended_remote_ops);
+
+ /* Now tell the remote that we're using the extended protocol. */
+ putpkt ("!");
+ getpkt (buf, 0);
+
}
/* Generic code for opening a connection to a remote target. */
-
static DCACHE *remote_dcache;
static void
-remote_open_1 (name, from_tty, target, extended_p)
+remote_open_1 (name, from_tty, target)
char *name;
int from_tty;
struct target_ops *target;
- int extended_p;
{
if (name == 0)
- error ("To open a remote debug connection, you need to specify what\n\
-serial device is attached to the remote system (e.g. /dev/ttya).");
+ 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);
@@ -1469,50 +728,28 @@ serial device is attached to the remote system (e.g. /dev/ttya).");
}
push_target (target); /* Switch to using remote target now */
- /* The target vector does not have the thread functions in it yet,
- so we use this function to call back into the thread module and
- register the thread vector and its contained functions. */
- bind_target_thread_vector (&remote_thread_vec);
-
- /* Start out by trying the 'P' request to set registers. We set
- this each time that we open a new target so that if the user
- switches from one stub to another, we can (if the target is
- closed and reopened) cope. */
+ /* Start out by trying the 'P' request to set registers. We set this each
+ time that we open a new target so that if the user switches from one
+ stub to another, we can (if the target is closed and reopened) cope. */
stub_supports_P = 1;
general_thread = -2;
cont_thread = -2;
- /* Force remote_write_bytes to check whether target supports
- binary downloading. */
- remote_binary_checked = 0;
+ /* Without this, some commands which require an active target (such as kill)
+ won't work. This variable serves (at least) double duty as both the pid
+ of the target process (if it has such), and as a flag indicating that a
+ target is active. These functions should be split out into seperate
+ variables, especially since GDB will someday have a notion of debugging
+ several processes. */
- /* Without this, some commands which require an active target (such
- as kill) won't work. This variable serves (at least) double duty
- as both the pid of the target process (if it has such), and as a
- flag indicating that a target is active. These functions should
- be split out into seperate variables, especially since GDB will
- someday have a notion of debugging several processes. */
-
- inferior_pid = MAGIC_NULL_PID;
+ inferior_pid = 42000;
/* Start the remote connection; if error (0), discard this target.
In particular, if the user quits, be sure to discard it
(we'd be in an inconsistent state otherwise). */
- if (!catch_errors (remote_start_remote, NULL,
- "Couldn't establish connection to remote target\n",
- RETURN_MASK_ALL))
- {
- pop_target ();
- return;
- }
-
- if (extended_p)
- {
- /* tell the remote that we're using the extended protocol. */
- char buf[PBUFSIZ];
- putpkt ("!");
- getpkt (buf, 0);
- }
+ if (!catch_errors (remote_start_remote, (char *)0,
+ "Couldn't establish connection to remote target\n", RETURN_MASK_ALL))
+ pop_target();
}
/* This takes a program previously attached to and detaches it. After
@@ -1541,7 +778,7 @@ remote_detach (args, from_tty)
/* Convert hex digit A to a number. */
-int
+static int
fromhex (a)
int a;
{
@@ -1549,8 +786,6 @@ fromhex (a)
return a - '0';
else if (a >= 'a' && a <= 'f')
return a - 'a' + 10;
- else if (a >= 'A' && a <= 'F')
- return a - 'A' + 10;
else
error ("Reply contains invalid hex digit %d", a);
}
@@ -1570,8 +805,7 @@ tohex (nib)
/* Tell the remote machine to resume. */
static enum target_signal last_sent_signal = TARGET_SIGNAL_0;
-
-static int last_sent_step;
+int last_sent_step;
static void
remote_resume (pid, step, siggnal)
@@ -1581,20 +815,15 @@ remote_resume (pid, step, siggnal)
char buf[PBUFSIZ];
if (pid == -1)
- set_thread (0, 0); /* run any thread */
+ set_thread (inferior_pid, 0);
else
- set_thread (pid, 0); /* run this thread */
+ set_thread (pid, 0);
dcache_flush (remote_dcache);
last_sent_signal = siggnal;
last_sent_step = step;
- /* A hook for when we need to do something at the last moment before
- resumption. */
- if (target_resume_hook)
- (*target_resume_hook) ();
-
if (siggnal != TARGET_SIGNAL_0)
{
buf[0] = step ? 'S' : 'C';
@@ -1611,39 +840,35 @@ remote_resume (pid, step, siggnal)
/* Send ^C to target to halt it. Target will respond, and send us a
packet. */
-static void (*ofunc) PARAMS ((int));
-
static void
remote_interrupt (signo)
int signo;
{
- remote_stop ();
- signal (signo, remote_interrupt);
-}
+ /* If this doesn't work, try more severe steps. */
+ signal (signo, remote_interrupt_twice);
+ if (remote_debug)
+ printf_unfiltered ("remote_interrupt called\n");
+
+ /* Send a break or a ^C, depending on user preference. */
+ if (remote_break)
+ SERIAL_SEND_BREAK (remote_desc);
+ else
+ SERIAL_WRITE (remote_desc, "\003", 1);
+}
+
+static void (*ofunc)();
+
+/* The user typed ^C twice. */
static void
-remote_stop ()
+remote_interrupt_twice (signo)
+ int signo;
{
- if (!interrupted_already)
- {
- /* Send a break or a ^C, depending on user preference. */
- interrupted_already = 1;
-
- if (remote_debug)
- printf_unfiltered ("remote_stop called\n");
+ signal (signo, ofunc);
+
+ interrupt_query ();
- if (remote_break)
- SERIAL_SEND_BREAK (remote_desc);
- else
- SERIAL_WRITE (remote_desc, "\003", 1);
- }
- else
- {
- signal (SIGINT, ofunc);
- interrupt_query ();
- signal (SIGINT, remote_interrupt);
- interrupted_already = 0;
- }
+ signal (signo, remote_interrupt);
}
/* Ask the user what to do when an interrupt is received. */
@@ -1664,31 +889,12 @@ Give up (and stop debugging it)? "))
}
/* If nonzero, ignore the next kill. */
-
int kill_kludge;
-void
-remote_console_output (msg)
- char *msg;
-{
- char *p;
-
- for (p = msg; *p; p +=2)
- {
- char tb[2];
- char c = fromhex (p[0]) * 16 + fromhex (p[1]);
- tb[0] = c;
- tb[1] = 0;
- if (target_output_hook)
- target_output_hook (tb);
- else
- fputs_filtered (tb, gdb_stdout);
- }
-}
-
-/* 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). */
+/* 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). */
static int
remote_wait (pid, status)
@@ -1705,16 +911,15 @@ remote_wait (pid, status)
{
unsigned char *p;
- interrupted_already = 0;
- ofunc = signal (SIGINT, remote_interrupt);
+#ifdef REMOTE_CHAT
+ if (remote_chat)
+ (void) remote_talk();
+#endif /* REMOTE_CHAT */
+
+ ofunc = (void (*)()) signal (SIGINT, remote_interrupt);
getpkt ((char *) buf, 1);
signal (SIGINT, ofunc);
- /* This is a hook for when we need to do something (perhaps the
- collection of trace data) every time the target stops. */
- if (target_wait_loop_hook)
- (*target_wait_loop_hook) ();
-
switch (buf[0])
{
case 'E': /* Error of some sort */
@@ -1732,6 +937,7 @@ remote_wait (pid, status)
n... = register number
r... = register contents
*/
+
p = &buf[3]; /* after Txx */
while (*p)
@@ -1739,22 +945,20 @@ remote_wait (pid, status)
unsigned char *p1;
char *p_temp;
- /* Read the register number */
- regno = strtol ((const char *) p, &p_temp, 16);
+ regno = strtol ((const char *) p, &p_temp, 16); /* Read the register number */
p1 = (unsigned char *)p_temp;
- if (p1 == p) /* No register number present here */
+ if (p1 == p)
{
p1 = (unsigned char *) strchr ((const char *) p, ':');
if (p1 == NULL)
- warning ("Malformed packet(a) (missing colon): %s\n\
+ warning ("Malformed packet (missing colon): %s\n\
Packet: '%s'\n",
p, buf);
if (strncmp ((const char *) p, "thread", p1 - p) == 0)
{
- p_temp = unpack_varlen_hex (++p1, &thread_num);
- record_currthread (thread_num);
- p = (unsigned char *) p_temp;
+ thread_num = strtol ((const char *) ++p1, &p_temp, 16);
+ p = (unsigned char *)p_temp;
}
}
else
@@ -1762,7 +966,7 @@ Packet: '%s'\n",
p = p1;
if (*p++ != ':')
- warning ("Malformed packet(b) (missing colon): %s\n\
+ warning ("Malformed packet (missing colon): %s\n\
Packet: '%s'\n",
p, buf);
@@ -1782,10 +986,7 @@ Packet: '%s'\n",
}
if (*p++ != ';')
- {
- warning ("Remote register badly formatted: %s", buf);
- warning (" here: %s",p);
- }
+ warning ("Remote register badly formatted: %s", buf);
}
}
/* fall through */
@@ -1810,7 +1011,17 @@ Packet: '%s'\n",
goto got_status;
case 'O': /* Console output */
- remote_console_output (buf + 1);
+ for (p = buf + 1; *p; p +=2)
+ {
+ char tb[2];
+ char c = fromhex (p[0]) * 16 + fromhex (p[1]);
+ tb[0] = c;
+ tb[1] = 0;
+ if (target_output_hook)
+ target_output_hook (tb);
+ else
+ fputs_filtered (tb, gdb_stdout);
+ }
continue;
case '\0':
if (last_sent_signal != TARGET_SIGNAL_0)
@@ -1840,11 +1051,10 @@ Packet: '%s'\n",
/* Initial thread value can only be acquired via wait, so deal with
this marker which is used before the first thread value is
acquired. */
- if (inferior_pid == MAGIC_NULL_PID)
+ if (inferior_pid == 42000)
{
inferior_pid = thread_num;
- if (!in_thread_list (inferior_pid))
- add_thread (inferior_pid);
+ add_thread (inferior_pid);
}
return thread_num;
}
@@ -1852,12 +1062,10 @@ Packet: '%s'\n",
}
/* Number of bytes of registers this stub implements. */
-
static int register_bytes_found;
/* Read the remote registers into the block REGS. */
/* Currently we just read all the registers, so we don't use regno. */
-
/* ARGSUSED */
static void
remote_fetch_registers (regno)
@@ -1873,9 +1081,6 @@ remote_fetch_registers (regno)
sprintf (buf, "g");
remote_send (buf);
- if (remote_register_buf_size == 0)
- remote_register_buf_size = strlen (buf);
-
/* Unimplemented registers read as all bits zero. */
memset (regs, 0, REGISTER_BYTES);
@@ -1883,8 +1088,7 @@ remote_fetch_registers (regno)
in the buffer is not a hex character, assume that has happened
and try to fetch another packet to read. */
while ((buf[0] < '0' || buf[0] > '9')
- && (buf[0] < 'a' || buf[0] > 'f')
- && buf[0] != 'x') /* New: unavailable register value */
+ && (buf[0] < 'a' || buf[0] > 'f'))
{
if (remote_debug)
printf_unfiltered ("Bad register packet; fetching a new packet\n");
@@ -1907,10 +1111,7 @@ remote_fetch_registers (regno)
print a second warning. */
goto supply_them;
}
- if (p[0] == 'x' && p[1] == 'x')
- regs[i] = 0; /* 'x' */
- else
- regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
+ regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
p += 2;
}
@@ -1922,14 +1123,10 @@ remote_fetch_registers (regno)
warning ("Remote reply is too short: %s", buf);
#endif
}
-
- supply_them:
+
+ supply_them:
for (i = 0; i < NUM_REGS; i++)
- {
supply_register (i, &regs[REGISTER_BYTE(i)]);
- if (buf[REGISTER_BYTE(i) * 2] == 'x')
- register_valid[i] = -1; /* register value not available */
- }
}
/* Prepare to store registers. Since we may send them all (using a
@@ -2000,8 +1197,9 @@ remote_store_registers (regno)
remote_send (buf);
}
-/* Use of the data cache *used* to be disabled because it loses for looking
- at and changing hardware I/O ports and the like. Accepting `volatile'
+/*
+ Use of the data cache *used* to be disabled because it loses for looking at
+ and changing hardware I/O ports and the like. Accepting `volatile'
would perhaps be one way to fix it. Another idea would be to use the
executable file for the text segment (for all SEC_CODE sections?
For all SEC_READONLY sections?). This has problems if you want to
@@ -2009,7 +1207,8 @@ remote_store_registers (regno)
clobbered memory, user downloaded the wrong thing).
Because it speeds so much up, it's now enabled, if you're playing
- with registers you turn it of (set remotecache 0). */
+ with registers you turn it of (set remotecache 0)
+*/
/* Read a word from remote address ADDR and return it.
This goes through the data cache. */
@@ -2035,98 +1234,6 @@ remote_store_word (addr, word)
#endif /* 0 (unused?) */
-
-/* Return the number of hex digits in num. */
-
-static int
-hexnumlen (num)
- ULONGEST num;
-{
- int i;
-
- for (i = 0; num != 0; i++)
- num >>= 4;
-
- return max (i, 1);
-}
-
-/* Set BUF to the hex digits representing NUM. */
-
-static int
-hexnumstr (buf, num)
- char *buf;
- ULONGEST num;
-{
- int i;
- int len = hexnumlen (num);
-
- buf[len] = '\0';
-
- for (i = len - 1; i >= 0; i--)
- {
- buf[i] = "0123456789abcdef" [(num & 0xf)];
- num >>= 4;
- }
-
- return len;
-}
-
-/* Mask all but the least significant REMOTE_ADDRESS_SIZE bits. */
-
-static CORE_ADDR
-remote_address_masked (addr)
- CORE_ADDR addr;
-{
- if (remote_address_size > 0
- && remote_address_size < (sizeof (ULONGEST) * 8))
- {
- /* Only create a mask when that mask can safely be constructed
- in a ULONGEST variable. */
- ULONGEST mask = 1;
- mask = (mask << remote_address_size) - 1;
- addr &= mask;
- }
- return addr;
-}
-
-/* Determine whether the remote target supports binary downloading.
- This is accomplished by sending a no-op memory write of zero length
- to the target at the specified address. It does not suffice to send
- the whole packet, since many stubs strip the eighth bit and subsequently
- compute a wrong checksum, which causes real havoc with remote_write_bytes. */
-static void
-check_binary_download (addr)
- CORE_ADDR addr;
-{
- if (remote_binary_download && !remote_binary_checked)
- {
- char buf[PBUFSIZ], *p;
- remote_binary_checked = 1;
-
- p = buf;
- *p++ = 'X';
- p += hexnumstr (p, (ULONGEST) addr);
- *p++ = ',';
- p += hexnumstr (p, (ULONGEST) 0);
- *p++ = ':';
- *p = '\0';
-
- putpkt_binary (buf, (int) (p - buf));
- getpkt (buf, 0);
-
- if (buf[0] == '\0')
- remote_binary_download = 0;
- }
-
- if (remote_debug)
- {
- if (remote_binary_download)
- printf_unfiltered ("binary downloading suppported by target\n");
- else
- printf_unfiltered ("binary downloading NOT suppported by target\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.
@@ -2141,102 +1248,36 @@ remote_write_bytes (memaddr, myaddr, len)
char *myaddr;
int len;
{
- int max_buf_size; /* Max size of packet output buffer */
- int origlen;
-
- /* Verify that the target can support a binary download */
- check_binary_download (memaddr);
-
+ char buf[PBUFSIZ];
+ int i;
+ char *p;
+ int done;
/* Chop the transfer down if necessary */
- max_buf_size = min (remote_write_size, PBUFSIZ);
- if (remote_register_buf_size != 0)
- max_buf_size = min (max_buf_size, remote_register_buf_size);
-
- /* Subtract header overhead from max payload size - $M<memaddr>,<len>:#nn */
- max_buf_size -= 2 + hexnumlen (memaddr + len - 1) + 1 + hexnumlen (len) + 4;
-
- origlen = len;
- while (len > 0)
+ done = 0;
+ while (done < len)
{
- unsigned char buf[PBUFSIZ];
- unsigned char *p, *plen;
- int todo;
- int i;
-
- /* construct "M"<memaddr>","<len>":" */
- /* sprintf (buf, "M%lx,%x:", (unsigned long) memaddr, todo); */
- memaddr = remote_address_masked (memaddr);
- p = buf;
- if (remote_binary_download)
- {
- *p++ = 'X';
- todo = min (len, max_buf_size);
- }
- else
- {
- *p++ = 'M';
- todo = min (len, max_buf_size / 2); /* num bytes that will fit */
- }
-
- p += hexnumstr (p, (ULONGEST) memaddr);
- *p++ = ',';
-
- plen = p; /* remember where len field goes */
- p += hexnumstr (p, (ULONGEST) todo);
- *p++ = ':';
- *p = '\0';
+ int todo = len - done;
+ int cando = PBUFSIZ /2 - 32; /* number of bytes that will fit. */
+ if (todo > cando)
+ todo = cando;
- /* We send target system values byte by byte, in increasing byte
- addresses, each byte encoded as two hex characters (or one
- binary character). */
- if (remote_binary_download)
- {
- int escaped = 0;
- for (i = 0;
- (i < todo) && (i + escaped) < (max_buf_size - 2);
- i++)
- {
- switch (myaddr[i] & 0xff)
- {
- case '$':
- case '#':
- case 0x7d:
- /* These must be escaped */
- escaped++;
- *p++ = 0x7d;
- *p++ = (myaddr[i] & 0xff) ^ 0x20;
- break;
- default:
- *p++ = myaddr[i] & 0xff;
- break;
- }
- }
-
- if (i < todo)
- {
- /* Escape chars have filled up the buffer prematurely,
- and we have actually sent fewer bytes than planned.
- Fix-up the length field of the packet. */
+ /* FIXME-32x64: Need a version of print_address_numeric which puts the
+ result in a buffer like sprintf. */
+ sprintf (buf, "M%lx,%x:", (unsigned long) memaddr + done, todo);
- /* FIXME: will fail if new len is a shorter string than
- old len. */
+ /* We send target system values byte by byte, in increasing byte addresses,
+ each byte encoded as two hex characters. */
- plen += hexnumstr (plen, (ULONGEST) i);
- *plen++ = ':';
- }
- }
- else
+ p = buf + strlen (buf);
+ for (i = 0; i < todo; i++)
{
- for (i = 0; i < todo; i++)
- {
- *p++ = tohex ((myaddr[i] >> 4) & 0xf);
- *p++ = tohex (myaddr[i] & 0xf);
- }
- *p = '\0';
+ *p++ = tohex ((myaddr[i + done] >> 4) & 0xf);
+ *p++ = tohex (myaddr[i + done] & 0xf);
}
+ *p = '\0';
- putpkt_binary (buf, (int) (p - buf));
+ putpkt (buf);
getpkt (buf, 0);
if (buf[0] == 'E')
@@ -2248,14 +1289,9 @@ remote_write_bytes (memaddr, myaddr, len)
errno = EIO;
return 0;
}
-
- /* Increment by i, not by todo, in case escape chars
- caused us to send fewer bytes than we'd planned. */
- myaddr += i;
- memaddr += i;
- len -= i;
+ done += todo;
}
- return origlen;
+ return len;
}
/* Read memory data directly from the remote machine.
@@ -2272,35 +1308,28 @@ remote_read_bytes (memaddr, myaddr, len)
char *myaddr;
int len;
{
- int max_buf_size; /* Max size of packet output buffer */
- int origlen;
-
- /* Chop the transfer down if necessary */
-
- max_buf_size = min (remote_write_size, PBUFSIZ);
- if (remote_register_buf_size != 0)
- max_buf_size = min (max_buf_size, remote_register_buf_size);
+ char buf[PBUFSIZ];
+ int i;
+ char *p;
+ int done;
+ /* Chop transfer down if neccessary */
- origlen = len;
- while (len > 0)
+#if 0
+ /* FIXME: This is wrong for larger packets */
+ if (len > PBUFSIZ / 2 - 1)
+ abort ();
+#endif
+ done = 0;
+ while (done < len)
{
- char buf[PBUFSIZ];
- char *p;
- int todo;
- int i;
-
- todo = min (len, max_buf_size / 2); /* num bytes that will fit */
-
- /* construct "m"<memaddr>","<len>" */
- /* sprintf (buf, "m%lx,%x", (unsigned long) memaddr, todo); */
- memaddr = remote_address_masked (memaddr);
- p = buf;
- *p++ = 'm';
- p += hexnumstr (p, (ULONGEST) memaddr);
- *p++ = ',';
- p += hexnumstr (p, (ULONGEST) todo);
- *p = '\0';
-
+ int todo = len - done;
+ int cando = PBUFSIZ / 2 - 32; /* number of bytes that will fit. */
+ if (todo > cando)
+ todo = cando;
+
+ /* FIXME-32x64: Need a version of print_address_numeric which puts the
+ result in a buffer like sprintf. */
+ sprintf (buf, "m%lx,%x", (unsigned long) memaddr + done, todo);
putpkt (buf);
getpkt (buf, 0);
@@ -2321,45 +1350,31 @@ remote_read_bytes (memaddr, myaddr, len)
for (i = 0; i < todo; i++)
{
if (p[0] == 0 || p[1] == 0)
- /* Reply is short. This means that we were able to read
- only part of what we wanted to. */
- return i + (origlen - len);
- myaddr[i] = fromhex (p[0]) * 16 + fromhex (p[1]);
+ /* Reply is short. This means that we were able to read only part
+ of what we wanted to. */
+ return i + done;
+ myaddr[i + done] = fromhex (p[0]) * 16 + fromhex (p[1]);
p += 2;
}
- myaddr += todo;
- memaddr += todo;
- len -= todo;
+ done += todo;
}
- return origlen;
+ return len;
}
-/* 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. */
+/* 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. */
/* ARGSUSED */
static int
-remote_xfer_memory (memaddr, myaddr, len, should_write, target)
+remote_xfer_memory(memaddr, myaddr, len, should_write, target)
CORE_ADDR memaddr;
char *myaddr;
int len;
int should_write;
struct target_ops *target; /* ignored */
{
-#ifdef REMOTE_TRANSLATE_XFER_ADDRESS
- CORE_ADDR targaddr;
- int targlen;
- REMOTE_TRANSLATE_XFER_ADDRESS (memaddr, len, targaddr, targlen);
- if (targlen == 0)
- return 0;
- memaddr = targaddr;
- len = targlen;
-#endif
-
- return dcache_xfer_memory (remote_dcache, memaddr, myaddr,
- len, should_write);
+ return dcache_xfer_memory (remote_dcache, memaddr, myaddr, len, should_write);
}
@@ -2470,8 +1485,9 @@ readchar (timeout)
}
}
-/* Send the command in BUF to the remote machine, and read the reply
- into BUF. Report an error if we get an error reply. */
+/* 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)
@@ -2484,39 +1500,17 @@ remote_send (buf)
error ("Remote failure reply: %s", buf);
}
-/* Display a null-terminated packet on stdout, for debugging, using C
- string notation. */
-
-static void
-print_packet (buf)
- char *buf;
-{
- puts_filtered ("\"");
- while (*buf)
- gdb_printchar (*buf++, gdb_stdout, '"');
- puts_filtered ("\"");
-}
-
-int
-putpkt (buf)
- char *buf;
-{
- return putpkt_binary (buf, strlen (buf));
-}
-
-/* Send a packet to the remote machine, with error checking. The data
- of the packet is in BUF. The string in BUF can be at most PBUFSIZ - 5
- to account for the $, # and checksum, and for a possible /0 if we are
- debugging (remote_debug) and want to print the sent packet as a string */
+/* Send a packet to the remote machine, with error checking.
+ The data of the packet is in BUF. */
static int
-putpkt_binary (buf, cnt)
+putpkt (buf)
char *buf;
- int cnt;
{
int i;
unsigned char csum = 0;
char buf2[PBUFSIZ];
+ int cnt = strlen (buf);
int ch;
int tcount = 0;
char *p;
@@ -2525,7 +1519,7 @@ putpkt_binary (buf, cnt)
and giving it a checksum. */
if (cnt > (int) sizeof (buf2) - 5) /* Prosanity check */
- abort ();
+ abort();
p = buf2;
*p++ = '$';
@@ -2549,7 +1543,7 @@ putpkt_binary (buf, cnt)
{
*p = '\0';
printf_unfiltered ("Sending packet: %s...", buf2);
- gdb_flush (gdb_stdout);
+ gdb_flush(gdb_stdout);
}
if (SERIAL_WRITE (remote_desc, buf2, p - buf2))
perror_with_name ("putpkt: write failed");
@@ -2578,7 +1572,7 @@ putpkt_binary (buf, cnt)
{
case '+':
if (remote_debug)
- printf_unfiltered ("Ack\n");
+ printf_unfiltered("Ack\n");
return 1;
case SERIAL_TIMEOUT:
tcount ++;
@@ -2589,11 +1583,21 @@ putpkt_binary (buf, cnt)
{
char junkbuf[PBUFSIZ];
- /* It's probably an old response, and we're out of sync.
- Just gobble up the packet and ignore it. */
+ /* It's probably an old response, and we're out of sync. Just
+ gobble up the packet and ignore it. */
getpkt (junkbuf, 0);
continue; /* Now, go look for + */
}
+
+#ifdef REMOTE_CHAT
+ case '|':
+ {
+ if (!started_error_output)
+ continue;
+ /* else fall through */
+ }
+#endif /* REMOTE_CHAT */
+
default:
if (remote_debug)
{
@@ -2611,10 +1615,10 @@ putpkt_binary (buf, cnt)
#if 0
/* This is wrong. If doing a long backtrace, the user should be
- able to get out next time we call QUIT, without anything as
- violent as interrupt_query. If we want to provide a way out of
- here without getting to the next QUIT, it should be based on
- hitting ^C twice as in remote_wait. */
+ able to get out next time we call QUIT, without anything as violent
+ as interrupt_query. If we want to provide a way out of here
+ without getting to the next QUIT, it should be based on hitting
+ ^C twice as in remote_wait. */
if (quit_flag)
{
quit_flag = 0;
@@ -2624,9 +1628,9 @@ putpkt_binary (buf, cnt)
}
}
-/* Come here after finding the start of the frame. Collect the rest
- into BUF, verifying the checksum, length, and handling run-length
- compression. Returns 0 on any error, 1 on success. */
+/* Come here after finding the start of the frame. Collect the rest into BUF,
+ verifying the checksum, length, and handling run-length compression.
+ Returns 0 on any error, 1 on success. */
static int
read_frame (buf)
@@ -2712,12 +1716,12 @@ read_frame (buf)
}
}
-/* Read a packet from the remote machine, with error checking, and
- store it in BUF. BUF is expected to be of size PBUFSIZ. If
- FOREVER, wait forever rather than timing out; this is used while
- the target is executing user code. */
+/* Read a packet from the remote machine, with error checking,
+ and store it in BUF. BUF is expected to be of size PBUFSIZ.
+ If FOREVER, wait forever rather than timing out; this is used
+ while the target is executing user code. */
-void
+static void
getpkt (buf, forever)
char *buf;
int forever;
@@ -2780,7 +1784,7 @@ getpkt (buf, forever)
if (val == 1)
{
if (remote_debug)
- fprintf_unfiltered (gdb_stdout, "Packet received: %s\n", buf);
+ fprintf_unfiltered (gdb_stderr, "Packet received: %s\n", buf);
SERIAL_WRITE (remote_desc, "+", 1);
return;
}
@@ -2810,7 +1814,7 @@ remote_kill ()
/* Use catch_errors so the user can quit from gdb even when we aren't on
speaking terms with the remote system. */
- catch_errors ((catch_errors_ftype *) putpkt, "k", "", RETURN_MASK_ERROR);
+ catch_errors (putpkt, "k", "", RETURN_MASK_ERROR);
/* Don't wait for it to die. I'm not really sure it matters whether
we do or not. For the existing stubs, kill is a noop. */
@@ -2877,33 +1881,19 @@ extended_remote_create_inferior (exec_file, args, env)
}
-/* On some machines, e.g. 68k, we may use a different breakpoint instruction
- than other targets; in those use REMOTE_BREAKPOINT instead of just
- BREAKPOINT. Also, bi-endian targets may define LITTLE_REMOTE_BREAKPOINT
- and BIG_REMOTE_BREAKPOINT. If none of these are defined, we just call
- the standard routines that are in mem-break.c. */
-
-/* FIXME, these ought to be done in a more dynamic fashion. For instance,
- the choice of breakpoint instruction affects target program design and
- vice versa, and by making it user-tweakable, the special code here
- goes away and we need fewer special GDB configurations. */
-
-#if defined (LITTLE_REMOTE_BREAKPOINT) && defined (BIG_REMOTE_BREAKPOINT) && !defined(REMOTE_BREAKPOINT)
-#define REMOTE_BREAKPOINT
-#endif
-
#ifdef REMOTE_BREAKPOINT
-/* If the target isn't bi-endian, just pretend it is. */
-#if !defined (LITTLE_REMOTE_BREAKPOINT) && !defined (BIG_REMOTE_BREAKPOINT)
-#define LITTLE_REMOTE_BREAKPOINT REMOTE_BREAKPOINT
-#define BIG_REMOTE_BREAKPOINT REMOTE_BREAKPOINT
-#endif
+/* On some machines, e.g. 68k, we may use a different breakpoint instruction
+ than other targets. */
+static unsigned char break_insn[] = REMOTE_BREAKPOINT;
+
+#else /* No REMOTE_BREAKPOINT. */
-static unsigned char big_break_insn[] = BIG_REMOTE_BREAKPOINT;
-static unsigned char little_break_insn[] = LITTLE_REMOTE_BREAKPOINT;
+/* Same old breakpoint instruction. This code does nothing different
+ than mem-break.c. */
+static unsigned char break_insn[] = BREAKPOINT;
-#endif /* REMOTE_BREAKPOINT */
+#endif /* No REMOTE_BREAKPOINT. */
/* Insert a breakpoint on targets that don't have any better breakpoint
support. We read the contents of the target location and stash it,
@@ -2918,25 +1908,14 @@ remote_insert_breakpoint (addr, contents_cache)
CORE_ADDR addr;
char *contents_cache;
{
-#ifdef REMOTE_BREAKPOINT
int val;
- val = target_read_memory (addr, contents_cache, sizeof big_break_insn);
+ val = target_read_memory (addr, contents_cache, sizeof break_insn);
if (val == 0)
- {
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
- val = target_write_memory (addr, (char *) big_break_insn,
- sizeof big_break_insn);
- else
- val = target_write_memory (addr, (char *) little_break_insn,
- sizeof little_break_insn);
- }
+ val = target_write_memory (addr, (char *)break_insn, sizeof break_insn);
return val;
-#else
- return memory_insert_breakpoint (addr, contents_cache);
-#endif /* REMOTE_BREAKPOINT */
}
static int
@@ -2944,530 +1923,122 @@ remote_remove_breakpoint (addr, contents_cache)
CORE_ADDR addr;
char *contents_cache;
{
-#ifdef REMOTE_BREAKPOINT
- return target_write_memory (addr, contents_cache, sizeof big_break_insn);
-#else
- return memory_remove_breakpoint (addr, contents_cache);
-#endif /* REMOTE_BREAKPOINT */
-}
-
-/* Some targets are only capable of doing downloads, and afterwards
- they switch to the remote serial protocol. This function provides
- a clean way to get from the download target to the remote target.
- It's basically just a wrapper so that we don't have to expose any
- of the internal workings of remote.c.
-
- Prior to calling this routine, you should shutdown the current
- target code, else you will get the "A program is being debugged
- already..." message. Usually a call to pop_target() suffices. */
-
-void
-push_remote_target (name, from_tty)
- char *name;
- int from_tty;
-{
- printf_filtered ("Switching to remote protocol\n");
- remote_open (name, from_tty);
-}
-
-/* Other targets want to use the entire remote serial module but with
- certain remote_ops overridden. */
-
-void
-open_remote_target (name, from_tty, target, extended_p)
- char *name;
- int from_tty;
- struct target_ops *target;
- int extended_p;
-{
- printf_filtered ("Selecting the %sremote protocol\n",
- (extended_p ? "extended-" : ""));
- remote_open_1 (name, from_tty, target, extended_p);
-}
-
-/* Table used by the crc32 function to calcuate the checksum. */
-
-static unsigned long crc32_table[256] = {0, 0};
-
-static unsigned long
-crc32 (buf, len, crc)
- unsigned char *buf;
- int len;
- unsigned int crc;
-{
- if (! crc32_table[1])
- {
- /* Initialize the CRC table and the decoding table. */
- int i, j;
- unsigned int c;
-
- for (i = 0; i < 256; i++)
- {
- for (c = i << 24, j = 8; j > 0; --j)
- c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1);
- crc32_table[i] = c;
- }
- }
-
- while (len--)
- {
- crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ *buf) & 255];
- buf++;
- }
- return crc;
-}
-
-/* compare-sections command
-
- With no arguments, compares each loadable section in the exec bfd
- with the same memory range on the target, and reports mismatches.
- Useful for verifying the image on the target against the exec file.
- Depends on the target understanding the new "qCRC:" request. */
-
-static void
-compare_sections_command (args, from_tty)
- char *args;
- int from_tty;
-{
- asection *s;
- unsigned long host_crc, target_crc;
- extern bfd *exec_bfd;
- struct cleanup *old_chain;
- char *tmp, *sectdata, *sectname, buf[PBUFSIZ];
- bfd_size_type size;
- bfd_vma lma;
- int matched = 0;
- int mismatched = 0;
-
- if (!exec_bfd)
- error ("command cannot be used without an exec file");
- if (!current_target.to_shortname ||
- strcmp (current_target.to_shortname, "remote") != 0)
- error ("command can only be used with remote target");
-
- for (s = exec_bfd->sections; s; s = s->next)
- {
- if (!(s->flags & SEC_LOAD))
- continue; /* skip non-loadable section */
-
- size = bfd_get_section_size_before_reloc (s);
- if (size == 0)
- continue; /* skip zero-length section */
-
- sectname = (char *) bfd_get_section_name (exec_bfd, s);
- if (args && strcmp (args, sectname) != 0)
- continue; /* not the section selected by user */
-
- matched = 1; /* do this section */
- lma = s->lma;
- /* FIXME: assumes lma can fit into long */
- sprintf (buf, "qCRC:%lx,%lx", (long) lma, (long) size);
- putpkt (buf);
-
- /* be clever; compute the host_crc before waiting for target reply */
- sectdata = xmalloc (size);
- old_chain = make_cleanup (free, sectdata);
- bfd_get_section_contents (exec_bfd, s, sectdata, 0, size);
- host_crc = crc32 ((unsigned char *) sectdata, size, 0xffffffff);
-
- getpkt (buf, 0);
- if (buf[0] == 'E')
- error ("target memory fault, section %s, range 0x%08x -- 0x%08x",
- sectname, lma, lma + size);
- if (buf[0] != 'C')
- error ("remote target does not support this operation");
-
- for (target_crc = 0, tmp = &buf[1]; *tmp; tmp++)
- target_crc = target_crc * 16 + fromhex (*tmp);
-
- printf_filtered ("Section %s, range 0x%08x -- 0x%08x: ",
- sectname, lma, lma + size);
- if (host_crc == target_crc)
- printf_filtered ("matched.\n");
- else
- {
- printf_filtered ("MIS-MATCHED!\n");
- mismatched++;
- }
-
- do_cleanups (old_chain);
- }
- if (mismatched > 0)
- warning ("One or more sections of the remote executable does not match\n\
-the loaded file\n");
- if (args && !matched)
- printf_filtered ("No loaded section named '%s'.\n", args);
-}
-
-static int
-remote_query (query_type, buf, outbuf, bufsiz)
- int query_type;
- char *buf;
- char *outbuf;
- int *bufsiz;
-{
- int i;
- char buf2[PBUFSIZ];
- char *p2 = &buf2[0];
- char *p = buf;
-
- if (! bufsiz)
- error ("null pointer to remote bufer size specified");
-
- /* minimum outbuf size is PBUFSIZE - if bufsiz is not large enough let
- the caller know and return what the minimum size is */
- /* Note: a zero bufsiz can be used to query the minimum buffer size */
- if ( *bufsiz < PBUFSIZ )
- {
- *bufsiz = PBUFSIZ;
- return -1;
- }
-
- /* except for querying the minimum buffer size, target must be open */
- if (! remote_desc)
- error ("remote query is only available after target open");
-
- /* we only take uppercase letters as query types, at least for now */
- if ( (query_type < 'A') || (query_type > 'Z') )
- error ("invalid remote query type");
-
- if (! buf)
- error ("null remote query specified");
-
- if (! outbuf)
- error ("remote query requires a buffer to receive data");
-
- outbuf[0] = '\0';
-
- *p2++ = 'q';
- *p2++ = query_type;
-
- /* we used one buffer char for the remote protocol q command and another
- for the query type. As the remote protocol encapsulation uses 4 chars
- plus one extra in case we are debugging (remote_debug),
- we have PBUFZIZ - 7 left to pack the query string */
- i = 0;
- while ( buf[i] && (i < (PBUFSIZ - 8)) )
- {
- /* bad caller may have sent forbidden characters */
- if ( (!isprint(buf[i])) || (buf[i] == '$') || (buf[i] == '#') )
- error ("illegal characters in query string");
-
- *p2++ = buf[i];
- i++;
- }
- *p2 = buf[i];
-
- if ( buf[i] )
- error ("query larger than available buffer");
-
- i = putpkt (buf2);
- if ( i < 0 ) return i;
-
- getpkt (outbuf, 0);
-
- return 0;
-}
-
-static void
-packet_command (args, from_tty)
- char *args;
- int from_tty;
-{
- char buf[PBUFSIZ];
-
- if (! remote_desc)
- error ("command can only be used with remote target");
-
- if (! args)
- error ("remote-packet command requires packet text as argument");
-
- puts_filtered ("sending: ");
- print_packet (args);
- puts_filtered ("\n");
- putpkt (args);
-
- getpkt (buf, 0);
- puts_filtered ("received: ");
- print_packet (buf);
- puts_filtered ("\n");
-}
-
-#if 0
-/* --------- UNIT_TEST for THREAD oriented PACKETS ------------------------- */
-
-static void display_thread_info PARAMS ((struct gdb_ext_thread_info *info));
-
-static void threadset_test_cmd PARAMS ((char *cmd, int tty));
-
-static void threadalive_test PARAMS ((char *cmd, int tty));
-
-static void threadlist_test_cmd PARAMS ((char *cmd, int tty));
-
-int get_and_display_threadinfo PARAMS ((threadref *ref));
-
-static void threadinfo_test_cmd PARAMS ((char *cmd, int tty));
-
-static int thread_display_step PARAMS ((threadref *ref, void *context));
-
-static void threadlist_update_test_cmd PARAMS ((char *cmd, int tty));
-
-static void init_remote_threadtests PARAMS ((void));
-
-#define SAMPLE_THREAD 0x05060708 /* Truncated 64 bit threadid */
-
-static void
-threadset_test_cmd (cmd, tty)
- char *cmd;
- int tty;
-{
- int sample_thread = SAMPLE_THREAD;
-
- printf_filtered ("Remote threadset test\n");
- set_thread (sample_thread, 1);
-}
-
-
-static void
-threadalive_test (cmd, tty)
- char *cmd;
- int tty;
-{
- int sample_thread = SAMPLE_THREAD;
-
- if (remote_thread_alive (sample_thread))
- printf_filtered ("PASS: Thread alive test\n");
- else
- printf_filtered ("FAIL: Thread alive test\n");
-}
-
-void output_threadid PARAMS ((char *title, threadref * ref));
-
-void
-output_threadid (title, ref)
- char *title;
- threadref *ref;
-{
- char hexid[20];
-
- pack_threadid (&hexid[0], ref); /* Convert threead id into hex */
- hexid[16] = 0;
- printf_filtered ("%s %s\n", title, (&hexid[0]));
-}
-
-static void
-threadlist_test_cmd (cmd, tty)
- char *cmd;
- int tty;
-{
- int startflag = 1;
- threadref nextthread;
- int done, result_count;
- threadref threadlist[3];
-
- printf_filtered ("Remote Threadlist test\n");
- if (!remote_get_threadlist (startflag, &nextthread, 3, &done,
- &result_count, &threadlist[0]))
- printf_filtered ("FAIL: threadlist test\n");
- else
- {
- threadref *scan = threadlist;
- threadref *limit = scan + result_count;
-
- while (scan < limit)
- output_threadid (" thread ", scan++);
- }
-}
-
-void
-display_thread_info (info)
- struct gdb_ext_thread_info *info;
-{
- output_threadid ("Threadid: ", &info->threadid);
- printf_filtered ("Name: %s\n ", info->shortname);
- printf_filtered ("State: %s\n", info->display);
- printf_filtered ("other: %s\n\n", info->more_display);
-}
-
-int
-get_and_display_threadinfo (ref)
- threadref *ref;
-{
- int result;
- int set;
- struct gdb_ext_thread_info threadinfo;
-
- set = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME
- | TAG_MOREDISPLAY | TAG_DISPLAY;
- if (0 != (result = remote_get_threadinfo (ref, set, &threadinfo)))
- display_thread_info (&threadinfo);
- return result;
-}
-
-static void
-threadinfo_test_cmd (cmd, tty)
- char *cmd;
- int tty;
-{
- int athread = SAMPLE_THREAD;
- threadref thread;
- int set;
-
- int_to_threadref (&thread, athread);
- printf_filtered ("Remote Threadinfo test\n");
- if (!get_and_display_threadinfo (&thread))
- printf_filtered ("FAIL cannot get thread info\n");
-}
-
-static int
-thread_display_step (ref, context)
- threadref *ref;
- void *context;
-{
- /* output_threadid(" threadstep ",ref); *//* simple test */
- return get_and_display_threadinfo (ref);
-}
-
-static void
-threadlist_update_test_cmd (cmd, tty)
- char *cmd;
- int tty;
-{
- printf_filtered ("Remote Threadlist update test\n");
- remote_threadlist_iterator (thread_display_step, 0, CRAZY_MAX_THREADS);
-}
-
-static void
-init_remote_threadtests (void)
-{
- add_com ("tlist", class_obscure, threadlist_test_cmd,
- "Fetch and print the remote list of thread identifiers, one pkt only");
- add_com ("tinfo", class_obscure, threadinfo_test_cmd,
- "Fetch and display info about one thread");
- add_com ("tset", class_obscure, threadset_test_cmd,
- "Test setting to a different thread");
- add_com ("tupd", class_obscure, threadlist_update_test_cmd,
- "Iterate through updating all remote thread info");
- add_com ("talive", class_obscure, threadalive_test,
- " Remote thread alive test ");
-}
-
-#endif /* 0 */
-
-static void
-init_remote_ops ()
-{
- remote_ops.to_shortname = "remote";
- remote_ops.to_longname = "Remote serial target in gdb-specific protocol";
- remote_ops.to_doc =
- "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).";
- remote_ops.to_open = remote_open;
- remote_ops.to_close = remote_close;
- remote_ops.to_detach = remote_detach;
- remote_ops.to_resume = remote_resume;
- remote_ops.to_wait = remote_wait;
- remote_ops.to_fetch_registers = remote_fetch_registers;
- remote_ops.to_store_registers = remote_store_registers;
- remote_ops.to_prepare_to_store = remote_prepare_to_store;
- remote_ops.to_xfer_memory = remote_xfer_memory;
- remote_ops.to_files_info = remote_files_info;
- remote_ops.to_insert_breakpoint = remote_insert_breakpoint;
- remote_ops.to_remove_breakpoint = remote_remove_breakpoint;
- remote_ops.to_kill = remote_kill;
- remote_ops.to_load = generic_load;
- remote_ops.to_mourn_inferior = remote_mourn;
- remote_ops.to_thread_alive = remote_thread_alive;
- remote_ops.to_stop = remote_stop;
- remote_ops.to_query = remote_query;
- remote_ops.to_stratum = process_stratum;
- remote_ops.to_has_all_memory = 1;
- remote_ops.to_has_memory = 1;
- remote_ops.to_has_stack = 1;
- remote_ops.to_has_registers = 1;
- remote_ops.to_has_execution = 1;
- remote_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */
- remote_ops.to_magic = OPS_MAGIC;
+ return target_write_memory (addr, contents_cache, sizeof break_insn);
}
+
+/* Define the target subroutine names */
-/* Set up the extended remote vector by making a copy of the standard
- remote vector and adding to it. */
-
-static void
-init_extended_remote_ops ()
-{
- extended_remote_ops = remote_ops;
-
- extended_remote_ops.to_shortname = "extended-remote";
- extended_remote_ops.to_longname =
- "Extended remote serial target in gdb-specific protocol";
- extended_remote_ops.to_doc =
- "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
-Specify the serial device it is connected to (e.g. /dev/ttya).",
- extended_remote_ops.to_open = extended_remote_open;
- extended_remote_ops.to_create_inferior = extended_remote_create_inferior;
- extended_remote_ops.to_mourn_inferior = extended_remote_mourn;
-}
+struct target_ops remote_ops = {
+ "remote", /* to_shortname */
+ "Remote serial target in gdb-specific protocol", /* to_longname */
+ "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
+Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
+ remote_open, /* to_open */
+ remote_close, /* to_close */
+ NULL, /* to_attach */
+ remote_detach, /* to_detach */
+ remote_resume, /* to_resume */
+ remote_wait, /* to_wait */
+ remote_fetch_registers, /* to_fetch_registers */
+ remote_store_registers, /* to_store_registers */
+ remote_prepare_to_store, /* to_prepare_to_store */
+ remote_xfer_memory, /* to_xfer_memory */
+ remote_files_info, /* to_files_info */
+ remote_insert_breakpoint, /* to_insert_breakpoint */
+ remote_remove_breakpoint, /* to_remove_breakpoint */
+ NULL, /* to_terminal_init */
+ NULL, /* to_terminal_inferior */
+ NULL, /* to_terminal_ours_for_output */
+ NULL, /* to_terminal_ours */
+ NULL, /* to_terminal_info */
+ remote_kill, /* to_kill */
+ generic_load, /* to_load */
+ NULL, /* to_lookup_symbol */
+ NULL, /* to_create_inferior */
+ remote_mourn, /* to_mourn_inferior */
+ 0, /* to_can_run */
+ 0, /* to_notice_signals */
+ remote_thread_alive, /* to_thread_alive */
+ 0, /* to_stop */
+ process_stratum, /* to_stratum */
+ NULL, /* to_next */
+ 1, /* to_has_all_memory */
+ 1, /* to_has_memory */
+ 1, /* to_has_stack */
+ 1, /* to_has_registers */
+ 1, /* to_has_execution */
+ NULL, /* sections */
+ NULL, /* sections_end */
+ OPS_MAGIC /* to_magic */
+};
+
+struct target_ops extended_remote_ops = {
+ "extended-remote", /* to_shortname */
+ "Extended remote serial target in gdb-specific protocol",/* to_longname */
+ "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
+Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
+ extended_remote_open, /* to_open */
+ remote_close, /* to_close */
+ NULL, /* to_attach */
+ remote_detach, /* to_detach */
+ remote_resume, /* to_resume */
+ remote_wait, /* to_wait */
+ remote_fetch_registers, /* to_fetch_registers */
+ remote_store_registers, /* to_store_registers */
+ remote_prepare_to_store, /* to_prepare_to_store */
+ remote_xfer_memory, /* to_xfer_memory */
+ remote_files_info, /* to_files_info */
+
+ remote_insert_breakpoint, /* to_insert_breakpoint */
+ remote_remove_breakpoint, /* to_remove_breakpoint */
+
+ NULL, /* to_terminal_init */
+ NULL, /* to_terminal_inferior */
+ NULL, /* to_terminal_ours_for_output */
+ NULL, /* to_terminal_ours */
+ NULL, /* to_terminal_info */
+ remote_kill, /* to_kill */
+ generic_load, /* to_load */
+ NULL, /* to_lookup_symbol */
+ extended_remote_create_inferior,/* to_create_inferior */
+ extended_remote_mourn, /* to_mourn_inferior */
+ 0, /* to_can_run */
+ 0, /* to_notice_signals */
+ remote_thread_alive, /* to_thread_alive */
+ 0, /* to_stop */
+ process_stratum, /* to_stratum */
+ NULL, /* to_next */
+ 1, /* to_has_all_memory */
+ 1, /* to_has_memory */
+ 1, /* to_has_stack */
+ 1, /* to_has_registers */
+ 1, /* to_has_execution */
+ NULL, /* sections */
+ NULL, /* sections_end */
+ OPS_MAGIC /* to_magic */
+};
void
_initialize_remote ()
{
- init_remote_ops ();
add_target (&remote_ops);
-
- init_extended_remote_ops ();
add_target (&extended_remote_ops);
- init_remote_threads ();
-#if 0
- init_remote_threadtests ();
-#endif
- add_cmd ("compare-sections", class_obscure, compare_sections_command,
- "Compare section data on target to the exec file.\n\
-Argument is a single section name (default: all loaded sections).",
- &cmdlist);
-
- add_cmd ("packet", class_maintenance, packet_command,
- "Send an arbitrary packet to a remote target.\n\
- maintenance packet TEXT\n\
-If GDB is talking to an inferior via the GDB serial protocol, then\n\
-this command sends the string TEXT to the inferior, and displays the\n\
-response packet. GDB supplies the initial `$' character, and the\n\
-terminating `#' character and checksum.",
- &maintenancelist);
-
- add_show_from_set
- (add_set_cmd ("remotetimeout", no_class,
- var_integer, (char *)&remote_timeout,
- "Set timeout value for remote read.\n",
- &setlist),
- &showlist);
-
- add_show_from_set
- (add_set_cmd ("remotebreak", no_class,
- var_integer, (char *)&remote_break,
- "Set whether to send break if interrupted.\n",
- &setlist),
- &showlist);
-
- add_show_from_set
- (add_set_cmd ("remotewritesize", no_class,
- var_integer, (char *)&remote_write_size,
- "Set the maximum number of bytes per memory write packet.\n",
- &setlist),
- &showlist);
-
- remote_address_size = TARGET_PTR_BIT;
- add_show_from_set
- (add_set_cmd ("remoteaddresssize", class_obscure,
- var_integer, (char *)&remote_address_size,
- "Set the maximum size of the address (in bits) \
-in a memory packet.\n",
- &setlist),
- &showlist);
-
- add_show_from_set (add_set_cmd ("remotebinarydownload", no_class,
- var_boolean, (char *) &remote_binary_download,
- "Set binary downloads.\n", &setlist),
+ add_show_from_set (add_set_cmd ("remotetimeout", no_class,
+ var_integer, (char *)&remote_timeout,
+ "Set timeout value for remote read.\n", &setlist),
&showlist);
+
+ add_show_from_set (add_set_cmd ("remotebreak", no_class,
+ var_integer, (char *)&remote_break,
+ "Set whether to send break if interrupted.\n", &setlist),
+ &showlist);
+
+#ifdef REMOTE_CHAT
+ add_show_from_set (add_set_cmd ("remotechat", no_class,
+ var_zinteger, (char *)&remote_chat,
+ "Set remote port interacts with target.\n", &setlist),
+ &showlist);
+#endif /* REMOTE_CHAT */
}
+
diff --git a/contrib/gdb/gdb/ser-e7kpc.c b/contrib/gdb/gdb/ser-e7kpc.c
deleted file mode 100644
index 8be5db9..0000000
--- a/contrib/gdb/gdb/ser-e7kpc.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/* Remote serial interface using Hitachi E7000 PC ISA card in a PC
- Copyright 1994, 1999 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#if defined __GO32__ || defined _WIN32
-#include "defs.h"
-#include "serial.h"
-#include "gdb_string.h"
-
-/* MSVC uses strnicmp instead of strncasecmp */
-#ifdef _MSC_VER
-#define strncasecmp strnicmp
-#define WIN32_LEAN_AND_MEAN
-#endif
-
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
-#ifdef __GO32__
-#include <sys/dos.h>
-#endif
-
-static int e7000pc_open PARAMS ((serial_t scb, const char *name));
-static void e7000pc_raw PARAMS ((serial_t scb));
-static int e7000pc_readchar PARAMS ((serial_t scb, int timeout));
-static int e7000pc_setbaudrate PARAMS ((serial_t scb, int rate));
-static int e7000pc_write PARAMS ((serial_t scb, const char *str, int len));
-static void e7000pc_close PARAMS ((serial_t scb));
-static serial_ttystate e7000pc_get_tty_state PARAMS ((serial_t scb));
-static int e7000pc_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
-
-#define OFF_DPD 0x0000
-#define OFF_DDP 0x1000
-#define OFF_CPD 0x2000
-#define OFF_CDP 0x2400
-#define OFF_FA 0x3000
-#define OFF_FB 0x3002
-#define OFF_FC 0x3004
-#define OFF_IRQTOD 0x3008
-#define OFF_IRQTOP 0x300a
-#define OFF_READY 0x300c
-#define OFF_PON 0x300e
-
-#define IDLE 0x0000
-#define CMD_CI 0x4349
-#define CMD_CO 0x434f
-#define CMD_LO 0x4c4f
-#define CMD_LS 0x4c53
-#define CMD_SV 0x5356
-#define CMD_SS 0x5353
-#define CMD_OK 0x4f4b
-#define CMD_ER 0x4552
-#define CMD_NF 0x4e46
-#define CMD_AB 0x4142
-#define CMD_ED 0x4544
-#define CMD_CE 0x4345
-
-static unsigned long fa;
-static unsigned long irqtod;
-static unsigned long ready;
-static unsigned long fb;
-static unsigned long cpd ;
-static unsigned long cdp ;
-static unsigned long ready;
-static unsigned long pon;
-static unsigned long irqtop;
-static unsigned long board_at;
-
-#ifdef __GO32__
-
-#define SET_BYTE(x,y) { char _buf = y;dosmemput(&_buf,1, x);}
-#define SET_WORD(x,y) { short _buf = y;dosmemput(&_buf,2, x);}
-#define GET_BYTE(x) ( dosmemget(x,1,&bb), bb)
-#define GET_WORD(x) ( dosmemget(x,2,&sb), sb)
-static unsigned char bb;
-static unsigned short sb;
-
-#else /* win32 */
-
-#define SET_BYTE(x,y) *(volatile unsigned char *)(x) = (y)
-#define SET_WORD(x,y) *(volatile unsigned short *)(x) = (y)
-#define GET_BYTE(x) (*(volatile unsigned char *)(x))
-#define GET_WORD(x) (*(volatile unsigned short *)(x))
-#define dosmemget(FROM, LEN, TO) memcpy ((void *)(TO), (void *)(FROM), (LEN))
-#define dosmemput(FROM, LEN, TO) memcpy ((void *)(TO), (void *)(FROM), (LEN))
-#endif
-
-static struct sw
-{
- int sw;
- int addr;
-} sigs[] = {
- {0x14, 0xd0000},
- {0x15, 0xd4000},
- {0x16, 0xd8000},
- {0x17, 0xdc000},
- 0};
-
-#ifdef _MSC_VER
-/* Get the base of the data segment. This is needed to calculate the offset
- between data segment addresses and the base of linear memory, which is where
- device registers reside. Note that this is really only necessary for
- Win32s, since Win95 and NT keep the data segment at linear 0. */
-
-static unsigned long
-get_ds_base (void)
-{
- unsigned short dsval;
- LDT_ENTRY ldt;
- unsigned long dsbase;
-
- __asm
- {
- mov dsval,ds
- }
-
- dsbase = 0;
-
- GetThreadSelectorEntry (GetCurrentThread(), dsval, &ldt);
-
- dsbase = ldt.HighWord.Bits.BaseHi << 24 | ldt.HighWord.Bits.BaseMid << 16
- | ldt.BaseLow;
-
- return dsbase;
-}
-#else /* !_MSC_VER */
-#define get_ds_base() 0
-#endif /* _MSC_VER */
-
-static int
-e7000pc_init ()
-{
- int try;
- unsigned long dsbase;
-
- dsbase = get_ds_base ();
-
- /* Look around in memory for the board's signature */
-
- for (try = 0; sigs[try].sw; try++)
- {
- int val;
- board_at = sigs[try].addr - dsbase;
- fa = board_at + OFF_FA;
- fb = board_at + OFF_FB;
- cpd = board_at + OFF_CPD;
- cdp = board_at + OFF_CDP;
- ready =board_at + OFF_READY;
- pon = board_at + OFF_PON;
- irqtop = board_at + OFF_IRQTOP;
- irqtod = board_at + OFF_IRQTOD;
-
- val = GET_WORD (ready);
-
- if (val == (0xaaa0 | sigs[try].sw))
- {
- if (GET_WORD (pon) & 0xf)
- {
- SET_WORD (fa, 0);
- SET_WORD (fb, 0);
-
- SET_WORD (irqtop, 1); /* Disable interrupts from e7000 */
- SET_WORD (ready, 1);
- printf_filtered ("\nConnected to the E7000PC at address 0x%x\n",
- sigs[try].addr);
- return 1;
- }
- error ("The E7000 PC board is working, but the E7000 is turned off.\n");
- return 0;
- }
- }
-
- error ("GDB cannot connect to the E7000 PC board, check that it is installed\n\
-and that the switch settings are correct. Some other DOS programs can \n\
-stop the board from working. Try starting from a very minimal boot, \n\
-perhaps you need to disable EMM386 over the region where the board has\n\
-its I/O space, remove other unneeded cards, etc etc\n");
- return 0;
-
-}
-
-static int pbuf_size;
-static int pbuf_index;
-
-/* Return next byte from cdp. If no more, then return -1. */
-
-static int
-e7000_get (void)
-{
- static char pbuf[1000];
- char tmp[1000];
- int x;
-
- if (pbuf_index < pbuf_size)
- {
- x = pbuf[pbuf_index++];
- }
- else if ((GET_WORD (fb) & 1))
- {
- int i;
- pbuf_size = GET_WORD (cdp + 2);
-
- dosmemget (cdp + 8, pbuf_size + 1, tmp);
-
- /* Tell the E7000 we've eaten */
- SET_WORD (fb, 0);
- /* Swap it around */
- for (i = 0; i < pbuf_size; i++)
- {
- pbuf[i] = tmp[i^1];
- }
- pbuf_index = 0;
- x = pbuf[pbuf_index++];
- }
- else
- {
- x = -1;
- }
- return x;
-}
-
-/* Works just like read(), except that it takes a TIMEOUT in seconds. Note
- that TIMEOUT == 0 is a poll, and TIMEOUT == -1 means wait forever. */
-
-static int
-dosasync_read (fd, buf, len, timeout)
- int fd;
- char *buf;
- int len;
- int timeout;
-
-{
- long now;
- long then;
- int i = 0;
-
- /* Then look for some more if we're still hungry */
- time (&now);
- then = now + timeout;
- while (i < len)
- {
- int ch = e7000_get();
-
- /* While there's room in the buffer, and we've already
- read the stuff in, suck it over */
- if (ch != -1)
- {
- buf[i++] = ch;
- while (i < len && pbuf_index < pbuf_size )
- {
- ch = e7000_get();
- if (ch == -1)
- break;
- buf[i++] = ch;
- }
- }
-
- time (&now);
-
- if (timeout == 0)
- return i;
- if (now >= then && timeout > 0)
- {
- return i;
- }
- }
- return len;
-}
-
-
-static int
-dosasync_write (fd, buf, len)
- int fd;
- const char *buf;
- int len;
-{
- int i;
- char dummy[1000];
-
- /* Construct copy locally */
- ((short *)dummy)[0] = CMD_CI;
- ((short *)dummy)[1] = len;
- ((short *)dummy)[2] = 0;
- ((short *)dummy)[3] = 0;
- for (i = 0; i < len ; i++)
- {
- dummy[8 + i ^ 1] = buf[i];
- }
-
- /* Wait for the card to get ready */
- while (GET_WORD (fa) & 1) ;
-
- /* Blast onto the ISA card */
- dosmemput (dummy, 8 + len + 1, cpd);
-
- SET_WORD (fa, 1);
- SET_WORD (irqtod, 1); /* Interrupt the E7000 */
-
- return len;
-}
-
-static int
-e7000pc_open (scb, name)
- serial_t scb;
- const char *name;
-{
- if (strncasecmp (name, "pc", 2) != 0)
- {
- errno = ENOENT;
- return -1;
- }
-
- scb->fd = e7000pc_init ();
-
- if (!scb->fd)
- return -1;
-
- return 0;
-}
-
-static int
-e7000pc_noop (scb)
- serial_t scb;
-{
- return 0;
-}
-
-static void
-e7000pc_raw (scb)
- serial_t scb;
-{
- /* Always in raw mode */
-}
-
-static int
-e7000pc_readchar (scb, timeout)
- serial_t scb;
- int timeout;
-{
- char buf;
-
- top:
-
- if (dosasync_read (scb->fd, &buf, 1, timeout))
- {
- if (buf == 0) goto top;
- return buf;
- }
- else
- return SERIAL_TIMEOUT;
-}
-
-struct e7000pc_ttystate {
- int dummy;
-};
-
-/* e7000pc_{get set}_tty_state() are both dummys to fill out the function
- vector. Someday, they may do something real... */
-
-static serial_ttystate
-e7000pc_get_tty_state (scb)
- serial_t scb;
-{
- struct e7000pc_ttystate *state;
-
- state = (struct e7000pc_ttystate *) xmalloc (sizeof *state);
-
- return (serial_ttystate) state;
-}
-
-static int
-e7000pc_set_tty_state (scb, ttystate)
- serial_t scb;
- serial_ttystate ttystate;
-{
- return 0;
-}
-
-static int
-e7000pc_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
- serial_t scb;
- serial_ttystate new_ttystate;
- serial_ttystate old_ttystate;
-{
- return 0;
-}
-
-static void
-e7000pc_print_tty_state (scb, ttystate)
- serial_t scb;
- serial_ttystate ttystate;
-{
- /* Nothing to print. */
- return;
-}
-
-static int
-e7000pc_setbaudrate (scb, rate)
- serial_t scb;
- int rate;
-{
- return 0;
-}
-
-static int
-e7000pc_write (scb, str, len)
- serial_t scb;
- const char *str;
- int len;
-{
- dosasync_write (scb->fd, str, len);
-
- return 0;
-}
-
-static void
-e7000pc_close (scb)
- serial_t scb;
-{
-}
-
-static struct serial_ops e7000pc_ops =
-{
- "pc",
- 0,
- e7000pc_open,
- e7000pc_close,
- e7000pc_readchar,
- e7000pc_write,
- e7000pc_noop, /* flush output */
- e7000pc_noop, /* flush input */
- e7000pc_noop, /* send break -- currently used only for nindy */
- e7000pc_raw,
- e7000pc_get_tty_state,
- e7000pc_set_tty_state,
- e7000pc_print_tty_state,
- e7000pc_noflush_set_tty_state,
- e7000pc_setbaudrate,
- e7000pc_noop, /* wait for output to drain */
-};
-
-void
-_initialize_ser_e7000pc ()
-{
- serial_add_interface (&e7000pc_ops);
-}
-#else
-
-void
-_initialize_ser_e7000pc ()
-{
-
-}
-#endif
diff --git a/contrib/gdb/gdb/ser-go32.c b/contrib/gdb/gdb/ser-go32.c
deleted file mode 100644
index f776161..0000000
--- a/contrib/gdb/gdb/ser-go32.c
+++ /dev/null
@@ -1,958 +0,0 @@
-/* Remote serial interface for local (hardwired) serial ports for
- GO32. Copyright 1992, 1993 Free Software Foundation, Inc.
-
- Contributed by Nigel Stephens, Algorithmics Ltd. (nigel@algor.co.uk).
-
- This version uses DPMI interrupts to handle buffered i/o
- without the separate "asynctsr" program.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "gdbcmd.h"
-#include "serial.h"
-
-
-/*
- * NS16550 UART registers
- */
-
-#define COM1ADDR 0x3f8
-#define COM2ADDR 0x2f8
-#define COM3ADDR 0x3e8
-#define COM4ADDR 0x3e0
-
-#define com_data 0 /* data register (R/W) */
-#define com_dlbl 0 /* divisor latch low (W) */
-#define com_ier 1 /* interrupt enable (W) */
-#define com_dlbh 1 /* divisor latch high (W) */
-#define com_iir 2 /* interrupt identification (R) */
-#define com_fifo 2 /* FIFO control (W) */
-#define com_lctl 3 /* line control register (R/W) */
-#define com_cfcr 3 /* line control register (R/W) */
-#define com_mcr 4 /* modem control register (R/W) */
-#define com_lsr 5 /* line status register (R/W) */
-#define com_msr 6 /* modem status register (R/W) */
-
-/*
- * Constants for computing 16 bit baud rate divisor (lower byte
- * in com_dlbl, upper in com_dlbh) from 1.8432MHz crystal. Divisor is
- * 1.8432 MHz / (16 * X) for X bps. If the baud rate can't be set
- * to within +- (desired_rate*SPEED_TOLERANCE/1000) bps, we fail.
- */
-#define COMTICK (1843200/16)
-#define SPEED_TOLERANCE 30 /* thousandths; real == desired +- 3.0% */
-
-/* interrupt enable register */
-#define IER_ERXRDY 0x1 /* int on rx ready */
-#define IER_ETXRDY 0x2 /* int on tx ready */
-#define IER_ERLS 0x4 /* int on line status change */
-#define IER_EMSC 0x8 /* int on modem status change */
-
-/* interrupt identification register */
-#define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */
-#define IIR_IMASK 0xf /* interrupt cause mask */
-#define IIR_NOPEND 0x1 /* nothing pending */
-#define IIR_RLS 0x6 /* receive line status */
-#define IIR_RXRDY 0x4 /* receive ready */
-#define IIR_RXTOUT 0xc /* receive timeout */
-#define IIR_TXRDY 0x2 /* transmit ready */
-#define IIR_MLSC 0x0 /* modem status */
-
-
-/* fifo control register */
-#define FIFO_ENABLE 0x01 /* enable fifo */
-#define FIFO_RCV_RST 0x02 /* reset receive fifo */
-#define FIFO_XMT_RST 0x04 /* reset transmit fifo */
-#define FIFO_DMA_MODE 0x08 /* enable dma mode */
-#define FIFO_TRIGGER_1 0x00 /* trigger at 1 char */
-#define FIFO_TRIGGER_4 0x40 /* trigger at 4 chars */
-#define FIFO_TRIGGER_8 0x80 /* trigger at 8 chars */
-#define FIFO_TRIGGER_14 0xc0 /* trigger at 14 chars */
-
-/* character format control register */
-#define CFCR_DLAB 0x80 /* divisor latch */
-#define CFCR_SBREAK 0x40 /* send break */
-#define CFCR_PZERO 0x30 /* zero parity */
-#define CFCR_PONE 0x20 /* one parity */
-#define CFCR_PEVEN 0x10 /* even parity */
-#define CFCR_PODD 0x00 /* odd parity */
-#define CFCR_PENAB 0x08 /* parity enable */
-#define CFCR_STOPB 0x04 /* 2 stop bits */
-#define CFCR_8BITS 0x03 /* 8 data bits */
-#define CFCR_7BITS 0x02 /* 7 data bits */
-#define CFCR_6BITS 0x01 /* 6 data bits */
-#define CFCR_5BITS 0x00 /* 5 data bits */
-
-/* modem control register */
-#define MCR_LOOPBACK 0x10 /* loopback */
-#define MCR_IENABLE 0x08 /* output 2 = int enable */
-#define MCR_DRS 0x04 /* output 1 = xxx */
-#define MCR_RTS 0x02 /* enable RTS */
-#define MCR_DTR 0x01 /* enable DTR */
-
-/* line status register */
-#define LSR_RCV_FIFO 0x80 /* error in receive fifo */
-#define LSR_TSRE 0x40 /* transmitter empty */
-#define LSR_TXRDY 0x20 /* transmitter ready */
-#define LSR_BI 0x10 /* break detected */
-#define LSR_FE 0x08 /* framing error */
-#define LSR_PE 0x04 /* parity error */
-#define LSR_OE 0x02 /* overrun error */
-#define LSR_RXRDY 0x01 /* receiver ready */
-#define LSR_RCV_MASK 0x1f
-
-/* modem status register */
-#define MSR_DCD 0x80
-#define MSR_RI 0x40
-#define MSR_DSR 0x20
-#define MSR_CTS 0x10
-#define MSR_DDCD 0x08
-#define MSR_TERI 0x04
-#define MSR_DDSR 0x02
-#define MSR_DCTS 0x01
-
-#include <sys/dos.h>
-#include <sys/go32.h>
-#include <sys/dpmi.h>
-
-/* DPMI Communication */
-static union REGS dpmi_regs;
-static struct SREGS dpmi_sregs;
-
-/* 16550 rx fifo trigger point */
-#define FIFO_TRIGGER FIFO_TRIGGER_4
-
-/* input buffer size */
-#define CBSIZE 4096
-
-/* return raw 18Hz clock count */
-extern long rawclock (void);
-
-#define RAWHZ 18
-
-#ifdef DOS_STATS
-#define CNT_RX 16
-#define CNT_TX 17
-#define CNT_STRAY 18
-#define CNT_ORUN 19
-#define NCNT 20
-
-static int intrcnt;
-static int cnts[NCNT];
-static char *cntnames[NCNT] = {
- /* h/w interrupt counts. */
- "mlsc", "nopend", "txrdy", "?3",
- "rxrdy", "?5", "rls", "?7",
- "?8", "?9", "?a", "?b",
- "rxtout", "?d", "?e", "?f",
- /* s/w counts. */
- "rxcnt", "txcnt", "stray", "swoflo"
-};
-
-#define COUNT(x) cnts[x]++
-#else
-#define COUNT(x)
-#endif
-
-/* Main interrupt controller port addresses. */
-#define ICU_BASE 0x20
-#define ICU_OCW2 (ICU_BASE + 0)
-#define ICU_MASK (ICU_BASE + 1)
-
-/* Original interrupt controller mask register. */
-unsigned char icu_oldmask;
-
-/* Maximum of 8 interrupts (we don't handle the slave icu yet). */
-#define NINTR 8
-
-static struct intrupt
-{
- char inuse;
- struct dos_ttystate *port;
- _go32_dpmi_seginfo old_rmhandler;
- _go32_dpmi_seginfo old_pmhandler;
- _go32_dpmi_seginfo new_rmhandler;
- _go32_dpmi_seginfo new_pmhandler;
- _go32_dpmi_registers regs;
-} intrupts[NINTR];
-
-
-static struct dos_ttystate
-{
- int base;
- int irq;
- int refcnt;
- struct intrupt *intrupt;
- int fifo;
- int baudrate;
- unsigned char cbuf[CBSIZE];
- unsigned int first;
- unsigned int count;
- int txbusy;
- unsigned char old_mcr;
- int ferr;
- int perr;
- int oflo;
- int msr;
-} ports[4] = {
- {COM1ADDR, 4},
- {COM2ADDR, 3},
- {COM3ADDR, 4},
- {COM4ADDR, 3}
-};
-
-static int dos_open PARAMS ((serial_t scb, const char *name));
-static void dos_raw PARAMS ((serial_t scb));
-static int dos_readchar PARAMS ((serial_t scb, int timeout));
-static int dos_setbaudrate PARAMS ((serial_t scb, int rate));
-static int dos_write PARAMS ((serial_t scb, const char *str, int len));
-static void dos_close PARAMS ((serial_t scb));
-static serial_ttystate dos_get_tty_state PARAMS ((serial_t scb));
-static int dos_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
-static int dos_baudconv PARAMS ((int rate));
-
-#define inb(p,a) inportb((p)->base + (a))
-#define outb(p,a,v) outportb((p)->base + (a), (v))
-#define disable() asm volatile ("cli");
-#define enable() asm volatile ("sti");
-
-
-static int
-dos_getc (port)
- volatile struct dos_ttystate *port;
-{
- int c;
-
- if (port->count == 0)
- return -1;
-
- c = port->cbuf[port->first];
- disable ();
- port->first = (port->first + 1) & (CBSIZE - 1);
- port->count--;
- enable ();
- return c;
-}
-
-
-static int
-dos_putc (c, port)
- int c;
- struct dos_ttystate *port;
-{
- if (port->count >= CBSIZE - 1)
- return -1;
- port->cbuf[(port->first + port->count) & (CBSIZE - 1)] = c;
- port->count++;
- return 0;
-}
-
-
-
-static void
-dos_comisr (irq)
- int irq;
-{
- struct dos_ttystate *port;
- unsigned char iir, lsr, c;
-
- disable (); /* Paranoia */
- outportb (ICU_OCW2, 0x20); /* End-Of-Interrupt */
-#ifdef DOS_STATS
- ++intrcnt;
-#endif
-
- port = intrupts[irq].port;
- if (!port)
- {
- COUNT (CNT_STRAY);
- return; /* not open */
- }
-
- while (1)
- {
- iir = inb (port, com_iir) & IIR_IMASK;
- switch (iir)
- {
-
- case IIR_RLS:
- lsr = inb (port, com_lsr);
- goto rx;
-
- case IIR_RXTOUT:
- case IIR_RXRDY:
- lsr = 0;
-
- rx:
- do
- {
- c = inb (port, com_data);
- if (lsr & (LSR_BI | LSR_FE | LSR_PE | LSR_OE))
- {
- if (lsr & (LSR_BI | LSR_FE))
- port->ferr++;
- else if (lsr & LSR_PE)
- port->perr++;
- if (lsr & LSR_OE)
- port->oflo++;
- }
-
- if (dos_putc (c, port) < 0)
- {
- COUNT (CNT_ORUN);
- }
- else
- {
- COUNT (CNT_RX);
- }
- }
- while ((lsr = inb (port, com_lsr)) & LSR_RXRDY);
- break;
-
- case IIR_MLSC:
- /* could be used to flowcontrol Tx */
- port->msr = inb (port, com_msr);
- break;
-
- case IIR_TXRDY:
- port->txbusy = 0;
- break;
-
- case IIR_NOPEND:
- /* no more pending interrupts, all done */
- return;
-
- default:
- /* unexpected interrupt, ignore */
- break;
- }
- COUNT (iir);
- }
-}
-
-#ifdef __STDC__
-#define ISRNAME(x) dos_comisr##x
-#else
-#define ISRNAME(x) dos_comisr/**/x
-#endif
-#define ISR(x) static void ISRNAME(x)() {dos_comisr(x);}
-
-ISR(0) ISR(1) ISR(2) ISR(3)
-ISR(4) ISR(5) ISR(6) ISR(7)
-
-typedef void (*isr_t)();
-
-static isr_t isrs[NINTR] = {
- ISRNAME(0), ISRNAME(1), ISRNAME(2), ISRNAME(3),
- ISRNAME(4), ISRNAME(5), ISRNAME(6), ISRNAME(7)
-};
-
-
-
-static struct intrupt *
-dos_hookirq (irq)
- unsigned int irq;
-{
- struct intrupt *intr;
- unsigned int vec;
- isr_t isr;
-
- if (irq >= NINTR)
- return 0;
-
- intr = &intrupts[irq];
- if (intr->inuse)
- return 0;
-
- vec = 0x08 + irq;
- isr = isrs[irq];
-
- /* setup real mode handler */
- _go32_dpmi_get_real_mode_interrupt_vector (vec, &intr->old_rmhandler);
-
- intr->new_rmhandler.pm_selector = _go32_my_cs();
- intr->new_rmhandler.pm_offset = (u_long)isr;
- if (_go32_dpmi_allocate_real_mode_callback_iret (&intr->new_rmhandler,
- &intr->regs))
- {
- return 0;
- }
-
- if (_go32_dpmi_set_real_mode_interrupt_vector (vec, &intr->new_rmhandler))
- {
- return 0;
- }
-
- /* setup protected mode handler */
- _go32_dpmi_get_protected_mode_interrupt_vector(vec, &intr->old_pmhandler);
-
- intr->new_pmhandler.pm_selector = _go32_my_cs();
- intr->new_pmhandler.pm_offset = (u_long)isr;
- _go32_dpmi_allocate_iret_wrapper (&intr->new_pmhandler);
-
- if (_go32_dpmi_set_protected_mode_interrupt_vector(vec, &intr->new_pmhandler))
- {
- return 0;
- }
-
- /* setup interrupt controller mask */
- disable ();
- outportb (ICU_MASK, inportb (ICU_MASK) & ~(1 << irq));
- enable ();
-
- intr->inuse = 1;
- return intr;
-}
-
-
-static void
-dos_unhookirq (intr)
- struct intrupt *intr;
-{
- unsigned int irq, vec;
- unsigned char mask;
-
- irq = intr - intrupts;
- vec = 0x08 + irq;
-
- /* restore old interrupt mask bit */
- mask = 1 << irq;
- disable ();
- outportb (ICU_MASK, inportb (ICU_MASK) | (mask & icu_oldmask));
- enable ();
-
- /* remove real mode handler */
- _go32_dpmi_set_real_mode_interrupt_vector (vec, &intr->old_rmhandler);
- _go32_dpmi_free_real_mode_callback (&intr->new_rmhandler);
-
- /* remove protected mode handler */
- _go32_dpmi_set_protected_mode_interrupt_vector (vec, &intr->old_pmhandler);
- _go32_dpmi_free_iret_wrapper (&intr->new_pmhandler);
- intr->inuse = 0;
-}
-
-
-
-static int
-dos_open (scb, name)
- serial_t scb;
- const char *name;
-{
- struct dos_ttystate *port;
- int fd, i;
-
- if (strncasecmp (name, "/dev/", 5) == 0)
- name += 5;
- else if (strncasecmp (name, "\\dev\\", 5) == 0)
- name += 5;
-
- if (strlen (name) != 4 || strncasecmp (name, "com", 3) != 0)
- {
- errno = ENOENT;
- return -1;
- }
-
- if (name[3] < '1' || name[3] > '4')
- {
- errno = ENOENT;
- return -1;
- }
-
- fd = name[3] - '1';
- port = &ports[fd];
- if (port->refcnt++ > 0)
- {
- /* Device already opened another user. Just point at it. */
- scb->fd = fd;
- return 0;
- }
-
- /* force access to ID reg */
- outb(port, com_cfcr, 0);
- outb(port, com_iir, 0);
- for (i = 0; i < 17; i++) {
- if ((inb(port, com_iir) & 0x38) == 0)
- goto ok;
- (void) inb(port, com_data); /* clear recv */
- }
- errno = ENODEV;
- return -1;
-
-ok:
- /* disable all interrupts in chip */
- outb(port, com_ier, 0);
-
- /* tentatively enable 16550 fifo, and see if it responds */
- outb(port, com_fifo, FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER);
- sleep(1);
- port->fifo = ((inb(port, com_iir) & IIR_FIFO_MASK) == IIR_FIFO_MASK);
-
- /* clear pending status reports. */
- (void) inb(port, com_lsr);
- (void) inb(port, com_msr);
-
- /* enable external interrupt gate (to avoid floating IRQ) */
- outb(port, com_mcr, MCR_IENABLE);
-
- /* hook up interrupt handler and initialise icu */
- port->intrupt = dos_hookirq (port->irq);
- if (!port->intrupt)
- {
- outb(port, com_mcr, 0);
- outb(port, com_fifo, 0);
- errno = ENODEV;
- return -1;
- }
-
- disable ();
-
- /* record port */
- port->intrupt->port = port;
- scb->fd = fd;
-
- /* clear rx buffer, tx busy flag and overflow count */
- port->first = port->count = 0;
- port->txbusy = 0;
- port->oflo = 0;
-
- /* set default baud rate and mode: 9600,8,n,1 */
- i = dos_baudconv (port->baudrate = 9600);
- outb(port, com_cfcr, CFCR_DLAB);
- outb(port, com_dlbl, i & 0xff);
- outb(port, com_dlbh, i >> 8);
- outb(port, com_cfcr, CFCR_8BITS);
-
- /* enable all interrupts */
- outb(port, com_ier, IER_ETXRDY | IER_ERXRDY | IER_ERLS | IER_EMSC);
-
- /* enable DTR & RTS */
- outb(port, com_mcr, MCR_DTR | MCR_RTS | MCR_IENABLE);
-
- enable ();
-
- return 0;
-}
-
-
-static void
-dos_close (scb)
- serial_t scb;
-{
- struct dos_ttystate *port;
- struct intrupt *intrupt;
-
- if (!scb)
- return;
-
- port = &ports[scb->fd];
-
- if (port->refcnt-- > 1)
- return;
-
- if (!(intrupt = port->intrupt))
- return;
-
- /* disable interrupts, fifo, flow control */
- disable ();
- port->intrupt = 0;
- intrupt->port = 0;
- outb(port, com_fifo, 0);
- outb(port, com_ier, 0);
- enable ();
-
- /* unhook handler, and disable interrupt gate */
- dos_unhookirq (intrupt);
- outb(port, com_mcr, 0);
-
- /* Check for overflow errors */
- if (port->oflo)
- {
- fprintf_unfiltered (gdb_stderr,
- "Serial input overruns occurred.\n");
- fprintf_unfiltered (gdb_stderr, "This system %s handle %d baud.\n",
- port->fifo ? "cannot" : "needs a 16550 to",
- port->baudrate);
- }
-}
-
-
-
-static int
-dos_noop (scb)
- serial_t scb;
-{
- return 0;
-}
-
-static void
-dos_raw (scb)
- serial_t scb;
-{
- /* Always in raw mode */
-}
-
-static int
-dos_readchar (scb, timeout)
- serial_t scb;
- int timeout;
-{
- struct dos_ttystate *port = &ports[scb->fd];
- long then;
- int c;
-
- then = rawclock() + (timeout * RAWHZ);
- while ((c = dos_getc (port)) < 0)
- {
- if (timeout >= 0 && (rawclock () - then) >= 0)
- return SERIAL_TIMEOUT;
- notice_quit ();
- }
-
- return c;
-}
-
-
-static serial_ttystate
-dos_get_tty_state (scb)
- serial_t scb;
-{
- struct dos_ttystate *port = &ports[scb->fd];
- struct dos_ttystate *state;
-
- state = (struct dos_ttystate *) xmalloc (sizeof *state);
- *state = *port;
- return (serial_ttystate) state;
-}
-
-static int
-dos_set_tty_state (scb, ttystate)
- serial_t scb;
- serial_ttystate ttystate;
-{
- struct dos_ttystate *state;
-
- state = (struct dos_ttystate *) ttystate;
- dos_setbaudrate (scb, state->baudrate);
- return 0;
-}
-
-static int
-dos_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
- serial_t scb;
- serial_ttystate new_ttystate;
- serial_ttystate old_ttystate;
-{
- struct dos_ttystate *state;
-
- state = (struct dos_ttystate *) new_ttystate;
- dos_setbaudrate (scb, state->baudrate);
- return 0;
-}
-
-static int
-dos_flush_input (scb)
- serial_t scb;
-{
- struct dos_ttystate *port = &ports[scb->fd];
- disable();
- port->first = port->count = 0;
- if (port->fifo)
- outb(port, com_fifo, FIFO_ENABLE|FIFO_RCV_RST|FIFO_TRIGGER);
- enable();
-}
-
-static void
-dos_print_tty_state (scb, ttystate)
- serial_t scb;
- serial_ttystate ttystate;
-{
- /* Nothing to print */
- return;
-}
-
-static int
-dos_baudconv (rate)
- int rate;
-{
- long x, err;
-
- if (rate <= 0)
- return -1;
-
-#define divrnd(n, q) (((n) * 2 / (q) + 1) / 2) /* divide and round off */
- x = divrnd(COMTICK, rate);
- if (x <= 0)
- return -1;
-
- err = divrnd(1000 * COMTICK, x * rate) - 1000;
- if (err < 0)
- err = -err;
- if (err > SPEED_TOLERANCE)
- return -1;
-#undef divrnd
- return x;
-}
-
-
-static int
-dos_setbaudrate (scb, rate)
- serial_t scb;
- int rate;
-{
- struct dos_ttystate *port = &ports[scb->fd];
-
- if (port->baudrate != rate)
- {
- int x;
- unsigned char cfcr;
-
- x = dos_baudconv (rate);
- if (x <= 0)
- {
- fprintf_unfiltered (gdb_stderr, "%d: impossible baudrate\n", rate);
- errno = EINVAL;
- return -1;
- }
-
- disable ();
- cfcr = inb (port, com_cfcr);
-
- outb(port, com_cfcr, CFCR_DLAB);
- outb(port, com_dlbl, x & 0xff);
- outb(port, com_dlbh, x >> 8);
- outb(port, com_cfcr, cfcr);
- port->baudrate = rate;
- enable ();
- }
-
- return 0;
-}
-
-static int
-dos_setstopbits (scb, num)
- serial_t scb;
- int num;
-{
- struct dos_ttystate *port = &ports[scb->fd];
- unsigned char cfcr;
-
- disable ();
- cfcr = inb (port, com_cfcr);
-
- switch (num)
- {
- case SERIAL_1_STOPBITS:
- outb (port, com_cfcr, cfcr & ~CFCR_STOPB);
- break;
- case SERIAL_1_AND_A_HALF_STOPBITS:
- case SERIAL_2_STOPBITS:
- outb (port, com_cfcr, cfcr | CFCR_STOPB);
- break;
- default:
- enable ();
- return 1;
- }
- enable ();
-
- return 0;
-}
-
-static int
-dos_write (scb, str, len)
- serial_t scb;
- const char *str;
- int len;
-{
- volatile struct dos_ttystate *port = &ports[scb->fd];
- int fifosize = port->fifo ? 16 : 1;
- long then;
- int cnt;
-
- while (len > 0)
- {
- /* send the data, fifosize bytes at a time */
- cnt = fifosize > len ? len : fifosize;
- port->txbusy = 1;
- outportsb (port->base + com_data, str, cnt);
- str += cnt;
- len -= cnt;
-#ifdef DOS_STATS
- cnts[CNT_TX] += cnt;
-#endif
- /* wait for transmission to complete (max 1 sec) */
- then = rawclock() + RAWHZ;
- while (port->txbusy)
- {
- if ((rawclock () - then) >= 0)
- {
- errno = EIO;
- return SERIAL_ERROR;
- }
- }
- }
- return 0;
-}
-
-
-static int
-dos_sendbreak (scb)
- serial_t scb;
-{
- volatile struct dos_ttystate *port = &ports[scb->fd];
- unsigned char cfcr;
- long then;
-
- cfcr = inb(port, com_cfcr);
- outb(port, com_cfcr, cfcr | CFCR_SBREAK);
-
- /* 0.25 sec delay */
- then = rawclock () + RAWHZ / 4;
- while ((rawclock () - then) < 0)
- continue;
-
- outb(port, com_cfcr, cfcr);
- return 0;
-}
-
-
-static struct serial_ops dos_ops =
-{
- "hardwire",
- 0,
- dos_open,
- dos_close,
- dos_readchar,
- dos_write,
- dos_noop, /* flush output */
- dos_flush_input,
- dos_sendbreak,
- dos_raw,
- dos_get_tty_state,
- dos_set_tty_state,
- dos_print_tty_state,
- dos_noflush_set_tty_state,
- dos_setbaudrate,
- dos_setstopbits,
- dos_noop, /* wait for output to drain */
-};
-
-
-static void
-dos_info (arg, from_tty)
- char *arg;
- int from_tty;
-{
- struct dos_ttystate *port;
- int i;
-
- for (port = ports; port < &ports[4]; port++)
- {
- if (port->baudrate == 0)
- continue;
- printf_filtered ("Port:\tCOM%d (%sactive)\n", port - ports + 1,
- port->intrupt ? "" : "not ");
- printf_filtered ("Addr:\t0x%03x (irq %d)\n", port->base, port->irq);
- printf_filtered ("16550:\t%s\n", port->fifo ? "yes" : "no");
- printf_filtered ("Speed:\t%d baud\n", port->baudrate);
- printf_filtered ("Errs:\tframing %d parity %d overflow %d\n\n",
- port->ferr, port->perr, port->oflo);
- }
-
-#ifdef DOS_STATS
- printf_filtered ("\nTotal interrupts: %d\n", intrcnt);
- for (i = 0; i < NCNT; i++)
- if (cnts[i])
- printf_filtered ("%s:\t%d\n", cntnames[i], cnts[i]);
-#endif
-}
-
-
-void
-_initialize_ser_dos ()
-{
- struct cmd_list_element *c;
-
- serial_add_interface (&dos_ops);
-
- /* Save original interrupt mask register. */
- icu_oldmask = inportb (ICU_MASK);
-
- /* Mark fixed motherboard irqs as inuse. */
- intrupts[0].inuse = /* timer tick */
- intrupts[1].inuse = /* keyboard */
- intrupts[2].inuse = 1; /* slave icu */
-
- add_show_from_set (
- add_set_cmd ("com1base", class_obscure, var_zinteger,
- (char *) &ports[0].base,
- "Set COM1 base i/o port address.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("com1irq", class_obscure, var_zinteger,
- (char *) &ports[0].irq,
- "Set COM1 interrupt request.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("com2base", class_obscure, var_zinteger,
- (char *) &ports[1].base,
- "Set COM2 base i/o port address.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("com2irq", class_obscure, var_zinteger,
- (char *) &ports[1].irq,
- "Set COM2 interrupt request.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("com3base", class_obscure, var_zinteger,
- (char *) &ports[2].base,
- "Set COM3 base i/o port address.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("com3irq", class_obscure, var_zinteger,
- (char *) &ports[2].irq,
- "Set COM3 interrupt request.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("com4base", class_obscure, var_zinteger,
- (char *) &ports[3].base,
- "Set COM4 base i/o port address.",
- &setlist),
- &showlist);
-
- add_show_from_set (
- add_set_cmd ("com4irq", class_obscure, var_zinteger,
- (char *) &ports[3].irq,
- "Set COM4 interrupt request.",
- &setlist),
- &showlist);
-
- add_info ("serial", dos_info,
- "Print DOS serial port status.");
-}
diff --git a/contrib/gdb/gdb/ser-mac.c b/contrib/gdb/gdb/ser-mac.c
deleted file mode 100644
index df0040e..0000000
--- a/contrib/gdb/gdb/ser-mac.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/* Remote serial interface for local (hardwired) serial ports for Macintosh.
- Copyright 1994 Free Software Foundation, Inc.
- Contributed by Cygnus Support. Written by Stan Shebs.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "serial.h"
-
-#include <Types.h>
-#include <Devices.h>
-/* This is the regular Mac Serial.h, but copied to a different name
- so as not to get confused with the GDB serial.h above. */
-#include "MacSerial.h"
-
-/* This is unused for now. We just return a placeholder. */
-
-struct mac_ttystate
- {
- int bogus;
- };
-
-static int mac_open PARAMS ((serial_t scb, const char *name));
-static void mac_raw PARAMS ((serial_t scb));
-static int mac_readchar PARAMS ((serial_t scb, int timeout));
-static int mac_setbaudrate PARAMS ((serial_t scb, int rate));
-static int mac_write PARAMS ((serial_t scb, const char *str, int len));
-static void mac_close PARAMS ((serial_t scb));
-static serial_ttystate mac_get_tty_state PARAMS ((serial_t scb));
-static int mac_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
-static char *aptr PARAMS ((short p));
-
-short input_refnum;
-short output_refnum;
-
-char *mac_input_buffer;
-char *mac_output_buffer;
-
-static int
-mac_open (scb, name)
- serial_t scb;
- const char *name;
-{
- OSErr err;
-
- /* Alloc buffer space first - that way any allocation failures are
- intercepted before the serial driver gets involved. */
- if (mac_input_buffer == NULL)
- mac_input_buffer = (char *) xmalloc (4096);
- /* Match on a name and open a port. */
- if (strcmp (name, "modem") == 0)
- {
- err = OpenDriver ("\p.AIn", &input_refnum);
- if (err != 0)
- {
- return (-1);
- }
- err = OpenDriver ("\p.AOut", &output_refnum);
- if (err != 0)
- {
- CloseDriver (input_refnum);
- return (-1);
- }
- }
- else if (strcmp (name, "printer") == 0)
- {
- err = OpenDriver ("\p.BIn", &input_refnum);
- if (err != 0)
- {
- return (-1);
- }
- err = OpenDriver ("\p.BOut", &output_refnum);
- if (err != 0)
- {
- CloseDriver (input_refnum);
- return (-1);
- }
- /* fake */
- scb->fd = 1;
- return 0;
- }
- else
- {
- error ("You must specify a valid serial port name; your choices are `modem' or `printer'.");
- errno = ENOENT;
- return (-1);
- }
- /* We got something open. */
- if (1 /* using custom buffer */)
- SerSetBuf (input_refnum, mac_input_buffer, 4096);
- /* Set to a GDB-preferred state. */
- SerReset (input_refnum, stop10|noParity|data8|baud9600);
- SerReset (output_refnum, stop10|noParity|data8|baud9600);
- {
- CntrlParam cb;
- struct SerShk *handshake;
-
- cb.ioCRefNum = output_refnum;
- cb.csCode = 14;
- handshake = (struct SerShk *) &cb.csParam[0];
- handshake->fXOn = 0;
- handshake->fCTS = 0;
- handshake->xOn = 0;
- handshake->xOff = 0;
- handshake->errs = 0;
- handshake->evts = 0;
- handshake->fInX = 0;
- handshake->fDTR = 0;
- err = PBControl ((ParmBlkPtr) &cb, 0);
- if (err < 0)
- return (-1);
- }
- /* fake */
- scb->fd = 1;
- return 0;
-}
-
-static int
-mac_noop (scb)
- serial_t scb;
-{
- return 0;
-}
-
-static void
-mac_raw (scb)
- serial_t scb;
-{
- /* Always effectively in raw mode. */
-}
-
-/* Read a character with user-specified timeout. TIMEOUT is number of seconds
- to wait, or -1 to wait forever. Use timeout of 0 to effect a poll. Returns
- char if successful. Returns -2 if timeout expired, EOF if line dropped
- dead, or -3 for any other error (see errno in that case). */
-
-static int
-mac_readchar (scb, timeout)
- serial_t scb;
- int timeout;
-{
- int status, n;
- /* time_t */ unsigned long start_time, now;
- OSErr err;
- CntrlParam cb;
- IOParam pb;
-
- if (scb->bufcnt-- > 0)
- return *scb->bufp++;
-
- time (&start_time);
-
- while (1)
- {
- cb.ioCRefNum = input_refnum;
- cb.csCode = 2;
- err = PBStatus ((ParmBlkPtr) &cb, 0);
- if (err < 0)
- return SERIAL_ERROR;
- n = *((long *) &cb.csParam[0]);
- if (n > 0)
- {
- pb.ioRefNum = input_refnum;
- pb.ioBuffer = (Ptr) (scb->buf);
- pb.ioReqCount = (n > 64 ? 64 : n);
- err = PBRead ((ParmBlkPtr) &pb, 0);
- if (err < 0)
- return SERIAL_ERROR;
- scb->bufcnt = pb.ioReqCount;
- scb->bufcnt--;
- scb->bufp = scb->buf;
- return *scb->bufp++;
- }
- else if (timeout == 0)
- return SERIAL_TIMEOUT;
- else if (timeout == -1)
- ;
- else
- {
- time (&now);
- if (now > start_time + timeout)
- return SERIAL_TIMEOUT;
- }
- PROGRESS (1);
- }
-}
-
-/* mac_{get set}_tty_state() are both dummys to fill out the function
- vector. Someday, they may do something real... */
-
-static serial_ttystate
-mac_get_tty_state (scb)
- serial_t scb;
-{
- struct mac_ttystate *state;
-
- state = (struct mac_ttystate *) xmalloc (sizeof *state);
-
- return (serial_ttystate) state;
-}
-
-static int
-mac_set_tty_state (scb, ttystate)
- serial_t scb;
- serial_ttystate ttystate;
-{
- return 0;
-}
-
-static int
-mac_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
- serial_t scb;
- serial_ttystate new_ttystate;
- serial_ttystate old_ttystate;
-{
- return 0;
-}
-
-static void
-mac_print_tty_state (scb, ttystate)
- serial_t scb;
- serial_ttystate ttystate;
-{
- /* Nothing to print. */
- return;
-}
-
-/* If there is a tricky formula to relate real baud rates
- to what the serial driver wants, we should use it. Until
- we get one, this table will have to do. */
-
-static struct {
- int real_rate;
- int bits;
-} mac_baud_rate_table[] = {
- { 57600, baud57600 },
- { 38400, 1 },
- { 19200, baud19200 },
- { 9600, baud9600 },
- { 7200, baud7200 },
- { 4800, baud4800 },
- { 3600, baud3600 },
- { 2400, baud2400 },
- { 1800, baud1800 },
- { 1200, baud1200 },
- { 600, baud600 },
- { 300, baud300 },
- { 0, 0 }
-};
-
-static int
-mac_set_baud_rate (scb, rate)
- serial_t scb;
- int rate;
-{
- int i, bits;
-
- for (i = 0; mac_baud_rate_table[i].real_rate != 0; ++i)
- {
- if (mac_baud_rate_table[i].real_rate == rate)
- {
- bits = mac_baud_rate_table[i].bits;
- break;
- }
- }
- SerReset (input_refnum, stop10|noParity|data8|bits);
- SerReset (output_refnum, stop10|noParity|data8|bits);
-}
-
-static int
-mac_set_stop_bits (scb, num)
- serial_t scb;
- int num;
-{
- return 0;
-}
-
-int first_mac_write = 0;
-
-static int
-mac_write (scb, str, len)
- serial_t scb;
- const char *str;
- int len;
-{
- OSErr err;
- IOParam pb;
-
- if (first_mac_write++ < 4)
- {
- sleep (1);
- }
- pb.ioRefNum = output_refnum;
- pb.ioBuffer = (Ptr) str;
- pb.ioReqCount = len;
- err = PBWrite ((ParmBlkPtr) &pb, 0);
- if (err < 0)
- {
- return 1;
- }
- return 0;
-}
-
-static void
-mac_close (serial_t scb)
-{
- if (input_refnum)
- {
- if (1 /* custom buffer */)
- SerSetBuf (input_refnum, mac_input_buffer, 0);
- CloseDriver (input_refnum);
- input_refnum = 0;
- }
- if (output_refnum)
- {
- if (0 /* custom buffer */)
- SerSetBuf (input_refnum, mac_output_buffer, 0);
- CloseDriver (output_refnum);
- output_refnum = 0;
- }
-}
-
-static struct serial_ops mac_ops =
-{
- "hardwire",
- 0,
- mac_open,
- mac_close,
- mac_readchar,
- mac_write,
- mac_noop, /* flush output */
- mac_noop, /* flush input */
- mac_noop, /* send break -- currently only for nindy */
- mac_raw,
- mac_get_tty_state,
- mac_set_tty_state,
- mac_print_tty_state,
- mac_noflush_set_tty_state,
- mac_set_baud_rate,
- mac_set_stop_bits,
- mac_noop, /* wait for output to drain */
-};
-
-void
-_initialize_ser_mac ()
-{
- serial_add_interface (&mac_ops);
-}
diff --git a/contrib/gdb/gdb/ser-unix.c b/contrib/gdb/gdb/ser-unix.c
index f279c94..f5dbaa0 100644
--- a/contrib/gdb/gdb/ser-unix.c
+++ b/contrib/gdb/gdb/ser-unix.c
@@ -1,5 +1,5 @@
/* Serial interface for local (hardwired) serial ports on Un*x like systems
- Copyright 1992, 1993, 1994, 1998 Free Software Foundation, Inc.
+ Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of GDB.
@@ -69,25 +69,12 @@ static int hardwire_readchar PARAMS ((serial_t scb, int timeout));
static int rate_to_code PARAMS ((int rate));
static int hardwire_setbaudrate PARAMS ((serial_t scb, int rate));
static int hardwire_write PARAMS ((serial_t scb, const char *str, int len));
+/* FIXME: static void hardwire_restore PARAMS ((serial_t scb)); */
static void hardwire_close PARAMS ((serial_t scb));
static int get_tty_state PARAMS ((serial_t scb, struct hardwire_ttystate *state));
static int set_tty_state PARAMS ((serial_t scb, struct hardwire_ttystate *state));
static serial_ttystate hardwire_get_tty_state PARAMS ((serial_t scb));
static int hardwire_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
-static int hardwire_noflush_set_tty_state PARAMS ((serial_t, serial_ttystate,
- serial_ttystate));
-static void hardwire_print_tty_state PARAMS ((serial_t, serial_ttystate));
-static int hardwire_drain_output PARAMS ((serial_t));
-static int hardwire_flush_output PARAMS ((serial_t));
-static int hardwire_flush_input PARAMS ((serial_t));
-static int hardwire_send_break PARAMS ((serial_t));
-static int hardwire_setstopbits PARAMS ((serial_t, int));
-
-void _initialize_ser_hardwire PARAMS ((void));
-
-#ifdef __CYGWIN32__
-extern void (*ui_loop_hook) PARAMS ((int));
-#endif
/* Open up a real live device for serial I/O */
@@ -104,11 +91,13 @@ hardwire_open(scb, name)
}
static int
-get_tty_state (scb, state)
+get_tty_state(scb, state)
serial_t scb;
struct hardwire_ttystate *state;
{
#ifdef HAVE_TERMIOS
+ extern int errno;
+
if (tcgetattr(scb->fd, &state->termios) < 0)
return -1;
@@ -280,38 +269,6 @@ hardwire_print_tty_state (scb, ttystate)
#endif
}
-/* Wait for the output to drain away, as opposed to flushing (discarding) it */
-
-static int
-hardwire_drain_output (scb)
- serial_t scb;
-{
-#ifdef HAVE_TERMIOS
- return tcdrain (scb->fd);
-#endif
-
-#ifdef HAVE_TERMIO
- return ioctl (scb->fd, TCSBRK, 1);
-#endif
-
-#ifdef HAVE_SGTTY
- /* Get the current state and then restore it using TIOCSETP,
- which should cause the output to drain and pending input
- to be discarded. */
- {
- struct hardwire_ttystate state;
- if (get_tty_state (scb, &state))
- {
- return (-1);
- }
- else
- {
- return (ioctl (scb->fd, TIOCSETP, &state.sgttyb));
- }
- }
-#endif
-}
-
static int
hardwire_flush_output (scb)
serial_t scb;
@@ -434,9 +391,7 @@ wait_for(scb, timeout)
serial_t scb;
int timeout;
{
-#ifndef __CYGWIN32__
scb->timeout_remaining = 0;
-#endif
#ifdef HAVE_SGTTY
{
@@ -545,37 +500,21 @@ wait_for(scb, timeout)
to wait, or -1 to wait forever. Use timeout of 0 to effect a poll. Returns
char if successful. Returns SERIAL_TIMEOUT if timeout expired, EOF if line
dropped dead, or SERIAL_ERROR for any other error (see errno in that case). */
+
static int
-hardwire_readchar (scb, timeout)
+hardwire_readchar(scb, timeout)
serial_t scb;
int timeout;
{
int status;
-#ifdef __CYGWIN32__
- int t;
-#endif
if (scb->bufcnt-- > 0)
return *scb->bufp++;
-#ifdef __CYGWIN32__
- if (timeout > 0)
- timeout++;
-#endif
-
while (1)
{
-#ifdef __CYGWIN32__
- t = timeout == 0 ? 0 : 1;
- scb->timeout_remaining = timeout < 0 ? timeout : timeout - t;
- status = wait_for (scb, t);
-
- /* -2 means disable timer */
- if (ui_loop_hook)
- ui_loop_hook (-2);
-#else
status = wait_for (scb, timeout);
-#endif
+
if (status < 0)
return status;
@@ -592,10 +531,6 @@ hardwire_readchar (scb, timeout)
timeout = scb->timeout_remaining;
continue;
}
-#ifdef __CYGWIN32__
- else if (scb->timeout_remaining < 0)
- continue;
-#endif
else
return SERIAL_TIMEOUT;
}
@@ -647,15 +582,15 @@ baudtab[] =
#ifdef B57600
{57600, B57600},
#endif
+#ifdef B76800
+ {76800, B76800},
+#endif
#ifdef B115200
{115200, B115200},
#endif
#ifdef B230400
{230400, B230400},
#endif
-#ifdef B460800
- {460800, B460800},
-#endif
{-1, -1},
};
@@ -798,7 +733,6 @@ static struct serial_ops hardwire_ops =
hardwire_noflush_set_tty_state,
hardwire_setbaudrate,
hardwire_setstopbits,
- hardwire_drain_output, /* wait for output to drain */
};
void
diff --git a/contrib/gdb/gdb/solib.c b/contrib/gdb/gdb/solib.c
index 6d6fd4a..4fd3344 100644
--- a/contrib/gdb/gdb/solib.c
+++ b/contrib/gdb/gdb/solib.c
@@ -1,5 +1,5 @@
/* Handle SunOS and SVR4 shared libraries for GDB, the GNU Debugger.
- Copyright 1990, 91, 92, 93, 94, 95, 96, 98, 1999
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996
Free Software Foundation, Inc.
This file is part of GDB.
@@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <a.out.h>
#else
#include "elf/external.h"
+#include "elf/common.h"
#endif
#include <link.h>
@@ -70,7 +71,6 @@ static char *solib_break_names[] = {
"r_debug_state",
"_r_debug_state",
"_dl_debug_state",
- "rtld_db_dlactivity",
NULL
};
#endif
@@ -149,20 +149,12 @@ static struct so_list *so_list_head; /* List of known shared objects */
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
-static int solib_cleanup_queued = 0; /* make_run_cleanup called */
-
extern int
fdmatch PARAMS ((int, int)); /* In libiberty */
/* Local function prototypes */
static void
-do_clear_solib PARAMS ((PTR));
-
-static int
-match_main PARAMS ((char *));
-
-static void
special_symbol_handling PARAMS ((struct so_list *));
static void
@@ -174,10 +166,17 @@ enable_break PARAMS ((void));
static void
info_sharedlibrary_command PARAMS ((char *, int));
-static int symbol_add_stub PARAMS ((PTR));
+static int
+symbol_add_stub PARAMS ((char *));
static struct so_list *
-find_solib PARAMS ((struct so_list *));
+alloc_solib PARAMS ((struct link_map *));
+
+static void
+free_solib PARAMS ((struct so_list *));
+
+static struct so_list *
+find_solib PARAMS ((struct so_list *, int maybe_changed));
static struct link_map *
first_link_map_member PARAMS ((void));
@@ -185,7 +184,8 @@ first_link_map_member PARAMS ((void));
static CORE_ADDR
locate_base PARAMS ((void));
-static int solib_map_sections PARAMS ((PTR));
+static void
+solib_map_sections PARAMS ((struct so_list *));
#ifdef SVR4_SHARED_LIBS
@@ -205,17 +205,6 @@ solib_add_common_symbols PARAMS ((struct rtc_symb *));
#endif
-void _initialize_solib PARAMS ((void));
-
-/* If non-zero, this is a prefix that will be added to the front of the name
- shared libraries with an absolute filename for loading. */
-static char *solib_absolute_prefix = NULL;
-
-/* If non-empty, this is a search path for loading non-absolute shared library
- symbol files. This takes precedence over the environment variables PATH
- and LD_LIBRARY_PATH. */
-static char *solib_search_path = NULL;
-
/*
LOCAL FUNCTION
@@ -224,7 +213,7 @@ LOCAL FUNCTION
SYNOPSIS
- static int solib_map_sections (struct so_list *so)
+ static void solib_map_sections (struct so_list *so)
DESCRIPTION
@@ -243,11 +232,10 @@ FIXMES
expansion stuff?).
*/
-static int
-solib_map_sections (arg)
- PTR arg;
+static void
+solib_map_sections (so)
+ struct so_list *so;
{
- struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */
char *filename;
char *scratch_pathname;
int scratch_chan;
@@ -256,38 +244,10 @@ solib_map_sections (arg)
bfd *abfd;
filename = tilde_expand (so -> so_name);
-
- if (solib_absolute_prefix && ROOTED_P (filename))
- /* Prefix shared libraries with absolute filenames with
- SOLIB_ABSOLUTE_PREFIX. */
- {
- char *pfxed_fn;
- int pfx_len;
-
- pfx_len = strlen (solib_absolute_prefix);
-
- /* Remove trailing slashes. */
- while (pfx_len > 0 && SLASH_P (solib_absolute_prefix[pfx_len - 1]))
- pfx_len--;
-
- pfxed_fn = xmalloc (pfx_len + strlen (filename) + 1);
- strcpy (pfxed_fn, solib_absolute_prefix);
- strcat (pfxed_fn, filename);
- free (filename);
-
- filename = pfxed_fn;
- }
-
old_chain = make_cleanup (free, filename);
-
- scratch_chan = -1;
-
- if (solib_search_path)
- scratch_chan = openp (solib_search_path,
- 1, filename, O_RDONLY, 0, &scratch_pathname);
- if (scratch_chan < 0)
- scratch_chan = openp (get_in_environ (inferior_environ, "PATH"),
- 1, filename, O_RDONLY, 0, &scratch_pathname);
+
+ scratch_chan = openp (get_in_environ (inferior_environ, "PATH"),
+ 1, filename, O_RDONLY, 0, &scratch_pathname);
if (scratch_chan < 0)
{
scratch_chan = openp (get_in_environ
@@ -344,8 +304,6 @@ solib_map_sections (arg)
/* Free the file names, close the file now. */
do_cleanups (old_chain);
-
- return (1);
}
#ifndef SVR4_SHARED_LIBS
@@ -399,6 +357,7 @@ solib_add_common_symbols (rtc_symp)
struct nlist inferior_rtc_nlist;
int len;
char *name;
+ char *origname;
/* Remove any runtime common symbols from previous runs. */
@@ -412,7 +371,7 @@ solib_add_common_symbols (rtc_symp)
}
init_minimal_symbol_collection ();
- make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0);
+ make_cleanup (discard_minimal_symbols, 0);
while (rtc_symp)
{
@@ -429,16 +388,18 @@ solib_add_common_symbols (rtc_symp)
behind the name of the symbol. */
len = inferior_rtc_nlist.n_value - inferior_rtc_nlist.n_un.n_strx;
- name = xmalloc (len);
+ origname = name = xmalloc (len);
read_memory ((CORE_ADDR) inferior_rtc_nlist.n_un.n_name, name, len);
/* Allocate the runtime common objfile if necessary. */
if (rt_common_objfile == NULL)
allocate_rt_common_objfile ();
+ name = obsavestring (name, strlen (name),
+ &rt_common_objfile -> symbol_obstack);
prim_record_minimal_symbol (name, inferior_rtc_nlist.n_value,
mst_bss, rt_common_objfile);
- free (name);
+ free (origname);
}
rtc_symp = inferior_rtc_symb.rtc_next;
}
@@ -483,7 +444,7 @@ bfd_lookup_symbol (abfd, symname)
bfd *abfd;
char *symname;
{
- unsigned int storage_needed;
+ long storage_needed;
asymbol *sym;
asymbol **symbol_table;
unsigned int number_of_symbols;
@@ -511,6 +472,29 @@ bfd_lookup_symbol (abfd, symname)
}
do_cleanups (back_to);
}
+
+ if (symaddr) return (symaddr);
+
+ storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd);
+
+ if (storage_needed > 0)
+ {
+ symbol_table = (asymbol **) xmalloc (storage_needed);
+ back_to = make_cleanup (free, (PTR)symbol_table);
+ number_of_symbols = bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
+
+ for (i = 0; i < number_of_symbols; i++)
+ {
+ sym = *symbol_table++;
+ if (STREQ (sym -> name, symname))
+ {
+ /* Bfd symbols are section relative. */
+ symaddr = sym -> value + sym -> section -> vma;
+ break;
+ }
+ }
+ do_cleanups (back_to);
+ }
return (symaddr);
}
@@ -583,7 +567,7 @@ look_for_base (fd, baseaddr)
if (fd == -1
|| (exec_bfd != NULL
- && fdmatch (fileno ((FILE *)(exec_bfd -> iostream)), fd)))
+ && fdmatch (fileno ((GDB_FILE *)(exec_bfd -> iostream)), fd)))
{
return (0);
}
@@ -691,7 +675,8 @@ elf_locate_base ()
/* Find the DT_DEBUG entry in the the .dynamic section.
For mips elf we look for DT_MIPS_RLD_MAP, mips elf apparently has
no DT_DEBUG entries. */
-#ifndef TARGET_ELF64
+ /* FIXME: In lack of a 64 bit ELF ABI the following code assumes
+ a 32 bit ELF ABI target. */
for (bufend = buf + dyninfo_sect_size;
buf < bufend;
buf += sizeof (Elf32_External_Dyn))
@@ -722,25 +707,6 @@ elf_locate_base ()
}
#endif
}
-#else /* ELF64 */
- for (bufend = buf + dyninfo_sect_size;
- buf < bufend;
- buf += sizeof (Elf64_External_Dyn))
- {
- Elf64_External_Dyn *x_dynp = (Elf64_External_Dyn *)buf;
- long dyn_tag;
- CORE_ADDR dyn_ptr;
-
- dyn_tag = bfd_h_get_64 (exec_bfd, (bfd_byte *) x_dynp->d_tag);
- if (dyn_tag == DT_NULL)
- break;
- else if (dyn_tag == DT_DEBUG)
- {
- dyn_ptr = bfd_h_get_64 (exec_bfd, (bfd_byte *) x_dynp->d_un.d_ptr);
- return dyn_ptr;
- }
- }
-#endif
/* DT_DEBUG entry not found. */
return 0;
@@ -824,7 +790,7 @@ locate_base ()
debug_base = elf_locate_base ();
#ifdef HANDLE_SVR4_EXEC_EMULATORS
/* Try it the hard way for emulated executables. */
- else if (inferior_pid != 0 && target_has_execution)
+ else if (inferior_pid != 0)
proc_iterate_over_mappings (look_for_base);
#endif
}
@@ -885,11 +851,106 @@ first_link_map_member ()
LOCAL FUNCTION
+ free_solib -- free a so_list structure
+
+SYNOPSIS
+
+ void free_solib (struct so_list *so_list_ptr)
+
+DESCRIPTION
+
+ Free the memory used by a struct so_list.
+
+ */
+
+void
+free_solib (so)
+ struct so_list *so;
+{
+ char *bfd_filename;
+ if (so -> sections)
+ {
+ free ((PTR)so -> sections);
+ }
+ if (so -> abfd)
+ {
+ bfd_filename = bfd_get_filename (so -> abfd);
+ if (!bfd_close (so -> abfd))
+ warning ("cannot close \"%s\": %s",
+ bfd_filename, bfd_errmsg (bfd_get_error ()));
+ }
+ else
+ /* This happens for the executable on SVR4. */
+ bfd_filename = NULL;
+
+ if (bfd_filename)
+ free ((PTR)bfd_filename);
+ free ((PTR)so);
+}
+
+/*
+
+LOCAL FUNCTION
+
+ alloc_solib -- free a so_list structure
+
+SYNOPSIS
+
+ struct so_list *alloc_solib (struct link_map *lm)
+
+DESCRIPTION
+
+ Allocate the struct so_list to cache debugging information
+ for a struct link_map entry in the target.
+
+ */
+
+struct so_list *
+alloc_solib (lm)
+ struct link_map *lm;
+{
+ struct so_list *new;
+
+ /* Get next link map structure from inferior image and build a local
+ abbreviated load_map structure */
+ new = (struct so_list *) xmalloc (sizeof (struct so_list));
+ memset ((char *) new, 0, sizeof (struct so_list));
+ new -> lmaddr = lm;
+
+ read_memory ((CORE_ADDR) lm, (char *) &(new -> lm),
+ sizeof (struct link_map));
+ /* For SVR4 versions, the first entry in the link map is for the
+ inferior executable, so we must ignore it. For some versions of
+ SVR4, it has no name. For others (Solaris 2.3 for example), it
+ does have a name, so we can no longer use a missing name to
+ decide when to ignore it. */
+ if (!IGNORE_FIRST_LINK_MAP_ENTRY (new -> lm))
+ {
+ int errcode;
+ char *buffer;
+ target_read_string ((CORE_ADDR) LM_NAME (new), &buffer,
+ MAX_PATH_SIZE - 1, &errcode);
+ if (errcode != 0)
+ error ("find_solib: Can't read pathname for load map: %s\n",
+ safe_strerror (errcode));
+ strncpy (new -> so_name, buffer, MAX_PATH_SIZE - 1);
+ new -> so_name[MAX_PATH_SIZE - 1] = '\0';
+ free (buffer);
+ solib_map_sections (new);
+ }
+
+ return new;
+}
+
+/*
+
+LOCAL FUNCTION
+
find_solib -- step through list of shared objects
SYNOPSIS
- struct so_list *find_solib (struct so_list *so_list_ptr)
+ struct so_list *find_solib (struct so_list *so_list_ptr, int maybe_changed)
DESCRIPTION
@@ -902,145 +963,138 @@ DESCRIPTION
The arg and return value are "struct link_map" pointers, as defined
in <link.h>.
+
+ If it is expected that the contents of the shared library list has changed
+ (e.g. when the special shared library breakpoint is hit) then pass non-zero
+ for maybe_changed, otherwise zero.
*/
static struct so_list *
-find_solib (so_list_ptr)
+find_solib (so_list_ptr, maybe_changed)
struct so_list *so_list_ptr; /* Last lm or NULL for first one */
+ int maybe_changed; /* non-zero if shlib list might have changed */
{
- struct so_list *so_list_next = NULL;
struct link_map *lm = NULL;
struct so_list *new;
+ struct so_list *p, **prev;
if (so_list_ptr == NULL)
{
- /* We are setting up for a new scan through the loaded images. */
- if ((so_list_next = so_list_head) == NULL)
+ struct so_list **map;
+
+ /* If we have not already read in the dynamic linking structures
+ from the inferior, lookup the address of the base structure. */
+ if (debug_base == 0)
+ debug_base = locate_base ();
+ if (debug_base != 0)
{
- /* We have not already read in the dynamic linking structures
- from the inferior, lookup the address of the base structure. */
- debug_base = locate_base ();
- if (debug_base != 0)
- {
- /* Read the base structure in and find the address of the first
- link map list member. */
- lm = first_link_map_member ();
- }
+ /* Read the base structure in and find the address of the first
+ link map list member. */
+ lm = first_link_map_member ();
}
+ else
+ lm = NULL;
+
+ prev = &so_list_head;
+ so_list_ptr = so_list_head;
}
else
{
/* We have been called before, and are in the process of walking
- the shared library list. Advance to the next shared object. */
- if ((lm = LM_NEXT (so_list_ptr)) == NULL)
+ the shared library list. Advance to the next shared object.
+
+ Always read from the target to check to see if any were
+ added, but be quiet if we can't read from the target any more. */
+ int status = target_read_memory ((CORE_ADDR) so_list_ptr -> lmaddr,
+ (char *) &(so_list_ptr -> lm),
+ sizeof (struct link_map));
+
+ if (status == 0)
{
- /* We have hit the end of the list, so check to see if any were
- added, but be quiet if we can't read from the target any more. */
- int status = target_read_memory ((CORE_ADDR) so_list_ptr -> lmaddr,
- (char *) &(so_list_ptr -> lm),
- sizeof (struct link_map));
- if (status == 0)
+ lm = LM_NEXT (so_list_ptr);
+ }
+ else
+ {
+ lm = NULL;
+ }
+
+ prev = &so_list_ptr -> next;
+ so_list_ptr = so_list_ptr -> next;
+ }
+
+ /* If we don't believe that the list has changed, just return the cached copy. */
+ if (!maybe_changed)
+ return (so_list_ptr);
+
+ /* At this point, lm is the address of the next list element in the target and
+ so_list_ptr is our cached entry for it. */
+
+ if (lm != NULL)
+ {
+ if (so_list_ptr == NULL || so_list_ptr -> lmaddr != lm)
+ {
+ /* We have detected a change in the list. Check for a deletion by searching
+ forward in the cached list */
+ if (so_list_ptr)
{
- lm = LM_NEXT (so_list_ptr);
+ for (p = so_list_ptr -> next; p; p = p -> next)
+ if (p -> lmaddr == lm)
+ break;
}
else
+ p = NULL;
+
+ if (p)
{
- lm = NULL;
+ /* This lib has been deleted */
+ while (so_list_ptr != p)
+ {
+ *prev = so_list_ptr -> next;
+ free_solib (so_list_ptr);
+ so_list_ptr = *prev;
+ }
+ }
+ else
+ {
+ /* A new lib has been inserted into the list */
+ new = alloc_solib (lm);
+ new -> next = so_list_ptr;
+ *prev = new;
+ so_list_ptr = new;
}
}
- so_list_next = so_list_ptr -> next;
}
- if ((so_list_next == NULL) && (lm != NULL))
+ else
{
- /* Get next link map structure from inferior image and build a local
- abbreviated load_map structure */
- new = (struct so_list *) xmalloc (sizeof (struct so_list));
- memset ((char *) new, 0, sizeof (struct so_list));
- new -> lmaddr = lm;
- /* Add the new node as the next node in the list, or as the root
- node if this is the first one. */
if (so_list_ptr != NULL)
{
- so_list_ptr -> next = new;
- }
- else
- {
- so_list_head = new;
-
- if (! solib_cleanup_queued)
- {
- make_run_cleanup (do_clear_solib, NULL);
- solib_cleanup_queued = 1;
- }
-
- }
- so_list_next = new;
- read_memory ((CORE_ADDR) lm, (char *) &(new -> lm),
- sizeof (struct link_map));
- /* For SVR4 versions, the first entry in the link map is for the
- inferior executable, so we must ignore it. For some versions of
- SVR4, it has no name. For others (Solaris 2.3 for example), it
- does have a name, so we can no longer use a missing name to
- decide when to ignore it. */
- if (!IGNORE_FIRST_LINK_MAP_ENTRY (new -> lm))
- {
- int errcode;
- char *buffer;
- target_read_string ((CORE_ADDR) LM_NAME (new), &buffer,
- MAX_PATH_SIZE - 1, &errcode);
- if (errcode != 0)
+ /* Libs have been deleted from the end of the list */
+ while (so_list_ptr != NULL)
{
- warning ("find_solib: Can't read pathname for load map: %s\n",
- safe_strerror (errcode));
- return (so_list_next);
+ *prev = so_list_ptr -> next;
+ free_solib (so_list_ptr);
+ so_list_ptr = *prev;
}
- strncpy (new -> so_name, buffer, MAX_PATH_SIZE - 1);
- new -> so_name[MAX_PATH_SIZE - 1] = '\0';
- free (buffer);
- catch_errors (solib_map_sections, new,
- "Error while mapping shared library sections:\n",
- RETURN_MASK_ALL);
- }
+ }
}
- return (so_list_next);
+
+ return (so_list_ptr);
}
/* A small stub to get us past the arg-passing pinhole of catch_errors. */
static int
symbol_add_stub (arg)
- PTR arg;
+ char *arg;
{
register struct so_list *so = (struct so_list *) arg; /* catch_errs bogon */
- CORE_ADDR text_addr = 0;
-
- if (so -> textsection)
- text_addr = so -> textsection -> addr;
- else if (so -> abfd != NULL)
- {
- asection *lowest_sect;
-
- /* If we didn't find a mapped non zero sized .text section, set up
- text_addr so that the relocation in symbol_file_add does no harm. */
-
- lowest_sect = bfd_get_section_by_name (so -> abfd, ".text");
- if (lowest_sect == NULL)
- bfd_map_over_sections (so -> abfd, find_lowest_section,
- (PTR) &lowest_sect);
- if (lowest_sect)
- text_addr = bfd_section_vma (so -> abfd, lowest_sect)
- + (CORE_ADDR) LM_ADDR (so);
- }
- ALL_OBJFILES (so -> objfile)
- {
- if (strcmp (so -> objfile -> name, so -> so_name) == 0)
- return 1;
- }
so -> objfile =
symbol_file_add (so -> so_name, so -> from_tty,
- text_addr,
- 0, 0, 0, 0, 1);
+ (so->textsection == NULL
+ ? 0
+ : (unsigned int) so -> textsection -> addr),
+ 0, 0, 0);
return (1);
}
@@ -1103,7 +1157,7 @@ solib_add (arg_string, from_tty, target)
/* Count how many new section_table entries there are. */
so = NULL;
count = 0;
- while ((so = find_solib (so)) != NULL)
+ while ((so = find_solib (so, 1)) != NULL)
{
if (so -> so_name[0] && !match_main (so -> so_name))
{
@@ -1119,7 +1173,7 @@ solib_add (arg_string, from_tty, target)
here, otherwise we dereference a potential dangling pointer
for each call to target_read/write_memory within this routine. */
update_coreops = core_ops.to_sections == target->to_sections;
-
+
/* Reallocate the target's section table including the new size. */
if (target -> to_sections)
{
@@ -1145,7 +1199,7 @@ solib_add (arg_string, from_tty, target)
}
/* Add these section table entries to the target's table. */
- while ((so = find_solib (so)) != NULL)
+ while ((so = find_solib (so, 1)) != NULL)
{
if (so -> so_name[0])
{
@@ -1160,7 +1214,7 @@ solib_add (arg_string, from_tty, target)
}
/* Now add the symbol files. */
- while ((so = find_solib (so)) != NULL)
+ while ((so = find_solib (so, 1)) != NULL)
{
if (so -> so_name[0] && re_exec (so -> so_name) &&
!match_main (so -> so_name))
@@ -1174,7 +1228,7 @@ solib_add (arg_string, from_tty, target)
}
}
else if (catch_errors
- (symbol_add_stub, so,
+ (symbol_add_stub, (char *) so,
"Error while reading shared library symbols:\n",
RETURN_MASK_ALL))
{
@@ -1216,41 +1270,30 @@ info_sharedlibrary_command (ignore, from_tty)
{
register struct so_list *so = NULL; /* link map state variable */
int header_done = 0;
- int addr_width;
- char *addr_fmt;
-
+
if (exec_bfd == NULL)
{
printf_unfiltered ("No exec file.\n");
return;
}
-
-#ifndef TARGET_ELF64
- addr_width = 8+4;
- addr_fmt = "08l";
-#else
- addr_width = 16+4;
- addr_fmt = "016l";
-#endif
-
- while ((so = find_solib (so)) != NULL)
+ while ((so = find_solib (so, 0)) != NULL)
{
if (so -> so_name[0])
{
if (!header_done)
{
- printf_unfiltered("%-*s%-*s%-12s%s\n", addr_width, "From",
- addr_width, "To", "Syms Read",
- "Shared Object Library");
+ printf_unfiltered("%-12s%-12s%-12s%s\n", "From", "To", "Syms Read",
+ "Shared Object Library");
header_done++;
}
-
- printf_unfiltered ("%-*s", addr_width,
+ /* FIXME-32x64: need print_address_numeric with field width or
+ some such. */
+ printf_unfiltered ("%-12s",
local_hex_string_custom ((unsigned long) LM_ADDR (so),
- addr_fmt));
- printf_unfiltered ("%-*s", addr_width,
+ "08l"));
+ printf_unfiltered ("%-12s",
local_hex_string_custom ((unsigned long) so -> lmend,
- addr_fmt));
+ "08l"));
printf_unfiltered ("%-12s", so -> symbols_loaded ? "Yes" : "No");
printf_unfiltered ("%s\n", so -> so_name);
}
@@ -1291,7 +1334,7 @@ solib_address (address)
{
register struct so_list *so = 0; /* link map state variable */
- while ((so = find_solib (so)) != NULL)
+ while ((so = find_solib (so, 0)) != NULL)
{
if (so -> so_name[0])
{
@@ -1309,62 +1352,16 @@ void
clear_solib()
{
struct so_list *next;
- char *bfd_filename;
while (so_list_head)
{
- if (so_list_head -> sections)
- {
- free ((PTR)so_list_head -> sections);
- }
- if (so_list_head -> abfd)
- {
- bfd_filename = bfd_get_filename (so_list_head -> abfd);
- if (!bfd_close (so_list_head -> abfd))
- warning ("cannot close \"%s\": %s",
- bfd_filename, bfd_errmsg (bfd_get_error ()));
- }
- else
- /* This happens for the executable on SVR4. */
- bfd_filename = NULL;
-
next = so_list_head -> next;
- if (bfd_filename)
- free ((PTR)bfd_filename);
- free ((PTR)so_list_head);
+ free_solib (so_list_head);
so_list_head = next;
}
debug_base = 0;
}
-static void
-do_clear_solib (dummy)
- PTR dummy;
-{
- solib_cleanup_queued = 0;
- clear_solib ();
-}
-
-#ifdef SVR4_SHARED_LIBS
-
-/* Return 1 if PC lies in the dynamic symbol resolution code of the
- SVR4 run time loader. */
-
-static CORE_ADDR interp_text_sect_low;
-static CORE_ADDR interp_text_sect_high;
-static CORE_ADDR interp_plt_sect_low;
-static CORE_ADDR interp_plt_sect_high;
-
-int
-in_svr4_dynsym_resolve_code (pc)
- CORE_ADDR pc;
-{
- return ((pc >= interp_text_sect_low && pc < interp_text_sect_high)
- || (pc >= interp_plt_sect_low && pc < interp_plt_sect_high)
- || in_plt_section (pc, NULL));
-}
-#endif
-
/*
LOCAL FUNCTION
@@ -1525,9 +1522,6 @@ enable_break ()
remove_solib_event_breakpoints ();
#ifdef SVR4_SHARED_LIBS
- interp_text_sect_low = interp_text_sect_high = 0;
- interp_plt_sect_low = interp_plt_sect_high = 0;
-
/* Find the .interp section; if not found, warn the user and drop
into the old breakpoint at symbol code. */
interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
@@ -1552,7 +1546,7 @@ enable_break ()
This address is stored on the stack. However, I've been unable
to find any magic formula to find it for Solaris (appears to
- be trivial on GNU/Linux). Therefore, we have to try an alternate
+ be trivial on Linux). Therefore, we have to try an alternate
mechanism to find the dynamic linker's base address. */
tmp_bfd = bfd_openr (buf, gnutarget);
if (tmp_bfd == NULL)
@@ -1571,25 +1565,6 @@ enable_break ()
linker) and subtracting the offset of the entry point. */
load_addr = read_pc () - tmp_bfd->start_address;
- /* Record the relocated start and end address of the dynamic linker
- text and plt section for in_svr4_dynsym_resolve_code. */
- interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
- if (interp_sect)
- {
- interp_text_sect_low =
- bfd_section_vma (tmp_bfd, interp_sect) + load_addr;
- interp_text_sect_high =
- interp_text_sect_low + bfd_section_size (tmp_bfd, interp_sect);
- }
- interp_sect = bfd_get_section_by_name (tmp_bfd, ".plt");
- if (interp_sect)
- {
- interp_plt_sect_low =
- bfd_section_vma (tmp_bfd, interp_sect) + load_addr;
- interp_plt_sect_high =
- interp_plt_sect_low + bfd_section_size (tmp_bfd, interp_sect);
- }
-
/* Now try to set a breakpoint in the dynamic linker. */
for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++)
{
@@ -1610,7 +1585,9 @@ enable_break ()
/* For whatever reason we couldn't set a breakpoint in the dynamic
linker. Warn and drop into the old code. */
bkpt_at_symbol:
- warning ("Unable to find dynamic linker breakpoint function.\nGDB will be unable to debug shared library initializers\nand track explicitly loaded dynamic code.");
+ warning ("Unable to find dynamic linker breakpoint function.");
+ warning ("GDB will be unable to debug shared library initializers");
+ warning ("and track explicitly loaded dynamic code.");
}
#endif
@@ -1629,7 +1606,7 @@ bkpt_at_symbol:
}
/* Nothing good happened. */
- success = 0;
+ return 0;
#endif /* BKPT_AT_SYMBOL */
@@ -1711,8 +1688,8 @@ solib_create_inferior_hook()
return;
}
-#if !defined(SVR4_SHARED_LIBS) || defined(_SCO_DS)
- /* SCO and SunOS need the loop below, other systems should be using the
+#ifndef SVR4_SHARED_LIBS
+ /* Only SunOS needs the loop below, other systems should be using the
special shared library breakpoints and the shared library breakpoint
service routine.
@@ -1731,8 +1708,7 @@ solib_create_inferior_hook()
}
while (stop_signal != TARGET_SIGNAL_TRAP);
stop_soon_quietly = 0;
-
-#if !defined(_SCO_DS)
+
/* We are now either at the "mapping complete" breakpoint (or somewhere
else, a condition we aren't prepared to deal with anyway), so adjust
the PC as necessary after a breakpoint, disable the breakpoint, and
@@ -1751,7 +1727,6 @@ solib_create_inferior_hook()
if (auto_solib_add)
solib_add ((char *) 0, 0, (struct target_ops *) 0);
-#endif /* ! _SCO_DS */
#endif
}
@@ -1869,20 +1844,5 @@ must be loaded manually, using `sharedlibrary'.",
&setlist),
&showlist);
- add_show_from_set
- (add_set_cmd ("solib-absolute-prefix", class_support, var_filename,
- (char *) &solib_absolute_prefix,
- "Set prefix for loading absolute shared library symbol files.\n\
-For other (relative) files, you can add values using `set solib-search-path'.",
- &setlist),
- &showlist);
- add_show_from_set
- (add_set_cmd ("solib-search-path", class_support, var_string,
- (char *) &solib_search_path,
- "Set the search path for loading non-absolute shared library symbol files.\n\
-This takes precedence over the environment variables PATH and LD_LIBRARY_PATH.",
- &setlist),
- &showlist);
-
#endif /* HAVE_LINK_H */
}
diff --git a/contrib/gdb/gdb/somread.c b/contrib/gdb/gdb/somread.c
deleted file mode 100644
index c03abd0..0000000
--- a/contrib/gdb/gdb/somread.c
+++ /dev/null
@@ -1,803 +0,0 @@
-/* Read HP PA/Risc object files for GDB.
- Copyright 1991, 1992, 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "bfd.h"
-#include <syms.h>
-#include "symtab.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "buildsym.h"
-#include "stabsread.h"
-#include "gdb-stabs.h"
-#include "complaints.h"
-#include "gdb_string.h"
-#include "demangle.h"
-#include "som.h"
-#include "libhppa.h"
-
-/* Various things we might complain about... */
-
-static void
-som_symfile_init PARAMS ((struct objfile *));
-
-static void
-som_new_init PARAMS ((struct objfile *));
-
-static void
-som_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int));
-
-static void
-som_symfile_finish PARAMS ((struct objfile *));
-
-static void
-som_symtab_read PARAMS ((bfd *, struct objfile *,
- struct section_offsets *));
-
-static struct section_offsets *
-som_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
-
-/* FIXME: These should really be in a common header somewhere */
-
-extern void
-hpread_build_psymtabs PARAMS ((struct objfile *, struct section_offsets *, int));
-
-extern void
-hpread_symfile_finish PARAMS ((struct objfile *));
-
-extern void
-hpread_symfile_init PARAMS ((struct objfile *));
-
-extern void
-do_pxdb PARAMS ((bfd *));
-
-/*
-
-LOCAL FUNCTION
-
- som_symtab_read -- read the symbol table of a SOM file
-
-SYNOPSIS
-
- void som_symtab_read (bfd *abfd, struct objfile *objfile,
- struct section_offsets *section_offsets)
-
-DESCRIPTION
-
- Given an open bfd, a base address to relocate symbols to, and a
- flag that specifies whether or not this bfd is for an executable
- or not (may be shared library for example), add all the global
- function and data symbols to the minimal symbol table.
-*/
-
-static void
-som_symtab_read (abfd, objfile, section_offsets)
- bfd *abfd;
- struct objfile *objfile;
- struct section_offsets *section_offsets;
-{
- unsigned int number_of_symbols;
- int val, dynamic;
- char *stringtab;
- asection *shlib_info;
- struct symbol_dictionary_record *buf, *bufp, *endbufp;
- char *symname;
- CONST int symsize = sizeof (struct symbol_dictionary_record);
- CORE_ADDR text_offset, data_offset;
-
-
- text_offset = ANOFFSET (section_offsets, 0);
- data_offset = ANOFFSET (section_offsets, 1);
-
- number_of_symbols = bfd_get_symcount (abfd);
-
- buf = alloca (symsize * number_of_symbols);
- bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET);
- val = bfd_read (buf, symsize * number_of_symbols, 1, abfd);
- if (val != symsize * number_of_symbols)
- error ("Couldn't read symbol dictionary!");
-
- stringtab = alloca (obj_som_stringtab_size (abfd));
- bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET);
- val = bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd);
- if (val != obj_som_stringtab_size (abfd))
- error ("Can't read in HP string table.");
-
- /* We need to determine if objfile is a dynamic executable (so we
- can do the right thing for ST_ENTRY vs ST_CODE symbols).
-
- There's nothing in the header which easily allows us to do
- this. The only reliable way I know of is to check for the
- existance of a $SHLIB_INFO$ section with a non-zero size. */
- /* The code below is not a reliable way to check whether an
- * executable is dynamic, so I commented it out - RT
- * shlib_info = bfd_get_section_by_name (objfile->obfd, "$SHLIB_INFO$");
- * if (shlib_info)
- * dynamic = (bfd_section_size (objfile->obfd, shlib_info) != 0);
- * else
- * dynamic = 0;
- */
- /* I replaced the code with a simple check for text offset not being
- * zero. Still not 100% reliable, but a more reliable way of asking
- * "is this a dynamic executable?" than the above. RT
- */
- dynamic = (text_offset != 0);
-
- endbufp = buf + number_of_symbols;
- for (bufp = buf; bufp < endbufp; ++bufp)
- {
- enum minimal_symbol_type ms_type;
-
- QUIT;
-
- switch (bufp->symbol_scope)
- {
- case SS_UNIVERSAL:
- case SS_EXTERNAL:
- switch (bufp->symbol_type)
- {
- case ST_SYM_EXT:
- case ST_ARG_EXT:
- continue;
-
- case ST_CODE:
- case ST_PRI_PROG:
- case ST_SEC_PROG:
- case ST_MILLICODE:
- symname = bufp->name.n_strx + stringtab;
- ms_type = mst_text;
- bufp->symbol_value += text_offset;
-#ifdef SMASH_TEXT_ADDRESS
- SMASH_TEXT_ADDRESS (bufp->symbol_value);
-#endif
- break;
-
- case ST_ENTRY:
- symname = bufp->name.n_strx + stringtab;
- /* For a dynamic executable, ST_ENTRY symbols are
- the stubs, while the ST_CODE symbol is the real
- function. */
- if (dynamic)
- ms_type = mst_solib_trampoline;
- else
- ms_type = mst_text;
- bufp->symbol_value += text_offset;
-#ifdef SMASH_TEXT_ADDRESS
- SMASH_TEXT_ADDRESS (bufp->symbol_value);
-#endif
- break;
-
- case ST_STUB:
- symname = bufp->name.n_strx + stringtab;
- ms_type = mst_solib_trampoline;
- bufp->symbol_value += text_offset;
-#ifdef SMASH_TEXT_ADDRESS
- SMASH_TEXT_ADDRESS (bufp->symbol_value);
-#endif
- break;
-
- case ST_DATA:
- symname = bufp->name.n_strx + stringtab;
- bufp->symbol_value += data_offset;
- ms_type = mst_data;
- break;
- default:
- continue;
- }
- break;
-
-#if 0
- /* SS_GLOBAL and SS_LOCAL are two names for the same thing (!). */
- case SS_GLOBAL:
-#endif
- case SS_LOCAL:
- switch (bufp->symbol_type)
- {
- case ST_SYM_EXT:
- case ST_ARG_EXT:
- continue;
-
- case ST_CODE:
- symname = bufp->name.n_strx + stringtab;
- ms_type = mst_file_text;
- bufp->symbol_value += text_offset;
-#ifdef SMASH_TEXT_ADDRESS
- SMASH_TEXT_ADDRESS (bufp->symbol_value);
-#endif
-
- check_strange_names:
- /* Utah GCC 2.5, FSF GCC 2.6 and later generate correct local
- label prefixes for stabs, constant data, etc. So we need
- only filter out L$ symbols which are left in due to
- limitations in how GAS generates SOM relocations.
-
- When linking in the HPUX C-library the HP linker has
- the nasty habit of placing section symbols from the literal
- subspaces in the middle of the program's text. Filter
- those out as best we can. Check for first and last character
- being '$'.
-
- And finally, the newer HP compilers emit crud like $PIC_foo$N
- in some circumstance (PIC code I guess). It's also claimed
- that they emit D$ symbols too. What stupidity. */
- if ((symname[0] == 'L' && symname[1] == '$')
- || (symname[0] == '$' && symname[strlen(symname) - 1] == '$')
- || (symname[0] == 'D' && symname[1] == '$')
- || (strncmp (symname, "$PIC", 4) == 0))
- continue;
- break;
-
- case ST_PRI_PROG:
- case ST_SEC_PROG:
- case ST_MILLICODE:
- symname = bufp->name.n_strx + stringtab;
- ms_type = mst_file_text;
- bufp->symbol_value += text_offset;
-#ifdef SMASH_TEXT_ADDRESS
- SMASH_TEXT_ADDRESS (bufp->symbol_value);
-#endif
- break;
-
- case ST_ENTRY:
- symname = bufp->name.n_strx + stringtab;
- /* For a dynamic executable, ST_ENTRY symbols are
- the stubs, while the ST_CODE symbol is the real
- function. */
- if (dynamic)
- ms_type = mst_solib_trampoline;
- else
- ms_type = mst_file_text;
- bufp->symbol_value += text_offset;
-#ifdef SMASH_TEXT_ADDRESS
- SMASH_TEXT_ADDRESS (bufp->symbol_value);
-#endif
- break;
-
- case ST_STUB:
- symname = bufp->name.n_strx + stringtab;
- ms_type = mst_solib_trampoline;
- bufp->symbol_value += text_offset;
-#ifdef SMASH_TEXT_ADDRESS
- SMASH_TEXT_ADDRESS (bufp->symbol_value);
-#endif
- break;
-
-
- case ST_DATA:
- symname = bufp->name.n_strx + stringtab;
- bufp->symbol_value += data_offset;
- ms_type = mst_file_data;
- goto check_strange_names;
-
- default:
- continue;
- }
- break;
-
- /* This can happen for common symbols when -E is passed to the
- final link. No idea _why_ that would make the linker force
- common symbols to have an SS_UNSAT scope, but it does.
-
- This also happens for weak symbols, but their type is
- ST_DATA. */
- case SS_UNSAT:
- switch (bufp->symbol_type)
- {
- case ST_STORAGE:
- case ST_DATA:
- symname = bufp->name.n_strx + stringtab;
- bufp->symbol_value += data_offset;
- ms_type = mst_data;
- break;
-
- default:
- continue;
- }
- break;
-
- default:
- continue;
- }
-
- if (bufp->name.n_strx > obj_som_stringtab_size (abfd))
- error ("Invalid symbol data; bad HP string table offset: %d",
- bufp->name.n_strx);
-
- prim_record_minimal_symbol (symname, bufp->symbol_value, ms_type,
- objfile);
- }
-}
-
-/* Scan and build partial symbols for a symbol file.
- We have been initialized by a call to som_symfile_init, which
- currently does nothing.
-
- SECTION_OFFSETS is a set of offsets to apply to relocate the symbols
- in each section. This is ignored, as it isn't needed for SOM.
-
- 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.
-
- We look for sections with specific names, to tell us what debug
- format to look for: FIXME!!!
-
- somstab_build_psymtabs() handles STABS symbols.
-
- Note that SOM files have a "minimal" symbol table, which is vaguely
- reminiscent of a COFF symbol table, but has only the minimal information
- necessary for linking. We process this also, and use the information to
- build gdb's minimal symbol table. This gives us some minimal debugging
- capability even for files compiled without -g. */
-
-static void
-som_symfile_read (objfile, section_offsets, mainline)
- struct objfile *objfile;
- struct section_offsets *section_offsets;
- int mainline;
-{
- bfd *abfd = objfile->obfd;
- struct cleanup *back_to;
-
- do_pxdb (symfile_bfd_open (objfile->name));
-
- init_minimal_symbol_collection ();
- back_to = make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0);
-
- /* Read in the import list and the export list. Currently
- the export list isn't used; the import list is used in
- hp-symtab-read.c to handle static vars declared in other
- shared libraries. */
- init_import_symbols (objfile);
-#if 0 /* Export symbols not used today 1997-08-05 */
- init_export_symbols (objfile);
-#else
- objfile->export_list = NULL;
- objfile->export_list_size = 0;
-#endif
-
- /* Process the normal SOM symbol table first.
- This reads in the DNTT and string table, but doesn't
- actually scan the DNTT. It does scan the linker symbol
- table and thus build up a "minimal symbol table". */
-
- som_symtab_read (abfd, objfile, section_offsets);
-
- /* Now read information from the stabs debug sections.
- This is a no-op for SOM.
- Perhaps it is intended for some kind of mixed STABS/SOM
- situation? */
- stabsect_build_psymtabs (objfile, section_offsets, mainline,
- "$GDB_SYMBOLS$", "$GDB_STRINGS$", "$TEXT$");
-
- /* Now read the native debug information.
- This builds the psymtab. This used to be done via a scan of
- the DNTT, but is now done via the PXDB-built quick-lookup tables
- together with a scan of the GNTT. See hp-psymtab-read.c. */
- hpread_build_psymtabs (objfile, section_offsets, mainline);
-
- /* Install any minimal symbols that have been collected as the current
- minimal symbols for this objfile.
- Further symbol-reading is done incrementally, file-by-file,
- in a step known as "psymtab-to-symtab" expansion. hp-symtab-read.c
- contains the code to do the actual DNTT scanning and symtab building. */
- install_minimal_symbols (objfile);
-
- /* Force hppa-tdep.c to re-read the unwind descriptors. */
- objfile->obj_private = NULL;
- 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).
-
- We reinitialize buildsym, since we may be reading stabs from a SOM file. */
-
-static void
-som_new_init (ignore)
- struct objfile *ignore;
-{
- stabsread_new_init ();
- buildsym_new_init ();
-}
-
-/* Perform any local cleanups required when we are done with a particular
- objfile. I.E, we are in the process of discarding all symbol information
- for an objfile, freeing up all memory held for it, and unlinking the
- objfile struct from the global list of known objfiles. */
-
-static void
-som_symfile_finish (objfile)
- struct objfile *objfile;
-{
- if (objfile -> sym_stab_info != NULL)
- {
- mfree (objfile -> md, objfile -> sym_stab_info);
- }
- hpread_symfile_finish (objfile);
-}
-
-/* SOM specific initialization routine for reading symbols. */
-
-static void
-som_symfile_init (objfile)
- struct objfile *objfile;
-{
- /* SOM objects may be reordered, so set OBJF_REORDERED. If we
- find this causes a significant slowdown in gdb then we could
- set it in the debug symbol readers only when necessary. */
- objfile->flags |= OBJF_REORDERED;
- hpread_symfile_init (objfile);
-}
-
-/* SOM specific parsing routine for section offsets.
-
- Plain and simple for now. */
-
-static struct section_offsets *
-som_symfile_offsets (objfile, addr)
- struct objfile *objfile;
- CORE_ADDR addr;
-{
- struct section_offsets *section_offsets;
- int i;
-
- objfile->num_sections = SECT_OFF_MAX;
- section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile -> psymbol_obstack, SIZEOF_SECTION_OFFSETS);
-
- /* First see if we're a shared library. If so, get the section
- offsets from the library, else get them from addr. */
- if (!som_solib_section_offsets (objfile, section_offsets))
- {
- for (i = 0; i < SECT_OFF_MAX; i++)
- ANOFFSET (section_offsets, i) = addr;
- }
-
- return section_offsets;
-}
-
-
-
-/* Check if a given symbol NAME is in the import list
- of OBJFILE.
- 1 => true, 0 => false
- This is used in hp_symtab_read.c to deal with static variables
- that are defined in a different shared library than the one
- whose symbols are being processed. */
-
-int is_in_import_list (name, objfile)
- char * name;
- struct objfile * objfile;
-{
- register int i;
-
- if (!objfile ||
- !name ||
- !*name)
- return 0;
-
- for (i=0; i < objfile->import_list_size; i++)
- if (objfile->import_list[i] && STREQ (name, objfile->import_list[i]))
- return 1;
- return 0;
-}
-
-
-/* Read in and initialize the SOM import list which is present
- for all executables and shared libraries. The import list
- consists of the symbols that are referenced in OBJFILE but
- not defined there. (Variables that are imported are dealt
- with as "loc_indirect" vars.)
- Return value = number of import symbols read in. */
-int
-init_import_symbols (objfile)
- struct objfile * objfile;
-{
- unsigned int import_list;
- unsigned int import_list_size;
- unsigned int string_table;
- unsigned int string_table_size;
- char * string_buffer;
- register int i;
- register int j;
- register int k;
- asection * text_section; /* section handle */
- unsigned int dl_header[12]; /* SOM executable header */
-
- /* A struct for an entry in the SOM import list */
- typedef struct {
- int name; /* index into the string table */
- short dont_care1; /* we don't use this */
- unsigned char type; /* 0 = NULL, 2 = Data, 3 = Code, 7 = Storage, 13 = Plabel */
- unsigned int reserved2 : 8; /* not used */
- } SomImportEntry;
-
- /* We read 100 entries in at a time from the disk file. */
-# define SOM_READ_IMPORTS_NUM 100
-# define SOM_READ_IMPORTS_CHUNK_SIZE (sizeof (SomImportEntry) * SOM_READ_IMPORTS_NUM)
- SomImportEntry buffer[SOM_READ_IMPORTS_NUM];
-
- /* Initialize in case we error out */
- objfile->import_list = NULL;
- objfile->import_list_size = 0;
-
-#if 0 /* DEBUGGING */
- printf ("Processing import list for %s\n", objfile->name);
-#endif
-
- /* It doesn't work, for some reason, to read in space $TEXT$;
- the subspace $SHLIB_INFO$ has to be used. Some BFD quirk? pai/1997-08-05 */
- text_section = bfd_get_section_by_name (objfile->obfd, "$SHLIB_INFO$");
- if (!text_section)
- return 0;
- /* Get the SOM executable header */
- bfd_get_section_contents (objfile->obfd, text_section, dl_header, 0, 12 * sizeof (int));
-
- /* Check header version number for 10.x HP-UX */
- /* Currently we deal only with 10.x systems; on 9.x the version # is 89060912.
- FIXME: Change for future HP-UX releases and mods to the SOM executable format */
- if (dl_header[0] != 93092112)
- return 0;
-
- import_list = dl_header[4];
- import_list_size = dl_header[5];
- if (!import_list_size)
- return 0;
- string_table = dl_header[10];
- string_table_size = dl_header[11];
- if (!string_table_size)
- return 0;
-
- /* Suck in SOM string table */
- string_buffer = (char *) xmalloc (string_table_size);
- bfd_get_section_contents (objfile->obfd, text_section, string_buffer,
- string_table, string_table_size);
-
- /* Allocate import list in the psymbol obstack; this has nothing
- to do with psymbols, just a matter of convenience. We want the
- import list to be freed when the objfile is deallocated */
- objfile->import_list
- = (ImportEntry *) obstack_alloc (&objfile->psymbol_obstack,
- import_list_size * sizeof (ImportEntry));
-
- /* Read in the import entries, a bunch at a time */
- for (j=0, k=0;
- j < (import_list_size / SOM_READ_IMPORTS_NUM);
- j++)
- {
- bfd_get_section_contents (objfile->obfd, text_section, buffer,
- import_list + j * SOM_READ_IMPORTS_CHUNK_SIZE,
- SOM_READ_IMPORTS_CHUNK_SIZE);
- for (i=0; i < SOM_READ_IMPORTS_NUM; i++, k++)
- {
- if (buffer[i].type != (unsigned char) 0)
- {
- objfile->import_list[k]
- = (char *) obstack_alloc (&objfile->psymbol_obstack, strlen (string_buffer + buffer[i].name) + 1);
- strcpy (objfile->import_list[k], string_buffer + buffer[i].name);
- /* Some day we might want to record the type and other information too */
- }
- else /* null type */
- objfile->import_list[k] = NULL;
-
-#if 0 /* DEBUGGING */
- printf ("Import String %d:%d (%d), type %d is %s\n", j, i, k,
- (int) buffer[i].type, objfile->import_list[k]);
-#endif
- }
- }
-
- /* Get the leftovers */
- if (k < import_list_size)
- bfd_get_section_contents (objfile->obfd, text_section, buffer,
- import_list + k * sizeof (SomImportEntry),
- (import_list_size - k) * sizeof (SomImportEntry));
- for (i=0; k < import_list_size; i++, k++)
- {
- if (buffer[i].type != (unsigned char) 0)
- {
- objfile->import_list[k]
- = (char *) obstack_alloc (&objfile->psymbol_obstack, strlen (string_buffer + buffer[i].name) + 1);
- strcpy (objfile->import_list[k], string_buffer + buffer[i].name);
- /* Some day we might want to record the type and other information too */
- }
- else
- objfile->import_list[k] = NULL;
-#if 0 /* DEBUGGING */
- printf ("Import String F:%d (%d), type %d, is %s\n", i, k,
- (int) buffer[i].type, objfile->import_list[k]);
-#endif
- }
-
- objfile->import_list_size = import_list_size;
- free (string_buffer);
- return import_list_size;
-}
-
-/* Read in and initialize the SOM export list which is present
- for all executables and shared libraries. The import list
- consists of the symbols that are referenced in OBJFILE but
- not defined there. (Variables that are imported are dealt
- with as "loc_indirect" vars.)
- Return value = number of import symbols read in. */
-int
-init_export_symbols (objfile)
- struct objfile * objfile;
-{
- unsigned int export_list;
- unsigned int export_list_size;
- unsigned int string_table;
- unsigned int string_table_size;
- char * string_buffer;
- register int i;
- register int j;
- register int k;
- asection * text_section; /* section handle */
- unsigned int dl_header[12]; /* SOM executable header */
-
- /* A struct for an entry in the SOM export list */
- typedef struct {
- int next; /* for hash table use -- we don't use this */
- int name; /* index into string table */
- int value; /* offset or plabel */
- int dont_care1; /* not used */
- unsigned char type; /* 0 = NULL, 2 = Data, 3 = Code, 7 = Storage, 13 = Plabel */
- char dont_care2; /* not used */
- short dont_care3; /* not used */
- } SomExportEntry;
-
- /* We read 100 entries in at a time from the disk file. */
-# define SOM_READ_EXPORTS_NUM 100
-# define SOM_READ_EXPORTS_CHUNK_SIZE (sizeof (SomExportEntry) * SOM_READ_EXPORTS_NUM)
- SomExportEntry buffer[SOM_READ_EXPORTS_NUM];
-
- /* Initialize in case we error out */
- objfile->export_list = NULL;
- objfile->export_list_size = 0;
-
-#if 0 /* DEBUGGING */
- printf ("Processing export list for %s\n", objfile->name);
-#endif
-
- /* It doesn't work, for some reason, to read in space $TEXT$;
- the subspace $SHLIB_INFO$ has to be used. Some BFD quirk? pai/1997-08-05 */
- text_section = bfd_get_section_by_name (objfile->obfd, "$SHLIB_INFO$");
- if (!text_section)
- return 0;
- /* Get the SOM executable header */
- bfd_get_section_contents (objfile->obfd, text_section, dl_header, 0, 12 * sizeof (int));
-
- /* Check header version number for 10.x HP-UX */
- /* Currently we deal only with 10.x systems; on 9.x the version # is 89060912.
- FIXME: Change for future HP-UX releases and mods to the SOM executable format */
- if (dl_header[0] != 93092112)
- return 0;
-
- export_list = dl_header[8];
- export_list_size = dl_header[9];
- if (!export_list_size)
- return 0;
- string_table = dl_header[10];
- string_table_size = dl_header[11];
- if (!string_table_size)
- return 0;
-
- /* Suck in SOM string table */
- string_buffer = (char *) xmalloc (string_table_size);
- bfd_get_section_contents (objfile->obfd, text_section, string_buffer,
- string_table, string_table_size);
-
- /* Allocate export list in the psymbol obstack; this has nothing
- to do with psymbols, just a matter of convenience. We want the
- export list to be freed when the objfile is deallocated */
- objfile->export_list
- = (ExportEntry *) obstack_alloc (&objfile->psymbol_obstack,
- export_list_size * sizeof (ExportEntry));
-
- /* Read in the export entries, a bunch at a time */
- for (j=0, k=0;
- j < (export_list_size / SOM_READ_EXPORTS_NUM);
- j++)
- {
- bfd_get_section_contents (objfile->obfd, text_section, buffer,
- export_list + j * SOM_READ_EXPORTS_CHUNK_SIZE,
- SOM_READ_EXPORTS_CHUNK_SIZE);
- for (i=0; i < SOM_READ_EXPORTS_NUM; i++, k++)
- {
- if (buffer[i].type != (unsigned char) 0)
- {
- objfile->export_list[k].name
- = (char *) obstack_alloc (&objfile->psymbol_obstack, strlen (string_buffer + buffer[i].name) + 1);
- strcpy (objfile->export_list[k].name, string_buffer + buffer[i].name);
- objfile->export_list[k].address = buffer[i].value;
- /* Some day we might want to record the type and other information too */
- }
- else /* null type */
- {
- objfile->export_list[k].name = NULL;
- objfile->export_list[k].address = 0;
- }
-#if 0 /* DEBUGGING */
- printf ("Export String %d:%d (%d), type %d is %s\n", j, i, k,
- (int) buffer[i].type, objfile->export_list[k].name);
-#endif
- }
- }
-
- /* Get the leftovers */
- if (k < export_list_size)
- bfd_get_section_contents (objfile->obfd, text_section, buffer,
- export_list + k * sizeof (SomExportEntry),
- (export_list_size - k) * sizeof (SomExportEntry));
- for (i=0; k < export_list_size; i++, k++)
- {
- if (buffer[i].type != (unsigned char) 0)
- {
- objfile->export_list[k].name
- = (char *) obstack_alloc (&objfile->psymbol_obstack, strlen (string_buffer + buffer[i].name) + 1);
- strcpy (objfile->export_list[k].name, string_buffer + buffer[i].name);
- /* Some day we might want to record the type and other information too */
- objfile->export_list[k].address = buffer[i].value;
- }
- else
- {
- objfile->export_list[k].name = NULL;
- objfile->export_list[k].address = 0;
- }
-#if 0 /* DEBUGGING */
- printf ("Export String F:%d (%d), type %d, value %x is %s\n", i, k,
- (int) buffer[i].type, buffer[i].value, objfile->export_list[k].name);
-#endif
- }
-
- objfile->export_list_size = export_list_size;
- free (string_buffer);
- return export_list_size;
-}
-
-
-
-/* Register that we are able to handle SOM object file formats. */
-
-static struct sym_fns som_sym_fns =
-{
- bfd_target_som_flavour,
- som_new_init, /* sym_new_init: init anything gbl to entire symtab */
- som_symfile_init, /* sym_init: read initial info, setup for sym_read() */
- som_symfile_read, /* sym_read: read a symbol file into symtab */
- som_symfile_finish, /* sym_finish: finished with file, cleanup */
- som_symfile_offsets, /* sym_offsets: Translate ext. to int. relocation */
- NULL /* next: pointer to next struct sym_fns */
-};
-
-void
-_initialize_somread ()
-{
- add_symtab_fns (&som_sym_fns);
-}
diff --git a/contrib/gdb/gdb/somsolib.c b/contrib/gdb/gdb/somsolib.c
deleted file mode 100644
index 870177c..0000000
--- a/contrib/gdb/gdb/somsolib.c
+++ /dev/null
@@ -1,1640 +0,0 @@
-/* Handle HP SOM shared libraries for GDB, the GNU Debugger.
- Copyright 1993, 1996, 1999 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Written by the Center for Software Science at the Univerity of Utah
-and by Cygnus Support. */
-
-
-#include "defs.h"
-
-#include "frame.h"
-#include "bfd.h"
-#include "som.h"
-#include "libhppa.h"
-#include "gdbcore.h"
-#include "symtab.h"
-#include "breakpoint.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "inferior.h"
-#include "gdb-stabs.h"
-#include "gdb_stat.h"
-#include "gdbcmd.h"
-#include "assert.h"
-#include "language.h"
-
-#include <fcntl.h>
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-/* Uncomment this to turn on some debugging output.
- */
-
-/* #define SOLIB_DEBUG
- */
-
-/* Defined in exec.c; used to prevent dangling pointer bug.
- */
-extern struct target_ops exec_ops;
-
-/* This lives in hppa-tdep.c. */
-extern struct unwind_table_entry *find_unwind_entry PARAMS ((CORE_ADDR pc));
-
-/* These ought to be defined in some public interface, but aren't. They
- define the meaning of the various bits in the distinguished __dld_flags
- variable that is declared in every debuggable a.out on HP-UX, and that
- is shared between the debugger and the dynamic linker.
- */
-#define DLD_FLAGS_MAPPRIVATE 0x1
-#define DLD_FLAGS_HOOKVALID 0x2
-#define DLD_FLAGS_LISTVALID 0x4
-#define DLD_FLAGS_BOR_ENABLE 0x8
-
-/* TODO:
-
- * Most of this code should work for hp300 shared libraries. Does
- anyone care enough to weed out any SOM-isms.
-
- * Support for hpux8 dynamic linker. */
-
-/* The basic structure which describes a dynamically loaded object. This
- data structure is private to the dynamic linker and isn't found in
- any HPUX include file. */
-
-struct som_solib_mapped_entry
-{
- /* The name of the library. */
- char *name;
-
- /* Version of this structure (it is expected to change again in hpux10). */
- unsigned char struct_version;
-
- /* Binding mode for this library. */
- unsigned char bind_mode;
-
- /* Version of this library. */
- short library_version;
-
- /* Start of text address,
- * link-time text location (length of text area),
- * end of text address. */
- CORE_ADDR text_addr;
- CORE_ADDR text_link_addr;
- CORE_ADDR text_end;
-
- /* Start of data, start of bss and end of data. */
- CORE_ADDR data_start;
- CORE_ADDR bss_start;
- CORE_ADDR data_end;
-
- /* Value of linkage pointer (%r19). */
- CORE_ADDR got_value;
-
- /* Next entry. */
- struct som_solib_mapped_entry *next;
-
- /* There are other fields, but I don't have information as to what is
- contained in them. */
-
- /* For versions from HPUX-10.30 and up */
-
- /* Address in target of offset from thread-local register of
- * start of this thread's data. I.e., the first thread-local
- * variable in this shared library starts at *(tsd_start_addr)
- * from that area pointed to by cr27 (mpsfu_hi).
- *
- * We do the indirection as soon as we read it, so from then
- * on it's the offset itself.
- */
- CORE_ADDR tsd_start_addr;
-
- /* Following this are longwords holding:
- *
- * ?, ?, ?, ptr to -1, ptr to-1, ptr to lib name (leaf name),
- * ptr to __data_start, ptr to __data_end
- */
-
-
-};
-
-/* A structure to keep track of all the known shared objects. */
-struct so_list
-{
- struct som_solib_mapped_entry som_solib;
- struct objfile *objfile;
- bfd *abfd;
- struct section_table *sections;
- struct section_table *sections_end;
-/* elz: added this field to store the address in target space (in the
- library) of the library descriptor (handle) which we read into
- som_solib_mapped_entry structure*/
- CORE_ADDR solib_addr;
- struct so_list *next;
-
-};
-
-static struct so_list *so_list_head;
-
-
-/* This is the cumulative size in bytes of the symbol tables of all
- shared objects on the so_list_head list. (When we say size, here
- we mean of the information before it is brought into memory and
- potentially expanded by GDB.) When adding a new shlib, this value
- is compared against the threshold size, held by auto_solib_add
- (in megabytes). If adding symbols for the new shlib would cause
- the total size to exceed the threshold, then the new shlib's symbols
- are not loaded.
- */
-static LONGEST som_solib_total_st_size;
-
-/* When the threshold is reached for any shlib, we refuse to add
- symbols for subsequent shlibs, even if those shlibs' symbols would
- be small enough to fit under the threshold. (Although this may
- result in one, early large shlib preventing the loading of later,
- smalller shlibs' symbols, it allows us to issue one informational
- message. The alternative, to issue a message for each shlib whose
- symbols aren't loaded, could be a big annoyance where the threshold
- is exceeded due to a very large number of shlibs.)
- */
-static int som_solib_st_size_threshold_exceeded;
-
-/* These addresses should be filled in by som_solib_create_inferior_hook.
- They are also used elsewhere in this module.
- */
-typedef struct {
- CORE_ADDR address;
- struct unwind_table_entry * unwind;
-} addr_and_unwind_t;
-
-/* When adding fields, be sure to clear them in _initialize_som_solib. */
-static struct {
- boolean is_valid;
- addr_and_unwind_t hook;
- addr_and_unwind_t hook_stub;
- addr_and_unwind_t load;
- addr_and_unwind_t load_stub;
- addr_and_unwind_t unload;
- addr_and_unwind_t unload2;
- addr_and_unwind_t unload_stub;
-} dld_cache;
-
-
-
-static void som_sharedlibrary_info_command PARAMS ((char *, int));
-
-static void som_solib_sharedlibrary_command PARAMS ((char *, int));
-
-static LONGEST
-som_solib_sizeof_symbol_table (filename)
- char * filename;
-{
- bfd * abfd;
- int desc;
- char * absolute_name;
- LONGEST st_size = (LONGEST) 0;
- asection * sect;
-
- /* We believe that filename was handed to us by the dynamic linker, and
- is therefore always an absolute path.
- */
- desc = openp (getenv ("PATH"), 1, filename, O_RDONLY | O_BINARY, 0, &absolute_name);
- if (desc < 0)
- {
- perror_with_name (filename);
- }
- filename = absolute_name;
-
- abfd = bfd_fdopenr (filename, gnutarget, desc);
- if (! abfd)
- {
- close (desc);
- make_cleanup (free, filename);
- error ("\"%s\": can't open to read symbols: %s.", filename,
- bfd_errmsg (bfd_get_error ()));
- }
-
- if (!bfd_check_format (abfd, bfd_object)) /* Reads in section info */
- {
- bfd_close (abfd); /* This also closes desc */
- make_cleanup (free, filename);
- error ("\"%s\": can't read symbols: %s.", filename,
- bfd_errmsg (bfd_get_error ()));
- }
-
- /* Sum the sizes of the various sections that compose debug info. */
-
- /* This contains non-DOC information. */
- sect = bfd_get_section_by_name (abfd, "$DEBUG$");
- if (sect)
- st_size += (LONGEST) bfd_section_size (abfd, sect);
-
- /* This contains DOC information. */
- sect = bfd_get_section_by_name (abfd, "$PINFO$");
- if (sect)
- st_size += (LONGEST) bfd_section_size (abfd, sect);
-
- bfd_close (abfd); /* This also closes desc */
- free (filename);
-
- /* Unfortunately, just summing the sizes of various debug info
- sections isn't a very accurate measurement of how much heap
- space the debugger will need to hold them. It also doesn't
- account for space needed by linker (aka "minimal") symbols.
-
- Anecdotal evidence suggests that just summing the sizes of
- debug-info-related sections understates the heap space needed
- to represent it internally by about an order of magnitude.
-
- Since it's not exactly brain surgery we're doing here, rather
- than attempt to more accurately measure the size of a shlib's
- symbol table in GDB's heap, we'll just apply a 10x fudge-
- factor to the debug info sections' size-sum. No, this doesn't
- account for minimal symbols in non-debuggable shlibs. But it
- all roughly washes out in the end.
- */
- return st_size * (LONGEST) 10;
-}
-
-
-static void
-som_solib_add_solib_objfile (so, name, from_tty, text_addr)
- struct so_list * so;
- char * name;
- int from_tty;
- CORE_ADDR text_addr;
-{
- obj_private_data_t *obj_private;
-
- so->objfile = symbol_file_add (name, from_tty, text_addr, 0, 0, 0, 0, 1);
- so->abfd = so->objfile->obfd;
-
- /* Mark this as a shared library and save private data.
- */
- so->objfile->flags |= OBJF_SHARED;
-
- if( so->objfile->obj_private == NULL )
- {
- obj_private = (obj_private_data_t *)
- obstack_alloc( &so->objfile->psymbol_obstack,
- sizeof( obj_private_data_t ));
- obj_private->unwind_info = NULL;
- obj_private->so_info = NULL;
- so->objfile->obj_private = (PTR) obj_private;
- }
-
- obj_private = (obj_private_data_t *) so->objfile->obj_private;
- obj_private->so_info = so;
-
- if (!bfd_check_format (so->abfd, bfd_object))
- {
- error ("\"%s\": not in executable format: %s.",
- name, bfd_errmsg (bfd_get_error ()));
- }
-}
-
-
-static void
-som_solib_load_symbols (so, name, from_tty, text_addr, target)
- struct so_list * so;
- char * name;
- int from_tty;
- CORE_ADDR text_addr;
- struct target_ops * target;
-{
- struct section_table * p;
- int status;
- char buf[4];
- CORE_ADDR presumed_data_start;
-
-#ifdef SOLIB_DEBUG
- printf( "--Adding symbols for shared library \"%s\"\n", name );
-#endif
-
- som_solib_add_solib_objfile (so, name, from_tty, text_addr);
-
- /* Now we need to build a section table for this library since
- we might be debugging a core file from a dynamically linked
- executable in which the libraries were not privately mapped. */
- if (build_section_table (so->abfd,
- &so->sections,
- &so->sections_end))
- {
- error ("Unable to build section table for shared library\n.");
- return;
- }
-
- /* Relocate all the sections based on where they got loaded. */
- for (p = so->sections; p < so->sections_end; p++)
- {
- if (p->the_bfd_section->flags & SEC_CODE)
- {
- p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT);
- p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT);
- }
- else if (p->the_bfd_section->flags & SEC_DATA)
- {
- p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA);
- p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA);
- }
- }
-
- /* Now see if we need to map in the text and data for this shared
- library (for example debugging a core file which does not use
- private shared libraries.).
-
- Carefully peek at the first text address in the library. If the
- read succeeds, then the libraries were privately mapped and were
- included in the core dump file.
-
- If the peek failed, then the libraries were not privately mapped
- and are not in the core file, we'll have to read them in ourselves. */
- status = target_read_memory (text_addr, buf, 4);
- if (status != 0)
- {
- int old, new;
- int update_coreops;
- int update_execops;
-
- /* We must update the to_sections field in the core_ops structure
- here, otherwise we dereference a potential dangling pointer
- for each call to target_read/write_memory within this routine. */
- update_coreops = core_ops.to_sections == target->to_sections;
-
- /* Ditto exec_ops (this was a bug).
- */
- update_execops = exec_ops.to_sections == target->to_sections;
-
- new = so->sections_end - so->sections;
- /* Add sections from the shared library to the core target. */
- if (target->to_sections)
- {
- old = target->to_sections_end - target->to_sections;
- target->to_sections = (struct section_table *)
- xrealloc ((char *)target->to_sections,
- ((sizeof (struct section_table)) * (old + new)));
- }
- else
- {
- old = 0;
- target->to_sections = (struct section_table *)
- xmalloc ((sizeof (struct section_table)) * new);
- }
- target->to_sections_end = (target->to_sections + old + new);
-
- /* Update the to_sections field in the core_ops structure
- if needed, ditto exec_ops. */
- if (update_coreops)
- {
- core_ops.to_sections = target->to_sections;
- core_ops.to_sections_end = target->to_sections_end;
- }
-
- if (update_execops)
- {
- exec_ops.to_sections = target->to_sections;
- exec_ops.to_sections_end = target->to_sections_end;
- }
-
- /* Copy over the old data before it gets clobbered. */
- memcpy ((char *)(target->to_sections + old),
- so->sections,
- ((sizeof (struct section_table)) * new));
- }
-}
-
-
-/* Add symbols from shared libraries into the symtab list, unless the
- size threshold (specified by auto_solib_add, in megabytes) would
- be exceeded. */
-
-void
-som_solib_add (arg_string, from_tty, target)
- char *arg_string;
- int from_tty;
- struct target_ops *target;
-{
- struct minimal_symbol *msymbol;
- struct so_list *so_list_tail;
- CORE_ADDR addr;
- asection *shlib_info;
- int status;
- unsigned int dld_flags;
- char buf[4], *re_err;
- int threshold_warning_given = 0;
-
- /* First validate our arguments. */
- if ((re_err = re_comp (arg_string ? arg_string : ".")) != NULL)
- {
- error ("Invalid regexp: %s", re_err);
- }
-
- /* If we're debugging a core file, or have attached to a running
- process, then som_solib_create_inferior_hook will not have been
- called.
-
- We need to first determine if we're dealing with a dynamically
- linked executable. If not, then return without an error or warning.
-
- We also need to examine __dld_flags to determine if the shared library
- list is valid and to determine if the libraries have been privately
- mapped. */
- if (symfile_objfile == NULL)
- return;
-
- /* First see if the objfile was dynamically linked. */
- shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$");
- if (!shlib_info)
- return;
-
- /* It's got a $SHLIB_INFO$ section, make sure it's not empty. */
- if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0)
- return;
-
- msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
- if (msymbol == NULL)
- {
- error ("Unable to find __dld_flags symbol in object file.\n");
- return;
- }
-
- addr = SYMBOL_VALUE_ADDRESS (msymbol);
- /* Read the current contents. */
- status = target_read_memory (addr, buf, 4);
- if (status != 0)
- {
- error ("Unable to read __dld_flags\n");
- return;
- }
- dld_flags = extract_unsigned_integer (buf, 4);
-
- /* __dld_list may not be valid. If not, then we punt, warning the user if
- we were called as a result of the add-symfile command.
- */
- if ((dld_flags & DLD_FLAGS_LISTVALID) == 0)
- {
- if (from_tty)
- error ("__dld_list is not valid according to __dld_flags.\n");
- return;
- }
-
- /* If the libraries were not mapped private, warn the user. */
- if ((dld_flags & DLD_FLAGS_MAPPRIVATE) == 0)
- warning ("The shared libraries were not privately mapped; setting a\nbreakpoint in a shared library will not work until you rerun the program.\n");
-
- msymbol = lookup_minimal_symbol ("__dld_list", NULL, NULL);
- if (!msymbol)
- {
- /* Older crt0.o files (hpux8) don't have __dld_list as a symbol,
- but the data is still available if you know where to look. */
- msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
- if (!msymbol)
- {
- error ("Unable to find dynamic library list.\n");
- return;
- }
- addr = SYMBOL_VALUE_ADDRESS (msymbol) - 8;
- }
- else
- addr = SYMBOL_VALUE_ADDRESS (msymbol);
-
- status = target_read_memory (addr, buf, 4);
- if (status != 0)
- {
- error ("Unable to find dynamic library list.\n");
- return;
- }
-
- addr = extract_unsigned_integer (buf, 4);
-
- /* If addr is zero, then we're using an old dynamic loader which
- doesn't maintain __dld_list. We'll have to use a completely
- different approach to get shared library information. */
- if (addr == 0)
- goto old_dld;
-
- /* Using the information in __dld_list is the preferred method
- to get at shared library information. It doesn't depend on
- any functions in /opt/langtools/lib/end.o and has a chance of working
- with hpux10 when it is released. */
- status = target_read_memory (addr, buf, 4);
- if (status != 0)
- {
- error ("Unable to find dynamic library list.\n");
- return;
- }
-
- /* addr now holds the address of the first entry in the dynamic
- library list. */
- addr = extract_unsigned_integer (buf, 4);
-
- /* Now that we have a pointer to the dynamic library list, walk
- through it and add the symbols for each library. */
-
- so_list_tail = so_list_head;
- /* Find the end of the list of shared objects. */
- while (so_list_tail && so_list_tail->next)
- so_list_tail = so_list_tail->next;
-
-#ifdef SOLIB_DEBUG
- printf( "--About to read shared library list data\n" );
-#endif
-
- /* "addr" will always point to the base of the
- * current data entry describing the current
- * shared library.
- */
- while (1)
- {
- CORE_ADDR name_addr, text_addr;
- unsigned int name_len;
- char *name;
- struct so_list *new_so;
- struct so_list *so_list = so_list_head;
- struct stat statbuf;
- LONGEST st_size;
- int is_main_program;
-
- if (addr == 0)
- break;
-
- /* Get a pointer to the name of this library. */
- status = target_read_memory (addr, buf, 4);
- if (status != 0)
- goto err;
-
- name_addr = extract_unsigned_integer (buf, 4);
- name_len = 0;
- while (1)
- {
- target_read_memory (name_addr + name_len, buf, 1);
- if (status != 0)
- goto err;
-
- name_len++;
- if (*buf == '\0')
- break;
- }
- name = alloca (name_len);
- status = target_read_memory (name_addr, name, name_len);
- if (status != 0)
- goto err;
-
- /* See if we've already loaded something with this name. */
- while (so_list)
- {
- if (!strcmp (so_list->som_solib.name, name))
- break;
- so_list = so_list->next;
- }
-
- /* See if the file exists. If not, give a warning, but don't
- die. */
- status = stat (name, &statbuf);
- if (status == -1)
- {
- warning ("Can't find file %s referenced in dld_list.", name);
-
- status = target_read_memory (addr + 36, buf, 4);
- if (status != 0)
- goto err;
-
- addr = (CORE_ADDR) extract_unsigned_integer (buf, 4);
- continue;
- }
-
- /* If we've already loaded this one or it's the main program, skip it. */
- is_main_program = (strcmp (name, symfile_objfile->name) == 0);
- if (so_list || is_main_program)
- {
- /* This is the "next" pointer in the strcuture.
- */
- status = target_read_memory (addr + 36, buf, 4);
- if (status != 0)
- goto err;
-
- addr = (CORE_ADDR) extract_unsigned_integer (buf, 4);
-
- /* Record the main program's symbol table size. */
- if (is_main_program && !so_list)
- {
- st_size = som_solib_sizeof_symbol_table (name);
- som_solib_total_st_size += st_size;
- }
-
- /* Was this a shlib that we noted but didn't load the symbols for?
- If so, were we invoked this time from the command-line, via
- a 'sharedlibrary' or 'add-symbol-file' command? If yes to
- both, we'd better load the symbols this time.
- */
- if (from_tty && so_list && !is_main_program && (so_list->objfile == NULL))
- som_solib_load_symbols (so_list,
- name,
- from_tty,
- so_list->som_solib.text_addr,
- target);
-
- continue;
- }
-
- name = obsavestring (name, name_len - 1,
- &symfile_objfile->symbol_obstack);
-
- status = target_read_memory (addr + 8, buf, 4);
- if (status != 0)
- goto err;
-
- text_addr = extract_unsigned_integer (buf, 4);
-
- new_so = (struct so_list *) xmalloc (sizeof (struct so_list));
- memset ((char *)new_so, 0, sizeof (struct so_list));
- if (so_list_head == NULL)
- {
- so_list_head = new_so;
- so_list_tail = new_so;
- }
- else
- {
- so_list_tail->next = new_so;
- so_list_tail = new_so;
- }
-
- /* Fill in all the entries in GDB's shared library list.
- */
-
- new_so->solib_addr = addr;
- new_so->som_solib.name = name;
- status = target_read_memory (addr + 4, buf, 4);
- if (status != 0)
- goto err;
-
- new_so->som_solib.struct_version = extract_unsigned_integer (buf + 3, 1);
- new_so->som_solib.bind_mode = extract_unsigned_integer (buf + 2, 1);
- /* Following is "high water mark", highest version number
- * seen, rather than plain version number.
- */
- new_so->som_solib.library_version = extract_unsigned_integer (buf, 2);
- new_so->som_solib.text_addr = text_addr;
-
- /* Q: What about longword at "addr + 8"?
- * A: It's read above, out of order, into "text_addr".
- */
-
- status = target_read_memory (addr + 12, buf, 4);
- if (status != 0)
- goto err;
-
- new_so->som_solib.text_link_addr = extract_unsigned_integer (buf, 4);
-
- status = target_read_memory (addr + 16, buf, 4);
- if (status != 0)
- goto err;
-
- new_so->som_solib.text_end = extract_unsigned_integer (buf, 4);
-
- status = target_read_memory (addr + 20, buf, 4);
- if (status != 0)
- goto err;
-
- new_so->som_solib.data_start = extract_unsigned_integer (buf, 4);
-
- status = target_read_memory (addr + 24, buf, 4);
- if (status != 0)
- goto err;
-
- new_so->som_solib.bss_start = extract_unsigned_integer (buf, 4);
-
- status = target_read_memory (addr + 28, buf, 4);
- if (status != 0)
- goto err;
-
- new_so->som_solib.data_end = extract_unsigned_integer (buf, 4);
-
- status = target_read_memory (addr + 32, buf, 4);
- if (status != 0)
- goto err;
-
- new_so->som_solib.got_value = extract_unsigned_integer (buf, 4);
-
- status = target_read_memory (addr + 36, buf, 4);
- if (status != 0)
- goto err;
-
- new_so->som_solib.next = (void *)extract_unsigned_integer (buf, 4);
-
- /* Note that we don't re-set "addr" to the next pointer
- * until after we've read the trailing data.
- */
-
- status = target_read_memory (addr + 40, buf, 4);
- new_so->som_solib.tsd_start_addr = extract_unsigned_integer (buf, 4);
- if (status != 0)
- goto err;
-
- /* Now indirect via that value!
- */
- status = target_read_memory (new_so->som_solib.tsd_start_addr, buf, 4);
- new_so->som_solib.tsd_start_addr = extract_unsigned_integer (buf, 4);
- if (status != 0)
- goto err;
-#ifdef SOLIB_DEBUG
- printf( "\n+ library \"%s\" is described at 0x%x\n", name, addr );
- printf( " 'version' is %d\n", new_so->som_solib.struct_version );
- printf( " 'bind_mode' is %d\n", new_so->som_solib.bind_mode );
- printf( " 'library_version' is %d\n", new_so->som_solib.library_version );
- printf( " 'text_addr' is 0x%x\n", new_so->som_solib.text_addr );
- printf( " 'text_link_addr' is 0x%x\n", new_so->som_solib.text_link_addr );
- printf( " 'text_end' is 0x%x\n", new_so->som_solib.text_end );
- printf( " 'data_start' is 0x%x\n", new_so->som_solib.data_start );
- printf( " 'bss_start' is 0x%x\n", new_so->som_solib.bss_start );
- printf( " 'data_end' is 0x%x\n", new_so->som_solib.data_end );
- printf( " 'got_value' is %x\n", new_so->som_solib.got_value );
- printf( " 'next' is 0x%x\n", new_so->som_solib.next );
- printf( " 'tsd_start_addr' is 0x%x\n", new_so->som_solib.tsd_start_addr );
-#endif
-
- /* Go on to the next shared library descriptor.
- */
- addr = (CORE_ADDR)new_so->som_solib.next;
-
-
-
- /* At this point, we have essentially hooked the shlib into the
- "info share" command. However, we haven't yet loaded its
- symbol table. We must now decide whether we ought to, i.e.,
- whether doing so would exceed the symbol table size threshold.
-
- If the threshold has just now been exceeded, then we'll issue
- a warning message (which explains how to load symbols manually,
- if the user so desires).
-
- If the threshold has just now or previously been exceeded,
- we'll just add the shlib to the list of object files, but won't
- actually load its symbols. (This is more useful than it might
- sound, for it allows us to e.g., still load and use the shlibs'
- unwind information for stack tracebacks.)
- */
-
- /* Note that we DON'T want to preclude the user from using the
- add-symbol-file command! Thus, we only worry about the threshold
- when we're invoked for other reasons.
- */
- st_size = som_solib_sizeof_symbol_table (name);
- som_solib_st_size_threshold_exceeded =
- !from_tty &&
- ((st_size + som_solib_total_st_size) > (auto_solib_add * (LONGEST)1000000));
-
- if (som_solib_st_size_threshold_exceeded)
- {
- if (! threshold_warning_given)
- warning ("Symbols for some libraries have not been loaded, because\ndoing so would exceed the size threshold specified by auto-solib-add.\nTo manually load symbols, use the 'sharedlibrary' command.\nTo raise the threshold, set auto-solib-add to a larger value and rerun\nthe program.\n");
- threshold_warning_given = 1;
-
- /* We'll still make note of this shlib, even if we don't
- read its symbols. This allows us to use its unwind
- information well enough to know how to e.g., correctly
- do a traceback from a PC within the shlib, even if we
- can't symbolize those PCs...
- */
- som_solib_add_solib_objfile (new_so, name, from_tty, text_addr);
- continue;
- }
-
- som_solib_total_st_size += st_size;
-
- /* This fills in new_so->objfile, among others. */
- som_solib_load_symbols (new_so, name, from_tty, text_addr, target);
- }
-
-#ifdef SOLIB_DEBUG
- printf( "--Done reading shared library data\n" );
-#endif
-
- /* Getting new symbols may change our opinion about what is
- frameless. */
- reinit_frame_cache ();
- return;
-
-old_dld:
- error ("Debugging dynamic executables loaded via the hpux8 dld.sl is not supported.\n");
- return;
-
-err:
- error ("Error while reading dynamic library list.\n");
- return;
-}
-
-
-/* This hook gets called just before the first instruction in the
- inferior process is executed.
-
- This is our opportunity to set magic flags in the inferior so
- that GDB can be notified when a shared library is mapped in and
- to tell the dynamic linker that a private copy of the library is
- needed (so GDB can set breakpoints in the library).
-
- __dld_flags is the location of the magic flags; as of this implementation
- there are 3 flags of interest:
-
- bit 0 when set indicates that private copies of the libraries are needed
- bit 1 when set indicates that the callback hook routine is valid
- bit 2 when set indicates that the dynamic linker should maintain the
- __dld_list structure when loading/unloading libraries.
-
- Note that shared libraries are not mapped in at this time, so we have
- run the inferior until the libraries are mapped in. Typically this
- means running until the "_start" is called. */
-
-void
-som_solib_create_inferior_hook()
-{
- struct minimal_symbol *msymbol;
- unsigned int dld_flags, status, have_endo;
- asection *shlib_info;
- char buf[4];
- struct objfile *objfile;
- CORE_ADDR anaddr;
-
- /* First, remove all the solib event breakpoints. Their addresses
- may have changed since the last time we ran the program. */
- remove_solib_event_breakpoints ();
-
- if (symfile_objfile == NULL)
- return;
-
- /* First see if the objfile was dynamically linked. */
- shlib_info = bfd_get_section_by_name (symfile_objfile->obfd, "$SHLIB_INFO$");
- if (!shlib_info)
- return;
-
- /* It's got a $SHLIB_INFO$ section, make sure it's not empty. */
- if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0)
- return;
-
- have_endo = 0;
- /* Slam the pid of the process into __d_pid; failing is only a warning! */
- msymbol = lookup_minimal_symbol ("__d_pid", NULL, symfile_objfile);
- if (msymbol == NULL)
- {
- warning ("Unable to find __d_pid symbol in object file.");
- warning ("Suggest linking with /opt/langtools/lib/end.o.");
- warning ("GDB will be unable to track shl_load/shl_unload calls");
- goto keep_going;
- }
-
- anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
- store_unsigned_integer (buf, 4, inferior_pid);
- status = target_write_memory (anaddr, buf, 4);
- if (status != 0)
- {
- warning ("Unable to write __d_pid");
- warning ("Suggest linking with /opt/langtools/lib/end.o.");
- warning ("GDB will be unable to track shl_load/shl_unload calls");
- goto keep_going;
- }
-
- /* Get the value of _DLD_HOOK (an export stub) and put it in __dld_hook;
- This will force the dynamic linker to call __d_trap when significant
- events occur.
-
- Note that the above is the pre-HP-UX 9.0 behaviour. At 9.0 and above,
- the dld provides an export stub named "__d_trap" as well as the
- function named "__d_trap" itself, but doesn't provide "_DLD_HOOK".
- We'll look first for the old flavor and then the new.
- */
- msymbol = lookup_minimal_symbol ("_DLD_HOOK", NULL, symfile_objfile);
- if (msymbol == NULL)
- msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile);
- if (msymbol == NULL)
- {
- warning ("Unable to find _DLD_HOOK symbol in object file.");
- warning ("Suggest linking with /opt/langtools/lib/end.o.");
- warning ("GDB will be unable to track shl_load/shl_unload calls");
- goto keep_going;
- }
- anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
- dld_cache.hook.address = anaddr;
-
- /* Grrr, this might not be an export symbol! We have to find the
- export stub. */
- ALL_OBJFILES (objfile)
- {
- struct unwind_table_entry *u;
- struct minimal_symbol *msymbol2;
-
- /* What a crock. */
- msymbol2 = lookup_minimal_symbol_solib_trampoline (SYMBOL_NAME (msymbol),
- NULL, objfile);
- /* Found a symbol with the right name. */
- if (msymbol2)
- {
- struct unwind_table_entry *u;
- /* It must be a shared library trampoline. */
- if (SYMBOL_TYPE (msymbol2) != mst_solib_trampoline)
- continue;
-
- /* It must also be an export stub. */
- u = find_unwind_entry (SYMBOL_VALUE (msymbol2));
- if (!u || u->stub_unwind.stub_type != EXPORT)
- continue;
-
- /* OK. Looks like the correct import stub. */
- anaddr = SYMBOL_VALUE (msymbol2);
- dld_cache.hook_stub.address = anaddr;
- }
- }
- store_unsigned_integer (buf, 4, anaddr);
-
- msymbol = lookup_minimal_symbol ("__dld_hook", NULL, symfile_objfile);
- if (msymbol == NULL)
- {
- warning ("Unable to find __dld_hook symbol in object file.");
- warning ("Suggest linking with /opt/langtools/lib/end.o.");
- warning ("GDB will be unable to track shl_load/shl_unload calls");
- goto keep_going;
- }
- anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
- status = target_write_memory (anaddr, buf, 4);
-
- /* Now set a shlib_event breakpoint at __d_trap so we can track
- significant shared library events. */
- msymbol = lookup_minimal_symbol ("__d_trap", NULL, symfile_objfile);
- if (msymbol == NULL)
- {
- warning ("Unable to find __dld_d_trap symbol in object file.");
- warning ("Suggest linking with /opt/langtools/lib/end.o.");
- warning ("GDB will be unable to track shl_load/shl_unload calls");
- goto keep_going;
- }
- create_solib_event_breakpoint (SYMBOL_VALUE_ADDRESS (msymbol));
-
- /* We have all the support usually found in end.o, so we can track
- shl_load and shl_unload calls. */
- have_endo = 1;
-
-keep_going:
-
- /* Get the address of __dld_flags, if no such symbol exists, then we can
- not debug the shared code. */
- msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
- if (msymbol == NULL)
- {
- error ("Unable to find __dld_flags symbol in object file.\n");
- }
-
- anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
-
- /* Read the current contents. */
- status = target_read_memory (anaddr, buf, 4);
- if (status != 0)
- {
- error ("Unable to read __dld_flags\n");
- }
- dld_flags = extract_unsigned_integer (buf, 4);
-
- /* Turn on the flags we care about. */
- dld_flags |= DLD_FLAGS_MAPPRIVATE;
- if (have_endo)
- dld_flags |= DLD_FLAGS_HOOKVALID;
- store_unsigned_integer (buf, 4, dld_flags);
- status = target_write_memory (anaddr, buf, 4);
- if (status != 0)
- {
- error ("Unable to write __dld_flags\n");
- }
-
- /* Now find the address of _start and set a breakpoint there.
- We still need this code for two reasons:
-
- * Not all sites have /opt/langtools/lib/end.o, so it's not always
- possible to track the dynamic linker's events.
-
- * At this time no events are triggered for shared libraries
- loaded at startup time (what a crock). */
-
- msymbol = lookup_minimal_symbol ("_start", NULL, symfile_objfile);
- if (msymbol == NULL)
- {
- error ("Unable to find _start symbol in object file.\n");
- }
-
- anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
-
- /* Make the breakpoint at "_start" a shared library event breakpoint. */
- create_solib_event_breakpoint (anaddr);
-
- /* Wipe out all knowledge of old shared libraries since their
- mapping can change from one exec to another! */
- while (so_list_head)
- {
- struct so_list *temp;
-
- temp = so_list_head;
- free (so_list_head);
- so_list_head = temp->next;
- }
- clear_symtab_users ();
-}
-
-
-static void
-reset_inferior_pid (saved_inferior_pid)
- int saved_inferior_pid;
-{
- inferior_pid = saved_inferior_pid;
-}
-
-
-/* This operation removes the "hook" between GDB and the dynamic linker,
- which causes the dld to notify GDB of shared library events.
-
- After this operation completes, the dld will no longer notify GDB of
- shared library events. To resume notifications, GDB must call
- som_solib_create_inferior_hook.
-
- This operation does not remove any knowledge of shared libraries which
- GDB may already have been notified of.
- */
-void
-som_solib_remove_inferior_hook (pid)
- int pid;
-{
- CORE_ADDR addr;
- struct minimal_symbol * msymbol;
- int status;
- char dld_flags_buffer [TARGET_INT_BIT/TARGET_CHAR_BIT];
- unsigned int dld_flags_value;
- int saved_inferior_pid = inferior_pid;
- struct cleanup * old_cleanups = make_cleanup (reset_inferior_pid, saved_inferior_pid);
-
- /* Ensure that we're really operating on the specified process. */
- inferior_pid = pid;
-
- /* We won't bother to remove the solib breakpoints from this process.
-
- In fact, on PA64 the breakpoint is hard-coded into the dld callback,
- and thus we're not supposed to remove it.
-
- Rather, we'll merely clear the dld_flags bit that enables callbacks.
- */
- msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
-
- addr = SYMBOL_VALUE_ADDRESS (msymbol);
- status = target_read_memory (addr, dld_flags_buffer, TARGET_INT_BIT/TARGET_CHAR_BIT);
-
- dld_flags_value = extract_unsigned_integer (dld_flags_buffer,
- sizeof (dld_flags_value));
-
- dld_flags_value &= ~DLD_FLAGS_HOOKVALID;
- store_unsigned_integer (dld_flags_buffer,
- sizeof (dld_flags_value),
- dld_flags_value);
- status = target_write_memory (addr, dld_flags_buffer, TARGET_INT_BIT/TARGET_CHAR_BIT);
-
- do_cleanups (old_cleanups);
-}
-
-
-/* This function creates a breakpoint on the dynamic linker hook, which
- is called when e.g., a shl_load or shl_unload call is made. This
- breakpoint will only trigger when a shl_load call is made.
-
- If filename is NULL, then loads of any dll will be caught. Else,
- only loads of the file whose pathname is the string contained by
- filename will be caught.
-
- Undefined behaviour is guaranteed if this function is called before
- som_solib_create_inferior_hook.
- */
-void
-som_solib_create_catch_load_hook (pid, tempflag, filename, cond_string)
- int pid;
- int tempflag;
- char * filename;
- char * cond_string;
-{
- create_solib_load_event_breakpoint ("__d_trap", tempflag, filename, cond_string);
-}
-
-/* This function creates a breakpoint on the dynamic linker hook, which
- is called when e.g., a shl_load or shl_unload call is made. This
- breakpoint will only trigger when a shl_unload call is made.
-
- If filename is NULL, then unloads of any dll will be caught. Else,
- only unloads of the file whose pathname is the string contained by
- filename will be caught.
-
- Undefined behaviour is guaranteed if this function is called before
- som_solib_create_inferior_hook.
- */
-void
-som_solib_create_catch_unload_hook (pid, tempflag, filename, cond_string)
- int pid;
- int tempflag;
- char * filename;
- char * cond_string;
-{
- create_solib_unload_event_breakpoint ("__d_trap", tempflag, filename, cond_string);
-}
-
-int
-som_solib_have_load_event (pid)
- int pid;
-{
- CORE_ADDR event_kind;
-
- event_kind = read_register (ARG0_REGNUM);
- return (event_kind == SHL_LOAD);
-}
-
-int
-som_solib_have_unload_event (pid)
- int pid;
-{
- CORE_ADDR event_kind;
-
- event_kind = read_register (ARG0_REGNUM);
- return (event_kind == SHL_UNLOAD);
-}
-
-static char *
-som_solib_library_pathname (pid)
- int pid;
-{
- CORE_ADDR dll_handle_address;
- CORE_ADDR dll_pathname_address;
- struct som_solib_mapped_entry dll_descriptor;
- char * p;
- static char dll_pathname [1024];
-
- /* Read the descriptor of this newly-loaded library. */
- dll_handle_address = read_register (ARG1_REGNUM);
- read_memory (dll_handle_address, (char *) &dll_descriptor, sizeof (dll_descriptor));
-
- /* We can find a pointer to the dll's pathname within the descriptor. */
- dll_pathname_address = (CORE_ADDR) dll_descriptor.name;
-
- /* Read the pathname, one byte at a time. */
- p = dll_pathname;
- for (;;)
- {
- char b;
- read_memory (dll_pathname_address++, (char *) &b, 1);
- *p++ = b;
- if (b == '\0')
- break;
- }
-
- return dll_pathname;
-}
-
-char *
-som_solib_loaded_library_pathname (pid)
- int pid;
-{
- if (! som_solib_have_load_event (pid))
- error ("Must have a load event to use this query");
-
- return som_solib_library_pathname (pid);
-}
-
-char *
-som_solib_unloaded_library_pathname (pid)
- int pid;
-{
- if (! som_solib_have_unload_event (pid))
- error ("Must have an unload event to use this query");
-
- return som_solib_library_pathname (pid);
-}
-
-static void
-som_solib_desire_dynamic_linker_symbols ()
-{
- struct objfile *objfile;
- struct unwind_table_entry *u;
- struct minimal_symbol * dld_msymbol;
-
- /* Do we already know the value of these symbols? If so, then
- we've no work to do.
-
- (If you add clauses to this test, be sure to likewise update the
- test within the loop.)
- */
- if (dld_cache.is_valid)
- return;
-
- ALL_OBJFILES (objfile)
- {
- dld_msymbol = lookup_minimal_symbol ("shl_load", NULL, objfile);
- if (dld_msymbol != NULL)
- {
- dld_cache.load.address = SYMBOL_VALUE (dld_msymbol);
- dld_cache.load.unwind = find_unwind_entry (dld_cache.load.address);
- }
-
- dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_load",
- NULL,
- objfile);
- if (dld_msymbol != NULL)
- {
- if (SYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
- {
- u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol));
- if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
- {
- dld_cache.load_stub.address = SYMBOL_VALUE (dld_msymbol);
- dld_cache.load_stub.unwind = u;
- }
- }
- }
-
- dld_msymbol = lookup_minimal_symbol ("shl_unload", NULL, objfile);
- if (dld_msymbol != NULL)
- {
- dld_cache.unload.address = SYMBOL_VALUE (dld_msymbol);
- dld_cache.unload.unwind = find_unwind_entry (dld_cache.unload.address);
-
- /* ??rehrauer: I'm not sure exactly what this is, but it appears
- that on some HPUX 10.x versions, there's two unwind regions to
- cover the body of "shl_unload", the second being 4 bytes past
- the end of the first. This is a large hack to handle that
- case, but since I don't seem to have any legitimate way to
- look for this thing via the symbol table...
- */
- if (dld_cache.unload.unwind != NULL)
- {
- u = find_unwind_entry (dld_cache.unload.unwind->region_end + 4);
- if (u != NULL)
- {
- dld_cache.unload2.address = u->region_start;
- dld_cache.unload2.unwind = u;
- }
- }
- }
-
- dld_msymbol = lookup_minimal_symbol_solib_trampoline ("shl_unload",
- NULL,
- objfile);
- if (dld_msymbol != NULL)
- {
- if (SYMBOL_TYPE (dld_msymbol) == mst_solib_trampoline)
- {
- u = find_unwind_entry (SYMBOL_VALUE (dld_msymbol));
- if ((u != NULL) && (u->stub_unwind.stub_type == EXPORT))
- {
- dld_cache.unload_stub.address = SYMBOL_VALUE (dld_msymbol);
- dld_cache.unload_stub.unwind = u;
- }
- }
- }
-
- /* Did we find everything we were looking for? If so, stop. */
- if ((dld_cache.load.address != NULL) && (dld_cache.load_stub.address != NULL)
- && (dld_cache.unload.address != NULL) && (dld_cache.unload_stub.address != NULL))
- {
- dld_cache.is_valid = 1;
- break;
- }
- }
-
- dld_cache.hook.unwind = find_unwind_entry (dld_cache.hook.address);
- dld_cache.hook_stub.unwind = find_unwind_entry (dld_cache.hook_stub.address);
-
- /* We're prepared not to find some of these symbols, which is why
- this function is a "desire" operation, and not a "require".
- */
-}
-
-int
-som_solib_in_dynamic_linker (pid, pc)
- int pid;
- CORE_ADDR pc;
-{
- struct unwind_table_entry * u_pc;
-
- /* Are we in the dld itself?
-
- ??rehrauer: Large hack -- We'll assume that any address in a
- shared text region is the dld's text. This would obviously
- fall down if the user attached to a process, whose shlibs
- weren't mapped to a (writeable) private region. However, in
- that case the debugger probably isn't able to set the fundamental
- breakpoint in the dld callback anyways, so this hack should be
- safe.
- */
- if ((pc & (CORE_ADDR) 0xc0000000) == (CORE_ADDR) 0xc0000000)
- return 1;
-
- /* Cache the address of some symbols that are part of the dynamic
- linker, if not already known.
- */
- som_solib_desire_dynamic_linker_symbols ();
-
- /* Are we in the dld callback? Or its export stub? */
- u_pc = find_unwind_entry (pc);
- if (u_pc == NULL)
- return 0;
-
- if ((u_pc == dld_cache.hook.unwind) || (u_pc == dld_cache.hook_stub.unwind))
- return 1;
-
- /* Or the interface of the dld (i.e., "shl_load" or friends)? */
- if ((u_pc == dld_cache.load.unwind)
- || (u_pc == dld_cache.unload.unwind)
- || (u_pc == dld_cache.unload2.unwind)
- || (u_pc == dld_cache.load_stub.unwind)
- || (u_pc == dld_cache.unload_stub.unwind))
- return 1;
-
- /* Apparently this address isn't part of the dld's text. */
- return 0;
-}
-
-
-/* Return the GOT value for the shared library in which ADDR belongs. If
- ADDR isn't in any known shared library, return zero. */
-
-CORE_ADDR
-som_solib_get_got_by_pc (addr)
- CORE_ADDR addr;
-{
- struct so_list *so_list = so_list_head;
- CORE_ADDR got_value = 0;
-
- while (so_list)
- {
- if (so_list->som_solib.text_addr <= addr
- && so_list->som_solib.text_end > addr)
- {
- got_value = so_list->som_solib.got_value;
- break;
- }
- so_list = so_list->next;
- }
- return got_value;
-}
-
-/* elz:
- Return the address of the handle of the shared library
- in which ADDR belongs. If
- ADDR isn't in any known shared library, return zero. */
-/* this function is used in hppa_fix_call_dummy in hppa-tdep.c*/
-
-CORE_ADDR
-som_solib_get_solib_by_pc (addr)
- CORE_ADDR addr;
-{
- struct so_list *so_list = so_list_head;
-
- while (so_list)
- {
- if (so_list->som_solib.text_addr <= addr
- && so_list->som_solib.text_end > addr)
- {
- break;
- }
- so_list = so_list->next;
- }
- if (so_list)
- return so_list->solib_addr;
- else
- return 0;
-}
-
-
-int
-som_solib_section_offsets (objfile, offsets)
- struct objfile *objfile;
- struct section_offsets *offsets;
-{
- struct so_list *so_list = so_list_head;
-
- while (so_list)
- {
- /* Oh what a pain! We need the offsets before so_list->objfile
- is valid. The BFDs will never match. Make a best guess. */
- if (strstr (objfile->name, so_list->som_solib.name))
- {
- asection *private_section;
-
- /* The text offset is easy. */
- ANOFFSET (offsets, SECT_OFF_TEXT)
- = (so_list->som_solib.text_addr
- - so_list->som_solib.text_link_addr);
- ANOFFSET (offsets, SECT_OFF_RODATA)
- = ANOFFSET (offsets, SECT_OFF_TEXT);
-
- /* We should look at presumed_dp in the SOM header, but
- that's not easily available. This should be OK though. */
- private_section = bfd_get_section_by_name (objfile->obfd,
- "$PRIVATE$");
- if (!private_section)
- {
- warning ("Unable to find $PRIVATE$ in shared library!");
- ANOFFSET (offsets, SECT_OFF_DATA) = 0;
- ANOFFSET (offsets, SECT_OFF_BSS) = 0;
- return 1;
- }
- ANOFFSET (offsets, SECT_OFF_DATA)
- = (so_list->som_solib.data_start - private_section->vma);
- ANOFFSET (offsets, SECT_OFF_BSS)
- = ANOFFSET (offsets, SECT_OFF_DATA);
- return 1;
- }
- so_list = so_list->next;
- }
- return 0;
-}
-
-/* Dump information about all the currently loaded shared libraries. */
-
-static void
-som_sharedlibrary_info_command (ignore, from_tty)
- char *ignore;
- int from_tty;
-{
- struct so_list *so_list = so_list_head;
-
- if (exec_bfd == NULL)
- {
- printf_unfiltered ("no exec file.\n");
- return;
- }
-
- if (so_list == NULL)
- {
- printf_unfiltered ("No shared libraries loaded at this time.\n");
- return;
- }
-
- printf_unfiltered ("Shared Object Libraries\n");
- printf_unfiltered (" %-12s%-12s%-12s%-12s%-12s%-12s\n",
- " flags", " tstart", " tend", " dstart", " dend", " dlt");
- while (so_list)
- {
- unsigned int flags;
-
- flags = so_list->som_solib.struct_version << 24;
- flags |= so_list->som_solib.bind_mode << 16;
- flags |= so_list->som_solib.library_version;
- printf_unfiltered ("%s", so_list->som_solib.name);
- if (so_list->objfile == NULL)
- printf_unfiltered (" (symbols not loaded)");
- printf_unfiltered ("\n");
- printf_unfiltered (" %-12s", local_hex_string_custom (flags, "08l"));
- printf_unfiltered ("%-12s",
- local_hex_string_custom (so_list->som_solib.text_addr, "08l"));
- printf_unfiltered ("%-12s",
- local_hex_string_custom (so_list->som_solib.text_end, "08l"));
- printf_unfiltered ("%-12s",
- local_hex_string_custom (so_list->som_solib.data_start, "08l"));
- printf_unfiltered ("%-12s",
- local_hex_string_custom (so_list->som_solib.data_end, "08l"));
- printf_unfiltered ("%-12s\n",
- local_hex_string_custom (so_list->som_solib.got_value, "08l"));
- so_list = so_list->next;
- }
-}
-
-static void
-som_solib_sharedlibrary_command (args, from_tty)
- char *args;
- int from_tty;
-{
- dont_repeat ();
- som_solib_add (args, from_tty, (struct target_ops *) 0);
-}
-
-
-
-char *
-som_solib_address (addr)
- CORE_ADDR addr;
-{
- struct so_list * so = so_list_head;
-
- while (so)
- {
- /* Is this address within this shlib's text range? If so,
- return the shlib's name.
- */
- if ((addr >= so->som_solib.text_addr) && (addr <= so->som_solib.text_end))
- return so->som_solib.name;
-
- /* Nope, keep looking... */
- so = so->next;
- }
-
- /* No, we couldn't prove that the address is within a shlib. */
- return NULL;
-}
-
-
-void
-som_solib_restart ()
-{
- struct so_list * sl = so_list_head;
-
- /* Before the shlib info vanishes, use it to disable any breakpoints
- that may still be active in those shlibs.
- */
- disable_breakpoints_in_shlibs (0);
-
- /* Discard all the shlib descriptors.
- */
- while (sl)
- {
- struct so_list * next_sl = sl->next;
- free (sl);
- sl = next_sl;
- }
- so_list_head = NULL;
-
- som_solib_total_st_size = (LONGEST) 0;
- som_solib_st_size_threshold_exceeded = 0;
-
- dld_cache.is_valid = 0;
-
- dld_cache.hook.address = 0;
- dld_cache.hook.unwind = NULL;
-
- dld_cache.hook_stub.address = 0;
- dld_cache.hook_stub.unwind = NULL;
-
- dld_cache.load.address = 0;
- dld_cache.load.unwind = NULL;
-
- dld_cache.load_stub.address = 0;
- dld_cache.load_stub.unwind = NULL;
-
- dld_cache.unload.address = 0;
- dld_cache.unload.unwind = NULL;
-
- dld_cache.unload2.address = 0;
- dld_cache.unload2.unwind = NULL;
-
- dld_cache.unload_stub.address = 0;
- dld_cache.unload_stub.unwind = NULL;
-}
-
-
-
-void
-_initialize_som_solib ()
-{
- add_com ("sharedlibrary", class_files, som_solib_sharedlibrary_command,
- "Load shared object library symbols for files matching REGEXP.");
- add_info ("sharedlibrary", som_sharedlibrary_info_command,
- "Status of loaded shared object libraries.");
- add_show_from_set
- (add_set_cmd ("auto-solib-add", class_support, var_zinteger,
- (char *) &auto_solib_add,
- "Set autoloading size threshold (in megabytes) of shared library symbols.\n\
-If nonzero, symbols from all shared object libraries will be loaded\n\
-automatically when the inferior begins execution or when the dynamic linker\n\
-informs gdb that a new library has been loaded, until the symbol table\n\
-of the program and libraries exceeds this threshold.\n\
-Otherwise, symbols must be loaded manually, using `sharedlibrary'.",
- &setlist),
- &showlist);
-
- /* ??rehrauer: On HP-UX, the kernel parameter MAXDSIZ limits how much
- data space a process can use. We ought to be reading MAXDSIZ and
- setting auto_solib_add to some large fraction of that value. If
- not that, we maybe ought to be setting it smaller than the default
- for MAXDSIZ (that being 64Mb, I believe). However, [1] this threshold
- is only crudely approximated rather than actually measured, and [2]
- 50 Mbytes is too small for debugging gdb itself. Thus, the arbitrary
- 100 figure.
- */
- auto_solib_add = 100; /* Megabytes */
-
- som_solib_restart ();
-}
-
-/* Get some HPUX-specific data from a shared lib.
- */
-CORE_ADDR
-so_lib_thread_start_addr( so )
- struct so_list *so;
-{
- return so->som_solib.tsd_start_addr;
-}
diff --git a/contrib/gdb/gdb/somsolib.h b/contrib/gdb/gdb/somsolib.h
deleted file mode 100644
index b969169..0000000
--- a/contrib/gdb/gdb/somsolib.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/* HP SOM Shared library declarations for GDB, the GNU Debugger.
- Copyright (C) 1992 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-Written by the Center for Software Science at the Univerity of Utah
-and by Cygnus Support. */
-
-#ifdef __STDC__ /* Forward decl's for prototypes */
-struct target_ops;
-struct objfile;
-struct section_offsets;
-#endif
-
-/* Called to add symbols from a shared library to gdb's symbol table. */
-
-#define SOLIB_ADD(filename, from_tty, targ) \
- som_solib_add (filename, from_tty, targ)
-
-extern void
-som_solib_add PARAMS ((char *, int, struct target_ops *));
-
-extern CORE_ADDR
-som_solib_get_got_by_pc PARAMS ((CORE_ADDR));
-
-extern int
-som_solib_section_offsets PARAMS ((struct objfile *, struct section_offsets *));
-
-/* Function to be called when the inferior starts up, to discover the names
- of shared libraries that are dynamically linked, the base addresses to
- which they are linked, and sufficient information to read in their symbols
- at a later time. */
-
-#define SOLIB_CREATE_INFERIOR_HOOK(PID) som_solib_create_inferior_hook()
-
-extern void
-som_solib_create_inferior_hook PARAMS((void));
-
-/* Function to be called to remove the connection between debugger and
- dynamic linker that was established by SOLIB_CREATE_INFERIOR_HOOK.
- (This operation does not remove shared library information from
- the debugger, as CLEAR_SOLIB does.)
- */
-#define SOLIB_REMOVE_INFERIOR_HOOK(PID) som_solib_remove_inferior_hook(PID)
-
-extern void
-som_solib_remove_inferior_hook PARAMS((int));
-
-/* This function is called by the "catch load" command. It allows
- the debugger to be notified by the dynamic linker when a specified
- library file (or any library file, if filename is NULL) is loaded.
- */
-#define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag, filename,cond_string) \
- som_solib_create_catch_load_hook (pid, tempflag, filename, cond_string)
-
-extern void
-som_solib_create_catch_load_hook PARAMS((int, int, char *, char *));
-
-/* This function is called by the "catch unload" command. It allows
- the debugger to be notified by the dynamic linker when a specified
- library file (or any library file, if filename is NULL) is unloaded.
- */
-#define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid,tempflag,filename, cond_string) \
- som_solib_create_catch_unload_hook (pid, tempflag, filename, cond_string)
-
-extern void
-som_solib_create_catch_unload_hook PARAMS((int, int, char *, char *));
-
-/* This function returns TRUE if the dynamic linker has just reported
- a load of a library.
-
- This function must be used only when the inferior has stopped in
- the dynamic linker hook, or undefined results are guaranteed.
- */
-#define SOLIB_HAVE_LOAD_EVENT(pid) \
- som_solib_have_load_event (pid)
-
-extern int
-som_solib_have_load_event PARAMS((int));
-
-/* This function returns a pointer to the string representation of the
- pathname of the dynamically-linked library that has just been loaded.
-
- This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
- or undefined results are guaranteed.
-
- This string's contents are only valid immediately after the inferior
- has stopped in the dynamic linker hook, and becomes invalid as soon
- as the inferior is continued. Clients should make a copy of this
- string if they wish to continue the inferior and then access the string.
- */
-#define SOLIB_LOADED_LIBRARY_PATHNAME(pid) \
- som_solib_loaded_library_pathname (pid)
-
-extern char *
-som_solib_loaded_library_pathname PARAMS((int));
-
-/* This function returns TRUE if the dynamic linker has just reported
- an unload of a library.
-
- This function must be used only when the inferior has stopped in
- the dynamic linker hook, or undefined results are guaranteed.
- */
-#define SOLIB_HAVE_UNLOAD_EVENT(pid) \
- som_solib_have_unload_event (pid)
-
-extern int
-som_solib_have_unload_event PARAMS((int));
-
-/* This function returns a pointer to the string representation of the
- pathname of the dynamically-linked library that has just been unloaded.
-
- This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is TRUE,
- or undefined results are guaranteed.
-
- This string's contents are only valid immediately after the inferior
- has stopped in the dynamic linker hook, and becomes invalid as soon
- as the inferior is continued. Clients should make a copy of this
- string if they wish to continue the inferior and then access the string.
- */
-#define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) \
- som_solib_unloaded_library_pathname (pid)
-
-extern char *
-som_solib_unloaded_library_pathname PARAMS((int));
-
-/* This function returns TRUE if pc is the address of an instruction that
- lies within the dynamic linker (such as the event hook, or the dld
- itself).
-
- This function must be used only when a dynamic linker event has been
- caught, and the inferior is being stepped out of the hook, or undefined
- results are guaranteed.
- */
-#define SOLIB_IN_DYNAMIC_LINKER(pid,pc) \
- som_solib_in_dynamic_linker (pid, pc)
-
-extern int
-som_solib_in_dynamic_linker PARAMS((int, CORE_ADDR));
-
-/* This function must be called when the inferior is killed, and the program
- restarted. This is not the same as CLEAR_SOLIB, in that it doesn't discard
- any symbol tables.
-
- Presently, this functionality is not implemented.
- */
-#define SOLIB_RESTART() \
- som_solib_restart ()
-
-extern void
-som_solib_restart PARAMS((void));
-
-/* If we can't set a breakpoint, and it's in a shared library, just
- disable it. */
-
-#define DISABLE_UNSETTABLE_BREAK(addr) (som_solib_address(addr) != NULL)
-
-extern char *
-som_solib_address PARAMS ((CORE_ADDR)); /* somsolib.c */
-
-/* If ADDR lies in a shared library, return its name. */
-
-#define PC_SOLIB(addr) som_solib_address (addr)
diff --git a/contrib/gdb/gdb/srec.h b/contrib/gdb/gdb/srec.h
deleted file mode 100644
index 8253e03..0000000
--- a/contrib/gdb/gdb/srec.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* S-record download support for GDB, the GNU debugger.
- Copyright 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-void load_srec PARAMS ((serial_t desc, const char *file, bfd_vma load_offset,
- int maxrecsize, int flags, int hashmark,
- int (*waitack)(void)));
-
-/* S-record capability flags */
-
-/* Which record types are supported */
-#define SREC_2_BYTE_ADDR 0x00000001
-#define SREC_3_BYTE_ADDR 0x00000002
-#define SREC_4_BYTE_ADDR 0x00000004
-#define SREC_TERM_SHIFT 3
-
-#define SREC_ALL (SREC_2_BYTE_ADDR | SREC_3_BYTE_ADDR | SREC_4_BYTE_ADDR \
- | ((SREC_2_BYTE_ADDR | SREC_3_BYTE_ADDR | SREC_4_BYTE_ADDR) \
- << SREC_TERM_SHIFT))
-
-#define SREC_BINARY 0x00000040 /* Supports binary form of S-records */
diff --git a/contrib/gdb/gdb/standalone.c b/contrib/gdb/gdb/standalone.c
deleted file mode 100644
index 13fc476..0000000
--- a/contrib/gdb/gdb/standalone.c
+++ /dev/null
@@ -1,593 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <sys/types.h>
-#include "gdb_stat.h"
-
-#if defined (SIGTSTP) && defined (SIGIO)
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif /* SIGTSTP and SIGIO defined (must be 4.2) */
-
-#include "defs.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 *
-getcwd (buf, len)
- char *buf;
- unsigned int len;
-{
- 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;
- }
-
- memcpy (destptr, sourceptr, 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;
- }
-
- memcpy (bufp, sourceptr, 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";
-}
-
-/* Nonzero if there is a core file. */
-
-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;
-{
- memcpy (myaddr, memaddr, len);
-}
-
-/* Always return 0 indicating success. */
-
-write_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- memcpy (memaddr, myaddr, 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 ();
-
- memcpy (restore, saved_regs, 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;
-{
- memcpy (saved_regs, &firstreg, 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/contrib/gdb/gdb/stop-gdb.c b/contrib/gdb/gdb/stop-gdb.c
deleted file mode 100644
index 8f22bf9..0000000
--- a/contrib/gdb/gdb/stop-gdb.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* A client to make GDB return to command level in Mach 3.
- Copyright (C) 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Authors: Jukka Virtanen <jtv@hut.fi> and Peter Stout <pds@cs.cmu.edu>.
-
- A simple client to make GDB (versions 4.4 and later) on Mach 3 return
- to the command level when it is waiting for the inferior to stop.
-
- Actions: Lookup the send right to the GDB message port from the
- NetMsgServer.
-
- Send an asynchronous message with msgh_id
- GDB_MESSAGE_ID_STOP to that port.
- */
-
-#include <stdio.h>
-
-#include "defs.h"
-
-#include <mach.h>
-#include <mach/message.h>
-#include <mach_error.h>
-#include <servers/netname.h>
-#include <servers/netname_defs.h>
-
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- kern_return_t kr;
- mach_msg_header_t msg;
- mach_port_t gdb_port;
- char *host;
- char *name;
-
- if (argc == 1)
- argv[argc++] = GDB_DEF_NAME;
-
- if (argc != 2)
- {
- fprintf (stderr, "Usage : %s <GDB name>\n", argv[0]);
- exit (1);
- }
-
- /* Allow the user to specify a remote host. */
- host = strchr (argv[1], '@');
- if (host)
- *(host++) = '\0';
- else
- host = (char *) "";
-
- name = malloc (strlen (argv[1]) + sizeof(GDB_NAME_PREFIX));
- if (name == NULL)
- {
- fprintf (stderr, "Unable to allocate memory for name.");
- exit (1);
- }
-
- strcpy (name, GDB_NAME_PREFIX);
- strcat (name, argv[1]);
-
- /* Look up the GDB service port. For convenience, add the
- GDB_NAME_PREFIX the argument before looking up the name.
- For backwards compatibility, do it without. */
-
- kr = netname_look_up (name_server_port, host, name, &gdb_port);
- if (kr == NETNAME_NOT_CHECKED_IN)
- kr = netname_look_up (name_server_port, host, argv[1], &gdb_port);
- if (kr != KERN_SUCCESS)
- {
- fprintf (stderr, "Unable to lookup the GDB service port: %s.\n",
- mach_error_string(kr));
- exit(1);
- }
-
- /* Code generated by mig stub generator, with minor cleanups :-)
-
- simpleroutine stop_inferior(gdb_port : mach_port_t); */
-
- msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND, 0);
- msg.msgh_remote_port = gdb_port;
- msg.msgh_local_port = MACH_PORT_NULL;
- msg.msgh_size = sizeof(msg);
- msg.msgh_seqno = 0;
- msg.msgh_id = GDB_MESSAGE_ID_STOP;
-
- kr = mach_msg_send (&msg);
- if (kr != KERN_SUCCESS)
- fprintf (stderr, "Message not sent, return code %d : %s\n", kr,
- mach_error_string (kr));
-
- exit (kr != KERN_SUCCESS);
-}
diff --git a/contrib/gdb/gdb/stuff.c b/contrib/gdb/gdb/stuff.c
deleted file mode 100644
index eedbeab..0000000
--- a/contrib/gdb/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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Written 13-Mar-86 by David Bridgham. */
-
-#include <stdio.h>
-#include <a.out.h>
-#include <sys/types.h>
-#include "gdb_stat.h"
-#include <sys/file.h>
-#include <varargs.h>
-
-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 (STREQ (argv[i], "-o"))
- 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, strerror (errno));
- if (lseek (out_fd, offset, 0) < 0)
- err ("Error seeking to heap in %s: %s\n", outfile, strerror (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 (STREQ (argv[i], "-o"))
- continue;
- if ((in_fd = open (argv[i], O_RDONLY)) < 0)
- err ("Error opening %s for read: %s\n", argv[i],
- strerror (errno));
- if (fstat (in_fd, &stat_buf) < 0)
- err ("Error stat'ing %s: %s\n", argv[i], strerror (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, strerror (errno));
- if (read (f, &file_hdr, sizeof (file_hdr)) < 0)
- err ("Error reading exec structure: %s\n", strerror (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", strerror (errno));
- if (read (f, symbol_table, file_hdr.a_syms) == -1)
- err ("Error reading symbol table from %s: %s\n", file,
- strerror (errno));
-
- /* read in string table */
- if (read (f, &size, 4) == -1)
- err ("reading string table size: %s\n", strerror (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", strerror (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 (STREQ (sym_name, strings + sym->n_un.n_strx - 4))
- 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 (gdb_stderr, string, args);
- va_end (args);
- exit (-1);
-}
diff --git a/contrib/gdb/gdb/symfile.c b/contrib/gdb/gdb/symfile.c
index ee60c93..4604678 100644
--- a/contrib/gdb/gdb/symfile.c
+++ b/contrib/gdb/gdb/symfile.c
@@ -1,5 +1,5 @@
/* Generic symbol file reading for the GNU debugger, GDB.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996
Free Software Foundation, Inc.
Contributed by Cygnus Support, using pieces from other GDB modules.
@@ -34,10 +34,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "complaints.h"
#include "demangle.h"
#include "inferior.h" /* for write_pc */
-#include "gdb-stabs.h"
-#include "obstack.h"
+#include "obstack.h"
#include <assert.h>
+
#include <sys/types.h>
#include <fcntl.h>
#include "gdb_string.h"
@@ -52,23 +52,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define O_BINARY 0
#endif
-#ifdef HPUXHPPA
-
-/* Some HP-UX related globals to clear when a new "main"
- symbol file is loaded. HP-specific. */
-
-extern int hp_som_som_object_present;
-extern int hp_cxx_exception_support_initialized;
-#define RESET_HP_UX_GLOBALS() do {\
- hp_som_som_object_present = 0; /* indicates HP-compiled code */ \
- hp_cxx_exception_support_initialized = 0; /* must reinitialize exception stuff */ \
- } while (0)
-#endif
-
-int (*ui_load_progress_hook) PARAMS ((char *, unsigned long));
-void (*pre_add_symbol_hook) PARAMS ((char *));
-void (*post_add_symbol_hook) PARAMS ((void));
-
/* Global variables owned by this file */
int readnow_symbol_files; /* Read full symbols immediately */
@@ -84,65 +67,34 @@ struct complaint empty_symtab_complaint = {
extern int info_verbose;
-extern void report_transfer_performance PARAMS ((unsigned long,
- time_t, time_t));
-
/* Functions this file defines */
-#if 0
-static int simple_read_overlay_region_table PARAMS ((void));
-static void simple_free_overlay_region_table PARAMS ((void));
-#endif
-
-static void set_initial_language PARAMS ((void));
-
-static void load_command PARAMS ((char *, int));
-
-static void add_symbol_file_command PARAMS ((char *, int));
-
-static void add_shared_symbol_files_command PARAMS ((char *, int));
-
-static void cashier_psymtab PARAMS ((struct partial_symtab *));
-
-static int compare_psymbols PARAMS ((const void *, const void *));
-
-static int compare_symbols PARAMS ((const void *, const void *));
-
-bfd *symfile_bfd_open PARAMS ((char *));
-
-static void find_sym_fns PARAMS ((struct objfile *));
-
-static void decrement_reading_symtab PARAMS ((void *));
-
-static void overlay_invalidate_all PARAMS ((void));
-
-static int overlay_is_mapped PARAMS ((struct obj_section *));
-
-void list_overlays_command PARAMS ((char *, int));
-
-void map_overlay_command PARAMS ((char *, int));
-
-void unmap_overlay_command PARAMS ((char *, int));
-
-static void overlay_auto_command PARAMS ((char *, int));
-
-static void overlay_manual_command PARAMS ((char *, int));
+static void
+set_initial_language PARAMS ((void));
-static void overlay_off_command PARAMS ((char *, int));
+static void
+load_command PARAMS ((char *, int));
-static void overlay_load_command PARAMS ((char *, int));
+static void
+add_symbol_file_command PARAMS ((char *, int));
-static void overlay_command PARAMS ((char *, int));
+static void
+add_shared_symbol_files_command PARAMS ((char *, int));
-static void simple_free_overlay_table PARAMS ((void));
+static void
+cashier_psymtab PARAMS ((struct partial_symtab *));
-static void read_target_long_array PARAMS ((CORE_ADDR, unsigned int *, int));
+static int
+compare_psymbols PARAMS ((const void *, const void *));
-static int simple_read_overlay_table PARAMS ((void));
+static int
+compare_symbols PARAMS ((const void *, const void *));
-static int simple_overlay_update_1 PARAMS ((struct obj_section *));
+static bfd *
+symfile_bfd_open PARAMS ((char *));
-void _initialize_symfile PARAMS ((void));
+static void
+find_sym_fns PARAMS ((struct objfile *));
/* List of all available sym_fns. On gdb startup, each object file reader
calls add_symtab_fns() to register information on each format it is
@@ -159,25 +111,15 @@ int symbol_reloading = SYMBOL_RELOADING_DEFAULT;
int symbol_reloading = 0;
#endif
-/* If non-zero, then on HP-UX (i.e., platforms that use somsolib.c),
- this variable is interpreted as a threshhold. If adding a new
- library's symbol table to those already known to the debugger would
- exceed this threshhold, then the shlib's symbols are not added.
-
- If non-zero on other platforms, shared library symbols will be added
- automatically when the inferior is created, new libraries are loaded,
- or when attaching to the inferior. This is almost always what users
+/* If true, then shared library symbols will be added automatically
+ when the inferior is created, new libraries are loaded, or when
+ attaching to the inferior. This is almost always what users
will want to have happen; but for very large programs, the startup
time will be excessive, and so if this is a problem, the user can
clear this flag and then add the shared library symbols as needed.
Note that there is a potential for confusion, since if the shared
library symbols are not loaded, commands like "info fun" will *not*
- report all the functions that are actually present.
-
- Note that HP-UX interprets this variable to mean, "threshhold size
- in megabytes, where zero means never add". Other platforms interpret
- this variable to mean, "always add if non-zero, never add if zero."
- */
+ report all the functions that are actually present. */
int auto_solib_add = 1;
@@ -239,19 +181,7 @@ compare_psymbols (s1p, s2p)
}
else
{
- /* Note: I replaced the STRCMP line (commented out below)
- * with a simpler "strcmp()" which compares the 2 strings
- * from the beginning. (STRCMP is a macro which first compares
- * the initial characters, then falls back on strcmp).
- * The reason is that the STRCMP line was tickling a C compiler
- * bug on HP-UX 10.30, which is avoided with the simpler
- * code. The performance gain from the more complicated code
- * is negligible, given that we have already checked the
- * initial 2 characters above. I reported the compiler bug,
- * and once it is fixed the original line can be put back. RT
- */
- /* return ( STRCMP (st1 + 2, st2 + 2)); */
- return ( strcmp (st1, st2));
+ return (STRCMP (st1 + 2, st2 + 2));
}
}
@@ -300,10 +230,9 @@ sort_symtab_syms (s)
}
}
-/* Make a null terminated copy of the string at PTR with SIZE characters in
- the obstack pointed to by OBSTACKP . Returns the address of the copy.
- Note that the string at PTR does not have to be null terminated, I.E. it
- may be part of a larger string and we are only saving a substring. */
+/* 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, obstackp)
@@ -312,9 +241,8 @@ obsavestring (ptr, size, obstackp)
struct obstack *obstackp;
{
register char *p = (char *) obstack_alloc (obstackp, size + 1);
- /* Open-coded memcpy--saves function call time. These strings are usually
- short. FIXME: Is this really still true with a compiler that can
- inline memcpy? */
+ /* Open-coded memcpy--saves function call time.
+ These strings are usually short. */
{
register char *p1 = ptr;
register char *p2 = p;
@@ -326,8 +254,8 @@ obsavestring (ptr, size, obstackp)
return p;
}
-/* Concatenate strings S1, S2 and S3; return the new string. Space is found
- in the obstack pointed to by OBSTACKP. */
+/* Concatenate strings S1, S2 and S3; return the new string.
+ Space is found in the symbol_obstack. */
char *
obconcat (obstackp, s1, s2, s3)
@@ -443,31 +371,6 @@ find_lowest_section (abfd, sect, obj)
*lowest = sect;
}
-/* Parse the user's idea of an offset for dynamic linking, into our idea
- of how to represent it for fast symbol reading. This is the default
- version of the sym_fns.sym_offsets function for symbol readers that
- don't need to do anything special. It allocates a section_offsets table
- for the objectfile OBJFILE and stuffs ADDR into all of the offsets. */
-
-struct section_offsets *
-default_symfile_offsets (objfile, addr)
- struct objfile *objfile;
- CORE_ADDR addr;
-{
- struct section_offsets *section_offsets;
- int i;
-
- objfile->num_sections = SECT_OFF_MAX;
- section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile -> psymbol_obstack, SIZEOF_SECTION_OFFSETS);
-
- for (i = 0; i < SECT_OFF_MAX; i++)
- ANOFFSET (section_offsets, i) = addr;
-
- return section_offsets;
-}
-
-
/* Process a symbol file, as either the main file or as a dynamically
loaded file.
@@ -496,13 +399,13 @@ syms_from_objfile (objfile, addr, mainline, verbo)
/* Make sure that partially constructed symbol tables will be cleaned up
if an error occurs during symbol reading. */
- old_chain = make_cleanup ((make_cleanup_func) free_objfile, objfile);
+ old_chain = make_cleanup (free_objfile, objfile);
if (mainline)
{
/* We will modify the main symbol table, make sure that all its users
will be cleaned up if an error occurs during symbol reading. */
- make_cleanup ((make_cleanup_func) clear_symtab_users, 0);
+ make_cleanup (clear_symtab_users, 0);
/* Since no error yet, throw away the old symbol table. */
@@ -669,25 +572,17 @@ new_symfile_objfile (objfile, mainline, verbo)
as dynamically loaded code. If !mainline, ADDR is the address
where the text segment was loaded.
- USER_LOADED is TRUE if the add-symbol-file command was how this
- symbol file came to be processed.
-
- IS_SOLIB is TRUE if this symbol file represents a solib, as discovered
- by the target's implementation of the solib package.
-
Upon success, returns a pointer to the objfile that was added.
Upon failure, jumps back to command level (never returns). */
struct objfile *
-symbol_file_add (name, from_tty, addr, mainline, mapped, readnow, user_loaded, is_solib)
+symbol_file_add (name, from_tty, addr, mainline, mapped, readnow)
char *name;
int from_tty;
CORE_ADDR addr;
int mainline;
int mapped;
int readnow;
- int user_loaded;
- int is_solib;
{
struct objfile *objfile;
struct partial_symtab *psymtab;
@@ -704,7 +599,7 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow, user_loaded, i
&& !query ("Load new symbol table from \"%s\"? ", name))
error ("Not confirmed.");
- objfile = allocate_objfile (abfd, mapped, user_loaded, is_solib);
+ objfile = allocate_objfile (abfd, mapped);
/* If the objfile uses a mapped symbol file, and we have a psymtab for
it, then skip reading any symbols at this time. */
@@ -731,17 +626,12 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow, user_loaded, i
performed, or need to read an unmapped symbol table. */
if (from_tty || info_verbose)
{
- if (pre_add_symbol_hook)
- pre_add_symbol_hook (name);
- else
- {
- printf_filtered ("Reading symbols from %s...", name);
- wrap_here ("");
- gdb_flush (gdb_stdout);
- }
+ printf_filtered ("Reading symbols from %s...", name);
+ wrap_here ("");
+ gdb_flush (gdb_stdout);
}
syms_from_objfile (objfile, addr, mainline, from_tty);
- }
+ }
/* We now have at least a partial symbol table. Check to see if the
user requested that all symbols be read on initial access via either
@@ -767,19 +657,12 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow, user_loaded, i
if (from_tty || info_verbose)
{
- if (post_add_symbol_hook)
- post_add_symbol_hook ();
- else
- {
- printf_filtered ("done.\n");
- gdb_flush (gdb_stdout);
- }
+ printf_filtered ("done.\n");
+ gdb_flush (gdb_stdout);
}
new_symfile_objfile (objfile, mainline, from_tty);
- target_new_objfile (objfile);
-
return (objfile);
}
@@ -815,23 +698,11 @@ symbol_file_command (args, from_tty)
symfile_objfile -> name))
error ("Not confirmed.");
free_all_objfiles ();
-
- /* solib descriptors may have handles to objfiles. Since their
- storage has just been released, we'd better wipe the solib
- descriptors as well.
- */
-#if defined(SOLIB_RESTART)
- SOLIB_RESTART ();
-#endif
-
symfile_objfile = NULL;
if (from_tty)
{
printf_unfiltered ("No symbol file now.\n");
}
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
}
else
{
@@ -839,7 +710,7 @@ symbol_file_command (args, from_tty)
{
nomem (0);
}
- cleanups = make_cleanup ((make_cleanup_func) freeargv, (char *) argv);
+ cleanups = make_cleanup (freeargv, (char *) argv);
while (*argv != NULL)
{
if (STREQ (*argv, "-mapped"))
@@ -871,16 +742,11 @@ symbol_file_command (args, from_tty)
if (text_relocation == (CORE_ADDR)0)
return;
else if (text_relocation == (CORE_ADDR)-1)
- {
- symbol_file_add (name, from_tty, (CORE_ADDR)0,
- 1, mapped, readnow, 1, 0);
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
- }
+ symbol_file_add (name, from_tty, (CORE_ADDR)0, 1, mapped,
+ readnow);
else
symbol_file_add (name, from_tty, (CORE_ADDR)text_relocation,
- 0, mapped, readnow, 1, 0);
+ 0, mapped, readnow);
/* Getting new symbols may change our opinion about what is
frameless. */
@@ -895,7 +761,6 @@ symbol_file_command (args, from_tty)
{
error ("no symbol file name was specified");
}
- TUIDO(((TuiOpaqueFuncPtr)tuiDisplayMainFunction));
do_cleanups (cleanups);
}
}
@@ -938,7 +803,7 @@ set_initial_language ()
malloc'd` copy of NAME (tilde-expanded and made absolute).
In case of trouble, error() is called. */
-bfd *
+static bfd *
symfile_bfd_open (name)
char *name;
{
@@ -946,26 +811,16 @@ symfile_bfd_open (name)
int desc;
char *absolute_name;
-
-
name = tilde_expand (name); /* Returns 1st new malloc'd copy */
/* Look down path for it, allocate 2nd new malloc'd copy. */
desc = openp (getenv ("PATH"), 1, name, O_RDONLY | O_BINARY, 0, &absolute_name);
-#if defined(__GO32__) || defined(_WIN32)
- if (desc < 0)
- {
- char *exename = alloca (strlen (name) + 5);
- strcat (strcpy (exename, name), ".exe");
- desc = openp (getenv ("PATH"), 1, exename, O_RDONLY | O_BINARY,
- 0, &absolute_name);
- }
-#endif
if (desc < 0)
{
make_cleanup (free, name);
perror_with_name (name);
}
+ fcntl (desc, F_SETFD, 1);
free (name); /* Free 1st new malloc'd copy */
name = absolute_name; /* Keep 2nd malloc'd copy in bfd */
/* It'll be freed in free_objfile(). */
@@ -990,6 +845,7 @@ symfile_bfd_open (name)
error ("\"%s\": can't read symbols: %s.", name,
bfd_errmsg (bfd_get_error ()));
}
+
return (sym_bfd);
}
@@ -1061,8 +917,6 @@ load_command (arg, from_tty)
to worry about finding it, and (b) On VMS, fork() is very slow and so
we don't want to run a subprocess. On the other hand, I'm not sure how
performance compares. */
-#define GENERIC_LOAD_CHUNK 256
-#define VALIDATE_DOWNLOAD 0
void
generic_load (filename, from_tty)
char *filename;
@@ -1072,20 +926,7 @@ generic_load (filename, from_tty)
asection *s;
bfd *loadfile_bfd;
time_t start_time, end_time; /* Start and end times of download */
- unsigned long data_count = 0; /* Number of bytes transferred to memory */
- int n;
- unsigned long load_offset = 0; /* offset to add to vma for each section */
- char buf[GENERIC_LOAD_CHUNK+8];
-#if VALIDATE_DOWNLOAD
- char verify_buffer[GENERIC_LOAD_CHUNK+8] ;
-#endif
-
- /* enable user to specify address for downloading as 2nd arg to load */
- n = sscanf(filename, "%s 0x%lx", buf, &load_offset);
- if (n > 1 )
- filename = buf;
- else
- load_offset = 0;
+ unsigned long data_count; /* Number of bytes transferred to memory */
loadfile_bfd = bfd_openr (filename, gnutarget);
if (loadfile_bfd == NULL)
@@ -1096,7 +937,7 @@ generic_load (filename, from_tty)
/* FIXME: should be checking for errors from bfd_close (for one thing,
on error it does not free all the storage associated with the
bfd). */
- old_cleanups = make_cleanup ((make_cleanup_func) bfd_close, loadfile_bfd);
+ old_cleanups = make_cleanup (bfd_close, loadfile_bfd);
if (!bfd_check_format (loadfile_bfd, bfd_object))
{
@@ -1109,87 +950,45 @@ generic_load (filename, from_tty)
for (s = loadfile_bfd->sections; s; s = s->next)
{
if (s->flags & SEC_LOAD)
- {
- bfd_size_type size;
-
- size = bfd_get_section_size_before_reloc (s);
- if (size > 0)
- {
- char *buffer;
- struct cleanup *old_chain;
- bfd_vma lma;
- unsigned long l = size ;
- int err;
- char *sect;
- unsigned long sent;
- unsigned long len;
-
- l = l > GENERIC_LOAD_CHUNK ? GENERIC_LOAD_CHUNK : l ;
-
- buffer = xmalloc (size);
- old_chain = make_cleanup (free, buffer);
-
- lma = s->lma;
- lma += load_offset;
-
- /* Is this really necessary? I guess it gives the user something
- to look at during a long download. */
- printf_filtered ("Loading section %s, size 0x%lx lma ",
- bfd_get_section_name (loadfile_bfd, s),
- (unsigned long) size);
- print_address_numeric (lma, 1, gdb_stdout);
- printf_filtered ("\n");
-
- bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
-
- sect = (char *) bfd_get_section_name (loadfile_bfd, s);
- sent = 0;
- do
- {
- len = (size - sent) < l ? (size - sent) : l;
- sent += len;
- err = target_write_memory (lma, buffer, len);
- if (ui_load_progress_hook)
- if (ui_load_progress_hook (sect, sent))
- error ("Canceled the download");
-#if VALIDATE_DOWNLOAD
- /* Broken memories and broken monitors manifest themselves
- here when bring new computers to life.
- This doubles already slow downloads.
- */
- if (err) break ;
- {
- target_read_memory(lma,verify_buffer,len) ;
- if (0 != bcmp(buffer,verify_buffer,len))
- error("Download verify failed at %08x",
- (unsigned long)lma) ;
- }
+ {
+ bfd_size_type size;
-#endif
- data_count += len ;
- lma += len;
- buffer += len;
- } /* od */
- while (err == 0 && sent < size);
-
- if (err != 0)
- error ("Memory access error while loading section %s.",
- bfd_get_section_name (loadfile_bfd, s));
-
- do_cleanups (old_chain);
- }
- }
+ size = bfd_get_section_size_before_reloc (s);
+ if (size > 0)
+ {
+ char *buffer;
+ struct cleanup *old_chain;
+ bfd_vma vma;
+
+ data_count += size;
+
+ buffer = xmalloc (size);
+ old_chain = make_cleanup (free, buffer);
+
+ vma = bfd_get_section_vma (loadfile_bfd, s);
+
+ /* Is this really necessary? I guess it gives the user something
+ to look at during a long download. */
+ printf_filtered ("Loading section %s, size 0x%lx vma ",
+ bfd_get_section_name (loadfile_bfd, s),
+ (unsigned long) size);
+ print_address_numeric (vma, 1, gdb_stdout);
+ printf_filtered ("\n");
+
+ bfd_get_section_contents (loadfile_bfd, s, buffer, 0, size);
+
+ target_write_memory (vma, buffer, size);
+
+ do_cleanups (old_chain);
+ }
+ }
}
end_time = time (NULL);
- {
- unsigned long entry ;
- entry = bfd_get_start_address(loadfile_bfd) ;
- printf_filtered ("Start address 0x%lx , load size %d\n", entry,data_count);
- /* We were doing this in remote-mips.c, I suspect it is right
- for other targets too. */
- write_pc (entry);
- }
+
+ /* We were doing this in remote-mips.c, I suspect it is right
+ for other targets too. */
+ write_pc (loadfile_bfd->start_address);
/* FIXME: are we supposed to call symbol_file_add or not? According to
a comment from remote-mips.c (where a call to symbol_file_add was
@@ -1197,27 +996,13 @@ generic_load (filename, from_tty)
loaded in. remote-nindy.c had no call to symbol_file_add, but remote-vx.c
does. */
- report_transfer_performance (data_count, start_time, end_time);
+ if (end_time != start_time)
+ printf_filtered ("Transfer rate: %d bits/sec.\n",
+ (data_count * 8)/(end_time - start_time));
do_cleanups (old_cleanups);
}
-/* Report how fast the transfer went. */
-
-void
-report_transfer_performance (data_count, start_time, end_time)
-unsigned long data_count;
-time_t start_time, end_time;
-{
- printf_filtered ("Transfer rate: ");
- if (end_time != start_time)
- printf_filtered ("%d bits/sec",
- (data_count * 8) / (end_time - start_time));
- else
- printf_filtered ("%d bits in <1 sec", (data_count * 8));
- printf_filtered (".\n");
-}
-
/* This function allows the addition of incrementally linked object files.
It does not modify any state in the target, only in the debugger. */
@@ -1297,14 +1082,11 @@ add_symbol_file_command (args, from_tty)
}
/* FIXME-32x64: Assumes text_addr fits in a long. */
- if ((from_tty)
- && (!query ("add symbol table from file \"%s\" at text_addr = %s?\n",
- name, local_hex_string ((unsigned long)text_addr))))
+ if (!query ("add symbol table from file \"%s\" at text_addr = %s?\n",
+ name, local_hex_string ((unsigned long)text_addr)))
error ("Not confirmed.");
- symbol_file_add (name, from_tty, text_addr, 0, mapped, readnow,
- 1, /* user_loaded */
- 0); /* We'll guess it's ! is_solib */
+ symbol_file_add (name, 0, text_addr, 0, mapped, readnow);
/* Getting new symbols may change our opinion about what is
frameless. */
@@ -1378,10 +1160,9 @@ reread_symbols ()
/* If we get an error, blow away this objfile (not sure if
that is the correct response for things like shared
libraries). */
- old_cleanups = make_cleanup ((make_cleanup_func) free_objfile,
- objfile);
+ old_cleanups = make_cleanup (free_objfile, objfile);
/* We need to do this whenever any symbols go away. */
- make_cleanup ((make_cleanup_func) clear_symtab_users, 0);
+ make_cleanup (clear_symtab_users, 0);
/* Clean up any state BFD has sitting around. We don't need
to close the descriptor but BFD lacks a way of closing the
@@ -1470,12 +1251,7 @@ reread_symbols ()
distinguishing between the main file and additional files
in this way seems rather dubious. */
if (objfile == symfile_objfile)
- {
- (*objfile->sf->sym_new_init) (objfile);
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
- }
+ (*objfile->sf->sym_new_init) (objfile);
(*objfile->sf->sym_init) (objfile);
clear_complaints (1, 1);
@@ -1523,150 +1299,31 @@ reread_symbols ()
}
-
-typedef struct {
- char *ext;
- enum language lang;
-} filename_language;
-
-static filename_language * filename_language_table;
-static int fl_table_size, fl_table_next;
-
-static void
-add_filename_language (ext, lang)
- char *ext;
- enum language lang;
-{
- if (fl_table_next >= fl_table_size)
- {
- fl_table_size += 10;
- filename_language_table = realloc (filename_language_table,
- fl_table_size);
- }
-
- filename_language_table[fl_table_next].ext = strsave (ext);
- filename_language_table[fl_table_next].lang = lang;
- fl_table_next++;
-}
-
-static char *ext_args;
-
-static void
-set_ext_lang_command (args, from_tty)
- char *args;
- int from_tty;
-{
- int i;
- char *cp = ext_args;
- enum language lang;
-
- /* First arg is filename extension, starting with '.' */
- if (*cp != '.')
- error ("'%s': Filename extension must begin with '.'", ext_args);
-
- /* Find end of first arg. */
- while (*cp && !isspace (*cp))
- cp++;
-
- if (*cp == '\0')
- error ("'%s': two arguments required -- filename extension and language",
- ext_args);
-
- /* Null-terminate first arg */
- *cp++ = '\0';
-
- /* Find beginning of second arg, which should be a source language. */
- while (*cp && isspace (*cp))
- cp++;
-
- if (*cp == '\0')
- error ("'%s': two arguments required -- filename extension and language",
- ext_args);
-
- /* Lookup the language from among those we know. */
- lang = language_enum (cp);
-
- /* Now lookup the filename extension: do we already know it? */
- for (i = 0; i < fl_table_next; i++)
- if (0 == strcmp (ext_args, filename_language_table[i].ext))
- break;
-
- if (i >= fl_table_next)
- {
- /* new file extension */
- add_filename_language (ext_args, lang);
- }
- else
- {
- /* redefining a previously known filename extension */
-
- /* if (from_tty) */
- /* query ("Really make files of type %s '%s'?", */
- /* ext_args, language_str (lang)); */
-
- free (filename_language_table[i].ext);
- filename_language_table[i].ext = strsave (ext_args);
- filename_language_table[i].lang = lang;
- }
-}
-
-static void
-info_ext_lang_command (args, from_tty)
- char *args;
- int from_tty;
-{
- int i;
-
- printf_filtered ("Filename extensions and the languages they represent:");
- printf_filtered ("\n\n");
- for (i = 0; i < fl_table_next; i++)
- printf_filtered ("\t%s\t- %s\n",
- filename_language_table[i].ext,
- language_str (filename_language_table[i].lang));
-}
-
-static void
-init_filename_language_table ()
-{
- if (fl_table_size == 0) /* protect against repetition */
- {
- fl_table_size = 20;
- fl_table_next = 0;
- filename_language_table =
- xmalloc (fl_table_size * sizeof (*filename_language_table));
- add_filename_language (".c", language_c);
- add_filename_language (".C", language_cplus);
- add_filename_language (".cc", language_cplus);
- add_filename_language (".cp", language_cplus);
- add_filename_language (".cpp", language_cplus);
- add_filename_language (".cxx", language_cplus);
- add_filename_language (".c++", language_cplus);
- add_filename_language (".java", language_java);
- add_filename_language (".class", language_java);
- add_filename_language (".ch", language_chill);
- add_filename_language (".c186", language_chill);
- add_filename_language (".c286", language_chill);
- add_filename_language (".f", language_fortran);
- add_filename_language (".F", language_fortran);
- add_filename_language (".s", language_asm);
- add_filename_language (".S", language_asm);
- }
-}
-
enum language
deduce_language_from_filename (filename)
char *filename;
{
- int i;
- char *cp;
-
- if (filename != NULL)
- if ((cp = strrchr (filename, '.')) != NULL)
- for (i = 0; i < fl_table_next; i++)
- if (strcmp (cp, filename_language_table[i].ext) == 0)
- return filename_language_table[i].lang;
-
- return language_unknown;
+ char *c;
+
+ if (0 == filename)
+ ; /* Get default */
+ else if (0 == (c = strrchr (filename, '.')))
+ ; /* Get default. */
+ else if (STREQ (c, ".c"))
+ return language_c;
+ else if (STREQ (c, ".cc") || STREQ (c, ".C") || STREQ (c, ".cxx")
+ || STREQ (c, ".cpp") || STREQ (c, ".cp") || STREQ (c, ".c++"))
+ return language_cplus;
+ else if (STREQ (c, ".ch") || STREQ (c, ".c186") || STREQ (c, ".c286"))
+ return language_chill;
+ else if (STREQ (c, ".f") || STREQ (c, ".F"))
+ return language_fortran;
+ else if (STREQ (c, ".mod"))
+ return language_m2;
+ else if (STREQ (c, ".s") || STREQ (c, ".S"))
+ return language_asm;
+
+ return language_unknown; /* default */
}
/* allocate_symtab:
@@ -1680,6 +1337,7 @@ deduce_language_from_filename (filename)
symtab->dirname
symtab->free_code
symtab->free_ptr
+ initialize any EXTRA_SYMTAB_INFO
possibly free_named_symtabs (symtab->filename);
*/
@@ -1697,8 +1355,6 @@ allocate_symtab (filename, objfile)
&objfile -> symbol_obstack);
symtab -> fullname = NULL;
symtab -> language = deduce_language_from_filename (filename);
- symtab -> debugformat = obsavestring ("unknown", 7,
- &objfile -> symbol_obstack);
/* Hook it to the objfile it comes from */
@@ -1706,10 +1362,6 @@ allocate_symtab (filename, objfile)
symtab -> next = objfile -> symtabs;
objfile -> symtabs = symtab;
- /* FIXME: This should go away. It is only defined for the Z8000,
- and the Z8000 definition of this macro doesn't have anything to
- do with the now-nonexistent EXTRA_SYMTAB_INFO macro, it's just
- here for convenience. */
#ifdef INIT_EXTRA_SYMTAB_INFO
INIT_EXTRA_SYMTAB_INFO (symtab);
#endif
@@ -1739,57 +1391,18 @@ allocate_psymtab (filename, objfile)
&objfile -> psymbol_obstack);
psymtab -> symtab = NULL;
- /* Prepend it to the psymtab list for the objfile it belongs to.
- Psymtabs are searched in most recent inserted -> least recent
- inserted order. */
+ /* Hook it to the objfile it comes from */
psymtab -> objfile = objfile;
psymtab -> next = objfile -> psymtabs;
objfile -> psymtabs = psymtab;
-#if 0
- {
- struct partial_symtab **prev_pst;
- psymtab -> objfile = objfile;
- psymtab -> next = NULL;
- prev_pst = &(objfile -> psymtabs);
- while ((*prev_pst) != NULL)
- prev_pst = &((*prev_pst) -> next);
- (*prev_pst) = psymtab;
- }
-#endif
return (psymtab);
}
-void
-discard_psymtab (pst)
- struct partial_symtab *pst;
-{
- struct partial_symtab **prev_pst;
-
- /* From dbxread.c:
- Empty psymtabs happen as a result of header files which don't
- have any symbols in them. There can be a lot of them. But this
- check is wrong, in that a psymtab with N_SLINE entries but
- nothing else is not empty, but we don't realize that. Fixing
- that without slowing things down might be tricky. */
-
- /* First, snip it out of the psymtab chain */
-
- prev_pst = &(pst->objfile->psymtabs);
- while ((*prev_pst) != pst)
- prev_pst = &((*prev_pst)->next);
- (*prev_pst) = pst->next;
-
- /* Next, put it on a free list for recycling */
-
- pst->next = pst->objfile->free_psymtabs;
- pst->objfile->free_psymtabs = pst;
-}
-
/* Reset all data structures in gdb which may contain references to symbol
- table data. */
+ table date. */
void
clear_symtab_users ()
@@ -1804,7 +1417,6 @@ clear_symtab_users ()
current_source_symtab = 0;
current_source_line = 0;
clear_pc_function_cache ();
- target_new_objfile (NULL);
}
/* clear_symtab_users_once:
@@ -2089,83 +1701,6 @@ add_psymbol_to_list (name, namelength, namespace, class, list, val, coreaddr,
OBJSTAT (objfile, n_psyms++);
}
-/* Add a symbol with a long value to a psymtab. This differs from
- * add_psymbol_to_list above in taking both a mangled and a demangled
- * name. */
-
-void
-add_psymbol_with_dem_name_to_list (name, namelength, dem_name, dem_namelength,
- namespace, class, list, val, coreaddr, language, objfile)
- char *name;
- int namelength;
- char *dem_name;
- int dem_namelength;
- namespace_enum namespace;
- enum address_class class;
- struct psymbol_allocation_list *list;
- long val; /* Value as a long */
- CORE_ADDR coreaddr; /* Value as a CORE_ADDR */
- enum language language;
- struct objfile *objfile;
-{
- register struct partial_symbol *psym;
- char *buf = alloca (namelength + 1);
- /* psymbol is static so that there will be no uninitialized gaps in the
- structure which might contain random data, causing cache misses in
- bcache. */
- static struct partial_symbol psymbol;
-
- /* Create local copy of the partial symbol */
-
- memcpy (buf, name, namelength);
- buf[namelength] = '\0';
- SYMBOL_NAME (&psymbol) = bcache (buf, namelength + 1, &objfile->psymbol_cache);
-
- buf = alloca (dem_namelength + 1);
- memcpy (buf, dem_name, dem_namelength);
- buf[dem_namelength] = '\0';
-
- switch (language)
- {
- case language_c:
- case language_cplus:
- SYMBOL_CPLUS_DEMANGLED_NAME (&psymbol) =
- bcache (buf, dem_namelength + 1, &objfile->psymbol_cache);
- break;
- case language_chill:
- SYMBOL_CHILL_DEMANGLED_NAME (&psymbol) =
- bcache (buf, dem_namelength + 1, &objfile->psymbol_cache);
-
- /* FIXME What should be done for the default case? Ignoring for now. */
- }
-
- /* val and coreaddr are mutually exclusive, one of them *will* be zero */
- if (val != 0)
- {
- SYMBOL_VALUE (&psymbol) = val;
- }
- else
- {
- SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
- }
- SYMBOL_SECTION (&psymbol) = 0;
- SYMBOL_LANGUAGE (&psymbol) = language;
- PSYMBOL_NAMESPACE (&psymbol) = namespace;
- PSYMBOL_CLASS (&psymbol) = class;
- SYMBOL_INIT_LANGUAGE_SPECIFIC (&psymbol, language);
-
- /* Stash the partial symbol away in the cache */
- psym = bcache (&psymbol, sizeof (struct partial_symbol), &objfile->psymbol_cache);
-
- /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
- if (list->next >= list->list + list->size)
- {
- extend_psymbol_list (list, objfile);
- }
- *list->next++ = psym;
- OBJSTAT (objfile, n_psyms++);
-}
-
/* Initialize storage for partial symbols. */
void
@@ -2190,761 +1725,16 @@ init_psymbol_list (objfile, total_symbols)
objfile -> global_psymbols.size = total_symbols / 10;
objfile -> static_psymbols.size = total_symbols / 10;
-
- if (objfile -> global_psymbols.size > 0)
- {
- objfile -> global_psymbols.next =
- objfile -> global_psymbols.list = (struct partial_symbol **)
- xmmalloc (objfile -> md, (objfile -> global_psymbols.size
- * sizeof (struct partial_symbol *)));
- }
- if (objfile -> static_psymbols.size > 0)
- {
- objfile -> static_psymbols.next =
- objfile -> static_psymbols.list = (struct partial_symbol **)
- xmmalloc (objfile -> md, (objfile -> static_psymbols.size
- * sizeof (struct partial_symbol *)));
- }
-}
-
-/* OVERLAYS:
- The following code implements an abstraction for debugging overlay sections.
-
- The target model is as follows:
- 1) The gnu linker will permit multiple sections to be mapped into the
- same VMA, each with its own unique LMA (or load address).
- 2) It is assumed that some runtime mechanism exists for mapping the
- sections, one by one, from the load address into the VMA address.
- 3) This code provides a mechanism for gdb to keep track of which
- sections should be considered to be mapped from the VMA to the LMA.
- This information is used for symbol lookup, and memory read/write.
- For instance, if a section has been mapped then its contents
- should be read from the VMA, otherwise from the LMA.
-
- Two levels of debugger support for overlays are available. One is
- "manual", in which the debugger relies on the user to tell it which
- overlays are currently mapped. This level of support is
- implemented entirely in the core debugger, and the information about
- whether a section is mapped is kept in the objfile->obj_section table.
-
- The second level of support is "automatic", and is only available if
- the target-specific code provides functionality to read the target's
- overlay mapping table, and translate its contents for the debugger
- (by updating the mapped state information in the obj_section tables).
-
- The interface is as follows:
- User commands:
- overlay map <name> -- tell gdb to consider this section mapped
- overlay unmap <name> -- tell gdb to consider this section unmapped
- overlay list -- list the sections that GDB thinks are mapped
- overlay read-target -- get the target's state of what's mapped
- overlay off/manual/auto -- set overlay debugging state
- Functional interface:
- find_pc_mapped_section(pc): if the pc is in the range of a mapped
- section, return that section.
- find_pc_overlay(pc): find any overlay section that contains
- the pc, either in its VMA or its LMA
- overlay_is_mapped(sect): true if overlay is marked as mapped
- section_is_overlay(sect): true if section's VMA != LMA
- pc_in_mapped_range(pc,sec): true if pc belongs to section's VMA
- pc_in_unmapped_range(...): true if pc belongs to section's LMA
- overlay_mapped_address(...): map an address from section's LMA to VMA
- overlay_unmapped_address(...): map an address from section's VMA to LMA
- symbol_overlayed_address(...): Return a "current" address for symbol:
- either in VMA or LMA depending on whether
- the symbol's section is currently mapped
- */
-
-/* Overlay debugging state: */
-
-int overlay_debugging = 0; /* 0 == off, 1 == manual, -1 == auto */
-int overlay_cache_invalid = 0; /* True if need to refresh mapped state */
-
-/* Target vector for refreshing overlay mapped state */
-static void simple_overlay_update PARAMS ((struct obj_section *));
-void (*target_overlay_update) PARAMS ((struct obj_section *))
- = simple_overlay_update;
-
-/* Function: section_is_overlay (SECTION)
- Returns true if SECTION has VMA not equal to LMA, ie.
- SECTION is loaded at an address different from where it will "run". */
-
-int
-section_is_overlay (section)
- asection *section;
-{
- if (overlay_debugging)
- if (section && section->lma != 0 &&
- section->vma != section->lma)
- return 1;
-
- return 0;
-}
-
-/* Function: overlay_invalidate_all (void)
- Invalidate the mapped state of all overlay sections (mark it as stale). */
-
-static void
-overlay_invalidate_all ()
-{
- struct objfile *objfile;
- struct obj_section *sect;
-
- ALL_OBJSECTIONS (objfile, sect)
- if (section_is_overlay (sect->the_bfd_section))
- sect->ovly_mapped = -1;
-}
-
-/* Function: overlay_is_mapped (SECTION)
- Returns true if section is an overlay, and is currently mapped.
- Private: public access is thru function section_is_mapped.
-
- Access to the ovly_mapped flag is restricted to this function, so
- that we can do automatic update. If the global flag
- OVERLAY_CACHE_INVALID is set (by wait_for_inferior), then call
- overlay_invalidate_all. If the mapped state of the particular
- section is stale, then call TARGET_OVERLAY_UPDATE to refresh it. */
-
-static int
-overlay_is_mapped (osect)
- struct obj_section *osect;
-{
- if (osect == 0 || !section_is_overlay (osect->the_bfd_section))
- return 0;
-
- switch (overlay_debugging)
- {
- default:
- case 0: return 0; /* overlay debugging off */
- case -1: /* overlay debugging automatic */
- /* Unles there is a target_overlay_update function,
- there's really nothing useful to do here (can't really go auto) */
- if (target_overlay_update)
- {
- if (overlay_cache_invalid)
- {
- overlay_invalidate_all ();
- overlay_cache_invalid = 0;
- }
- if (osect->ovly_mapped == -1)
- (*target_overlay_update) (osect);
- }
- /* fall thru to manual case */
- case 1: /* overlay debugging manual */
- return osect->ovly_mapped == 1;
- }
-}
-
-/* Function: section_is_mapped
- Returns true if section is an overlay, and is currently mapped. */
-
-int
-section_is_mapped (section)
- asection *section;
-{
- struct objfile *objfile;
- struct obj_section *osect;
-
- if (overlay_debugging)
- if (section && section_is_overlay (section))
- ALL_OBJSECTIONS (objfile, osect)
- if (osect->the_bfd_section == section)
- return overlay_is_mapped (osect);
-
- return 0;
-}
-
-/* Function: pc_in_unmapped_range
- If PC falls into the lma range of SECTION, return true, else false. */
-
-CORE_ADDR
-pc_in_unmapped_range (pc, section)
- CORE_ADDR pc;
- asection *section;
-{
- int size;
-
- if (overlay_debugging)
- if (section && section_is_overlay (section))
- {
- size = bfd_get_section_size_before_reloc (section);
- if (section->lma <= pc && pc < section->lma + size)
- return 1;
- }
- return 0;
-}
-
-/* Function: pc_in_mapped_range
- If PC falls into the vma range of SECTION, return true, else false. */
-
-CORE_ADDR
-pc_in_mapped_range (pc, section)
- CORE_ADDR pc;
- asection *section;
-{
- int size;
-
- if (overlay_debugging)
- if (section && section_is_overlay (section))
- {
- size = bfd_get_section_size_before_reloc (section);
- if (section->vma <= pc && pc < section->vma + size)
- return 1;
- }
- return 0;
-}
-
-/* Function: overlay_unmapped_address (PC, SECTION)
- Returns the address corresponding to PC in the unmapped (load) range.
- May be the same as PC. */
-
-CORE_ADDR
-overlay_unmapped_address (pc, section)
- CORE_ADDR pc;
- asection *section;
-{
- if (overlay_debugging)
- if (section && section_is_overlay (section) &&
- pc_in_mapped_range (pc, section))
- return pc + section->lma - section->vma;
-
- return pc;
-}
-
-/* Function: overlay_mapped_address (PC, SECTION)
- Returns the address corresponding to PC in the mapped (runtime) range.
- May be the same as PC. */
-
-CORE_ADDR
-overlay_mapped_address (pc, section)
- CORE_ADDR pc;
- asection *section;
-{
- if (overlay_debugging)
- if (section && section_is_overlay (section) &&
- pc_in_unmapped_range (pc, section))
- return pc + section->vma - section->lma;
-
- return pc;
-}
-
-
-/* Function: symbol_overlayed_address
- Return one of two addresses (relative to the VMA or to the LMA),
- depending on whether the section is mapped or not. */
-
-CORE_ADDR
-symbol_overlayed_address (address, section)
- CORE_ADDR address;
- asection *section;
-{
- if (overlay_debugging)
- {
- /* If the symbol has no section, just return its regular address. */
- if (section == 0)
- return address;
- /* If the symbol's section is not an overlay, just return its address */
- if (!section_is_overlay (section))
- return address;
- /* If the symbol's section is mapped, just return its address */
- if (section_is_mapped (section))
- return address;
- /*
- * HOWEVER: if the symbol is in an overlay section which is NOT mapped,
- * then return its LOADED address rather than its vma address!!
- */
- return overlay_unmapped_address (address, section);
- }
- return address;
+ objfile -> global_psymbols.next =
+ objfile -> global_psymbols.list = (struct partial_symbol **)
+ xmmalloc (objfile -> md, objfile -> global_psymbols.size
+ * sizeof (struct partial_symbol *));
+ objfile -> static_psymbols.next =
+ objfile -> static_psymbols.list = (struct partial_symbol **)
+ xmmalloc (objfile -> md, objfile -> static_psymbols.size
+ * sizeof (struct partial_symbol *));
}
-
-/* Function: find_pc_overlay (PC)
- Return the best-match overlay section for PC:
- If PC matches a mapped overlay section's VMA, return that section.
- Else if PC matches an unmapped section's VMA, return that section.
- Else if PC matches an unmapped section's LMA, return that section. */
-
-asection *
-find_pc_overlay (pc)
- CORE_ADDR pc;
-{
- struct objfile *objfile;
- struct obj_section *osect, *best_match = NULL;
-
- if (overlay_debugging)
- ALL_OBJSECTIONS (objfile, osect)
- if (section_is_overlay (osect->the_bfd_section))
- {
- if (pc_in_mapped_range (pc, osect->the_bfd_section))
- {
- if (overlay_is_mapped (osect))
- return osect->the_bfd_section;
- else
- best_match = osect;
- }
- else if (pc_in_unmapped_range (pc, osect->the_bfd_section))
- best_match = osect;
- }
- return best_match ? best_match->the_bfd_section : NULL;
-}
-
-/* Function: find_pc_mapped_section (PC)
- If PC falls into the VMA address range of an overlay section that is
- currently marked as MAPPED, return that section. Else return NULL. */
-
-asection *
-find_pc_mapped_section (pc)
- CORE_ADDR pc;
-{
- struct objfile *objfile;
- struct obj_section *osect;
-
- if (overlay_debugging)
- ALL_OBJSECTIONS (objfile, osect)
- if (pc_in_mapped_range (pc, osect->the_bfd_section) &&
- overlay_is_mapped (osect))
- return osect->the_bfd_section;
-
- return NULL;
-}
-
-/* Function: list_overlays_command
- Print a list of mapped sections and their PC ranges */
-
-void
-list_overlays_command (args, from_tty)
- char *args;
- int from_tty;
-{
- int nmapped = 0;
- struct objfile *objfile;
- struct obj_section *osect;
-
- if (overlay_debugging)
- ALL_OBJSECTIONS (objfile, osect)
- if (overlay_is_mapped (osect))
- {
- const char *name;
- bfd_vma lma, vma;
- int size;
-
- vma = bfd_section_vma (objfile->obfd, osect->the_bfd_section);
- lma = bfd_section_lma (objfile->obfd, osect->the_bfd_section);
- size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
- name = bfd_section_name (objfile->obfd, osect->the_bfd_section);
-
- printf_filtered ("Section %s, loaded at ", name);
- print_address_numeric (lma, 1, gdb_stdout);
- puts_filtered (" - ");
- print_address_numeric (lma + size, 1, gdb_stdout);
- printf_filtered (", mapped at ");
- print_address_numeric (vma, 1, gdb_stdout);
- puts_filtered (" - ");
- print_address_numeric (vma + size, 1, gdb_stdout);
- puts_filtered ("\n");
-
- nmapped ++;
- }
- if (nmapped == 0)
- printf_filtered ("No sections are mapped.\n");
-}
-
-/* Function: map_overlay_command
- Mark the named section as mapped (ie. residing at its VMA address). */
-
-void
-map_overlay_command (args, from_tty)
- char *args;
- int from_tty;
-{
- struct objfile *objfile, *objfile2;
- struct obj_section *sec, *sec2;
- asection *bfdsec;
-
- if (!overlay_debugging)
- error ("Overlay debugging not enabled. Use the 'OVERLAY ON' command.");
-
- if (args == 0 || *args == 0)
- error ("Argument required: name of an overlay section");
-
- /* First, find a section matching the user supplied argument */
- ALL_OBJSECTIONS (objfile, sec)
- if (!strcmp (bfd_section_name (objfile->obfd, sec->the_bfd_section), args))
- {
- /* Now, check to see if the section is an overlay. */
- bfdsec = sec->the_bfd_section;
- if (!section_is_overlay (bfdsec))
- continue; /* not an overlay section */
-
- /* Mark the overlay as "mapped" */
- sec->ovly_mapped = 1;
-
- /* Next, make a pass and unmap any sections that are
- overlapped by this new section: */
- ALL_OBJSECTIONS (objfile2, sec2)
- if (sec2->ovly_mapped &&
- sec != sec2 &&
- sec->the_bfd_section != sec2->the_bfd_section &&
- (pc_in_mapped_range (sec2->addr, sec->the_bfd_section) ||
- pc_in_mapped_range (sec2->endaddr, sec->the_bfd_section)))
- {
- if (info_verbose)
- printf_filtered ("Note: section %s unmapped by overlap\n",
- bfd_section_name (objfile->obfd,
- sec2->the_bfd_section));
- sec2->ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2 */
- }
- return;
- }
- error ("No overlay section called %s", args);
-}
-
-/* Function: unmap_overlay_command
- Mark the overlay section as unmapped
- (ie. resident in its LMA address range, rather than the VMA range). */
-
-void
-unmap_overlay_command (args, from_tty)
- char *args;
- int from_tty;
-{
- struct objfile *objfile;
- struct obj_section *sec;
-
- if (!overlay_debugging)
- error ("Overlay debugging not enabled. Use the 'OVERLAY ON' command.");
-
- if (args == 0 || *args == 0)
- error ("Argument required: name of an overlay section");
-
- /* First, find a section matching the user supplied argument */
- ALL_OBJSECTIONS (objfile, sec)
- if (!strcmp (bfd_section_name (objfile->obfd, sec->the_bfd_section), args))
- {
- if (!sec->ovly_mapped)
- error ("Section %s is not mapped", args);
- sec->ovly_mapped = 0;
- return;
- }
- error ("No overlay section called %s", args);
-}
-
-/* Function: overlay_auto_command
- A utility command to turn on overlay debugging.
- Possibly this should be done via a set/show command. */
-
-static void
-overlay_auto_command (args, from_tty)
- char *args;
- int from_tty;
-{
- overlay_debugging = -1;
- if (info_verbose)
- printf_filtered ("Automatic overlay debugging enabled.");
-}
-
-/* Function: overlay_manual_command
- A utility command to turn on overlay debugging.
- Possibly this should be done via a set/show command. */
-
-static void
-overlay_manual_command (args, from_tty)
- char *args;
- int from_tty;
-{
- overlay_debugging = 1;
- if (info_verbose)
- printf_filtered ("Overlay debugging enabled.");
-}
-
-/* Function: overlay_off_command
- A utility command to turn on overlay debugging.
- Possibly this should be done via a set/show command. */
-
-static void
-overlay_off_command (args, from_tty)
- char *args;
- int from_tty;
-{
- overlay_debugging = 0;
- if (info_verbose)
- printf_filtered ("Overlay debugging disabled.");
-}
-
-static void
-overlay_load_command (args, from_tty)
- char *args;
- int from_tty;
-{
- if (target_overlay_update)
- (*target_overlay_update) (NULL);
- else
- error ("This target does not know how to read its overlay state.");
-}
-
-/* Function: overlay_command
- A place-holder for a mis-typed command */
-
-/* Command list chain containing all defined "overlay" subcommands. */
-struct cmd_list_element *overlaylist;
-
-static void
-overlay_command (args, from_tty)
- char *args;
- int from_tty;
-{
- printf_unfiltered
- ("\"overlay\" must be followed by the name of an overlay command.\n");
- help_list (overlaylist, "overlay ", -1, gdb_stdout);
-}
-
-
-/* Target Overlays for the "Simplest" overlay manager:
-
- This is GDB's default target overlay layer. It works with the
- minimal overlay manager supplied as an example by Cygnus. The
- entry point is via a function pointer "target_overlay_update",
- so targets that use a different runtime overlay manager can
- substitute their own overlay_update function and take over the
- function pointer.
-
- The overlay_update function pokes around in the target's data structures
- to see what overlays are mapped, and updates GDB's overlay mapping with
- this information.
-
- In this simple implementation, the target data structures are as follows:
- unsigned _novlys; /# number of overlay sections #/
- unsigned _ovly_table[_novlys][4] = {
- {VMA, SIZE, LMA, MAPPED}, /# one entry per overlay section #/
- {..., ..., ..., ...},
- }
- unsigned _novly_regions; /# number of overlay regions #/
- unsigned _ovly_region_table[_novly_regions][3] = {
- {VMA, SIZE, MAPPED_TO_LMA}, /# one entry per overlay region #/
- {..., ..., ...},
- }
- These functions will attempt to update GDB's mappedness state in the
- symbol section table, based on the target's mappedness state.
-
- To do this, we keep a cached copy of the target's _ovly_table, and
- attempt to detect when the cached copy is invalidated. The main
- entry point is "simple_overlay_update(SECT), which looks up SECT in
- the cached table and re-reads only the entry for that section from
- the target (whenever possible).
- */
-
-/* Cached, dynamically allocated copies of the target data structures: */
-static unsigned (*cache_ovly_table)[4] = 0;
-#if 0
-static unsigned (*cache_ovly_region_table)[3] = 0;
-#endif
-static unsigned cache_novlys = 0;
-#if 0
-static unsigned cache_novly_regions = 0;
-#endif
-static CORE_ADDR cache_ovly_table_base = 0;
-#if 0
-static CORE_ADDR cache_ovly_region_table_base = 0;
-#endif
-enum ovly_index { VMA, SIZE, LMA, MAPPED};
-#define TARGET_LONG_BYTES (TARGET_LONG_BIT / TARGET_CHAR_BIT)
-
-/* Throw away the cached copy of _ovly_table */
-static void
-simple_free_overlay_table ()
-{
- if (cache_ovly_table)
- free(cache_ovly_table);
- cache_novlys = 0;
- cache_ovly_table = NULL;
- cache_ovly_table_base = 0;
-}
-
-#if 0
-/* Throw away the cached copy of _ovly_region_table */
-static void
-simple_free_overlay_region_table ()
-{
- if (cache_ovly_region_table)
- free(cache_ovly_region_table);
- cache_novly_regions = 0;
- cache_ovly_region_table = NULL;
- cache_ovly_region_table_base = 0;
-}
-#endif
-
-/* Read an array of ints from the target into a local buffer.
- Convert to host order. int LEN is number of ints */
-static void
-read_target_long_array (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- unsigned int *myaddr;
- int len;
-{
- char *buf = alloca (len * TARGET_LONG_BYTES);
- int i;
-
- read_memory (memaddr, buf, len * TARGET_LONG_BYTES);
- for (i = 0; i < len; i++)
- myaddr[i] = extract_unsigned_integer (TARGET_LONG_BYTES * i + buf,
- TARGET_LONG_BYTES);
-}
-
-/* Find and grab a copy of the target _ovly_table
- (and _novlys, which is needed for the table's size) */
-static int
-simple_read_overlay_table ()
-{
- struct minimal_symbol *msym;
-
- simple_free_overlay_table ();
- msym = lookup_minimal_symbol ("_novlys", 0, 0);
- if (msym != NULL)
- cache_novlys = read_memory_integer (SYMBOL_VALUE_ADDRESS (msym), 4);
- else
- return 0; /* failure */
- cache_ovly_table = (void *) xmalloc (cache_novlys * sizeof(*cache_ovly_table));
- if (cache_ovly_table != NULL)
- {
- msym = lookup_minimal_symbol ("_ovly_table", 0, 0);
- if (msym != NULL)
- {
- cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (msym);
- read_target_long_array (cache_ovly_table_base,
- (int *) cache_ovly_table,
- cache_novlys * 4);
- }
- else
- return 0; /* failure */
- }
- else
- return 0; /* failure */
- return 1; /* SUCCESS */
-}
-
-#if 0
-/* Find and grab a copy of the target _ovly_region_table
- (and _novly_regions, which is needed for the table's size) */
-static int
-simple_read_overlay_region_table ()
-{
- struct minimal_symbol *msym;
-
- simple_free_overlay_region_table ();
- msym = lookup_minimal_symbol ("_novly_regions", 0, 0);
- if (msym != NULL)
- cache_novly_regions = read_memory_integer (SYMBOL_VALUE_ADDRESS (msym), 4);
- else
- return 0; /* failure */
- cache_ovly_region_table = (void *) xmalloc (cache_novly_regions * 12);
- if (cache_ovly_region_table != NULL)
- {
- msym = lookup_minimal_symbol ("_ovly_region_table", 0, 0);
- if (msym != NULL)
- {
- cache_ovly_region_table_base = SYMBOL_VALUE_ADDRESS (msym);
- read_target_long_array (cache_ovly_region_table_base,
- (int *) cache_ovly_region_table,
- cache_novly_regions * 3);
- }
- else
- return 0; /* failure */
- }
- else
- return 0; /* failure */
- return 1; /* SUCCESS */
-}
-#endif
-
-/* Function: simple_overlay_update_1
- A helper function for simple_overlay_update. Assuming a cached copy
- of _ovly_table exists, look through it to find an entry whose vma,
- lma and size match those of OSECT. Re-read the entry and make sure
- it still matches OSECT (else the table may no longer be valid).
- Set OSECT's mapped state to match the entry. Return: 1 for
- success, 0 for failure. */
-
-static int
-simple_overlay_update_1 (osect)
- struct obj_section *osect;
-{
- int i, size;
-
- size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
- for (i = 0; i < cache_novlys; i++)
- if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
- cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* &&
- cache_ovly_table[i][SIZE] == size */)
- {
- read_target_long_array (cache_ovly_table_base + i * TARGET_LONG_BYTES,
- (int *) cache_ovly_table[i], 4);
- if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
- cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* &&
- cache_ovly_table[i][SIZE] == size */)
- {
- osect->ovly_mapped = cache_ovly_table[i][MAPPED];
- return 1;
- }
- else /* Warning! Warning! Target's ovly table has changed! */
- return 0;
- }
- return 0;
-}
-
-/* Function: simple_overlay_update
- If OSECT is NULL, then update all sections' mapped state
- (after re-reading the entire target _ovly_table).
- If OSECT is non-NULL, then try to find a matching entry in the
- cached ovly_table and update only OSECT's mapped state.
- If a cached entry can't be found or the cache isn't valid, then
- re-read the entire cache, and go ahead and update all sections. */
-
-static void
-simple_overlay_update (osect)
- struct obj_section *osect;
-{
- struct objfile *objfile;
-
- /* Were we given an osect to look up? NULL means do all of them. */
- if (osect)
- /* Have we got a cached copy of the target's overlay table? */
- if (cache_ovly_table != NULL)
- /* Does its cached location match what's currently in the symtab? */
- if (cache_ovly_table_base ==
- SYMBOL_VALUE_ADDRESS (lookup_minimal_symbol ("_ovly_table", 0, 0)))
- /* Then go ahead and try to look up this single section in the cache */
- if (simple_overlay_update_1 (osect))
- /* Found it! We're done. */
- return;
-
- /* Cached table no good: need to read the entire table anew.
- Or else we want all the sections, in which case it's actually
- more efficient to read the whole table in one block anyway. */
-
- if (simple_read_overlay_table () == 0) /* read failed? No table? */
- {
- warning ("Failed to read the target overlay mapping table.");
- return;
- }
- /* Now may as well update all sections, even if only one was requested. */
- ALL_OBJSECTIONS (objfile, osect)
- if (section_is_overlay (osect->the_bfd_section))
- {
- int i, size;
-
- size = bfd_get_section_size_before_reloc (osect->the_bfd_section);
- for (i = 0; i < cache_novlys; i++)
- if (cache_ovly_table[i][VMA] == osect->the_bfd_section->vma &&
- cache_ovly_table[i][LMA] == osect->the_bfd_section->lma /* &&
- cache_ovly_table[i][SIZE] == size */)
- { /* obj_section matches i'th entry in ovly_table */
- osect->ovly_mapped = cache_ovly_table[i][MAPPED];
- break; /* finished with inner for loop: break out */
- }
- }
-}
-
-
+
void
_initialize_symfile ()
{
@@ -2982,40 +1772,4 @@ for access from GDB.", &cmdlist);
&setlist),
&showlist);
- add_prefix_cmd ("overlay", class_support, overlay_command,
- "Commands for debugging overlays.", &overlaylist,
- "overlay ", 0, &cmdlist);
-
- add_com_alias ("ovly", "overlay", class_alias, 1);
- add_com_alias ("ov", "overlay", class_alias, 1);
-
- add_cmd ("map-overlay", class_support, map_overlay_command,
- "Assert that an overlay section is mapped.", &overlaylist);
-
- add_cmd ("unmap-overlay", class_support, unmap_overlay_command,
- "Assert that an overlay section is unmapped.", &overlaylist);
-
- add_cmd ("list-overlays", class_support, list_overlays_command,
- "List mappings of overlay sections.", &overlaylist);
-
- add_cmd ("manual", class_support, overlay_manual_command,
- "Enable overlay debugging.", &overlaylist);
- add_cmd ("off", class_support, overlay_off_command,
- "Disable overlay debugging.", &overlaylist);
- add_cmd ("auto", class_support, overlay_auto_command,
- "Enable automatic overlay debugging.", &overlaylist);
- add_cmd ("load-target", class_support, overlay_load_command,
- "Read the overlay mapping state from the target.", &overlaylist);
-
- /* Filename extension to source language lookup table: */
- init_filename_language_table ();
- c = add_set_cmd ("extension-language", class_files, var_string_noescape,
- (char *) &ext_args,
- "Set mapping between filename extension and source language.\n\
-Usage: set extension-language .foo bar",
- &setlist);
- c->function.cfunc = set_ext_lang_command;
-
- add_info ("extensions", info_ext_lang_command,
- "All filename extensions associated with a source language.");
}
diff --git a/contrib/gdb/gdb/symm-nat.c b/contrib/gdb/gdb/symm-nat.c
deleted file mode 100644
index 0461066..0000000
--- a/contrib/gdb/gdb/symm-nat.c
+++ /dev/null
@@ -1,846 +0,0 @@
-/* Sequent Symmetry host interface, for GDB when running under Unix.
- Copyright 1986, 1987, 1989, 1991, 1992, 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* FIXME, some 387-specific items of use taken from i387-tdep.c -- ought to be
- merged back in. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "symtab.h"
-#include "target.h"
-
-/* FIXME: What is the _INKERNEL define for? */
-#define _INKERNEL
-#include <signal.h>
-#undef _INKERNEL
-#include <sys/wait.h>
-#include <sys/param.h>
-#include <sys/user.h>
-#include <sys/proc.h>
-#include <sys/dir.h>
-#include <sys/ioctl.h>
-#include "gdb_stat.h"
-#ifdef _SEQUENT_
-#include <sys/ptrace.h>
-#else
-/* Dynix has only machine/ptrace.h, which is already included by sys/user.h */
-/* Dynix has no mptrace call */
-#define mptrace ptrace
-#endif
-#include "gdbcore.h"
-#include <fcntl.h>
-#include <sgtty.h>
-#define TERMINAL struct sgttyb
-
-#include "gdbcore.h"
-
-void
-store_inferior_registers(regno)
-int regno;
-{
- struct pt_regset regs;
- int i;
- extern char registers[];
-
- /* FIXME: Fetching the registers is a kludge to initialize all elements
- in the fpu and fpa status. This works for normal debugging, but
- might cause problems when calling functions in the inferior.
- At least fpu_control and fpa_pcr (probably more) should be added
- to the registers array to solve this properly. */
- mptrace (XPT_RREGS, inferior_pid, (PTRACE_ARG3_TYPE) &regs, 0);
-
- regs.pr_eax = *(int *)&registers[REGISTER_BYTE(0)];
- regs.pr_ebx = *(int *)&registers[REGISTER_BYTE(5)];
- regs.pr_ecx = *(int *)&registers[REGISTER_BYTE(2)];
- regs.pr_edx = *(int *)&registers[REGISTER_BYTE(1)];
- regs.pr_esi = *(int *)&registers[REGISTER_BYTE(6)];
- regs.pr_edi = *(int *)&registers[REGISTER_BYTE(7)];
- regs.pr_esp = *(int *)&registers[REGISTER_BYTE(14)];
- regs.pr_ebp = *(int *)&registers[REGISTER_BYTE(15)];
- regs.pr_eip = *(int *)&registers[REGISTER_BYTE(16)];
- regs.pr_flags = *(int *)&registers[REGISTER_BYTE(17)];
- for (i = 0; i < 31; i++)
- {
- regs.pr_fpa.fpa_regs[i] =
- *(int *)&registers[REGISTER_BYTE(FP1_REGNUM+i)];
- }
- memcpy (regs.pr_fpu.fpu_stack[0], &registers[REGISTER_BYTE(ST0_REGNUM)], 10);
- memcpy (regs.pr_fpu.fpu_stack[1], &registers[REGISTER_BYTE(ST1_REGNUM)], 10);
- memcpy (regs.pr_fpu.fpu_stack[2], &registers[REGISTER_BYTE(ST2_REGNUM)], 10);
- memcpy (regs.pr_fpu.fpu_stack[3], &registers[REGISTER_BYTE(ST3_REGNUM)], 10);
- memcpy (regs.pr_fpu.fpu_stack[4], &registers[REGISTER_BYTE(ST4_REGNUM)], 10);
- memcpy (regs.pr_fpu.fpu_stack[5], &registers[REGISTER_BYTE(ST5_REGNUM)], 10);
- memcpy (regs.pr_fpu.fpu_stack[6], &registers[REGISTER_BYTE(ST6_REGNUM)], 10);
- memcpy (regs.pr_fpu.fpu_stack[7], &registers[REGISTER_BYTE(ST7_REGNUM)], 10);
- mptrace (XPT_WREGS, inferior_pid, (PTRACE_ARG3_TYPE) &regs, 0);
-}
-
-void
-fetch_inferior_registers (regno)
- int regno;
-{
- int i;
- struct pt_regset regs;
- extern char registers[];
-
- registers_fetched ();
-
- mptrace (XPT_RREGS, inferior_pid, (PTRACE_ARG3_TYPE) &regs, 0);
- *(int *)&registers[REGISTER_BYTE(EAX_REGNUM)] = regs.pr_eax;
- *(int *)&registers[REGISTER_BYTE(EBX_REGNUM)] = regs.pr_ebx;
- *(int *)&registers[REGISTER_BYTE(ECX_REGNUM)] = regs.pr_ecx;
- *(int *)&registers[REGISTER_BYTE(EDX_REGNUM)] = regs.pr_edx;
- *(int *)&registers[REGISTER_BYTE(ESI_REGNUM)] = regs.pr_esi;
- *(int *)&registers[REGISTER_BYTE(EDI_REGNUM)] = regs.pr_edi;
- *(int *)&registers[REGISTER_BYTE(EBP_REGNUM)] = regs.pr_ebp;
- *(int *)&registers[REGISTER_BYTE(ESP_REGNUM)] = regs.pr_esp;
- *(int *)&registers[REGISTER_BYTE(EIP_REGNUM)] = regs.pr_eip;
- *(int *)&registers[REGISTER_BYTE(EFLAGS_REGNUM)] = regs.pr_flags;
- for (i = 0; i < FPA_NREGS; i++)
- {
- *(int *)&registers[REGISTER_BYTE(FP1_REGNUM+i)] =
- regs.pr_fpa.fpa_regs[i];
- }
- memcpy (&registers[REGISTER_BYTE(ST0_REGNUM)], regs.pr_fpu.fpu_stack[0], 10);
- memcpy (&registers[REGISTER_BYTE(ST1_REGNUM)], regs.pr_fpu.fpu_stack[1], 10);
- memcpy (&registers[REGISTER_BYTE(ST2_REGNUM)], regs.pr_fpu.fpu_stack[2], 10);
- memcpy (&registers[REGISTER_BYTE(ST3_REGNUM)], regs.pr_fpu.fpu_stack[3], 10);
- memcpy (&registers[REGISTER_BYTE(ST4_REGNUM)], regs.pr_fpu.fpu_stack[4], 10);
- memcpy (&registers[REGISTER_BYTE(ST5_REGNUM)], regs.pr_fpu.fpu_stack[5], 10);
- memcpy (&registers[REGISTER_BYTE(ST6_REGNUM)], regs.pr_fpu.fpu_stack[6], 10);
- memcpy (&registers[REGISTER_BYTE(ST7_REGNUM)], regs.pr_fpu.fpu_stack[7], 10);
-}
-
-/* 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_unfiltered("80387:");
- if (ep.pr_fpu.fpu_ip == 0) {
- printf_unfiltered(" not in use.\n");
- return;
- } else {
- printf_unfiltered("\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_unfiltered ("last exception: ");
- printf_unfiltered ("opcode 0x%x; ", ep.pr_fpu.fpu_rsvd4);
- printf_unfiltered ("pc 0x%x:0x%x; ", ep.pr_fpu.fpu_cs, ep.pr_fpu.fpu_ip);
- printf_unfiltered ("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_unfiltered ("regno tag msb lsb value\n");
- for (fpreg = 7; fpreg >= 0; fpreg--)
- {
- double val;
-
- printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
-
- switch ((ep.pr_fpu.fpu_tag >> (fpreg * 2)) & 3)
- {
- case 0: printf_unfiltered ("valid "); break;
- case 1: printf_unfiltered ("zero "); break;
- case 2: printf_unfiltered ("trap "); break;
- case 3: printf_unfiltered ("empty "); break;
- }
- for (i = 9; i >= 0; i--)
- printf_unfiltered ("%02x", ep.pr_fpu.fpu_stack[fpreg][i]);
-
- i387_to_double ((char *)ep.pr_fpu.fpu_stack[fpreg], (char *)&val);
- printf_unfiltered (" %g\n", val);
- }
- if (ep.pr_fpu.fpu_rsvd1)
- warning ("rsvd1 is 0x%x\n", ep.pr_fpu.fpu_rsvd1);
- if (ep.pr_fpu.fpu_rsvd2)
- warning ("rsvd2 is 0x%x\n", ep.pr_fpu.fpu_rsvd2);
- if (ep.pr_fpu.fpu_rsvd3)
- warning ("rsvd3 is 0x%x\n", ep.pr_fpu.fpu_rsvd3);
- if (ep.pr_fpu.fpu_rsvd5)
- 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_unfiltered("\tMODE= %#x; RND= %#x ", pcr_tmp, pcr_tmp & 12);
- switch (pcr_tmp & 12) {
- case 0:
- printf_unfiltered("RN (Nearest Value)");
- break;
- case 1:
- printf_unfiltered("RZ (Zero)");
- break;
- case 2:
- printf_unfiltered("RP (Positive Infinity)");
- break;
- case 3:
- printf_unfiltered("RM (Negative Infinity)");
- break;
- }
- printf_unfiltered("; IRND= %d ", pcr_tmp & 2);
- if (0 == pcr_tmp & 2) {
- printf_unfiltered("(same as RND)\n");
- } else {
- printf_unfiltered("(toward zero)\n");
- }
- pcr_tmp = pcr & FPA_PCR_EM;
- printf_unfiltered("\tEM= %#x", pcr_tmp);
- if (pcr_tmp & FPA_PCR_EM_DM) printf_unfiltered(" DM");
- if (pcr_tmp & FPA_PCR_EM_UOM) printf_unfiltered(" UOM");
- if (pcr_tmp & FPA_PCR_EM_PM) printf_unfiltered(" PM");
- if (pcr_tmp & FPA_PCR_EM_UM) printf_unfiltered(" UM");
- if (pcr_tmp & FPA_PCR_EM_OM) printf_unfiltered(" OM");
- if (pcr_tmp & FPA_PCR_EM_ZM) printf_unfiltered(" ZM");
- if (pcr_tmp & FPA_PCR_EM_IM) printf_unfiltered(" IM");
- printf_unfiltered("\n");
- pcr_tmp = FPA_PCR_CC;
- printf_unfiltered("\tCC= %#x", pcr_tmp);
- if (pcr_tmp & FPA_PCR_20MHZ) printf_unfiltered(" 20MHZ");
- if (pcr_tmp & FPA_PCR_CC_Z) printf_unfiltered(" Z");
- if (pcr_tmp & FPA_PCR_CC_C2) printf_unfiltered(" C2");
-
- /* Dynix defines FPA_PCR_CC_C0 to 0x100 and ptx defines
- FPA_PCR_CC_C1 to 0x100. Use whichever is defined and assume
- the OS knows what it is doing. */
-#ifdef FPA_PCR_CC_C1
- if (pcr_tmp & FPA_PCR_CC_C1) printf_unfiltered(" C1");
-#else
- if (pcr_tmp & FPA_PCR_CC_C0) printf_unfiltered(" C0");
-#endif
-
- switch (pcr_tmp)
- {
- case FPA_PCR_CC_Z:
- printf_unfiltered(" (Equal)");
- break;
-#ifdef FPA_PCR_CC_C1
- case FPA_PCR_CC_C1:
-#else
- case FPA_PCR_CC_C0:
-#endif
- printf_unfiltered(" (Less than)");
- break;
- case 0:
- printf_unfiltered(" (Greater than)");
- break;
- case FPA_PCR_CC_Z |
-#ifdef FPA_PCR_CC_C1
- FPA_PCR_CC_C1
-#else
- FPA_PCR_CC_C0
-#endif
- | FPA_PCR_CC_C2:
- printf_unfiltered(" (Unordered)");
- break;
- default:
- printf_unfiltered(" (Undefined)");
- break;
- }
- printf_unfiltered("\n");
- pcr_tmp = pcr & FPA_PCR_AE;
- printf_unfiltered("\tAE= %#x", pcr_tmp);
- if (pcr_tmp & FPA_PCR_AE_DE) printf_unfiltered(" DE");
- if (pcr_tmp & FPA_PCR_AE_UOE) printf_unfiltered(" UOE");
- if (pcr_tmp & FPA_PCR_AE_PE) printf_unfiltered(" PE");
- if (pcr_tmp & FPA_PCR_AE_UE) printf_unfiltered(" UE");
- if (pcr_tmp & FPA_PCR_AE_OE) printf_unfiltered(" OE");
- if (pcr_tmp & FPA_PCR_AE_ZE) printf_unfiltered(" ZE");
- if (pcr_tmp & FPA_PCR_AE_EE) printf_unfiltered(" EE");
- if (pcr_tmp & FPA_PCR_AE_IE) printf_unfiltered(" IE");
- printf_unfiltered("\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_unfiltered("%%fp%d: raw= %#x, single= %f", i+1, regs[i], xf.f);
- if (!(i & 1)) {
- printf_unfiltered("\n");
- } else {
- xd.l[1] = regs[i];
- xd.l[0] = regs[i+1];
- printf_unfiltered(", double= %f\n", xd.d);
- }
- }
-}
-
-print_fpa_status(ep)
-struct pt_regset ep;
-
-{
-
- printf_unfiltered("WTL 1167:");
- if (ep.pr_fpa.fpa_pcr !=0) {
- printf_unfiltered("\n");
- print_1167_control_word(ep.pr_fpa.fpa_pcr);
- print_1167_regs(ep.pr_fpa.fpa_regs);
- } else {
- printf_unfiltered(" not in use.\n");
- }
-}
-
-#if 0 /* disabled because it doesn't go through the target vector. */
-i386_float_info ()
-{
- char ubuf[UPAGES*NBPG];
- struct pt_regset regset;
-
- if (have_inferior_p())
- {
- PTRACE_READ_REGS (inferior_pid, (PTRACE_ARG3_TYPE) &regset);
- }
- else
- {
- int corechan = bfd_cache_lookup (core_bfd);
- 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);
-}
-#endif
-
-static volatile int got_sigchld;
-
-/*ARGSUSED*/
-/* This will eventually be more interesting. */
-void
-sigchld_handler(signo)
- int signo;
-{
- got_sigchld++;
-}
-
-/*
- * Signals for which the default action does not cause the process
- * to die. See <sys/signal.h> for where this came from (alas, we
- * can't use those macros directly)
- */
-#ifndef sigmask
-#define sigmask(s) (1 << ((s) - 1))
-#endif
-#define SIGNALS_DFL_SAFE sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
- sigmask(SIGTTIN) | sigmask(SIGTTOU) | sigmask(SIGCHLD) | \
- sigmask(SIGCONT) | sigmask(SIGWINCH) | sigmask(SIGPWR) | \
- sigmask(SIGURG) | sigmask(SIGPOLL)
-
-#ifdef ATTACH_DETACH
-/*
- * Thanks to XPT_MPDEBUGGER, we have to mange child_wait().
- */
-int
-child_wait(pid, status)
- int pid;
- struct target_waitstatus *status;
-{
- int save_errno, rv, xvaloff, saoff, sa_hand;
- struct pt_stop pt;
- struct user u;
- sigset_t set;
- /* Host signal number for a signal which the inferior terminates with, or
- 0 if it hasn't terminated due to a signal. */
- static int death_by_signal = 0;
-#ifdef SVR4_SHARED_LIBS /* use this to distinguish ptx 2 vs ptx 4 */
- prstatus_t pstatus;
-#endif
-
- do {
- set_sigint_trap(); /* Causes SIGINT to be passed on to the
- attached process. */
- save_errno = errno;
-
- got_sigchld = 0;
-
- sigemptyset(&set);
-
- while (got_sigchld == 0) {
- sigsuspend(&set);
- }
-
- clear_sigint_trap();
-
- rv = mptrace(XPT_STOPSTAT, 0, (char *)&pt, 0);
- if (-1 == rv) {
- printf("XPT_STOPSTAT: errno %d\n", errno); /* DEBUG */
- continue;
- }
-
- pid = pt.ps_pid;
-
- if (pid != inferior_pid) {
- /* NOTE: the mystery fork in csh/tcsh needs to be ignored.
- * We should not return new children for the initial run
- * of a process until it has done the exec.
- */
- /* inferior probably forked; send it on its way */
- rv = mptrace(XPT_UNDEBUG, pid, 0, 0);
- if (-1 == rv) {
- printf("child_wait: XPT_UNDEBUG: pid %d: %s\n", pid,
- safe_strerror(errno));
- }
- continue;
- }
- /* FIXME: Do we deal with fork notification correctly? */
- switch (pt.ps_reason) {
- case PTS_FORK:
- /* multi proc: treat like PTS_EXEC */
- /*
- * Pretend this didn't happen, since gdb isn't set up
- * to deal with stops on fork.
- */
- rv = ptrace(PT_CONTSIG, pid, 1, 0);
- if (-1 == rv) {
- printf("PTS_FORK: PT_CONTSIG: error %d\n", errno);
- }
- continue;
- case PTS_EXEC:
- /*
- * Pretend this is a SIGTRAP.
- */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = TARGET_SIGNAL_TRAP;
- break;
- case PTS_EXIT:
- /*
- * Note: we stop before the exit actually occurs. Extract
- * the exit code from the uarea. If we're stopped in the
- * exit() system call, the exit code will be in
- * u.u_ap[0]. An exit due to an uncaught signal will have
- * something else in here, see the comment in the default:
- * case, below. Finally,let the process exit.
- */
- if (death_by_signal)
- {
- status->kind = TARGET_WAITKIND_SIGNALED;
- status->value.sig = target_signal_from_host (death_by_signal);
- death_by_signal = 0;
- break;
- }
- xvaloff = (unsigned long)&u.u_ap[0] - (unsigned long)&u;
- errno = 0;
- rv = ptrace(PT_RUSER, pid, (char *)xvaloff, 0);
- status->kind = TARGET_WAITKIND_EXITED;
- status->value.integer = rv;
- /*
- * addr & data to mptrace() don't matter here, since
- * the process is already dead.
- */
- rv = mptrace(XPT_UNDEBUG, pid, 0, 0);
- if (-1 == rv) {
- printf("child_wait: PTS_EXIT: XPT_UNDEBUG: pid %d error %d\n", pid,
- errno);
- }
- break;
- case PTS_WATCHPT_HIT:
- fatal("PTS_WATCHPT_HIT\n");
- break;
- default:
- /* stopped by signal */
- status->kind = TARGET_WAITKIND_STOPPED;
- status->value.sig = target_signal_from_host (pt.ps_reason);
- death_by_signal = 0;
-
- if (0 == (SIGNALS_DFL_SAFE & sigmask(pt.ps_reason))) {
- break;
- }
- /* else default action of signal is to die */
-#ifdef SVR4_SHARED_LIBS
- rv = ptrace(PT_GET_PRSTATUS, pid, (char *)&pstatus, 0);
- if (-1 == rv)
- error("child_wait: signal %d PT_GET_PRSTATUS: %s\n",
- pt.ps_reason, safe_strerror(errno));
- if (pstatus.pr_cursig != pt.ps_reason) {
- printf("pstatus signal %d, pt signal %d\n",
- pstatus.pr_cursig, pt.ps_reason);
- }
- sa_hand = (int)pstatus.pr_action.sa_handler;
-#else
- saoff = (unsigned long)&u.u_sa[0] - (unsigned long)&u;
- saoff += sizeof(struct sigaction) * (pt.ps_reason - 1);
- errno = 0;
- sa_hand = ptrace(PT_RUSER, pid, (char *)saoff, 0);
- if (errno)
- error("child_wait: signal %d: RUSER: %s\n",
- pt.ps_reason, safe_strerror(errno));
-#endif
- if ((int)SIG_DFL == sa_hand) {
- /* we will be dying */
- death_by_signal = pt.ps_reason;
- }
- break;
- }
-
- } while (pid != inferior_pid); /* Some other child died or stopped */
-
- return pid;
-}
-#else /* !ATTACH_DETACH */
-/*
- * Simple child_wait() based on inftarg.c child_wait() for use until
- * the MPDEBUGGER child_wait() works properly. This will go away when
- * that is fixed.
- */
-child_wait (pid, ourstatus)
- int pid;
- struct target_waitstatus *ourstatus;
-{
- int save_errno;
- int status;
-
- do {
- pid = wait (&status);
- save_errno = errno;
-
- if (pid == -1)
- {
- if (save_errno == EINTR)
- continue;
- fprintf (stderr, "Child process unexpectedly missing: %s.\n",
- safe_strerror (save_errno));
- ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
- ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
- return -1;
- }
- } while (pid != inferior_pid); /* Some other child died or stopped */
- store_waitstatus (ourstatus, status);
- return pid;
-}
-#endif /* ATTACH_DETACH */
-
-
-
-/* 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;
- PTRACE_ARG3_TYPE addr;
- int data;
-{
- return ptrace (request, pid, addr, data);
-}
-
-int
-call_mptrace(request, pid, addr, data)
- int request, pid;
- PTRACE_ARG3_TYPE addr;
- int data;
-{
- return mptrace(request, pid, addr, data);
-}
-
-#if defined (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
-#define mptrace call_mptrace
-#endif
-
-void
-kill_inferior ()
-{
- if (inferior_pid == 0)
- return;
-
- /* For MPDEBUGGER, don't use PT_KILL, since the child will stop
- again with a PTS_EXIT. Just hit him with SIGKILL (so he stops)
- and detach. */
-
- kill (inferior_pid, SIGKILL);
-#ifdef ATTACH_DETACH
- detach(SIGKILL);
-#else /* ATTACH_DETACH */
- ptrace(PT_KILL, inferior_pid, 0, 0);
- wait((int *)NULL);
-#endif /* ATTACH_DETACH */
- 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 (pid, step, signal)
- int pid;
- int step;
- enum target_signal signal;
-{
- errno = 0;
-
- if (pid == -1)
- pid = inferior_pid;
-
- /* An address of (PTRACE_ARG3_TYPE)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 this system does not support PT_SSTEP, a higher level function will
- have called single_step() to transmute the step request into a
- continue request (by setting breakpoints on all possible successor
- instructions), so we don't have to worry about that here. */
-
- if (step)
- ptrace (PT_SSTEP, pid, (PTRACE_ARG3_TYPE) 1, signal);
- else
- ptrace (PT_CONTSIG, pid, (PTRACE_ARG3_TYPE) 1, signal);
-
- if (errno)
- perror_with_name ("ptrace");
-}
-
-#ifdef ATTACH_DETACH
-/* Start debugging the process whose number is PID. */
-int
-attach (pid)
- int pid;
-{
- sigset_t set;
- int rv;
-
- rv = mptrace(XPT_DEBUG, pid, 0, 0);
- if (-1 == rv) {
- error("mptrace(XPT_DEBUG): %s", safe_strerror(errno));
- }
- rv = mptrace(XPT_SIGNAL, pid, 0, SIGSTOP);
- if (-1 == rv) {
- error("mptrace(XPT_SIGNAL): %s", safe_strerror(errno));
- }
- attach_flag = 1;
- return pid;
-}
-
-void
-detach (signo)
- int signo;
-{
- int rv;
-
- rv = mptrace(XPT_UNDEBUG, inferior_pid, 1, signo);
- if (-1 == rv) {
- error("mptrace(XPT_UNDEBUG): %s", safe_strerror(errno));
- }
- attach_flag = 0;
-}
-
-#endif /* ATTACH_DETACH */
-
-/* Default the type of the ptrace transfer to int. */
-#ifndef PTRACE_XFER_TYPE
-#define PTRACE_XFER_TYPE int
-#endif
-
-
-/* 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 (PTRACE_XFER_TYPE);
- /* Round ending address up; get number of longwords that makes. */
- register int count
- = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
- / sizeof (PTRACE_XFER_TYPE);
- /* Allocate buffer of that many longwords. */
- register PTRACE_XFER_TYPE *buffer
- = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE));
-
- if (write)
- {
- /* Fill start and end extra bytes of buffer with existing memory data. */
-
- if (addr != memaddr || len < (int) sizeof (PTRACE_XFER_TYPE)) {
- /* Need part of initial word -- fetch it. */
- buffer[0] = ptrace (PT_RTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr,
- 0);
- }
-
- if (count > 1) /* FIXME, avoid if even boundary */
- {
- buffer[count - 1]
- = ptrace (PT_RTEXT, inferior_pid,
- ((PTRACE_ARG3_TYPE)
- (addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))),
- 0);
- }
-
- /* Copy data to be written over corresponding part of buffer */
-
- memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)),
- myaddr,
- len);
-
- /* Write the entire buffer. */
-
- for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
- {
- errno = 0;
- ptrace (PT_WDATA, inferior_pid, (PTRACE_ARG3_TYPE) addr,
- buffer[i]);
- if (errno)
- {
- /* Using the appropriate one (I or D) is necessary for
- Gould NP1, at least. */
- errno = 0;
- ptrace (PT_WTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr,
- buffer[i]);
- }
- if (errno)
- return 0;
- }
- }
- else
- {
- /* Read all the longwords */
- for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
- {
- errno = 0;
- buffer[i] = ptrace (PT_RTEXT, inferior_pid,
- (PTRACE_ARG3_TYPE) addr, 0);
- if (errno)
- return 0;
- QUIT;
- }
-
- /* Copy appropriate bytes out of the buffer. */
- memcpy (myaddr,
- (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)),
- len);
- }
- return len;
-}
-
-
-void
-_initialize_symm_nat ()
-{
-#ifdef ATTACH_DETACH
-/*
- * the MPDEBUGGER is necessary for process tree debugging and attach
- * to work, but it alters the behavior of debugged processes, so other
- * things (at least child_wait()) will have to change to accomodate
- * that.
- *
- * Note that attach is not implemented in dynix 3, and not in ptx
- * until version 2.1 of the OS.
- */
- int rv;
- sigset_t set;
- struct sigaction sact;
-
- rv = mptrace(XPT_MPDEBUGGER, 0, 0, 0);
- if (-1 == rv) {
- fatal("_initialize_symm_nat(): mptrace(XPT_MPDEBUGGER): %s",
- safe_strerror(errno));
- }
-
- /*
- * Under MPDEBUGGER, we get SIGCLHD when a traced process does
- * anything of interest.
- */
-
- /*
- * Block SIGCHLD. We leave it blocked all the time, and then
- * call sigsuspend() in child_wait() to wait for the child
- * to do something. None of these ought to fail, but check anyway.
- */
- sigemptyset(&set);
- rv = sigaddset(&set, SIGCHLD);
- if (-1 == rv) {
- fatal("_initialize_symm_nat(): sigaddset(SIGCHLD): %s",
- safe_strerror(errno));
- }
- rv = sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
- if (-1 == rv) {
- fatal("_initialize_symm_nat(): sigprocmask(SIG_BLOCK): %s",
- safe_strerror(errno));
- }
-
- sact.sa_handler = sigchld_handler;
- sigemptyset(&sact.sa_mask);
- sact.sa_flags = SA_NOCLDWAIT; /* keep the zombies away */
- rv = sigaction(SIGCHLD, &sact, (struct sigaction *)NULL);
- if (-1 == rv) {
- fatal("_initialize_symm_nat(): sigaction(SIGCHLD): %s",
- safe_strerror(errno));
- }
-#endif
-}
diff --git a/contrib/gdb/gdb/symm-tdep.c b/contrib/gdb/gdb/symm-tdep.c
deleted file mode 100644
index aaf73e9..0000000
--- a/contrib/gdb/gdb/symm-tdep.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Sequent Symmetry target interface, for GDB.
- Copyright (C) 1986, 1987, 1989, 1991, 1994 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* many 387-specific items of use taken from i386-dep.c */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-#include "symtab.h"
-
-#include <signal.h>
-#include <sys/param.h>
-#include <sys/user.h>
-#include <sys/dir.h>
-#include <sys/ioctl.h>
-#include "gdb_stat.h"
-#include "gdbcore.h"
-#include <fcntl.h>
-
-void
-symmetry_extract_return_value(type, regbuf, valbuf)
- struct type *type;
- char *regbuf;
- char *valbuf;
-{
- union {
- double d;
- int l[2];
- } xd;
- struct minimal_symbol *msymbol;
- float f;
-
- if (TYPE_CODE_FLT == TYPE_CODE(type)) {
- msymbol = lookup_minimal_symbol ("1167_flt", NULL, NULL);
- if (msymbol != NULL) {
- /* found "1167_flt" means 1167, %fp2-%fp3 */
- /* float & double; 19= %fp2, 20= %fp3 */
- /* no single precision on 1167 */
- xd.l[1] = *((int *)&regbuf[REGISTER_BYTE(19)]);
- xd.l[0] = *((int *)&regbuf[REGISTER_BYTE(20)]);
- switch (TYPE_LENGTH(type)) {
- case 4:
- /* FIXME: broken for cross-debugging. */
- f = (float) xd.d;
- memcpy (valbuf, &f, TYPE_LENGTH(type));
- break;
- case 8:
- /* FIXME: broken for cross-debugging. */
- memcpy (valbuf, &xd.d, TYPE_LENGTH(type));
- break;
- default:
- error("Unknown floating point size");
- break;
- }
- } else {
- /* 387 %st(0), gcc uses this */
- i387_to_double(((int *)&regbuf[REGISTER_BYTE(3)]),
- &xd.d);
- switch (TYPE_LENGTH(type)) {
- case 4: /* float */
- f = (float) xd.d;
- /* FIXME: broken for cross-debugging. */
- memcpy (valbuf, &f, 4);
- break;
- case 8: /* double */
- /* FIXME: broken for cross-debugging. */
- memcpy (valbuf, &xd.d, 8);
- break;
- default:
- error("Unknown floating point size");
- break;
- }
- }
- } else {
- memcpy (valbuf, regbuf, TYPE_LENGTH (type));
- }
-}
diff --git a/contrib/gdb/gdb/target.c b/contrib/gdb/gdb/target.c
index 808eb8f..fa7c167 100644
--- a/contrib/gdb/gdb/target.c
+++ b/contrib/gdb/gdb/target.c
@@ -1,5 +1,5 @@
/* Select target systems and architectures at runtime for GDB.
- Copyright 1990, 1992-1995, 1998, 1999 Free Software Foundation, Inc.
+ Copyright 1990, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file is part of GDB.
@@ -44,9 +44,6 @@ static void
maybe_kill_then_create_inferior PARAMS ((char *, char *, char **));
static void
-default_clone_and_follow_inferior PARAMS ((int, int *));
-
-static void
maybe_kill_then_attach PARAMS ((char *, int));
static void
@@ -67,11 +64,8 @@ nomemory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
static int
return_zero PARAMS ((void));
-static int
-return_one PARAMS ((void));
-
-void
-target_ignore PARAMS ((void));
+static void
+ignore PARAMS ((void));
static void
target_command PARAMS ((char *, int));
@@ -79,103 +73,6 @@ target_command PARAMS ((char *, int));
static struct target_ops *
find_default_run_target PARAMS ((char *));
-static void
-update_current_target PARAMS ((void));
-
-/* Transfer LEN bytes between target address MEMADDR and GDB address MYADDR.
- Returns 0 for success, errno code for failure (which includes partial
- transfers--if you want a more useful response to partial transfers, try
- target_read_memory_partial). */
-
-static int
-target_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
- int write, asection *bfd_section));
-
-static void init_dummy_target PARAMS ((void));
-
-static void
-debug_to_open PARAMS ((char *, int));
-
-static void
-debug_to_close PARAMS ((int));
-
-static void
-debug_to_attach PARAMS ((char *, int));
-
-static void
-debug_to_detach PARAMS ((char *, int));
-
-static void
-debug_to_resume PARAMS ((int, int, enum target_signal));
-
-static int
-debug_to_wait PARAMS ((int, struct target_waitstatus *));
-
-static void
-debug_to_fetch_registers PARAMS ((int));
-
-static void
-debug_to_store_registers PARAMS ((int));
-
-static void
-debug_to_prepare_to_store PARAMS ((void));
-
-static int
-debug_to_xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
-
-static void
-debug_to_files_info PARAMS ((struct target_ops *));
-
-static int
-debug_to_insert_breakpoint PARAMS ((CORE_ADDR, char *));
-
-static int
-debug_to_remove_breakpoint PARAMS ((CORE_ADDR, char *));
-
-static void
-debug_to_terminal_init PARAMS ((void));
-
-static void
-debug_to_terminal_inferior PARAMS ((void));
-
-static void
-debug_to_terminal_ours_for_output PARAMS ((void));
-
-static void
-debug_to_terminal_ours PARAMS ((void));
-
-static void
-debug_to_terminal_info PARAMS ((char *, int));
-
-static void
-debug_to_kill PARAMS ((void));
-
-static void
-debug_to_load PARAMS ((char *, int));
-
-static int
-debug_to_lookup_symbol PARAMS ((char *, CORE_ADDR *));
-
-static void
-debug_to_create_inferior PARAMS ((char *, char *, char **));
-
-static void
-debug_to_mourn_inferior PARAMS ((void));
-
-static int
-debug_to_can_run PARAMS ((void));
-
-static void
-debug_to_notice_signals PARAMS ((int));
-
-static int
-debug_to_thread_alive PARAMS ((int));
-
-static void
-debug_to_stop PARAMS ((void));
-
-static int debug_to_query PARAMS ((int/*char*/, char *, char *, int *));
-
/* Pointer to array of target architecture structures; the size of the
array; the current index into the array; the allocated size of the
array. */
@@ -188,7 +85,48 @@ unsigned target_struct_allocsize;
/* The initial current target, so that there is always a semi-valid
current target. */
-static struct target_ops dummy_target;
+struct target_ops dummy_target = {
+ "None", /* to_shortname */
+ "None", /* to_longname */
+ "", /* to_doc */
+ 0, /* to_open */
+ 0, /* to_close */
+ find_default_attach, /* to_attach */
+ 0, /* to_detach */
+ 0, /* to_resume */
+ 0, /* to_wait */
+ 0, /* to_fetch_registers */
+ 0, /* to_store_registers */
+ 0, /* to_prepare_to_store */
+ 0, /* to_xfer_memory */
+ 0, /* to_files_info */
+ 0, /* to_insert_breakpoint */
+ 0, /* to_remove_breakpoint */
+ 0, /* to_terminal_init */
+ 0, /* to_terminal_inferior */
+ 0, /* to_terminal_ours_for_output */
+ 0, /* to_terminal_ours */
+ 0, /* to_terminal_info */
+ 0, /* to_kill */
+ 0, /* to_load */
+ 0, /* to_lookup_symbol */
+ find_default_create_inferior, /* to_create_inferior */
+ 0, /* to_mourn_inferior */
+ 0, /* to_can_run */
+ 0, /* to_notice_signals */
+ 0, /* to_thread_alive */
+ 0, /* to_stop */
+ dummy_stratum, /* to_stratum */
+ 0, /* to_next */
+ 0, /* to_next */
+ 0, /* to_has_all_memory */
+ 0, /* to_has_memory */
+ 0, /* to_has_registers */
+ 0, /* to_has_execution */
+ 0, /* to_sections */
+ 0, /* to_sections_end */
+ OPS_MAGIC, /* to_magic */
+};
/* Top of target stack. */
@@ -264,8 +202,8 @@ information on the arguments for a particular protocol, type\n\
/* Stub functions */
-void
-target_ignore ()
+static void
+ignore ()
{
}
@@ -292,7 +230,7 @@ tcomplain ()
void
noprocess ()
{
- error ("You can't do that without a process to debug.");
+ error ("You can't do that without a process to debug");
}
/* ARGSUSED */
@@ -305,17 +243,6 @@ nosymbol (name, addrp)
}
/* ARGSUSED */
-void
-nosupport_runtime ()
-{
- if (!inferior_pid)
- noprocess ();
- else
- error ("No run-time support for this");
-}
-
-
-/* ARGSUSED */
static void
default_terminal_info (args, from_tty)
char *args;
@@ -368,14 +295,6 @@ maybe_kill_then_create_inferior (exec, args, env)
target_create_inferior (exec, args, env);
}
-static void
-default_clone_and_follow_inferior (child_pid, followed_child)
- int child_pid;
- int *followed_child;
-{
- target_clone_and_follow_inferior (child_pid, followed_child);
-}
-
/* 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. */
@@ -389,61 +308,34 @@ cleanup_target (t)
/* FIELD DEFAULT VALUE */
- de_fault (to_open, (void (*) PARAMS((char *, int))) tcomplain);
- de_fault (to_close, (void (*) PARAMS((int))) target_ignore);
+ de_fault (to_open, (void (*)())tcomplain);
+ de_fault (to_close, (void (*)())ignore);
de_fault (to_attach, maybe_kill_then_attach);
- de_fault (to_post_attach, (void (*) PARAMS ((int))) target_ignore);
- de_fault (to_require_attach, maybe_kill_then_attach);
- de_fault (to_detach, (void (*) PARAMS((char *, int))) target_ignore);
- de_fault (to_require_detach, (void (*) PARAMS((int, char *, int))) target_ignore);
- de_fault (to_resume, (void (*) PARAMS((int, int, enum target_signal))) noprocess);
- de_fault (to_wait, (int (*) PARAMS((int, struct target_waitstatus *))) noprocess);
- de_fault (to_post_wait, (void (*) PARAMS ((int, int))) target_ignore);
- de_fault (to_fetch_registers, (void (*) PARAMS((int))) target_ignore);
- de_fault (to_store_registers, (void (*) PARAMS((int))) noprocess);
- de_fault (to_prepare_to_store, (void (*) PARAMS((void))) noprocess);
- de_fault (to_xfer_memory, (int (*) PARAMS((CORE_ADDR, char *, int, int, struct target_ops *))) nomemory);
- de_fault (to_files_info, (void (*) PARAMS((struct target_ops *))) target_ignore);
+ de_fault (to_detach, (void (*)())ignore);
+ de_fault (to_resume, (void (*)())noprocess);
+ de_fault (to_wait, (int (*)())noprocess);
+ de_fault (to_fetch_registers, (void (*)())ignore);
+ de_fault (to_store_registers, (void (*)())noprocess);
+ de_fault (to_prepare_to_store, (void (*)())noprocess);
+ de_fault (to_xfer_memory, (int (*)())nomemory);
+ de_fault (to_files_info, (void (*)())ignore);
de_fault (to_insert_breakpoint, memory_insert_breakpoint);
de_fault (to_remove_breakpoint, memory_remove_breakpoint);
- de_fault (to_terminal_init, (void (*) PARAMS((void))) target_ignore);
- de_fault (to_terminal_inferior, (void (*) PARAMS ((void))) target_ignore);
- de_fault (to_terminal_ours_for_output,(void (*) PARAMS ((void))) target_ignore);
- de_fault (to_terminal_ours, (void (*) PARAMS ((void))) target_ignore);
+ 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 (*) PARAMS((void))) noprocess);
- de_fault (to_load, (void (*) PARAMS((char *, int))) tcomplain);
- de_fault (to_lookup_symbol, (int (*) PARAMS ((char *, CORE_ADDR *))) nosymbol);
+ de_fault (to_kill, (void (*)())noprocess);
+ de_fault (to_load, (void (*)())tcomplain);
+ de_fault (to_lookup_symbol, nosymbol);
de_fault (to_create_inferior, maybe_kill_then_create_inferior);
- de_fault (to_post_startup_inferior, (void (*) PARAMS ((int))) target_ignore);
- de_fault (to_acknowledge_created_inferior, (void (*) PARAMS((int))) target_ignore);
- de_fault (to_clone_and_follow_inferior, default_clone_and_follow_inferior);
- de_fault (to_post_follow_inferior_by_clone, (void (*) PARAMS ((void))) target_ignore);
- de_fault (to_insert_fork_catchpoint, (int (*) PARAMS ((int))) tcomplain);
- de_fault (to_remove_fork_catchpoint, (int (*) PARAMS ((int))) tcomplain);
- de_fault (to_insert_vfork_catchpoint, (int (*) PARAMS ((int))) tcomplain);
- de_fault (to_remove_vfork_catchpoint, (int (*) PARAMS ((int))) tcomplain);
- de_fault (to_has_forked, (int (*) PARAMS ((int, int *))) return_zero);
- de_fault (to_has_vforked, (int (*) PARAMS ((int, int *))) return_zero);
- de_fault (to_can_follow_vfork_prior_to_exec, (int (*) PARAMS ((void ))) return_zero);
- de_fault (to_post_follow_vfork, (void (*) PARAMS ((int, int, int, int))) target_ignore);
- de_fault (to_insert_exec_catchpoint, (int (*) PARAMS ((int))) tcomplain);
- de_fault (to_remove_exec_catchpoint, (int (*) PARAMS ((int))) tcomplain);
- de_fault (to_has_execd, (int (*) PARAMS ((int, char **))) return_zero);
- de_fault (to_reported_exec_events_per_exec_call, (int (*) PARAMS ((void))) return_one);
- de_fault (to_has_syscall_event, (int (*) PARAMS ((int, enum target_waitkind *, int *))) return_zero);
- de_fault (to_has_exited, (int (*) PARAMS ((int, int, int *))) return_zero);
- de_fault (to_mourn_inferior, (void (*) PARAMS ((void))) noprocess);
+ de_fault (to_mourn_inferior, (void (*)())noprocess);
de_fault (to_can_run, return_zero);
- de_fault (to_notice_signals, (void (*) PARAMS((int))) target_ignore);
- de_fault (to_thread_alive, (int (*) PARAMS((int))) target_ignore);
- de_fault (to_stop, (void (*) PARAMS((void))) target_ignore);
- de_fault (to_query, (int (*) PARAMS((int/*char*/, char*, char *, int *))) target_ignore);
- de_fault (to_enable_exception_callback, (struct symtab_and_line * (*) PARAMS((enum exception_event_kind, int))) nosupport_runtime);
- de_fault (to_get_current_exception_event, (struct exception_event_record * (*) PARAMS((void))) nosupport_runtime);
-
- de_fault (to_pid_to_exec_file, (char* (*) PARAMS((int))) return_zero);
- de_fault (to_core_file_to_sym_file, (char* (*) PARAMS ((char *))) return_zero);
+ de_fault (to_notice_signals, (void (*)())ignore);
+ de_fault (to_thread_alive, (int (*)())ignore);
+ de_fault (to_stop, (void (*)())ignore);
+
#undef de_fault
}
@@ -474,13 +366,9 @@ update_current_target ()
INHERIT (to_open, t);
INHERIT (to_close, t);
INHERIT (to_attach, t);
- INHERIT (to_post_attach, t);
- INHERIT (to_require_attach, t);
INHERIT (to_detach, t);
- INHERIT (to_require_detach, t);
INHERIT (to_resume, t);
INHERIT (to_wait, t);
- INHERIT (to_post_wait, t);
INHERIT (to_fetch_registers, t);
INHERIT (to_store_registers, t);
INHERIT (to_prepare_to_store, t);
@@ -497,34 +385,11 @@ update_current_target ()
INHERIT (to_load, t);
INHERIT (to_lookup_symbol, t);
INHERIT (to_create_inferior, t);
- INHERIT (to_post_startup_inferior, t);
- INHERIT (to_acknowledge_created_inferior, t);
- INHERIT (to_clone_and_follow_inferior, t);
- INHERIT (to_post_follow_inferior_by_clone, t);
- INHERIT (to_insert_fork_catchpoint, t);
- INHERIT (to_remove_fork_catchpoint, t);
- INHERIT (to_insert_vfork_catchpoint, t);
- INHERIT (to_remove_vfork_catchpoint, t);
- INHERIT (to_has_forked, t);
- INHERIT (to_has_vforked, t);
- INHERIT (to_can_follow_vfork_prior_to_exec, t);
- INHERIT (to_post_follow_vfork, t);
- INHERIT (to_insert_exec_catchpoint, t);
- INHERIT (to_remove_exec_catchpoint, t);
- INHERIT (to_has_execd, t);
- INHERIT (to_reported_exec_events_per_exec_call, t);
- INHERIT (to_has_syscall_event, t);
- INHERIT (to_has_exited, t);
INHERIT (to_mourn_inferior, t);
INHERIT (to_can_run, t);
INHERIT (to_notice_signals, t);
INHERIT (to_thread_alive, t);
INHERIT (to_stop, t);
- INHERIT (to_query, t);
- INHERIT (to_enable_exception_callback, t);
- INHERIT (to_get_current_exception_event, t);
- INHERIT (to_pid_to_exec_file, t);
- INHERIT (to_core_file_to_sym_file, t);
INHERIT (to_stratum, t);
INHERIT (DONT_USE, t);
INHERIT (to_has_all_memory, t);
@@ -532,7 +397,6 @@ update_current_target ()
INHERIT (to_has_stack, t);
INHERIT (to_has_registers, t);
INHERIT (to_has_execution, t);
- INHERIT (to_has_thread_control, t);
INHERIT (to_sections, t);
INHERIT (to_sections_end, t);
INHERIT (to_magic, t);
@@ -581,8 +445,7 @@ push_target (t)
while (t->to_stratum == cur->target_ops->to_stratum)
{
/* There's already something on this stratum. Close it off. */
- if (cur->target_ops->to_close)
- (cur->target_ops->to_close) (0);
+ (cur->target_ops->to_close) (0);
if (prev)
prev->next = cur->next; /* Unchain old target_ops */
else
@@ -702,18 +565,9 @@ target_read_string (memaddr, string, len, errnop)
tlen = MIN (len, 4 - (memaddr & 3));
offset = memaddr & 3;
- errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0, NULL);
+ errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0);
if (errcode != 0)
- {
- /* The transfer request might have crossed the boundary to an
- unallocated region of memory. Retry the transfer, requesting
- a single byte. */
- tlen = 1;
- offset = 0;
- errcode = target_xfer_memory (memaddr, buf, 1, 0, NULL);
- if (errcode != 0)
- goto done;
- }
+ goto done;
if (bufptr - buffer + tlen > buffer_allocated)
{
@@ -762,17 +616,7 @@ target_read_memory (memaddr, myaddr, len)
char *myaddr;
int len;
{
- return target_xfer_memory (memaddr, myaddr, len, 0, NULL);
-}
-
-int
-target_read_memory_section (memaddr, myaddr, len, bfd_section)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- asection *bfd_section;
-{
- return target_xfer_memory (memaddr, myaddr, len, 0, bfd_section);
+ return target_xfer_memory (memaddr, myaddr, len, 0);
}
/* Read LEN bytes of target memory at address MEMADDR, placing the results
@@ -791,7 +635,7 @@ target_read_memory_partial (memaddr, myaddr, len, errnoptr)
int errcode; /* Error from last read. */
/* First try a complete read. */
- errcode = target_xfer_memory (memaddr, myaddr, len, 0, NULL);
+ errcode = target_xfer_memory (memaddr, myaddr, len, 0);
if (errcode == 0)
{
/* Got it all. */
@@ -802,7 +646,7 @@ target_read_memory_partial (memaddr, myaddr, len, errnoptr)
/* Loop, reading one byte at a time until we get as much as we can. */
for (errcode = 0, nread = 0; len > 0 && errcode == 0; nread++, len--)
{
- errcode = target_xfer_memory (memaddr++, myaddr++, 1, 0, NULL);
+ errcode = target_xfer_memory (memaddr++, myaddr++, 1, 0);
}
/* If an error, the last read was unsuccessful, so adjust count. */
if (errcode != 0)
@@ -823,15 +667,9 @@ target_write_memory (memaddr, myaddr, len)
char *myaddr;
int len;
{
- return target_xfer_memory (memaddr, myaddr, len, 1, NULL);
+ return target_xfer_memory (memaddr, myaddr, len, 1);
}
-/* This variable is used to pass section information down to targets. This
- *should* be done by adding an argument to the target_xfer_memory function
- of all the targets, but I didn't feel like changing 50+ files. */
-
-asection *target_memory_bfd_section = NULL;
-
/* 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
@@ -842,25 +680,18 @@ asection *target_memory_bfd_section = NULL;
Result is 0 or errno value. */
-static int
-target_xfer_memory (memaddr, myaddr, len, write, bfd_section)
+int
+target_xfer_memory (memaddr, myaddr, len, write)
CORE_ADDR memaddr;
char *myaddr;
int len;
int write;
- asection *bfd_section;
{
int curlen;
int res;
struct target_ops *t;
struct target_stack_item *item;
- /* Zero length requests are ok and require no work. */
- if (len == 0)
- return 0;
-
- target_memory_bfd_section = bfd_section;
-
/* to_xfer_memory is not guaranteed to set errno, even when it returns
0. */
errno = 0;
@@ -1044,31 +875,6 @@ find_default_attach (args, from_tty)
}
void
-find_default_require_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- struct target_ops *t;
-
- t = find_default_run_target("require_attach");
- (t->to_require_attach) (args, from_tty);
- return;
-}
-
-void
-find_default_require_detach (pid, args, from_tty)
- int pid;
- char * args;
- int from_tty;
-{
- struct target_ops *t;
-
- t = find_default_run_target("require_detach");
- (t->to_require_detach) (pid, args, from_tty);
- return;
-}
-
-void
find_default_create_inferior (exec_file, allargs, env)
char *exec_file;
char *allargs;
@@ -1081,30 +887,12 @@ find_default_create_inferior (exec_file, allargs, env)
return;
}
-void
-find_default_clone_and_follow_inferior (child_pid, followed_child)
- int child_pid;
- int *followed_child;
-{
- struct target_ops *t;
-
- t = find_default_run_target("run");
- (t->to_clone_and_follow_inferior) (child_pid, followed_child);
- return;
-}
-
static int
return_zero ()
{
return 0;
}
-static int
-return_one ()
-{
- return 1;
-}
-
struct target_ops *
find_core_target ()
{
@@ -1117,7 +905,7 @@ find_core_target ()
for (t = target_structs; t < target_structs + target_struct_size;
++t)
{
- if ((*t)->to_stratum == core_stratum)
+ if ((*t)->to_stratum == (kernel_debugging ? kcore_stratum : core_stratum))
{
runable = *t;
++count;
@@ -1136,7 +924,7 @@ generic_mourn_inferior ()
inferior_pid = 0;
attach_flag = 0;
- breakpoint_init_inferior (inf_exited);
+ breakpoint_init_inferior ();
registers_changed ();
#ifdef CLEAR_DEFERRED_STORES
@@ -1202,7 +990,7 @@ static struct {
{"SIGLWP", "Signal LWP"},
{"SIGDANGER", "Swap space dangerously low"},
{"SIGGRANT", "Monitor mode granted"},
- {"SIGRETRACT", "Need to relinquish monitor mode"},
+ {"SIGRETRACT", "Need to relinguish monitor mode"},
{"SIGMSG", "Monitor mode data available"},
{"SIGSOUND", "Sound completed"},
{"SIGSAK", "Secure attention"},
@@ -1239,15 +1027,6 @@ static struct {
{"SIG62", "Real-time event 62"},
{"SIG63", "Real-time event 63"},
-#if defined(MACH) || defined(__MACH__)
- /* Mach exceptions */
- {"EXC_BAD_ACCESS", "Could not access memory"},
- {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
- {"EXC_ARITHMETIC", "Arithmetic exception"},
- {"EXC_EMULATION", "Emulation instruction"},
- {"EXC_SOFTWARE", "Software generated exception"},
- {"EXC_BREAKPOINT", "Breakpoint"},
-#endif
{NULL, "Unknown signal"},
{NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
@@ -1445,27 +1224,6 @@ target_signal_from_host (hostsig)
#if defined (SIGPRIO)
if (hostsig == SIGPRIO) return TARGET_SIGNAL_PRIO;
#endif
-
- /* Mach exceptions. Assumes that the values for EXC_ are positive! */
-#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
- if (hostsig == _NSIG + EXC_BAD_ACCESS) return TARGET_EXC_BAD_ACCESS;
-#endif
-#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
- if (hostsig == _NSIG + EXC_BAD_INSTRUCTION) return TARGET_EXC_BAD_INSTRUCTION;
-#endif
-#if defined (EXC_ARITHMETIC) && defined (_NSIG)
- if (hostsig == _NSIG + EXC_ARITHMETIC) return TARGET_EXC_ARITHMETIC;
-#endif
-#if defined (EXC_EMULATION) && defined (_NSIG)
- if (hostsig == _NSIG + EXC_EMULATION) return TARGET_EXC_EMULATION;
-#endif
-#if defined (EXC_SOFTWARE) && defined (_NSIG)
- if (hostsig == _NSIG + EXC_SOFTWARE) return TARGET_EXC_SOFTWARE;
-#endif
-#if defined (EXC_BREAKPOINT) && defined (_NSIG)
- if (hostsig == _NSIG + EXC_BREAKPOINT) return TARGET_EXC_BREAKPOINT;
-#endif
-
#if defined (REALTIME_LO)
if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
return (enum target_signal)
@@ -1619,27 +1377,6 @@ target_signal_to_host (oursig)
#if defined (SIGPRIO)
case TARGET_SIGNAL_PRIO: return SIGPRIO;
#endif
-
- /* Mach exceptions. Assumes that the values for EXC_ are positive! */
-#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
- case TARGET_EXC_BAD_ACCESS: return _NSIG + EXC_BAD_ACCESS;
-#endif
-#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
- case TARGET_EXC_BAD_INSTRUCTION: return _NSIG + EXC_BAD_INSTRUCTION;
-#endif
-#if defined (EXC_ARITHMETIC) && defined (_NSIG)
- case TARGET_EXC_ARITHMETIC: return _NSIG + EXC_ARITHMETIC;
-#endif
-#if defined (EXC_EMULATION) && defined (_NSIG)
- case TARGET_EXC_EMULATION: return _NSIG + EXC_EMULATION;
-#endif
-#if defined (EXC_SOFTWARE) && defined (_NSIG)
- case TARGET_EXC_SOFTWARE: return _NSIG + EXC_SOFTWARE;
-#endif
-#if defined (EXC_BREAKPOINT) && defined (_NSIG)
- case TARGET_EXC_BREAKPOINT: return _NSIG + EXC_BREAKPOINT;
-#endif
-
default:
#if defined (REALTIME_LO)
if (oursig >= TARGET_SIGNAL_REALTIME_33
@@ -1723,50 +1460,12 @@ normal_pid_to_str (pid)
static char buf[30];
if (STREQ (current_target.to_shortname, "remote"))
- sprintf (buf, "thread %d\0", pid);
+ sprintf (buf, "thread %d", pid);
else
- sprintf (buf, "process %d\0", pid);
+ sprintf (buf, "process %d", pid);
return buf;
}
-
-/* Some targets (such as ttrace-based HPUX) don't allow us to request
- notification of inferior events such as fork and vork immediately
- after the inferior is created. (This because of how gdb gets an
- inferior created via invoking a shell to do it. In such a scenario,
- if the shell init file has commands in it, the shell will fork and
- exec for each of those commands, and we will see each such fork
- event. Very bad.)
-
- This function is used by all targets that allow us to request
- notification of forks, etc at inferior creation time; e.g., in
- target_acknowledge_forked_child.
- */
-void
-normal_target_post_startup_inferior (pid)
- int pid;
-{
- /* This space intentionally left blank. */
-}
-
-/* Set up the handful of non-empty slots needed by the dummy target
- vector. */
-
-static void
-init_dummy_target ()
-{
- dummy_target.to_shortname = "None";
- dummy_target.to_longname = "None";
- dummy_target.to_doc = "";
- dummy_target.to_attach = find_default_attach;
- dummy_target.to_require_attach = find_default_require_attach;
- dummy_target.to_require_detach = find_default_require_detach;
- dummy_target.to_create_inferior = find_default_create_inferior;
- dummy_target.to_clone_and_follow_inferior = find_default_clone_and_follow_inferior;
- dummy_target.to_stratum = dummy_stratum;
- dummy_target.to_magic = OPS_MAGIC;
-}
-
#ifdef MAINTENANCE_CMDS
static struct target_ops debug_target;
@@ -1778,7 +1477,7 @@ debug_to_open (args, from_tty)
{
debug_target.to_open (args, from_tty);
- fprintf_unfiltered (gdb_stderr, "target_open (%s, %d)\n", args, from_tty);
+ fprintf_unfiltered (stderr, "target_open (%s, %d)\n", args, from_tty);
}
static void
@@ -1787,7 +1486,7 @@ debug_to_close (quitting)
{
debug_target.to_close (quitting);
- fprintf_unfiltered (gdb_stderr, "target_close (%d)\n", quitting);
+ fprintf_unfiltered (stderr, "target_close (%d)\n", quitting);
}
static void
@@ -1797,28 +1496,7 @@ debug_to_attach (args, from_tty)
{
debug_target.to_attach (args, from_tty);
- fprintf_unfiltered (gdb_stderr, "target_attach (%s, %d)\n", args, from_tty);
-}
-
-
-static void
-debug_to_post_attach (pid)
- int pid;
-{
- debug_target.to_post_attach (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_post_attach (%d)\n", pid);
-}
-
-static void
-debug_to_require_attach (args, from_tty)
- char *args;
- int from_tty;
-{
- debug_target.to_require_attach (args, from_tty);
-
- fprintf_unfiltered (gdb_stderr,
- "target_require_attach (%s, %d)\n", args, from_tty);
+ fprintf_unfiltered (stderr, "target_attach (%s, %d)\n", args, from_tty);
}
static void
@@ -1828,19 +1506,7 @@ debug_to_detach (args, from_tty)
{
debug_target.to_detach (args, from_tty);
- fprintf_unfiltered (gdb_stderr, "target_detach (%s, %d)\n", args, from_tty);
-}
-
-static void
-debug_to_require_detach (pid, args, from_tty)
- int pid;
- char * args;
- int from_tty;
-{
- debug_target.to_require_detach (pid, args, from_tty);
-
- fprintf_unfiltered (gdb_stderr,
- "target_require_detach (%d, %s, %d)\n", pid, args, from_tty);
+ fprintf_unfiltered (stderr, "target_detach (%s, %d)\n", args, from_tty);
}
static void
@@ -1851,7 +1517,7 @@ debug_to_resume (pid, step, siggnal)
{
debug_target.to_resume (pid, step, siggnal);
- fprintf_unfiltered (gdb_stderr, "target_resume (%d, %s, %s)\n", pid,
+ fprintf_unfiltered (stderr, "target_resume (%d, %s, %s)\n", pid,
step ? "step" : "continue",
target_signal_to_name (siggnal));
}
@@ -1865,40 +1531,29 @@ debug_to_wait (pid, status)
retval = debug_target.to_wait (pid, status);
- fprintf_unfiltered (gdb_stderr,
- "target_wait (%d, status) = %d, ", pid, retval);
- fprintf_unfiltered (gdb_stderr, "status->kind = ");
+ fprintf_unfiltered (stderr, "target_wait (%d, status) = %d, ", pid, retval);
+ fprintf_unfiltered (stderr, "status->kind = ");
switch (status->kind)
{
case TARGET_WAITKIND_EXITED:
- fprintf_unfiltered (gdb_stderr, "exited, status = %d\n",
- status->value.integer);
+ fprintf_unfiltered (stderr, "exited, status = %d\n", status->value.integer);
break;
case TARGET_WAITKIND_STOPPED:
- fprintf_unfiltered (gdb_stderr, "stopped, signal = %s\n",
+ fprintf_unfiltered (stderr, "stopped, signal = %s\n",
target_signal_to_name (status->value.sig));
break;
case TARGET_WAITKIND_SIGNALLED:
- fprintf_unfiltered (gdb_stderr, "signalled, signal = %s\n",
+ fprintf_unfiltered (stderr, "signalled, signal = %s\n",
target_signal_to_name (status->value.sig));
break;
case TARGET_WAITKIND_LOADED:
- fprintf_unfiltered (gdb_stderr, "loaded\n");
- break;
- case TARGET_WAITKIND_FORKED:
- fprintf_unfiltered (gdb_stderr, "forked\n");
- break;
- case TARGET_WAITKIND_VFORKED:
- fprintf_unfiltered (gdb_stderr, "vforked\n");
- break;
- case TARGET_WAITKIND_EXECD:
- fprintf_unfiltered (gdb_stderr, "execd\n");
+ fprintf_unfiltered (stderr, "loaded\n");
break;
case TARGET_WAITKIND_SPURIOUS:
- fprintf_unfiltered (gdb_stderr, "spurious\n");
+ fprintf_unfiltered (stderr, "spurious\n");
break;
default:
- fprintf_unfiltered (gdb_stderr, "unknown???\n");
+ fprintf_unfiltered (stderr, "unknown???\n");
break;
}
@@ -1906,29 +1561,17 @@ debug_to_wait (pid, status)
}
static void
-debug_to_post_wait (pid, status)
- int pid;
- int status;
-{
- debug_target.to_post_wait (pid, status);
-
- fprintf_unfiltered (gdb_stderr, "target_post_wait (%d, %d)\n",
- pid, status);
-}
-
-static void
debug_to_fetch_registers (regno)
int regno;
{
debug_target.to_fetch_registers (regno);
- fprintf_unfiltered (gdb_stderr, "target_fetch_registers (%s)",
- regno != -1 ? REGISTER_NAME (regno) : "-1");
+ fprintf_unfiltered (stderr, "target_fetch_registers (%s)",
+ regno != -1 ? reg_names[regno] : "-1");
if (regno != -1)
- fprintf_unfiltered (gdb_stderr, " = 0x%x %d",
- (unsigned long) read_register (regno),
+ fprintf_unfiltered (stderr, " = 0x%x %d", read_register (regno),
read_register (regno));
- fprintf_unfiltered (gdb_stderr, "\n");
+ fprintf_unfiltered (stderr, "\n");
}
static void
@@ -1938,12 +1581,11 @@ debug_to_store_registers (regno)
debug_target.to_store_registers (regno);
if (regno >= 0 && regno < NUM_REGS)
- fprintf_unfiltered (gdb_stderr, "target_store_registers (%s) = 0x%x %d\n",
- REGISTER_NAME (regno),
- (unsigned long) read_register (regno),
- (unsigned long) read_register (regno));
+ fprintf_unfiltered (stderr, "target_store_registers (%s) = 0x%x %d\n",
+ reg_names[regno], read_register (regno),
+ read_register (regno));
else
- fprintf_unfiltered (gdb_stderr, "target_store_registers (%d)\n", regno);
+ fprintf_unfiltered (stderr, "target_store_registers (%d)\n", regno);
}
static void
@@ -1951,7 +1593,7 @@ debug_to_prepare_to_store ()
{
debug_target.to_prepare_to_store ();
- fprintf_unfiltered (gdb_stderr, "target_prepare_to_store ()\n");
+ fprintf_unfiltered (stderr, "target_prepare_to_store ()\n");
}
static int
@@ -1966,12 +1608,8 @@ debug_to_xfer_memory (memaddr, myaddr, len, write, target)
retval = debug_target.to_xfer_memory (memaddr, myaddr, len, write, target);
- fprintf_unfiltered (gdb_stderr,
- "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
- (unsigned int) memaddr, /* possable truncate long long */
- len, write ? "write" : "read", retval);
-
-
+ fprintf_unfiltered (stderr, "target_xfer_memory (0x%x, xxx, %d, %s, xxx) = %d",
+ memaddr, len, write ? "write" : "read", retval);
if (retval > 0)
{
@@ -1979,11 +1617,7 @@ debug_to_xfer_memory (memaddr, myaddr, len, write, target)
fputs_unfiltered (", bytes =", gdb_stderr);
for (i = 0; i < retval; i++)
- {
- if ((((long) &(myaddr[i])) & 0xf) == 0)
- fprintf_unfiltered (gdb_stderr, "\n");
- fprintf_unfiltered (gdb_stderr, " %02x", myaddr[i] & 0xff);
- }
+ fprintf_unfiltered (stderr, " %02x", myaddr[i] & 0xff);
}
fputc_unfiltered ('\n', gdb_stderr);
@@ -1997,7 +1631,7 @@ debug_to_files_info (target)
{
debug_target.to_files_info (target);
- fprintf_unfiltered (gdb_stderr, "target_files_info (xxx)\n");
+ fprintf_unfiltered (stderr, "target_files_info (xxx)\n");
}
static int
@@ -2009,9 +1643,8 @@ debug_to_insert_breakpoint (addr, save)
retval = debug_target.to_insert_breakpoint (addr, save);
- fprintf_unfiltered (gdb_stderr,
- "target_insert_breakpoint (0x%x, xxx) = %d\n",
- (unsigned long) addr, retval);
+ fprintf_unfiltered (stderr, "target_insert_breakpoint (0x%x, xxx) = %d\n",
+ addr, retval);
return retval;
}
@@ -2024,9 +1657,8 @@ debug_to_remove_breakpoint (addr, save)
retval = debug_target.to_remove_breakpoint (addr, save);
- fprintf_unfiltered (gdb_stderr,
- "target_remove_breakpoint (0x%x, xxx) = %d\n",
- (unsigned long)addr, retval);
+ fprintf_unfiltered (stderr, "target_remove_breakpoint (0x%x, xxx) = %d\n",
+ addr, retval);
return retval;
}
@@ -2035,7 +1667,7 @@ debug_to_terminal_init ()
{
debug_target.to_terminal_init ();
- fprintf_unfiltered (gdb_stderr, "target_terminal_init ()\n");
+ fprintf_unfiltered (stderr, "target_terminal_init ()\n");
}
static void
@@ -2043,7 +1675,7 @@ debug_to_terminal_inferior ()
{
debug_target.to_terminal_inferior ();
- fprintf_unfiltered (gdb_stderr, "target_terminal_inferior ()\n");
+ fprintf_unfiltered (stderr, "target_terminal_inferior ()\n");
}
static void
@@ -2051,7 +1683,7 @@ debug_to_terminal_ours_for_output ()
{
debug_target.to_terminal_ours_for_output ();
- fprintf_unfiltered (gdb_stderr, "target_terminal_ours_for_output ()\n");
+ fprintf_unfiltered (stderr, "target_terminal_ours_for_output ()\n");
}
static void
@@ -2059,7 +1691,7 @@ debug_to_terminal_ours ()
{
debug_target.to_terminal_ours ();
- fprintf_unfiltered (gdb_stderr, "target_terminal_ours ()\n");
+ fprintf_unfiltered (stderr, "target_terminal_ours ()\n");
}
static void
@@ -2069,7 +1701,7 @@ debug_to_terminal_info (arg, from_tty)
{
debug_target.to_terminal_info (arg, from_tty);
- fprintf_unfiltered (gdb_stderr, "target_terminal_info (%s, %d)\n", arg,
+ fprintf_unfiltered (stderr, "target_terminal_info (%s, %d)\n", arg,
from_tty);
}
@@ -2078,7 +1710,7 @@ debug_to_kill ()
{
debug_target.to_kill ();
- fprintf_unfiltered (gdb_stderr, "target_kill ()\n");
+ fprintf_unfiltered (stderr, "target_kill ()\n");
}
static void
@@ -2088,7 +1720,7 @@ debug_to_load (args, from_tty)
{
debug_target.to_load (args, from_tty);
- fprintf_unfiltered (gdb_stderr, "target_load (%s, %d)\n", args, from_tty);
+ fprintf_unfiltered (stderr, "target_load (%s, %d)\n", args, from_tty);
}
static int
@@ -2100,7 +1732,7 @@ debug_to_lookup_symbol (name, addrp)
retval = debug_target.to_lookup_symbol (name, addrp);
- fprintf_unfiltered (gdb_stderr, "target_lookup_symbol (%s, xxx)\n", name);
+ fprintf_unfiltered (stderr, "target_lookup_symbol (%s, xxx)\n", name);
return retval;
}
@@ -2113,274 +1745,16 @@ debug_to_create_inferior (exec_file, args, env)
{
debug_target.to_create_inferior (exec_file, args, env);
- fprintf_unfiltered (gdb_stderr, "target_create_inferior (%s, %s, xxx)\n",
+ fprintf_unfiltered (stderr, "target_create_inferior (%s, %s, xxx)\n",
exec_file, args);
}
static void
-debug_to_post_startup_inferior (pid)
- int pid;
-{
- debug_target.to_post_startup_inferior (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_post_startup_inferior (%d)\n",
- pid);
-}
-
-static void
-debug_to_acknowledge_created_inferior (pid)
- int pid;
-{
- debug_target.to_acknowledge_created_inferior (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_acknowledge_created_inferior (%d)\n",
- pid);
-}
-
-static void
-debug_to_clone_and_follow_inferior (child_pid, followed_child)
- int child_pid;
- int *followed_child;
-{
- debug_target.to_clone_and_follow_inferior (child_pid, followed_child);
-
- fprintf_unfiltered (gdb_stderr,
- "target_clone_and_follow_inferior (%d, %d)\n",
- child_pid, *followed_child);
-}
-
-static void
-debug_to_post_follow_inferior_by_clone ()
-{
- debug_target.to_post_follow_inferior_by_clone ();
-
- fprintf_unfiltered (gdb_stderr, "target_post_follow_inferior_by_clone ()\n");
-}
-
-static int
-debug_to_insert_fork_catchpoint (pid)
- int pid;
-{
- int retval;
-
- retval = debug_target.to_insert_fork_catchpoint (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_insert_fork_catchpoint (%d) = %d\n",
- pid, retval);
-
- return retval;
-}
-
-static int
-debug_to_remove_fork_catchpoint (pid)
- int pid;
-{
- int retval;
-
- retval = debug_target.to_remove_fork_catchpoint (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_remove_fork_catchpoint (%d) = %d\n",
- pid, retval);
-
- return retval;
-}
-
-static int
-debug_to_insert_vfork_catchpoint (pid)
- int pid;
-{
- int retval;
-
- retval = debug_target.to_insert_vfork_catchpoint (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_insert_vfork_catchpoint (%d)= %d\n",
- pid, retval);
-
- return retval;
-}
-
-static int
-debug_to_remove_vfork_catchpoint (pid)
- int pid;
-{
- int retval;
-
- retval = debug_target.to_remove_vfork_catchpoint (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_remove_vfork_catchpoint (%d) = %d\n",
- pid, retval);
-
- return retval;
-}
-
-static int
-debug_to_has_forked (pid, child_pid)
- int pid;
- int * child_pid;
-{
- int has_forked;
-
- has_forked = debug_target.to_has_forked (pid, child_pid);
-
- fprintf_unfiltered (gdb_stderr, "target_has_forked (%d, %d) = %d\n",
- pid, *child_pid, has_forked);
-
- return has_forked;
-}
-
-static int
-debug_to_has_vforked (pid, child_pid)
- int pid;
- int * child_pid;
-{
- int has_vforked;
-
- has_vforked = debug_target.to_has_vforked (pid, child_pid);
-
- fprintf_unfiltered (gdb_stderr, "target_has_vforked (%d, %d) = %d\n",
- pid, *child_pid, has_vforked);
-
- return has_vforked;
-}
-
-static int
-debug_to_can_follow_vfork_prior_to_exec ()
-{
- int can_immediately_follow_vfork;
-
- can_immediately_follow_vfork = debug_target.to_can_follow_vfork_prior_to_exec ();
-
- fprintf_unfiltered (gdb_stderr, "target_can_follow_vfork_prior_to_exec () = %d\n",
- can_immediately_follow_vfork);
-
- return can_immediately_follow_vfork;
-}
-
-static void
-debug_to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child)
- int parent_pid;
- int followed_parent;
- int child_pid;
- int followed_child;
-{
- debug_target.to_post_follow_vfork (parent_pid, followed_parent, child_pid, followed_child);
-
- fprintf_unfiltered (gdb_stderr,
- "target_post_follow_vfork (%d, %d, %d, %d)\n",
- parent_pid, followed_parent, child_pid, followed_child);
-}
-
-static int
-debug_to_insert_exec_catchpoint (pid)
- int pid;
-{
- int retval;
-
- retval = debug_target.to_insert_exec_catchpoint (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_insert_exec_catchpoint (%d) = %d\n",
- pid, retval);
-
- return retval;
-}
-
-static int
-debug_to_remove_exec_catchpoint (pid)
- int pid;
-{
- int retval;
-
- retval = debug_target.to_remove_exec_catchpoint (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_remove_exec_catchpoint (%d) = %d\n",
- pid, retval);
-
- return retval;
-}
-
-static int
-debug_to_has_execd (pid, execd_pathname)
- int pid;
- char ** execd_pathname;
-{
- int has_execd;
-
- has_execd = debug_target.to_has_execd (pid, execd_pathname);
-
- fprintf_unfiltered (gdb_stderr, "target_has_execd (%d, %s) = %d\n",
- pid, *execd_pathname, has_execd);
-
- return has_execd;
-}
-
-static int
-debug_to_reported_exec_events_per_exec_call ()
-{
- int reported_exec_events;
-
- reported_exec_events = debug_target.to_reported_exec_events_per_exec_call ();
-
- fprintf_unfiltered (gdb_stderr,
- "target_reported_exec_events_per_exec_call () = %d\n",
- reported_exec_events);
-
- return reported_exec_events;
-}
-
-static int
-debug_to_has_syscall_event (pid, kind, syscall_id)
- int pid;
- enum target_waitkind * kind;
- int * syscall_id;
-{
- int has_syscall_event;
- char * kind_spelling = "??";
-
- has_syscall_event = debug_target.to_has_syscall_event (pid, kind, syscall_id);
- if (has_syscall_event)
- {
- switch (*kind)
- {
- case TARGET_WAITKIND_SYSCALL_ENTRY:
- kind_spelling = "SYSCALL_ENTRY";
- break;
- case TARGET_WAITKIND_SYSCALL_RETURN:
- kind_spelling = "SYSCALL_RETURN";
- break;
- default:
- break;
- }
- }
-
- fprintf_unfiltered (gdb_stderr,
- "target_has_syscall_event (%d, %s, %d) = %d\n",
- pid, kind_spelling, *syscall_id, has_syscall_event);
-
- return has_syscall_event;
-}
-
-static int
-debug_to_has_exited (pid, wait_status, exit_status)
- int pid;
- int wait_status;
- int * exit_status;
-{
- int has_exited;
-
- has_exited = debug_target.to_has_exited (pid, wait_status, exit_status);
-
- fprintf_unfiltered (gdb_stderr, "target_has_exited (%d, %d, %d) = %d\n",
- pid, wait_status, *exit_status, has_exited);
-
- return has_exited;
-}
-
-static void
debug_to_mourn_inferior ()
{
debug_target.to_mourn_inferior ();
- fprintf_unfiltered (gdb_stderr, "target_mourn_inferior ()\n");
+ fprintf_unfiltered (stderr, "target_mourn_inferior ()\n");
}
static int
@@ -2390,7 +1764,7 @@ debug_to_can_run ()
retval = debug_target.to_can_run ();
- fprintf_unfiltered (gdb_stderr, "target_can_run () = %d\n", retval);
+ fprintf_unfiltered (stderr, "target_can_run () = %d\n", retval);
return retval;
}
@@ -2401,21 +1775,17 @@ debug_to_notice_signals (pid)
{
debug_target.to_notice_signals (pid);
- fprintf_unfiltered (gdb_stderr, "target_notice_signals (%d)\n", pid);
+ fprintf_unfiltered (stderr, "target_notice_signals (%d)\n", pid);
}
static int
debug_to_thread_alive (pid)
int pid;
{
- int retval;
-
- retval = debug_target.to_thread_alive (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_thread_alive (%d) = %d\n",
- pid, retval);
+ debug_target.to_thread_alive (pid);
- return retval;
+ fprintf_unfiltered (stderr, "target_thread_alive (%d)\n", pid);
+ return (0);
}
static void
@@ -2423,71 +1793,7 @@ debug_to_stop ()
{
debug_target.to_stop ();
- fprintf_unfiltered (gdb_stderr, "target_stop ()\n");
-}
-
-static int
-debug_to_query (type, req, resp, siz)
- int type;
- char *req;
- char *resp;
- int *siz;
-{
- int retval;
-
- retval = debug_target.to_query (type, req, resp, siz);
-
- fprintf_unfiltered (gdb_stderr, "target_query (%c, %s, %s, %d) = %d\n", type, req, resp, *siz, retval);
-
- return retval;
-}
-
-static struct symtab_and_line *
-debug_to_enable_exception_callback (kind, enable)
- enum exception_event_kind kind;
- int enable;
-{
- debug_target.to_enable_exception_callback (kind, enable);
-
- fprintf_unfiltered (gdb_stderr,
- "target get_exception_callback_sal (%d, %d)\n",
- kind, enable);
-}
-
-static struct exception_event_record *
-debug_to_get_current_exception_event ()
-{
- debug_target.to_get_current_exception_event();
-
- fprintf_unfiltered (gdb_stderr, "target get_current_exception_event ()\n");
-}
-
-static char *
-debug_to_pid_to_exec_file (pid)
- int pid;
-{
- char * exec_file;
-
- exec_file = debug_target.to_pid_to_exec_file (pid);
-
- fprintf_unfiltered (gdb_stderr, "target_pid_to_exec_file (%d) = %s\n",
- pid, exec_file);
-
- return exec_file;
-}
-
-static char *
-debug_to_core_file_to_sym_file (core)
- char * core;
-{
- char * sym_file;
-
- sym_file = debug_target.to_core_file_to_sym_file (core);
-
- fprintf_unfiltered (gdb_stderr, "target_core_file_to_sym_file (%s) = %s\n",
- core, sym_file);
-
- return sym_file;
+ fprintf_unfiltered (stderr, "target_stop ()\n");
}
static void
@@ -2498,13 +1804,9 @@ setup_target_debug ()
current_target.to_open = debug_to_open;
current_target.to_close = debug_to_close;
current_target.to_attach = debug_to_attach;
- current_target.to_post_attach = debug_to_post_attach;
- current_target.to_require_attach = debug_to_require_attach;
current_target.to_detach = debug_to_detach;
- current_target.to_require_detach = debug_to_require_detach;
current_target.to_resume = debug_to_resume;
current_target.to_wait = debug_to_wait;
- current_target.to_post_wait = debug_to_post_wait;
current_target.to_fetch_registers = debug_to_fetch_registers;
current_target.to_store_registers = debug_to_store_registers;
current_target.to_prepare_to_store = debug_to_prepare_to_store;
@@ -2521,35 +1823,11 @@ setup_target_debug ()
current_target.to_load = debug_to_load;
current_target.to_lookup_symbol = debug_to_lookup_symbol;
current_target.to_create_inferior = debug_to_create_inferior;
- current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
- current_target.to_acknowledge_created_inferior = debug_to_acknowledge_created_inferior;
- current_target.to_clone_and_follow_inferior = debug_to_clone_and_follow_inferior;
- current_target.to_post_follow_inferior_by_clone = debug_to_post_follow_inferior_by_clone;
- current_target.to_insert_fork_catchpoint = debug_to_insert_fork_catchpoint;
- current_target.to_remove_fork_catchpoint = debug_to_remove_fork_catchpoint;
- current_target.to_insert_vfork_catchpoint = debug_to_insert_vfork_catchpoint;
- current_target.to_remove_vfork_catchpoint = debug_to_remove_vfork_catchpoint;
- current_target.to_has_forked = debug_to_has_forked;
- current_target.to_has_vforked = debug_to_has_vforked;
- current_target.to_can_follow_vfork_prior_to_exec = debug_to_can_follow_vfork_prior_to_exec;
- current_target.to_post_follow_vfork = debug_to_post_follow_vfork;
- current_target.to_insert_exec_catchpoint = debug_to_insert_exec_catchpoint;
- current_target.to_remove_exec_catchpoint = debug_to_remove_exec_catchpoint;
- current_target.to_has_execd = debug_to_has_execd;
- current_target.to_reported_exec_events_per_exec_call = debug_to_reported_exec_events_per_exec_call;
- current_target.to_has_syscall_event = debug_to_has_syscall_event;
- current_target.to_has_exited = debug_to_has_exited;
current_target.to_mourn_inferior = debug_to_mourn_inferior;
current_target.to_can_run = debug_to_can_run;
current_target.to_notice_signals = debug_to_notice_signals;
current_target.to_thread_alive = debug_to_thread_alive;
current_target.to_stop = debug_to_stop;
- current_target.to_query = debug_to_query;
- current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
- current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
- current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
- current_target.to_core_file_to_sym_file = debug_to_core_file_to_sym_file;
-
}
#endif /* MAINTENANCE_CMDS */
@@ -2561,7 +1839,6 @@ core-file, and process, if any), as well as the symbol file name.";
void
initialize_targets ()
{
- init_dummy_target ();
push_target (&dummy_target);
add_info ("target", target_info, targ_desc);
diff --git a/contrib/gdb/gdb/target.h b/contrib/gdb/gdb/target.h
index 21c3bab..209faeb 100644
--- a/contrib/gdb/gdb/target.h
+++ b/contrib/gdb/gdb/target.h
@@ -1,5 +1,5 @@
/* Interface between GDB and target environments, including files and processes
- Copyright 1990, 91, 92, 93, 94, 1999 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by John Gilmore.
This file is part of GDB.
@@ -41,22 +41,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
stratum. */
#include "bfd.h"
-#include "symtab.h"
enum strata {
dummy_stratum, /* The lowest of the low */
file_stratum, /* Executable files, etc */
core_stratum, /* Core dump files */
+ kcore_stratum, /* Kernel core files */
download_stratum, /* Downloading of remote targets */
process_stratum /* Executing processes */
};
-enum thread_control_capabilities {
- tc_none = 0, /* Default: can't control thread execution. */
- tc_schedlock = 1, /* Can lock the thread scheduler. */
- tc_switch = 2 /* Can switch the running thread on demand. */
-};
-
/* Stuff for target_wait. */
/* Generally, what has the program done? */
@@ -75,27 +69,6 @@ enum target_waitkind {
(e.g. it called load(2) on AIX). */
TARGET_WAITKIND_LOADED,
- /* The program has forked. A "related" process' ID is in value.related_pid.
- I.e., if the child forks, value.related_pid is the parent's ID.
- */
- TARGET_WAITKIND_FORKED,
-
- /* The program has vforked. A "related" process's ID is in value.related_pid.
- */
- TARGET_WAITKIND_VFORKED,
-
- /* The program has exec'ed a new executable file. The new file's pathname
- is pointed to by value.execd_pathname.
- */
- TARGET_WAITKIND_EXECD,
-
- /* The program has entered or returned from a system call. On HP-UX, this
- is used in the hardware watchpoint implementation. The syscall's unique
- integer ID number is in value.syscall_id;
- */
- TARGET_WAITKIND_SYSCALL_ENTRY,
- TARGET_WAITKIND_SYSCALL_RETURN,
-
/* Nothing happened, but we stopped anyway. This perhaps should be handled
within target_wait, but I'm not sure target_wait should be resuming the
inferior. */
@@ -205,15 +178,7 @@ enum target_signal {
TARGET_SIGNAL_REALTIME_61 = 73,
TARGET_SIGNAL_REALTIME_62 = 74,
TARGET_SIGNAL_REALTIME_63 = 75,
-#if defined(MACH) || defined(__MACH__)
- /* Mach exceptions */
- TARGET_EXC_BAD_ACCESS = 76,
- TARGET_EXC_BAD_INSTRUCTION = 77,
- TARGET_EXC_ARITHMETIC = 78,
- TARGET_EXC_EMULATION = 79,
- TARGET_EXC_SOFTWARE = 80,
- TARGET_EXC_BREAKPOINT = 81,
-#endif
+
/* Some signal we don't know about. */
TARGET_SIGNAL_UNKNOWN,
@@ -228,13 +193,10 @@ enum target_signal {
struct target_waitstatus {
enum target_waitkind kind;
- /* Forked child pid, execd pathname, exit status or signal number. */
+ /* Exit status or signal number. */
union {
int integer;
enum target_signal sig;
- int related_pid;
- char * execd_pathname;
- int syscall_id;
} value;
};
@@ -246,7 +208,6 @@ extern char *target_signal_to_name PARAMS ((enum target_signal));
/* Given a name (SIGHUP, etc.), return its signal. */
enum target_signal target_signal_from_name PARAMS ((char *));
-
/* If certain kinds of activity happen, target_wait should perform
callbacks. */
@@ -266,13 +227,9 @@ struct target_ops
void (*to_open) PARAMS ((char *, int));
void (*to_close) PARAMS ((int));
void (*to_attach) PARAMS ((char *, int));
- void (*to_post_attach) PARAMS ((int));
- void (*to_require_attach) PARAMS ((char *, int));
void (*to_detach) PARAMS ((char *, int));
- void (*to_require_detach) PARAMS ((int, char *, int));
void (*to_resume) PARAMS ((int, int, enum target_signal));
int (*to_wait) PARAMS ((int, struct target_waitstatus *));
- void (*to_post_wait) PARAMS ((int, int));
void (*to_fetch_registers) PARAMS ((int));
void (*to_store_registers) PARAMS ((int));
void (*to_prepare_to_store) PARAMS ((void));
@@ -332,34 +289,11 @@ struct target_ops
void (*to_load) PARAMS ((char *, int));
int (*to_lookup_symbol) PARAMS ((char *, CORE_ADDR *));
void (*to_create_inferior) PARAMS ((char *, char *, char **));
- void (*to_post_startup_inferior) PARAMS ((int));
- void (*to_acknowledge_created_inferior) PARAMS ((int));
- void (*to_clone_and_follow_inferior) PARAMS ((int, int *));
- void (*to_post_follow_inferior_by_clone) PARAMS ((void));
- int (*to_insert_fork_catchpoint) PARAMS ((int));
- int (*to_remove_fork_catchpoint) PARAMS ((int));
- int (*to_insert_vfork_catchpoint) PARAMS ((int));
- int (*to_remove_vfork_catchpoint) PARAMS ((int));
- int (*to_has_forked) PARAMS ((int, int *));
- int (*to_has_vforked) PARAMS ((int, int *));
- int (*to_can_follow_vfork_prior_to_exec) PARAMS ((void));
- void (*to_post_follow_vfork) PARAMS ((int, int, int, int));
- int (*to_insert_exec_catchpoint) PARAMS ((int));
- int (*to_remove_exec_catchpoint) PARAMS ((int));
- int (*to_has_execd) PARAMS ((int, char **));
- int (*to_reported_exec_events_per_exec_call) PARAMS ((void));
- int (*to_has_syscall_event) PARAMS ((int, enum target_waitkind *, int *));
- int (*to_has_exited) PARAMS ((int, int, int *));
void (*to_mourn_inferior) PARAMS ((void));
int (*to_can_run) PARAMS ((void));
void (*to_notice_signals) PARAMS ((int pid));
int (*to_thread_alive) PARAMS ((int pid));
void (*to_stop) PARAMS ((void));
- int (*to_query) PARAMS ((int/*char*/, char *, char *, int *));
- struct symtab_and_line * (*to_enable_exception_callback) PARAMS ((enum exception_event_kind, int));
- struct exception_event_record * (*to_get_current_exception_event) PARAMS ((void));
- char * (*to_pid_to_exec_file) PARAMS ((int pid));
- char * (*to_core_file_to_sym_file) PARAMS ((char *));
enum strata to_stratum;
struct target_ops
*DONT_USE; /* formerly to_next */
@@ -368,7 +302,6 @@ struct target_ops
int to_has_stack;
int to_has_registers;
int to_has_execution;
- int to_has_thread_control; /* control thread execution */
struct section_table
*to_sections;
struct section_table
@@ -433,26 +366,6 @@ extern struct target_stack_item *target_stack;
#define target_attach(args, from_tty) \
(*current_target.to_attach) (args, from_tty)
-/* The target_attach operation places a process under debugger control,
- and stops the process.
-
- This operation provides a target-specific hook that allows the
- necessary bookkeeping to be performed after an attach completes.
- */
-#define target_post_attach(pid) \
- (*current_target.to_post_attach) (pid)
-
-/* Attaches to a process on the target side, if not already attached.
- (If already attached, takes no action.)
-
- This operation can be used to follow the child process of a fork.
- On some targets, such child processes of an original inferior process
- are automatically under debugger control, and thus do not require an
- actual attach operation. */
-
-#define target_require_attach(args, from_tty) \
- (*current_target.to_require_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
@@ -463,21 +376,6 @@ extern struct target_stack_item *target_stack;
extern void
target_detach PARAMS ((char *, int));
-/* Detaches from a process on the target side, if not already dettached.
- (If already detached, takes no action.)
-
- This operation can be used to follow the parent process of a fork.
- On some targets, such child processes of an original inferior process
- are automatically under debugger control, and thus do require an actual
- detach operation.
-
- PID is the process id of the child to detach from.
- 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_require_detach(pid, args, from_tty) \
- (*current_target.to_require_detach) (pid, args, from_tty)
-
/* Resume execution of the target process PID. STEP says whether to
single-step or to run free; SIGGNAL is the signal to be given to
the target, or TARGET_SIGNAL_0 for no signal. The caller may not
@@ -497,20 +395,6 @@ target_detach PARAMS ((char *, int));
#define target_wait(pid, status) \
(*current_target.to_wait) (pid, status)
-/* The target_wait operation waits for a process event to occur, and
- thereby stop the process.
-
- On some targets, certain events may happen in sequences. gdb's
- correct response to any single event of such a sequence may require
- knowledge of what earlier events in the sequence have been seen.
-
- This operation provides a target-specific hook that allows the
- necessary bookkeeping to be performed to track such sequences.
- */
-
-#define target_post_wait(pid, status) \
- (*current_target.to_post_wait) (pid, status)
-
/* Fetch register REGNO, or all regs if regno == -1. No result. */
#define target_fetch_registers(regno) \
@@ -535,11 +419,7 @@ target_detach PARAMS ((char *, int));
extern int target_read_string PARAMS ((CORE_ADDR, char **, int, int *));
extern int
-target_read_memory PARAMS ((CORE_ADDR memaddr, char *myaddr, int len));
-
-extern int
-target_read_memory_section PARAMS ((CORE_ADDR memaddr, char *myaddr, int len,
- asection *bfd_section));
+target_read_memory PARAMS ((CORE_ADDR, char *, int));
extern int
target_read_memory_partial PARAMS ((CORE_ADDR, char *, int, int *));
@@ -553,79 +433,13 @@ xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
extern int
child_xfer_memory PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
-extern char *
-child_pid_to_exec_file PARAMS ((int));
-
-extern char *
-child_core_file_to_sym_file PARAMS ((char *));
-
-#if defined(CHILD_POST_ATTACH)
-extern void
-child_post_attach PARAMS ((int));
-#endif
-
-extern void
-child_post_wait PARAMS ((int, int));
-
-extern void
-child_post_startup_inferior PARAMS ((int));
-
-extern void
-child_acknowledge_created_inferior PARAMS ((int));
-
-extern void
-child_clone_and_follow_inferior PARAMS ((int, int *));
-
-extern void
-child_post_follow_inferior_by_clone PARAMS ((void));
-
-extern int
-child_insert_fork_catchpoint PARAMS ((int));
-
-extern int
-child_remove_fork_catchpoint PARAMS ((int));
-
-extern int
-child_insert_vfork_catchpoint PARAMS ((int));
-
-extern int
-child_remove_vfork_catchpoint PARAMS ((int));
-
-extern int
-child_has_forked PARAMS ((int, int *));
-
-extern int
-child_has_vforked PARAMS ((int, int *));
-
-extern void
-child_acknowledge_created_inferior PARAMS ((int));
-
-extern int
-child_can_follow_vfork_prior_to_exec PARAMS ((void));
-
-extern void
-child_post_follow_vfork PARAMS ((int, int, int, int));
-
-extern int
-child_insert_exec_catchpoint PARAMS ((int));
-
-extern int
-child_remove_exec_catchpoint PARAMS ((int));
-
-extern int
-child_has_execd PARAMS ((int, char **));
-
-extern int
-child_reported_exec_events_per_exec_call PARAMS ((void));
-
-extern int
-child_has_syscall_event PARAMS ((int, enum target_waitkind *, int *));
-
-extern int
-child_has_exited PARAMS ((int, int, int *));
+/* Transfer LEN bytes between target address MEMADDR and GDB address MYADDR.
+ Returns 0 for success, errno code for failure (which includes partial
+ transfers--if you want a more useful response to partial transfers, try
+ target_read_memory_partial). */
-extern int
-child_thread_alive PARAMS ((int));
+extern int target_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr,
+ int len, int write));
/* From exec.c */
@@ -722,149 +536,6 @@ print_section_info PARAMS ((struct target_ops *, bfd *));
#define target_create_inferior(exec_file, args, env) \
(*current_target.to_create_inferior) (exec_file, args, env)
-
-/* Some targets (such as ttrace-based HPUX) don't allow us to request
- notification of inferior events such as fork and vork immediately
- after the inferior is created. (This because of how gdb gets an
- inferior created via invoking a shell to do it. In such a scenario,
- if the shell init file has commands in it, the shell will fork and
- exec for each of those commands, and we will see each such fork
- event. Very bad.)
-
- Such targets will supply an appropriate definition for this function.
- */
-#define target_post_startup_inferior(pid) \
- (*current_target.to_post_startup_inferior) (pid)
-
-/* On some targets, the sequence of starting up an inferior requires
- some synchronization between gdb and the new inferior process, PID.
- */
-#define target_acknowledge_created_inferior(pid) \
- (*current_target.to_acknowledge_created_inferior) (pid)
-
-/* An inferior process has been created via a fork() or similar
- system call. This function will clone the debugger, then ensure
- that CHILD_PID is attached to by that debugger.
-
- FOLLOWED_CHILD is set TRUE on return *for the clone debugger only*,
- and FALSE otherwise. (The original and clone debuggers can use this
- to determine which they are, if need be.)
-
- (This is not a terribly useful feature without a GUI to prevent
- the two debuggers from competing for shell input.)
- */
-#define target_clone_and_follow_inferior(child_pid,followed_child) \
- (*current_target.to_clone_and_follow_inferior) (child_pid, followed_child)
-
-/* This operation is intended to be used as the last in a sequence of
- steps taken when following both parent and child of a fork. This
- is used by a clone of the debugger, which will follow the child.
-
- The original debugger has detached from this process, and the
- clone has attached to it.
-
- On some targets, this requires a bit of cleanup to make it work
- correctly.
- */
-#define target_post_follow_inferior_by_clone() \
- (*current_target.to_post_follow_inferior_by_clone) ()
-
-/* On some targets, we can catch an inferior fork or vfork event when it
- occurs. These functions insert/remove an already-created catchpoint for
- such events.
- */
-#define target_insert_fork_catchpoint(pid) \
- (*current_target.to_insert_fork_catchpoint) (pid)
-
-#define target_remove_fork_catchpoint(pid) \
- (*current_target.to_remove_fork_catchpoint) (pid)
-
-#define target_insert_vfork_catchpoint(pid) \
- (*current_target.to_insert_vfork_catchpoint) (pid)
-
-#define target_remove_vfork_catchpoint(pid) \
- (*current_target.to_remove_vfork_catchpoint) (pid)
-
-/* Returns TRUE if PID has invoked the fork() system call. And,
- also sets CHILD_PID to the process id of the other ("child")
- inferior process that was created by that call.
- */
-#define target_has_forked(pid,child_pid) \
- (*current_target.to_has_forked) (pid,child_pid)
-
-/* Returns TRUE if PID has invoked the vfork() system call. And,
- also sets CHILD_PID to the process id of the other ("child")
- inferior process that was created by that call.
- */
-#define target_has_vforked(pid,child_pid) \
- (*current_target.to_has_vforked) (pid,child_pid)
-
-/* Some platforms (such as pre-10.20 HP-UX) don't allow us to do
- anything to a vforked child before it subsequently calls exec().
- On such platforms, we say that the debugger cannot "follow" the
- child until it has vforked.
-
- This function should be defined to return 1 by those targets
- which can allow the debugger to immediately follow a vforked
- child, and 0 if they cannot.
- */
-#define target_can_follow_vfork_prior_to_exec() \
- (*current_target.to_can_follow_vfork_prior_to_exec) ()
-
-/* An inferior process has been created via a vfork() system call.
- The debugger has followed the parent, the child, or both. The
- process of setting up for that follow may have required some
- target-specific trickery to track the sequence of reported events.
- If so, this function should be defined by those targets that
- require the debugger to perform cleanup or initialization after
- the vfork follow.
- */
-#define target_post_follow_vfork(parent_pid,followed_parent,child_pid,followed_child) \
- (*current_target.to_post_follow_vfork) (parent_pid,followed_parent,child_pid,followed_child)
-
-/* On some targets, we can catch an inferior exec event when it
- occurs. These functions insert/remove an already-created catchpoint
- for such events.
- */
-#define target_insert_exec_catchpoint(pid) \
- (*current_target.to_insert_exec_catchpoint) (pid)
-
-#define target_remove_exec_catchpoint(pid) \
- (*current_target.to_remove_exec_catchpoint) (pid)
-
-/* Returns TRUE if PID has invoked a flavor of the exec() system call.
- And, also sets EXECD_PATHNAME to the pathname of the executable file
- that was passed to exec(), and is now being executed.
- */
-#define target_has_execd(pid,execd_pathname) \
- (*current_target.to_has_execd) (pid,execd_pathname)
-
-/* Returns the number of exec events that are reported when a process
- invokes a flavor of the exec() system call on this target, if exec
- events are being reported.
- */
-#define target_reported_exec_events_per_exec_call() \
- (*current_target.to_reported_exec_events_per_exec_call) ()
-
-/* Returns TRUE if PID has reported a syscall event. And, also sets
- KIND to the appropriate TARGET_WAITKIND_, and sets SYSCALL_ID to
- the unique integer ID of the syscall.
- */
-#define target_has_syscall_event(pid,kind,syscall_id) \
- (*current_target.to_has_syscall_event) (pid,kind,syscall_id)
-
-/* Returns TRUE if PID has exited. And, also sets EXIT_STATUS to the
- exit code of PID, if any.
- */
-#define target_has_exited(pid,wait_status,exit_status) \
- (*current_target.to_has_exited) (pid,wait_status,exit_status)
-
-/* The debugger has completed a blocking wait() call. There is now
- some process event that must be processed. This function should
- be defined by those targets that require the debugger to perform
- cleanup or internal state changes in response to the process event.
- */
-
/* The inferior process has died. Do what is right. */
#define target_mourn_inferior() \
@@ -889,32 +560,7 @@ print_section_info PARAMS ((struct target_ops *, bfd *));
should act like SIGSTOP). This function is normally used by GUIs to
implement a stop button. */
-#define target_stop current_target.to_stop
-
-/* Queries the target side for some information. The first argument is a
- letter specifying the type of the query, which is used to determine who
- should process it. The second argument is a string that specifies which
- information is desired and the third is a buffer that carries back the
- response from the target side. The fourth parameter is the size of the
- output buffer supplied. */
-
-#define target_query(query_type, query, resp_buffer, bufffer_size) \
- (*current_target.to_query) (query_type, query, resp_buffer, bufffer_size)
-
-/* Get the symbol information for a breakpointable routine called when
- an exception event occurs.
- Intended mainly for C++, and for those
- platforms/implementations where such a callback mechanism is available,
- e.g. HP-UX with ANSI C++ (aCC). Some compilers (e.g. g++) support
- different mechanisms for debugging exceptions. */
-
-#define target_enable_exception_callback(kind, enable) \
- (*current_target.to_enable_exception_callback) (kind, enable)
-
-/* Get the current exception event kind -- throw or catch, etc. */
-
-#define target_get_current_exception_event() \
- (*current_target.to_get_current_exception_event) ()
+#define target_stop() current_target.to_stop ()
/* Pointer to next target in the chain, e.g. a core file and an exec file. */
@@ -954,16 +600,6 @@ print_section_info PARAMS ((struct target_ops *, bfd *));
#define target_has_execution \
(current_target.to_has_execution)
-/* Can the target support the debugger control of thread execution?
- a) Can it lock the thread scheduler?
- b) Can it switch the currently running thread? */
-
-#define target_can_lock_scheduler \
- (current_target.to_has_thread_control & tc_schedlock)
-
-#define target_can_switch_threads \
- (current_target.to_has_thread_control & tc_switch)
-
extern void target_link PARAMS ((char *, CORE_ADDR *));
/* Converts a process id to a string. Usually, the string just contains
@@ -976,38 +612,6 @@ extern void target_link PARAMS ((char *, CORE_ADDR *));
extern char *normal_pid_to_str PARAMS ((int pid));
#endif
-#ifndef target_tid_to_str
-#define target_tid_to_str(PID) \
- normal_pid_to_str (PID)
-extern char *normal_pid_to_str PARAMS ((int pid));
-#endif
-
-
-#ifndef target_new_objfile
-#define target_new_objfile(OBJFILE)
-#endif
-
-#ifndef target_pid_or_tid_to_str
-#define target_pid_or_tid_to_str(ID) \
- normal_pid_to_str (ID)
-#endif
-
-/* Attempts to find the pathname of the executable file
- that was run to create a specified process.
-
- The process PID must be stopped when this operation is used.
-
- If the executable file cannot be determined, NULL is returned.
-
- Else, a pointer to a character string containing the pathname
- is returned. This string should be copied into a buffer by
- the client if the string will not be immediately used, or if
- it must persist.
- */
-
-#define target_pid_to_exec_file(pid) \
- (current_target.to_pid_to_exec_file) (pid)
-
/* Hook to call target-dependant code after reading in a new symbol table. */
#ifndef TARGET_SYMFILE_POSTREAD
@@ -1030,18 +634,6 @@ extern char *normal_pid_to_str PARAMS ((int pid));
#define STOPPED_BY_WATCHPOINT(w) 0
#endif
-/* HP-UX supplies these operations, which respectively disable and enable
- the memory page-protections that are used to implement hardware watchpoints
- on that platform. See wait_for_inferior's use of these.
- */
-#if !defined(TARGET_DISABLE_HW_WATCHPOINTS)
-#define TARGET_DISABLE_HW_WATCHPOINTS(pid)
-#endif
-
-#if !defined(TARGET_ENABLE_HW_WATCHPOINTS)
-#define TARGET_ENABLE_HW_WATCHPOINTS(pid)
-#endif
-
/* Provide defaults for systems that don't support hardware watchpoints. */
#ifndef TARGET_HAS_HARDWARE_WATCHPOINTS
@@ -1053,26 +645,9 @@ extern char *normal_pid_to_str PARAMS ((int pid));
#define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) 0
-#if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
-#define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(byte_count) \
- (LONGEST)(byte_count) <= REGISTER_SIZE
-#endif
-
-/* However, some addresses may not be profitable to use hardware to watch,
- or may be difficult to understand when the addressed object is out of
- scope, and hence should be unwatched. On some targets, this may have
- severe performance penalties, such that we might as well use regular
- watchpoints, and save (possibly precious) hardware watchpoints for other
- locations.
- */
-#if !defined(TARGET_RANGE_PROFITABLE_FOR_HW_WATCHPOINT)
-#define TARGET_RANGE_PROFITABLE_FOR_HW_WATCHPOINT(pid,start,len) 0
-#endif
-
-
-/* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes. TYPE is 0
- for write, 1 for read, and 2 for read/write accesses. Returns 0 for
- success, non-zero for failure. */
+/* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes. TYPE is 1
+ for read and 2 for read/write accesses. Returns 0 for success, non-zero for
+ failure. */
#define target_remove_watchpoint(ADDR,LEN,TYPE) -1
#define target_insert_watchpoint(ADDR,LEN,TYPE) -1
@@ -1095,38 +670,6 @@ extern char *normal_pid_to_str PARAMS ((int pid));
#define DECR_PC_AFTER_HW_BREAK 0
#endif
-/* Sometimes gdb may pick up what appears to be a valid target address
- from a minimal symbol, but the value really means, essentially,
- "This is an index into a table which is populated when the inferior
- is run. Therefore, do not attempt to use this as a PC."
- */
-#if !defined(PC_REQUIRES_RUN_BEFORE_USE)
-#define PC_REQUIRES_RUN_BEFORE_USE(pc) (0)
-#endif
-
-/* This will only be defined by a target that supports catching vfork events,
- such as HP-UX.
-
- On some targets (such as HP-UX 10.20 and earlier), resuming a newly vforked
- child process after it has exec'd, causes the parent process to resume as
- well. To prevent the parent from running spontaneously, such targets should
- define this to a function that prevents that from happening.
- */
-#if !defined(ENSURE_VFORKING_PARENT_REMAINS_STOPPED)
-#define ENSURE_VFORKING_PARENT_REMAINS_STOPPED(PID) (0)
-#endif
-
-/* This will only be defined by a target that supports catching vfork events,
- such as HP-UX.
-
- On some targets (such as HP-UX 10.20 and earlier), a newly vforked child
- process must be resumed when it delivers its exec event, before the parent
- vfork event will be delivered to us.
- */
-#if !defined(RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK)
-#define RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK() (0)
-#endif
-
/* Routines for maintenance of the target structures...
add_target: Add a target to the list of all possible targets.
@@ -1179,40 +722,24 @@ build_section_table PARAMS ((bfd *, struct section_table **,
/* From mem-break.c */
-extern int memory_remove_breakpoint PARAMS ((CORE_ADDR, char *));
-
-extern int memory_insert_breakpoint PARAMS ((CORE_ADDR, char *));
-
-extern breakpoint_from_pc_fn memory_breakpoint_from_pc;
-#ifndef BREAKPOINT_FROM_PC
-#define BREAKPOINT_FROM_PC(pcptr, lenptr) memory_breakpoint_from_pc (pcptr, lenptr)
-#endif
+extern int
+memory_remove_breakpoint PARAMS ((CORE_ADDR, char *));
+extern int
+memory_insert_breakpoint PARAMS ((CORE_ADDR, char *));
/* From target.c */
-extern void
-initialize_targets PARAMS ((void));
-
-extern void
+void
noprocess PARAMS ((void));
-extern void
-find_default_attach PARAMS ((char *, int));
-
void
-find_default_require_attach PARAMS ((char *, int));
+find_default_attach PARAMS ((char *, int));
void
-find_default_require_detach PARAMS ((int, char *, int));
-
-extern void
find_default_create_inferior PARAMS ((char *, char *, char **));
-void
-find_default_clone_and_follow_inferior PARAMS ((int, int *));
-
-extern struct target_ops *
+struct target_ops *
find_core_target PARAMS ((void));
/* Stuff that should be shared among the various remote targets. */
@@ -1223,10 +750,6 @@ extern int remote_debug;
/* Speed in bits per second, or -1 which means don't mess with the speed. */
extern int baud_rate;
-/* Timeout limit for response from target. */
-extern int remote_timeout;
-
-extern asection *target_memory_bfd_section;
/* Functions for helping to write a native target. */
@@ -1240,25 +763,4 @@ extern int target_signal_to_host PARAMS ((enum target_signal));
/* Convert from a number used in a GDB command to an enum target_signal. */
extern enum target_signal target_signal_from_command PARAMS ((int));
-/* Any target can call this to switch to remote protocol (in remote.c). */
-extern void push_remote_target PARAMS ((char *name, int from_tty));
-
-/* Imported from machine dependent code */
-
-#ifndef SOFTWARE_SINGLE_STEP_P
-#define SOFTWARE_SINGLE_STEP_P 0
-#define SOFTWARE_SINGLE_STEP(sig,bp_p) abort ()
-#endif /* SOFTWARE_SINGLE_STEP_P */
-
-/* Blank target vector entries are initialized to target_ignore. */
-void target_ignore PARAMS ((void));
-
-/* Macro for getting target's idea of a frame pointer.
- FIXME: GDB's whole scheme for dealing with "frames" and
- "frame pointers" needs a serious shakedown. */
-#ifndef TARGET_VIRTUAL_FRAME_POINTER
-#define TARGET_VIRTUAL_FRAME_POINTER(ADDR, REGP, OFFP) \
- do { *(REGP) = FP_REGNUM; *(OFFP) = 0; } while (0)
-#endif /* TARGET_VIRTUAL_FRAME_POINTER */
-
#endif /* !defined (TARGET_H) */
diff --git a/contrib/gdb/gdb/umax-xdep.c b/contrib/gdb/gdb/umax-xdep.c
deleted file mode 100644
index d54519e..0000000
--- a/contrib/gdb/gdb/umax-xdep.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* umax host stuff.
- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "frame.h"
-#include "inferior.h"
-
-#include <sys/param.h>
-#include <sys/dir.h>
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include "gdbcore.h"
-#include <sys/ptrace.h>
-#define PTRACE_ATTACH PT_ATTACH
-#define PTRACE_DETACH PT_FREEPROC
-
-#include <sys/file.h>
-#include "gdb_stat.h"
-
-/* Work with core dump and executable files, for GDB.
- This code would be in corefile.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 program 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;
-
- memcpy (&core_aouthdr, &u.pt_aouthdr, sizeof (AOUTHDR));
- printf_unfiltered ("Core file is from \"%s\".\n", u.pt_comm);
- if (u.pt_signal > 0)
- printf_unfiltered ("Program terminated with signal %d, %s.\n",
- u.pt_signal, safe_strsignal (u.pt_signal));
-
- /* 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);
- }
-
- flush_cached_frames ();
- select_frame (get_current_frame (), 0);
- validate_files ();
- }
- else if (from_tty)
- printf_unfiltered ("No core file now.\n");
-}
diff --git a/contrib/gdb/gdb/xcoffread.c b/contrib/gdb/gdb/xcoffread.c
deleted file mode 100644
index 0cf9371..0000000
--- a/contrib/gdb/gdb/xcoffread.c
+++ /dev/null
@@ -1,2811 +0,0 @@
-/* Read AIX xcoff symbol tables and convert to internal format, for GDB.
- Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997
- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "bfd.h"
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include "gdb_string.h"
-
-#include <sys/param.h>
-#ifndef NO_SYS_FILE
-#include <sys/file.h>
-#endif
-#include "gdb_stat.h"
-
-#include "coff/internal.h"
-#include "libcoff.h" /* FIXME, internal data from BFD */
-#include "coff/rs6000.h"
-
-#include "symtab.h"
-#include "gdbtypes.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "buildsym.h"
-#include "stabsread.h"
-#include "expression.h"
-#include "language.h" /* Needed inside partial-stab.h */
-#include "complaints.h"
-
-#include "gdb-stabs.h"
-
-/* For interface with stabsread.c. */
-#include "aout/stab_gnu.h"
-
-/* For interface with partial-stab.h. */
-#define N_UNDF 0 /* Undefined symbol */
-#undef N_ABS
-#define N_ABS 2
-#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_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. */
-
-/* We put a pointer to this structure in the read_symtab_private field
- of the psymtab. */
-
-struct symloc {
-
- /* First symbol number for this file. */
-
- int first_symnum;
-
- /* Number of symbols in 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 numsyms is 0, the only
- reason for this thing's existence is the dependency list. Nothing
- else will happen when it is read in. */
-
- int numsyms;
-
- /* Position of the start of the line number information for this psymtab. */
- unsigned int lineno_off;
-};
-
-/* Remember what we deduced to be the source language of this psymtab. */
-
-static enum language psymtab_language = language_unknown;
-
-
-/* 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 */
- long c_value;
- unsigned char c_sclass;
- int c_secnum;
- unsigned int c_type;
-};
-
-/* 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_end_addr;
-
-/* Core address of the end of the first object file. */
-
-static CORE_ADDR first_object_file_end;
-
-/* initial symbol-table-debug-string vector length */
-
-#define INITIAL_STABVECTOR_LENGTH 40
-
-/* Nonzero if within a function (so symbols should be local,
- if nothing says specifically). */
-
-int within_function;
-
-/* Size of a COFF symbol. I think it is always 18, so I'm not sure
- there is any reason not to just use a #define, but might as well
- ask BFD for the size and store it here, I guess. */
-
-static unsigned local_symesz;
-
-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 */
-
- /* Pointer to the string table. */
- char *strtbl;
-
- /* Pointer to debug section. */
- char *debugsec;
-
- /* Pointer to the a.out symbol table. */
- char *symtbl;
-
- /* Number of symbols in symtbl. */
- int symtbl_num_syms;
-
- /* Offset in data section to TOC anchor. */
- CORE_ADDR toc_offset;
-};
-
-static struct complaint storclass_complaint =
- {"Unexpected storage class: %d", 0, 0};
-
-static struct complaint bf_notfound_complaint =
- {"line numbers off, `.bf' symbol not found", 0, 0};
-
-static struct complaint ef_complaint =
- {"Mismatched .ef symbol ignored starting at symnum %d", 0, 0};
-
-static struct complaint eb_complaint =
- {"Mismatched .eb symbol ignored starting at symnum %d", 0, 0};
-
-static void
-xcoff_initial_scan PARAMS ((struct objfile *, struct section_offsets *, int));
-
-static void
-scan_xcoff_symtab PARAMS ((struct section_offsets *, struct objfile *));
-
-static char *
-xcoff_next_symbol_text PARAMS ((struct objfile *));
-
-static void
-record_include_begin PARAMS ((struct coff_symbol *));
-
-static void
-enter_line_range PARAMS ((struct subfile *, unsigned, unsigned,
- CORE_ADDR, CORE_ADDR, unsigned *));
-
-static void
-init_stringtab PARAMS ((bfd *, file_ptr, struct objfile *));
-
-static void
-xcoff_symfile_init PARAMS ((struct objfile *));
-
-static void
-xcoff_new_init PARAMS ((struct objfile *));
-
-static void
-xcoff_symfile_finish PARAMS ((struct objfile *));
-
-static struct section_offsets *
-xcoff_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR));
-
-static void
-find_linenos PARAMS ((bfd *, sec_ptr, PTR));
-
-static char *
-coff_getfilename PARAMS ((union internal_auxent *, struct objfile *));
-
-static void
-read_symbol PARAMS ((struct internal_syment *, int));
-
-static int
-read_symbol_lineno PARAMS ((int));
-
-static int
-read_symbol_nvalue PARAMS ((int));
-
-static struct symbol *
-process_xcoff_symbol PARAMS ((struct coff_symbol *, struct objfile *));
-
-static void
-read_xcoff_symtab PARAMS ((struct partial_symtab *));
-
-#if 0
-static void
-add_stab_to_list PARAMS ((char *, struct pending_stabs **));
-#endif
-
-static int
-compare_lte PARAMS ((const void *, const void *));
-
-static struct linetable *
-arrange_linetable PARAMS ((struct linetable *));
-
-static void
-record_include_end PARAMS ((struct coff_symbol *));
-
-static void
-process_linenos PARAMS ((CORE_ADDR, CORE_ADDR));
-
-
-/* Translate from a COFF section number (target_index) to a SECT_OFF_*
- code. */
-static int secnum_to_section PARAMS ((int, struct objfile *));
-static asection * secnum_to_bfd_section PARAMS ((int, struct objfile *));
-
-struct find_targ_sec_arg {
- int targ_index;
- int *resultp;
- asection **bfd_sect;
-};
-
-static void find_targ_sec PARAMS ((bfd *, asection *, void *));
-
-static void find_targ_sec (abfd, sect, obj)
- bfd *abfd;
- asection *sect;
- PTR obj;
-{
- struct find_targ_sec_arg *args = (struct find_targ_sec_arg *)obj;
- if (sect->target_index == args->targ_index)
- {
- /* This is the section. Figure out what SECT_OFF_* code it is. */
- if (bfd_get_section_flags (abfd, sect) & SEC_CODE)
- *args->resultp = SECT_OFF_TEXT;
- else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD)
- *args->resultp = SECT_OFF_DATA;
- else
- *args->resultp = SECT_OFF_BSS;
- *args->bfd_sect = sect;
- }
-}
-
-/* Return the section number (SECT_OFF_*) that CS points to. */
-static int
-secnum_to_section (secnum, objfile)
- int secnum;
- struct objfile *objfile;
-{
- int off = SECT_OFF_TEXT;
- asection *sect = NULL;
- struct find_targ_sec_arg args;
- args.targ_index = secnum;
- args.resultp = &off;
- args.bfd_sect = &sect;
- bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
- return off;
-}
-
-/* Return the BFD section that CS points to. */
-static asection *
-secnum_to_bfd_section (secnum, objfile)
- int secnum;
- struct objfile *objfile;
-{
- int off = SECT_OFF_TEXT;
- asection *sect = NULL;
- struct find_targ_sec_arg args;
- args.targ_index = secnum;
- args.resultp = &off;
- args.bfd_sect = &sect;
- bfd_map_over_sections (objfile->obfd, find_targ_sec, &args);
- return sect;
-}
-
-/* add a given stab string into given stab vector. */
-
-#if 0
-
-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 ((char *) *stabvector, sizeof (struct pending_stabs) +
- (*stabvector)->length * sizeof (char*));
- }
- (*stabvector)->stab [(*stabvector)->count++] = stabname;
-}
-
-#endif
-
-
-/* Linenos are processed on a file-by-file basis.
-
- Two reasons:
-
- 1) xlc (IBM's native c compiler) postpones static function code
- emission to the end of a compilation unit. This way it can
- determine if those functions (statics) are needed or not, and
- can do some garbage collection (I think). This makes line
- numbers and corresponding addresses unordered, and we end up
- with a line table like:
-
-
- lineno addr
- foo() 10 0x100
- 20 0x200
- 30 0x300
-
- foo3() 70 0x400
- 80 0x500
- 90 0x600
-
- static foo2()
- 40 0x700
- 50 0x800
- 60 0x900
-
- and that breaks gdb's binary search on line numbers, if the
- above table is not sorted on line numbers. And that sort
- should be on function based, since gcc can emit line numbers
- like:
-
- 10 0x100 - for the init/test part of a for stmt.
- 20 0x200
- 30 0x300
- 10 0x400 - for the increment part of a for stmt.
-
- arrange_linetable() will do this sorting.
-
- 2) aix symbol table might look like:
-
- c_file // beginning of a new file
- .bi // beginning of include file
- .ei // end of include file
- .bi
- .ei
-
- basically, .bi/.ei pairs do not necessarily encapsulate
- their scope. They need to be recorded, and processed later
- on when we come the end of the compilation unit.
- Include table (inclTable) and process_linenos() handle
- that. */
-
-/* compare line table entry addresses. */
-
-static int
-compare_lte (lte1p, lte2p)
- const void *lte1p;
- const void *lte2p;
-{
- struct linetable_entry *lte1 = (struct linetable_entry *) lte1p;
- struct linetable_entry *lte2 = (struct linetable_entry *) lte2p;
- return lte1->pc - lte2->pc;
-}
-
-/* Given a line table with function entries are marked, arrange its functions
- in ascending order and strip off function entry markers and return it in
- a newly created table. If the old one is good enough, return the old one. */
-/* FIXME: I think all this stuff can be replaced by just passing
- sort_linevec = 1 to end_symtab. */
-
-static struct linetable *
-arrange_linetable (oldLineTb)
- struct linetable *oldLineTb; /* old linetable */
-{
- int ii, jj,
- newline, /* new line count */
- function_count; /* # of functions */
-
- struct linetable_entry *fentry; /* function entry vector */
- int fentry_size; /* # of function entries */
- struct linetable *newLineTb; /* new line table */
-
-#define NUM_OF_FUNCTIONS 20
-
- fentry_size = NUM_OF_FUNCTIONS;
- fentry = (struct linetable_entry*)
- xmalloc (fentry_size * sizeof (struct linetable_entry));
-
- for (function_count=0, ii=0; ii <oldLineTb->nitems; ++ii) {
-
- if (oldLineTb->item[ii].line == 0) { /* function entry found. */
-
- if (function_count >= fentry_size) { /* make sure you have room. */
- fentry_size *= 2;
- fentry = (struct linetable_entry*)
- xrealloc (fentry, fentry_size * sizeof (struct linetable_entry));
- }
- fentry[function_count].line = ii;
- fentry[function_count].pc = oldLineTb->item[ii].pc;
- ++function_count;
- }
- }
-
- if (function_count == 0) {
- free (fentry);
- return oldLineTb;
- }
- else if (function_count > 1)
- qsort (fentry, function_count, sizeof(struct linetable_entry), compare_lte);
-
- /* allocate a new line table. */
- newLineTb = (struct linetable *)
- xmalloc
- (sizeof (struct linetable) +
- (oldLineTb->nitems - function_count) * sizeof (struct linetable_entry));
-
- /* if line table does not start with a function beginning, copy up until
- a function begin. */
-
- newline = 0;
- if (oldLineTb->item[0].line != 0)
- for (newline=0;
- newline < oldLineTb->nitems && oldLineTb->item[newline].line; ++newline)
- newLineTb->item[newline] = oldLineTb->item[newline];
-
- /* Now copy function lines one by one. */
-
- for (ii=0; ii < function_count; ++ii) {
- for (jj = fentry[ii].line + 1;
- jj < oldLineTb->nitems && oldLineTb->item[jj].line != 0;
- ++jj, ++newline)
- newLineTb->item[newline] = oldLineTb->item[jj];
- }
- free (fentry);
- newLineTb->nitems = oldLineTb->nitems - function_count;
- return newLineTb;
-}
-
-/* include file support: C_BINCL/C_EINCL pairs will be kept in the
- following `IncludeChain'. At the end of each symtab (end_symtab),
- we will determine if we should create additional symtab's to
- represent if (the include files. */
-
-
-typedef struct _inclTable {
- char *name; /* include filename */
-
- /* Offsets to the line table. end points to the last entry which is
- part of this include file. */
- int begin, end;
-
- struct subfile *subfile;
- unsigned funStartLine; /* start line # of its function */
-} InclTable;
-
-#define INITIAL_INCLUDE_TABLE_LENGTH 20
-static InclTable *inclTable; /* global include table */
-static int inclIndx; /* last entry to table */
-static int inclLength; /* table length */
-static int inclDepth; /* nested include depth */
-
-static void allocate_include_entry PARAMS ((void));
-
-static void
-record_include_begin (cs)
-struct coff_symbol *cs;
-{
- if (inclDepth)
- {
- /* In xcoff, we assume include files cannot be nested (not in .c files
- of course, but in corresponding .s files.). */
-
- /* This can happen with old versions of GCC.
- GCC 2.3.3-930426 does not exhibit this on a test case which
- a user said produced the message for him. */
- static struct complaint msg = {"Nested C_BINCL symbols", 0, 0};
- complain (&msg);
- }
- ++inclDepth;
-
- allocate_include_entry ();
-
- inclTable [inclIndx].name = cs->c_name;
- inclTable [inclIndx].begin = cs->c_value;
-}
-
-static void
-record_include_end (cs)
-struct coff_symbol *cs;
-{
- InclTable *pTbl;
-
- if (inclDepth == 0)
- {
- static struct complaint msg = {"Mismatched C_BINCL/C_EINCL pair", 0, 0};
- complain (&msg);
- }
-
- allocate_include_entry ();
-
- pTbl = &inclTable [inclIndx];
- pTbl->end = cs->c_value;
-
- --inclDepth;
- ++inclIndx;
-}
-
-static void
-allocate_include_entry ()
-{
- if (inclTable == NULL)
- {
- inclTable = (InclTable *)
- xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
- memset (inclTable,
- '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH);
- inclLength = INITIAL_INCLUDE_TABLE_LENGTH;
- inclIndx = 0;
- }
- else if (inclIndx >= inclLength)
- {
- inclLength += INITIAL_INCLUDE_TABLE_LENGTH;
- inclTable = (InclTable *)
- xrealloc (inclTable, sizeof (InclTable) * inclLength);
- memset (inclTable + inclLength - INITIAL_INCLUDE_TABLE_LENGTH,
- '\0', sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH);
- }
-}
-
-/* Global variable to pass the psymtab down to all the routines involved
- in psymtab to symtab processing. */
-static struct partial_symtab *this_symtab_psymtab;
-
-/* given the start and end addresses of a compilation unit (or a csect,
- at times) process its lines and create appropriate line vectors. */
-
-static void
-process_linenos (start, end)
- CORE_ADDR start, end;
-{
- int offset, ii;
- file_ptr max_offset =
- ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private)
- ->max_lineno_offset;
-
- /* subfile structure for the main compilation unit. */
- struct subfile main_subfile;
-
- /* In the main source file, any time we see a function entry, we
- reset this variable to function's absolute starting line number.
- All the following line numbers in the function are relative to
- this, and we record absolute line numbers in record_line(). */
-
- unsigned int main_source_baseline = 0;
-
- unsigned *firstLine;
-
- offset =
- ((struct symloc *)this_symtab_psymtab->read_symtab_private)->lineno_off;
- if (offset == 0)
- goto return_after_cleanup;
-
- memset (&main_subfile, '\0', sizeof (main_subfile));
-
- if (inclIndx == 0)
- /* All source lines were in the main source file. None in include files. */
-
- enter_line_range (&main_subfile, offset, 0, start, end,
- &main_source_baseline);
-
- else
- {
- /* There was source with line numbers in include files. */
- main_source_baseline = 0;
- for (ii=0; ii < inclIndx; ++ii)
- {
- struct subfile *tmpSubfile;
-
- /* If there is main file source before include file, enter it. */
- if (offset < inclTable[ii].begin)
- {
- enter_line_range
- (&main_subfile, offset, inclTable[ii].begin - LINESZ,
- start, 0, &main_source_baseline);
- }
-
- /* Have a new subfile for the include file. */
-
- tmpSubfile = inclTable[ii].subfile =
- (struct subfile *) xmalloc (sizeof (struct subfile));
-
- memset (tmpSubfile, '\0', sizeof (struct subfile));
- firstLine = &(inclTable[ii].funStartLine);
-
- /* Enter include file's lines now. */
- enter_line_range (tmpSubfile, inclTable[ii].begin,
- inclTable[ii].end, start, 0, firstLine);
-
- if (offset <= inclTable[ii].end)
- offset = inclTable[ii].end + LINESZ;
- }
-
- /* All the include files' line have been processed at this point. Now,
- enter remaining lines of the main file, if any left. */
- if (offset < max_offset + 1 - LINESZ)
- {
- enter_line_range (&main_subfile, offset, 0, start, end,
- &main_source_baseline);
- }
- }
-
- /* Process main file's line numbers. */
- if (main_subfile.line_vector)
- {
- struct linetable *lineTb, *lv;
-
- lv = main_subfile.line_vector;
-
- /* Line numbers are not necessarily ordered. xlc compilation will
- put static function to the end. */
-
- lineTb = arrange_linetable (lv);
- if (lv == lineTb)
- {
- current_subfile->line_vector = (struct linetable *)
- xrealloc (lv, (sizeof (struct linetable)
- + lv->nitems * sizeof (struct linetable_entry)));
- }
- else
- {
- free (lv);
- current_subfile->line_vector = lineTb;
- }
-
- current_subfile->line_vector_length =
- current_subfile->line_vector->nitems;
- }
-
- /* Now, process included files' line numbers. */
-
- for (ii=0; ii < inclIndx; ++ii)
- {
- if ((inclTable[ii].subfile)->line_vector) /* Useless if!!! FIXMEmgo */
- {
- struct linetable *lineTb, *lv;
-
- lv = (inclTable[ii].subfile)->line_vector;
-
- /* Line numbers are not necessarily ordered. xlc compilation will
- put static function to the end. */
-
- lineTb = arrange_linetable (lv);
-
- push_subfile ();
-
- /* For the same include file, we might want to have more than one
- subfile. This happens if we have something like:
-
- ......
- #include "foo.h"
- ......
- #include "foo.h"
- ......
-
- while foo.h including code in it. (stupid but possible)
- Since start_subfile() looks at the name and uses an
- existing one if finds, we need to provide a fake name and
- fool it. */
-
-#if 0
- start_subfile (inclTable[ii].name, (char*)0);
-#else
- {
- /* Pick a fake name that will produce the same results as this
- one when passed to deduce_language_from_filename. Kludge on
- top of kludge. */
- char *fakename = strrchr (inclTable[ii].name, '.');
- if (fakename == NULL)
- fakename = " ?";
- start_subfile (fakename, (char*)0);
- free (current_subfile->name);
- }
- current_subfile->name = strdup (inclTable[ii].name);
-#endif
-
- if (lv == lineTb)
- {
- current_subfile->line_vector =
- (struct linetable *) xrealloc
- (lv, (sizeof (struct linetable)
- + lv->nitems * sizeof (struct linetable_entry)));
-
- }
- else
- {
- free (lv);
- current_subfile->line_vector = lineTb;
- }
-
- current_subfile->line_vector_length =
- current_subfile->line_vector->nitems;
- start_subfile (pop_subfile (), (char*)0);
- }
- }
-
- return_after_cleanup:
-
- /* We don't want to keep alloc/free'ing the global include file table. */
- inclIndx = 0;
-
- /* Start with a fresh subfile structure for the next file. */
- memset (&main_subfile, '\0', sizeof (struct subfile));
-}
-
-void
-aix_process_linenos ()
-{
- /* process line numbers and enter them into line vector */
- process_linenos (last_source_start_addr, cur_src_end_addr);
-}
-
-
-/* Enter a given range of lines into the line vector.
- can be called in the following two ways:
- enter_line_range (subfile, beginoffset, endoffset, startaddr, 0, firstLine) or
- enter_line_range (subfile, beginoffset, 0, startaddr, endaddr, firstLine)
-
- endoffset points to the last line table entry that we should pay
- attention to. */
-
-static void
-enter_line_range (subfile, beginoffset, endoffset, startaddr, endaddr,
- firstLine)
- struct subfile *subfile;
- unsigned beginoffset, endoffset; /* offsets to line table */
- CORE_ADDR startaddr, endaddr;
- unsigned *firstLine;
-{
- unsigned int curoffset;
- CORE_ADDR addr;
- struct external_lineno ext_lnno;
- struct internal_lineno int_lnno;
- unsigned int limit_offset;
- bfd *abfd;
-
- if (endoffset == 0 && startaddr == 0 && endaddr == 0)
- return;
- curoffset = beginoffset;
- limit_offset =
- ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private)
- ->max_lineno_offset;
-
- if (endoffset != 0)
- {
- if (endoffset >= limit_offset)
- {
- static struct complaint msg =
- {"Bad line table offset in C_EINCL directive", 0, 0};
- complain (&msg);
- return;
- }
- limit_offset = endoffset;
- }
- else
- limit_offset -= 1;
- abfd = this_symtab_psymtab->objfile->obfd;
-
- while (curoffset <= limit_offset)
- {
- bfd_seek (abfd, curoffset, SEEK_SET);
- bfd_read (&ext_lnno, sizeof (struct external_lineno), 1, abfd);
- bfd_coff_swap_lineno_in (abfd, &ext_lnno, &int_lnno);
-
- /* Find the address this line represents. */
- addr = (int_lnno.l_lnno
- ? int_lnno.l_addr.l_paddr
- : read_symbol_nvalue (int_lnno.l_addr.l_symndx));
- addr += ANOFFSET (this_symtab_psymtab->objfile->section_offsets,
- SECT_OFF_TEXT);
-
- if (addr < startaddr || (endaddr && addr >= endaddr))
- return;
-
- if (int_lnno.l_lnno == 0)
- {
- *firstLine = read_symbol_lineno (int_lnno.l_addr.l_symndx);
- record_line (subfile, 0, addr);
- --(*firstLine);
- }
- else
- record_line (subfile, *firstLine + int_lnno.l_lnno, addr);
- curoffset += 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)); \
- last_source_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_MINIMAL_SYMBOL(NAME, ADDR, TYPE, SECTION, OBJFILE) \
-{ \
- char *namestr; \
- namestr = (NAME); \
- if (namestr[0] == '.') ++namestr; \
- prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \
- (char *)NULL, (SECTION), (asection *)NULL, (OBJFILE)); \
- misc_func_recorded = 1; \
-}
-
-
-/* xcoff 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;
-
-/* Section number for the current static block. */
-
-static int static_block_section = -1;
-
-/* true if space for symbol name has been allocated. */
-
-static int symname_alloced = 0;
-
-/* Next symbol to read. Pointer into raw seething symbol table. */
-
-static char *raw_symbol;
-
-/* This is the function which stabsread.c calls to get symbol
- continuations. */
-
-static char *
-xcoff_next_symbol_text (objfile)
- struct objfile *objfile;
-{
- struct internal_syment symbol;
- static struct complaint msg =
- {"Unexpected symbol continuation", 0, 0};
- char *retval;
- /* FIXME: is this the same as the passed arg? */
- objfile = this_symtab_psymtab->objfile;
-
- bfd_coff_swap_sym_in (objfile->obfd, raw_symbol, &symbol);
- if (symbol.n_zeroes)
- {
- complain (&msg);
-
- /* Return something which points to '\0' and hope the symbol reading
- code does something reasonable. */
- retval = "";
- }
- else if (symbol.n_sclass & 0x80)
- {
- retval =
- ((struct coff_symfile_info *)objfile->sym_private)->debugsec
- + symbol.n_offset;
- raw_symbol +=
- coff_data (objfile->obfd)->local_symesz;
- ++symnum;
- }
- else
- {
- complain (&msg);
-
- /* Return something which points to '\0' and hope the symbol reading
- code does something reasonable. */
- retval = "";
- }
- return retval;
-}
-
-/* Read symbols for a given partial symbol table. */
-
-static void
-read_xcoff_symtab (pst)
- struct partial_symtab *pst;
-{
- struct objfile *objfile = pst->objfile;
- bfd *abfd = objfile->obfd;
- char *raw_auxptr; /* Pointer to first raw aux entry for sym */
- char *strtbl = ((struct coff_symfile_info *)objfile->sym_private)->strtbl;
- char *debugsec =
- ((struct coff_symfile_info *)objfile->sym_private)->debugsec;
-
- struct internal_syment symbol[1];
- union internal_auxent main_aux;
- struct coff_symbol cs[1];
- CORE_ADDR file_start_addr = 0;
- CORE_ADDR file_end_addr = 0;
-
- int next_file_symnum = -1;
- unsigned int max_symnum;
- int just_started = 1;
- int depth = 0;
- int fcn_start_addr = 0;
-
- struct coff_symbol fcn_stab_saved;
-
- /* 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_csect_name; /* last seen csect's name and value */
- CORE_ADDR last_csect_val;
- int last_csect_sec;
-
- this_symtab_psymtab = pst;
-
- /* Get the appropriate COFF "constants" related to the file we're
- handling. */
- local_symesz = coff_data (abfd)->local_symesz;
-
- last_source_file = NULL;
- last_csect_name = 0;
- last_csect_val = 0;
-
- start_stabs ();
- start_symtab (filestring, (char *)NULL, file_start_addr);
- record_debugformat ("XCOFF");
- symnum = ((struct symloc *)pst->read_symtab_private)->first_symnum;
- max_symnum =
- symnum + ((struct symloc *)pst->read_symtab_private)->numsyms;
- first_object_file_end = 0;
-
- raw_symbol =
- ((struct coff_symfile_info *) objfile->sym_private)->symtbl
- + symnum * local_symesz;
-
- while (symnum < max_symnum)
- {
-
- 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 xcoff 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_naux = 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;
- /* If it's exactly E_SYMNMLEN characters long it isn't
- '\0'-terminated. */
- if (cs->c_name[E_SYMNMLEN - 1] != '\0')
- {
- char *p;
- p = obstack_alloc (&objfile->symbol_obstack, E_SYMNMLEN + 1);
- strncpy (p, cs->c_name, E_SYMNMLEN);
- p[E_SYMNMLEN] = '\0';
- cs->c_name = p;
- symname_alloced = 1;
- }
- }
- 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;
- cs->c_secnum = symbol->n_scnum;
- cs->c_type = (unsigned)symbol->n_type;
-
- raw_symbol += coff_data (abfd)->local_symesz;
- ++symnum;
-
- /* Save addr of first aux entry. */
- raw_auxptr = raw_symbol;
-
- /* 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)
- {
- pst->symtab =
- end_symtab (cur_src_end_addr, objfile, SECT_OFF_TEXT);
- end_stabs ();
- }
-
- start_stabs ();
- start_symtab ("_globals_", (char *)NULL, (CORE_ADDR)0);
- record_debugformat ("XCOFF");
- 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,
- 0, cs->c_naux, &main_aux);
- goto function_entry_point;
- }
-
- if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT)
- && cs->c_naux == 1)
- {
- /* Dealing with a symbol with a csect entry. */
-
-#define CSECT(PP) ((PP)->x_csect)
-#define CSECT_LEN(PP) (CSECT(PP).x_scnlen.l)
-#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,
- 0, cs->c_naux, &main_aux);
-
- switch (CSECT_SMTYP (&main_aux))
- {
-
- case XTY_ER:
- /* Ignore all external references. */
- continue;
-
- case XTY_SD:
- /* A section description. */
- {
- switch (CSECT_SCLAS (&main_aux))
- {
-
- case XMC_PR:
- {
-
- /* A program csect is seen. We have to allocate one
- symbol table for each program csect. Normally gdb
- prefers one symtab for each source file. In case
- of AIX, one source file might include more than one
- [PR] csect, and they don't have to be adjacent in
- terms of the space they occupy in memory. Thus, one
- single source file might get fragmented in the
- memory and gdb's file start and end address
- approach does not work! GCC (and I think xlc) seem
- to put all the code in the unnamed program csect. */
-
- if (last_csect_name)
- {
- complete_symtab (filestring, file_start_addr);
- cur_src_end_addr = file_end_addr;
- end_symtab (file_end_addr, objfile, SECT_OFF_TEXT);
- end_stabs ();
- start_stabs ();
- /* Give all csects for this source file the same
- name. */
- start_symtab (filestring, NULL, (CORE_ADDR)0);
- record_debugformat ("XCOFF");
- }
-
- /* 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 + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT);
- file_end_addr = file_start_addr + CSECT_LEN (&main_aux);
-
- if (cs->c_name && cs->c_name[0] == '.')
- {
- last_csect_name = cs->c_name;
- last_csect_val = cs->c_value;
- last_csect_sec = secnum_to_section (cs->c_secnum, objfile);
- }
- }
- continue;
-
- /* All other symbols are put into the minimal symbol
- table only. */
-
- case XMC_RW:
- continue;
-
- case XMC_TC0:
- continue;
-
- case XMC_TC:
- continue;
-
- default:
- /* Ignore the symbol. */
- continue;
- }
- }
- break;
-
- case XTY_LD:
-
- switch (CSECT_SCLAS (&main_aux))
- {
- case XMC_PR:
- /* a function entry point. */
- function_entry_point:
-
- 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;
-
- case XMC_GL:
- /* shared library function trampoline code entry point. */
- continue;
-
- case XMC_DS:
- /* The symbols often have the same names as debug symbols for
- functions, and confuse lookup_symbol. */
- continue;
-
- default:
- /* xlc puts each variable in a separate csect, so we get
- an XTY_SD for each variable. But gcc puts several
- variables in a csect, so that each variable only gets
- an XTY_LD. This will typically be XMC_RW; I suspect
- XMC_RO and XMC_BS might be possible too.
- These variables are put in the minimal symbol table
- only. */
- continue;
- }
- break;
-
- case XTY_CM:
- /* Common symbols are put into the minimal symbol table only. */
- continue;
-
- default:
- break;
- }
- }
-
- 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_stabs' and `start_stabs' 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, objfile, SECT_OFF_TEXT);
- end_stabs ();
-
- /* XCOFF, according to the AIX 3.2 documentation, puts the filename
- in cs->c_name. But xlc 1.3.0.2 has decided to do things the
- standard COFF way and put it in the auxent. We use the auxent if
- the symbol is ".file" and an auxent exists, otherwise use the symbol
- itself. Simple enough. */
- if (!strcmp (cs->c_name, ".file") && cs->c_naux > 0)
- {
- bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
- 0, cs->c_naux, &main_aux);
- filestring = coff_getfilename (&main_aux, objfile);
- }
- else
- filestring = cs->c_name;
-
- start_stabs ();
- start_symtab (filestring, (char *)NULL, (CORE_ADDR)0);
- record_debugformat ("XCOFF");
- last_csect_name = 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;
- break;
-
- case C_FUN:
- fcn_stab_saved = *cs;
- break;
-
- case C_FCN:
- if (STREQ (cs->c_name, ".bf"))
- {
- CORE_ADDR off = ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT);
- bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
- 0, cs->c_naux, &main_aux);
-
- within_function = 1;
-
- new = push_context (0, fcn_start_addr + off);
-
- new->name = define_symbol
- (fcn_cs_saved.c_value + off,
- fcn_stab_saved.c_name, 0, 0, objfile);
- if (new->name != NULL)
- SYMBOL_SECTION (new->name) = SECT_OFF_TEXT;
- }
- else if (STREQ (cs->c_name, ".ef"))
- {
-
- bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
- 0, cs->c_naux, &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 '}' */
-
- if (context_stack_depth <= 0)
- { /* We attempted to pop an empty context stack */
- complain (&ef_complaint, cs->c_symnum);
- within_function = 0;
- break;
- }
- new = pop_context ();
- /* Stack must be empty now. */
- if (context_stack_depth > 0 || new == NULL)
- {
- complain (&ef_complaint, cs->c_symnum);
- within_function = 0;
- break;
- }
-
- 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
- + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT)),
- objfile);
- within_function = 0;
- }
- break;
-
- case C_BSTAT:
- /* Begin static block. */
- {
- struct internal_syment symbol;
-
- read_symbol (&symbol, cs->c_value);
- static_block_base = symbol.n_value;
- static_block_section =
- secnum_to_section (symbol.n_scnum, objfile);
- }
- break;
-
- case C_ESTAT:
- /* End of static block. */
- static_block_base = 0;
- static_block_section = -1;
- break;
-
- case C_ARG:
- case C_REGPARM:
- case C_REG:
- case C_TPDEF:
- case C_STRTAG:
- case C_UNTAG:
- case C_ENTAG:
- {
- static struct complaint msg =
- {"Unrecognized storage class %d.", 0, 0};
- complain (&msg, cs->c_sclass);
- }
- break;
-
- case C_LABEL:
- case C_NULL:
- /* Ignore these. */
- break;
-
- case C_HIDEXT:
- case C_STAT:
- break;
-
- case C_BINCL:
- /* beginning of include file */
- /* In xlc output, C_BINCL/C_EINCL pair doesn't show up in sorted
- order. Thus, when wee see them, we might not know enough info
- to process them. Thus, we'll be saving them into a table
- (inclTable) and postpone their processing. */
-
- record_include_begin (cs);
- break;
-
- case C_EINCL:
- /* End of include file. */
- /* See the comment after case C_BINCL. */
- record_include_end (cs);
- break;
-
- case C_BLOCK:
- if (STREQ (cs->c_name, ".bb"))
- {
- depth++;
- new = push_context (depth,
- (cs->c_value
- + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT)));
- }
- else if (STREQ (cs->c_name, ".eb"))
- {
- if (context_stack_depth <= 0)
- { /* We attempted to pop an empty context stack */
- complain (&eb_complaint, cs->c_symnum);
- break;
- }
- new = pop_context ();
- if (depth-- != new->depth)
- {
- complain (&eb_complaint, cs->c_symnum);
- break;
- }
- 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
- + ANOFFSET (objfile->section_offsets,
- SECT_OFF_TEXT)),
- objfile);
- }
- local_symbols = new->locals;
- }
- break;
-
- default:
- process_xcoff_symbol (cs, objfile);
- break;
- }
- }
-
- if (last_source_file)
- {
- struct symtab *s;
-
- complete_symtab (filestring, file_start_addr);
- cur_src_end_addr = file_end_addr;
- s = end_symtab (file_end_addr, objfile, SECT_OFF_TEXT);
- /* When reading symbols for the last C_FILE of the objfile, try
- to make sure that we set pst->symtab to the symtab for the
- file, not to the _globals_ symtab. I'm not sure whether this
- actually works right or when/if it comes up. */
- if (pst->symtab == NULL)
- pst->symtab = s;
- end_stabs ();
- }
-}
-
-#define SYMBOL_DUP(SYMBOL1, SYMBOL2) \
- (SYMBOL2) = (struct symbol *) \
- obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); \
- *(SYMBOL2) = *(SYMBOL1);
-
-
-#define SYMNAME_ALLOC(NAME, ALLOCED) \
- (ALLOCED) ? (NAME) : obsavestring ((NAME), strlen (NAME), &objfile->symbol_obstack);
-
-
-static struct type *func_symbol_type;
-static struct type *var_symbol_type;
-
-/* process one xcoff symbol. */
-
-static struct symbol *
-process_xcoff_symbol (cs, objfile)
- register struct coff_symbol *cs;
- struct objfile *objfile;
-{
- struct symbol onesymbol;
- register struct symbol *sym = &onesymbol;
- struct symbol *sym2 = NULL;
- char *name, *pp;
-
- int sec;
- CORE_ADDR off;
-
- if (cs->c_secnum < 0)
- {
- /* The value is a register number, offset within a frame, etc.,
- and does not get relocated. */
- off = 0;
- sec = -1;
- }
- else
- {
- sec = secnum_to_section (cs->c_secnum, objfile);
- off = ANOFFSET (objfile->section_offsets, sec);
- }
-
- name = cs->c_name;
- if (name[0] == '.')
- ++name;
-
- memset (sym, '\0', sizeof (struct symbol));
-
- /* default assumptions */
- SYMBOL_VALUE (sym) = cs->c_value + off;
- SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
- SYMBOL_SECTION (sym) = secnum_to_section (cs->c_secnum, objfile);
-
- if (ISFCN (cs->c_type))
- {
- /* At this point, we don't know the type of the function. This
- will be patched with the type from its stab entry later on in
- patch_block_stabs (), unless the file was compiled without -g. */
-
- SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
- SYMBOL_TYPE (sym) = func_symbol_type;
-
- 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, provide default. */
- SYMBOL_TYPE (sym) = var_symbol_type;
-
- switch (cs->c_sclass)
- {
-#if 0
- /* The values of functions and global symbols are now resolved
- via the global_sym_chain in stabsread.c. */
- 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_GSYM:
- add_stab_to_list (name, &global_stabs);
- break;
-#endif
-
- case C_BCOMM:
- common_block_start (cs->c_name, objfile);
- break;
-
- case C_ECOMM:
- common_block_end (objfile);
- break;
-
- default:
- complain (&storclass_complaint, cs->c_sclass);
- /* FALLTHROUGH */
-
- case C_DECL:
- case C_PSYM:
- case C_RPSYM:
- case C_ECOML:
- case C_LSYM:
- case C_RSYM:
- case C_GSYM:
-
- {
- sym = define_symbol (cs->c_value + off, cs->c_name, 0, 0, objfile);
- if (sym != NULL)
- {
- SYMBOL_SECTION (sym) = sec;
- }
- return sym;
- }
-
- case C_STSYM:
-
- /* For xlc (not GCC), the 'V' symbol descriptor is used for
- all statics and we need to distinguish file-scope versus
- function-scope using within_function. We do this by
- changing the string we pass to define_symbol to use 'S'
- where we need to, which is not necessarily super-clean,
- but seems workable enough. */
-
- if (*name == ':' || (pp = (char *) strchr(name, ':')) == NULL)
- return NULL;
-
- ++pp;
- if (*pp == 'V' && !within_function)
- *pp = 'S';
- sym = define_symbol ((cs->c_value
- + ANOFFSET (objfile->section_offsets,
- static_block_section)),
- cs->c_name, 0, 0, objfile);
- if (sym != NULL)
- {
- SYMBOL_VALUE (sym) += static_block_base;
- SYMBOL_SECTION (sym) = static_block_section;
- }
- return sym;
-
- }
- }
- return sym2;
-}
-
-/* Extract the file name from the aux entry of a C_FILE symbol.
- Result is in static storage and is only good for temporary use. */
-
-static char *
-coff_getfilename (aux_entry, objfile)
- union internal_auxent *aux_entry;
- struct objfile *objfile;
-{
- static char buffer[BUFSIZ];
-
- if (aux_entry->x_file.x_n.x_zeroes == 0)
- strcpy (buffer,
- ((struct coff_symfile_info *)objfile->sym_private)->strtbl
- + aux_entry->x_file.x_n.x_offset);
- else
- {
- strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN);
- buffer[FILNMLEN] = '\0';
- }
- return (buffer);
-}
-
-/* Set *SYMBOL to symbol number symno in symtbl. */
-static void
-read_symbol (symbol, symno)
- struct internal_syment *symbol;
- int symno;
-{
- int nsyms =
- ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private)
- ->symtbl_num_syms;
- char *stbl =
- ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private)
- ->symtbl;
- if (symno < 0 || symno >= nsyms)
- {
- static struct complaint msg =
- {"Invalid symbol offset", 0, 0};
- complain (&msg);
- symbol->n_value = 0;
- symbol->n_scnum = -1;
- return;
- }
- bfd_coff_swap_sym_in (this_symtab_psymtab->objfile->obfd,
- stbl + (symno*local_symesz),
- symbol);
-}
-
-/* Get value corresponding to symbol number symno in symtbl. */
-
-static int
-read_symbol_nvalue (symno)
- int symno;
-{
- struct internal_syment symbol[1];
-
- read_symbol (symbol, symno);
- return symbol->n_value;
-}
-
-
-/* Find the address of the function corresponding to symno, where
- symno is the symbol pointed to by the linetable. */
-
-static int
-read_symbol_lineno (symno)
- int symno;
-{
- int nsyms =
- ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private)
- ->symtbl_num_syms;
- char *stbl =
- ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private)
- ->symtbl;
- struct internal_syment symbol[1];
- union internal_auxent main_aux[1];
-
- if (symno < 0)
- {
- complain (&bf_notfound_complaint);
- return 0;
- }
-
- /* Note that just searching for a short distance (e.g. 50 symbols)
- is not enough, at least in the following case.
-
- .extern foo
- [many .stabx entries]
- [a few functions, referring to foo]
- .globl foo
- .bf
-
- What happens here is that the assembler moves the .stabx entries
- to right before the ".bf" for foo, but the symbol for "foo" is before
- all the stabx entries. See PR gdb/2222. */
-
- /* Maintaining a table of .bf entries might be preferable to this search.
- If I understand things correctly it would need to be done only for
- the duration of a single psymtab to symtab conversion. */
- while (symno < nsyms)
- {
- bfd_coff_swap_sym_in (symfile_bfd,
- stbl + (symno * local_symesz), symbol);
- if (symbol->n_sclass == C_FCN && STREQ (symbol->n_name, ".bf"))
- goto gotit;
- symno += symbol->n_numaux + 1;
- }
-
- complain (&bf_notfound_complaint);
- return 0;
-
-gotit:
- /* take aux entry and return its lineno */
- symno++;
- bfd_coff_swap_aux_in (this_symtab_psymtab->objfile->obfd,
- stbl + symno * local_symesz,
- symbol->n_type, symbol->n_sclass,
- 0, symbol->n_numaux, 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;
- PTR vpinfo;
-{
- struct coff_symfile_info *info;
- int size, count;
- file_ptr offset, maxoff;
-
- count = asect->lineno_count;
-
- if (!STREQ (asect->name, ".text") || count == 0)
- return;
-
- size = count * coff_data (abfd)->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;
-}
-
-static void xcoff_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *));
-
-static void
-xcoff_psymtab_to_symtab_1 (pst)
- struct partial_symtab *pst;
-{
- struct cleanup *old_chain;
- int i;
-
- if (!pst)
- return;
-
- if (pst->readin)
- {
- fprintf_unfiltered
- (gdb_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 (" ", gdb_stdout);
- wrap_here ("");
- fputs_filtered ("and ", gdb_stdout);
- wrap_here ("");
- printf_filtered ("%s...", pst->dependencies[i]->filename);
- wrap_here (""); /* Flush output */
- gdb_flush (gdb_stdout);
- }
- xcoff_psymtab_to_symtab_1 (pst->dependencies[i]);
- }
-
- if (((struct symloc *)pst->read_symtab_private)->numsyms != 0)
- {
- /* Init stuff necessary for reading in symbols. */
- stabsread_init ();
- buildsym_init ();
- old_chain = make_cleanup ((make_cleanup_func) really_free_pendings, 0);
-
- read_xcoff_symtab (pst);
- sort_symtab_syms (pst->symtab);
-
- do_cleanups (old_chain);
- }
-
- pst->readin = 1;
-}
-
-static void xcoff_psymtab_to_symtab PARAMS ((struct partial_symtab *));
-
-/* Read in all of the symbols for a given psymtab for real.
- Be verbose about it if the user wants that. */
-
-static void
-xcoff_psymtab_to_symtab (pst)
- struct partial_symtab *pst;
-{
- bfd *sym_bfd;
-
- if (!pst)
- return;
-
- if (pst->readin)
- {
- fprintf_unfiltered
- (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n",
- pst->filename);
- return;
- }
-
- if (((struct symloc *)pst->read_symtab_private)->numsyms != 0
- || 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);
- gdb_flush (gdb_stdout);
- }
-
- sym_bfd = pst->objfile->obfd;
-
- next_symbol_text_func = xcoff_next_symbol_text;
-
- xcoff_psymtab_to_symtab_1 (pst);
-
- /* 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 (pst->objfile);
-
- /* Finish up the debug error message. */
- if (info_verbose)
- printf_filtered ("done.\n");
- }
-}
-
-static void
-xcoff_new_init (objfile)
- struct objfile *objfile;
-{
- stabsread_new_init ();
- buildsym_new_init ();
-}
-
-/* Do initialization in preparation for reading symbols from OBJFILE.
-
- We will only be called if this is an XCOFF or XCOFF-like file.
- BFD handles figuring out the format of the file, and code in symfile.c
- uses BFD's determination to vector to us. */
-
-static void
-xcoff_symfile_init (objfile)
- struct objfile *objfile;
-{
- /* Allocate struct to keep track of the symfile */
- objfile -> sym_private = xmmalloc (objfile -> md,
- sizeof (struct coff_symfile_info));
-
- /* XCOFF objects may be reordered, so set OBJF_REORDERED. If we
- find this causes a significant slowdown in gdb then we could
- set it in the debug symbol readers only when necessary. */
- objfile->flags |= OBJF_REORDERED;
-
- init_entry_point_info (objfile);
-}
-
-/* Perform any local cleanups required when we are done with a particular
- objfile. I.E, we are in the process of discarding all symbol information
- for an objfile, freeing up all memory held for it, and unlinking the
- objfile struct from the global list of known objfiles. */
-
-static void
-xcoff_symfile_finish (objfile)
- struct objfile *objfile;
-{
- if (objfile -> sym_private != NULL)
- {
- mfree (objfile -> md, objfile -> sym_private);
- }
-
- /* Start with a fresh include table for the next objfile. */
- if (inclTable)
- {
- free (inclTable);
- inclTable = NULL;
- }
- inclIndx = inclLength = inclDepth = 0;
-}
-
-
-static void
-init_stringtab (abfd, offset, objfile)
- bfd *abfd;
- file_ptr offset;
- struct objfile *objfile;
-{
- long length;
- int val;
- unsigned char lengthbuf[4];
- char *strtbl;
-
- ((struct coff_symfile_info *)objfile->sym_private)->strtbl = NULL;
-
- if (bfd_seek (abfd, offset, SEEK_SET) < 0)
- error ("cannot seek to string table in %s: %s",
- bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
-
- 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 lengthbuf || length < sizeof lengthbuf)
- return;
-
- /* Allocate string table from symbol_obstack. We will need this table
- as long as we have its symbol table around. */
-
- strtbl = (char *) obstack_alloc (&objfile->symbol_obstack, length);
- ((struct coff_symfile_info *)objfile->sym_private)->strtbl = strtbl;
-
- /* Copy length buffer, the first byte is usually zero and is
- used for stabs with a name length of zero. */
- memcpy (strtbl, lengthbuf, sizeof lengthbuf);
- if (length == sizeof lengthbuf)
- return;
-
- val = bfd_read (strtbl + sizeof lengthbuf, 1, length - sizeof lengthbuf,
- abfd);
-
- if (val != length - sizeof lengthbuf)
- error ("cannot read string table from %s: %s",
- bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
- if (strtbl[length - 1] != '\0')
- error ("bad symbol file: string table does not end with null character");
-
- return;
-}
-
-/* If we have not yet seen a function for this psymtab, this is 0. If we
- have seen one, it is the offset in the line numbers of the line numbers
- for the psymtab. */
-static unsigned int first_fun_line_offset;
-
-static struct partial_symtab *xcoff_start_psymtab
- PARAMS ((struct objfile *, struct section_offsets *, char *, int,
- struct partial_symbol **, struct partial_symbol **));
-
-/* 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 *
-xcoff_start_psymtab (objfile, section_offsets,
- filename, first_symnum, global_syms, static_syms)
- struct objfile *objfile;
- struct section_offsets *section_offsets;
- char *filename;
- int first_symnum;
- struct partial_symbol **global_syms;
- struct partial_symbol **static_syms;
-{
- struct partial_symtab *result =
- start_psymtab_common (objfile, section_offsets,
- filename,
- /* We fill in textlow later. */
- 0,
- global_syms, static_syms);
-
- result->read_symtab_private = (char *)
- obstack_alloc (&objfile -> psymbol_obstack, sizeof (struct symloc));
- ((struct symloc *)result->read_symtab_private)->first_symnum = first_symnum;
- result->read_symtab = xcoff_psymtab_to_symtab;
-
- /* Deduce the source language from the filename for this psymtab. */
- psymtab_language = deduce_language_from_filename (filename);
-
- return result;
-}
-
-static struct partial_symtab *xcoff_end_psymtab
- PARAMS ((struct partial_symtab *, char **, int, int,
- struct partial_symtab **, int, int));
-
-/* Close off the current usage of PST.
- Returns PST, or NULL if the partial symtab was empty and thrown away.
-
- CAPPING_SYMBOL_NUMBER is the end of pst (exclusive).
-
- INCLUDE_LIST, NUM_INCLUDES, DEPENDENCY_LIST, and NUMBER_DEPENDENCIES
- are the information for includes and dependencies. */
-
-static struct partial_symtab *
-xcoff_end_psymtab (pst, include_list, num_includes, capping_symbol_number,
- dependency_list, number_dependencies, textlow_not_set)
- struct partial_symtab *pst;
- char **include_list;
- int num_includes;
- int capping_symbol_number;
- struct partial_symtab **dependency_list;
- int number_dependencies;
- int textlow_not_set;
-{
- int i;
- struct objfile *objfile = pst -> objfile;
-
- if (capping_symbol_number != -1)
- ((struct symloc *)pst->read_symtab_private)->numsyms =
- capping_symbol_number
- - ((struct symloc *)pst->read_symtab_private)->first_symnum;
- ((struct symloc *)pst->read_symtab_private)->lineno_off =
- first_fun_line_offset;
- first_fun_line_offset = 0;
- pst->n_global_syms =
- objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset);
- pst->n_static_syms =
- objfile->static_psymbols.next - (objfile->static_psymbols.list + pst->statics_offset);
-
- pst->number_of_dependencies = number_dependencies;
- if (number_dependencies)
- {
- pst->dependencies = (struct partial_symtab **)
- obstack_alloc (&objfile->psymbol_obstack,
- number_dependencies * sizeof (struct partial_symtab *));
- memcpy (pst->dependencies, dependency_list,
- number_dependencies * sizeof (struct partial_symtab *));
- }
- else
- pst->dependencies = 0;
-
- for (i = 0; i < num_includes; i++)
- {
- struct partial_symtab *subpst =
- allocate_psymtab (include_list[i], objfile);
-
- subpst->section_offsets = pst->section_offsets;
- subpst->read_symtab_private =
- (char *) obstack_alloc (&objfile->psymbol_obstack,
- sizeof (struct symloc));
- ((struct symloc *)subpst->read_symtab_private)->first_symnum = 0;
- ((struct symloc *)subpst->read_symtab_private)->numsyms = 0;
- subpst->textlow = 0;
- 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 (&objfile->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 = pst->read_symtab;
- }
-
- sort_pst_symbols (pst);
-
- /* 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);
-
- if (num_includes == 0
- && number_dependencies == 0
- && pst->n_global_syms == 0
- && pst->n_static_syms == 0)
- {
- /* Throw away this psymtab, it's empty. We can't deallocate it, since
- it is on the obstack, but we can forget to chain it on the list. */
- /* Empty psymtabs happen as a result of header files which don't have
- any symbols in them. There can be a lot of them. */
-
- discard_psymtab (pst);
-
- /* Indicate that psymtab was thrown away. */
- pst = (struct partial_symtab *)NULL;
- }
- return pst;
-}
-
-static void swap_sym PARAMS ((struct internal_syment *,
- union internal_auxent *, char **, char **,
- unsigned int *,
- struct objfile *));
-
-/* Swap raw symbol at *RAW and put the name in *NAME, the symbol in
- *SYMBOL, the first auxent in *AUX. Advance *RAW and *SYMNUMP over
- the symbol and its auxents. */
-
-static void
-swap_sym (symbol, aux, name, raw, symnump, objfile)
- struct internal_syment *symbol;
- union internal_auxent *aux;
- char **name;
- char **raw;
- unsigned int *symnump;
- struct objfile *objfile;
-{
- bfd_coff_swap_sym_in (objfile->obfd, *raw, symbol);
- if (symbol->n_zeroes)
- {
- /* If it's exactly E_SYMNMLEN characters long it isn't
- '\0'-terminated. */
- if (symbol->n_name[E_SYMNMLEN - 1] != '\0')
- {
- /* FIXME: wastes memory for symbols which we don't end up putting
- into the minimal symbols. */
- char *p;
- p = obstack_alloc (&objfile->psymbol_obstack, E_SYMNMLEN + 1);
- strncpy (p, symbol->n_name, E_SYMNMLEN);
- p[E_SYMNMLEN] = '\0';
- *name = p;
- }
- else
- /* Point to the unswapped name as that persists as long as the
- objfile does. */
- *name = ((struct external_syment *)*raw)->e.e_name;
- }
- else if (symbol->n_sclass & 0x80)
- {
- *name = ((struct coff_symfile_info *)objfile->sym_private)->debugsec
- + symbol->n_offset;
- }
- else
- {
- *name = ((struct coff_symfile_info *)objfile->sym_private)->strtbl
- + symbol->n_offset;
- }
- ++*symnump;
- *raw += coff_data (objfile->obfd)->local_symesz;
- if (symbol->n_numaux > 0)
- {
- bfd_coff_swap_aux_in (objfile->obfd, *raw, symbol->n_type,
- symbol->n_sclass, 0, symbol->n_numaux, aux);
-
- *symnump += symbol->n_numaux;
- *raw += coff_data (objfile->obfd)->local_symesz * symbol->n_numaux;
- }
-}
-
-static void
-scan_xcoff_symtab (section_offsets, objfile)
- struct section_offsets *section_offsets;
- struct objfile *objfile;
-{
- CORE_ADDR toc_offset = 0; /* toc offset value in data section. */
- char *filestring = NULL;
-
- char *namestring;
- int past_first_source_file = 0;
- bfd *abfd;
- asection *bfd_sect;
- unsigned int nsyms;
-
- /* 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;
-
- char *sraw_symbol;
- struct internal_syment symbol;
- union internal_auxent main_aux;
- unsigned int ssymnum;
-
- char *last_csect_name = NULL; /* last seen csect's name and value */
- CORE_ADDR last_csect_val = 0;
- int last_csect_sec = 0;
- int misc_func_recorded = 0; /* true if any misc. function */
- int textlow_not_set = 1;
-
- 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 *));
-
- last_source_file = NULL;
-
- abfd = objfile->obfd;
-
- sraw_symbol = ((struct coff_symfile_info *)objfile->sym_private)->symtbl;
- nsyms = ((struct coff_symfile_info *)objfile->sym_private)->symtbl_num_syms;
- ssymnum = 0;
- while (ssymnum < nsyms)
- {
- int sclass = ((struct external_syment *)sraw_symbol)->e_sclass[0] & 0xff;
- /* This is the type we pass to partial-stab.h. A less kludgy solution
- would be to break out partial-stab.h into its various parts--shuffle
- off the DBXREAD_ONLY stuff to dbxread.c, and make separate
- pstab-norm.h (for most types), pstab-sol.h (for N_SOL), etc. */
- int stype;
-
- QUIT;
-
- switch (sclass)
- {
- case C_EXT:
- case C_HIDEXT:
- {
- /* The CSECT auxent--always the last auxent. */
- union internal_auxent csect_aux;
- unsigned int symnum_before = ssymnum;
-
- swap_sym (&symbol, &main_aux, &namestring, &sraw_symbol,
- &ssymnum, objfile);
- if (symbol.n_numaux > 1)
- {
- bfd_coff_swap_aux_in
- (objfile->obfd,
- sraw_symbol - coff_data(abfd)->local_symesz,
- symbol.n_type,
- symbol.n_sclass,
- symbol.n_numaux - 1,
- symbol.n_numaux,
- &csect_aux);
- }
- else
- csect_aux = main_aux;
-
- /* If symbol name starts with ".$" or "$", ignore it. */
- if (namestring[0] == '$'
- || (namestring[0] == '.' && namestring[1] == '$'))
- break;
-
- switch (csect_aux.x_csect.x_smtyp & 0x7)
- {
- case XTY_SD:
- switch (csect_aux.x_csect.x_smclas)
- {
- case XMC_PR:
- if (last_csect_name)
- {
- /* If no misc. function recorded in the last
- seen csect, enter it as a function. This
- will take care of functions like strcmp()
- compiled by xlc. */
-
- if (!misc_func_recorded)
- {
- RECORD_MINIMAL_SYMBOL
- (last_csect_name, last_csect_val,
- mst_text, last_csect_sec,
- objfile);
- }
-
- if (pst != NULL)
- {
- /* We have to allocate one psymtab for
- each program csect, because their text
- sections need not be adjacent. */
- xcoff_end_psymtab
- (pst, psymtab_include_list, includes_used,
- symnum_before, dependency_list,
- dependencies_used, textlow_not_set);
- includes_used = 0;
- dependencies_used = 0;
- /* Give all psymtabs for this source file the same
- name. */
- pst = xcoff_start_psymtab
- (objfile, section_offsets,
- filestring,
- symnum_before,
- objfile->global_psymbols.next,
- objfile->static_psymbols.next);
- }
- }
- if (namestring && namestring[0] == '.')
- {
- last_csect_name = namestring;
- last_csect_val = symbol.n_value;
- last_csect_sec =
- secnum_to_section (symbol.n_scnum, objfile);
- }
- if (pst != NULL)
- {
- CORE_ADDR highval =
- symbol.n_value + csect_aux.x_csect.x_scnlen.l;
- if (highval > pst->texthigh)
- pst->texthigh = highval;
- if (pst->textlow == 0 || symbol.n_value < pst->textlow)
- pst->textlow = symbol.n_value;
- }
- misc_func_recorded = 0;
- break;
-
- case XMC_RW:
- /* Data variables are recorded in the minimal symbol
- table, except for section symbols. */
- if (*namestring != '.')
- prim_record_minimal_symbol_and_info
- (namestring, symbol.n_value,
- sclass == C_HIDEXT ? mst_file_data : mst_data,
- NULL, secnum_to_section (symbol.n_scnum, objfile),
- NULL, objfile);
- break;
-
- case XMC_TC0:
- if (toc_offset)
- warning ("More than one XMC_TC0 symbol found.");
- toc_offset = symbol.n_value;
-
- /* Make TOC offset relative to start address of section. */
- bfd_sect = secnum_to_bfd_section (symbol.n_scnum, objfile);
- if (bfd_sect)
- toc_offset -= bfd_section_vma (objfile->obfd, bfd_sect);
- break;
-
- case XMC_TC:
- /* These symbols tell us where the TOC entry for a
- variable is, not the variable itself. */
- break;
-
- default:
- break;
- }
- break;
-
- case XTY_LD:
- switch (csect_aux.x_csect.x_smclas)
- {
- case XMC_PR:
- /* A function entry point. */
-
- if (first_fun_line_offset == 0 && symbol.n_numaux > 1)
- first_fun_line_offset =
- main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
- RECORD_MINIMAL_SYMBOL
- (namestring, symbol.n_value,
- sclass == C_HIDEXT ? mst_file_text : mst_text,
- secnum_to_section (symbol.n_scnum, objfile),
- objfile);
- break;
-
- case XMC_GL:
- /* shared library function trampoline code entry
- point. */
-
- /* record trampoline code entries as
- mst_solib_trampoline symbol. When we lookup mst
- symbols, we will choose mst_text over
- mst_solib_trampoline. */
- RECORD_MINIMAL_SYMBOL
- (namestring, symbol.n_value,
- mst_solib_trampoline,
- secnum_to_section (symbol.n_scnum, objfile),
- objfile);
- break;
-
- case XMC_DS:
- /* The symbols often have the same names as
- debug symbols for functions, and confuse
- lookup_symbol. */
- break;
-
- default:
-
- /* xlc puts each variable in a separate csect,
- so we get an XTY_SD for each variable. But
- gcc puts several variables in a csect, so
- that each variable only gets an XTY_LD. We
- still need to record them. This will
- typically be XMC_RW; I suspect XMC_RO and
- XMC_BS might be possible too. */
- if (*namestring != '.')
- prim_record_minimal_symbol_and_info
- (namestring, symbol.n_value,
- sclass == C_HIDEXT ? mst_file_data : mst_data,
- NULL, secnum_to_section (symbol.n_scnum, objfile),
- NULL, objfile);
- break;
- }
- break;
-
- case XTY_CM:
- switch (csect_aux.x_csect.x_smclas)
- {
- case XMC_RW:
- case XMC_BS:
- /* Common variables are recorded in the minimal symbol
- table, except for section symbols. */
- if (*namestring != '.')
- prim_record_minimal_symbol_and_info
- (namestring, symbol.n_value,
- sclass == C_HIDEXT ? mst_file_bss : mst_bss,
- NULL, secnum_to_section (symbol.n_scnum, objfile),
- NULL, objfile);
- break;
- }
- break;
-
- default:
- break;
- }
- }
- break;
- case C_FILE:
- {
- unsigned int symnum_before;
-
- symnum_before = ssymnum;
- swap_sym (&symbol, &main_aux, &namestring, &sraw_symbol,
- &ssymnum, objfile);
-
- /* See if the last csect needs to be recorded. */
-
- if (last_csect_name && !misc_func_recorded)
- {
-
- /* If no misc. function recorded in the last seen csect, enter
- it as a function. This will take care of functions like
- strcmp() compiled by xlc. */
-
- RECORD_MINIMAL_SYMBOL
- (last_csect_name, last_csect_val,
- mst_text, last_csect_sec, objfile);
- }
-
- if (pst)
- {
- xcoff_end_psymtab (pst, psymtab_include_list, includes_used,
- symnum_before, dependency_list,
- dependencies_used, textlow_not_set);
- includes_used = 0;
- dependencies_used = 0;
- }
- first_fun_line_offset = 0;
-
- /* XCOFF, according to the AIX 3.2 documentation, puts the
- filename in cs->c_name. But xlc 1.3.0.2 has decided to
- do things the standard COFF way and put it in the auxent.
- We use the auxent if the symbol is ".file" and an auxent
- exists, otherwise use the symbol itself. */
- if (!strcmp (namestring, ".file") && symbol.n_numaux > 0)
- {
- filestring = coff_getfilename (&main_aux, objfile);
- }
- else
- filestring = namestring;
-
- pst = xcoff_start_psymtab (objfile, section_offsets,
- filestring,
- symnum_before,
- objfile->global_psymbols.next,
- objfile->static_psymbols.next);
- last_csect_name = NULL;
- }
- break;
-
- default:
- {
- static struct complaint msg =
- {"Storage class %d not recognized during scan", 0, 0};
- complain (&msg, sclass);
- }
- /* FALLTHROUGH */
-
- /* C_FCN is .bf and .ef symbols. I think it is sufficient
- to handle only the C_FUN and C_EXT. */
- case C_FCN:
-
- case C_BSTAT:
- case C_ESTAT:
- case C_ARG:
- case C_REGPARM:
- case C_REG:
- case C_TPDEF:
- case C_STRTAG:
- case C_UNTAG:
- case C_ENTAG:
- case C_LABEL:
- case C_NULL:
-
- /* C_EINCL means we are switching back to the main file. But there
- is no reason to care; the only thing we want to know about
- includes is the names of all the included (.h) files. */
- case C_EINCL:
-
- case C_BLOCK:
-
- /* I don't think C_STAT is used in xcoff; C_HIDEXT appears to be
- used instead. */
- case C_STAT:
-
- /* I don't think the name of the common block (as opposed to the
- variables within it) is something which is user visible
- currently. */
- case C_BCOMM:
- case C_ECOMM:
-
- case C_PSYM:
- case C_RPSYM:
-
- /* I think we can ignore C_LSYM; types on xcoff seem to use C_DECL
- so C_LSYM would appear to be only for locals. */
- case C_LSYM:
-
- case C_AUTO:
- case C_RSYM:
- {
- /* We probably could save a few instructions by assuming that
- C_LSYM, C_PSYM, etc., never have auxents. */
- int naux1 =
- ((struct external_syment *)sraw_symbol)->e_numaux[0] + 1;
- ssymnum += naux1;
- sraw_symbol += sizeof (struct external_syment) * naux1;
- }
- break;
-
- case C_BINCL:
- stype = N_SOL;
- goto pstab;
-
- case C_FUN:
- /* The value of the C_FUN is not the address of the function (it
- appears to be the address before linking), but as long as it
- is smaller than the actual address, then find_pc_partial_function
- will use the minimal symbols instead. I hope. */
-
- case C_GSYM:
- case C_ECOML:
- case C_DECL:
- case C_STSYM:
- stype = N_LSYM;
- pstab:;
- swap_sym (&symbol, &main_aux, &namestring, &sraw_symbol,
- &ssymnum, objfile);
-#define CUR_SYMBOL_TYPE stype
-#define CUR_SYMBOL_VALUE symbol.n_value
-
-/* START_PSYMTAB and END_PSYMTAB are never used, because they are only
- called from DBXREAD_ONLY or N_SO code. Likewise for the symnum
- variable. */
-#define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms) 0
-#define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set)\
- do {} while (0)
-/* We have already set the namestring. */
-#define SET_NAMESTRING() /* */
-
-#include "partial-stab.h"
- }
- }
-
- if (pst)
- {
- xcoff_end_psymtab (pst, psymtab_include_list, includes_used,
- ssymnum, dependency_list,
- dependencies_used, textlow_not_set);
- }
-
- /* Record the toc offset value of this symbol table into objfile structure.
- If no XMC_TC0 is found, toc_offset should be zero. Another place to obtain
- this information would be file auxiliary header. */
-
- ((struct coff_symfile_info *) objfile->sym_private)->toc_offset = toc_offset;
-}
-
-/* Return the toc offset value for a given objfile. */
-
-CORE_ADDR
-get_toc_offset (objfile)
- struct objfile *objfile;
-{
- if (objfile)
- return ((struct coff_symfile_info *) objfile->sym_private)->toc_offset;
- return 0;
-}
-
-/* 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 objfile structure.
-
- SECTION_OFFSETS contains offsets relative to which the symbols in the
- various sections are (depending where the sections were actually loaded).
- MAINLINE is true if we are reading the main symbol
- table (as opposed to a shared lib or dynamically loaded file). */
-
-static void
-xcoff_initial_scan (objfile, section_offsets, mainline)
- struct objfile *objfile;
- struct section_offsets *section_offsets;
- int mainline; /* FIXME comments above */
-{
- bfd *abfd;
- int val;
- struct cleanup *back_to;
- int num_symbols; /* # of symbols */
- file_ptr symtab_offset; /* symbol table and */
- file_ptr stringtab_offset; /* string table file offsets */
- struct coff_symfile_info *info;
- char *name;
- unsigned int size;
-
- info = (struct coff_symfile_info *) objfile -> sym_private;
- symfile_bfd = abfd = objfile->obfd;
- name = 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);
-
- if (num_symbols > 0)
- {
- /* Read the string table. */
- init_stringtab (abfd, stringtab_offset, objfile);
-
- /* Read the .debug section, if present. */
- {
- sec_ptr secp;
- bfd_size_type length;
- char *debugsec = NULL;
-
- secp = bfd_get_section_by_name (abfd, ".debug");
- if (secp)
- {
- length = bfd_section_size (abfd, secp);
- if (length)
- {
- debugsec =
- (char *) obstack_alloc (&objfile->symbol_obstack, length);
-
- if (!bfd_get_section_contents (abfd, secp, debugsec,
- (file_ptr) 0, length))
- {
- error ("Error reading .debug section of `%s': %s",
- name, bfd_errmsg (bfd_get_error ()));
- }
- }
- }
- ((struct coff_symfile_info *)objfile->sym_private)->debugsec =
- debugsec;
- }
- }
-
- /* Read the symbols. We keep them in core because we will want to
- access them randomly in read_symbol*. */
- val = bfd_seek (abfd, symtab_offset, SEEK_SET);
- if (val < 0)
- error ("Error reading symbols from %s: %s",
- name, bfd_errmsg (bfd_get_error ()));
- size = coff_data (abfd)->local_symesz * num_symbols;
- ((struct coff_symfile_info *)objfile->sym_private)->symtbl =
- obstack_alloc (&objfile->symbol_obstack, size);
- ((struct coff_symfile_info *)objfile->sym_private)->symtbl_num_syms =
- num_symbols;
-
- val = bfd_read (((struct coff_symfile_info *)objfile->sym_private)->symtbl,
- size, 1, abfd);
- if (val != size)
- perror_with_name ("reading symbol table");
-
- /* If we are reinitializing, or if we have never loaded syms yet, init */
- if (mainline
- || objfile->global_psymbols.size == 0
- || objfile->static_psymbols.size == 0)
- /* I'm not sure how how good num_symbols is; the rule of thumb in
- init_psymbol_list was developed for a.out. On the one hand,
- num_symbols includes auxents. On the other hand, it doesn't
- include N_SLINE. */
- init_psymbol_list (objfile, num_symbols);
-
- free_pending_blocks ();
- back_to = make_cleanup ((make_cleanup_func) really_free_pendings, 0);
-
- init_minimal_symbol_collection ();
- make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0);
-
- /* Now that the symbol table data of the executable file are all in core,
- process them and define symbols accordingly. */
-
- scan_xcoff_symtab (section_offsets, objfile);
-
- /* Install any minimal symbols that have been collected as the current
- minimal symbols for this objfile. */
-
- install_minimal_symbols (objfile);
-
- do_cleanups (back_to);
-}
-
-static struct section_offsets *
-xcoff_symfile_offsets (objfile, addr)
- struct objfile *objfile;
- CORE_ADDR addr;
-{
- struct section_offsets *section_offsets;
- int i;
-
- objfile->num_sections = SECT_OFF_MAX;
- section_offsets = (struct section_offsets *)
- obstack_alloc
- (&objfile -> psymbol_obstack,
- sizeof (struct section_offsets)
- + sizeof (section_offsets->offsets) * objfile->num_sections);
-
- /* syms_from_objfile kindly subtracts from addr the bfd_section_vma
- of the .text section. This strikes me as wrong--whether the
- offset to be applied to symbol reading is relative to the start
- address of the section depends on the symbol format. In any
- event, this whole "addr" concept is pretty broken (it doesn't
- handle any section but .text sensibly), so just ignore the addr
- parameter and use 0. rs6000-nat.c will set the correct section
- offsets via objfile_relocate. */
- for (i = 0; i < objfile->num_sections; ++i)
- ANOFFSET (section_offsets, i) = 0;
-
- return section_offsets;
-}
-
-/* Register our ability to parse symbols for xcoff BFD files. */
-
-static struct sym_fns xcoff_sym_fns =
-{
-
- /* Because the bfd uses coff_flavour, we need to specially kludge
- the flavour. It is possible that coff and xcoff should be merged as
- they do have fundamental similarities (for example, the extra storage
- classes used for stabs could presumably be recognized in any COFF file).
- However, in addition to obvious things like all the csect hair, there are
- some subtler differences between xcoffread.c and coffread.c, notably
- the fact that coffread.c has no need to read in all the symbols, but
- xcoffread.c reads all the symbols and does in fact randomly access them
- (in C_BSTAT and line number processing). */
-
- (enum bfd_flavour)-1,
-
- xcoff_new_init, /* sym_new_init: init anything gbl to entire symtab */
- xcoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
- xcoff_initial_scan, /* sym_read: read a symbol file into symtab */
- xcoff_symfile_finish, /* sym_finish: finished with file, cleanup */
- xcoff_symfile_offsets, /* sym_offsets: xlate offsets ext->int form */
- NULL /* next: pointer to next struct sym_fns */
-};
-
-void
-_initialize_xcoffread ()
-{
- add_symtab_fns(&xcoff_sym_fns);
-
- func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0,
- "<function, no debug info>", NULL);
- TYPE_TARGET_TYPE (func_symbol_type) = builtin_type_int;
- var_symbol_type =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
- "<variable, no debug info>", NULL);
-}
diff --git a/contrib/gdb/gdb/xcoffsolib.c b/contrib/gdb/gdb/xcoffsolib.c
deleted file mode 100644
index 13d8065..0000000
--- a/contrib/gdb/gdb/xcoffsolib.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* Shared library support for RS/6000 (xcoff) object files, for GDB.
- Copyright 1991, 1992 Free Software Foundation.
- 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#if 0
-#include <sys/types.h>
-#include <sys/ldr.h>
-#endif
-
-#include "defs.h"
-#include "bfd.h"
-#include "xcoffsolib.h"
-#include "inferior.h"
-#include "command.h"
-
-/* Hook to relocate symbols at runtime. If gdb is build natively, this
- hook is initialized in by rs6000-nat.c. If not, it is currently left
- NULL and never called. */
-
-void (*xcoff_relocate_symtab_hook) PARAMS ((unsigned int)) = NULL;
-
-#ifdef SOLIB_SYMBOLS_MANUAL
-
-extern struct symtab *current_source_symtab;
-extern int current_source_line;
-
-/* 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;
-{
- char *val;
- struct vmap *vp = vmap;
- struct objfile *obj;
- struct symtab *saved_symtab;
- int saved_line;
-
- int loaded = 0; /* true if any shared obj loaded */
- int matched = 0; /* true if any shared obj matched */
-
- if (arg_string == 0)
- re_comp (".");
- else if (val = (char *) re_comp (arg_string)) {
- error ("Invalid regexp: %s", val);
- }
- if (!vp || !vp->nxt)
- return;
-
- /* save current symbol table and line number, in case they get changed
- in symbol loading process. */
-
- saved_symtab = current_source_symtab;
- saved_line = current_source_line;
-
- /* skip over the first vmap, it is the main program, always loaded. */
- vp = vp->nxt;
-
- for (; vp; vp = vp->nxt) {
-
- if (re_exec (vp->name) || (*vp->member && re_exec (vp->member))) {
-
- matched = 1;
-
- /* if already loaded, continue with the next one. */
- if (vp->loaded) {
-
- printf_unfiltered ("%s%s%s%s: already loaded.\n",
- *vp->member ? "(" : "",
- vp->member,
- *vp->member ? ") " : "",
- vp->name);
- continue;
- }
-
- printf_unfiltered ("Loading %s%s%s%s...",
- *vp->member ? "(" : "",
- vp->member,
- *vp->member ? ") " : "",
- vp->name);
- gdb_flush (gdb_stdout);
-
- /* This is gross and doesn't work. If this code is re-enabled,
- just stick a objfile member into the struct vmap; that's the
- way solib.c (for SunOS/SVR4) does it. */
- obj = lookup_objfile_bfd (vp->bfd);
- if (!obj) {
- warning ("\nObj structure for the shared object not found. Loading failed.");
- continue;
- }
-
- syms_from_objfile (obj, 0, 0, 0);
- new_symfile_objfile (obj, 0, 0);
- vmap_symtab (vp, 0, 0);
- printf_unfiltered ("Done.\n");
- loaded = vp->loaded = 1;
- }
- }
- /* if any shared object is loaded, then misc_func_vector needs sorting. */
- if (loaded) {
-#if 0
- sort_misc_function_vector ();
-#endif
- current_source_symtab = saved_symtab;
- current_source_line = saved_line;
-
- /* Getting new symbols might change our opinion about what is frameless.
- Is this correct?? FIXME. */
-/* reinit_frame_cache(); */
- }
- else if (!matched)
- printf_unfiltered ("No matching shared object found.\n");
-}
-#endif /* SOLIB_SYMBOLS_MANUAL */
-
-/* Return the module name of a given text address. Note that returned buffer
- is not persistent. */
-
-char *
-pc_load_segment_name (addr)
-CORE_ADDR addr;
-{
- static char buffer [BUFSIZ];
- struct vmap *vp = vmap;
-
- buffer [0] = buffer [1] = '\0';
- for (; vp; vp = vp->nxt)
- if (vp->tstart <= addr && addr < vp->tend) {
- if (*vp->member) {
- buffer [0] = '(';
- strcat (&buffer[1], vp->member);
- strcat (buffer, ")");
- }
- strcat (buffer, vp->name);
- return buffer;
- }
- return "(unknown load module)";
-}
-
-static void solib_info PARAMS ((char *, int));
-
-static void
-solib_info (args, from_tty)
- char *args;
- int from_tty;
-{
- struct vmap *vp = vmap;
-
- /* Check for new shared libraries loaded with load (). */
- if (xcoff_relocate_symtab_hook != NULL)
- (*xcoff_relocate_symtab_hook) (inferior_pid);
-
- if (vp == NULL || vp->nxt == NULL)
- {
- printf_unfiltered ("No shared libraries loaded at this time.\n");
- return;
- }
-
- /* Skip over the first vmap, it is the main program, always loaded. */
- vp = vp->nxt;
-
- printf_unfiltered ("\
-Text Range Data Range Syms Shared Object Library\n");
-
- for (; vp != NULL; vp = vp->nxt)
- {
- printf_unfiltered ("0x%08x-0x%08x 0x%08x-0x%08x %s %s%s%s%s\n",
- vp->tstart, vp->tend,
- vp->dstart, vp->dend,
- vp->loaded ? "Yes" : "No ",
- *vp->member ? "(" : "",
- vp->member,
- *vp->member ? ") " : "",
- vp->name);
- }
-}
-
-void
-sharedlibrary_command (args, from_tty)
- char *args;
- int from_tty;
-{
- dont_repeat ();
-
- /* Check for new shared libraries loaded with load (). */
- if (xcoff_relocate_symtab_hook != NULL)
- (*xcoff_relocate_symtab_hook) (inferior_pid);
-
-#ifdef SOLIB_SYMBOLS_MANUAL
- solib_add (args, from_tty, (struct target_ops *)0);
-#endif /* SOLIB_SYMBOLS_MANUAL */
-}
-
-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/contrib/gdb/gdb/xmodem.c b/contrib/gdb/gdb/xmodem.c
deleted file mode 100644
index dd13b87..0000000
--- a/contrib/gdb/gdb/xmodem.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/* XMODEM support for GDB, the GNU debugger.
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "serial.h"
-#include "target.h"
-#include "xmodem.h"
-
-/* These definitions are for xmodem protocol. */
-
-#define SOH 0x01
-#define STX 0x02
-#define ACK 0x06
-#define NAK 0x15
-#define EOT 0x04
-#define CANCEL 0x18
-
-static int blknum; /* XMODEM block number */
-static int crcflag; /* Sez we are using CRC's instead of cksums */
-
-static int
-readchar (desc, timeout)
- serial_t desc;
- int timeout;
-{
- int c;
-
- c = SERIAL_READCHAR (desc, timeout);
-
- if (remote_debug > 0)
- fputc_unfiltered (c, gdb_stderr);
-
- if (c >= 0)
- return c;
-
- if (c == SERIAL_TIMEOUT)
- error ("Timeout reading from remote system.");
-
- perror_with_name ("xmodem.c:readchar()");
-}
-
-#define CRC16 0x1021 /* Generator polynomial (X^16 + X^12 + X^5 + 1) */
-
-static unsigned short *crctab;
-
-/* Call this to init the fast CRC-16 calculation table. */
-
-static void
-crcinit ()
-{
- static int crctab_inited = 0;
- int val;
-
- if (crctab_inited == 1)
- return;
-
- crctab = xmalloc (256 * sizeof (short));
-
- for (val = 0; val <= 255; val++)
- {
- int i;
- unsigned int crc;
-
- crc = val << 8;
-
- for (i = 0; i < 8; ++i)
- {
- crc <<= 1;
-
- if (crc & 0x10000)
- crc ^= CRC16;
- }
-
- crctab [val] = crc;
- }
-
- crctab_inited = 1;
-}
-
-/* Calculate a CRC-16 for the LEN byte message pointed at by P. */
-
-static unsigned short
-docrc (p, len)
- unsigned char *p;
- int len;
-{
- unsigned short crc = 0;
-
- while (len-- > 0)
- crc = (crc << 8) ^ crctab [(crc >> 8) ^ *p++];
-
- return crc;
-}
-
-/* Start up the transmit process. Reset state variables. Wait for receiver to
- send NAK or CRC request. */
-
-int
-xmodem_init_xfer (desc)
- serial_t desc;
-{
- int c;
- int i;
-
- blknum = 1;
- crcflag = 0;
- crcinit ();
-
- for (i = 1; i <= 10; i++)
- {
- c = readchar (desc, 6);
-
- switch (c)
- {
- case 'C':
- crcflag = 1;
- case NAK:
- return 0;
- default:
- fprintf_unfiltered (gdb_stderr, "xmodem_init_xfer: Got unexpected character %c (0%o)\n", c, c);
- continue;
- case CANCEL: /* target aborted load */
- fprintf_unfiltered (gdb_stderr, "Got a CANCEL from the target.\n");
- continue;
- }
- }
- error ("xmodem_init_xfer: Too many unexpected characters.");
-}
-
-/* Take 128 bytes of data and make a packet out of it.
- *
- * Each packet looks like this:
- * +-----+-------+-------+------+-----+
- * | SOH | Seq1. | Seq2. | data | SUM |
- * +-----+-------+-------+------+-----+
- * SOH = 0x01
- * Seq1 = The sequence number.
- * Seq2 = The complement of the sequence number.
- * Data = A 128 bytes of data.
- * SUM = Add the contents of the 128 bytes and use the low-order
- * 8 bits of the result.
- *
- * send_xmodem_packet fills in the XMODEM fields of PACKET and sends it to the
- * remote system. PACKET must be XMODEM_PACKETSIZE bytes long. The data must
- * start 3 bytes after the beginning of the packet to leave room for the
- * XMODEM header. LEN is the length of the data portion of the packet (and
- * must be <= 128 bytes). If it is < 128 bytes, ^Z padding will be added.
- */
-
-void
-xmodem_send_packet (desc, packet, len, hashmark)
- serial_t desc;
- unsigned char *packet;
- int len;
- int hashmark;
-{
- int i;
- int retries;
- int pktlen;
- int datasize;
-
- /* build the packet header */
-
- packet[1] = blknum;
- packet[2] = ~blknum;
-
- blknum++;
-
- if (len <= XMODEM_DATASIZE)
- {
- packet[0] = SOH;
- datasize = XMODEM_DATASIZE;
- }
- else if (len <= XMODEM_1KDATASIZE)
- {
- packet[0] = STX;
- datasize = XMODEM_1KDATASIZE;
- }
- else
- abort (); /* Packet way too large */
-
- /* Add ^Z padding if packet < 128 (or 1024) bytes */
-
- memset (packet + 3 + len, '\026', datasize - len);
-
- if (crcflag)
- {
- int crc;
-
- crc = docrc (packet + 3, datasize);
-
- packet[3 + datasize] = crc >> 8;
- packet[3 + datasize + 1] = crc;
- pktlen = datasize + 5;
- }
- else
- {
- int sum;
-
- sum = 0;
- for (i = 3; i < datasize + 3; i++)
- sum += packet[i];
-
- packet[3 + datasize] = sum; /* add the checksum */
- pktlen = datasize + 4;
- }
-
- for (retries = 3; retries >= 0; retries--)
- {
- int c;
-
- SERIAL_WRITE (desc, packet, pktlen);
-
- c = readchar (desc, 3);
- switch (c)
- {
- case ACK:
- return;
- case NAK:
- if (!hashmark)
- continue;
- putchar_unfiltered ('-');
- gdb_flush (gdb_stdout);
- continue;
- case CANCEL:
- error ("xmodem_send_packet: Transfer aborted by receiver.");
- default:
- fprintf_unfiltered (gdb_stderr, "xmodem_send_packet: Got unexpected character %c (0%o)\n", c, c);
- continue;
- }
- }
-
- SERIAL_WRITE (desc, "\004", 1); /* Send an EOT */
-
- error ("xmodem_send_packet: Excessive retries.");
-}
-
-/* Finish off the transfer. Send out the EOT, and wait for an ACK. */
-
-void
-xmodem_finish_xfer (desc)
- serial_t desc;
-{
- int retries;
-
- for (retries = 10; retries >= 0; retries--)
- {
- int c;
-
- SERIAL_WRITE (desc, "\004", 1); /* Send an EOT */
-
- c = readchar (desc, 3);
- switch (c)
- {
- case ACK:
- return;
- case NAK:
- continue;
- case CANCEL:
- error ("xmodem_finish_xfer: Transfer aborted by receiver.");
- default:
- fprintf_unfiltered (gdb_stderr, "xmodem_send_packet: Got unexpected character %c (0%o)\n", c, c);
- continue;
- }
- }
-
- error ("xmodem_finish_xfer: Excessive retries.");
-}
diff --git a/contrib/gdb/gdb/xmodem.h b/contrib/gdb/gdb/xmodem.h
deleted file mode 100644
index 0303612..0000000
--- a/contrib/gdb/gdb/xmodem.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* XMODEM support for GDB, the GNU debugger.
- Copyright 1995 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-int xmodem_init_xfer PARAMS ((serial_t desc));
-void send_xmodem_packet PARAMS ((serial_t desc, unsigned char *packet, int len,
- int hashmark));
-void xmodem_finish_xfer PARAMS ((serial_t desc));
-
-#define XMODEM_DATASIZE 128 /* The data size is ALWAYS 128 */
-#define XMODEM_1KDATASIZE 1024 /* Unless it's 1024!!! */
-#define XMODEM_PACKETSIZE 133 /* data + packet headers and crc */
-#define XMODEM_1KPACKETSIZE 1024 + 5 /* data + packet headers and crc */
-#define XMODEM_DATAOFFSET 3 /* Offset to start of actual data */
diff --git a/contrib/gdb/readline/doc/ChangeLog b/contrib/gdb/readline/doc/ChangeLog
deleted file mode 100644
index 2520a85..0000000
--- a/contrib/gdb/readline/doc/ChangeLog
+++ /dev/null
@@ -1,12 +0,0 @@
-Wed Sep 20 12:57:29 1995 Ian Lance Taylor <ian@cygnus.com>
-
- * Makefile.in (maintainer-clean): New synonym for realclean.
-
-Tue Feb 2 11:40:04 1993 Roland H. Pesch (pesch@fowanton.cygnus.com)
-
- * Makefile.in: configurable (and useable) Makefile template
- * Makefile: removed, replaced with configurable Makefile.in
- * texindex.c texinfo.tex: remove, replacing w/refs to tools
- elsewhere in distribution tree
- * configure.in: pro forma configure stub
- * ChangeLog: new file
diff --git a/contrib/gdb/readline/doc/Makefile.in b/contrib/gdb/readline/doc/Makefile.in
deleted file mode 100644
index 451b9fe..0000000
--- a/contrib/gdb/readline/doc/Makefile.in
+++ /dev/null
@@ -1,94 +0,0 @@
-## 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 maintainer-clean: 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/contrib/gdb/readline/doc/configure.in b/contrib/gdb/readline/doc/configure.in
deleted file mode 100644
index c082c56..0000000
--- a/contrib/gdb/readline/doc/configure.in
+++ /dev/null
@@ -1,8 +0,0 @@
-srcname="READLINE doc"
-srctrigger=rlman.texinfo
-# per-host:
-
-# per-target:
-
-files=""
-links=""
diff --git a/contrib/gdb/readline/doc/hist.texinfo b/contrib/gdb/readline/doc/hist.texinfo
deleted file mode 100644
index 6292738..0000000
--- a/contrib/gdb/readline/doc/hist.texinfo
+++ /dev/null
@@ -1,106 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@comment %**start of header (This is for running Texinfo on a region.)
-@setfilename history.info
-@settitle GNU Readline Library
-@comment %**end of header (This is for running Texinfo on a region.)
-@synindex vr fn
-@setchapternewpage odd
-
-@ifinfo
-This document describes the GNU History library, a programming tool that
-provides a consistent user interface for recalling lines of previously
-typed input.
-
-Copyright (C) 1988, 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
-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
-
-@titlepage
-@sp 10
-@center @titlefont{GNU History Library}
-@center Brian Fox
-@center Free Software Foundation
-@center Version 1.1
-@center April 1991
-
-@c Include the Distribution inside the titlepage environment so
-@c that headings are turned off.
-
-@page
-
-This document describes the GNU History library, a programming tool that
-provides a consistent user interface for recalling lines of previously
-typed input.
-
-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.
-
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
-@end titlepage
-
-@ifinfo
-@node Top
-@top GNU History Library
-
-This document describes the GNU History library, a programming tool that
-provides a consistent user interface for recalling lines of previously
-typed input.
-
-@menu
-* Using History Interactively:: GNU History User's Manual.
-* Programming with GNU History:: GNU History Programmer's Manual.
-* Concept Index:: Index of concepts described in this manual.
-* Function and Variable Index:: Index of externally visible functions
- and variables.
-@end menu
-@end ifinfo
-
-@include hsuser.texinfo
-@include hstech.texinfo
-
-@node Concept Index
-@appendix Concept Index
-@printindex cp
-
-@node Function and Variable Index
-@appendix Function and Variable Index
-@printindex vr
-@contents
-
-@bye
diff --git a/contrib/gdb/readline/doc/hstech.texinfo b/contrib/gdb/readline/doc/hstech.texinfo
deleted file mode 100644
index c3fe3f6..0000000
--- a/contrib/gdb/readline/doc/hstech.texinfo
+++ /dev/null
@@ -1,311 +0,0 @@
-@ignore
-This file documents the user interface to the GNU History library.
-
-Copyright (C) 1988, 1991 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.
-
-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 Programming with GNU History
-@chapter Programming with GNU History
-
-This chapter describes how to interface the GNU History Library with
-programs that you write. It should be considered a technical guide.
-For information on the interactive use of GNU History, @pxref{Using
-History Interactively}.
-
-@menu
-* Introduction to History:: What is the GNU History library for?
-* History Storage:: How information is stored.
-* History Functions:: Functions that you can use.
-* History Variables:: Variables that control behaviour.
-* History Programming Example:: Example of using the GNU History Library.
-@end menu
-
-@node Introduction to History
-@section 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.
-
-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 @code{Csh}.
-
-If the programmer desires, he can use the Readline library, which
-includes some history manipulation by default, and has the added
-advantage of Emacs style command line editing.
-
-@node History Storage
-@section History Storage
-
-@example
-typedef struct _hist_entry @{
- char *line;
- char *data;
-@} HIST_ENTRY;
-@end example
-
-@node History Functions
-@section History Functions
-
-This section describes the calling sequence for the various functions
-present in GNU History.
-
-@defun {void using_history} ()
-Begin a session in which the history functions might be used. This
-just initializes the interactive variables.
-@end defun
-
-@defun {void add_history} (char *string)
-Place @var{string} at the end of the history list. The associated data
-field (if any) is set to @code{NULL}.
-@end defun
-
-@defun {int where_history} ()
-Returns the number which says what history element we are now looking
-at.
-@end defun
-
-@defun {int history_set_pos} (int pos)
-Set the position in the history list to @var{pos}.
-@end defun
-
-@defun {int history_search_pos} (char *string, int direction, int pos)
-Search for @var{string} in the history list, starting at @var{pos}, an
-absolute index into the list. @var{direction}, if negative, says to search
-backwards from @var{pos}, else forwards. Returns the absolute index of
-the history element where @var{string} was found, or -1 otherwise.
-@end defun
-
-@defun {HIST_ENTRY *remove_history} ();
-Remove history element @var{which} from the history. The removed
-element is returned to you so you can free the line, data,
-and containing structure.
-@end defun
-
-@defun {void stifle_history} (int max)
-Stifle the history list, remembering only @var{max} number of entries.
-@end defun
-
-@defun {int unstifle_history} ();
-Stop stifling the history. This returns the previous amount the
-history was stifled by. The value is positive if the history was
-stifled, negative if it wasn't.
-@end defun
-
-@defun {int read_history} (char *filename)
-Add the contents of @var{filename} to the history list, a line at a
-time. If @var{filename} is @code{NULL}, then read from
-@file{~/.history}. Returns 0 if successful, or errno if not.
-@end defun
-
-@defun {int read_history_range} (char *filename, int from, int to)
-Read a range of lines from @var{filename}, adding them to the history list.
-Start reading at the @var{from}'th line and end at the @var{to}'th. If
-@var{from} is zero, start at the beginning. If @var{to} is less than
-@var{from}, then read until the end of the file. If @var{filename} is
-@code{NULL}, then read from @file{~/.history}. Returns 0 if successful,
-or @code{errno} if not.
-@end defun
-
-@defun {int write_history} (char *filename)
-Append the current history to @var{filename}. If @var{filename} is
-@code{NULL}, then append the history list to @file{~/.history}. Values
-returned are as in @code{read_history ()}.
-@end defun
-
-@defun {int append_history} (int nelements, char *filename)
-Append @var{nelement} entries to @var{filename}. The entries appended
-are from the end of the list minus @var{nelements} up to the end of the
-list.
-@end defun
-
-@defun {HIST_ENTRY *replace_history_entry} ()
-Make the history entry at @var{which} have @var{line} and @var{data}.
-This returns the old entry so you can dispose of the data. In the case
-of an invalid @var{which}, a @code{NULL} pointer is returned.
-@end defun
-
-@defun {HIST_ENTRY *current_history} ()
-Return the history entry at the current position, as determined by
-@code{history_offset}. If there is no entry there, return a @code{NULL}
-pointer.
-@end defun
-
-@defun {HIST_ENTRY *previous_history} ()
-Back up @var{history_offset} to the previous history entry, and return a
-pointer to that entry. If there is no previous entry, return a
-@code{NULL} pointer.
-@end defun
-
-@defun {HIST_ENTRY *next_history} ()
-Move @code{history_offset} forward to the next history entry, and return
-the a pointer to that entry. If there is no next entry, return a
-@code{NULL} pointer.
-@end defun
-
-@defun {HIST_ENTRY **history_list} ()
-Return a @code{NULL} terminated array of @code{HIST_ENTRY} which is the
-current input history. Element 0 of this list is the beginning of time.
-If there is no history, return @code{NULL}.
-@end defun
-
-@defun {int history_search} (char *string, int direction)
-Search the history for @var{string}, starting at @code{history_offset}.
-If @var{direction} < 0, then the search is through previous entries,
-else through subsequent. If @var{string} is found, then
-@code{current_history ()} is the history entry, and the value of this
-function is the offset in the line of that history entry that the
-@var{string} was found in. Otherwise, nothing is changed, and a -1 is
-returned.
-@end defun
-
-@defun {int history_expand} (char *string, char **output)
-Expand @var{string}, placing the result into @var{output}, a pointer
-to a string. Returns:
-@table @code
-@item 0
-If no expansions took place (or, if the only change in
-the text was the de-slashifying of the history expansion
-character),
-@item 1
-if expansions did take place, or
-@item -1
-if there was an error in expansion.
-@end table
-
-If an error ocurred in expansion, then @var{output} contains a descriptive
-error message.
-@end defun
-
-@defun {char *history_arg_extract} (int first, int last, char *string)
-Extract a string segment consisting of the @var{first} through @var{last}
-arguments present in @var{string}. Arguments are broken up as in
-the GNU Bash shell.
-@end defun
-
-@defun {int history_total_bytes} ();
-Return the number of bytes that the primary history entries are using.
-This just adds up the lengths of @code{the_history->lines}.
-@end defun
-
-@node History Variables
-@section History Variables
-
-This section describes the variables in GNU History that are externally
-visible.
-
-@defvar {int history_base}
-For convenience only. You set this when interpreting history commands.
-It is the logical offset of the first history element.
-@end defvar
-
-@node History Programming Example
-@section History Programming Example
-
-The following snippet of code demonstrates simple use of the GNU History
-Library.
-
-@smallexample
-main ()
-@{
- char line[1024], *t;
- int done = 0;
-
- line[0] = 0;
-
- while (!done)
- @{
- fprintf (stdout, "history%% ");
- t = gets (line);
-
- if (!t)
- strcpy (line, "quit");
-
- if (line[0])
- @{
- char *expansion;
- int result;
-
- using_history ();
-
- result = history_expand (line, &expansion);
- strcpy (line, expansion);
- free (expansion);
- if (result)
- fprintf (stderr, "%s\n", line);
-
- if (result < 0)
- continue;
-
- add_history (line);
- @}
-
- if (strcmp (line, "quit") == 0) done = 1;
- if (strcmp (line, "save") == 0) write_history (0);
- if (strcmp (line, "read") == 0) read_history (0);
- if (strcmp (line, "list") == 0)
- @{
- register HIST_ENTRY **the_list = history_list ();
- register int i;
-
- if (the_list)
- for (i = 0; the_list[i]; i++)
- fprintf (stdout, "%d: %s\n",
- i + history_base, the_list[i]->line);
- @}
- if (strncmp (line, "delete", strlen ("delete")) == 0)
- @{
- int which;
- if ((sscanf (line + strlen ("delete"), "%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");
- @}
- @}
- @}
-@}
-@end smallexample
-
-
-
diff --git a/contrib/gdb/readline/doc/hsuser.texinfo b/contrib/gdb/readline/doc/hsuser.texinfo
deleted file mode 100644
index cda0a68..0000000
--- a/contrib/gdb/readline/doc/hsuser.texinfo
+++ /dev/null
@@ -1,153 +0,0 @@
-@ignore
-This file documents the user interface to the GNU History library.
-
-Copyright (C) 1988, 1991 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.
-
-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 Using History Interactively
-@chapter Using History Interactively
-
-This chapter describes how to use the GNU History Library interactively,
-from a user's standpoint. It should be considered a user's guide. For
-information on using the GNU History Library in your own programs,
-@pxref{Programming with GNU History}.
-
-@menu
-* History Interaction:: What it feels like using History as a user.
-@end menu
-
-@node History Interaction
-@section 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 the sytax
-that you use to manipulate the history information.
-
-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
-@subsection 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... @key{=} or @key{(}.
-
-@item @code{!!}
-Refer to the previous command. This is a synonym for @code{!-1}.
-
-@item @code{!n}
-Refer to command line @var{n}.
-
-@item @code{!-n}
-Refer to the command line @var{n} lines back.
-
-@item @code{!string}
-Refer to the most recent command starting with @var{string}.
-
-@item @code{!?string}[@code{?}]
-Refer to the most recent command containing @var{string}.
-
-@end table
-
-@node Word Designators
-@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 @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{?string?} search.
-
-@item x-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 @code{1-$}.
-It is not an error to use @key{*} if there is just one word in the event.
-The empty string is returned in that case.
-
-@end table
-
-@node Modifiers
-@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 @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.
-@end table
diff --git a/contrib/gdb/readline/doc/inc-hist.texi b/contrib/gdb/readline/doc/inc-hist.texi
deleted file mode 100644
index 9cdde40..0000000
--- a/contrib/gdb/readline/doc/inc-hist.texi
+++ /dev/null
@@ -1,159 +0,0 @@
-@ignore
-This file is completely identical to hsuser.texinfo, except that it has the
-reference to the programming manual removed. There are definately better ways
-to do this!
-
-This file documents the user interface to the GNU History library.
-
-Copyright (C) 1988, 1991 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.
-
-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 Using History Interactively
-@appendix Using History Interactively
-
-This chapter describes how to use the GNU History Library interactively,
-from a user's standpoint.
-
-@menu
-* History Interaction:: What it feels like using History as a user.
-@end menu
-
-@node History Interaction
-@section History Interaction
-@cindex expansion
-
-The History library provides a history expansion feature similar
-to the history expansion in @code{csh}. The following text describes the
-syntax you use to manipulate history information.
-
-History expansion takes two parts. In the first part, determine
-which line from the previous history will be used for substitution.
-This line is called the @dfn{event}.
-In the second part, select portions of that line for inclusion into the
-current line. These portions are called @dfn{words}.
-@value{GDBN} breaks the line into words in the same
-way that the Bash shell does, so that several English (or Unix) words
-surrounded by quotes are considered 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
-@subsection Event Designators
-@cindex event designators
-
-An @dfn{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... @key{=} or @key{(}.
-
-@item @code{!!}
-Refer to the previous command. This is a synonym for @code{!-1}.
-
-@item @code{!n}
-Refer to command line @var{n}.
-
-@item @code{!-n}
-Refer to the command line @var{n} lines back.
-
-@item @code{!string}
-Refer to the most recent command starting with @var{string}.
-
-@item @code{!?string}[@code{?}]
-Refer to the most recent command containing @var{string}.
-
-@end table
-
-@node Word Designators
-@subsection Word Designators
-
-A @key{:} separates the event designator from the @dfn{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 @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{?string?} search.
-
-@item x-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 @code{1-$}.
-It is not an error to use @key{*} if there is just one word in the event.
-The empty string is returned in that case.
-
-@end table
-
-@node Modifiers
-@subsection Modifiers
-
-After the optional word designator, you can add a sequence of one or more
-of the following @dfn{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.
-@c
-@c FIXME: If it doesn't belong here, let's put it where it does.
-@c
-@c so it technically isn't a word designator and doesn't belong in
-@c 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.
-@end table
diff --git a/contrib/gdb/readline/doc/rlman.texinfo b/contrib/gdb/readline/doc/rlman.texinfo
deleted file mode 100644
index f2e7fb6..0000000
--- a/contrib/gdb/readline/doc/rlman.texinfo
+++ /dev/null
@@ -1,103 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@comment %**start of header (This is for running Texinfo on a region.)
-@setfilename readline.info
-@settitle GNU Readline Library
-@comment %**end of header (This is for running Texinfo on a region.)
-@synindex vr fn
-@setchapternewpage odd
-
-@ifinfo
-This document describes the GNU Readline Library, a utility which aids
-in the consistency of user interface across discrete programs that need
-to provide a command line interface.
-
-Copyright (C) 1988, 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
-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
-
-@titlepage
-@sp 10
-@center @titlefont{GNU Readline Library}
-@center Brian Fox
-@center Free Software Foundation
-@center Version 1.1
-@center April 1991
-
-@page
-This document describes the GNU Readline Library, a utility which aids
-in the consistency of user interface across discrete programs that need
-to provide a command line interface.
-
-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.
-
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
-@end titlepage
-
-@ifinfo
-@node Top
-@top GNU Readline Library
-
-This document describes the GNU Readline Library, a utility which aids
-in the consistency of user interface across discrete programs that need
-to provide a command line interface.
-
-@menu
-* Command Line Editing:: GNU Readline User's Manual.
-* Programming with GNU Readline:: GNU Readline Programmer's Manual.
-* Concept Index:: Index of concepts described in this manual.
-* Function and Variable Index:: Index of externally visible functions
- and variables.
-@end menu
-@end ifinfo
-
-@include rluser.texinfo
-@include rltech.texinfo
-
-@node Concept Index
-@unnumbered Concept Index
-@printindex cp
-
-@node Function and Variable Index
-@unnumbered Function and Variable Index
-@printindex fn
-
-@contents
-@bye
-
diff --git a/contrib/gdb/readline/doc/rltech.texinfo b/contrib/gdb/readline/doc/rltech.texinfo
deleted file mode 100644
index 2048b7c..0000000
--- a/contrib/gdb/readline/doc/rltech.texinfo
+++ /dev/null
@@ -1,1012 +0,0 @@
-@comment %**start of header (This is for running Texinfo on a region.)
-@setfilename rltech.info
-@comment %**end of header (This is for running Texinfo on a region.)
-@setchapternewpage odd
-
-@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
-
-@node Programming with GNU Readline
-@chapter Programming with GNU Readline
-
-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.
-@end menu
-
-@node Default Behaviour
-@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 for @code{readline}
-in ANSI C is
-
-@example
-@code{char *readline (char *@var{prompt});}
-@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 @code{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
-
-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 it
-is rare than someone has a burning need to reuse a blank line. Here is
-a function which usefully replaces the standard @code{gets ()} library
-function:
-
-@example
-/* A static variable for holding the line. */
-static char *line_read = (char *)NULL;
-
-/* Read a string, and return a pointer to it. Returns NULL on EOF. */
-char *
-do_gets ()
-@{
- /* If the buffer has already been allocated, return the memory
- to the free pool. */
- if (line_read != (char *)NULL)
- @{
- free (line_read);
- line_read = (char *)NULL;
- @}
-
- /* Get a line from the user. */
- line_read = readline ("");
-
- /* If the line has any text in it, save it on the history. */
- if (line_read && *line_read)
- add_history (line_read);
-
- return (line_read);
-@}
-@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
-
-This code should be executed once at the start of your program; you
-might write a function called @code{initialize_readline ()} which
-performs this and other desired initializations, such as installing
-custom completers, etc.
-
-@node Custom Functions
-@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
-@subsection The Function Type
-
-For the sake of readabilty, we declare a new type of object, called
-@dfn{Function}. A @code{Function} is a C language function which
-returns an @code{int}. The type declaration for @code{Function} is:
-
-@noindent
-@code{typedef int Function ();}
-
-The reason for declaring this new type is to make it easier to write
-code describing 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
-@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 the keystroke @key{Meta-Rubout} to the function
-@emph{descriptively} named @code{backward-kill-word}. You, as the
-programmer, should bind the functions you write to descriptive names as
-well. Readline provides a function for doing 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
-@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 {Keymap 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 {Keymap rl_copy_keymap} (Keymap map)
-Return a new keymap which is a copy of @var{map}.
-@end defun
-
-@defun {Keymap 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
-@subsection Binding Keys
-
-You associate keys with functions through the keymap. Here are
-functions for doing that.
-
-@defun {int 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 {int 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 {int 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 {int 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
-
-@defun rl_generic_bind (int type, char *keyseq, char *data, Keymap map)
-Bind the key sequence represented by the string @var{keyseq} to the arbitrary
-pointer @var{data}. @var{type} says what kind of data is pointed to by
-@var{data}; right now this can be a function (@code{ISFUNC}), a macro
-(@code{ISMACR}), or a keymap (@code{ISKMAP}). This makes new keymaps as
-necessary. The initial place to do bindings is in @var{map}.
-@end defun
-
-@node Function Writing
-@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 (int count, int 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
-@subsection Allowing Undoing
-
-Supporting the undo command is a painless thing to do, and makes your
-functions 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 should 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
-
-Here is a function which changes lowercase characters to the uppercase
-equivalents, and uppercase characters to the lowercase equivalents. If
-this function was bound to @samp{M-c}, then typing @samp{M-c} would
-change the case of the character under point. Typing @samp{10 M-c}
-would change the case of the following 10 characters, leaving the cursor on
-the last character changed.
-
-@example
-/* Invert the case of the COUNT following characters. */
-invert_case_line (count, key)
- int count, key;
-@{
- register int start, end;
-
- start = rl_point;
-
- if (count < 0)
- @{
- direction = -1;
- count = -count;
- @}
- else
- direction = 1;
-
- /* Find the end of the range to modify. */
- end = start + (count * direction);
-
- /* Force it to be within range. */
- if (end > rl_end)
- end = rl_end;
- else if (end < 0)
- end = -1;
-
- if (start > end)
- @{
- int temp = start;
- start = end;
- end = temp;
- @}
-
- if (start == end)
- return;
-
- /* Tell readline that we are modifying the line, so save the undo
- information. */
- rl_modifying (start, end);
-
- for (; start != end; start += direction)
- @{
- if (uppercase_p (rl_line_buffer[start]))
- rl_line_buffer[start] = to_lower (rl_line_buffer[start]);
- else if (lowercase_p (rl_line_buffer[start]))
- rl_line_buffer[start] = to_upper (rl_line_buffer[start]);
- @}
- /* Move point to on top of the last character changed. */
- rl_point = end - direction;
-@}
-@end example
-
-@node Custom Completers
-@section Custom Completers
-
-Typically, a program that reads commands from the user has a way of
-disambiguating 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
-* How Completing Works:: The logic used to do completion.
-* Completion Functions:: Functions provided by Readline.
-* Completion Variables:: Variables which control completion.
-* A Short Completion Example:: An example of writing completer subroutines.
-@end menu
-
-@node How Completing Works
-@subsection How Completing Works
-
-In order to complete some text, the full list of possible completions
-must be available. That is to say, it is not possible to accurately
-expand a partial word without knowing what all of the possible words
-that make sense in that context are. The GNU Readline library provides
-the user interface to completion, and additionally, two of the most common
-completion functions; filename and username. For completing other types
-of text, you must write your own completion function. This section
-describes exactly what those functions must do, and provides an example
-function.
-
-There are three major functions used to perform completion:
-
-@enumerate
-@item
-The user-interface function @code{rl_complete ()}. This function is
-called interactively with the same calling conventions as other
-functions in readline intended for interactive use; i.e. @var{count},
-and @var{invoking-key}. It isolates the word to be completed and calls
-@code{completion_matches ()} to generate a list of possible completions.
-It then either lists the possible completions or actually performs the
-completion, depending on which behaviour is desired.
-
-@item
-The internal function @code{completion_matches ()} uses your
-@dfn{generator} function to generate the list of possible matches, and
-then returns the array of these matches. You should place the address
-of your generator function in @code{rl_completion_entry_function}.
-
-@item
-The generator function is called repeatedly from
-@code{completion_matches ()}, returning a string each time. The
-arguments to the generator function are @var{text} and @var{state}.
-@var{text} is the partial word to be completed. @var{state} is zero the
-first time the function is called, and a positive non-zero integer for
-each subsequent call. When the generator function returns @code{(char
-*)NULL} this signals @code{completion_matches ()} that there are no more
-possibilities left.
-
-@end enumerate
-
-@defun rl_complete (int ignore, int invoking_key)
-Complete the word at or before point. You have supplied the function
-that does the initial simple matching selection algorithm (see
-@code{completion_matches ()}). The default is to do filename completion.
-@end defun
-
-Note that @code{rl_complete ()} has the identical calling conventions as
-any other key-invokable function; this is because by default it is bound
-to the @samp{TAB} key.
-
-@defvar {Function *rl_completion_entry_function}
-This is a pointer to the generator function for @code{completion_matches
-()}. If the value of @code{rl_completion_entry_function} is
-@code{(Function *)NULL} then the default filename generator function is
-used, namely @code{filename_entry_function ()}.
-@end defvar
-
-@node Completion Functions
-@subsection Completion Functions
-
-Here is the complete list of callable completion functions present in
-Readline.
-
-@defun rl_complete_internal (int what_to_do)
-Complete the word at or before point. @var{what_to_do} says what to do
-with the completion. A value of @samp{?} means list the possible
-completions. @samp{TAB} means do standard completion. @samp{*} means
-insert all of the possible completions.
-@end defun
-
-@defun rl_complete (int ignore, int invoking_key)
-Complete the word at or before point. You have supplied the function
-that does the initial simple matching selection algorithm (see
-@code{completion_matches ()}). The default is to do filename
-completion. This just calls @code{rl_complete_internal ()} with an
-argument of @samp{TAB}.
-@end defun
-
-@defun rl_possible_completions ()
-List the possible completions. See description of @code{rl_complete
-()}. This just calls @code{rl_complete_internal ()} with an argument of
-@samp{?}.
-@end defun
-
-@defun {char **completion_matches} (char *text, char *(*entry_function) ())
-Returns an array of @code{(char *)} which is a list of completions for
-@var{text}. If there are no completions, returns @code{(char **)NULL}.
-The first entry in the returned array is the substitution for @var{text}.
-The remaining entries are the possible completions. The array is
-terminated with a @code{NULL} pointer.
-
-@var{entry_function} is a function of two args, and returns a
-@code{(char *)}. The first argument is @var{text}. The second is a
-state argument; it is zero on the first call, and non-zero on subsequent
-calls. It returns a @code{NULL} pointer to the caller when there are
-no more matches.
-@end defun
-
-@defun {char *filename_completion_function} (char *text, int state)
-A generator function for filename completion in the general case. Note
-that completion in the Bash shell is a little different because of all
-the pathnames that must be followed when looking up the completion for a
-command.
-@end defun
-
-@defun {char *username_completion_function} (char *text, int state)
-A completion generator for usernames. @var{text} contains a partial
-username preceded by a random character (usually @samp{~}).
-@end defun
-
-@node Completion Variables
-@subsection Completion Variables
-
-@defvar {Function *rl_completion_entry_function}
-A pointer to the generator function for @code{completion_matches ()}.
-@code{NULL} means to use @code{filename_entry_function ()}, the default
-filename completer.
-@end defvar
-
-@defvar {Function *rl_attempted_completion_function}
-A pointer to an alternative function to create matches.
-The function is called with @var{text}, @var{start}, and @var{end}.
-@var{start} and @var{end} are indices in @code{rl_line_buffer} saying
-what the boundaries of @var{text} are. If this function exists and
-returns @code{NULL} then @code{rl_complete ()} will call the value of
-@code{rl_completion_entry_function} to generate matches, otherwise the
-array of strings returned will be used.
-@end defvar
-
-@defvar {int rl_completion_query_items}
-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. The default value is 100.
-@end defvar
-
-@defvar {char *rl_basic_word_break_characters}
-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 Bash shell, i.e. " \t\n\"\\'`@@$><=;|&@{(".
-@end defvar
-
-@defvar {char *rl_completer_word_break_characters}
-The list of characters that signal a break between words for
-@code{rl_complete_internal ()}. The default list is the contents of
-@code{rl_basic_word_break_characters}.
-@end defvar
-
-@defvar {char *rl_special_prefixes}
-The list of characters that are word break characters, but should be
-left in @var{text} when it is passed to the completion function.
-Programs can use this to help determine what kind of completing to do.
-@end defvar
-
-@defvar {int rl_ignore_completion_duplicates}
-If non-zero, then disallow duplicates in the matches. Default is 1.
-@end defvar
-
-@defvar {int rl_filename_completion_desired}
-Non-zero means that the results of the matches are to be treated as
-filenames. This is @emph{always} zero on entry, and can only be changed
-within a completion entry generator function.
-@end defvar
-
-@defvar {Function *rl_ignore_some_completions_function}
-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 @code{NULL} terminated array of @code{(char *)} known as
-@var{matches} in the code. The 1st element (@code{matches[0]}) is the
-maximal substring that is common to all matches. This function can
-re-arrange the list of matches as required, but each deleted element of
-the array must be @code{free()}'d.
-@end defvar
-
-@node A Short Completion Example
-@subsection A Short Completion Example
-
-Here is a small application demonstrating the use of the GNU Readline
-library. It is called @code{fileman}, and the source code resides in
-@file{readline/examples/fileman.c}. This sample application provides
-completion of command names, line editing features, and access to the
-history list.
-
-@page
-@smallexample
-/* fileman.c -- A tiny application which demonstrates how to use the
- GNU Readline library. This application interactively allows users
- to manipulate files and their modes. */
-
-#include <stdio.h>
-#include <readline/readline.h>
-#include <readline/history.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/errno.h>
-
-/* The names of functions that actually do the manipulation. */
-int com_list (), com_view (), com_rename (), com_stat (), com_pwd ();
-int com_delete (), com_help (), com_cd (), com_quit ();
-
-/* A structure which contains information on the commands this program
- can understand. */
-
-typedef struct @{
- char *name; /* User printable name of the function. */
- Function *func; /* Function to call to do the job. */
- char *doc; /* Documentation for this function. */
-@} COMMAND;
-
-COMMAND commands[] = @{
- @{ "cd", com_cd, "Change to directory DIR" @},
- @{ "delete", com_delete, "Delete FILE" @},
- @{ "help", com_help, "Display this text" @},
- @{ "?", com_help, "Synonym for `help'" @},
- @{ "list", com_list, "List files in DIR" @},
- @{ "ls", com_list, "Synonym for `list'" @},
- @{ "pwd", com_pwd, "Print the current working directory" @},
- @{ "quit", com_quit, "Quit using Fileman" @},
- @{ "rename", com_rename, "Rename FILE to NEWNAME" @},
- @{ "stat", com_stat, "Print out statistics on FILE" @},
- @{ "view", com_view, "View the contents of FILE" @},
- @{ (char *)NULL, (Function *)NULL, (char *)NULL @}
-@};
-
-/* The name of this program, as taken from argv[0]. */
-char *progname;
-
-/* When non-zero, this global means the user is done using this program. */
-int done = 0;
-@page
-main (argc, argv)
- int argc;
- char **argv;
-@{
- progname = argv[0];
-
- initialize_readline (); /* Bind our completer. */
-
- /* Loop reading and executing lines until the user quits. */
- while (!done)
- @{
- char *line;
-
- line = readline ("FileMan: ");
-
- if (!line)
- @{
- done = 1; /* Encountered EOF at top level. */
- @}
- else
- @{
- /* Remove leading and trailing whitespace from the line.
- Then, if there is anything left, add it to the history list
- and execute it. */
- stripwhite (line);
-
- if (*line)
- @{
- add_history (line);
- execute_line (line);
- @}
- @}
-
- if (line)
- free (line);
- @}
- exit (0);
-@}
-
-/* Execute a command line. */
-execute_line (line)
- char *line;
-@{
- register int i;
- COMMAND *find_command (), *command;
- char *word;
-
- /* Isolate the command word. */
- i = 0;
- while (line[i] && !whitespace (line[i]))
- i++;
-
- word = line;
-
- if (line[i])
- line[i++] = '\0';
-
- command = find_command (word);
-
- if (!command)
- @{
- fprintf (stderr, "%s: No such command for FileMan.\n", word);
- return;
- @}
-
- /* Get argument to command, if any. */
- while (whitespace (line[i]))
- i++;
-
- word = line + i;
-
- /* Call the function. */
- (*(command->func)) (word);
-@}
-
-/* Look up NAME as the name of a command, and return a pointer to that
- command. Return a NULL pointer if NAME isn't a command name. */
-COMMAND *
-find_command (name)
- char *name;
-@{
- register int i;
-
- for (i = 0; commands[i].name; i++)
- if (strcmp (name, commands[i].name) == 0)
- return (&commands[i]);
-
- return ((COMMAND *)NULL);
-@}
-
-/* Strip whitespace from the start and end of STRING. */
-stripwhite (string)
- char *string;
-@{
- register int i = 0;
-
- while (whitespace (string[i]))
- i++;
-
- if (i)
- strcpy (string, string + i);
-
- i = strlen (string) - 1;
-
- while (i > 0 && whitespace (string[i]))
- i--;
-
- string[++i] = '\0';
-@}
-@page
-/* **************************************************************** */
-/* */
-/* Interface to Readline Completion */
-/* */
-/* **************************************************************** */
-
-/* Tell the GNU Readline library how to complete. We want to try to complete
- on command names if this is the first word in the line, or on filenames
- if not. */
-initialize_readline ()
-@{
- char **fileman_completion ();
-
- /* Allow conditional parsing of the ~/.inputrc file. */
- rl_readline_name = "FileMan";
-
- /* Tell the completer that we want a crack first. */
- rl_attempted_completion_function = (Function *)fileman_completion;
-@}
-
-/* Attempt to complete on the contents of TEXT. START and END show the
- region of TEXT that contains the word to complete. We can use the
- entire line in case we want to do some simple parsing. Return the
- array of matches, or NULL if there aren't any. */
-char **
-fileman_completion (text, start, end)
- char *text;
- int start, end;
-@{
- char **matches;
- char *command_generator ();
-
- matches = (char **)NULL;
-
- /* If this word is at the start of the line, then it is a command
- to complete. Otherwise it is the name of a file in the current
- directory. */
- if (start == 0)
- matches = completion_matches (text, command_generator);
-
- return (matches);
-@}
-
-/* Generator function for command completion. STATE lets us know whether
- to start from scratch; without any state (i.e. STATE == 0), then we
- start at the top of the list. */
-char *
-command_generator (text, state)
- char *text;
- int state;
-@{
- static int list_index, len;
- char *name;
-
- /* If this is a new word to complete, initialize now. This includes
- saving the length of TEXT for efficiency, and initializing the index
- variable to 0. */
- if (!state)
- @{
- list_index = 0;
- len = strlen (text);
- @}
-
- /* Return the next name which partially matches from the command list. */
- while (name = commands[list_index].name)
- @{
- list_index++;
-
- if (strncmp (name, text, len) == 0)
- return (name);
- @}
-
- /* If no names matched, then return NULL. */
- return ((char *)NULL);
-@}
-@page
-/* **************************************************************** */
-/* */
-/* FileMan Commands */
-/* */
-/* **************************************************************** */
-
-/* String to pass to system (). This is for the LIST, VIEW and RENAME
- commands. */
-static char syscom[1024];
-
-/* List the file(s) named in arg. */
-com_list (arg)
- char *arg;
-@{
- if (!arg)
- arg = "*";
-
- sprintf (syscom, "ls -FClg %s", arg);
- system (syscom);
-@}
-
-com_view (arg)
- char *arg;
-@{
- if (!valid_argument ("view", arg))
- return;
-
- sprintf (syscom, "cat %s | more", arg);
- system (syscom);
-@}
-
-com_rename (arg)
- char *arg;
-@{
- too_dangerous ("rename");
-@}
-
-com_stat (arg)
- char *arg;
-@{
- struct stat finfo;
-
- if (!valid_argument ("stat", arg))
- return;
-
- if (stat (arg, &finfo) == -1)
- @{
- perror (arg);
- return;
- @}
-
- printf ("Statistics for `%s':\n", arg);
-
- printf ("%s has %d link%s, and is %d bytes in length.\n", arg,
- finfo.st_nlink, (finfo.st_nlink == 1) ? "" : "s", finfo.st_size);
- printf (" Created on: %s", ctime (&finfo.st_ctime));
- printf (" Last access at: %s", ctime (&finfo.st_atime));
- printf ("Last modified at: %s", ctime (&finfo.st_mtime));
-@}
-
-com_delete (arg)
- char *arg;
-@{
- too_dangerous ("delete");
-@}
-
-/* Print out help for ARG, or for all of the commands if ARG is
- not present. */
-com_help (arg)
- char *arg;
-@{
- register int i;
- int printed = 0;
-
- for (i = 0; commands[i].name; i++)
- @{
- if (!*arg || (strcmp (arg, commands[i].name) == 0))
- @{
- printf ("%s\t\t%s.\n", commands[i].name, commands[i].doc);
- printed++;
- @}
- @}
-
- if (!printed)
- @{
- printf ("No commands match `%s'. Possibilties are:\n", arg);
-
- for (i = 0; commands[i].name; i++)
- @{
- /* Print in six columns. */
- if (printed == 6)
- @{
- printed = 0;
- printf ("\n");
- @}
-
- printf ("%s\t", commands[i].name);
- printed++;
- @}
-
- if (printed)
- printf ("\n");
- @}
-@}
-
-/* Change to the directory ARG. */
-com_cd (arg)
- char *arg;
-@{
- if (chdir (arg) == -1)
- perror (arg);
-
- com_pwd ("");
-@}
-
-/* Print out the current working directory. */
-com_pwd (ignore)
- char *ignore;
-@{
- char dir[1024];
-
- (void) getwd (dir);
-
- printf ("Current directory is %s\n", dir);
-@}
-
-/* The user wishes to quit using this program. Just set DONE non-zero. */
-com_quit (arg)
- char *arg;
-@{
- done = 1;
-@}
-
-/* Function which tells you that you can't do this. */
-too_dangerous (caller)
- char *caller;
-@{
- fprintf (stderr,
- "%s: Too dangerous for me to distribute. Write it yourself.\n",
- caller);
-@}
-
-/* Return non-zero if ARG is a valid argument for CALLER, else print
- an error message and return zero. */
-int
-valid_argument (caller, arg)
- char *caller, *arg;
-@{
- if (!arg || !*arg)
- @{
- fprintf (stderr, "%s: Argument required.\n", caller);
- return (0);
- @}
-
- return (1);
-@}
-@end smallexample
diff --git a/contrib/gdb/readline/doc/rluser.texinfo b/contrib/gdb/readline/doc/rluser.texinfo
deleted file mode 100644
index da11111..0000000
--- a/contrib/gdb/readline/doc/rluser.texinfo
+++ /dev/null
@@ -1,566 +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 Free Software Foundation, Inc.
-
-Authored 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
-@appendix Command Line Editing
-
-This text describes GNU's command line editing interface.
-
-@menu
-* Introduction and Notation:: Notation used in this text.
-* Readline Interaction:: The minimum set of commands for editing a line.
-* Readline Init File:: Customizing Readline from a user's view.
-@end menu
-
-@node Introduction and Notation
-@section Introduction to Line Editing
-
-The following paragraphs describe the notation we use to represent
-keystrokes.
-
-The text @key{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 @key{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, the identical keystroke
-can be generated by typing @key{ESC} @i{first}, and then typing @key{k}.
-Either process is known as @dfn{metafying} the @key{k} key.
-
-The text @key{M-C-k} is read as `Meta-Control-k' and describes the
-character produced by @dfn{metafying} @key{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
-@section Readline Interaction
-@cindex interaction, readline
-
-Often during an interactive session you 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{RET}. You do not have to be at the
-end of the line to press @key{RET}; the entire line is accepted
-regardless of the location of the cursor within the line.
-
-@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
-@subsection Readline 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 @key{C-b} to move the cursor to the left, and then
-correct your mistake. Aftwerwards, you can move the cursor to the right
-with @key{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 @key{C-b}
-Move back one character.
-@item @key{C-f}
-Move forward one character.
-@item @key{DEL}
-Delete the character to the left of the cursor.
-@item @key{C-d}
-Delete the character underneath the cursor.
-@item @w{Printing characters}
-Insert itself into the line at the cursor.
-@item @key{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
-@subsection Readline 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 @key{C-b}, @key{C-f},
-@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
-about the line.
-
-@table @key
-@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 @key{C-f} moves forward a character, while @key{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
-@subsection Readline 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 @key
-@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-DEL
-Kill from the cursor to the start of the 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
-@key{M-DEL} because the word boundaries differ.
-
-@end table
-
-And, here is how to @dfn{yank} the text back into the line.
-
-@table @key
-@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 @key{C-y} or @key{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
-@subsection Readline 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 @key{M--} @key{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 (@key{-}), 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 @key{C-d} command an argument of 10, you could type @key{M-1 0 C-d}.
-
-
-@node Readline Init File
-@section Readline Init File
-
-Although the Readline library comes with a set of @sc{gnu} 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, the
-@file{~/.inputrc} file is read, and the keybindings are set.
-
-In addition, the @key{C-x C-r} command re-reads this init file, thus
-incorporating any changes that you might have made to it.
-
-@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
-@subsection Readline Init Syntax
-
-There are only four constructs allowed in the @file{~/.inputrc}
-file:
-
-@table @asis
-@item Variable Settings
-You can change the state of a few variables in Readline. You do this by
-using the @code{set} command within the init file. Here is how you
-would specify that you wish to use @code{vi} line editing commands:
-
-@example
-set editing-mode vi
-@end example
-
-Right now, there are only a few variables which can be set; so few in
-fact, that we just iterate them here:
-
-@table @code
-
-@item editing-mode
-@vindex editing-mode
-The @code{editing-mode} variable controls which editing mode you are
-using. By default, @sc{gnu} Readline starts up in Emacs editing mode, where
-the keystrokes are most similar to Emacs. This variable can either be
-set to @code{emacs} or @code{vi}.
-
-@item horizontal-scroll-mode
-@vindex horizontal-scroll-mode
-This variable can either be set to @code{On} or @code{Off}. Setting it
-to @code{On} means that the text of the lines that you edit will scroll
-horizontally on a single screen line when they are larger than the width
-of the screen, instead of wrapping onto a new screen line. By default,
-this variable is set to @code{Off}.
-
-@item mark-modified-lines
-@vindex mark-modified-lines
-This variable when set to @code{On}, says to display an asterisk
-(@samp{*}) at the starts of history lines which have been modified.
-This variable is off by default.
-
-@item prefer-visible-bell
-@vindex prefer-visible-bell
-If this variable is set to @code{On} it means to use a visible bell if
-one is available, rather than simply ringing the terminal bell. By
-default, the value is @code{Off}.
-@end table
-
-@item Key Bindings
-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. The name of the key
-can be expressed in different ways, depending on which is most
-comfortable for you.
-
-@table @asis
-@item @w{@var{keyname}: @var{function-name} or @var{macro}}
-@var{keyname} is the name of a key spelled out in English. For example:
-@example
-Control-u: universal-argument
-Meta-Rubout: backward-kill-word
-Control-o: ">&output"
-@end example
-
-In the above example, @key{C-u} is bound to the function
-@code{universal-argument}, and @key{C-o} is bound to run the macro
-expressed on the right hand side (that is, to insert the text
-@samp{>&output} into the line).
-
-@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
-@var{keyseq} differs from @var{keyname} above in that strings denoting
-an entire key sequence can be specified. Simply place the key sequence
-in double quotes. @sc{gnu} Emacs style key escapes can be used, as in the
-following example:
-
-@example
-"\C-u": universal-argument
-"\C-x\C-r": re-read-init-file
-"\e[11~": "Function Key 1"
-@end example
-
-In the above example, @key{C-u} is bound to the function
-@code{universal-argument} (just as it was in the first example),
-@key{C-x C-r} is bound to the function @code{re-read-init-file}, and
-@key{ESC [ 1 1 ~} is bound to insert the text @samp{Function Key 1}.
-
-@end table
-@end table
-
-@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
-
-@need 2000
-@node Commands For Moving
-@subsubsection Commands For Moving
-
-@ftable @code
-@item beginning-of-line (@key{C-a})
-Move to the start of the current line.
-
-@item end-of-line (@key{C-e})
-Move to the end of the line.
-
-@item forward-char (@key{C-f})
-Move forward a character.
-
-@item backward-char (@key{C-b})
-Move back a character.
-
-@item forward-word (@key{M-f})
-Move forward to the end of the next word.
-
-@item backward-word (@key{M-b})
-Move back to the start of this, or the previous, word.
-
-@item clear-screen (@key{C-l})
-Clear the screen leaving the current line at the top of the screen.
-
-@end ftable
-
-@need 2000
-@node Commands For History
-@subsubsection Commands For Manipulating The History
-
-@ftable @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 (@key{C-p})
-Move `up' through the history list.
-
-@item next-history (@key{C-n})
-Move `down' through the history list.
-
-@item beginning-of-history (@key{M-<})
-Move to the first line in the history.
-
-@item end-of-history (@key{M->})
-Move to the end of the input history, i.e., the line you are entering.
-
-@item reverse-search-history (@key{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 (@key{C-s})
-Search forward starting at the current line and moving `down' through
-the the history as necessary.
-
-@end ftable
-
-@need 2000
-@node Commands For Text
-@subsubsection Commands For Changing Text
-
-@ftable @code
-@item delete-char (@key{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 @key{C-d}, then return EOF.
-
-@item backward-delete-char (Rubout)
-Delete the character behind the cursor. A numeric argument says to kill
-the characters instead of deleting them.
-
-@item quoted-insert (@key{C-q}, @key{C-v})
-Add the next character that you type to the line verbatim. This is
-how to insert things like @key{C-q} for example.
-
-@item tab-insert (@key{M-TAB})
-Insert a tab character.
-
-@item self-insert (a, b, A, 1, !, ...)
-Insert yourself.
-
-@item transpose-chars (@key{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 arguments don't work.
-
-@item transpose-words (@key{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 (@key{M-u})
-Uppercase all letters in the current (or following) word. With a
-negative argument, do the previous word, but do not move point.
-
-@item downcase-word (@key{M-l})
-Lowercase all letters in the current (or following) word. With a
-negative argument, do the previous word, but do not move point.
-
-@item capitalize-word (@key{M-c})
-Uppercase the first letter in the current (or following) word. With a
-negative argument, do the previous word, but do not move point.
-
-@end ftable
-
-@need 2000
-@node Commands For Killing
-@subsubsection Killing And Yanking
-
-@ftable @code
-@item kill-line (@key{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 (@key{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 (@key{M-DEL})
-Kill the word behind the cursor.
-
-@item unix-line-discard (@key{C-u})
-Kill the whole line the way @key{C-u} used to in Unix line input.
-The killed text is saved on the kill-ring.
-
-@item unix-word-rubout (@key{C-w})
-Kill the word the way @key{C-w} used to in Unix line input.
-The killed text is saved on the kill-ring. This is different than
-backward-kill-word because the word boundaries differ.
-
-@item yank (@key{C-y})
-Yank the top of the kill ring into the buffer at point.
-
-@item yank-pop (@key{M-y})
-Rotate the kill-ring, and yank the new top. You can only do this if
-the prior command is yank or yank-pop.
-@end ftable
-
-@need 2000
-@node Numeric Arguments
-@subsubsection Specifying Numeric Arguments
-
-@ftable @code
-
-@item digit-argument (@key{M-0}, @key{M-1}, ... @key{M--})
-Add this digit to the argument already accumulating, or start a new
-argument. @key{M--} starts a negative argument.
-
-@item universal-argument ()
-Do what @key{C-u} does in @sc{gnu} Emacs. By default, this is not bound.
-@end ftable
-
-
-@need 2000
-@node Commands For Completion
-@subsubsection Letting Readline Type For You
-
-@ftable @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 ftable
-
-@need 2000
-@node Miscellaneous Commands
-@subsubsection Some Miscellaneous Commands
-
-@ftable @code
-
-@item re-read-init-file (@key{C-x} @key{C-r})
-Read in the contents of your @file{~/.inputrc} file, and incorporate
-any bindings found there.
-
-@item abort (@key{C-g})
-Stop running the current editing command.
-
-@ignore
-@c I have no idea what this means, and can't figure it out by
-@c experiment, and can't find it in the readline source.
-@c doc@cygnus.com, 20may1993.
-@item do-uppercase-version (@key{M-a}, @key{M-b}, ...)
-Run the command that is bound to your uppercase brother.
-@end ignore
-
-@item prefix-meta (ESC)
-Make the next character that you type be metafied. This is for people
-without a meta key. Typing @key{ESC f} is equivalent to typing
-@key{M-f}.
-
-@item undo (@key{C-_})
-Incremental undo, separately remembered for each line.
-
-@item revert-line (@key{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 ftable
-
-@need 2000
-@node Readline vi Mode
-@subsection Readline @code{vi} Mode
-
-@cindex @code{vi} style command editing
-@kindex toggle-editing-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 @sc{gnu} Emacs and @code{vi}
-editing modes, use the command @key{M-C-j} (toggle-editing-mode).
-
-When you enter a line in @code{vi} mode, you are already placed in `insertion'
-mode, as if you had typed an `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 `k', and following
-lines with `j', and so forth.
-
OpenPOWER on IntegriCloud